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 pkgListNames = false
|
||||
var reinstall = false
|
||||
var noOptional = false
|
||||
var nosync = true
|
||||
|
||||
func main() {
|
||||
@ -207,7 +208,7 @@ func resolveCommand() {
|
||||
}]()
|
||||
for _, pkg := range clone.Keys() {
|
||||
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 {
|
||||
log.Fatalf("Could not resolve dependencies for package (%s). Error: %s\n", pkg, err)
|
||||
}
|
||||
@ -238,7 +239,7 @@ func resolveCommand() {
|
||||
if err != nil {
|
||||
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 {
|
||||
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(" -c lists the amount 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(" -v Show additional information about what BPM is doing")
|
||||
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(" -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(" --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(" -R=<path> lets you define the root path which will be used")
|
||||
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(&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(&noOptional, "no-optional", false, "Prevents installation of optional dependencies")
|
||||
installFlagSet.Usage = printHelp
|
||||
// Update flags
|
||||
updateFlagSet := flag.NewFlagSet("Update flags", flag.ExitOnError)
|
||||
|
@ -20,23 +20,19 @@ import (
|
||||
)
|
||||
|
||||
type PackageInfo struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Description string `yaml:"description,omitempty"`
|
||||
Version string `yaml:"version,omitempty"`
|
||||
Url string `yaml:"url,omitempty"`
|
||||
License string `yaml:"license,omitempty"`
|
||||
Arch string `yaml:"architecture,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Keep []string `yaml:"keep,omitempty"`
|
||||
Depends []string `yaml:"depends,omitempty"`
|
||||
ConditionalDepends map[string][]string `yaml:"conditional_depends,omitempty"`
|
||||
MakeDepends []string `yaml:"make_depends,omitempty"`
|
||||
ConditionalMakeDepends map[string][]string `yaml:"conditional_make_depends,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"`
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Description string `yaml:"description,omitempty"`
|
||||
Version string `yaml:"version,omitempty"`
|
||||
Url string `yaml:"url,omitempty"`
|
||||
License string `yaml:"license,omitempty"`
|
||||
Arch string `yaml:"architecture,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Keep []string `yaml:"keep,omitempty"`
|
||||
Depends []string `yaml:"depends,omitempty"`
|
||||
MakeDepends []string `yaml:"make_depends,omitempty"`
|
||||
OptionalDepends []string `yaml:"optional_depends,omitempty"`
|
||||
Conflicts []string `yaml:"conflicts,omitempty"`
|
||||
Provides []string `yaml:"provides,omitempty"`
|
||||
}
|
||||
|
||||
type InstallationReason string
|
||||
@ -312,23 +308,19 @@ func ExecutePackageScripts(filename, rootDir string, operation Operation, postOp
|
||||
|
||||
func ReadPackageInfo(contents string, defaultValues bool) (*PackageInfo, error) {
|
||||
pkgInfo := PackageInfo{
|
||||
Name: "",
|
||||
Description: "",
|
||||
Version: "",
|
||||
Url: "",
|
||||
License: "",
|
||||
Arch: "",
|
||||
Type: "",
|
||||
Keep: make([]string, 0),
|
||||
Depends: make([]string, 0),
|
||||
ConditionalDepends: make(map[string][]string),
|
||||
MakeDepends: make([]string, 0),
|
||||
ConditionalMakeDepends: make(map[string][]string),
|
||||
Conflicts: make([]string, 0),
|
||||
ConditionalConflicts: make(map[string][]string),
|
||||
Optional: make([]string, 0),
|
||||
ConditionalOptional: make(map[string][]string),
|
||||
Provides: make([]string, 0),
|
||||
Name: "",
|
||||
Description: "",
|
||||
Version: "",
|
||||
Url: "",
|
||||
License: "",
|
||||
Arch: "",
|
||||
Type: "",
|
||||
Keep: make([]string, 0),
|
||||
Depends: make([]string, 0),
|
||||
MakeDepends: make([]string, 0),
|
||||
OptionalDepends: make([]string, 0),
|
||||
Conflicts: make([]string, 0),
|
||||
Provides: make([]string, 0),
|
||||
}
|
||||
err := yaml.Unmarshal([]byte(contents), &pkgInfo)
|
||||
if err != nil {
|
||||
@ -369,18 +361,6 @@ func CreateReadableInfo(showArchitecture, showType, showPackageRelations, showRe
|
||||
}
|
||||
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, "Description: "+pkgInfo.Description)
|
||||
ret = append(ret, "Version: "+pkgInfo.Version)
|
||||
@ -395,13 +375,10 @@ func CreateReadableInfo(showArchitecture, showType, showPackageRelations, showRe
|
||||
if showPackageRelations {
|
||||
appendArray("Dependencies", pkgInfo.Depends)
|
||||
appendArray("Make Dependencies", pkgInfo.MakeDepends)
|
||||
appendArray("Provided packages", pkgInfo.Provides)
|
||||
appendArray("Optional dependencies", pkgInfo.OptionalDepends)
|
||||
appendArray("Conflicting packages", pkgInfo.Conflicts)
|
||||
appendArray("Optional dependencies", pkgInfo.Optional)
|
||||
appendMap("Conditional dependencies", pkgInfo.ConditionalDepends)
|
||||
appendMap("Conditional make dependencies", pkgInfo.ConditionalMakeDepends)
|
||||
appendMap("Conditional conflicting packages", pkgInfo.ConditionalConflicts)
|
||||
appendMap("Conditional optional dependencies", pkgInfo.ConditionalOptional)
|
||||
appendArray("Provided packages", pkgInfo.Provides)
|
||||
|
||||
}
|
||||
if showRemoteInfo {
|
||||
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")
|
||||
}
|
||||
|
||||
func CheckDependencies(pkgInfo *PackageInfo, checkMake, checkConditional bool, rootDir string) []string {
|
||||
func CheckDependencies(pkgInfo *PackageInfo, checkMake, checkOptional bool, rootDir string) []string {
|
||||
var ret []string
|
||||
for _, dependency := range pkgInfo.Depends {
|
||||
if !IsPackageProvided(dependency, rootDir) {
|
||||
@ -1262,30 +1239,14 @@ func CheckDependencies(pkgInfo *PackageInfo, checkMake, checkConditional bool, r
|
||||
}
|
||||
}
|
||||
}
|
||||
if checkConditional {
|
||||
for condition, dependencies := range pkgInfo.ConditionalDepends {
|
||||
if !IsPackageInstalled(condition, rootDir) {
|
||||
continue
|
||||
}
|
||||
for _, dependency := range dependencies {
|
||||
if !IsPackageProvided(dependency, rootDir) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
if checkOptional {
|
||||
for _, dependency := range pkgInfo.OptionalDepends {
|
||||
if !IsPackageProvided(dependency, rootDir) {
|
||||
ret = append(ret, dependency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@ -1296,41 +1257,20 @@ func CheckConflicts(pkgInfo *PackageInfo, checkConditional bool, rootDir string)
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
unresolved := make([]string, 0)
|
||||
toResolve := make([]string, 0)
|
||||
allDepends := make([]string, 0)
|
||||
|
||||
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 {
|
||||
allDepends = append(allDepends, pkgInfo.MakeDepends...)
|
||||
for condition, depends := range pkgInfo.ConditionalMakeDepends {
|
||||
if IsPackageInstalled(condition, rootDir) {
|
||||
allDepends = append(allDepends, depends...)
|
||||
}
|
||||
}
|
||||
toResolve = append(toResolve, pkgInfo.MakeDepends...)
|
||||
}
|
||||
if checkOptional {
|
||||
toResolve = append(toResolve, pkgInfo.OptionalDepends...)
|
||||
}
|
||||
|
||||
resolve := func(depend string) {
|
||||
@ -1349,6 +1289,12 @@ func ResolveAll(pkgInfo *PackageInfo, checkMake, ignoreInstalled bool, rootDir s
|
||||
}
|
||||
resolved = append(resolved, depend)
|
||||
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 {
|
||||
|
@ -43,23 +43,19 @@ func (repo *Repository) ReadLocalDatabase() error {
|
||||
for _, b := range strings.Split(data, "---") {
|
||||
entry := RepositoryEntry{
|
||||
Info: &PackageInfo{
|
||||
Name: "",
|
||||
Description: "",
|
||||
Version: "",
|
||||
Url: "",
|
||||
License: "",
|
||||
Arch: "",
|
||||
Type: "",
|
||||
Keep: make([]string, 0),
|
||||
Depends: make([]string, 0),
|
||||
ConditionalDepends: make(map[string][]string),
|
||||
MakeDepends: make([]string, 0),
|
||||
ConditionalMakeDepends: make(map[string][]string),
|
||||
Conflicts: make([]string, 0),
|
||||
ConditionalConflicts: make(map[string][]string),
|
||||
Optional: make([]string, 0),
|
||||
ConditionalOptional: make(map[string][]string),
|
||||
Provides: make([]string, 0),
|
||||
Name: "",
|
||||
Description: "",
|
||||
Version: "",
|
||||
Url: "",
|
||||
License: "",
|
||||
Arch: "",
|
||||
Type: "",
|
||||
Keep: make([]string, 0),
|
||||
Depends: make([]string, 0),
|
||||
MakeDepends: make([]string, 0),
|
||||
OptionalDepends: make([]string, 0),
|
||||
Conflicts: make([]string, 0),
|
||||
Provides: make([]string, 0),
|
||||
},
|
||||
Download: "",
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user