Fixed issue where ResolveAll would not resolve make dependencies and optional dependencies and removed conditional dependencies
This commit is contained in:
parent
747c770499
commit
2fd01a3fc2
10
main.go
10
main.go
@ -35,6 +35,7 @@ var showInstalled = false
|
|||||||
var pkgListNumbers = false
|
var pkgListNumbers = false
|
||||||
var pkgListNames = false
|
var pkgListNames = false
|
||||||
var reinstall = false
|
var reinstall = false
|
||||||
|
var noOptional = false
|
||||||
var nosync = true
|
var nosync = true
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -207,7 +208,7 @@ func resolveCommand() {
|
|||||||
}]()
|
}]()
|
||||||
for _, pkg := range clone.Keys() {
|
for _, pkg := range clone.Keys() {
|
||||||
value := clone.GetElement(pkg).Value
|
value := clone.GetElement(pkg).Value
|
||||||
resolved, u, err := utils.ResolveAll(value.pkgInfo, false, !reinstall, rootDir)
|
resolved, u, err := utils.ResolveAll(value.pkgInfo, false, !noOptional, !reinstall, rootDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not resolve dependencies for package (%s). Error: %s\n", pkg, err)
|
log.Fatalf("Could not resolve dependencies for package (%s). Error: %s\n", pkg, err)
|
||||||
}
|
}
|
||||||
@ -238,7 +239,7 @@ func resolveCommand() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not read package. Error: %s\n", err)
|
log.Fatalf("Could not read package. Error: %s\n", err)
|
||||||
}
|
}
|
||||||
resolved, u, err := utils.ResolveAll(entry.Info, false, !reinstall, rootDir)
|
resolved, u, err := utils.ResolveAll(entry.Info, false, !noOptional, !reinstall, rootDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not resolve dependencies for package (%s). Error: %s\n", pkg, err)
|
log.Fatalf("Could not resolve dependencies for package (%s). Error: %s\n", pkg, err)
|
||||||
}
|
}
|
||||||
@ -447,7 +448,7 @@ func printHelp() {
|
|||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" -c lists the amount of installed packages")
|
fmt.Println(" -c lists the amount of installed packages")
|
||||||
fmt.Println(" -n lists only the names of installed packages")
|
fmt.Println(" -n lists only the names of installed packages")
|
||||||
fmt.Println("-> bpm install [-R, -v, -y, -f, -o, -c, -b, -k] <files...> | installs the following files")
|
fmt.Println("-> bpm install [-R, -v, -y, -f, -o, -c, -b, -k, --reinstall, --no-optional] <files...> | installs the following files")
|
||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" -v Show additional information about what BPM is doing")
|
fmt.Println(" -v Show additional information about what BPM is doing")
|
||||||
fmt.Println(" -y skips the confirmation prompt")
|
fmt.Println(" -y skips the confirmation prompt")
|
||||||
@ -456,6 +457,8 @@ func printHelp() {
|
|||||||
fmt.Println(" -c=<path> set the compilation directory (defaults to /var/tmp)")
|
fmt.Println(" -c=<path> set the compilation directory (defaults to /var/tmp)")
|
||||||
fmt.Println(" -b creates a binary package from a source package after compilation and saves it in the binary package output directory")
|
fmt.Println(" -b creates a binary package from a source package after compilation and saves it in the binary package output directory")
|
||||||
fmt.Println(" -k keeps the compilation directory created by BPM after source package installation")
|
fmt.Println(" -k keeps the compilation directory created by BPM after source package installation")
|
||||||
|
fmt.Println(" --reinstall Reinstalls packages even if they do not have a newer version available")
|
||||||
|
fmt.Println(" --no-optional Prevents installation of optional dependencies")
|
||||||
fmt.Println("-> bpm update [-R, -v, -y, -f, --reinstall, --nosync] | updates all packages that are available in the repositories")
|
fmt.Println("-> bpm update [-R, -v, -y, -f, --reinstall, --nosync] | updates all packages that are available in the repositories")
|
||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" -v Show additional information about what BPM is doing")
|
fmt.Println(" -v Show additional information about what BPM is doing")
|
||||||
@ -500,6 +503,7 @@ func resolveFlags() {
|
|||||||
installFlagSet.BoolVar(&keepTempDir, "k", false, "Keep temporary directory after source compilation")
|
installFlagSet.BoolVar(&keepTempDir, "k", false, "Keep temporary directory after source compilation")
|
||||||
installFlagSet.BoolVar(&force, "f", false, "Force installation by skipping architecture and dependency resolution")
|
installFlagSet.BoolVar(&force, "f", false, "Force installation by skipping architecture and dependency resolution")
|
||||||
installFlagSet.BoolVar(&reinstall, "reinstall", false, "Reinstalls packages even if they do not have a newer version available")
|
installFlagSet.BoolVar(&reinstall, "reinstall", false, "Reinstalls packages even if they do not have a newer version available")
|
||||||
|
installFlagSet.BoolVar(&noOptional, "no-optional", false, "Prevents installation of optional dependencies")
|
||||||
installFlagSet.Usage = printHelp
|
installFlagSet.Usage = printHelp
|
||||||
// Update flags
|
// Update flags
|
||||||
updateFlagSet := flag.NewFlagSet("Update flags", flag.ExitOnError)
|
updateFlagSet := flag.NewFlagSet("Update flags", flag.ExitOnError)
|
||||||
|
@ -29,13 +29,9 @@ type PackageInfo struct {
|
|||||||
Type string `yaml:"type,omitempty"`
|
Type string `yaml:"type,omitempty"`
|
||||||
Keep []string `yaml:"keep,omitempty"`
|
Keep []string `yaml:"keep,omitempty"`
|
||||||
Depends []string `yaml:"depends,omitempty"`
|
Depends []string `yaml:"depends,omitempty"`
|
||||||
ConditionalDepends map[string][]string `yaml:"conditional_depends,omitempty"`
|
|
||||||
MakeDepends []string `yaml:"make_depends,omitempty"`
|
MakeDepends []string `yaml:"make_depends,omitempty"`
|
||||||
ConditionalMakeDepends map[string][]string `yaml:"conditional_make_depends,omitempty"`
|
OptionalDepends []string `yaml:"optional_depends,omitempty"`
|
||||||
Conflicts []string `yaml:"conflicts,omitempty"`
|
Conflicts []string `yaml:"conflicts,omitempty"`
|
||||||
ConditionalConflicts map[string][]string `yaml:"conditional_conflicts,omitempty"`
|
|
||||||
Optional []string `yaml:"optional,omitempty"`
|
|
||||||
ConditionalOptional map[string][]string `yaml:"conditional_optional,omitempty"`
|
|
||||||
Provides []string `yaml:"provides,omitempty"`
|
Provides []string `yaml:"provides,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,13 +317,9 @@ func ReadPackageInfo(contents string, defaultValues bool) (*PackageInfo, error)
|
|||||||
Type: "",
|
Type: "",
|
||||||
Keep: make([]string, 0),
|
Keep: make([]string, 0),
|
||||||
Depends: make([]string, 0),
|
Depends: make([]string, 0),
|
||||||
ConditionalDepends: make(map[string][]string),
|
|
||||||
MakeDepends: make([]string, 0),
|
MakeDepends: make([]string, 0),
|
||||||
ConditionalMakeDepends: make(map[string][]string),
|
OptionalDepends: make([]string, 0),
|
||||||
Conflicts: make([]string, 0),
|
Conflicts: make([]string, 0),
|
||||||
ConditionalConflicts: make(map[string][]string),
|
|
||||||
Optional: make([]string, 0),
|
|
||||||
ConditionalOptional: make(map[string][]string),
|
|
||||||
Provides: make([]string, 0),
|
Provides: make([]string, 0),
|
||||||
}
|
}
|
||||||
err := yaml.Unmarshal([]byte(contents), &pkgInfo)
|
err := yaml.Unmarshal([]byte(contents), &pkgInfo)
|
||||||
@ -369,18 +361,6 @@ func CreateReadableInfo(showArchitecture, showType, showPackageRelations, showRe
|
|||||||
}
|
}
|
||||||
ret = append(ret, fmt.Sprintf("%s: %s", label, strings.Join(array, ", ")))
|
ret = append(ret, fmt.Sprintf("%s: %s", label, strings.Join(array, ", ")))
|
||||||
}
|
}
|
||||||
appendMap := func(label string, m map[string][]string) {
|
|
||||||
if len(m) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ret = append(ret, label+":")
|
|
||||||
for k, v := range m {
|
|
||||||
if len(v) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ret = append(ret, fmt.Sprintf(" %s: %s", k, strings.Join(v, ", ")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret = append(ret, "Name: "+pkgInfo.Name)
|
ret = append(ret, "Name: "+pkgInfo.Name)
|
||||||
ret = append(ret, "Description: "+pkgInfo.Description)
|
ret = append(ret, "Description: "+pkgInfo.Description)
|
||||||
ret = append(ret, "Version: "+pkgInfo.Version)
|
ret = append(ret, "Version: "+pkgInfo.Version)
|
||||||
@ -395,13 +375,10 @@ func CreateReadableInfo(showArchitecture, showType, showPackageRelations, showRe
|
|||||||
if showPackageRelations {
|
if showPackageRelations {
|
||||||
appendArray("Dependencies", pkgInfo.Depends)
|
appendArray("Dependencies", pkgInfo.Depends)
|
||||||
appendArray("Make Dependencies", pkgInfo.MakeDepends)
|
appendArray("Make Dependencies", pkgInfo.MakeDepends)
|
||||||
appendArray("Provided packages", pkgInfo.Provides)
|
appendArray("Optional dependencies", pkgInfo.OptionalDepends)
|
||||||
appendArray("Conflicting packages", pkgInfo.Conflicts)
|
appendArray("Conflicting packages", pkgInfo.Conflicts)
|
||||||
appendArray("Optional dependencies", pkgInfo.Optional)
|
appendArray("Provided packages", pkgInfo.Provides)
|
||||||
appendMap("Conditional dependencies", pkgInfo.ConditionalDepends)
|
|
||||||
appendMap("Conditional make dependencies", pkgInfo.ConditionalMakeDepends)
|
|
||||||
appendMap("Conditional conflicting packages", pkgInfo.ConditionalConflicts)
|
|
||||||
appendMap("Conditional optional dependencies", pkgInfo.ConditionalOptional)
|
|
||||||
}
|
}
|
||||||
if showRemoteInfo {
|
if showRemoteInfo {
|
||||||
arr := make([]string, 0)
|
arr := make([]string, 0)
|
||||||
@ -1248,7 +1225,7 @@ func GetSourceScript(filename string) (string, error) {
|
|||||||
return "", errors.New("package does not contain a source.sh file")
|
return "", errors.New("package does not contain a source.sh file")
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckDependencies(pkgInfo *PackageInfo, checkMake, checkConditional bool, rootDir string) []string {
|
func CheckDependencies(pkgInfo *PackageInfo, checkMake, checkOptional bool, rootDir string) []string {
|
||||||
var ret []string
|
var ret []string
|
||||||
for _, dependency := range pkgInfo.Depends {
|
for _, dependency := range pkgInfo.Depends {
|
||||||
if !IsPackageProvided(dependency, rootDir) {
|
if !IsPackageProvided(dependency, rootDir) {
|
||||||
@ -1262,30 +1239,14 @@ func CheckDependencies(pkgInfo *PackageInfo, checkMake, checkConditional bool, r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if checkConditional {
|
if checkOptional {
|
||||||
for condition, dependencies := range pkgInfo.ConditionalDepends {
|
for _, dependency := range pkgInfo.OptionalDepends {
|
||||||
if !IsPackageInstalled(condition, rootDir) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, dependency := range dependencies {
|
|
||||||
if !IsPackageProvided(dependency, rootDir) {
|
if !IsPackageProvided(dependency, rootDir) {
|
||||||
ret = append(ret, dependency)
|
ret = append(ret, dependency)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if checkMake {
|
|
||||||
for condition, dependencies := range pkgInfo.ConditionalMakeDepends {
|
|
||||||
if !IsPackageInstalled(condition, rootDir) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, dependency := range dependencies {
|
|
||||||
if !IsPackageInstalled(dependency, rootDir) {
|
|
||||||
ret = append(ret, dependency)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1296,41 +1257,20 @@ func CheckConflicts(pkgInfo *PackageInfo, checkConditional bool, rootDir string)
|
|||||||
ret = append(ret, conflict)
|
ret = append(ret, conflict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if checkConditional {
|
|
||||||
for condition, conflicts := range pkgInfo.ConditionalConflicts {
|
|
||||||
if !IsPackageInstalled(condition, rootDir) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, conflict := range conflicts {
|
|
||||||
if IsPackageInstalled(conflict, rootDir) {
|
|
||||||
ret = append(ret, conflict)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResolveAll(pkgInfo *PackageInfo, checkMake, ignoreInstalled bool, rootDir string) ([]string, []string, error) {
|
func ResolveAll(pkgInfo *PackageInfo, checkMake, checkOptional, ignoreInstalled bool, rootDir string) ([]string, []string, error) {
|
||||||
resolved := make([]string, 0)
|
resolved := make([]string, 0)
|
||||||
unresolved := make([]string, 0)
|
unresolved := make([]string, 0)
|
||||||
toResolve := make([]string, 0)
|
toResolve := make([]string, 0)
|
||||||
allDepends := make([]string, 0)
|
|
||||||
|
|
||||||
toResolve = append(toResolve, pkgInfo.Depends...)
|
toResolve = append(toResolve, pkgInfo.Depends...)
|
||||||
allDepends = append(allDepends, pkgInfo.Depends...)
|
|
||||||
for condition, depends := range pkgInfo.ConditionalDepends {
|
|
||||||
if IsPackageInstalled(condition, rootDir) {
|
|
||||||
allDepends = append(allDepends, depends...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if checkMake {
|
if checkMake {
|
||||||
allDepends = append(allDepends, pkgInfo.MakeDepends...)
|
toResolve = append(toResolve, pkgInfo.MakeDepends...)
|
||||||
for condition, depends := range pkgInfo.ConditionalMakeDepends {
|
|
||||||
if IsPackageInstalled(condition, rootDir) {
|
|
||||||
allDepends = append(allDepends, depends...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if checkOptional {
|
||||||
|
toResolve = append(toResolve, pkgInfo.OptionalDepends...)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve := func(depend string) {
|
resolve := func(depend string) {
|
||||||
@ -1349,6 +1289,12 @@ func ResolveAll(pkgInfo *PackageInfo, checkMake, ignoreInstalled bool, rootDir s
|
|||||||
}
|
}
|
||||||
resolved = append(resolved, depend)
|
resolved = append(resolved, depend)
|
||||||
toResolve = append(toResolve, entry.Info.Depends...)
|
toResolve = append(toResolve, entry.Info.Depends...)
|
||||||
|
if checkMake {
|
||||||
|
toResolve = append(toResolve, entry.Info.MakeDepends...)
|
||||||
|
}
|
||||||
|
if checkOptional {
|
||||||
|
toResolve = append(toResolve, entry.Info.OptionalDepends...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for len(toResolve) > 0 {
|
for len(toResolve) > 0 {
|
||||||
|
@ -52,13 +52,9 @@ func (repo *Repository) ReadLocalDatabase() error {
|
|||||||
Type: "",
|
Type: "",
|
||||||
Keep: make([]string, 0),
|
Keep: make([]string, 0),
|
||||||
Depends: make([]string, 0),
|
Depends: make([]string, 0),
|
||||||
ConditionalDepends: make(map[string][]string),
|
|
||||||
MakeDepends: make([]string, 0),
|
MakeDepends: make([]string, 0),
|
||||||
ConditionalMakeDepends: make(map[string][]string),
|
OptionalDepends: make([]string, 0),
|
||||||
Conflicts: make([]string, 0),
|
Conflicts: make([]string, 0),
|
||||||
ConditionalConflicts: make(map[string][]string),
|
|
||||||
Optional: make([]string, 0),
|
|
||||||
ConditionalOptional: make(map[string][]string),
|
|
||||||
Provides: make([]string, 0),
|
Provides: make([]string, 0),
|
||||||
},
|
},
|
||||||
Download: "",
|
Download: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user