mirror of
https://github.com/mudler/luet.git
synced 2025-09-03 16:25:19 +00:00
Re-organize common CLI code
Signed-off-by: Ettore Di Giacinto <mudler@sabayon.org>
This commit is contained in:
19
cmd/build.go
19
cmd/build.go
@@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
"github.com/mudler/luet/pkg/compiler"
|
"github.com/mudler/luet/pkg/compiler"
|
||||||
"github.com/mudler/luet/pkg/compiler/types/artifact"
|
"github.com/mudler/luet/pkg/compiler/types/artifact"
|
||||||
compilerspec "github.com/mudler/luet/pkg/compiler/types/spec"
|
compilerspec "github.com/mudler/luet/pkg/compiler/types/spec"
|
||||||
@@ -83,10 +84,8 @@ Build packages specifying multiple definition trees:
|
|||||||
viper.BindPFlag("wait", cmd.Flags().Lookup("wait"))
|
viper.BindPFlag("wait", cmd.Flags().Lookup("wait"))
|
||||||
viper.BindPFlag("keep-images", cmd.Flags().Lookup("keep-images"))
|
viper.BindPFlag("keep-images", cmd.Flags().Lookup("keep-images"))
|
||||||
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
|
||||||
LuetCfg.Viper.BindPFlag("general.show_build_output", cmd.Flags().Lookup("live-output"))
|
LuetCfg.Viper.BindPFlag("general.show_build_output", cmd.Flags().Lookup("live-output"))
|
||||||
LuetCfg.Viper.BindPFlag("backend-args", cmd.Flags().Lookup("backend-args"))
|
LuetCfg.Viper.BindPFlag("backend-args", cmd.Flags().Lookup("backend-args"))
|
||||||
|
|
||||||
@@ -148,21 +147,11 @@ Build packages specifying multiple definition trees:
|
|||||||
|
|
||||||
Info("Building in", dst)
|
Info("Building in", dst)
|
||||||
|
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
opts := util.SetSolverConfig()
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
pullRepo, _ := cmd.Flags().GetStringArray("pull-repository")
|
pullRepo, _ := cmd.Flags().GetStringArray("pull-repository")
|
||||||
|
|
||||||
LuetCfg.GetGeneral().ShowBuildOutput = LuetCfg.Viper.GetBool("general.show_build_output")
|
LuetCfg.GetGeneral().ShowBuildOutput = LuetCfg.Viper.GetBool("general.show_build_output")
|
||||||
|
|
||||||
opts := &LuetSolverOptions{
|
|
||||||
Type: stype,
|
|
||||||
LearnRate: float32(rate),
|
|
||||||
Discount: float32(discount),
|
|
||||||
MaxAttempts: attempts,
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug("Solver", opts.CompactString())
|
Debug("Solver", opts.CompactString())
|
||||||
|
|
||||||
if concurrent {
|
if concurrent {
|
||||||
|
@@ -20,8 +20,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
config "github.com/mudler/luet/pkg/config"
|
|
||||||
fileHelper "github.com/mudler/luet/pkg/helpers/file"
|
fileHelper "github.com/mudler/luet/pkg/helpers/file"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
|
|
||||||
@@ -33,19 +33,11 @@ var cleanupCmd = &cobra.Command{
|
|||||||
Short: "Clean packages cache.",
|
Short: "Clean packages cache.",
|
||||||
Long: `remove downloaded packages tarballs and clean cache directory`,
|
Long: `remove downloaded packages tarballs and clean cache directory`,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("installed", cmd.Flags().Lookup("installed"))
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var cleaned int = 0
|
var cleaned int = 0
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
util.SetSystemConfig()
|
||||||
rootfs := config.LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := config.LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
// Check if cache dir exists
|
// Check if cache dir exists
|
||||||
if fileHelper.Exists(LuetCfg.GetSystem().GetSystemPkgsCacheDirPath()) {
|
if fileHelper.Exists(LuetCfg.GetSystem().GetSystemPkgsCacheDirPath()) {
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ package cmd_database
|
|||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
artifact "github.com/mudler/luet/pkg/compiler/types/artifact"
|
artifact "github.com/mudler/luet/pkg/compiler/types/artifact"
|
||||||
|
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
@@ -45,21 +46,11 @@ The yaml must contain the package definition, and the file list at least.
|
|||||||
For reference, inspect a "metadata.yaml" file generated while running "luet build"`,
|
For reference, inspect a "metadata.yaml" file generated while running "luet build"`,
|
||||||
Args: cobra.OnlyValidArgs,
|
Args: cobra.OnlyValidArgs,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
util.SetSystemConfig()
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
systemDB := LuetCfg.GetSystemDB()
|
systemDB := LuetCfg.GetSystemDB()
|
||||||
|
|
||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
@@ -38,20 +39,11 @@ To return also files:
|
|||||||
$ luet database get --files system/foo`,
|
$ luet database get --files system/foo`,
|
||||||
Args: cobra.OnlyValidArgs,
|
Args: cobra.OnlyValidArgs,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
showFiles, _ := cmd.Flags().GetBool("files")
|
showFiles, _ := cmd.Flags().GetBool("files")
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
util.SetSystemConfig()
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
systemDB := LuetCfg.GetSystemDB()
|
systemDB := LuetCfg.GetSystemDB()
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
|
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -36,19 +37,10 @@ This commands takes multiple packages as arguments and prunes their entries from
|
|||||||
`,
|
`,
|
||||||
Args: cobra.OnlyValidArgs,
|
Args: cobra.OnlyValidArgs,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
util.SetSystemConfig()
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
systemDB := LuetCfg.GetSystemDB()
|
systemDB := LuetCfg.GetSystemDB()
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/mudler/luet/pkg/solver"
|
"github.com/mudler/luet/pkg/solver"
|
||||||
|
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
@@ -47,13 +48,8 @@ To force install a package:
|
|||||||
`,
|
`,
|
||||||
Aliases: []string{"i"},
|
Aliases: []string{"i"},
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
|
||||||
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
||||||
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
||||||
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
@@ -70,10 +66,6 @@ To force install a package:
|
|||||||
toInstall = append(toInstall, pack)
|
toInstall = append(toInstall, pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
force := LuetCfg.Viper.GetBool("force")
|
force := LuetCfg.Viper.GetBool("force")
|
||||||
nodeps := LuetCfg.Viper.GetBool("nodeps")
|
nodeps := LuetCfg.Viper.GetBool("nodeps")
|
||||||
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
||||||
@@ -81,18 +73,8 @@ To force install a package:
|
|||||||
yes := LuetCfg.Viper.GetBool("yes")
|
yes := LuetCfg.Viper.GetBool("yes")
|
||||||
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
||||||
|
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
util.SetSystemConfig()
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
util.SetSolverConfig()
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
LuetCfg.GetSolverOptions().Type = stype
|
|
||||||
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
|
||||||
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
|
||||||
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
|
||||||
|
|
||||||
if concurrent {
|
if concurrent {
|
||||||
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
installer "github.com/mudler/luet/pkg/installer"
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
|
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
@@ -27,9 +28,7 @@ var reclaimCmd = &cobra.Command{
|
|||||||
Use: "reclaim",
|
Use: "reclaim",
|
||||||
Short: "Reclaim packages to Luet database from available repositories",
|
Short: "Reclaim packages to Luet database from available repositories",
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
},
|
},
|
||||||
Long: `Reclaim tries to find association between packages in the online repositories and the system one.
|
Long: `Reclaim tries to find association between packages in the online repositories and the system one.
|
||||||
@@ -39,13 +38,7 @@ var reclaimCmd = &cobra.Command{
|
|||||||
It scans the target file system, and if finds a match with a package available in the repositories, it marks as installed in the system database.
|
It scans the target file system, and if finds a match with a package available in the repositories, it marks as installed in the system database.
|
||||||
`,
|
`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
util.SetSystemConfig()
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
// This shouldn't be necessary, but we need to unmarshal the repositories to a concrete struct, thus we need to port them back to the Repositories type
|
// This shouldn't be necessary, but we need to unmarshal the repositories to a concrete struct, thus we need to port them back to the Repositories type
|
||||||
repos := installer.Repositories{}
|
repos := installer.Repositories{}
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/mudler/luet/pkg/solver"
|
"github.com/mudler/luet/pkg/solver"
|
||||||
|
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
@@ -34,13 +35,8 @@ var reinstallCmd = &cobra.Command{
|
|||||||
$ luet reinstall -y system/busybox shells/bash system/coreutils ...
|
$ luet reinstall -y system/busybox shells/bash system/coreutils ...
|
||||||
`,
|
`,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
|
||||||
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
||||||
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
LuetCfg.Viper.BindPFlag("for", cmd.Flags().Lookup("for"))
|
LuetCfg.Viper.BindPFlag("for", cmd.Flags().Lookup("for"))
|
||||||
@@ -51,22 +47,14 @@ var reinstallCmd = &cobra.Command{
|
|||||||
var toUninstall pkg.Packages
|
var toUninstall pkg.Packages
|
||||||
var toAdd pkg.Packages
|
var toAdd pkg.Packages
|
||||||
|
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
force := LuetCfg.Viper.GetBool("force")
|
force := LuetCfg.Viper.GetBool("force")
|
||||||
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
||||||
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
||||||
yes := LuetCfg.Viper.GetBool("yes")
|
yes := LuetCfg.Viper.GetBool("yes")
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
util.SetSystemConfig()
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
pack, err := helpers.ParsePackageStr(a)
|
pack, err := helpers.ParsePackageStr(a)
|
||||||
@@ -87,10 +75,7 @@ var reinstallCmd = &cobra.Command{
|
|||||||
repos = append(repos, r)
|
repos = append(repos, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
LuetCfg.GetSolverOptions().Type = stype
|
util.SetSolverConfig()
|
||||||
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
|
||||||
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
|
||||||
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
|
||||||
|
|
||||||
if concurrent {
|
if concurrent {
|
||||||
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/mudler/luet/pkg/solver"
|
"github.com/mudler/luet/pkg/solver"
|
||||||
|
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
@@ -35,13 +36,8 @@ var replaceCmd = &cobra.Command{
|
|||||||
$ luet replace -y system/busybox ... --for shells/bash --for system/coreutils ...
|
$ luet replace -y system/busybox ... --for shells/bash --for system/coreutils ...
|
||||||
`,
|
`,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
|
||||||
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
LuetCfg.Viper.BindPFlag("onlydeps", cmd.Flags().Lookup("onlydeps"))
|
||||||
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
||||||
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
@@ -54,24 +50,15 @@ var replaceCmd = &cobra.Command{
|
|||||||
var toAdd pkg.Packages
|
var toAdd pkg.Packages
|
||||||
|
|
||||||
f := LuetCfg.Viper.GetStringSlice("for")
|
f := LuetCfg.Viper.GetStringSlice("for")
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
force := LuetCfg.Viper.GetBool("force")
|
force := LuetCfg.Viper.GetBool("force")
|
||||||
nodeps := LuetCfg.Viper.GetBool("nodeps")
|
nodeps := LuetCfg.Viper.GetBool("nodeps")
|
||||||
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
onlydeps := LuetCfg.Viper.GetBool("onlydeps")
|
||||||
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
||||||
yes := LuetCfg.Viper.GetBool("yes")
|
yes := LuetCfg.Viper.GetBool("yes")
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
util.SetSystemConfig()
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
util.SetSolverConfig()
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
|
|
||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
pack, err := helpers.ParsePackageStr(a)
|
pack, err := helpers.ParsePackageStr(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -98,11 +85,6 @@ var replaceCmd = &cobra.Command{
|
|||||||
repos = append(repos, r)
|
repos = append(repos, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
LuetCfg.GetSolverOptions().Type = stype
|
|
||||||
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
|
||||||
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
|
||||||
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
|
||||||
|
|
||||||
if concurrent {
|
if concurrent {
|
||||||
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
||||||
} else {
|
} else {
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
"github.com/jedib0t/go-pretty/table"
|
"github.com/jedib0t/go-pretty/table"
|
||||||
"github.com/jedib0t/go-pretty/v6/list"
|
"github.com/jedib0t/go-pretty/v6/list"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
installer "github.com/mudler/luet/pkg/installer"
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
@@ -306,14 +307,9 @@ Search can also return results in the terminal in different ways: as terminal ou
|
|||||||
`,
|
`,
|
||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("installed", cmd.Flags().Lookup("installed"))
|
LuetCfg.Viper.BindPFlag("installed", cmd.Flags().Lookup("installed"))
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var results Results
|
var results Results
|
||||||
@@ -325,32 +321,20 @@ Search can also return results in the terminal in different ways: as terminal ou
|
|||||||
hidden, _ := cmd.Flags().GetBool("hidden")
|
hidden, _ := cmd.Flags().GetBool("hidden")
|
||||||
|
|
||||||
installed := LuetCfg.Viper.GetBool("installed")
|
installed := LuetCfg.Viper.GetBool("installed")
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
searchWithLabel, _ := cmd.Flags().GetBool("by-label")
|
searchWithLabel, _ := cmd.Flags().GetBool("by-label")
|
||||||
searchWithLabelMatch, _ := cmd.Flags().GetBool("by-label-regex")
|
searchWithLabelMatch, _ := cmd.Flags().GetBool("by-label-regex")
|
||||||
revdeps, _ := cmd.Flags().GetBool("revdeps")
|
revdeps, _ := cmd.Flags().GetBool("revdeps")
|
||||||
tableMode, _ := cmd.Flags().GetBool("table")
|
tableMode, _ := cmd.Flags().GetBool("table")
|
||||||
files, _ := cmd.Flags().GetBool("files")
|
files, _ := cmd.Flags().GetBool("files")
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
util.SetSystemConfig()
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
util.SetSolverConfig()
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
out, _ := cmd.Flags().GetString("output")
|
out, _ := cmd.Flags().GetString("output")
|
||||||
if out != "terminal" {
|
if out != "terminal" {
|
||||||
LuetCfg.GetLogging().SetLogLevel("error")
|
LuetCfg.GetLogging().SetLogLevel("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
LuetCfg.GetSolverOptions().Type = stype
|
|
||||||
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
|
||||||
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
|
||||||
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
|
||||||
|
|
||||||
l := list.NewWriter()
|
l := list.NewWriter()
|
||||||
t := table.NewWriter()
|
t := table.NewWriter()
|
||||||
t.AppendHeader(rows)
|
t.AppendHeader(rows)
|
||||||
|
@@ -16,6 +16,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
helpers "github.com/mudler/luet/cmd/helpers"
|
helpers "github.com/mudler/luet/cmd/helpers"
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
installer "github.com/mudler/luet/pkg/installer"
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
@@ -31,16 +32,11 @@ var uninstallCmd = &cobra.Command{
|
|||||||
Long: `Uninstall packages`,
|
Long: `Uninstall packages`,
|
||||||
Aliases: []string{"rm", "un"},
|
Aliases: []string{"rm", "un"},
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
|
||||||
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
LuetCfg.Viper.BindPFlag("nodeps", cmd.Flags().Lookup("nodeps"))
|
||||||
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
LuetCfg.Viper.BindPFlag("force", cmd.Flags().Lookup("force"))
|
||||||
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
toRemove := []pkg.Package{}
|
toRemove := []pkg.Package{}
|
||||||
@@ -53,10 +49,6 @@ var uninstallCmd = &cobra.Command{
|
|||||||
toRemove = append(toRemove, pack)
|
toRemove = append(toRemove, pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
force := LuetCfg.Viper.GetBool("force")
|
force := LuetCfg.Viper.GetBool("force")
|
||||||
nodeps, _ := cmd.Flags().GetBool("nodeps")
|
nodeps, _ := cmd.Flags().GetBool("nodeps")
|
||||||
full, _ := cmd.Flags().GetBool("full")
|
full, _ := cmd.Flags().GetBool("full")
|
||||||
@@ -64,20 +56,12 @@ var uninstallCmd = &cobra.Command{
|
|||||||
fullClean, _ := cmd.Flags().GetBool("full-clean")
|
fullClean, _ := cmd.Flags().GetBool("full-clean")
|
||||||
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
||||||
yes := LuetCfg.Viper.GetBool("yes")
|
yes := LuetCfg.Viper.GetBool("yes")
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
keepProtected, _ := cmd.Flags().GetBool("keep-protected-files")
|
keepProtected, _ := cmd.Flags().GetBool("keep-protected-files")
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
util.SetSystemConfig()
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
util.SetSolverConfig()
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
LuetCfg.ConfigProtectSkip = !keepProtected
|
|
||||||
|
|
||||||
LuetCfg.GetSolverOptions().Type = stype
|
LuetCfg.ConfigProtectSkip = !keepProtected
|
||||||
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
|
||||||
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
|
||||||
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
|
||||||
if concurrent {
|
if concurrent {
|
||||||
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
||||||
} else {
|
} else {
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/mudler/luet/cmd/util"
|
||||||
. "github.com/mudler/luet/pkg/config"
|
. "github.com/mudler/luet/pkg/config"
|
||||||
installer "github.com/mudler/luet/pkg/installer"
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
. "github.com/mudler/luet/pkg/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
@@ -28,15 +29,10 @@ var upgradeCmd = &cobra.Command{
|
|||||||
Short: "Upgrades the system",
|
Short: "Upgrades the system",
|
||||||
Aliases: []string{"u"},
|
Aliases: []string{"u"},
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
LuetCfg.Viper.BindPFlag("system.database_path", installCmd.Flags().Lookup("system-dbpath"))
|
util.BindSystemFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("system.rootfs", installCmd.Flags().Lookup("system-target"))
|
util.BindSolverFlags(cmd)
|
||||||
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
|
||||||
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
|
||||||
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("force", cmd.Flags().Lookup("force"))
|
||||||
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
LuetCfg.Viper.BindPFlag("yes", cmd.Flags().Lookup("yes"))
|
||||||
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
|
||||||
},
|
},
|
||||||
Long: `Upgrades packages in parallel`,
|
Long: `Upgrades packages in parallel`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
@@ -51,10 +47,6 @@ var upgradeCmd = &cobra.Command{
|
|||||||
repos = append(repos, r)
|
repos = append(repos, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
|
||||||
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
|
||||||
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
|
||||||
force := LuetCfg.Viper.GetBool("force")
|
force := LuetCfg.Viper.GetBool("force")
|
||||||
nodeps, _ := cmd.Flags().GetBool("nodeps")
|
nodeps, _ := cmd.Flags().GetBool("nodeps")
|
||||||
full, _ := cmd.Flags().GetBool("full")
|
full, _ := cmd.Flags().GetBool("full")
|
||||||
@@ -63,18 +55,11 @@ var upgradeCmd = &cobra.Command{
|
|||||||
sync, _ := cmd.Flags().GetBool("sync")
|
sync, _ := cmd.Flags().GetBool("sync")
|
||||||
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
concurrent, _ := cmd.Flags().GetBool("solver-concurrent")
|
||||||
yes := LuetCfg.Viper.GetBool("yes")
|
yes := LuetCfg.Viper.GetBool("yes")
|
||||||
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
|
||||||
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
|
||||||
engine := LuetCfg.Viper.GetString("system.database_engine")
|
|
||||||
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
downloadOnly, _ := cmd.Flags().GetBool("download-only")
|
||||||
|
|
||||||
LuetCfg.System.DatabaseEngine = engine
|
util.SetSystemConfig()
|
||||||
LuetCfg.System.DatabasePath = dbpath
|
util.SetSolverConfig()
|
||||||
LuetCfg.System.SetRootFS(rootfs)
|
|
||||||
LuetCfg.GetSolverOptions().Type = stype
|
|
||||||
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
|
||||||
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
|
||||||
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
|
||||||
if concurrent {
|
if concurrent {
|
||||||
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
LuetCfg.GetSolverOptions().Implementation = solver.ParallelSimple
|
||||||
} else {
|
} else {
|
||||||
|
65
cmd/util/cli.go
Normal file
65
cmd/util/cli.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
// Copyright © 2021 Ettore Di Giacinto <mudler@mocaccino.org>
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/mudler/luet/pkg/config"
|
||||||
|
. "github.com/mudler/luet/pkg/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func BindSystemFlags(cmd *cobra.Command) {
|
||||||
|
LuetCfg.Viper.BindPFlag("system.database_path", cmd.Flags().Lookup("system-dbpath"))
|
||||||
|
LuetCfg.Viper.BindPFlag("system.rootfs", cmd.Flags().Lookup("system-target"))
|
||||||
|
LuetCfg.Viper.BindPFlag("system.database_engine", cmd.Flags().Lookup("system-engine"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func BindSolverFlags(cmd *cobra.Command) {
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.type", cmd.Flags().Lookup("solver-type"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.discount", cmd.Flags().Lookup("solver-discount"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.rate", cmd.Flags().Lookup("solver-rate"))
|
||||||
|
LuetCfg.Viper.BindPFlag("solver.max_attempts", cmd.Flags().Lookup("solver-attempts"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetSystemConfig() {
|
||||||
|
dbpath := LuetCfg.Viper.GetString("system.database_path")
|
||||||
|
rootfs := LuetCfg.Viper.GetString("system.rootfs")
|
||||||
|
engine := LuetCfg.Viper.GetString("system.database_engine")
|
||||||
|
|
||||||
|
LuetCfg.System.DatabaseEngine = engine
|
||||||
|
LuetCfg.System.DatabasePath = dbpath
|
||||||
|
LuetCfg.System.SetRootFS(rootfs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetSolverConfig() (c *config.LuetSolverOptions) {
|
||||||
|
stype := LuetCfg.Viper.GetString("solver.type")
|
||||||
|
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
||||||
|
rate := LuetCfg.Viper.GetFloat64("solver.rate")
|
||||||
|
attempts := LuetCfg.Viper.GetInt("solver.max_attempts")
|
||||||
|
|
||||||
|
LuetCfg.GetSolverOptions().Type = stype
|
||||||
|
LuetCfg.GetSolverOptions().LearnRate = float32(rate)
|
||||||
|
LuetCfg.GetSolverOptions().Discount = float32(discount)
|
||||||
|
LuetCfg.GetSolverOptions().MaxAttempts = attempts
|
||||||
|
|
||||||
|
return &config.LuetSolverOptions{
|
||||||
|
Type: stype,
|
||||||
|
LearnRate: float32(rate),
|
||||||
|
Discount: float32(discount),
|
||||||
|
MaxAttempts: attempts,
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user