From a42c8ae706c2218c2284ba8750d77ace75a18455 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 5 Oct 2022 09:42:17 -0300 Subject: [PATCH] feat: aur backup (#3366) closes #3353 --- internal/pipe/aur/aur.go | 1 + internal/pipe/aur/aur_test.go | 4 ++++ internal/pipe/aur/testdata/TestFullAur.golden | 1 + internal/pipe/aur/tmpl.go | 4 ++++ pkg/config/config.go | 1 + www/docs/customization/aur.md | 8 ++++++++ 6 files changed, 19 insertions(+) diff --git a/internal/pipe/aur/aur.go b/internal/pipe/aur/aur.go index a4d13366141..d8bb6a5be9e 100644 --- a/internal/pipe/aur/aur.go +++ b/internal/pipe/aur/aur.go @@ -292,6 +292,7 @@ func dataFor(ctx *context.Context, cfg config.AUR, cl client.Client, artifacts [ Contributors: cfg.Contributors, Provides: cfg.Provides, Conflicts: cfg.Conflicts, + Backup: cfg.Backup, Depends: cfg.Depends, OptDepends: cfg.OptDepends, Package: cfg.Package, diff --git a/internal/pipe/aur/aur_test.go b/internal/pipe/aur/aur_test.go index 9b108fddbba..54cb1a24bcc 100644 --- a/internal/pipe/aur/aur_test.go +++ b/internal/pipe/aur/aur_test.go @@ -33,6 +33,10 @@ func createTemplateData() templateData { Rel: "1", Provides: []string{"test"}, OptDepends: []string{"nfpm"}, + Backup: []string{ + "/etc/mypkg.conf", + "/var/share/mypkg", + }, Maintainers: []string{ "Ciclano ", "Cicrano ", diff --git a/internal/pipe/aur/testdata/TestFullAur.golden b/internal/pipe/aur/testdata/TestFullAur.golden index 4b47416f21f..80a11daa969 100644 --- a/internal/pipe/aur/testdata/TestFullAur.golden +++ b/internal/pipe/aur/testdata/TestFullAur.golden @@ -15,6 +15,7 @@ provides=('test') conflicts=('nope') depends=('nope') optdepends=('nfpm') +backup=('/etc/mypkg.conf' '/var/share/mypkg') 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') diff --git a/internal/pipe/aur/tmpl.go b/internal/pipe/aur/tmpl.go index 55a42413056..ea6e3ebc0f6 100644 --- a/internal/pipe/aur/tmpl.go +++ b/internal/pipe/aur/tmpl.go @@ -11,6 +11,7 @@ type templateData struct { Contributors []string Provides []string Conflicts []string + Backup []string Depends []string OptDepends []string Arches []string @@ -53,6 +54,9 @@ depends=({{ pkgArray . }}) {{- with .OptDepends }} optdepends=({{ pkgArray . }}) {{- end }} +{{- with .Backup }} +backup=({{ pkgArray . }}) +{{- end }} {{ range .ReleasePackages -}} source_{{ .Arch }}=("${pkgname}_${pkgver}_{{ .Arch }}.{{ .Format }}::{{ .DownloadURL }}") diff --git a/pkg/config/config.go b/pkg/config/config.go index ae2ebe9258a..67828378ac5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -140,6 +140,7 @@ type AUR struct { Conflicts []string `yaml:"conflicts,omitempty" json:"conflicts,omitempty"` Depends []string `yaml:"depends,omitempty" json:"depends,omitempty"` OptDepends []string `yaml:"optdepends,omitempty" json:"optdepends,omitempty"` + Backup []string `yaml:"backup,omitempty" json:"backup,omitempty"` Rel string `yaml:"rel,omitempty" json:"rel,omitempty"` Package string `yaml:"package,omitempty" json:"package,omitempty"` GitURL string `yaml:"git_url,omitempty" json:"git_url,omitempty"` diff --git a/www/docs/customization/aur.md b/www/docs/customization/aur.md index eec647dc724..541a3bbc2a5 100644 --- a/www/docs/customization/aur.md +++ b/www/docs/customization/aur.md @@ -101,6 +101,14 @@ aurs: optdepends: - 'wget: for downloading things' + # List of files that can contain user-made changes and should be preserved + # during package upgrades and removals. + # + # Default: empty. + # Since: v1.12 + backup: + - /etc/foo.conf + # Custom package instructions. # # Defaults to `install -Dm755 "./PROJECT_NAME" "${pkgdir}/usr/bin/PROJECT_NAME",