From c0119436136826241bb1a926a65d526f9ae417ce Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 26 Nov 2020 23:45:17 -0300 Subject: [PATCH] feat: nfpm symlinks closes #1861 Signed-off-by: Carlos Alexandro Becker --- internal/pipe/nfpm/nfpm.go | 1 + internal/pipe/nfpm/nfpm_test.go | 3 +++ pkg/config/config.go | 1 + www/docs/customization/nfpm.md | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go index cd9e317a2da..dde51e24366 100644 --- a/internal/pipe/nfpm/nfpm.go +++ b/internal/pipe/nfpm/nfpm.go @@ -169,6 +169,7 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries EmptyFolders: overridden.EmptyFolders, Files: files, ConfigFiles: overridden.ConfigFiles, + Symlinks: overridden.Symlinks, Scripts: nfpm.Scripts{ PreInstall: overridden.Scripts.PreInstall, PostInstall: overridden.Scripts.PostInstall, diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go index 14086be6133..add012b950b 100644 --- a/internal/pipe/nfpm/nfpm_test.go +++ b/internal/pipe/nfpm/nfpm_test.go @@ -112,6 +112,9 @@ func TestRunPipe(t *testing.T) { ConfigFiles: map[string]string{ "./testdata/testfile.txt": "/etc/nope.conf", }, + Symlinks: map[string]string{ + "/etc/nope2.conf": "/etc/nope.conf", + }, Replacements: map[string]string{ "linux": "Tux", }, diff --git a/pkg/config/config.go b/pkg/config/config.go index 07061cd64fd..c5eca187e84 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -407,6 +407,7 @@ type NFPMOverridables struct { EmptyFolders []string `yaml:"empty_folders,omitempty"` Files map[string]string `yaml:",omitempty"` ConfigFiles map[string]string `yaml:"config_files,omitempty"` + Symlinks map[string]string `yaml:"symlinks,omitempty"` Scripts NFPMScripts `yaml:"scripts,omitempty"` RPM NFPMRPM `yaml:"rpm,omitempty"` Deb NFPMDeb `yaml:"deb,omitempty"` diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md index 9be42700dc4..ce46052c523 100644 --- a/www/docs/customization/nfpm.md +++ b/www/docs/customization/nfpm.md @@ -128,6 +128,10 @@ nfpms: "tmp/app_generated.conf": "/etc/app.conf" "conf/*.conf": "/etc/foo/" + # Symlinks mapping from symlink name inside package to target inside package (overridable) + symlinks: + /sbin/foo: /usr/local/bin/foo + # Scripts to execute during the installation of the package. # Keys are the possible targets during the installation process # Values are the paths to the scripts which will be executed