From c17ff3b9663b2fe0e4ceef56446dd1af3019daf5 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 9 Mar 2022 09:50:57 -0300 Subject: [PATCH] fix(aur): improve yay caching (#2965) Signed-off-by: Carlos A Becker --- internal/pipe/aur/aur.go | 1 + internal/pipe/aur/aur_test.go | 7 ++++++- internal/pipe/aur/testdata/TestFullAur.golden | 10 +++++----- .../TestFullPipe/default-gitlab.pkgbuild.golden | 2 +- .../aur/testdata/TestFullPipe/default.pkgbuild.golden | 2 +- .../TestFullPipe/with-more-opts.pkgbuild.golden | 2 +- internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden | 10 +++++----- .../testdata/TestRunPipeBinaryRelease.pkgbuild.golden | 2 +- internal/pipe/aur/tmpl.go | 3 ++- 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/internal/pipe/aur/aur.go b/internal/pipe/aur/aur.go index b045ca237..a1598141f 100644 --- a/internal/pipe/aur/aur.go +++ b/internal/pipe/aur/aur.go @@ -312,6 +312,7 @@ func dataFor(ctx *context.Context, cfg config.AUR, cl client.Client, artifacts [ DownloadURL: url, SHA256: sum, Arch: toPkgBuildArch(art.Goarch + art.Goarm), + Format: art.ExtraOr(artifact.ExtraFormat, "").(string), } result.ReleasePackages = append(result.ReleasePackages, releasePackage) result.Arches = append(result.Arches, releasePackage.Arch) diff --git a/internal/pipe/aur/aur_test.go b/internal/pipe/aur/aur_test.go index 949d79e33..89055f452 100644 --- a/internal/pipe/aur/aur_test.go +++ b/internal/pipe/aur/aur_test.go @@ -64,26 +64,31 @@ func createTemplateData() templateData { Arch: "x86_64", DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67", + Format: "tar.gz", }, { Arch: "armv6h", DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_Arm6.tar.gz", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67", + Format: "tar.gz", }, { Arch: "aarch64", DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_Arm64.tar.gz", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67", + Format: "tar.gz", }, { Arch: "i686", DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_386.tar.gz", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67", + Format: "tar.gz", }, { Arch: "armv7h", DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_arm7.tar.gz", SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67", + Format: "tar.gz", }, }, } @@ -108,7 +113,7 @@ func TestAurSimple(t *testing.T) { require.Contains(t, pkg, `# Contributor: Beltrano `) require.Contains(t, pkg, `pkgname='test-bin'`) require.Contains(t, pkg, `url='https://example.com'`) - require.Contains(t, pkg, `source_x86_64=('https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz')`) + require.Contains(t, pkg, `source_x86_64=('${pkgname}_${pkgver}_x86_64.tar.gz::https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz')`) require.Contains(t, pkg, `sha256sums_x86_64=('1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67')`) require.Contains(t, pkg, `pkgver=0.1.3`) } diff --git a/internal/pipe/aur/testdata/TestFullAur.golden b/internal/pipe/aur/testdata/TestFullAur.golden index c1ce5ff55..ec859b63d 100644 --- a/internal/pipe/aur/testdata/TestFullAur.golden +++ b/internal/pipe/aur/testdata/TestFullAur.golden @@ -16,19 +16,19 @@ conflicts=('nope') depends=('nope') optdepends=('nfpm') -source_x86_64=('https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz') +source_x86_64=('${pkgname}_${pkgver}_x86_64.tar.gz::https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz') sha256sums_x86_64=('1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67') -source_armv6h=('https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_Arm6.tar.gz') +source_armv6h=('${pkgname}_${pkgver}_armv6h.tar.gz::https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_Arm6.tar.gz') sha256sums_armv6h=('1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67') -source_aarch64=('https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_Arm64.tar.gz') +source_aarch64=('${pkgname}_${pkgver}_aarch64.tar.gz::https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_Arm64.tar.gz') sha256sums_aarch64=('1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67') -source_i686=('https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_386.tar.gz') +source_i686=('${pkgname}_${pkgver}_i686.tar.gz::https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_386.tar.gz') sha256sums_i686=('1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67') -source_armv7h=('https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_arm7.tar.gz') +source_armv7h=('${pkgname}_${pkgver}_armv7h.tar.gz::https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_arm7.tar.gz') sha256sums_armv7h=('1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67') package() { diff --git a/internal/pipe/aur/testdata/TestFullPipe/default-gitlab.pkgbuild.golden b/internal/pipe/aur/testdata/TestFullPipe/default-gitlab.pkgbuild.golden index 10543e1fb..592087023 100644 --- a/internal/pipe/aur/testdata/TestFullPipe/default-gitlab.pkgbuild.golden +++ b/internal/pipe/aur/testdata/TestFullPipe/default-gitlab.pkgbuild.golden @@ -10,7 +10,7 @@ license=('MIT') provides=('default-gitlab') conflicts=('default-gitlab') -source_x86_64=('https://dummyhost/download/v1.0.1-foo/bin.tar.gz') +source_x86_64=('${pkgname}_${pkgver}_x86_64.tar.gz::https://dummyhost/download/v1.0.1-foo/bin.tar.gz') sha256sums_x86_64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') package() { diff --git a/internal/pipe/aur/testdata/TestFullPipe/default.pkgbuild.golden b/internal/pipe/aur/testdata/TestFullPipe/default.pkgbuild.golden index ead70e190..397f45581 100644 --- a/internal/pipe/aur/testdata/TestFullPipe/default.pkgbuild.golden +++ b/internal/pipe/aur/testdata/TestFullPipe/default.pkgbuild.golden @@ -10,7 +10,7 @@ license=('MIT') provides=('default') conflicts=('default') -source_x86_64=('https://dummyhost/download/v1.0.1-foo/bin.tar.gz') +source_x86_64=('${pkgname}_${pkgver}_x86_64.tar.gz::https://dummyhost/download/v1.0.1-foo/bin.tar.gz') sha256sums_x86_64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') package() { diff --git a/internal/pipe/aur/testdata/TestFullPipe/with-more-opts.pkgbuild.golden b/internal/pipe/aur/testdata/TestFullPipe/with-more-opts.pkgbuild.golden index c7a3348ea..ad4fad1e7 100644 --- a/internal/pipe/aur/testdata/TestFullPipe/with-more-opts.pkgbuild.golden +++ b/internal/pipe/aur/testdata/TestFullPipe/with-more-opts.pkgbuild.golden @@ -14,7 +14,7 @@ conflicts=('libcurl' 'cvs' 'blah') depends=('curl' 'bash') optdepends=('wget: stuff' 'foo: bar') -source_x86_64=('https://dummyhost/download/v1.0.1-foo/bin.tar.gz') +source_x86_64=('${pkgname}_${pkgver}_x86_64.tar.gz::https://dummyhost/download/v1.0.1-foo/bin.tar.gz') sha256sums_x86_64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') package() { diff --git a/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden b/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden index ecf34aaaf..16526bb20 100644 --- a/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden +++ b/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden @@ -10,19 +10,19 @@ license=('MIT') provides=('foo') conflicts=('foo') -source_aarch64=('https://dummyhost/download/v1.0.1/arm64.tar.gz') +source_aarch64=('${pkgname}_${pkgver}_aarch64.tar.gz::https://dummyhost/download/v1.0.1/arm64.tar.gz') sha256sums_aarch64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') -source_armv6h=('https://dummyhost/download/v1.0.1/armv6.tar.gz') +source_armv6h=('${pkgname}_${pkgver}_armv6h.tar.gz::https://dummyhost/download/v1.0.1/armv6.tar.gz') sha256sums_armv6h=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') -source_armv7h=('https://dummyhost/download/v1.0.1/armv7.tar.gz') +source_armv7h=('${pkgname}_${pkgver}_armv7h.tar.gz::https://dummyhost/download/v1.0.1/armv7.tar.gz') sha256sums_armv7h=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') -source_i686=('https://dummyhost/download/v1.0.1/bin.tar.gz') +source_i686=('${pkgname}_${pkgver}_i686.tar.gz::https://dummyhost/download/v1.0.1/bin.tar.gz') sha256sums_i686=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') -source_x86_64=('https://dummyhost/download/v1.0.1/bin.tar.gz') +source_x86_64=('${pkgname}_${pkgver}_x86_64.tar.gz::https://dummyhost/download/v1.0.1/bin.tar.gz') sha256sums_x86_64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') package() { diff --git a/internal/pipe/aur/testdata/TestRunPipeBinaryRelease.pkgbuild.golden b/internal/pipe/aur/testdata/TestRunPipeBinaryRelease.pkgbuild.golden index c8a311aec..1d9287558 100644 --- a/internal/pipe/aur/testdata/TestRunPipeBinaryRelease.pkgbuild.golden +++ b/internal/pipe/aur/testdata/TestRunPipeBinaryRelease.pkgbuild.golden @@ -10,7 +10,7 @@ license=('') provides=('foo') conflicts=('foo') -source_x86_64=('https://dummyhost/download/v1.2.1/foo_linux_amd64') +source_x86_64=('${pkgname}_${pkgver}_x86_64.binary::https://dummyhost/download/v1.2.1/foo_linux_amd64') sha256sums_x86_64=('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855') package() { diff --git a/internal/pipe/aur/tmpl.go b/internal/pipe/aur/tmpl.go index afb97112d..5e756432f 100644 --- a/internal/pipe/aur/tmpl.go +++ b/internal/pipe/aur/tmpl.go @@ -22,6 +22,7 @@ type releasePackage struct { DownloadURL string SHA256 string Arch string + Format string } const aurTemplateData = `# This file was generated by GoReleaser. DO NOT EDIT. @@ -54,7 +55,7 @@ optdepends=({{ pkgArray . }}) {{- end }} {{ range .ReleasePackages -}} -source_{{ .Arch }}=('{{ .DownloadURL }}') +source_{{ .Arch }}=('${pkgname}_${pkgver}_{{ .Arch }}.{{ .Format }}::{{ .DownloadURL }}') sha256sums_{{ .Arch }}=('{{ .SHA256 }}') {{ printf "" }} {{ end }}