]> git.ozlabs.org Git - next-scripts/commitdiff
make_tree_file: general tidy up
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2022 06:49:03 +0000 (17:49 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2022 06:49:03 +0000 (17:49 +1100)
use new get_* functions
quote more things
change some double quotes to single
make into a Posix script

make_tree_file

index 0d8e42a184aea95a94223652228fc4c19327b3a3..5db410dfd79e3c513f661a2a206e72b986785369 100755 (executable)
@@ -1,65 +1,66 @@
-#!/bin/bash
+#!/bin/sh
 
-# shellcheck source=./common.sh
-. "$(dirname "$0")/common.sh"
+_next_common_no_args=1 . "$(dirname "$0")/common.sh"
 
 # Don't do releases in the wee hours :-)
 h=$(date '+%k')
-(( "$h" < 10 && "$h" > 4 )) && {
-       echo "Go back to bed" 1>&2
+if [ "$h" -lt 10 ] && [ "$h" -gt 4 ]; then
+       printf '%s\n' 'Go back to bed' 1>&2
        exit 1
-}
+fi
 
-read -r -p "Yubikey token: " tok
+printf 'Yubikey token: '
+read -r tok
 # shellcheck disable=SC2029
 ssh git@gitolite.kernel.org 2fa val-session "$tok"
 
 # This means I get the right tag if I finish after midnight
-d=$(date --date "5 hours ago" '+%Y%m%d')
+d=$(date --date '5 hours ago' '+%Y%m%d')
 l=$(git tag -l --sort=taggerdate 'v*' | tail -n 1)
 n="next-$d"
 
 mkdir Next
 
 (
-       cat <<-'EOF'
-       Trees included into this release:
-
-       Name            Type    URL
-       ----            ----    ---
-       EOF
-
-       IFS='   '
-       while read -r email type name url ref _; do
-               case "$email" in
-               \#*) continue;;
-               esac
-               [ "$type" = "branch" ] && continue
-               tab="\t"
-               [ ${#name} -lt 8 ] && tab="\t\t"
-               [ "$type" = "git" ] && url="$url#${ref##*:}"
-               printf "%s$tab%s\t%s\n" "$name" "$type" "$url"
-       done <"$CTRL_FILE"
+       tab="$_TAB$_TAB"
+
+       printf '%s\n\n' 'Trees included into this release:'
+       printf '%s%s%s\t%s\n' 'Name' "$tab" 'Type' 'Url'
+       printf '%s%s%s\t%s\n' '----' "$tab" '----' '---'
+
+       for name in $(get_branches); do
+               tab="$_TAB"
+               if [ ${#name} -lt 8 ]; then
+                       tab="$tab$_TAB"
+               fi
+               type=$(get_type "$name")
+               url=$(get_url "$name")
+               if [ "$type" = "git" ]; then
+                       ref=$(get_remote_branch "$name")
+                       url="$url#$ref"
+               fi
+               printf '%s%s%s\t%s\n' "$name" "$tab" "$type" "$url"
+       done
 ) >Next/Trees
 
 mv ../SHA1s Next/SHA1s
 
 grep -v '^Checking out files:' ../merge.log >Next/merge.log
 
-printf -- "-next-%s\n" "$d" >localversion-next
+printf -- '-next-%s\n' "$d" >localversion-next
 
 git add Next localversion-next
 git commit -s -v -a -m "Add linux-next specific files for $d"
-git tag -u $gpg_key -m "$n" "$n"
+git tag -u "$gpg_key" -m "$n" "$n"
 
 git branch -f stable refs/remotes/origin/master
 
 p="patch-$l-$n"
 git diff-tree -p "$l.." >"../$p"
-gpg -u $kup_gpg_key -a -b "../$p"
+gpg -u "$kup_gpg_key" -a -b "../$p"
 
-oldest=$(date --date "3 months ago" '+%Y%m%d')
-echo "Removing old releases ... <= next-$oldest"
+oldest=$(date --date '3 months ago' '+%Y%m%d')
+printf 'Removing old releases ... <= next-%s\n' "$oldest"
 
 old_tags=$(git tag -l 'next-*[0-9]' |
        awk -F - -v oldest="$oldest" '$2 ~ /^[0-9]*$/ && $2 <= oldest { printf("next-%s\n", $2); }')
@@ -67,16 +68,16 @@ old_tags=$(git tag -l 'next-*[0-9]' |
 # shellcheck disable=SC2086
 [ "$old_tags" ] && git tag -d $old_tags
 
-echo Pushing to korg ...
+printf '%s\n' 'Pushing to korg ...'
 git push --prune korg
 
-echo Pushing to korg-history ...
+printf '%s\n' 'Pushing to korg-history ...'
 git push korg-history
 
-echo Pushing to history
+printf '%s\n' 'Pushing to history ...'
 git push history
 
-echo Pushing patch to kernel.org ...
+printf '%s\n' 'Pushing patch to kernel.org ...'
 cd ..
 xz -v -9 "$p"
 kup put "$p.xz" "$p.asc" "/pub/linux/kernel/next/$p.gz"