Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/releng:master commit in: scripts/
Date: Wed, 21 Nov 2018 19:13:21
Message-Id: 1542827585.a4b2ec7de2e43454a969a41f1a3ad22bb9cb18aa.mattst88@gentoo
1 commit: a4b2ec7de2e43454a969a41f1a3ad22bb9cb18aa
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 21 07:06:48 2018 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 21 19:13:05 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/releng.git/commit/?id=a4b2ec7d
7
8 scripts/copy_buildsync: shellcheck pass
9
10 [mattst88]: Small fixes
11 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
12 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
13
14 scripts/copy_buildsync.sh | 46 +++++++++++++++++++++++++++-------------------
15 1 file changed, 27 insertions(+), 19 deletions(-)
16
17 diff --git a/scripts/copy_buildsync.sh b/scripts/copy_buildsync.sh
18 index 815d21de..5e4046c4 100755
19 --- a/scripts/copy_buildsync.sh
20 +++ b/scripts/copy_buildsync.sh
21 @@ -56,7 +56,7 @@ Options:
22 -v, --verbose Run in verbose mode
23 -d, --debug Run in debug mode
24 EOF
25 - exit ${1:-1}
26 + exit "${1:-1}"
27 }
28
29 # Copy artifacts for an arch to the outgoing directory.
30 @@ -83,7 +83,7 @@ copy_arch_to_outgoing() {
31 for i in "${timestamps[@]}" ; do
32 #echo "Doing $i"
33 t="${outdir}/${i}"
34 - mkdir -p ${t} 2>/dev/null
35 + mkdir -p "${t}" 2>/dev/null
36 rsync \
37 "${RSYNC_OPTS[@]}" \
38 --temp-dir="${tmpdir}" \
39 @@ -92,8 +92,8 @@ copy_arch_to_outgoing() {
40 --filter "S *${i}*" \
41 --filter 'S **/' \
42 --filter 'H *' \
43 - ${indir}/ \
44 - ${t}
45 + "${indir}"/ \
46 + "${t}"
47 rc=$?
48 if [ $rc -eq 0 ]; then
49 find "${indir}" \
50 @@ -102,7 +102,7 @@ copy_arch_to_outgoing() {
51 \( -not -path '*/\.*' \) \
52 -print0 \
53 | xargs -0 --no-run-if-empty \
54 - "$DEBUGP" rm "$VERBOSEP" -f
55 + $DEBUGP rm $VERBOSEP -f
56 else
57 echo "Not deleting ${indir}/*${i}*, rsync failed!" 1>&2
58 fail=1
59 @@ -124,7 +124,7 @@ process_arch() {
60 outdir="${OUTGOING_BASE}/${ARCH}"
61 tmpdir="${TMPDIR_BASE}/${ARCH}"
62
63 - mkdir -p ${tmpdir} 2>/dev/null
64 + mkdir -p "${tmpdir}" 2>/dev/null
65
66 # Sync incoming->outgoing first.
67 copy_arch_to_outgoing "${ARCH}" "${indir}" "${outdir}" "${tmpdir}"
68 @@ -182,23 +182,31 @@ process_arch() {
69 # New variant preserve code
70 find_variants=( '(' -iname '*.iso' -o -name 'netboot-*' -o "${EXTENSIONS[@]}" ')' )
71 variants=$(find 20* "${find_variants[@]}" -printf '%f\n' 2>/dev/null | sed -e 's,-20[012][0-9]\{5\}.*,,g' -r | sort -u)
72 - echo -n '' >"${tmpdir}"/.keep.${ARCH}.txt
73 + keepfile="${tmpdir}/.keep.${ARCH}.txt"
74 + keepfile_tmp=$(mktemp -p "${tmpdir}" -t ".keep.${ARCH}.txt.XXXXXX")
75 + echo -n '' >"${keepfile_tmp}"
76 + chmod 644 "${keepfile_tmp}"
77 for v in $variants ; do
78 + # FIXME: trace the $a variable in this!
79 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 )
80 - if [ -z "${variant_path}" -o ! -e "${variant_path}" ]; then
81 + if [ -z "${variant_path}" ] || [ ! -e "${variant_path}" ]; then
82 echo "$ARCH: Variant ${v} is missing" 1>&2
83 continue
84 fi
85 - size=$(stat --format=%s ${variant_path})
86 + size=$(stat --format='%s' "${variant_path}")
87 f="latest-${v}.txt"
88 - echo -e "${header}" >"${f}"
89 - echo -e "${variant_path} ${size}" >>${f}
90 - [[ ${variant_path} =~ tar.*$ ]] && echo -e "${variant_path} ${size}" >>${OUT_STAGE3}
91 - [[ ${variant_path} =~ iso$ ]] && echo -e "${variant_path} ${size}" >>${OUT_ISO}
92 + f_tmp=$(mktemp -p . -t ".${f}.XXXXXX")
93 + chmod 644 "${f_tmp}"
94 + echo -e "${header}" >"${f_tmp}"
95 + echo -e "${variant_path} ${size}" >>"${f_tmp}"
96 + [[ ${variant_path} =~ tar.*$ ]] && echo -e "${variant_path} ${size}" >>"${OUT_STAGE3}" # FIXME: tempfile
97 + [[ ${variant_path} =~ iso$ ]] && echo -e "${variant_path} ${size}" >>"${OUT_ISO}" # FIXME: tempfile
98 rm -f "current-$v"
99 ln -sf "${variant_path%/*}" "current-$v"
100 - echo "${variant_path}" | sed -e 's,/.*,,g' -e 's,^,/,g' -e 's,$,$,g' >>"${tmpdir}"/.keep.${ARCH}.txt
101 + echo "${variant_path}" | sed -e 's,/.*,,g' -e 's,^,/,g' -e 's,$,$,g' >>"${keepfile_tmp}"
102 + mv -f "${f_tmp}" "${f}"
103 done
104 + mv -f "${keepfile_tmp}" "${keepfile}"
105
106 # ================================================================
107 # Cleanup
108 @@ -206,17 +214,17 @@ process_arch() {
109
110 # Clean up all but latest 4 from mirror dir
111 cd "${outdir}"
112 - for i in $(find -regextype posix-basic -mindepth 1 -maxdepth 1 -type d -regex '.*20[012][0-9]\{5\}.*' \
113 + for i in $(find . -regextype posix-basic -mindepth 1 -maxdepth 1 -type d -regex '.*20[012][0-9]\{5\}.*' \
114 | sed -e 's:^.*-\(20[^.]\+\).*$:\1:' \
115 | sort -ur \
116 - | egrep -v "/${latest_iso_date}\$|/${latest_stage3_date}\$" \
117 - | egrep -v -f "${tmpdir}"/.keep.${ARCH}.txt \
118 + | grep -E -v -e "/${latest_iso_date}\$|/${latest_stage3_date}\$" \
119 + | grep -E -v -f "${keepfile}" \
120 | tail -n +5); do
121
122 - $DEBUGP rm $VERBOSEP -rf $(pwd)/${i}
123 + $DEBUGP rm $VERBOSEP -rf "$(pwd)"/"${i}"
124 done
125
126 - $DEBUGP rm $VERBOSEP -rf ${tmpdir}
127 + $DEBUGP rm $VERBOSEP -rf "${tmpdir}"
128
129 else
130 echo "There was some failure for $ARCH during the weekly sync. Not doing cleanup for fear of dataloss." 1>&2