mirror of
https://github.com/mudler/luet.git
synced 2025-09-05 01:00:44 +00:00
Concurrency option is now global
* concurrency could be configured now from cmdline, configuration file or LUET_GENERAL__CONCURRENCY env variable * verbose option is now related to debug option
This commit is contained in:
committed by
Ettore Di Giacinto
parent
358b39b5dd
commit
16453bd09f
@@ -18,15 +18,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
|
||||||
"github.com/mudler/luet/pkg/compiler"
|
"github.com/mudler/luet/pkg/compiler"
|
||||||
"github.com/mudler/luet/pkg/compiler/backend"
|
"github.com/mudler/luet/pkg/compiler/backend"
|
||||||
|
. "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"
|
||||||
tree "github.com/mudler/luet/pkg/tree"
|
tree "github.com/mudler/luet/pkg/tree"
|
||||||
|
|
||||||
|
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
@@ -39,7 +39,6 @@ var buildCmd = &cobra.Command{
|
|||||||
viper.BindPFlag("tree", cmd.Flags().Lookup("tree"))
|
viper.BindPFlag("tree", cmd.Flags().Lookup("tree"))
|
||||||
viper.BindPFlag("destination", cmd.Flags().Lookup("destination"))
|
viper.BindPFlag("destination", cmd.Flags().Lookup("destination"))
|
||||||
viper.BindPFlag("backend", cmd.Flags().Lookup("backend"))
|
viper.BindPFlag("backend", cmd.Flags().Lookup("backend"))
|
||||||
viper.BindPFlag("concurrency", cmd.Flags().Lookup("concurrency"))
|
|
||||||
viper.BindPFlag("privileged", cmd.Flags().Lookup("privileged"))
|
viper.BindPFlag("privileged", cmd.Flags().Lookup("privileged"))
|
||||||
viper.BindPFlag("database", cmd.Flags().Lookup("database"))
|
viper.BindPFlag("database", cmd.Flags().Lookup("database"))
|
||||||
viper.BindPFlag("revdeps", cmd.Flags().Lookup("revdeps"))
|
viper.BindPFlag("revdeps", cmd.Flags().Lookup("revdeps"))
|
||||||
@@ -50,7 +49,7 @@ var buildCmd = &cobra.Command{
|
|||||||
|
|
||||||
src := viper.GetString("tree")
|
src := viper.GetString("tree")
|
||||||
dst := viper.GetString("destination")
|
dst := viper.GetString("destination")
|
||||||
concurrency := viper.GetInt("concurrency")
|
concurrency := LuetCfg.GetGeneral().Concurrency
|
||||||
backendType := viper.GetString("backend")
|
backendType := viper.GetString("backend")
|
||||||
privileged := viper.GetBool("privileged")
|
privileged := viper.GetBool("privileged")
|
||||||
revdeps := viper.GetBool("revdeps")
|
revdeps := viper.GetBool("revdeps")
|
||||||
@@ -162,7 +161,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
buildCmd.Flags().String("tree", path, "Source luet tree")
|
buildCmd.Flags().String("tree", path, "Source luet tree")
|
||||||
buildCmd.Flags().String("backend", "docker", "backend used (docker,img)")
|
buildCmd.Flags().String("backend", "docker", "backend used (docker,img)")
|
||||||
buildCmd.Flags().Int("concurrency", runtime.NumCPU(), "Concurrency")
|
|
||||||
buildCmd.Flags().Bool("privileged", false, "Privileged (Keep permissions)")
|
buildCmd.Flags().Bool("privileged", false, "Privileged (Keep permissions)")
|
||||||
buildCmd.Flags().String("database", "memory", "database used for solving (memory,boltdb)")
|
buildCmd.Flags().String("database", "memory", "database used for solving (memory,boltdb)")
|
||||||
buildCmd.Flags().Bool("revdeps", false, "Build with revdeps")
|
buildCmd.Flags().Bool("revdeps", false, "Build with revdeps")
|
||||||
|
@@ -16,8 +16,8 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
|
. "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"
|
||||||
tree "github.com/mudler/luet/pkg/tree"
|
tree "github.com/mudler/luet/pkg/tree"
|
||||||
@@ -33,13 +33,11 @@ var convertCmd = &cobra.Command{
|
|||||||
Long: `Parses external PM and produces a luet parsable tree`,
|
Long: `Parses external PM and produces a luet parsable tree`,
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
viper.BindPFlag("type", cmd.Flags().Lookup("type"))
|
viper.BindPFlag("type", cmd.Flags().Lookup("type"))
|
||||||
viper.BindPFlag("concurrency", cmd.Flags().Lookup("concurrency"))
|
|
||||||
viper.BindPFlag("database", cmd.Flags().Lookup("database"))
|
viper.BindPFlag("database", cmd.Flags().Lookup("database"))
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
t := viper.GetString("type")
|
t := viper.GetString("type")
|
||||||
c := viper.GetInt("concurrency")
|
|
||||||
databaseType := viper.GetString("database")
|
databaseType := viper.GetString("database")
|
||||||
var db pkg.PackageDatabase
|
var db pkg.PackageDatabase
|
||||||
|
|
||||||
@@ -54,9 +52,15 @@ var convertCmd = &cobra.Command{
|
|||||||
var builder tree.Parser
|
var builder tree.Parser
|
||||||
switch t {
|
switch t {
|
||||||
case "gentoo":
|
case "gentoo":
|
||||||
builder = gentoo.NewGentooBuilder(&gentoo.SimpleEbuildParser{}, c, gentoo.InMemory)
|
builder = gentoo.NewGentooBuilder(
|
||||||
|
&gentoo.SimpleEbuildParser{},
|
||||||
|
LuetCfg.GetGeneral().Concurrency,
|
||||||
|
gentoo.InMemory)
|
||||||
default: // dup
|
default: // dup
|
||||||
builder = gentoo.NewGentooBuilder(&gentoo.SimpleEbuildParser{}, c, gentoo.InMemory)
|
builder = gentoo.NewGentooBuilder(
|
||||||
|
&gentoo.SimpleEbuildParser{},
|
||||||
|
LuetCfg.GetGeneral().Concurrency,
|
||||||
|
gentoo.InMemory)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch databaseType {
|
switch databaseType {
|
||||||
@@ -91,7 +95,6 @@ var convertCmd = &cobra.Command{
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
convertCmd.Flags().String("type", "gentoo", "source type")
|
convertCmd.Flags().String("type", "gentoo", "source type")
|
||||||
convertCmd.Flags().Int("concurrency", runtime.NumCPU(), "Concurrency")
|
|
||||||
convertCmd.Flags().String("database", "memory", "database used for solving (memory,boltdb)")
|
convertCmd.Flags().String("database", "memory", "database used for solving (memory,boltdb)")
|
||||||
|
|
||||||
RootCmd.AddCommand(convertCmd)
|
RootCmd.AddCommand(convertCmd)
|
||||||
|
@@ -18,10 +18,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
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/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
|
|
||||||
@@ -35,7 +35,6 @@ var installCmd = &cobra.Command{
|
|||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
||||||
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
||||||
viper.BindPFlag("concurrency", cmd.Flags().Lookup("concurrency"))
|
|
||||||
},
|
},
|
||||||
Long: `Install packages in parallel`,
|
Long: `Install packages in parallel`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
@@ -71,7 +70,7 @@ var installCmd = &cobra.Command{
|
|||||||
synced = append(synced, s)
|
synced = append(synced, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
inst := installer.NewLuetInstaller(viper.GetInt("concurrency"))
|
inst := installer.NewLuetInstaller(LuetCfg.GetGeneral().Concurrency)
|
||||||
|
|
||||||
inst.Repositories(synced)
|
inst.Repositories(synced)
|
||||||
|
|
||||||
@@ -92,7 +91,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
installCmd.Flags().String("system-dbpath", path, "System db path")
|
installCmd.Flags().String("system-dbpath", path, "System db path")
|
||||||
installCmd.Flags().String("system-target", path, "System rootpath")
|
installCmd.Flags().String("system-target", path, "System rootpath")
|
||||||
installCmd.Flags().Int("concurrency", runtime.NumCPU(), "Concurrency")
|
|
||||||
|
|
||||||
RootCmd.AddCommand(installCmd)
|
RootCmd.AddCommand(installCmd)
|
||||||
}
|
}
|
||||||
|
10
cmd/root.go
10
cmd/root.go
@@ -18,6 +18,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/marcsauter/single"
|
"github.com/marcsauter/single"
|
||||||
@@ -101,8 +102,13 @@ func Execute() {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.luet.yaml)")
|
pflags := RootCmd.PersistentFlags()
|
||||||
RootCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
|
pflags.StringVar(&cfgFile, "config", "", "config file (default is $HOME/.luet.yaml)")
|
||||||
|
pflags.BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
|
||||||
|
pflags.Int("concurrency", runtime.NumCPU(), "Concurrency")
|
||||||
|
|
||||||
|
config.LuetCfg.Viper.BindPFlag("general.debug", pflags.Lookup("verbose"))
|
||||||
|
config.LuetCfg.Viper.BindPFlag("general.concurrency", pflags.Lookup("concurrency"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// initConfig reads in config file and ENV variables if set.
|
// initConfig reads in config file and ENV variables if set.
|
||||||
|
@@ -18,7 +18,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
installer "github.com/mudler/luet/pkg/installer"
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
|
|
||||||
@@ -36,7 +35,6 @@ var searchCmd = &cobra.Command{
|
|||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
||||||
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
||||||
viper.BindPFlag("concurrency", cmd.Flags().Lookup("concurrency"))
|
|
||||||
viper.BindPFlag("installed", cmd.Flags().Lookup("installed"))
|
viper.BindPFlag("installed", cmd.Flags().Lookup("installed"))
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
@@ -91,7 +89,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
searchCmd.Flags().String("system-dbpath", path, "System db path")
|
searchCmd.Flags().String("system-dbpath", path, "System db path")
|
||||||
searchCmd.Flags().String("system-target", path, "System rootpath")
|
searchCmd.Flags().String("system-target", path, "System rootpath")
|
||||||
searchCmd.Flags().Int("concurrency", runtime.NumCPU(), "Concurrency")
|
|
||||||
searchCmd.Flags().Bool("installed", false, "Search between system packages")
|
searchCmd.Flags().Bool("installed", false, "Search between system packages")
|
||||||
RootCmd.AddCommand(searchCmd)
|
RootCmd.AddCommand(searchCmd)
|
||||||
}
|
}
|
||||||
|
@@ -18,11 +18,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
installer "github.com/mudler/luet/pkg/installer"
|
installer "github.com/mudler/luet/pkg/installer"
|
||||||
|
|
||||||
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
||||||
|
. "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"
|
||||||
|
|
||||||
@@ -37,7 +37,6 @@ var uninstallCmd = &cobra.Command{
|
|||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
||||||
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
||||||
viper.BindPFlag("concurrency", cmd.Flags().Lookup("concurrency"))
|
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
@@ -57,7 +56,7 @@ var uninstallCmd = &cobra.Command{
|
|||||||
Uri: make([]string, 0),
|
Uri: make([]string, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
inst := installer.NewLuetInstaller(viper.GetInt("concurrency"))
|
inst := installer.NewLuetInstaller(LuetCfg.GetGeneral().Concurrency)
|
||||||
os.MkdirAll(viper.GetString("system-dbpath"), os.ModePerm)
|
os.MkdirAll(viper.GetString("system-dbpath"), os.ModePerm)
|
||||||
systemDB := pkg.NewBoltDatabase(filepath.Join(viper.GetString("system-dbpath"), "luet.db"))
|
systemDB := pkg.NewBoltDatabase(filepath.Join(viper.GetString("system-dbpath"), "luet.db"))
|
||||||
system := &installer.System{Database: systemDB, Target: viper.GetString("system-target")}
|
system := &installer.System{Database: systemDB, Target: viper.GetString("system-target")}
|
||||||
@@ -77,6 +76,5 @@ func init() {
|
|||||||
}
|
}
|
||||||
uninstallCmd.Flags().String("system-dbpath", path, "System db path")
|
uninstallCmd.Flags().String("system-dbpath", path, "System db path")
|
||||||
uninstallCmd.Flags().String("system-target", path, "System rootpath")
|
uninstallCmd.Flags().String("system-target", path, "System rootpath")
|
||||||
uninstallCmd.Flags().Int("concurrency", runtime.NumCPU(), "Concurrency")
|
|
||||||
RootCmd.AddCommand(uninstallCmd)
|
RootCmd.AddCommand(uninstallCmd)
|
||||||
}
|
}
|
||||||
|
@@ -17,10 +17,10 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
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/logger"
|
. "github.com/mudler/luet/pkg/logger"
|
||||||
pkg "github.com/mudler/luet/pkg/package"
|
pkg "github.com/mudler/luet/pkg/package"
|
||||||
|
|
||||||
@@ -34,7 +34,6 @@ var upgradeCmd = &cobra.Command{
|
|||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
viper.BindPFlag("system-dbpath", cmd.Flags().Lookup("system-dbpath"))
|
||||||
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
viper.BindPFlag("system-target", cmd.Flags().Lookup("system-target"))
|
||||||
viper.BindPFlag("concurrency", cmd.Flags().Lookup("concurrency"))
|
|
||||||
},
|
},
|
||||||
Long: `Upgrades packages in parallel`,
|
Long: `Upgrades packages in parallel`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
@@ -54,7 +53,7 @@ var upgradeCmd = &cobra.Command{
|
|||||||
synced = append(synced, s)
|
synced = append(synced, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
inst := installer.NewLuetInstaller(viper.GetInt("concurrency"))
|
inst := installer.NewLuetInstaller(LuetCfg.GetGeneral().Concurrency)
|
||||||
|
|
||||||
inst.Repositories(synced)
|
inst.Repositories(synced)
|
||||||
|
|
||||||
@@ -75,7 +74,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
upgradeCmd.Flags().String("system-dbpath", path, "System db path")
|
upgradeCmd.Flags().String("system-dbpath", path, "System db path")
|
||||||
upgradeCmd.Flags().String("system-target", path, "System rootpath")
|
upgradeCmd.Flags().String("system-target", path, "System rootpath")
|
||||||
upgradeCmd.Flags().Int("concurrency", runtime.NumCPU(), "Concurrency")
|
|
||||||
|
|
||||||
RootCmd.AddCommand(upgradeCmd)
|
RootCmd.AddCommand(upgradeCmd)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user