From a1e7249e712bfc7bbcf6275bdd87f2343d60f81a Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Thu, 19 May 2022 15:39:24 -0500 Subject: bail out on unknown package attributes Be freindlier to the user by clearly communicating and refusing to install packages we do not know how to install. Add an environment variable allowing users to opt out and silently ignore errors if they so choose. --- installpkg.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'installpkg.go') diff --git a/installpkg.go b/installpkg.go index 479b318..488692e 100644 --- a/installpkg.go +++ b/installpkg.go @@ -65,11 +65,13 @@ type InstallPkgFlags struct { TerseLength int Warn bool - chown bool - chmod bool + chown bool + chmod bool + Strict bool } var DefaultInstallPkgFlags = InstallPkgFlags{ + // Official slackware configuration Ask: false, InfoBox: false, LockDir: InstallLockDir, @@ -83,8 +85,10 @@ var DefaultInstallPkgFlags = InstallPkgFlags{ TerseLength: DefaultTerseLength, Warn: false, - chown: true, - chmod: true, + // ours + chown: false, + chmod: false, + Strict: true, } func (s *InstallPkgFlags) SetEnvValues() { @@ -97,6 +101,10 @@ func (s *InstallPkgFlags) SetEnvValues() { if v := os.Getenv("ROOT"); v != "" { s.Root = v } + + if v := os.Getenv("PKGTOOLS_GO_STRICT"); v != "NO" { + s.Strict = false + } } func runInstallScript( @@ -301,9 +309,10 @@ func extractSlackwarePkg(flags *InstallPkgFlags, fp string) error { defer slackPkg.Close() toRoot := NewTarExtractor(&TarCfg{ - Root: flags.Root, - Chmod: flags.chmod, - Chown: flags.chown, + Root: flags.Root, + Chmod: flags.chmod, + Chown: flags.chown, + Strict: flags.Strict, }) err = FilterTar( -- cgit v1.2.3