From 1fd6f3f636ec7b0780815120f10e1beb545bc07f Mon Sep 17 00:00:00 2001 From: Scott Little Date: Tue, 15 Dec 2020 14:17:34 -0500 Subject: [PATCH] tidy stx/downloads directory $MY_REPO/stx/downloads contains links to tarballs and other files relevant to the build. It is populated by populate_downloads.sh. On subsequent runs, new links might be added, but old links are not cleaned up. Adopt the convention used by generate-centos-repo.sh of moving the old content under a timestamp backup directory, leaving an empty directory to re-populate. Closes-bug: 1908297 Signed-off-by: Scott Little Change-Id: Ib6c8b782db6c369cb00e8fe8c64be099d7a5d238 --- toCOPY/generate-centos-repo.sh | 12 ++++++------ toCOPY/populate_downloads.sh | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/toCOPY/generate-centos-repo.sh b/toCOPY/generate-centos-repo.sh index 48eadcf9..9bdb7fcf 100755 --- a/toCOPY/generate-centos-repo.sh +++ b/toCOPY/generate-centos-repo.sh @@ -183,13 +183,13 @@ if [ ! -d "${dest_dir}" ]; then fi for t in "Binary" "Source" ; do - target_dir=${dest_dir}/$t - if [ ! -d "$target_dir" ]; then - mkdir -p "$target_dir" - else - mv -f "$target_dir" "$target_dir-backup-$timestamp" - mkdir -p "$target_dir" + target_dir=${dest_dir}/${t} + + if [ -d "${target_dir}" ]; then + mv -f "${target_dir}" "${target_dir}-backup-${timestamp}" fi + + mkdir -p "${target_dir}" done # diff --git a/toCOPY/populate_downloads.sh b/toCOPY/populate_downloads.sh index e434becf..0a02fb62 100755 --- a/toCOPY/populate_downloads.sh +++ b/toCOPY/populate_downloads.sh @@ -91,7 +91,12 @@ if [ -f ${extra_downloads_lst} ]; then fi -mkdir -p ${MY_REPO}/stx/downloads +if [ -d "${downloads_dir}" ]; then + timestamp="$(date +%F_%H%M)" + mv -f "${downloads_dir}" "${downloads_dir}-backup-${timestamp}" +fi + +mkdir -p ${downloads_dir} grep -v "^#" ${tarball_lst} | while read x; do if [ -z "$x" ]; then