commit:     ed258c751bb3457721112e2371d426c112369331
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Fri Dec  8 07:40:09 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Dec  8 07:40:38 2017 +0000
URL:        https://gitweb.gentoo.org/proj/releng.git/commit/?id=ed258c75

tools/catalyst-auto: change datestamp->timestamp

Prepare for doing multiple automated runs in a single day on
newer/faster build systems.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 scripts/copy_buildsync.sh      |  4 ++--
 tools/catalyst-auto            | 13 ++++++++-----
 tools/catalyst-auto-amd64.conf | 21 ++++++++++++++++-----
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/scripts/copy_buildsync.sh b/scripts/copy_buildsync.sh
index 2b5c1ef1..d67cf6ee 100755
--- a/scripts/copy_buildsync.sh
+++ b/scripts/copy_buildsync.sh
@@ -70,7 +70,7 @@ copy_arch_to_outgoing() {
        fi
 
        # Copying
-       for i in $(find ${indir} -type f | grep -- '-20[0123][0-9]\{5\}' | sed 
-e 's:^.*-\(20[^.]\+\).*$:\1:' | sort -ur); do
+       for i in $(find ${indir} -type f | egrep -- 
'-20[0123][0-9]{5}(([0-9]{6})|(T[0-9]{6}Z))?' | sed -e 
's:^.*-\(20[^.]\+\).*$:\1:' | sort -ur); do
                #echo "Doing $i"
                t="${outdir}/${i}"
                mkdir -p ${t} 2>/dev/null
@@ -154,7 +154,7 @@ process_arch() {
 
        # New variant preserve code
        find_variants=( '(' -iname '*.iso' -o -name 'netboot-*' -o 
"${EXTENSIONS[@]}" ')' )
-       variants=$(find 20* "${find_variants[@]}" -printf '%f\n' 2>/dev/null | 
sed  -e 's,-20[012][0-9]\{5\}.*,,g' -r | sort -u)
+       variants=$(find 20* "${find_variants[@]}" -printf '%f\n' 2>/dev/null | 
sed -e 's,-20[012][0-9]\{5\}.*,,g' -r | sort -u)
        echo -n '' >"${tmpdir}"/.keep.${ARCH}.txt
        for v in $variants ; do
                variant_path=$(find 20* -iname "${v}-20*" "${find_variants[@]}" 
-print 2>/dev/null | sed -e "s,.*/$a/autobuilds/,,g" | sort -k1,1 -t/ | tail 
-n1 )

diff --git a/tools/catalyst-auto b/tools/catalyst-auto
index 3f7d84ef..ae47f443 100755
--- a/tools/catalyst-auto
+++ b/tools/catalyst-auto
@@ -207,8 +207,9 @@ if [[ ${lastrun} -ne 0 ]]; then
   fi
 fi
 
-DATESTAMP=$(date +%Y%m%d)
-TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" 
"catalyst-auto.${DATESTAMP}.XXXXXX")
+DATESTAMP=$(date -u +%Y%m%d)
+TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)
+TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" 
"catalyst-auto.${TIMESTAMP}.XXXXXX")
 
 # Nuke any previous tmpdirs to keep them from accumulating.
 if [[ ${preclean} -eq 1 ]]; then
@@ -219,6 +220,7 @@ fi
 if [ ${verbose} = 1 ]; then
   echo "TMPDIR = ${TMPDIR}"
   echo "DATESTAMP = ${DATESTAMP}"
+  echo "TIMESTAMP = ${TIMESTAMP}"
 fi
 
 if ! mkdir -p "${TMPDIR}"/{specs,kconfig,log}; then
@@ -257,11 +259,11 @@ for i in $(find -name '*.spec'); do
   old_version_stamp=$(grep version_stamp "${i}" | sed -e 's|^version_stamp: 
*||')
   old_source_subpath=$(grep source_subpath "${i}" | sed -e 's|^source_subpath: 
*||')
 
-  new_version_stamp=$(echo "${old_version_stamp}" | sed -e 
"s|^\(.*-\)\?.*$|\1${DATESTAMP}|")
+  new_version_stamp=$(echo "${old_version_stamp}" | sed -e 
"s|^\(.*-\)\?.*$|\1${TIMESTAMP}|")
   new_source_subpath=$(echo "${old_source_subpath}" | sed -e 
"s|${old_version_stamp}|${new_version_stamp}|")
 
   sed -i "s|^version_stamp:.*$|version_stamp: ${new_version_stamp}|" "${i}"
-  sed -i "s|^snapshot:.*$|snapshot: ${DATESTAMP}|" "${i}"
+  sed -i "s|^snapshot:.*$|snapshot: ${TIMESTAMP}|" "${i}"
 
   # We don't want to mangle the source_subpath for our stage1 spec
   if ! grep -q '^target: *stage[14]$' "${i}"; then
@@ -283,6 +285,7 @@ for i in $(find -name '*.spec'); do
   # Expand vars that the spec expects us to.
   sed -i \
     -e "s:@DATESTAMP@:${DATESTAMP}:g" \
+    -e "s:@TIMESTAMP@:${TIMESTAMP}:g" \
     -e "s:@REPO_DIR@:${REPO_DIR}:g" \
     "${i}"
 done
@@ -305,7 +308,7 @@ if [[ ${preclean} -eq 1 ]]; then
 fi
 
 # Create snapshot
-if ! run_cmd "${TMPDIR}/log/snapshot.log" catalyst -c "${CATALYST_CONFIG}" -s 
"${DATESTAMP}"; then
+if ! run_cmd "${TMPDIR}/log/snapshot.log" catalyst -c "${CATALYST_CONFIG}" -s 
"${TIMESTAMP}"; then
   send_email "Catalyst build error - snapshot" "" "${TMPDIR}/log/snapshot.log"
   exit 1
 fi

diff --git a/tools/catalyst-auto-amd64.conf b/tools/catalyst-auto-amd64.conf
index 35bc255d..5676f5c1 100644
--- a/tools/catalyst-auto-amd64.conf
+++ b/tools/catalyst-auto-amd64.conf
@@ -60,9 +60,16 @@ update_symlinks() {
        for d in ${BUILD_SRCDIR_BASE}/{default,hardened} ; do
                pushd $d >/dev/null
                for f in $(ls stage3*${EXTENSIONS} | grep -v latest | 
give_latest_from_dates ) ; do
-                       of=${f/20[0-9][0-9].[0-9]/latest} # for 20XX.Y stuff
-                       of=${of/20[0-9][0-9][0-1][0-9][0-9][0-9]/latest} # for 
20YYMMDD stuff
-                       ln -sf $f $of
+                       # 20yymmddThhmmssZ
+                       # 20yymmddhhmmss
+                       # 20yymmdd
+                       # 20yy.n
+                       of=$(perl -p \
+                               -e 's/20\d{6}T\d{6}Z/latest/g;' \
+                               -e 's/20\d{6}\d{6}/latest/g;' \
+                               -e 's/20\d{2}\.\d{2}/latest/g;' \
+                               <<<"$f")
+                       ln -sf "$f" "$of"
                done
                popd >/dev/null
        done
@@ -78,25 +85,29 @@ pre_build() {
 post_build() {
        pushd ${BUILD_SRCDIR_BASE}/default >/dev/null
        mkdir -p ${BUILD_DESTDIR_BASE}
-       for file in $(ls stage{3,4}*${DATESTAMP}*${EXTENSIONS} ); do
+       for file in $(ls stage{3,4}*${DATESTAMP}*${EXTENSIONS} 
stage{3,4}*${TIMESTAMP}*${EXTENSIONS} ); do
                if [ -f $file ]; then
                        cp $file* ${BUILD_DESTDIR_BASE}
                fi
        done
        if [ -f *${DATESTAMP}*.iso ]; then
                cp *${DATESTAMP}*.iso* ${BUILD_DESTDIR_BASE}
+       elif [ -f *${TIMESTAMP}*.iso ]; then
+               cp *${TIMESTAMP}*.iso* ${BUILD_DESTDIR_BASE}
        fi
        popd >/dev/null
 
        pushd ${BUILD_SRCDIR_BASE}/hardened >/dev/null
        mkdir -p ${BUILD_DESTDIR_BASE}/hardened
-       for file in $(ls stage{3,4}*${DATESTAMP}*${EXTENSIONS} ); do
+       for file in $(ls stage{3,4}*${DATESTAMP}*${EXTENSIONS} 
stage{3,4}*${TIMESTAMP}*${EXTENSIONS} ); do
                if [ -f $file ]; then
                        cp $file* ${BUILD_DESTDIR_BASE}/hardened
                fi
        done
        if [ -f *${DATESTAMP}*.iso ]; then
                cp *${DATESTAMP}*.iso* ${BUILD_DESTDIR_BASE}/hardened
+       elif [ -f *${TIMESTAMP}*.iso ]; then
+               cp *${TIMESTAMP}*.iso* ${BUILD_DESTDIR_BASE}/hardened
        fi
 }
 

Reply via email to