X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fpackage-listing.sh;h=c0b5476ca35e8f31c17f53d0711d5ace9cbd3ec4;hb=refs%2Fchanges%2F50%2F72650%2F2;hp=0c35917e731ace052e14ba1a65678989ece08660;hpb=a079f1b34f9f3ae69dd5f996682514db667fe82d;p=releng%2Fglobal-jjb.git diff --git a/shell/package-listing.sh b/shell/package-listing.sh old mode 100644 new mode 100755 index 0c35917e..c0b5476c --- a/shell/package-listing.sh +++ b/shell/package-listing.sh @@ -18,18 +18,18 @@ set -x # Trace commands for this script to make debugging easier OS_FAMILY=$(facter osfamily | tr '[:upper:]' '[:lower:]') +# Capture the CI WORKSPACE safely in the case that it doesn't exist +workspace="${WORKSPACE:-}" + START_PACKAGES=/tmp/packages_start.txt END_PACKAGES=/tmp/packages_end.txt DIFF_PACKAGES=/tmp/packages_diff.txt -# This script may be run during system boot, if that is true then there will be -# a starting_packages file. We will want to create a diff if we have a starting -# packages file +# Swap to creating END_PACKAGES if we are running in a CI job (determined by if +# we have a workspace env) or if the starting packages listing already exists. PACKAGES="${START_PACKAGES}" -if [ -f "${PACKAGES}" ] -then +if [ "${workspace}" ] || [ -f "${START_PACKAGES}" ]; then PACKAGES="${END_PACKAGES}" - CREATEDIFF=1 fi case "${OS_FAMILY}" in @@ -46,15 +46,14 @@ case "${OS_FAMILY}" in ;; esac -if [ "${CREATEDIFF}" ] -then - diff "${START_PACKAGES}" "${END_PACKAGES}" > "${DIFF_PACKAGES}" +if [ -f "${START_PACKAGES}" ] && [ -f "${END_PACKAGES}" ]; then + # ` || true` Ignore exit code because diff exits 1 when there is a diff + diff "${START_PACKAGES}" "${END_PACKAGES}" > "${DIFF_PACKAGES}" || true fi # If running in a Jenkins job, then copy the created files to the archives # location -if [ "${WORKSPACE}" ] -then - mkdir -p "${WORKSPACE}/archives/" - cp -f /tmp/packages_*.txt "${WORKSPACE}/archives/" +if [ "${workspace}" ]; then + mkdir -p "${workspace}/archives/" + cp -f /tmp/packages_*.txt "${workspace}/archives/" fi