mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
scripts/remove_old_packages: optionally show which are kept
This commit is contained in:
parent
ac5a7cd1cd
commit
5a7234e78d
1 changed files with 7 additions and 0 deletions
|
@ -38,6 +38,7 @@ def main(args):
|
|||
except TypeError:
|
||||
print('Bad things happen: %s' % v)
|
||||
raise
|
||||
|
||||
for pkg, f in v[:-args.keep]:
|
||||
if args.dry_run:
|
||||
print('would remove %s.' % f)
|
||||
|
@ -45,12 +46,18 @@ def main(args):
|
|||
print('removing %s.' % f)
|
||||
remove_pkg(f)
|
||||
|
||||
if args.show_kept_fd >= 0:
|
||||
for _, f in v[args.keep:]:
|
||||
os.write(args.show_kept_fd, f.encode('utf-8') + b'\n')
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='remove old Arch Linux packages')
|
||||
parser.add_argument('-n', '--dry-run', action='store_true',
|
||||
help='dry run')
|
||||
parser.add_argument('-k', '--keep', metavar='N', type=int, default=2,
|
||||
help='how many versions to keep. Default is 2')
|
||||
parser.add_argument('--show-kept-fd', metavar='FD', type=int, default=-1,
|
||||
help='write kept package paths to fd FD, one per line')
|
||||
parser.add_argument('packages', metavar='PACKAGE', nargs='+',
|
||||
help='package files to check')
|
||||
args = parser.parse_args()
|
||||
|
|
Loading…
Add table
Reference in a new issue