mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 10:36:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3950c5f0d6
|
||
|
|
f3c2b9f0f6
|
@@ -159,7 +159,7 @@ func ResolveDependencies(pkgInfo *PackageInfo, resolvedVirtualPackages map[strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip ignored packages in config
|
// Skip ignored packages in config
|
||||||
if slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) {
|
if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -51,7 +51,7 @@ func InstallPackages(rootDir string, forceInstallationReason InstallationReason,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operation.AppendAction(&InstallPackageAction{
|
operation.Actions = append(operation.Actions, &InstallPackageAction{
|
||||||
File: pkg,
|
File: pkg,
|
||||||
InstallationReason: installationReason,
|
InstallationReason: installationReason,
|
||||||
BpmPackage: bpmpkg,
|
BpmPackage: bpmpkg,
|
||||||
@@ -75,7 +75,7 @@ func InstallPackages(rootDir string, forceInstallationReason InstallationReason,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operation.AppendAction(&InstallPackageAction{
|
operation.Actions = append(operation.Actions, &InstallPackageAction{
|
||||||
File: pkg,
|
File: pkg,
|
||||||
InstallationReason: installationReason,
|
InstallationReason: installationReason,
|
||||||
BpmPackage: bpmpkg,
|
BpmPackage: bpmpkg,
|
||||||
@@ -120,7 +120,7 @@ func InstallPackages(rootDir string, forceInstallationReason InstallationReason,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.Actions = append(operation.Actions, &FetchPackageAction{
|
||||||
InstallationReason: installationReason,
|
InstallationReason: installationReason,
|
||||||
DatabaseEntry: entry,
|
DatabaseEntry: entry,
|
||||||
})
|
})
|
||||||
@@ -206,7 +206,7 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages ..
|
|||||||
if bpmpkg == nil {
|
if bpmpkg == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
operation.AppendAction(&RemovePackageAction{BpmPackage: bpmpkg})
|
operation.Actions = append(operation.Actions, &RemovePackageAction{BpmPackage: bpmpkg})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do package cleanup
|
// Do package cleanup
|
||||||
@@ -223,7 +223,7 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages ..
|
|||||||
packageDepndants := make(map[string][]string, 0)
|
packageDepndants := make(map[string][]string, 0)
|
||||||
for _, action := range operation.Actions {
|
for _, action := range operation.Actions {
|
||||||
// Skip package if ignored in config
|
// Skip package if ignored in config
|
||||||
if slices.Contains(MainBPMConfig.IgnorePackages, action.(*RemovePackageAction).BpmPackage.PkgInfo.Name) {
|
if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, action.(*RemovePackageAction).BpmPackage.PkgInfo.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages ..
|
|||||||
// Remove dependant packages if ignored
|
// Remove dependant packages if ignored
|
||||||
for pkg, required := range packageDepndants {
|
for pkg, required := range packageDepndants {
|
||||||
required = slices.DeleteFunc(required, func(pkgName string) bool {
|
required = slices.DeleteFunc(required, func(pkgName string) bool {
|
||||||
return slices.Contains(MainBPMConfig.IgnorePackages, pkgName)
|
return rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, pkgName)
|
||||||
})
|
})
|
||||||
packageDepndants[pkg] = required
|
packageDepndants[pkg] = required
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
|
|||||||
// Search for packages
|
// Search for packages
|
||||||
pkgsNotFound := make([]string, 0)
|
pkgsNotFound := make([]string, 0)
|
||||||
for _, pkg := range pkgs {
|
for _, pkg := range pkgs {
|
||||||
if slices.Contains(MainBPMConfig.IgnorePackages, pkg) {
|
if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, pkg) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var entry *BPMDatabaseEntry
|
var entry *BPMDatabaseEntry
|
||||||
@@ -421,7 +421,7 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
|
|||||||
} else {
|
} else {
|
||||||
comparison := CompareVersions(entry.Info.GetFullVersion(), installedInfo.GetFullVersion())
|
comparison := CompareVersions(entry.Info.GetFullVersion(), installedInfo.GetFullVersion())
|
||||||
if (!allowDowngrades && comparison > 0) || (allowDowngrades && comparison != 0) {
|
if (!allowDowngrades && comparison > 0) || (allowDowngrades && comparison != 0) {
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.Actions = append(operation.Actions, &FetchPackageAction{
|
||||||
InstallationReason: GetPackage(pkg, rootDir).LocalInfo.GetInstallationReason(),
|
InstallationReason: GetPackage(pkg, rootDir).LocalInfo.GetInstallationReason(),
|
||||||
DatabaseEntry: entry,
|
DatabaseEntry: entry,
|
||||||
})
|
})
|
||||||
@@ -452,12 +452,12 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip dependency if action already exists
|
// Skip dependency if action already exists
|
||||||
if operation.ActionsContainPackage(dependEntry.Info.Name) {
|
if ActionSliceIndex(operation.Actions, dependEntry.Info.Name) != -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip dependency if ignored in config
|
// Skip dependency if ignored in config
|
||||||
if slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) {
|
if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch dependency
|
// Fetch dependency
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.Actions = append(operation.Actions, &FetchPackageAction{
|
||||||
InstallationReason: InstallationReasonDependency,
|
InstallationReason: InstallationReasonDependency,
|
||||||
DatabaseEntry: dependEntry,
|
DatabaseEntry: dependEntry,
|
||||||
})
|
})
|
||||||
@@ -499,7 +499,7 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip dependency if ignored in config
|
// Skip dependency if ignored in config
|
||||||
if slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) {
|
if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch dependency
|
// Fetch dependency
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.Actions = append(operation.Actions, &FetchPackageAction{
|
||||||
InstallationReason: InstallationReasonDependency,
|
InstallationReason: InstallationReasonDependency,
|
||||||
DatabaseEntry: dependEntry,
|
DatabaseEntry: dependEntry,
|
||||||
})
|
})
|
||||||
|
|||||||
+57
-58
@@ -23,54 +23,6 @@ type BPMOperation struct {
|
|||||||
hasFetchedPackages bool
|
hasFetchedPackages bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (operation *BPMOperation) ActionsContainPackage(pkg string) bool {
|
|
||||||
for _, action := range operation.Actions {
|
|
||||||
if action.GetActionType() == "install" {
|
|
||||||
if action.(*InstallPackageAction).BpmPackage.PkgInfo.Name == pkg {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
} else if action.GetActionType() == "fetch" {
|
|
||||||
if action.(*FetchPackageAction).DatabaseEntry.Info.Name == pkg {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
} else if action.GetActionType() == "remove" {
|
|
||||||
if action.(*RemovePackageAction).BpmPackage.PkgInfo.Name == pkg {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (operation *BPMOperation) AppendAction(action OperationAction) {
|
|
||||||
operation.InsertActionAt(len(operation.Actions), action)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (operation *BPMOperation) InsertActionAt(index int, action OperationAction) {
|
|
||||||
if len(operation.Actions) == index { // nil or empty slice or after last element
|
|
||||||
operation.Actions = append(operation.Actions, action)
|
|
||||||
} else {
|
|
||||||
operation.Actions = append(operation.Actions[:index+1], operation.Actions[index:]...) // index < len(a)
|
|
||||||
operation.Actions[index] = action
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (operation *BPMOperation) RemoveAction(pkg, actionType string) {
|
|
||||||
operation.Actions = slices.DeleteFunc(operation.Actions, func(a OperationAction) bool {
|
|
||||||
if a.GetActionType() != actionType {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if a.GetActionType() == "install" {
|
|
||||||
return a.(*InstallPackageAction).BpmPackage.PkgInfo.Name == pkg
|
|
||||||
} else if a.GetActionType() == "fetch" {
|
|
||||||
return a.(*FetchPackageAction).DatabaseEntry.Info.Name == pkg
|
|
||||||
} else if a.GetActionType() == "remove" {
|
|
||||||
return a.(*RemovePackageAction).BpmPackage.PkgInfo.Name == pkg
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (operation *BPMOperation) GetTotalDownloadSize() int64 {
|
func (operation *BPMOperation) GetTotalDownloadSize() int64 {
|
||||||
var ret int64 = 0
|
var ret int64 = 0
|
||||||
for _, action := range operation.Actions {
|
for _, action := range operation.Actions {
|
||||||
@@ -136,8 +88,8 @@ func (operation *BPMOperation) ResolveDependencies(installRuntimeDepends bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Discover all dependencies
|
// Discover all dependencies
|
||||||
pos := 0
|
newActions := make([]OperationAction, 0)
|
||||||
for _, value := range slices.Clone(operation.Actions) {
|
for _, value := range operation.Actions {
|
||||||
var pkgInfo *PackageInfo
|
var pkgInfo *PackageInfo
|
||||||
if value.GetActionType() == "install" {
|
if value.GetActionType() == "install" {
|
||||||
action := value.(*InstallPackageAction)
|
action := value.(*InstallPackageAction)
|
||||||
@@ -156,11 +108,12 @@ func (operation *BPMOperation) ResolveDependencies(installRuntimeDepends bool) {
|
|||||||
operation.UnresolvedDepends = removeDuplicates(operation.UnresolvedDepends)
|
operation.UnresolvedDepends = removeDuplicates(operation.UnresolvedDepends)
|
||||||
|
|
||||||
for _, resolvedPkg := range resolved {
|
for _, resolvedPkg := range resolved {
|
||||||
if !operation.ActionsContainPackage(resolvedPkg.DatabaseEntry.Info.Name) && resolvedPkg.DatabaseEntry.Info.Name != pkgInfo.Name {
|
if ActionSliceIndex(newActions, resolvedPkg.DatabaseEntry.Info.Name) == -1 { // Dependency not in actions slice
|
||||||
operation.InsertActionAt(pos, &FetchPackageAction{
|
var action OperationAction = &FetchPackageAction{
|
||||||
InstallationReason: resolvedPkg.InstallationReason,
|
InstallationReason: resolvedPkg.InstallationReason,
|
||||||
DatabaseEntry: resolvedPkg.DatabaseEntry,
|
DatabaseEntry: resolvedPkg.DatabaseEntry,
|
||||||
})
|
}
|
||||||
|
newActions = append(newActions, action)
|
||||||
|
|
||||||
for _, vpkg := range resolvedPkg.DatabaseEntry.Info.Provides {
|
for _, vpkg := range resolvedPkg.DatabaseEntry.Info.Provides {
|
||||||
if _, ok := resolvedVirtualPackages[vpkg]; !ok {
|
if _, ok := resolvedVirtualPackages[vpkg]; !ok {
|
||||||
@@ -168,12 +121,19 @@ func (operation *BPMOperation) ResolveDependencies(installRuntimeDepends bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++
|
// Check if can move original action
|
||||||
|
if i := ActionSliceIndex(operation.Actions, resolvedPkg.DatabaseEntry.Info.Name); i != -1 {
|
||||||
|
newActions[len(newActions)-1] = operation.Actions[i]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++
|
if ActionSliceIndex(newActions, pkgInfo.Name) == -1 {
|
||||||
|
newActions = append(newActions, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operation.Actions = newActions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (operation *BPMOperation) Cleanup(cleanupMakeDepends bool) error {
|
func (operation *BPMOperation) Cleanup(cleanupMakeDepends bool) error {
|
||||||
@@ -289,10 +249,11 @@ func (operation *BPMOperation) ReplaceObsoletePackages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range pkgInfo.Replaces {
|
for _, r := range pkgInfo.Replaces {
|
||||||
if bpmpkg := GetPackage(r, operation.RootDir); bpmpkg != nil && !operation.ActionsContainPackage(bpmpkg.PkgInfo.Name) {
|
if bpmpkg := GetPackage(r, operation.RootDir); bpmpkg != nil && ActionSliceIndex(operation.Actions, bpmpkg.PkgInfo.Name) == -1 {
|
||||||
operation.InsertActionAt(0, &RemovePackageAction{
|
var action OperationAction = &RemovePackageAction{
|
||||||
BpmPackage: bpmpkg,
|
BpmPackage: bpmpkg,
|
||||||
})
|
}
|
||||||
|
operation.Actions = slices.Insert(operation.Actions, 0, action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -832,3 +793,41 @@ type RemovePackageAction struct {
|
|||||||
func (action *RemovePackageAction) GetActionType() string {
|
func (action *RemovePackageAction) GetActionType() string {
|
||||||
return "remove"
|
return "remove"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ActionSliceIndex(actions []OperationAction, pkg string) int {
|
||||||
|
for i, action := range actions {
|
||||||
|
if action.GetActionType() == "install" {
|
||||||
|
if action.(*InstallPackageAction).BpmPackage.PkgInfo.Name == pkg {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
} else if action.GetActionType() == "fetch" {
|
||||||
|
if action.(*FetchPackageAction).DatabaseEntry.Info.Name == pkg {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
} else if action.GetActionType() == "remove" {
|
||||||
|
if action.(*RemovePackageAction).BpmPackage.PkgInfo.Name == pkg {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func ActionSliceRemove(actions []OperationAction, pkg, actionType string) []OperationAction {
|
||||||
|
actions = slices.DeleteFunc(actions, func(a OperationAction) bool {
|
||||||
|
if a.GetActionType() != actionType {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if a.GetActionType() == "install" {
|
||||||
|
return a.(*InstallPackageAction).BpmPackage.PkgInfo.Name == pkg
|
||||||
|
} else if a.GetActionType() == "fetch" {
|
||||||
|
return a.(*FetchPackageAction).DatabaseEntry.Info.Name == pkg
|
||||||
|
} else if a.GetActionType() == "remove" {
|
||||||
|
return a.(*RemovePackageAction).BpmPackage.PkgInfo.Name == pkg
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
return actions
|
||||||
|
}
|
||||||
|
|||||||
@@ -703,7 +703,7 @@ func extractPackage(bpmpkg *BPMPackage, verbose bool, filename, rootDir string)
|
|||||||
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
||||||
matched, _ := filepath.Match(s, header.Name)
|
matched, _ := filepath.Match(s, header.Name)
|
||||||
return matched
|
return matched
|
||||||
}); ok {
|
}); rootDir == "/" && ok {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Skipping Directory: %s (Path was ignored)\n", extractFilename)
|
fmt.Printf("Skipping Directory: %s (Path was ignored)\n", extractFilename)
|
||||||
}
|
}
|
||||||
@@ -741,7 +741,7 @@ func extractPackage(bpmpkg *BPMPackage, verbose bool, filename, rootDir string)
|
|||||||
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
||||||
matched, _ := filepath.Match(s, header.Name)
|
matched, _ := filepath.Match(s, header.Name)
|
||||||
return matched
|
return matched
|
||||||
}); ok {
|
}); rootDir == "/" && ok {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Skipping File: %s (Path was ignored)\n", extractFilename)
|
fmt.Printf("Skipping File: %s (Path was ignored)\n", extractFilename)
|
||||||
}
|
}
|
||||||
@@ -809,7 +809,7 @@ func extractPackage(bpmpkg *BPMPackage, verbose bool, filename, rootDir string)
|
|||||||
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
||||||
matched, _ := filepath.Match(s, header.Name)
|
matched, _ := filepath.Match(s, header.Name)
|
||||||
return matched
|
return matched
|
||||||
}); ok {
|
}); rootDir == "/" && ok {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Skipping Symlink: %s (Path was ignored)\n", extractFilename)
|
fmt.Printf("Skipping Symlink: %s (Path was ignored)\n", extractFilename)
|
||||||
}
|
}
|
||||||
@@ -835,7 +835,7 @@ func extractPackage(bpmpkg *BPMPackage, verbose bool, filename, rootDir string)
|
|||||||
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
||||||
matched, _ := filepath.Match(s, header.Name)
|
matched, _ := filepath.Match(s, header.Name)
|
||||||
return matched
|
return matched
|
||||||
}); ok {
|
}); rootDir == "/" && ok {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Skipping Hard Link: %s (Path was ignored)\n", extractFilename)
|
fmt.Printf("Skipping Hard Link: %s (Path was ignored)\n", extractFilename)
|
||||||
}
|
}
|
||||||
@@ -930,7 +930,7 @@ func installPackage(filename string, installationReason InstallationReason, root
|
|||||||
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
||||||
matched, _ := filepath.Match(s, entry.Path)
|
matched, _ := filepath.Match(s, entry.Path)
|
||||||
return matched
|
return matched
|
||||||
}); ok {
|
}); rootDir == "/" && ok {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Skipping path: %s (Path was ignored)\n", finalPath)
|
fmt.Printf("Skipping path: %s (Path was ignored)\n", finalPath)
|
||||||
}
|
}
|
||||||
@@ -1183,7 +1183,7 @@ func removePackage(pkg string, verbose bool, rootDir string) error {
|
|||||||
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
if ok := slices.ContainsFunc(MainBPMConfig.IgnorePaths, func(s string) bool {
|
||||||
matched, _ := filepath.Match(s, entry.Path)
|
matched, _ := filepath.Match(s, entry.Path)
|
||||||
return matched
|
return matched
|
||||||
}); ok {
|
}); rootDir == "/" && ok {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Skipping path: %s (Path was ignored)\n", finalPath)
|
fmt.Printf("Skipping path: %s (Path was ignored)\n", finalPath)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user