added a clean tool for multipackages
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@854 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
TODO list:
|
||||
- world: first fetch all, then upgrade
|
||||
- multipackage: clean tool
|
||||
- implement a sane exception infrastructure
|
||||
- mirrors: one more and in random order
|
||||
- trigger: Regenerating cracklib dictionary
|
||||
|
||||
@@ -712,6 +712,72 @@ def database(options):
|
||||
dbconn.closeDB()
|
||||
return 0
|
||||
|
||||
elif (options[0] == "multiremove"):
|
||||
|
||||
print_info(green(" * ")+red("Scanning packages that would be removed ..."), back = True)
|
||||
|
||||
branch = etpConst['branch']
|
||||
atoms = []
|
||||
for opt in options[1:]:
|
||||
if (opt.startswith("--branch=")) and (len(opt.split("=")) == 2):
|
||||
branch = opt.split("=")[1]
|
||||
else:
|
||||
atoms.append(opt)
|
||||
|
||||
pkglist = set()
|
||||
dbconn = databaseTools.openServerDatabase(readOnly = True, noUpload = True)
|
||||
allidpackages = dbconn.listAllIdpackages()
|
||||
|
||||
idpackages = set()
|
||||
if not atoms:
|
||||
# choose all
|
||||
for idpackage in allidpackages:
|
||||
if dbconn.isInjected(idpackage):
|
||||
idpackages.add(idpackage)
|
||||
else:
|
||||
for atom in atoms:
|
||||
match = dbconn.atomMatch(atom, matchBranches = (branch,), multiMatch = True, packagesFilter = False)
|
||||
if match[1] != 0:
|
||||
print_warning(red("Attention, no match for: ")+bold(atom))
|
||||
else:
|
||||
for x in match[0]:
|
||||
if dbconn.isInjected(x):
|
||||
idpackages.add(x)
|
||||
|
||||
# check if atoms were found
|
||||
if not idpackages:
|
||||
dbconn.closeDB()
|
||||
print_error(brown(" * ")+red("No packages found."))
|
||||
return 11
|
||||
|
||||
print_info(green(" * ")+blue("These are the packages that would be removed from the database:"))
|
||||
|
||||
for idpackage in idpackages:
|
||||
pkgatom = dbconn.retrieveAtom(idpackage)
|
||||
branch = dbconn.retrieveBranch(idpackage)
|
||||
print_info(darkred(" (*) ")+blue("[")+red(branch)+blue("] ")+brown(pkgatom))
|
||||
|
||||
# ask to continue
|
||||
rc = askquestion(" Would you like to continue ?")
|
||||
if rc == "No":
|
||||
return 0
|
||||
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
dbconn = databaseTools.openServerDatabase(readOnly = False, noUpload = True)
|
||||
|
||||
print_info(green(" * ")+red("Removing selected packages ..."))
|
||||
|
||||
# open db
|
||||
for idpackage in idpackages:
|
||||
pkgatom = dbconn.retrieveAtom(idpackage)
|
||||
print_info(green(" * ")+red("Removing package: ")+bold(pkgatom)+red(" ..."))
|
||||
dbconn.removePackage(idpackage)
|
||||
print_info(green(" * ")+red("All the selected packages have been removed as requested."))
|
||||
dbconn.closeDB()
|
||||
del dbconn
|
||||
return 0
|
||||
|
||||
# used by reagent
|
||||
elif (options[0] == "md5check"):
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ def print_help():
|
||||
print_info(" \t\t"+green("search")+"\t\t\t\t Search a package inside the Entropy packages database")
|
||||
print_info(" \t\t"+green("remove")+"\t\t\t\t Remove a package or a list of packages")
|
||||
print_info(" \t\t\t"+red("--branch=<branch name>")+"\t Choose which branch of the package to remove")
|
||||
print_info(" \t\t"+green("multiremove")+"\t\t\t Remove injected packages (all if no atom specified, multipackage)")
|
||||
print_info(" \t\t\t"+red("--branch=<branch name>")+"\t Choose which branch of the package to remove")
|
||||
print_info(" \t\t"+green("create-empty-database")+"\t\t Create an empty Entropy database file in the specified <path>")
|
||||
print_info(" \t\t"+green("switchbranch")+"\t\t\t Switch to the specified branch, a package, a list of packages, world")
|
||||
print_info(" \t\t"+green("md5check")+"\t\t\t Check digest of a package, a list of packages, world")
|
||||
|
||||
Reference in New Issue
Block a user