33version=0.24
44program=${0##*/ }
55progdir=${0%/* }
6+ svn_url_base=" https://svn.ietf.org/svn/tools/ietfdb"
67if [ " $progdir " = " $program " ]; then progdir=" ." ; fi
78
89# ----------------------------------------------------------------------
@@ -24,10 +25,14 @@ DESCRIPTION
2425
2526EOF
2627 echo -e " OPTIONS"
27- if [ " $( uname) " = " Linux" ]; then
28- egrep " ^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | tr -s " \t|" " \t," | sed -r -e ' s/\)[ \t]+([A-Z]+)=\$2[^#]*#/=\1\t/' -e ' s/\)[^#]*#/\t/'
28+ if [ " $( uname) " = " Linux" ]; then
29+ # shellcheck disable=SC2086
30+ # shellcheck disable=SC2016
31+ grep -E " ^\s+[-][A-Za-z| -]+\*?\)\s+[A-Za-z].+#" " $0 " | tr -s " \t|" " \t," | $sed -e ' s/\)[ \t]+([A-Z]+)=\$2[^#]*#/=\1\t/' -e ' s/\)[^#]*#/\t/'
2932 else
30- egrep " ^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | sed ' s/\|.*\$2[^#]*#/ /' | sed -E ' s/\|.*\)[^#]*#/ /'
33+ # shellcheck disable=SC2086
34+ # shellcheck disable=SC2016
35+ grep -E " ^\s+[-][A-Za-z| -]+\*?\)\s+[A-Za-z].+#" " $0 " | $sed ' s/\|.*\$2[^#]*#/ /' | $sed ' s/\|.*\)[^#]*#/ /'
3136 fi
3237 cat << EOF
3338
5257
5358# ----------------------------------------------------------------------
5459function die() {
55- echo -e " \n$program : error: $* " > /dev/stderr
60+ echo -e " \n$program : error: $* " > /dev/stderr
5661 exit 1
5762}
5863
59- function warn() {
60- echo " $program : Warning: $* " 1>&2 ;
64+ function warn() {
65+ echo " $program : Warning: $* " 1>&2
6166}
6267
63-
64- function note() {
68+ function note() {
6569 if [ -n " $VERBOSE " ]; then echo -e " $* " ; fi
6670}
6771
6872# ----------------------------------------------------------------------
6973function version() {
70- echo -e " $program $version "
74+ echo -e " $program $version "
7175}
7276
7377# ----------------------------------------------------------------------
74- trap ' echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
7578
79+ function check_svn_path_exists() {
80+ local __resultvar=$1
81+ local __path=$2
82+ local myresult
83+
84+ svn info " ${__path} " > /dev/null 2>&1
85+ myresult=$?
86+
87+ # shellcheck disable=SC2086
88+ eval $__resultvar =" '$myresult '"
89+ }
90+
91+ function mksvndir() {
92+ who=$1
93+ if [ " $2 " ]; then dir=$2 ; else dir=$who ; fi
94+ check_svn_path_exists exists " ${svn_url_base} /personal/$dir "
95+ # shellcheck disable=SC2154
96+ if [ " $exists " != " 0" ]; then
97+ $do echo " Creating personal directory area for IETF datatracker coding: /personal/$dir "
98+ $do svn mkdir " ${svn_url_base} /personal/$dir " -m " Personal SVN dir for $who , for IETF datatracker code"
99+ else
100+ echo " Repository area personal/$dir is already in place."
101+ fi
102+ }
103+
104+ function mksvntarget() {
105+ local who=$1
106+ local target=$2
107+ local source=$3
108+ local email=$4
109+ local name=$5
110+
111+ check_svn_path_exists exists " ${svn_url_base} /personal/$who /$target "
112+ if [ " $exists " != " 0" ]; then
113+ $do echo " creating $target branch for $who ($name )."
114+ $do svn cp " ${svn_url_base} /$source " \
115+ " ${svn_url_base} /personal/$who /$target /" \
116+ -m " New branch for $target "
117+ $do echo " New branch: ^/personal/$who /$target "
118+ if [ -n " $email " ]; then
119+ notify_user " $who " " $target " " $email " " $name "
120+ fi
121+ else
122+ $do echo " branch personal/$who /$target already exists."
123+ fi
124+ }
125+
126+ function notify_user() {
127+ local login=$1
128+ local target=$2
129+ local email=$3
130+ local name=$4
131+
132+ $do mail " $name <$email >" -s " A new SVN branch for you for IETF datatracker coding${rev: +, based on $rev } ." -b rjsparks@nostrum.com << -EOF
133+ Hi,
134+ $msg
135+ This mail has been automatically generated by the $program script.
136+
137+ A new SVN branch has been set up for you for IETF datatracker coding, at
138+ ${svn_url_base} /personal/$login /$target
139+ ${rev: +This branch is based on $rev . } You can check it out by doing
140+ svn co ${svn_url_base} /personal/$login /$target
141+
142+ There's also a database dump available at
143+ https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz -- this dump is served
144+ via CDN, and should hopefully be swifter to download than the alternatives.
145+
146+ Please read the instructions about sprint coder setup at
147+ https://trac.ietf.org/tools/ietfdb/wiki/SprintCoderSetup
148+ -- both the workflow description and the details of setting up your
149+ environment.
150+
151+
152+ Best regards,
153+
154+ The IETF tools team (via the $program script)
155+
156+ EOF
157+ }
158+
159+ function get_sprinters_info() {
160+ local n=$1
161+
162+ curl -L -s " https://trac.ietf.org/trac/ietfdb/wiki/IETF${n} SprintSignUp?format=txt" | \
163+ grep -E " ^\|\|" | \
164+ grep -Ev " ^\|\|\s+\|\|\s+" | \
165+ tail -n +2 | \
166+ python3 sprintcoders.py | \
167+ update " $progdir /sprint${n} .txt"
168+
169+ }
170+
171+ # ----------------------------------------------------------------------
172+ trap ' echo "$program($LINENO): Command failed with error code $? ([$$] "$0" $*)"; exit 1' ERR
76173
77174# ----------------------------------------------------------------------
78175# Option parsing
79176
80177# Options
81- shortopts =hm:M:nsvV
82- longopts =help,meeting=,message=,dry-run,sprint,verbose,version
178+ short_options =hm:M:nsvV
179+ long_options =help,meeting=,message=,dry-run,sprint,verbose,version
83180
84181# Default values
85182num=" "
86183msg=" "
87184do=" "
88185
89- if [ " $( uname) " = " Linux" ]; then
90- args=$( getopt -o " $shortopts " --long " $longopts " -n ' $program' -- $SV " $@ " )
91- if [ $? != 0 ] ; then die " Terminating..." >&2 ; exit 1 ; fi
92- eval set -- " $args "
186+ if [ " $( uname) " = " Linux" ]; then
187+ # shellcheck disable=SC2086
188+ # shellcheck disable=SC2048
189+ if ! args=$( getopt -o $short_options --long $long_options -n $program -- $SV $* ) ; then
190+ die " Terminating..." >&2
191+ exit 1
192+ fi
193+ # shellcheck disable=SC2086
194+ eval set -- $args
93195 sed=" sed -r"
94196else
95197 # Darwin, BSDs
96- args=$( getopt -o$shortopts $SV $* )
97- if [ $? != 0 ] ; then die " Terminating..." >&2 ; exit 1 ; fi
198+ # shellcheck disable=SC2086
199+ # shellcheck disable=SC2048
200+ if ! args=$( getopt -o$short_options $SV $* ) ; then
201+ die " Terminating..." >&2
202+ exit 1
203+ fi
204+ # shellcheck disable=SC2086
98205 set -- $args
99206 sed=" sed -E"
100207fi
101208
102- while true ; do
209+ while true ; do
103210 case " $1 " in
104- -h| --help) usage; exit ;; # Show this help, then exit
105- -m| --meeting) num=$2 ; shift ;; # Specify the IETF meeting number
106- -M| --message) msg=$2 ; shift ;; # Specify extra message text
107- -n| --dry-run) do=" echo -- ==>" ;; # Only show what would be done
108- -s| --sprint) SPRINT=1;; # Make branches for sprint sign-ups
109- -v| --verbose) VERBOSE=1;; # Be more talkative
110- -V| --version) version; exit ;; # Show program version, then exit
111- --) shift ; break ;;
112- * ) die " Internal error, inconsistent option specification: '$1 '" ;;
211+ -h | --help)
212+ usage
213+ exit
214+ ;; # Show this help, then exit
215+ -m | --meeting)
216+ num=$2
217+ shift
218+ ;; # Specify the IETF meeting number
219+ -M | --message)
220+ msg=$2
221+ shift
222+ ;; # Specify extra message text
223+ -n | --dry-run) do=" echo -- ==>" ;; # Only show what would be done
224+ -s | --sprint) SPRINT=1 ;; # Make branches for sprint sign-ups
225+ -v | --verbose) VERBOSE=1 ;; # Be more talkative
226+ -V | --version)
227+ version
228+ exit
229+ ;; # Show program version, then exit
230+ --)
231+ shift
232+ break
233+ ;;
234+ * ) die " Internal error, inconsistent option specification: '$1 '" ;;
113235 esac
114236 shift
115237done
118240# The program itself
119241
120242who=" "
121- tag=$( svn log -v https://svn.ietf.org/svn/tools/ietfdb /tags/dev/ --limit 1 | grep ' /tags/' | awk ' {print $2}' )
243+ tag=$( svn log -v ${svn_url_base} /tags/dev/ --limit 1 | grep ' /tags/' | awk ' {print $2}' )
122244
123245source=" ${tag: 1} "
124246target=" ${tag##*/ } "
@@ -127,95 +249,34 @@ rev="dev tag $target"
127249[ " $1 " ] && who=" $1 "
128250[ " $2 " ] && target=" ${target% .dev* } -$2 "
129251
130- function mksvndir() {
131- who=$1
132- if [ " $2 " ]; then dir=$2 ; else dir=$who ; fi
133- if ! svn info https://svn.ietf.org/svn/tools/ietfdb/personal/$dir > /dev/null 2>&1 ; then
134- $do echo " Creating personal directory area for IETF datatracker coding: /personal/$dir "
135- $do svn mkdir https://svn.ietf.org/svn/tools/ietfdb/personal/$dir -m " Personal SVN dir for $who , for IETF datatracker code"
136- else
137- echo " Repository area personal/$dir is already in place."
138- fi
139- }
140-
141- # dump="ietf_utf8.sql.gz"
142- # echo "Copying a database dump to www.ietf.org/lib/dt/sprint/$dump"
143- # scp /www/tools.ietf.org/tools/$dump ietfa:/a/www/www6s/lib/dt/sprint/
144-
145- if [ -z " $who " -a -z " $SPRINT " ]; then die " Specify either individual developer name or --sprint" ; fi
252+ if [ -z " ${who}${SPRINT} " ]; then die " Specify either individual developer name or --sprint" ; fi
146253
147- cd $progdir
254+ cd $progdir || exit
148255
149256if [ " $who " ]; then
150- mksvndir $who
151- $do svn cp https://svn.ietf.org/svn/tools/ietfdb/$source https://svn.ietf.org/svn/tools/ietfdb/personal/$who /$target / -m " New branch for $target "
152- echo " New branch: ^/personal/$who /$target "
257+ mksvndir " $who "
258+ mksvntarget " $who " " $target " " $source "
153259fi
154260if [ " $SPRINT " ]; then
155261 [ " $msg " ] && msg="
156262$msg
157263"
158- [ " $num " ] || num=$( < /www/tools.ietf.org/meta/current-ietf-number.txt)
159- for n in $( seq $(( num- 3 )) $num ) ; do
160- trac-admin /www/tools.ietf.org/tools/ietfdb wiki export IETF${n} SprintSignUp \
161- | egrep " ^\|\|" | tail -n +2 | python -c '
162- import sys, re
163- with open("aliases") as afile:
164- try:
165- aliases = dict([ line.strip().split(None,1) for line in afile.read().splitlines() if line.strip() ])
166- except ValueError:
167- sys.stderr.write([ line.strip().split(None,1) for line in afile.read().splitlines() if line.strip() ])
168- raise
169-
170- for line in sys.stdin:
171- try:
172- blank, name, email, rest = line.strip().split("||", 3)
173- email = email.strip()
174- except ValueError:
175- sys.stderr.write(line+"\n")
176- raise
177-
178- login, dummy = re.split("[@.]", email, 1)
179- if email in aliases:
180- login = aliases[email]
181- print "\t".join((login.strip().lower(), email.strip().lower(), name.strip())) ' \
182- | update $progdir /sprint$n .txt
264+ [ " $num " ] || num=$( curl -L -s " https://tools.ietf.org/meta/current-ietf-number.txt" )
265+ for n in $( seq $(( num - 3 )) " $num " ) ; do
266+ get_sprinters_info " $n "
183267 done
184268
185- cat $( ls $progdir /sprint* .txt | tail -n 2) $progdir /extras.txt | sed -r -e ' s/[ \t]*$//' -e ' s/[ \t]+/ /g' | sort | uniq | while read login email name; do
186- echo " "
187- echo " $login ($name <$email >):"
188- mksvndir $login
189- if ! svn info https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login /$target > /dev/null 2>&1 ; then
190- $do echo " creating $target branch for $login ($name )."
191- $do svn cp https://svn.tools.ietf.org/svn/tools/ietfdb/$source https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login /$target / -m " New IETF datatracker coding branch for $name " \
192- && $do mail " $name <$email >" -s " A new SVN branch for you for IETF datatracker coding${rev: +, based on $rev } ." -b rjsparks@nostrum.com << -EOF
193- Hi,
194- $msg
195- This mail has been automatically generated by the $program script.
196-
197- A new SVN branch has been set up for you for IETF datatracker coding, at
198- https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login /$target
199- ${rev: +This branch is based on $rev . } You can check it out by doing
200- svn co https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login /$target
201-
202- There's also a new database dump available at
203- https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz -- this dump is served
204- via CDN, and should hopefully be swifter to download than the alternatives.
205-
206- Please read the instructions about sprint coder setup at
207- https://trac.tools.ietf.org/tools/ietfdb/wiki/SprintCoderSetup
208- -- both the workflow description and the details of setting up your
209- environment.
210-
211-
212- Best regards,
213-
214- Henrik (via the $program script)
215-
216- EOF
217- else
218- $do echo " branch personal/$login /$target already exists."
219- fi
269+ # shellcheck disable=SC2046
270+ # shellcheck disable=SC2012
271+ # shellcheck disable=SC2162
272+ # sed -E (regexp extended) breaks this usage on MacOS 10.15, so back to regular sed.
273+ cat $( ls $progdir /sprint* .txt | tail -n 2) $progdir /extras.txt | \
274+ sed -e ' s/[ \t]*$//' -e ' s/[ \t]+/ /g' | \
275+ sort | uniq | \
276+ while read login email name; do
277+ echo " "
278+ echo " $login ($name <$email >):"
279+ mksvndir " $login "
280+ mksvntarget " $login " " $target " " $source " " $email " " $name "
220281 done
221282fi
0 commit comments