Merge branch 'improve_compile_error' into audit_dups
This commit is contained in:
100
remove.ce
100
remove.ce
@@ -43,64 +43,64 @@ var run = function() {
|
||||
return
|
||||
}
|
||||
|
||||
target_pkg = shop.resolve_locator(target_pkg)
|
||||
target_pkg = shop.resolve_locator(target_pkg)
|
||||
|
||||
var packages_to_remove = [target_pkg]
|
||||
var packages_to_remove = [target_pkg]
|
||||
|
||||
var lock = null
|
||||
var all_packages = null
|
||||
var needed = null
|
||||
if (prune) {
|
||||
// Find packages no longer needed
|
||||
// Get all dependencies of remaining packages
|
||||
lock = shop.load_lock()
|
||||
all_packages = shop.list_packages()
|
||||
var lock = null
|
||||
var all_packages = null
|
||||
var needed = null
|
||||
if (prune) {
|
||||
// Find packages no longer needed
|
||||
// Get all dependencies of remaining packages
|
||||
lock = shop.load_lock()
|
||||
all_packages = shop.list_packages()
|
||||
|
||||
// Build set of all needed packages (excluding target)
|
||||
needed = {}
|
||||
arrfor(all_packages, function(p) {
|
||||
if (p == target_pkg || p == 'core') return
|
||||
// Build set of all needed packages (excluding target)
|
||||
needed = {}
|
||||
arrfor(all_packages, function(p) {
|
||||
if (p == target_pkg || p == 'core') return
|
||||
|
||||
// Mark this package and its deps as needed
|
||||
needed[p] = true
|
||||
var _gather = function() {
|
||||
var deps = pkg.gather_dependencies(p)
|
||||
arrfor(deps, function(dep) {
|
||||
needed[dep] = true
|
||||
})
|
||||
} disruption {
|
||||
// Skip if can't read deps
|
||||
}
|
||||
_gather()
|
||||
})
|
||||
// Mark this package and its deps as needed
|
||||
needed[p] = true
|
||||
var _gather = function() {
|
||||
var deps = pkg.gather_dependencies(p)
|
||||
arrfor(deps, function(dep) {
|
||||
needed[dep] = true
|
||||
})
|
||||
} disruption {
|
||||
// Skip if can't read deps
|
||||
}
|
||||
_gather()
|
||||
})
|
||||
|
||||
// Find packages that are NOT needed
|
||||
arrfor(all_packages, function(p) {
|
||||
if (p == 'core') return
|
||||
if (!needed[p] && find(packages_to_remove, p) == null) {
|
||||
push(packages_to_remove, p)
|
||||
}
|
||||
})
|
||||
}
|
||||
// Find packages that are NOT needed
|
||||
arrfor(all_packages, function(p) {
|
||||
if (p == 'core') return
|
||||
if (!needed[p] && find(packages_to_remove, p) == null) {
|
||||
push(packages_to_remove, p)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (dry_run) {
|
||||
log.console("Would remove:")
|
||||
arrfor(packages_to_remove, function(p) {
|
||||
log.console(" " + p)
|
||||
})
|
||||
} else {
|
||||
arrfor(packages_to_remove, function(p) {
|
||||
// Remove any link for this package
|
||||
if (link.is_linked(p)) {
|
||||
link.remove(p)
|
||||
}
|
||||
if (dry_run) {
|
||||
log.console("Would remove:")
|
||||
arrfor(packages_to_remove, function(p) {
|
||||
log.console(" " + p)
|
||||
})
|
||||
} else {
|
||||
arrfor(packages_to_remove, function(p) {
|
||||
// Remove any link for this package
|
||||
if (link.is_linked(p)) {
|
||||
link.remove(p)
|
||||
}
|
||||
|
||||
// Remove from shop
|
||||
shop.remove(p)
|
||||
})
|
||||
// Remove from shop
|
||||
shop.remove(p)
|
||||
})
|
||||
|
||||
log.console("Removed " + text(length(packages_to_remove)) + " package(s).")
|
||||
}
|
||||
log.console("Removed " + text(length(packages_to_remove)) + " package(s).")
|
||||
}
|
||||
}
|
||||
run()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user