Merge pull request 'adds a rootCmd call if necessary' (#79) from Maks1mS/ALR:add-root-cmd into master
Reviewed-on: #79
This commit is contained in:
		
							
								
								
									
										16
									
								
								install.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								install.go
									
									
									
									
									
								
							| @@ -46,11 +46,7 @@ func InstallCmd() *cli.Command { | |||||||
| 				Usage:   gotext.Get("Build package from scratch even if there's an already built package available"), | 				Usage:   gotext.Get("Build package from scratch even if there's an already built package available"), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		Action: func(c *cli.Context) error { | 		Action: utils.RootNeededAction(func(c *cli.Context) error { | ||||||
| 			if err := utils.ExitIfNotRoot(); err != nil { |  | ||||||
| 				return err |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			args := c.Args() | 			args := c.Args() | ||||||
| 			if args.Len() < 1 { | 			if args.Len() < 1 { | ||||||
| 				return cliutils.FormatCliExit(gotext.Get("Command install expected at least 1 argument, got %d", args.Len()), nil) | 				return cliutils.FormatCliExit(gotext.Get("Command install expected at least 1 argument, got %d", args.Len()), nil) | ||||||
| @@ -119,7 +115,7 @@ func InstallCmd() *cli.Command { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		}, | 		}), | ||||||
| 		BashComplete: cliutils.BashCompleteWithError(func(c *cli.Context) error { | 		BashComplete: cliutils.BashCompleteWithError(func(c *cli.Context) error { | ||||||
| 			if err := utils.ExitIfCantDropCapsToAlrUser(); err != nil { | 			if err := utils.ExitIfCantDropCapsToAlrUser(); err != nil { | ||||||
| 				return err | 				return err | ||||||
| @@ -213,11 +209,7 @@ func RemoveCmd() *cli.Command { | |||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		}), | 		}), | ||||||
| 		Action: func(c *cli.Context) error { | 		Action: utils.RootNeededAction(func(c *cli.Context) error { | ||||||
| 			if err := utils.ExitIfNotRoot(); err != nil { |  | ||||||
| 				return err |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			args := c.Args() | 			args := c.Args() | ||||||
| 			if args.Len() < 1 { | 			if args.Len() < 1 { | ||||||
| 				return cliutils.FormatCliExit(gotext.Get("Command remove expected at least 1 argument, got %d", args.Len()), nil) | 				return cliutils.FormatCliExit(gotext.Get("Command remove expected at least 1 argument, got %d", args.Len()), nil) | ||||||
| @@ -239,6 +231,6 @@ func RemoveCmd() *cli.Command { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		}, | 		}), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -39,6 +39,7 @@ type ALRConfig struct { | |||||||
|  |  | ||||||
| var defaultConfig = &types.Config{ | var defaultConfig = &types.Config{ | ||||||
| 	RootCmd:          "sudo", | 	RootCmd:          "sudo", | ||||||
|  | 	UseRootCmd:       true, | ||||||
| 	PagerStyle:       "native", | 	PagerStyle:       "native", | ||||||
| 	IgnorePkgUpdates: []string{}, | 	IgnorePkgUpdates: []string{}, | ||||||
| 	AutoPull:         true, | 	AutoPull:         true, | ||||||
| @@ -142,6 +143,10 @@ func (c *ALRConfig) LogLevel() string { | |||||||
| 	return c.cfg.LogLevel | 	return c.cfg.LogLevel | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (c *ALRConfig) UseRootCmd() bool { | ||||||
|  | 	return c.cfg.UseRootCmd | ||||||
|  | } | ||||||
|  |  | ||||||
| func (c *ALRConfig) GetPaths() *Paths { | func (c *ALRConfig) GetPaths() *Paths { | ||||||
| 	return c.paths | 	return c.paths | ||||||
| } | } | ||||||
|   | |||||||
| @@ -154,27 +154,27 @@ msgstr "" | |||||||
| msgid "Install a new package" | msgid "Install a new package" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: install.go:56 | #: install.go:52 | ||||||
| msgid "Command install expected at least 1 argument, got %d" | msgid "Command install expected at least 1 argument, got %d" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: install.go:118 | #: install.go:114 | ||||||
| msgid "Error when installing the package" | msgid "Error when installing the package" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: install.go:163 | #: install.go:159 | ||||||
| msgid "Remove an installed package" | msgid "Remove an installed package" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: install.go:182 | #: install.go:178 | ||||||
| msgid "Error listing installed packages" | msgid "Error listing installed packages" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: install.go:223 | #: install.go:215 | ||||||
| msgid "Command remove expected at least 1 argument, got %d" | msgid "Command remove expected at least 1 argument, got %d" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: install.go:238 | #: install.go:230 | ||||||
| msgid "Error removing packages" | msgid "Error removing packages" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -315,16 +315,16 @@ msgstr "" | |||||||
| msgid "ERROR" | msgid "ERROR" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: internal/utils/cmd.go:95 | #: internal/utils/cmd.go:97 | ||||||
| msgid "Error on dropping capabilities" | msgid "Error on dropping capabilities" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: internal/utils/cmd.go:123 | #: internal/utils/cmd.go:164 | ||||||
| msgid "You need to be root to perform this action" | msgid "You need to be a %s member to perform this action" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: internal/utils/cmd.go:165 | #: internal/utils/cmd.go:200 | ||||||
| msgid "You need to be a %s member to perform this action" | msgid "You need to be root to perform this action" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: list.go:41 | #: list.go:41 | ||||||
| @@ -443,35 +443,35 @@ msgstr "" | |||||||
| msgid "URL of the new repo" | msgid "URL of the new repo" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:79 | #: repo.go:75 | ||||||
| msgid "Repo \"%s\" already exists" | msgid "Repo \"%s\" already exists" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:90 repo.go:167 | #: repo.go:86 repo.go:159 | ||||||
| msgid "Error saving config" | msgid "Error saving config" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:116 | #: repo.go:112 | ||||||
| msgid "Remove an existing repository" | msgid "Remove an existing repository" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:123 | #: repo.go:119 | ||||||
| msgid "Name of the repo to be deleted" | msgid "Name of the repo to be deleted" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:156 | #: repo.go:148 | ||||||
| msgid "Repo \"%s\" does not exist" | msgid "Repo \"%s\" does not exist" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:163 | #: repo.go:155 | ||||||
| msgid "Error removing repo directory" | msgid "Error removing repo directory" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:186 | #: repo.go:178 | ||||||
| msgid "Error removing packages from database" | msgid "Error removing packages from database" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:197 | #: repo.go:189 | ||||||
| msgid "Pull all repositories that have changed" | msgid "Pull all repositories that have changed" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -515,10 +515,10 @@ msgstr "" | |||||||
| msgid "Upgrade all installed packages" | msgid "Upgrade all installed packages" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: upgrade.go:109 upgrade.go:126 | #: upgrade.go:105 upgrade.go:122 | ||||||
| msgid "Error checking for updates" | msgid "Error checking for updates" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: upgrade.go:129 | #: upgrade.go:125 | ||||||
| msgid "There is nothing to do." | msgid "There is nothing to do." | ||||||
| msgstr "" | msgstr "" | ||||||
|   | |||||||
| @@ -12,8 +12,8 @@ msgstr "" | |||||||
| "MIME-Version: 1.0\n" | "MIME-Version: 1.0\n" | ||||||
| "Content-Type: text/plain; charset=UTF-8\n" | "Content-Type: text/plain; charset=UTF-8\n" | ||||||
| "Content-Transfer-Encoding: 8bit\n" | "Content-Transfer-Encoding: 8bit\n" | ||||||
| "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " | "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" | ||||||
| "n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" | "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" | ||||||
| "X-Generator: Gtranslator 48.0\n" | "X-Generator: Gtranslator 48.0\n" | ||||||
|  |  | ||||||
| #: build.go:42 | #: build.go:42 | ||||||
| @@ -161,27 +161,27 @@ msgstr "Ошибка кодирования переменных скрита" | |||||||
| msgid "Install a new package" | msgid "Install a new package" | ||||||
| msgstr "Установить новый пакет" | msgstr "Установить новый пакет" | ||||||
|  |  | ||||||
| #: install.go:56 | #: install.go:52 | ||||||
| msgid "Command install expected at least 1 argument, got %d" | msgid "Command install expected at least 1 argument, got %d" | ||||||
| msgstr "Для команды install ожидался хотя бы 1 аргумент, получено %d" | msgstr "Для команды install ожидался хотя бы 1 аргумент, получено %d" | ||||||
|  |  | ||||||
| #: install.go:118 | #: install.go:114 | ||||||
| msgid "Error when installing the package" | msgid "Error when installing the package" | ||||||
| msgstr "Ошибка при установке пакета" | msgstr "Ошибка при установке пакета" | ||||||
|  |  | ||||||
| #: install.go:163 | #: install.go:159 | ||||||
| msgid "Remove an installed package" | msgid "Remove an installed package" | ||||||
| msgstr "Удалить установленный пакет" | msgstr "Удалить установленный пакет" | ||||||
|  |  | ||||||
| #: install.go:182 | #: install.go:178 | ||||||
| msgid "Error listing installed packages" | msgid "Error listing installed packages" | ||||||
| msgstr "Ошибка при составлении списка установленных пакетов" | msgstr "Ошибка при составлении списка установленных пакетов" | ||||||
|  |  | ||||||
| #: install.go:223 | #: install.go:215 | ||||||
| msgid "Command remove expected at least 1 argument, got %d" | msgid "Command remove expected at least 1 argument, got %d" | ||||||
| msgstr "Для команды remove ожидался хотя бы 1 аргумент, получено %d" | msgstr "Для команды remove ожидался хотя бы 1 аргумент, получено %d" | ||||||
|  |  | ||||||
| #: install.go:238 | #: install.go:230 | ||||||
| msgid "Error removing packages" | msgid "Error removing packages" | ||||||
| msgstr "Ошибка при удалении пакетов" | msgstr "Ошибка при удалении пакетов" | ||||||
|  |  | ||||||
| @@ -323,18 +323,18 @@ msgstr "%s %s загружается — %s/с\n" | |||||||
| msgid "ERROR" | msgid "ERROR" | ||||||
| msgstr "ОШИБКА" | msgstr "ОШИБКА" | ||||||
|  |  | ||||||
| #: internal/utils/cmd.go:95 | #: internal/utils/cmd.go:97 | ||||||
| msgid "Error on dropping capabilities" | msgid "Error on dropping capabilities" | ||||||
| msgstr "Ошибка при понижении привилегий" | msgstr "Ошибка при понижении привилегий" | ||||||
|  |  | ||||||
| #: internal/utils/cmd.go:123 | #: internal/utils/cmd.go:164 | ||||||
| msgid "You need to be root to perform this action" |  | ||||||
| msgstr "Вы должны быть root чтобы выполнить это" |  | ||||||
|  |  | ||||||
| #: internal/utils/cmd.go:165 |  | ||||||
| msgid "You need to be a %s member to perform this action" | msgid "You need to be a %s member to perform this action" | ||||||
| msgstr "Вы должны быть членом %s чтобы выполнить это" | msgstr "Вы должны быть членом %s чтобы выполнить это" | ||||||
|  |  | ||||||
|  | #: internal/utils/cmd.go:200 | ||||||
|  | msgid "You need to be root to perform this action" | ||||||
|  | msgstr "Вы должны быть root чтобы выполнить это" | ||||||
|  |  | ||||||
| #: list.go:41 | #: list.go:41 | ||||||
| msgid "List ALR repo packages" | msgid "List ALR repo packages" | ||||||
| msgstr "Список пакетов репозитория ALR" | msgstr "Список пакетов репозитория ALR" | ||||||
| @@ -457,35 +457,35 @@ msgstr "Название нового репозитория" | |||||||
| msgid "URL of the new repo" | msgid "URL of the new repo" | ||||||
| msgstr "URL-адрес нового репозитория" | msgstr "URL-адрес нового репозитория" | ||||||
|  |  | ||||||
| #: repo.go:79 | #: repo.go:75 | ||||||
| msgid "Repo \"%s\" already exists" | msgid "Repo \"%s\" already exists" | ||||||
| msgstr "Репозиторий \"%s\" уже существует" | msgstr "Репозиторий \"%s\" уже существует" | ||||||
|  |  | ||||||
| #: repo.go:90 repo.go:167 | #: repo.go:86 repo.go:159 | ||||||
| msgid "Error saving config" | msgid "Error saving config" | ||||||
| msgstr "Ошибка при сохранении конфигурации" | msgstr "Ошибка при сохранении конфигурации" | ||||||
|  |  | ||||||
| #: repo.go:116 | #: repo.go:112 | ||||||
| msgid "Remove an existing repository" | msgid "Remove an existing repository" | ||||||
| msgstr "Удалить существующий репозиторий" | msgstr "Удалить существующий репозиторий" | ||||||
|  |  | ||||||
| #: repo.go:123 | #: repo.go:119 | ||||||
| msgid "Name of the repo to be deleted" | msgid "Name of the repo to be deleted" | ||||||
| msgstr "Название репозитория  удалён" | msgstr "Название репозитория  удалён" | ||||||
|  |  | ||||||
| #: repo.go:156 | #: repo.go:148 | ||||||
| msgid "Repo \"%s\" does not exist" | msgid "Repo \"%s\" does not exist" | ||||||
| msgstr "Репозитория \"%s\" не существует" | msgstr "Репозитория \"%s\" не существует" | ||||||
|  |  | ||||||
| #: repo.go:163 | #: repo.go:155 | ||||||
| msgid "Error removing repo directory" | msgid "Error removing repo directory" | ||||||
| msgstr "Ошибка при удалении каталога репозитория" | msgstr "Ошибка при удалении каталога репозитория" | ||||||
|  |  | ||||||
| #: repo.go:186 | #: repo.go:178 | ||||||
| msgid "Error removing packages from database" | msgid "Error removing packages from database" | ||||||
| msgstr "Ошибка при удалении пакетов из базы данных" | msgstr "Ошибка при удалении пакетов из базы данных" | ||||||
|  |  | ||||||
| #: repo.go:197 | #: repo.go:189 | ||||||
| msgid "Pull all repositories that have changed" | msgid "Pull all repositories that have changed" | ||||||
| msgstr "Скачать все изменённые репозитории" | msgstr "Скачать все изменённые репозитории" | ||||||
|  |  | ||||||
| @@ -529,11 +529,11 @@ msgstr "Ошибка при выполнении шаблона" | |||||||
| msgid "Upgrade all installed packages" | msgid "Upgrade all installed packages" | ||||||
| msgstr "Обновить все установленные пакеты" | msgstr "Обновить все установленные пакеты" | ||||||
|  |  | ||||||
| #: upgrade.go:109 upgrade.go:126 | #: upgrade.go:105 upgrade.go:122 | ||||||
| msgid "Error checking for updates" | msgid "Error checking for updates" | ||||||
| msgstr "Ошибка при проверке обновлений" | msgstr "Ошибка при проверке обновлений" | ||||||
|  |  | ||||||
| #: upgrade.go:129 | #: upgrade.go:125 | ||||||
| msgid "There is nothing to do." | msgid "There is nothing to do." | ||||||
| msgstr "Здесь нечего делать." | msgstr "Здесь нечего делать." | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ package types | |||||||
| // Config represents the ALR configuration file | // Config represents the ALR configuration file | ||||||
| type Config struct { | type Config struct { | ||||||
| 	RootCmd          string   `toml:"rootCmd" env:"ALR_ROOT_CMD"` | 	RootCmd          string   `toml:"rootCmd" env:"ALR_ROOT_CMD"` | ||||||
|  | 	UseRootCmd       bool     `toml:"useRootCmd"` | ||||||
| 	PagerStyle       string   `toml:"pagerStyle" env:"ALR_PAGER_STYLE"` | 	PagerStyle       string   `toml:"pagerStyle" env:"ALR_PAGER_STYLE"` | ||||||
| 	IgnorePkgUpdates []string `toml:"ignorePkgUpdates"` | 	IgnorePkgUpdates []string `toml:"ignorePkgUpdates"` | ||||||
| 	Repos            []Repo   `toml:"repo"` | 	Repos            []Repo   `toml:"repo"` | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ package utils | |||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"os/exec" | ||||||
| 	"os/user" | 	"os/user" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"syscall" | 	"syscall" | ||||||
| @@ -27,6 +28,7 @@ import ( | |||||||
| 	"github.com/urfave/cli/v2" | 	"github.com/urfave/cli/v2" | ||||||
|  |  | ||||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils" | 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils" | ||||||
|  | 	appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder" | ||||||
| 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/constants" | 	"gitea.plemya-x.ru/Plemya-x/ALR/internal/constants" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -118,11 +120,8 @@ func ExitIfCantDropCapsToAlrUserNoPrivs() cli.ExitCoder { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func ExitIfNotRoot() error { | func IsNotRoot() bool { | ||||||
| 	if os.Getuid() != 0 { | 	return os.Getuid() != 0 | ||||||
| 		return cli.Exit(gotext.Get("You need to be root to perform this action"), 1) |  | ||||||
| 	} |  | ||||||
| 	return nil |  | ||||||
| } | } | ||||||
|  |  | ||||||
| func EnsureIsAlrUser() error { | func EnsureIsAlrUser() error { | ||||||
| @@ -184,3 +183,33 @@ func EscalateToRoot() error { | |||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func RootNeededAction(f cli.ActionFunc) cli.ActionFunc { | ||||||
|  | 	return func(ctx *cli.Context) error { | ||||||
|  | 		deps, err := appbuilder. | ||||||
|  | 			New(ctx.Context). | ||||||
|  | 			WithConfig(). | ||||||
|  | 			Build() | ||||||
|  | 		if err != nil { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  | 		defer deps.Defer() | ||||||
|  |  | ||||||
|  | 		if IsNotRoot() { | ||||||
|  | 			if !deps.Cfg.UseRootCmd() { | ||||||
|  | 				return cli.Exit(gotext.Get("You need to be root to perform this action"), 1) | ||||||
|  | 			} | ||||||
|  | 			executable, err := os.Executable() | ||||||
|  | 			if err != nil { | ||||||
|  | 				return cliutils.FormatCliExit("failed to get executable path", err) | ||||||
|  | 			} | ||||||
|  | 			args := append([]string{executable}, os.Args[1:]...) | ||||||
|  | 			cmd := exec.Command(deps.Cfg.RootCmd(), args...) | ||||||
|  | 			cmd.Stdin = os.Stdin | ||||||
|  | 			cmd.Stdout = os.Stdout | ||||||
|  | 			cmd.Stderr = os.Stderr | ||||||
|  | 			return cmd.Run() | ||||||
|  | 		} | ||||||
|  | 		return f(ctx) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								repo.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								repo.go
									
									
									
									
									
								
							| @@ -52,11 +52,7 @@ func AddRepoCmd() *cli.Command { | |||||||
| 				Usage:    gotext.Get("URL of the new repo"), | 				Usage:    gotext.Get("URL of the new repo"), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		Action: func(c *cli.Context) error { | 		Action: utils.RootNeededAction(func(c *cli.Context) error { | ||||||
| 			if err := utils.ExitIfNotRoot(); err != nil { |  | ||||||
| 				return err |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			name := c.String("name") | 			name := c.String("name") | ||||||
| 			repoURL := c.String("url") | 			repoURL := c.String("url") | ||||||
|  |  | ||||||
| @@ -106,7 +102,7 @@ func AddRepoCmd() *cli.Command { | |||||||
| 			defer deps.Defer() | 			defer deps.Defer() | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		}, | 		}), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -123,11 +119,7 @@ func RemoveRepoCmd() *cli.Command { | |||||||
| 				Usage:    gotext.Get("Name of the repo to be deleted"), | 				Usage:    gotext.Get("Name of the repo to be deleted"), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		Action: func(c *cli.Context) error { | 		Action: utils.RootNeededAction(func(c *cli.Context) error { | ||||||
| 			if err := utils.ExitIfNotRoot(); err != nil { |  | ||||||
| 				return err |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			ctx := c.Context | 			ctx := c.Context | ||||||
|  |  | ||||||
| 			name := c.String("name") | 			name := c.String("name") | ||||||
| @@ -187,7 +179,7 @@ func RemoveRepoCmd() *cli.Command { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		}, | 		}), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -53,11 +53,7 @@ func UpgradeCmd() *cli.Command { | |||||||
| 				Usage:   gotext.Get("Build package from scratch even if there's an already built package available"), | 				Usage:   gotext.Get("Build package from scratch even if there's an already built package available"), | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		Action: func(c *cli.Context) error { | 		Action: utils.RootNeededAction(func(c *cli.Context) error { | ||||||
| 			if err := utils.ExitIfNotRoot(); err != nil { |  | ||||||
| 				return err |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			if err := utils.ExitIfCantDropCapsToAlrUser(); err != nil { | 			if err := utils.ExitIfCantDropCapsToAlrUser(); err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| @@ -130,7 +126,7 @@ func UpgradeCmd() *cli.Command { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			return nil | 			return nil | ||||||
| 		}, | 		}), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user