diff --git a/cmd/install.go b/cmd/install.go index 47578553..df212982 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -43,6 +43,7 @@ var installCmd = &cobra.Command{ LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps")) LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps")) LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force")) + LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes")) }, Long: `Install packages in parallel`, Run: func(cmd *cobra.Command, args []string) { @@ -75,6 +76,7 @@ var installCmd = &cobra.Command{ nodeps := LuetCfg.Viper.GetBool("nodeps") onlydeps := LuetCfg.Viper.GetBool("onlydeps") concurrent, _ := cmd.Flags().GetBool("solver-concurrent") + yes := LuetCfg.Viper.GetBool("yes") LuetCfg.GetSolverOptions().Type = stype LuetCfg.GetSolverOptions().LearnRate = float32(rate) @@ -99,6 +101,7 @@ var installCmd = &cobra.Command{ Force: force, OnlyDeps: onlydeps, PreserveSystemEssentialData: true, + Ask: !yes, }) inst.Repositories(repos) @@ -131,6 +134,7 @@ func init() { installCmd.Flags().Bool("onlydeps", false, "Consider **only** package dependencies") installCmd.Flags().Bool("force", false, "Skip errors and keep going (potentially harmful)") installCmd.Flags().Bool("solver-concurrent", false, "Use concurrent solver (experimental)") + installCmd.Flags().BoolP("yes", "y", false, "Don't ask questions") RootCmd.AddCommand(installCmd) } diff --git a/cmd/root.go b/cmd/root.go index c5f974b0..38e8bb0e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -54,9 +54,31 @@ var ( // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ - Use: "luet", - Short: "Package manager for the XXth century!", - Long: `Package manager which uses containers to build packages`, + Use: "luet", + Short: "Package manager for the XXth century!", + Long: `Luet is a single-binary package manager based on containers to build packages. + +To install a package: + +$ luet install package + +To search for a package in the repositories: + +$ luet search package + +To list all packages installed in the system: + +$ luet search --installed . + +To show hidden packages: + +$ luet search --hidden package + +To build a package, from a tree definition: + +$ luet build --tree tree/path package + +`, Version: fmt.Sprintf("%s-g%s %s", LuetCLIVersion, BuildCommit, BuildTime), PersistentPreRun: func(cmd *cobra.Command, args []string) { err := LoadConfig(config.LuetCfg) diff --git a/cmd/uninstall.go b/cmd/uninstall.go index 1b99828e..2fde2e16 100644 --- a/cmd/uninstall.go +++ b/cmd/uninstall.go @@ -42,6 +42,7 @@ var uninstallCmd = &cobra.Command{ LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts")) LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps")) LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force")) + LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes")) }, Run: func(cmd *cobra.Command, args []string) { var systemDB pkg.PackageDatabase @@ -63,6 +64,7 @@ var uninstallCmd = &cobra.Command{ checkconflicts, _ := cmd.Flags().GetBool("conflictscheck") fullClean, _ := cmd.Flags().GetBool("full-clean") concurrent, _ := cmd.Flags().GetBool("solver-concurrent") + yes := LuetCfg.Viper.GetBool("yes") LuetCfg.GetSolverOptions().Type = stype LuetCfg.GetSolverOptions().LearnRate = float32(rate) @@ -86,6 +88,7 @@ var uninstallCmd = &cobra.Command{ FullUninstall: full, FullCleanUninstall: fullClean, CheckConflicts: checkconflicts, + Ask: !yes, }) if LuetCfg.GetSystem().DatabaseEngine == "boltdb" { @@ -120,6 +123,7 @@ func init() { uninstallCmd.Flags().Bool("conflictscheck", true, "Check if the package marked for deletion is required by other packages") uninstallCmd.Flags().Bool("full-clean", false, "(experimental) Uninstall packages and all the other deps/revdeps of it.") uninstallCmd.Flags().Bool("solver-concurrent", false, "Use concurrent solver (experimental)") + uninstallCmd.Flags().BoolP("yes", "y", false, "Don't ask questions") RootCmd.AddCommand(uninstallCmd) } diff --git a/cmd/upgrade.go b/cmd/upgrade.go index f612fd77..b00a50f3 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -39,6 +39,7 @@ var upgradeCmd = &cobra.Command{ LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate")) LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts")) LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force")) + LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes")) }, Long: `Upgrades packages in parallel`, Run: func(cmd *cobra.Command, args []string) { @@ -65,6 +66,7 @@ var upgradeCmd = &cobra.Command{ clean, _ := cmd.Flags().GetBool("clean") sync, _ := cmd.Flags().GetBool("sync") concurrent, _ := cmd.Flags().GetBool("solver-concurrent") + yes := LuetCfg.Viper.GetBool("yes") LuetCfg.GetSolverOptions().Type = stype LuetCfg.GetSolverOptions().LearnRate = float32(rate) @@ -90,6 +92,7 @@ var upgradeCmd = &cobra.Command{ SolverUpgrade: universe, RemoveUnavailableOnUpgrade: clean, UpgradeNewRevisions: sync, + Ask: !yes, }) inst.Repositories(repos) _, err := inst.SyncRepositories(false) @@ -129,6 +132,7 @@ func init() { upgradeCmd.Flags().Bool("clean", false, "Try to drop removed packages (experimental, only when --universe is enabled)") upgradeCmd.Flags().Bool("sync", false, "Upgrade packages with new revisions (experimental)") upgradeCmd.Flags().Bool("solver-concurrent", false, "Use concurrent solver (experimental)") + upgradeCmd.Flags().BoolP("yes", "y", false, "Don't ask questions") RootCmd.AddCommand(upgradeCmd) } diff --git a/pkg/installer/installer.go b/pkg/installer/installer.go index c8c84cb0..7cc92d7f 100644 --- a/pkg/installer/installer.go +++ b/pkg/installer/installer.go @@ -16,7 +16,6 @@ package installer import ( - "fmt" "io/ioutil" "os" "path/filepath" @@ -24,6 +23,7 @@ import ( "strings" "sync" + . "github.com/logrusorgru/aurora" "github.com/mudler/luet/pkg/bus" compiler "github.com/mudler/luet/pkg/compiler" "github.com/mudler/luet/pkg/config" @@ -45,6 +45,7 @@ type LuetInstallerOptions struct { FullUninstall, FullCleanUninstall bool CheckConflicts bool SolverUpgrade, RemoveUnavailableOnUpgrade, UpgradeNewRevisions bool + Ask bool } type LuetInstaller struct { @@ -63,93 +64,105 @@ func NewLuetInstaller(opts LuetInstallerOptions) Installer { return &LuetInstaller{Options: opts} } -func (l *LuetInstaller) Upgrade(s *System) error { +// ComputeUpgrade returns the packages to be uninstalled and installed in a system to perform an upgrade +// based on the system repositories +func (l *LuetInstaller) ComputeUpgrade(s *System) (Repositories, pkg.Packages, pkg.Packages, error) { + toInstall := pkg.Packages{} + var uninstall pkg.Packages + syncedRepos, err := l.SyncRepositories(true) if err != nil { - return err + return nil, uninstall, toInstall, err } + // First match packages against repositories by priority + allRepos := pkg.NewInMemoryDatabase(false) + syncedRepos.SyncDatabase(allRepos) + // compute a "big" world + solv := solver.NewResolver(solver.Options{Type: l.Options.SolverOptions.Implementation, Concurrency: l.Options.Concurrency}, s.Database, allRepos, pkg.NewInMemoryDatabase(false), l.Options.SolverOptions.Resolver()) + var solution solver.PackagesAssertions + + if l.Options.SolverUpgrade { + uninstall, solution, err = solv.UpgradeUniverse(l.Options.RemoveUnavailableOnUpgrade) + if err != nil { + return syncedRepos, uninstall, toInstall, errors.Wrap(err, "Failed solving solution for upgrade") + } + } else { + uninstall, solution, err = solv.Upgrade(!l.Options.FullUninstall, l.Options.NoDeps) + if err != nil { + return syncedRepos, uninstall, toInstall, errors.Wrap(err, "Failed solving solution for upgrade") + } + } + + for _, assertion := range solution { + // Be sure to filter from solutions packages already installed in the system + if _, err := s.Database.FindPackage(assertion.Package); err != nil && assertion.Value { + toInstall = append(toInstall, assertion.Package) + } + } + + if l.Options.UpgradeNewRevisions { + for _, p := range s.Database.World() { + matches := syncedRepos.PackageMatches(pkg.Packages{p}) + if len(matches) == 0 { + // Package missing. the user should run luet upgrade --universe + continue + } + for _, artefact := range matches[0].Repo.GetIndex() { + if artefact.GetCompileSpec().GetPackage() == nil { + return syncedRepos, uninstall, toInstall, errors.New("Package in compilespec empty") + + } + if artefact.GetCompileSpec().GetPackage().Matches(p) && artefact.GetCompileSpec().GetPackage().GetBuildTimestamp() != p.GetBuildTimestamp() { + toInstall = append(toInstall, matches[0].Package).Unique() + uninstall = append(uninstall, p).Unique() + } + } + } + } + + return syncedRepos, uninstall, toInstall, nil +} + +func packsToList(p pkg.Packages) string { + var packs []string + + for _, pp := range p { + packs = append(packs, pp.HumanReadableString()) + } + return strings.Join(packs, " ") +} + +// Upgrade upgrades a System based on the Installer options. Returns error in case of failure +func (l *LuetInstaller) Upgrade(s *System) error { Info(":thinking: Computing upgrade, please hang tight... :zzz:") if l.Options.UpgradeNewRevisions { Info(":memo: note: will consider new build revisions while upgrading") } Spinner(32) defer SpinnerStop() - // First match packages against repositories by priority - allRepos := pkg.NewInMemoryDatabase(false) - syncedRepos.SyncDatabase(allRepos) - // compute a "big" world - solv := solver.NewResolver(solver.Options{Type: l.Options.SolverOptions.Implementation, Concurrency: l.Options.Concurrency}, s.Database, allRepos, pkg.NewInMemoryDatabase(false), l.Options.SolverOptions.Resolver()) - var uninstall pkg.Packages - var solution solver.PackagesAssertions - - if l.Options.SolverUpgrade { - - uninstall, solution, err = solv.UpgradeUniverse(l.Options.RemoveUnavailableOnUpgrade) - if err != nil { - return errors.Wrap(err, "Failed solving solution for upgrade") - } - } else { - uninstall, solution, err = solv.Upgrade(!l.Options.FullUninstall, l.Options.NoDeps) - if err != nil { - return errors.Wrap(err, "Failed solving solution for upgrade") - } + syncedRepos, uninstall, toInstall, err := l.ComputeUpgrade(s) + if err != nil { + return errors.Wrap(err, "failed computing upgrade") } - SpinnerStop() if len(uninstall) > 0 { - Info(":recycle: Packages marked for uninstall:") + Info(":recycle: Packages that are going to be removed from the system:\n ", Yellow(packsToList(uninstall)).BgBlack().String()) } - for _, p := range uninstall { - Info(fmt.Sprintf("- %s", p.HumanReadableString())) + if len(toInstall) > 0 { + Info(":zap: Packages that are going to be installed in the system:\n ", Green(packsToList(toInstall)).BgBlack().String()) } - if len(solution) > 0 { - Info(":zap: Packages marked for upgrade:") - } - - toInstall := pkg.Packages{} - for _, assertion := range solution { - // Be sure to filter from solutions packages already installed in the system - if _, err := s.Database.FindPackage(assertion.Package); err != nil && assertion.Value { - Info(fmt.Sprintf("- %s", assertion.Package.HumanReadableString())) - toInstall = append(toInstall, assertion.Package) + if l.Options.Ask { + Info("By going forward, you are also accepting the licenses of the packages that you are going to install in your system.") + if Ask() { + return l.swap(syncedRepos, uninstall, toInstall, s) + } else { + return errors.New("Aborted by user") } } - - if l.Options.UpgradeNewRevisions { - Info(":mag: Checking packages with new revisions available") - for _, p := range s.Database.World() { - matches := syncedRepos.PackageMatches(pkg.Packages{p}) - if len(matches) == 0 { - // Package missing. the user should run luet upgrade --universe - Info(":warning: Installed packages seems to be missing from remote repositories.") - Info(":warning: It is suggested to run 'luet upgrade --universe'") - continue - } - for _, artefact := range matches[0].Repo.GetIndex() { - if artefact.GetCompileSpec().GetPackage() == nil { - return errors.New("Package in compilespec empty") - - } - if artefact.GetCompileSpec().GetPackage().Matches(p) && artefact.GetCompileSpec().GetPackage().GetBuildTimestamp() != p.GetBuildTimestamp() { - toInstall = append(toInstall, matches[0].Package).Unique() - uninstall = append(uninstall, p).Unique() - Info( - fmt.Sprintf("- %s ( %s vs %s ) repo: %s (date: %s)", - p.HumanReadableString(), - artefact.GetCompileSpec().GetPackage().GetBuildTimestamp(), - p.GetBuildTimestamp(), - matches[0].Repo.GetName(), - matches[0].Repo.GetLastUpdate(), - )) - } - } - } - } - return l.swap(syncedRepos, uninstall, toInstall, s) } @@ -216,7 +229,12 @@ func (l *LuetInstaller) swap(syncedRepos Repositories, toRemove pkg.Packages, to } l.Options.Force = forced - return l.install(syncedRepos, toInstall, s) + match, packages, assertions, allRepos, err := l.ComputeInstall(syncedRepos, toInstall, s) + if err != nil { + return errors.Wrap(err, "computing installation") + } + + return l.install(syncedRepos, match, packages, assertions, allRepos, s) } func (l *LuetInstaller) Install(cp pkg.Packages, s *System) error { @@ -224,7 +242,28 @@ func (l *LuetInstaller) Install(cp pkg.Packages, s *System) error { if err != nil { return err } - return l.install(syncedRepos, cp, s) + + match, packages, assertions, allRepos, err := l.ComputeInstall(syncedRepos, cp, s) + if err != nil { + return err + } + + if len(packages) > 0 { + Info("Packages that are going to be installed in the system: \n ", Green(packsToList(packages)).BgBlack().String()) + } else { + Info("No packages to install") + return nil + } + + if l.Options.Ask { + Info("By going forward, you are also accepting the licenses of the packages that you are going to install in your system.") + if Ask() { + return l.install(syncedRepos, match, packages, assertions, allRepos, s) + } else { + return errors.New("Aborted by user") + } + } + return l.install(syncedRepos, match, packages, assertions, allRepos, s) } func (l *LuetInstaller) download(syncedRepos Repositories, cp pkg.Packages) error { @@ -323,16 +362,18 @@ func (l *LuetInstaller) Reclaim(s *System) error { return nil } -func (l *LuetInstaller) install(syncedRepos Repositories, cp pkg.Packages, s *System) error { +func (l *LuetInstaller) ComputeInstall(syncedRepos Repositories, cp pkg.Packages, s *System) (map[string]ArtifactMatch, pkg.Packages, solver.PackagesAssertions, pkg.PackageDatabase, error) { var p pkg.Packages + toInstall := map[string]ArtifactMatch{} + allRepos := pkg.NewInMemoryDatabase(false) + var solution solver.PackagesAssertions // Check if the package is installed first for _, pi := range cp { - vers, _ := s.Database.FindPackageVersions(pi) if len(vers) >= 1 { - Warning("Filtering out package " + pi.HumanReadableString() + ", it has other versions already installed. Uninstall one of them first ") + // Warning("Filtering out package " + pi.HumanReadableString() + ", it has other versions already installed. Uninstall one of them first ") continue //return errors.New("Package " + pi.GetFingerPrint() + " has other versions already installed. Uninstall one of them first: " + strings.Join(vers, " ")) @@ -342,7 +383,7 @@ func (l *LuetInstaller) install(syncedRepos Repositories, cp pkg.Packages, s *Sy if len(p) == 0 { Warning("No package to install, bailing out with no errors") - return nil + return toInstall, p, solution, allRepos, nil } // First get metas from all repos (and decodes trees) @@ -350,25 +391,19 @@ func (l *LuetInstaller) install(syncedRepos Repositories, cp pkg.Packages, s *Sy // matches := syncedRepos.PackageMatches(p) // compute a "big" world - allRepos := pkg.NewInMemoryDatabase(false) syncedRepos.SyncDatabase(allRepos) p = syncedRepos.ResolveSelectors(p) - toInstall := map[string]ArtifactMatch{} var packagesToInstall pkg.Packages var err error - var solution solver.PackagesAssertions if !l.Options.NoDeps { - Info(":deciduous_tree: Computing installation, hang tight") solv := solver.NewResolver(solver.Options{Type: l.Options.SolverOptions.Implementation, Concurrency: l.Options.Concurrency}, s.Database, allRepos, pkg.NewInMemoryDatabase(false), l.Options.SolverOptions.Resolver()) solution, err = solv.Install(p) /// TODO: PackageAssertions needs to be a map[fingerprint]pack so lookup is in O(1) if err != nil && !l.Options.Force { - return errors.Wrap(err, "Failed solving solution for package") + return toInstall, p, solution, allRepos, errors.Wrap(err, "Failed solving solution for package") } - Info(":deciduous_tree: Finished calculating dependencies") // Gathers things to install - Info(":deciduous_tree: Checking for packages already installed, and prepare for installation") for _, assertion := range solution { if assertion.Value { if _, err := s.Database.FindPackage(assertion.Package); err == nil { @@ -387,32 +422,33 @@ func (l *LuetInstaller) install(syncedRepos Repositories, cp pkg.Packages, s *Sy packagesToInstall = append(packagesToInstall, currentPack) } } - Info(":deciduous_tree: Finding packages to install from :cloud:") // Gathers things to install for _, currentPack := range packagesToInstall { // Check if package is already installed. matches := syncedRepos.PackageMatches(pkg.Packages{currentPack}) if len(matches) == 0 { - return errors.New("Failed matching solutions against repository for " + currentPack.HumanReadableString() + " where are definitions coming from?!") + return toInstall, p, solution, allRepos, errors.New("Failed matching solutions against repository for " + currentPack.HumanReadableString() + " where are definitions coming from?!") } A: for _, artefact := range matches[0].Repo.GetIndex() { if artefact.GetCompileSpec().GetPackage() == nil { - return errors.New("Package in compilespec empty") - + return toInstall, p, solution, allRepos, errors.New("Package in compilespec empty") } if matches[0].Package.Matches(artefact.GetCompileSpec().GetPackage()) { currentPack.SetBuildTimestamp(artefact.GetCompileSpec().GetPackage().GetBuildTimestamp()) // Filter out already installed if _, err := s.Database.FindPackage(currentPack); err != nil { toInstall[currentPack.GetFingerPrint()] = ArtifactMatch{Package: currentPack, Artifact: artefact, Repository: matches[0].Repo} - Info("\t:package:", currentPack.HumanReadableString(), ":cloud:", matches[0].Repo.GetName()) } break A } } } + return toInstall, p, solution, allRepos, nil +} + +func (l *LuetInstaller) install(syncedRepos Repositories, toInstall map[string]ArtifactMatch, p pkg.Packages, solution solver.PackagesAssertions, allRepos pkg.PackageDatabase, s *System) error { // Install packages into rootfs in parallel. all := make(chan ArtifactMatch) @@ -542,7 +578,7 @@ func (l *LuetInstaller) downloadWorker(i int, wg *sync.WaitGroup, c <-chan Artif return errors.Wrap(err, "Failed installing package "+p.Package.GetName()) } if err == nil { - Info("\n:package: ", p.Package.HumanReadableString(), "downloaded") + Info("\n:package: Package ", p.Package.HumanReadableString(), "downloaded") } else if err != nil && l.Options.Force { Info("\n:package: ", p.Package.HumanReadableString(), "downloaded with failures (force download)") } @@ -563,9 +599,9 @@ func (l *LuetInstaller) installerWorker(i int, wg *sync.WaitGroup, c <-chan Arti return errors.Wrap(err, "Failed installing package "+p.Package.GetName()) } if err == nil { - Info(":package: ", p.Package.HumanReadableString(), "installed") + Info(":package: Package ", p.Package.HumanReadableString(), "installed") } else if err != nil && l.Options.Force { - Info(":package: ", p.Package.HumanReadableString(), "installed with failures (force install)") + Info(":package: Package ", p.Package.HumanReadableString(), "installed with failures (forced install)") } } @@ -663,12 +699,9 @@ func (l *LuetInstaller) uninstall(p pkg.Package, s *System) error { return nil } -func (l *LuetInstaller) Uninstall(p pkg.Package, s *System) error { - Spinner(32) - defer SpinnerStop() - - Info(":recycle: Uninstalling :package:", p.HumanReadableString(), "hang tight") +func (l *LuetInstaller) ComputeUninstall(p pkg.Package, s *System) (pkg.Packages, error) { + var toUninstall pkg.Packages // compute uninstall from all world - remove packages in parallel - run uninstall finalizer (in order) TODO - mark the uninstallation in db // Get installed definition checkConflicts := l.Options.CheckConflicts @@ -685,44 +718,66 @@ func (l *LuetInstaller) Uninstall(p pkg.Package, s *System) error { for _, i := range s.Database.World() { _, err := installedtmp.CreatePackage(i) if err != nil { - return errors.Wrap(err, "Failed create temporary in-memory db") + return toUninstall, errors.Wrap(err, "Failed create temporary in-memory db") } } if !l.Options.NoDeps { - Info(":mag: Finding :package:", p.HumanReadableString(), "dependency graph :deciduous_tree:") solv := solver.NewResolver(solver.Options{Type: l.Options.SolverOptions.Implementation, Concurrency: l.Options.Concurrency}, installedtmp, installedtmp, pkg.NewInMemoryDatabase(false), l.Options.SolverOptions.Resolver()) var solution pkg.Packages var err error if l.Options.FullCleanUninstall { solution, err = solv.UninstallUniverse(pkg.Packages{p}) if err != nil { - return errors.Wrap(err, "Could not solve the uninstall constraints. Tip: try with --solver-type qlearning or with --force, or by removing packages excluding their dependencies with --nodeps") + return toUninstall, errors.Wrap(err, "Could not solve the uninstall constraints. Tip: try with --solver-type qlearning or with --force, or by removing packages excluding their dependencies with --nodeps") } } else { solution, err = solv.Uninstall(checkConflicts, full, p) if err != nil && !l.Options.Force { - return errors.Wrap(err, "Could not solve the uninstall constraints. Tip: try with --solver-type qlearning or with --force, or by removing packages excluding their dependencies with --nodeps") + return toUninstall, errors.Wrap(err, "Could not solve the uninstall constraints. Tip: try with --solver-type qlearning or with --force, or by removing packages excluding their dependencies with --nodeps") } } for _, p := range solution { - Info(":recycle: Uninstalling", p.HumanReadableString()) + toUninstall = append(toUninstall, p) + } + } else { + toUninstall = append(toUninstall, p) + + } + + return toUninstall, nil +} +func (l *LuetInstaller) Uninstall(p pkg.Package, s *System) error { + Spinner(32) + defer SpinnerStop() + + toUninstall, err := l.ComputeUninstall(p, s) + if err != nil { + return errors.Wrap(err, "while computing uninstall") + } + + uninstall := func() error { + for _, p := range toUninstall { err := l.uninstall(p, s) if err != nil && !l.Options.Force { return errors.Wrap(err, "Uninstall failed") } } - } else { - Info(":recycle: Uninstalling", p.HumanReadableString(), "without deps") - err := l.uninstall(p, s) - if err != nil && !l.Options.Force { - return errors.Wrap(err, "Uninstall failed") - } - Info(":recycle: :package:", p.HumanReadableString(), "uninstalled :heavy_check_mark:") + return nil } - return nil + Info(":recycle: Packages that are going to be removed from the system:\n ", Yellow(packsToList(toUninstall)).BgBlack().String()) + + if l.Options.Ask { + Info("By going forward, you are also accepting the licenses of the packages that you are going to install in your system.") + if Ask() { + return uninstall() + } else { + return errors.New("Aborted by user") + } + } + return uninstall() } func (l *LuetInstaller) Repositories(r []Repository) { l.PackageRepositories = r } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 31d3d922..b0e0f565 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "regexp" + "strings" . "github.com/mudler/luet/pkg/config" @@ -36,6 +37,22 @@ func GetAurora() Aurora { return aurora } +func Ask() bool { + var input string + + Info("Do you want to continue with this operation? [y/N]: ") + _, err := fmt.Scanln(&input) + if err != nil { + panic(err) + } + input = strings.ToLower(input) + + if input == "y" || input == "yes" { + return true + } + return false +} + func ZapLogger() error { var err error if z == nil { @@ -183,7 +200,7 @@ func msg(level string, withoutColor bool, msg ...interface{}) { case "debug": levelMsg = White(message).BgBlack().String() case "info": - levelMsg = Bold(White(message)).BgBlack().String() + levelMsg = message case "error": levelMsg = Bold(Red(":bomb: " + message + ":fire:")).BgBlack().String() } diff --git a/tests/integration/01_simple.sh b/tests/integration/01_simple.sh index d71db2ed..ecb87fb3 100755 --- a/tests/integration/01_simple.sh +++ b/tests/integration/01_simple.sh @@ -57,22 +57,22 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/c - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml test/c + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" } testReInstall() { - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertContains 'contains warning' "$output" 'Filtering out' + assertContains 'contains warning' "$output" 'No packages to install' } testUnInstall() { - luet uninstall --config $tmpdir/luet.yaml test/c + luet uninstall -y --config $tmpdir/luet.yaml test/c installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" @@ -80,10 +80,10 @@ testUnInstall() { testInstallAgain() { assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertNotContains 'contains warning' "$output" 'Filtering out' + assertNotContains 'contains warning' "$output" 'No packages to install' assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" assertTrue 'package in cache' "[ -e '$tmpdir/testrootfs/packages/c-test-1.0.package.tar.gz' ]" } diff --git a/tests/integration/01_simple_gzip.sh b/tests/integration/01_simple_gzip.sh index 112ba628..16ce967d 100755 --- a/tests/integration/01_simple_gzip.sh +++ b/tests/integration/01_simple_gzip.sh @@ -62,22 +62,22 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/c-1.0 - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml test/c-1.0 + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" } testReInstall() { - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertContains 'contains warning' "$output" 'Filtering out' + assertContains 'contains warning' "$output" 'No packages to install' } testUnInstall() { - luet uninstall --config $tmpdir/luet.yaml test/c-1.0 + luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0 installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" @@ -85,10 +85,10 @@ testUnInstall() { testInstallAgain() { assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertNotContains 'contains warning' "$output" 'Filtering out' + assertNotContains 'contains warning' "$output" 'No packages to install' assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" assertTrue 'package in cache' "[ -e '$tmpdir/testrootfs/packages/c-test-1.0.package.tar.gz' ]" } diff --git a/tests/integration/01_simple_meta_gzip.sh b/tests/integration/01_simple_meta_gzip.sh index cdf01ad0..e3f586a5 100755 --- a/tests/integration/01_simple_meta_gzip.sh +++ b/tests/integration/01_simple_meta_gzip.sh @@ -65,22 +65,22 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/c-1.0 - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml test/c-1.0 + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" } testReInstall() { - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertContains 'contains warning' "$output" 'Filtering out' + assertContains 'contains warning' "$output" 'No packages to install' } testUnInstall() { - luet uninstall --config $tmpdir/luet.yaml test/c-1.0 + luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0 installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" @@ -88,10 +88,10 @@ testUnInstall() { testInstallAgain() { assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertNotContains 'contains warning' "$output" 'Filtering out' + assertNotContains 'contains warning' "$output" 'No packages to install' assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" assertTrue 'package in cache' "[ -e '$tmpdir/testrootfs/packages/c-test-1.0.package.tar.gz' ]" } diff --git a/tests/integration/02_create_repo_from_config.sh b/tests/integration/02_create_repo_from_config.sh index 89de999e..5a78c4d0 100755 --- a/tests/integration/02_create_repo_from_config.sh +++ b/tests/integration/02_create_repo_from_config.sh @@ -55,22 +55,22 @@ testRepo() { } testInstall() { - luet install --config $tmpdir/luet.yaml test/c-1.0 - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml test/c-1.0 + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" } testReInstall() { - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertContains 'contains warning' "$output" 'Filtering out' + assertContains 'contains warning' "$output" 'No packages to install' } testUnInstall() { - luet uninstall --config $tmpdir/luet.yaml test/c-1.0 + luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0 installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" @@ -78,10 +78,10 @@ testUnInstall() { testInstallAgain() { assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" - output=$(luet install --config $tmpdir/luet.yaml test/c-1.0) + output=$(luet install -y --config $tmpdir/luet.yaml test/c-1.0) installst=$? assertEquals 'install test successfully' "$installst" "0" - assertNotContains 'contains warning' "$output" 'Filtering out' + assertNotContains 'contains warning' "$output" 'No packages to install' assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]" assertTrue 'package in cache' "[ -e '$tmpdir/testrootfs/packages/c-test-1.0.package.tar.gz' ]" } diff --git a/tests/integration/03_qlearning.sh b/tests/integration/03_qlearning.sh index fb7bf0d6..82aaa877 100755 --- a/tests/integration/03_qlearning.sh +++ b/tests/integration/03_qlearning.sh @@ -57,15 +57,15 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/c - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml test/c + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package C installed' "[ -e '$tmpdir/testrootfs/c' ]" } testFullInstall() { - output=$(luet install --config $tmpdir/luet.yaml test/d test/f test/e test/a) + output=$(luet install -y --config $tmpdir/luet.yaml test/d test/f test/e test/a) installst=$? assertEquals 'cannot install' "$installst" "1" assertTrue 'package D installed' "[ ! -e '$tmpdir/testrootfs/d' ]" @@ -73,11 +73,11 @@ testFullInstall() { } testInstallAgain() { - output=$(luet install --solver-type qlearning --config $tmpdir/luet.yaml test/d test/f test/e test/a) + output=$(luet install -y --solver-type qlearning --config $tmpdir/luet.yaml test/d test/f test/e test/a) installst=$? echo "$output" assertEquals 'install test successfully' "0" "$installst" - assertNotContains 'contains warning' "$output" 'Filtering out' + assertNotContains 'contains warning' "$output" 'No packages to install' assertTrue 'package D installed' "[ -e '$tmpdir/testrootfs/d' ]" assertTrue 'package F installed' "[ -e '$tmpdir/testrootfs/f' ]" assertTrue 'package E not installed' "[ ! -e '$tmpdir/testrootfs/e' ]" diff --git a/tests/integration/04_retrieve.sh b/tests/integration/04_retrieve.sh index 9d69ee1a..fa2e4ce2 100755 --- a/tests/integration/04_retrieve.sh +++ b/tests/integration/04_retrieve.sh @@ -59,8 +59,8 @@ EOF testInstall() { - luet install --config $tmpdir/luet.yaml test/b - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml test/b + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package B installed' "[ -e '$tmpdir/testrootfs/b' ]" @@ -71,7 +71,7 @@ testInstall() { testUnInstall() { - luet uninstall --full --config $tmpdir/luet.yaml test/b + luet uninstall -y --full --config $tmpdir/luet.yaml test/b installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/b' ]" diff --git a/tests/integration/05_upgrade.sh b/tests/integration/05_upgrade.sh index db4f2971..c7bf8f0e 100755 --- a/tests/integration/05_upgrade.sh +++ b/tests/integration/05_upgrade.sh @@ -85,31 +85,31 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/b-1.0 + luet install -y --config $tmpdir/luet.yaml test/b-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]" - luet install --config $tmpdir/luet.yaml test/a-1.0 + luet install -y --config $tmpdir/luet.yaml test/a-1.0 assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]" installst=$? assertEquals 'install test successfully' "$installst" "0" - luet install --config $tmpdir/luet.yaml test/a-1.1 + luet install -y --config $tmpdir/luet.yaml test/a-1.1 assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]" installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]" assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]" - luet install --config $tmpdir/luet.yaml test/c-1.0 + luet install -y --config $tmpdir/luet.yaml test/c-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]" } testUpgrade() { - upgrade=$(luet --config $tmpdir/luet.yaml upgrade) + upgrade=$(luet --config $tmpdir/luet.yaml upgrade -y) installst=$? echo "$upgrade" assertEquals 'install test successfully' "$installst" "0" diff --git a/tests/integration/06_search.sh b/tests/integration/06_search.sh index e6d2f844..1c7b3201 100755 --- a/tests/integration/06_search.sh +++ b/tests/integration/06_search.sh @@ -84,24 +84,24 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/b-1.0 + luet install -y --config $tmpdir/luet.yaml test/b-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]" - luet install --config $tmpdir/luet.yaml test/a-1.0 + luet install -y --config $tmpdir/luet.yaml test/a-1.0 assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]" installst=$? assertEquals 'install test successfully' "$installst" "0" - luet install --config $tmpdir/luet.yaml test/a-1.1 + luet install -y --config $tmpdir/luet.yaml test/a-1.1 assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]" installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]" assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]" - luet install --config $tmpdir/luet.yaml test/c-1.0 + luet install -y --config $tmpdir/luet.yaml test/c-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]" diff --git a/tests/integration/07_finalizer.sh b/tests/integration/07_finalizer.sh index 8eea896b..d4f99fd1 100755 --- a/tests/integration/07_finalizer.sh +++ b/tests/integration/07_finalizer.sh @@ -56,8 +56,8 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml seed/alpine - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml seed/alpine + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/bin/busybox' ]" diff --git a/tests/integration/07_finalizer_custom.sh b/tests/integration/07_finalizer_custom.sh index baf4f8fe..f0c2ac8a 100755 --- a/tests/integration/07_finalizer_custom.sh +++ b/tests/integration/07_finalizer_custom.sh @@ -56,8 +56,8 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml seed/alpine - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml seed/alpine + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/bin/busybox' ]" diff --git a/tests/integration/08_versioning.sh b/tests/integration/08_versioning.sh index 6930a6ac..82f824df 100755 --- a/tests/integration/08_versioning.sh +++ b/tests/integration/08_versioning.sh @@ -64,13 +64,13 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml media-libs/libsndfile + luet install -y --config $tmpdir/luet.yaml media-libs/libsndfile installst=$? assertEquals 'install test successfully' "0" "$installst" } testInstall2() { - luet install --config $tmpdir/luet.yaml '>=dev-libs/libsigc++-2-0' + luet install -y --config $tmpdir/luet.yaml '>=dev-libs/libsigc++-2-0' installst=$? assertEquals 'install test successfully' "0" "$installst" } diff --git a/tests/integration/09_docker.sh b/tests/integration/09_docker.sh index 2095cc95..abd0e6b8 100755 --- a/tests/integration/09_docker.sh +++ b/tests/integration/09_docker.sh @@ -63,7 +63,7 @@ testInstall() { docker run --name luet-runtime-test \ -v /tmp:/tmp \ -v $tmpdir/luet.yaml:/etc/luet/luet.yaml:ro \ - luet:test install seed/alpine + luet:test install -y seed/alpine installst=$? assertEquals 'install test successfully' "0" "$installst" diff --git a/tests/integration/11_upgrade_universe.sh b/tests/integration/11_upgrade_universe.sh index 29a9dd1a..4ce3b93a 100755 --- a/tests/integration/11_upgrade_universe.sh +++ b/tests/integration/11_upgrade_universe.sh @@ -85,31 +85,31 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/b-1.0 + luet install -y --config $tmpdir/luet.yaml test/b-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]" - luet install --config $tmpdir/luet.yaml test/a-1.0 + luet install -y --config $tmpdir/luet.yaml test/a-1.0 assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]" installst=$? assertEquals 'install test successfully' "$installst" "0" - luet install --config $tmpdir/luet.yaml test/a-1.1 + luet install -y --config $tmpdir/luet.yaml test/a-1.1 assertTrue 'package installed A' "[ -e '$tmpdir/testrootfs/testaa' ]" installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package keeps old A' "[ -e '$tmpdir/testrootfs/testaa' ]" assertTrue 'package new A was not installed' "[ ! -e '$tmpdir/testrootfs/testlatest' ]" - luet install --config $tmpdir/luet.yaml test/c-1.0 + luet install -y --config $tmpdir/luet.yaml test/c-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed C' "[ -e '$tmpdir/testrootfs/c' ]" } testUpgrade() { - upgrade=$(luet --config $tmpdir/luet.yaml upgrade --universe --clean) + upgrade=$(luet --config $tmpdir/luet.yaml upgrade -y --universe --clean) installst=$? assertEquals 'install test successfully' "$installst" "0" echo "$upgrade" diff --git a/tests/integration/12_config_protect.sh b/tests/integration/12_config_protect.sh index 4cd45c3c..16a57cbf 100755 --- a/tests/integration/12_config_protect.sh +++ b/tests/integration/12_config_protect.sh @@ -74,7 +74,7 @@ testInstall() { mkdir $tmpdir/testrootfs/etc/a -p echo "fakeconf" > $tmpdir/testrootfs/etc/a/conf - luet install --config $tmpdir/luet.yaml test/a + luet install -y --config $tmpdir/luet.yaml test/a installst=$? assertEquals 'install test successfully' "$installst" "0" @@ -86,7 +86,7 @@ testInstall() { testUnInstall() { - luet uninstall --full --config $tmpdir/luet.yaml test/a + luet uninstall -y --full --config $tmpdir/luet.yaml test/a installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" diff --git a/tests/integration/13_config_protect_annotation.sh b/tests/integration/13_config_protect_annotation.sh index 9dcc50c3..c396833d 100755 --- a/tests/integration/13_config_protect_annotation.sh +++ b/tests/integration/13_config_protect_annotation.sh @@ -74,7 +74,7 @@ testInstall() { mkdir $tmpdir/testrootfs/opt/etc -p echo "fakeconf" > $tmpdir/testrootfs/opt/etc/conf - luet install --config $tmpdir/luet.yaml test/a + luet install -y --config $tmpdir/luet.yaml test/a installst=$? assertEquals 'install test successfully' "$installst" "0" @@ -86,7 +86,7 @@ testInstall() { testUnInstall() { - luet uninstall --full --config $tmpdir/luet.yaml test/a + luet uninstall -y --full --config $tmpdir/luet.yaml test/a installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" diff --git a/tests/integration/14_upgrade_revision.sh b/tests/integration/14_upgrade_revision.sh index f5e5d77a..7741d1e4 100755 --- a/tests/integration/14_upgrade_revision.sh +++ b/tests/integration/14_upgrade_revision.sh @@ -75,7 +75,7 @@ EOF } testUpgrade() { - luet install --config $tmpdir/luet.yaml test/b-1.0 + luet install -y --config $tmpdir/luet.yaml test/b-1.0 installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/test5' ]" @@ -100,13 +100,13 @@ EOF res=$? assertEquals 'config test successfully' "$res" "0" - luet upgrade --sync --config $tmpdir/luet.yaml + luet upgrade -y --sync --config $tmpdir/luet.yaml installst=$? assertEquals 'upgrade test successfully' "$installst" "0" assertTrue 'package uninstalled B' "[ ! -e '$tmpdir/testrootfs/test5' ]" assertTrue 'package installed B' "[ -e '$tmpdir/testrootfs/newc' ]" - content=$(luet upgrade --sync --config $tmpdir/luet.yaml) + content=$(luet upgrade -y --sync --config $tmpdir/luet.yaml) installst=$? assertNotContains 'didn not upgrade' "$content" "Uninstalling" } diff --git a/tests/integration/15_symlinks.sh b/tests/integration/15_symlinks.sh index 3dafc8d0..299c2530 100755 --- a/tests/integration/15_symlinks.sh +++ b/tests/integration/15_symlinks.sh @@ -56,7 +56,7 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml test/pkgAsym test/pkgBsym + luet install -y --config $tmpdir/luet.yaml test/pkgAsym test/pkgBsym installst=$? assertEquals 'install test successfully' "$installst" "0" ls -liah $tmpdir/testrootfs/ diff --git a/tests/integration/16_caps.sh b/tests/integration/16_caps.sh index c6d3441e..44720074 100755 --- a/tests/integration/16_caps.sh +++ b/tests/integration/16_caps.sh @@ -56,7 +56,7 @@ EOF } testInstall() { - $ROOT_DIR/tests/integration/bin/luet install --config $tmpdir/luet.yaml test/caps-0.1 test/caps2-0.1 + $ROOT_DIR/tests/integration/bin/luet install -y --config $tmpdir/luet.yaml test/caps-0.1 test/caps2-0.1 installst=$? assertEquals 'install test successfully' "$installst" "0" diff --git a/tests/integration/17_config_protect_skip.sh b/tests/integration/17_config_protect_skip.sh index 58b3752a..d3b4c152 100755 --- a/tests/integration/17_config_protect_skip.sh +++ b/tests/integration/17_config_protect_skip.sh @@ -75,7 +75,7 @@ testInstall() { mkdir $tmpdir/testrootfs/etc/a -p echo "fakeconf" > $tmpdir/testrootfs/etc/a/conf - luet install --config $tmpdir/luet.yaml test/a + luet install -y --config $tmpdir/luet.yaml test/a installst=$? assertEquals 'install test successfully' "$installst" "0" @@ -87,7 +87,7 @@ testInstall() { testUnInstall() { - luet uninstall --full --config $tmpdir/luet.yaml test/a + luet uninstall -y --full --config $tmpdir/luet.yaml test/a installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" diff --git a/tests/integration/18_database.sh b/tests/integration/18_database.sh index 6a33803a..0ea2dbd5 100755 --- a/tests/integration/18_database.sh +++ b/tests/integration/18_database.sh @@ -58,7 +58,7 @@ EOF testDatabase() { luet database create --config $tmpdir/luet.yaml $tmpdir/testbuild/c-test-1.0.metadata.yaml - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null createst=$? assertEquals 'created package successfully' "$createst" "0" assertTrue 'package not installed' "[ ! -e '$tmpdir/testrootfs/c' ]" @@ -75,12 +75,12 @@ testDatabase() { assertTrue 'file not touched' "[ -e '$tmpdir/testrootfs/c' ]" luet database create --config $tmpdir/luet.yaml $tmpdir/testbuild/c-test-1.0.metadata.yaml - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null createst=$? assertEquals 'created package successfully' "$createst" "0" assertTrue 'file still present' "[ -e '$tmpdir/testrootfs/c' ]" - luet uninstall --config $tmpdir/luet.yaml test/c + luet uninstall -y --config $tmpdir/luet.yaml test/c installst=$? assertEquals 'uninstall test successfully' "$installst" "0" assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]" diff --git a/tests/integration/19_finalizer_templated.sh b/tests/integration/19_finalizer_templated.sh index b6a55101..2f8d14f3 100755 --- a/tests/integration/19_finalizer_templated.sh +++ b/tests/integration/19_finalizer_templated.sh @@ -56,8 +56,8 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml seed/alpine - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet install -y --config $tmpdir/luet.yaml seed/alpine + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/bin/busybox' ]" diff --git a/tests/integration/20_plugin.sh b/tests/integration/20_plugin.sh index 9cd0c0fb..b13b257a 100755 --- a/tests/integration/20_plugin.sh +++ b/tests/integration/20_plugin.sh @@ -61,8 +61,8 @@ EOF } testInstall() { - luet --plugin test-foo install --config $tmpdir/luet.yaml seed/alpine - #luet install --config $tmpdir/luet.yaml test/c-1.0 > /dev/null + luet --plugin test-foo install -y --config $tmpdir/luet.yaml seed/alpine + #luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null installst=$? assertEquals 'install test successfully' "$installst" "0" assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/bin/busybox' ]" diff --git a/tests/integration/21_collections.sh b/tests/integration/21_collections.sh index 14988777..81c0351d 100755 --- a/tests/integration/21_collections.sh +++ b/tests/integration/21_collections.sh @@ -59,7 +59,7 @@ EOF } testInstall() { - luet install --config $tmpdir/luet.yaml distro/a + luet install -y --config $tmpdir/luet.yaml distro/a installst=$? assertEquals 'install test successfully' "$installst" "0" @@ -75,12 +75,12 @@ testInstall() { assertContains 'contains distro/a-0.1' "$installed" 'distro/a-0.1' - luet uninstall --config $tmpdir/luet.yaml distro/a + luet uninstall -y --config $tmpdir/luet.yaml distro/a installst=$? assertEquals 'install test successfully' "$installst" "0" # We do the same check for the others - luet install --config $tmpdir/luet.yaml distro/b + luet install -y --config $tmpdir/luet.yaml distro/b installst=$? assertEquals 'install test successfully' "$installst" "0" @@ -94,11 +94,11 @@ testInstall() { assertContains 'contains distro/b-0.3' "$installed" 'distro/b-0.3' - luet uninstall --config $tmpdir/luet.yaml distro/b + luet uninstall -y --config $tmpdir/luet.yaml distro/b installst=$? assertEquals 'install test successfully' "$installst" "0" - luet install --config $tmpdir/luet.yaml distro/c + luet install -y --config $tmpdir/luet.yaml distro/c installst=$? assertEquals 'install test successfully' "$installst" "0" @@ -112,7 +112,7 @@ testInstall() { assertContains 'contains distro/c-0.3' "$installed" 'distro/c-0.3' - luet uninstall --config $tmpdir/luet.yaml distro/c + luet uninstall -y --config $tmpdir/luet.yaml distro/c installst=$? assertEquals 'install test successfully' "$installst" "0" }