Skip to content

Commit

Permalink
fix(aur): support wrap_in_directory (#4502)
Browse files Browse the repository at this point in the history
closes #4500

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Dec 26, 2023
1 parent 27f0e33 commit 8586878
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/pipe/aur/aur.go
Expand Up @@ -140,8 +140,10 @@ func doRun(ctx *context.Context, aur config.AUR, cl client.ReleaseURLTemplater)
bin := artifact.ExtraOr(*art, artifact.ExtraBinary, art.Name)
pkg = fmt.Sprintf(`install -Dm755 "./%s "${pkgdir}/usr/bin/%s"`, name, bin)
case artifact.UploadableArchive:
folder := artifact.ExtraOr(*art, artifact.ExtraWrappedIn, ".")
for _, bin := range artifact.ExtraOr(*art, artifact.ExtraBinaries, []string{}) {
pkg = fmt.Sprintf(`install -Dm755 "./%s" "${pkgdir}/usr/bin/%[1]s"`, bin)
path := filepath.ToSlash(filepath.Clean(filepath.Join(folder, bin)))
pkg = fmt.Sprintf(`install -Dm755 "./%s" "${pkgdir}/usr/bin/%s"`, path, bin)
break
}
}
Expand Down
47 changes: 47 additions & 0 deletions internal/pipe/aur/aur_test.go
Expand Up @@ -493,6 +493,53 @@ func TestRunPipeNoBuilds(t *testing.T) {
require.False(t, client.CreatedFile)
}

func TestRunPipeWrappedInDirectory(t *testing.T) {
url := testlib.GitMakeBareRepository(t)
key := testlib.MakeNewSSHKey(t, "")
folder := t.TempDir()
ctx := testctx.NewWithCfg(
config.Project{
Dist: folder,
ProjectName: "foo",
AURs: []config.AUR{{
GitURL: url,
PrivateKey: key,
}},
},
testctx.WithVersion("1.2.1"),
testctx.WithCurrentTag("v1.2.1"),
testctx.WithSemver(1, 2, 1, ""),
)

path := filepath.Join(folder, "dist/foo_linux_amd64/foo")
ctx.Artifacts.Add(&artifact.Artifact{
Name: "foo.tar.gz",
Path: path,
Goos: "linux",
Goarch: "amd64",
Goamd64: "v1",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
artifact.ExtraID: "foo",
artifact.ExtraFormat: "tar.gz",
artifact.ExtraBinaries: []string{"foo"},
artifact.ExtraWrappedIn: "foo",
},
})

require.NoError(t, Pipe{}.Default(ctx))
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
f, err := os.Create(path)
require.NoError(t, err)
require.NoError(t, f.Close())

client := client.NewMock()
require.NoError(t, runAll(ctx, client))
require.NoError(t, Pipe{}.Publish(ctx))

requireEqualRepoFiles(t, folder, ".", "foo", url)
}

func TestRunPipeBinaryRelease(t *testing.T) {
url := testlib.GitMakeBareRepository(t)
key := testlib.MakeNewSSHKey(t, "")
Expand Down
@@ -0,0 +1,18 @@
# This file was generated by GoReleaser. DO NOT EDIT.

pkgname='foo-bin'
pkgver=1.2.1
pkgrel=1
pkgdesc=''
url=''
arch=('x86_64')
license=('')
provides=('foo')
conflicts=('foo')

source_x86_64=("${pkgname}_${pkgver}_x86_64.tar.gz::https://dummyhost/download/v1.2.1/foo.tar.gz")
sha256sums_x86_64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')

package() {
install -Dm755 "./foo/foo" "${pkgdir}/usr/bin/foo"
}
@@ -0,0 +1,11 @@
pkgbase = foo-bin
pkgdesc =
pkgver = 1.2.1
pkgrel = 1
conflicts = foo
provides = foo
arch = x86_64
source_x86_64 = https://dummyhost/download/v1.2.1/foo.tar.gz
sha256sums_x86_64 = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

pkgname = foo-bin

0 comments on commit 8586878

Please sign in to comment.