From 904f598069ff533562061c4f67dd2d4102f23057 Mon Sep 17 00:00:00 2001 From: Jarred Wilson Date: Tue, 15 Oct 2024 20:43:16 +0000 Subject: [PATCH] fix: disallow updating built-in package managers - check for built-in and error - add english translation for error --- cmd/pkgManagers.go | 5 +++++ locales/en.yml | 2 ++ 2 files changed, 7 insertions(+) diff --git a/cmd/pkgManagers.go b/cmd/pkgManagers.go index 1039d900..fadedf4c 100644 --- a/cmd/pkgManagers.go +++ b/cmd/pkgManagers.go @@ -675,6 +675,11 @@ func updatePkgManager(cmd *cobra.Command, args []string) error { return error } + if pkgmanager.BuiltIn { + cmdr.Error.Println(apx.Trans("pkgmanagers.update.error.builtIn")) + os.Exit(126) + } + if autoRemove == "" { if !assumeYes { cmdr.Info.Printfln(apx.Trans("pkgmanagers.update.info.askNewCommand"), "autoRemove", pkgmanager.CmdAutoRemove) diff --git a/locales/en.yml b/locales/en.yml index 81264f74..d32f63ac 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -168,6 +168,7 @@ pkgmanagers: error: noName: "No name specified." missingCommand: "Missing command for %s." + builtIn: "Built-in package managers cannot be modified." rm: description: "Remove the specified package manager." error: @@ -268,6 +269,7 @@ stacks: noPkgManager: "No package manager specified." pkgManagerDoesNotExist: "The specified package manager does not exist. Create it with 'apx pkgmanagers new' or contact the system administrator." + builtIn: "Built-in stacks cannot be modified." info: askBase: "Type a new base or confirm the current one (%s):" askPkgManager: "Choose a new package manager or confirm the current one (%s):"