diff --git a/internal/pipe/aur/aur.go b/internal/pipe/aur/aur.go index 981d8138ea4..87c6453be32 100644 --- a/internal/pipe/aur/aur.go +++ b/internal/pipe/aur/aur.go @@ -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 } } diff --git a/internal/pipe/aur/aur_test.go b/internal/pipe/aur/aur_test.go index 7769f808485..7d3fa5143cc 100644 --- a/internal/pipe/aur/aur_test.go +++ b/internal/pipe/aur/aur_test.go @@ -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, "") diff --git a/internal/pipe/aur/testdata/TestRunPipeWrappedInDirectory.pkgbuild.golden b/internal/pipe/aur/testdata/TestRunPipeWrappedInDirectory.pkgbuild.golden new file mode 100644 index 00000000000..bc47b61fa52 --- /dev/null +++ b/internal/pipe/aur/testdata/TestRunPipeWrappedInDirectory.pkgbuild.golden @@ -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" +} diff --git a/internal/pipe/aur/testdata/TestRunPipeWrappedInDirectory.srcinfo.golden b/internal/pipe/aur/testdata/TestRunPipeWrappedInDirectory.srcinfo.golden new file mode 100644 index 00000000000..2fbfd40671e --- /dev/null +++ b/internal/pipe/aur/testdata/TestRunPipeWrappedInDirectory.srcinfo.golden @@ -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