Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aur): support wrap_in_directory #4502

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/pipe/aur/aur.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
Loading