The attached script allows one to list and delete item(s) from the gentoo portage resume list. It would be useful, imo, to have such a script in the app-portage/gentoolkit package. Reproducible: Always Steps to Reproduce: As an example: list the current resume list: # edit_resume_list.py -l 1: =cross-powerpc64-unknown-linux-gnu/binutils-2.25.1-r1 2: =cross-powerpc-unknown-linux-gnu/binutils-2.25.1-r1 Actual Results: This python script allows one to list and / or delete item(s) from the resume list #!/bin/env python import sys, portage def item_dump(list, idx, dblen): if idx >= 0 and idx < dblen: print("%d: =%s" % (idx + 1, list[idx][2])) else: sys.exit('Error: invalid resume item index %d' % (idx + 1)) def item_del(list, idx, dblen): if idx >= 0 and idx < dblen: print("delete item %d: =%s" % (idx + 1, list[idx][2])) del list[idx] else: sys.exit('Error: invalid resume item index %d' % (idx + 1)) argv_len = len(sys.argv) # If no arguments or '-l' argument, we want to dump if argv_len == 1 or sys.argv[1] == '-l': #resume_list=portage.mtimedb["resume"]["mergelist"] resume_list=portage.mtimedb.get("resume", {}).get("mergelist") if resume_list == None: resume_len = 0 else: resume_len=len(resume_list) # Exit directly if resume list is empty if resume_len == 0: sys.exit('Nothing in resume list') if argv_len == 3: i = int(sys.argv[2]) - 1 item_dump(resume_list, i, resume_len) else: for i in range(resume_len): item_dump(resume_list, i, resume_len) elif sys.argv[1] == '-d': #resume_list=portage.mtimedb["resume"]["mergelist"] resume_list=portage.mtimedb.get("resume", {}).get("mergelist") if resume_list == None: resume_len = 0 else: resume_len=len(resume_list) # Exit directly if resume list is empty if resume_len == 0: sys.exit('Nothing in resume list') if argv_len == 3: if sys.argv[2] == 'all': # Delete all items from resume list for i in range(resume_len): item_del(resume_list, i, resume_len) else: # Delete one item from resume list i = int(sys.argv[2]) - 1 item_del(resume_list, i, resume_len) # Commit changes in portage database portage.mtimedb.commit() else: sys.exit('Delete function must be given an argument') print("Usage: edit_resume_list.py [-h] [-l [<idx>] | -d [<idx>|all]]") print("\t-h: print this help") print("\t-l: list item(s) from the resume list") print("\t\tprint resume list entry <idx>") print("\t\tor all items if no index is given") print("\t-d: delete item(s) from the resume list") print("\t\tdelete resume list entry <idx>") print("\t\tor all items if \"all\" argument is specified") print("\tdefault action is to list all resume list items\n") sys.exit() else: sys.exit('Unknown argument %s' % sys.argv[1])
Or make it into an emaint module
I'd prefer to see it as an emaint module, instead of being a standalone script in gentoolkit.
Emaint has been re-written as a plugin system. There are 2 main files in the plugin module. 1) the modules directory __init__.py It contains the info about the module, such as the options it takes, the file and class or classes it exports, etc. You should be able to figure it out by looking at some existing modules. 2) the .py file which contains the class that will be run to perform the functions. If possible try to use the generic check/fix options, but I don't think they will be much use for this. There are several of the portage team members in IRC #gentoo-portage that can help you with getting it ready for emaint as a plugin module.
I clicked save too soon :/ There is an existing resume emaint module, so it should be fairly easy to extend it's capabilities to add your new functionality and options. It is already laid out, it just needs extending.