From 637aeb6d1ae587234ef4b1be97beebaf874e0e4f Mon Sep 17 00:00:00 2001 From: devrandom Date: Wed, 25 May 2011 22:50:34 -0700 Subject: [PATCH] remove files that were removed from manifest in new version, add force flag --- doc/NOTES | 1 - share/gitian-updater | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/NOTES b/doc/NOTES index 9aa1226..ad21e3c 100644 --- a/doc/NOTES +++ b/doc/NOTES @@ -2,6 +2,5 @@ Downloader * incremental update of dest directory * overwrite existing files (optionally balk if sha256sum changed) - * remove files that are in manifest and not in new version * remove empty dirs as result of previous action * json diff --git a/share/gitian-updater b/share/gitian-updater index d62cc5f..f708493 100755 --- a/share/gitian-updater +++ b/share/gitian-updater @@ -218,6 +218,7 @@ parser.add_argument('-c', '--config', metavar='CONF', type=str, required=not hav parser.add_argument('-d', '--dest', metavar='DEST', type=str, required=False, help='the destination directory for unpacking') parser.add_argument('-q', '--quiet', action='append_const', const=1, default=[], help='be quiet') +parser.add_argument('-f', '--force', action='store_true', help='force downgrades and such') parser.add_argument('-m', '--customize', metavar='OUTPUT', type=str, help='generate a customized version of the script with the given config') args = parser.parse_args() @@ -327,7 +328,7 @@ if old_manifest: if out_manifest['name'] != old_manifest['name']: print>>sys.stderr, "The old directory has a manifest for a different package" exit(1) - if LooseVersion(out_manifest['release']) < LooseVersion(old_manifest['release']): + if LooseVersion(out_manifest['release']) < LooseVersion(old_manifest['release']) and not args.force: print>>sys.stderr, "This would downgrade from version %s to %s"%(old_manifest['release'],out_manifest['release']) exit(1) elif LooseVersion(out_manifest['release']) == LooseVersion(old_manifest['release']): @@ -356,6 +357,12 @@ for root, dirs, files in os.walk(unpack_dir, topdown = True): for f in files: shutil.copy2(path.join(root, f), path.join(dest_path, rel, f)) +removed = set(old_manifest['sums'].keys()).difference(out_manifest['sums'].keys()) + +for f in removed: + if path.exists(path.join(dest_path, f)): + os.unlink(path.join(dest_path, f)) + f = file(path.join(dest_path, '.gitian-manifest'), 'w') yaml.dump(out_manifest, f) f.close()