From f92af9cb9aa3ad10bbf62a4788a7813fcdcb8df2 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 24 Jan 2018 14:05:20 +0000 Subject: [PATCH] shared-repo-pack: Move out any existing build directory to the trash delection handler Signed-off-by: Richard Purdie --- config.json | 1 + scripts/shared-repo-unpack | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/config.json b/config.json index 4c40982..b64a598 100644 --- a/config.json +++ b/config.json @@ -6,6 +6,7 @@ "BUILD_HISTORY_FORKPUSH" : {"poky-contrib:ross/mut" : "poky:master", "poky:master-next" : "poky:master"}, "REPO_STASH_DIR" : "/home/pokybuild/git/mirror", + "TRASH_DIR" : "/home/pokybuild/git/trash", "defaults" : { "NEEDREPOS" : ["poky"], diff --git a/scripts/shared-repo-unpack b/scripts/shared-repo-unpack index 0cb5aee..10e871c 100755 --- a/scripts/shared-repo-unpack +++ b/scripts/shared-repo-unpack @@ -29,12 +29,19 @@ scriptsdir = os.path.dirname(os.path.realpath(__file__)) ourconfig = utils.loadconfig(__file__) stashdir = ourconfig["REPO_STASH_DIR"] +trashdir = ourconfig["TRASH_DIR"] needrepos = utils.getconfigvar("NEEDREPOS", ourconfig, target, None) with open(repojson) as f: repos = json.load(f) +# Move any existing directory to the trash collection directory (deferred ionice deletion) +if os.path.exists(targetdir): + trashdest = trashdir + "/" + target + "/" + str(int(time.time())) + '-' + str(random.randrange(100, 100000, 2)) + utils.mkdir(trashdest) + subprocess.check_call(['mv', targetdir, trashdest]) + for repo in sorted(repos.keys()): if repo not in needrepos: continue