Message ID | 1536049846-16802-1-git-send-email-stefan.bader@canonical.com |
---|---|
State | New |
Headers | show |
Series | [kteam-tools] NEW: stable/update-kuc-sru-dates | expand |
Acked-by: Kamal Mostafa <kamal@canonical.com> Two comments ... 1. > +# <date> : This is the YYYY.MM.DD date of the Monday which starts the > +# new cycle. IMHO this script (and gen-sru-announce, and all other things) should switch to using the standard ISO 8601 date format: YYYY-MM-DD with hyphens instead of dots. 2. > +TMP=$(mktemp '/tmp/update-sru-XXXXX') > +trap 'test -f "$TMP" && rm "$TMP"' ERR If you use were to use trap 0 instead: trap 'rm -f "$TMP"' 0 then you could just omit this cleanup line at the end, which is more robust: > +test -f "$TMP" && rm "$TMP" -Kamal On Tue, Sep 04, 2018 at 10:30:46AM +0200, Stefan Bader wrote: > Adds a new shell script which updates the entry web page > kernel.ubuntu.com/index.html with a new set of dates and > commits the result (if differing to before). > > Signed-off-by: Stefan Bader <stefan.bader@canonical.com> > --- > > If anybody has a better name, I do not insist on the current one. > The script itself takes the SRU cycle date and passes it into > gen-sru-announce --html. Then takes that output and inserts it > between the repective markers in the kernel.ubuntu.com/index.html > file. > The path is found relative to the script path. To make this work > either the stable directory has to be in the PATH environment or > a softlink pointing to it must be present in some path, or the > script is called with a full path. > > -Stefan > > stable/update-kuc-sru-dates | 74 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > create mode 100755 stable/update-kuc-sru-dates > > diff --git a/stable/update-kuc-sru-dates b/stable/update-kuc-sru-dates > new file mode 100755 > index 0000000..3d8cec5 > --- /dev/null > +++ b/stable/update-kuc-sru-dates > @@ -0,0 +1,74 @@ > +#!/bin/bash > +#------------------------------------------------------------------------------ > +# Update the main web page (index.html) SRU dates section with the output from > +# gen-sru-announce --html and commit the changes if successful. > +# > +# Arguments: <date> > +# <date> : This is the YYYY.MM.DD date of the Monday which starts the > +# new cycle. > +#------------------------------------------------------------------------------ > +set -e > +if [ -L "$0" ]; then > + BINDIR=$(dirname $(readlink $0)) > +else > + BINDIR=$(dirname "$0") > +fi > +if [ "$BINDIR" = "." ]; then > + BINDIR=$(pwd) > +fi > + > +SRC="$BINDIR/../kernel.ubuntu.com/index.html" > +if [ ! -r $SRC ]; then > + echo "EE: $SRC cannot be read!" >&2 > + exit 1 > +fi > + > +if [ "$1" = "" ]; then > + echo "Usage: $(basename $0) <date:YYYY.MM.DD>" >&2 > + exit 1 > +fi > + > +TMP=$(mktemp '/tmp/update-sru-XXXXX') > +trap 'test -f "$TMP" && rm "$TMP"' ERR > + > +gen-sru-announce --html "$1" >>$TMP || ( > + echo "EE: Error calling gen-sru-announce:" >&2 > + cat $TMP >&2 > + exit 1 > +) > + > +awk -v DATA=$TMP ' > + match($0, /<!-- Start-SRU-Dates -->/){ > + skip=1 > + indent=RSTART-1 > + print $0 > + while (getline < DATA) { > + printf("%*s%s\n", indent, " ", $0) > + } > + next > + } > + /<!-- End-SRU-Dates -->/{ > + skip=0 > + } > + skip == 0{ > + print $0 > + } > +' $SRC >$SRC.new && mv $SRC.new $SRC > + > +MSG=$(cat <<EOD > +kernel.ubuntu.com/index.html: Update for $1 SRU cycle > + > +Update the dates shown on the main web page to the new SRU cycle > +dates. > + > +EOD > +) > + > +if [ "$(git diff $SRC 2>/dev/null)" != "" ]; then > + git add $SRC && git commit -s -m"$MSG" > +fi > + > +test -f "$TMP" && rm "$TMP" > + > +exit 0 > + > -- > 2.7.4 > > > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team
On 04.09.2018 17:33, Kamal Mostafa wrote: > Acked-by: Kamal Mostafa <kamal@canonical.com> > > Two comments ... > > 1. >> +# <date> : This is the YYYY.MM.DD date of the Monday which starts the >> +# new cycle. > > IMHO this script (and gen-sru-announce, and all other things) should > switch to using the standard ISO 8601 date format: YYYY-MM-DD with > hyphens instead of dots. It uses that format because this gets passed as-is to gen-sru-announce, which used that format because it is used by the SRU cycle board and the tracking bugs (and likely plenty of other places). Am I hearing you volunteering for making a big sweep over code and documentation to get things "right"? ;) > > > 2. > >> +TMP=$(mktemp '/tmp/update-sru-XXXXX') >> +trap 'test -f "$TMP" && rm "$TMP"' ERR > > If you use were to use trap 0 instead: > trap 'rm -f "$TMP"' 0 > then you could just omit this cleanup line at the end, which is more robust: > >> +test -f "$TMP" && rm "$TMP" Hm, maybe not only more robust but rather correct. Re-reading through the shell help more carefully I suspect adding the ERR trap handler might make things continue to run instead of exiting. While using EXIT (or 0) seems to be called on every exit (error exit or success exit). So that sounds better. I will re-submit with that fixed. -Stefan > > -Kamal > > > On Tue, Sep 04, 2018 at 10:30:46AM +0200, Stefan Bader wrote: >> Adds a new shell script which updates the entry web page >> kernel.ubuntu.com/index.html with a new set of dates and >> commits the result (if differing to before). >> >> Signed-off-by: Stefan Bader <stefan.bader@canonical.com> >> --- >> >> If anybody has a better name, I do not insist on the current one. >> The script itself takes the SRU cycle date and passes it into >> gen-sru-announce --html. Then takes that output and inserts it >> between the repective markers in the kernel.ubuntu.com/index.html >> file. >> The path is found relative to the script path. To make this work >> either the stable directory has to be in the PATH environment or >> a softlink pointing to it must be present in some path, or the >> script is called with a full path. >> >> -Stefan >> >> stable/update-kuc-sru-dates | 74 +++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 74 insertions(+) >> create mode 100755 stable/update-kuc-sru-dates >> >> diff --git a/stable/update-kuc-sru-dates b/stable/update-kuc-sru-dates >> new file mode 100755 >> index 0000000..3d8cec5 >> --- /dev/null >> +++ b/stable/update-kuc-sru-dates >> @@ -0,0 +1,74 @@ >> +#!/bin/bash >> +#------------------------------------------------------------------------------ >> +# Update the main web page (index.html) SRU dates section with the output from >> +# gen-sru-announce --html and commit the changes if successful. >> +# >> +# Arguments: <date> >> +# <date> : This is the YYYY.MM.DD date of the Monday which starts the >> +# new cycle. >> +#------------------------------------------------------------------------------ >> +set -e >> +if [ -L "$0" ]; then >> + BINDIR=$(dirname $(readlink $0)) >> +else >> + BINDIR=$(dirname "$0") >> +fi >> +if [ "$BINDIR" = "." ]; then >> + BINDIR=$(pwd) >> +fi >> + >> +SRC="$BINDIR/../kernel.ubuntu.com/index.html" >> +if [ ! -r $SRC ]; then >> + echo "EE: $SRC cannot be read!" >&2 >> + exit 1 >> +fi >> + >> +if [ "$1" = "" ]; then >> + echo "Usage: $(basename $0) <date:YYYY.MM.DD>" >&2 >> + exit 1 >> +fi >> + >> +TMP=$(mktemp '/tmp/update-sru-XXXXX') >> +trap 'test -f "$TMP" && rm "$TMP"' ERR >> + >> +gen-sru-announce --html "$1" >>$TMP || ( >> + echo "EE: Error calling gen-sru-announce:" >&2 >> + cat $TMP >&2 >> + exit 1 >> +) >> + >> +awk -v DATA=$TMP ' >> + match($0, /<!-- Start-SRU-Dates -->/){ >> + skip=1 >> + indent=RSTART-1 >> + print $0 >> + while (getline < DATA) { >> + printf("%*s%s\n", indent, " ", $0) >> + } >> + next >> + } >> + /<!-- End-SRU-Dates -->/{ >> + skip=0 >> + } >> + skip == 0{ >> + print $0 >> + } >> +' $SRC >$SRC.new && mv $SRC.new $SRC >> + >> +MSG=$(cat <<EOD >> +kernel.ubuntu.com/index.html: Update for $1 SRU cycle >> + >> +Update the dates shown on the main web page to the new SRU cycle >> +dates. >> + >> +EOD >> +) >> + >> +if [ "$(git diff $SRC 2>/dev/null)" != "" ]; then >> + git add $SRC && git commit -s -m"$MSG" >> +fi >> + >> +test -f "$TMP" && rm "$TMP" >> + >> +exit 0 >> + >> -- >> 2.7.4 >> >> >> -- >> kernel-team mailing list >> kernel-team@lists.ubuntu.com >> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff --git a/stable/update-kuc-sru-dates b/stable/update-kuc-sru-dates new file mode 100755 index 0000000..3d8cec5 --- /dev/null +++ b/stable/update-kuc-sru-dates @@ -0,0 +1,74 @@ +#!/bin/bash +#------------------------------------------------------------------------------ +# Update the main web page (index.html) SRU dates section with the output from +# gen-sru-announce --html and commit the changes if successful. +# +# Arguments: <date> +# <date> : This is the YYYY.MM.DD date of the Monday which starts the +# new cycle. +#------------------------------------------------------------------------------ +set -e +if [ -L "$0" ]; then + BINDIR=$(dirname $(readlink $0)) +else + BINDIR=$(dirname "$0") +fi +if [ "$BINDIR" = "." ]; then + BINDIR=$(pwd) +fi + +SRC="$BINDIR/../kernel.ubuntu.com/index.html" +if [ ! -r $SRC ]; then + echo "EE: $SRC cannot be read!" >&2 + exit 1 +fi + +if [ "$1" = "" ]; then + echo "Usage: $(basename $0) <date:YYYY.MM.DD>" >&2 + exit 1 +fi + +TMP=$(mktemp '/tmp/update-sru-XXXXX') +trap 'test -f "$TMP" && rm "$TMP"' ERR + +gen-sru-announce --html "$1" >>$TMP || ( + echo "EE: Error calling gen-sru-announce:" >&2 + cat $TMP >&2 + exit 1 +) + +awk -v DATA=$TMP ' + match($0, /<!-- Start-SRU-Dates -->/){ + skip=1 + indent=RSTART-1 + print $0 + while (getline < DATA) { + printf("%*s%s\n", indent, " ", $0) + } + next + } + /<!-- End-SRU-Dates -->/{ + skip=0 + } + skip == 0{ + print $0 + } +' $SRC >$SRC.new && mv $SRC.new $SRC + +MSG=$(cat <<EOD +kernel.ubuntu.com/index.html: Update for $1 SRU cycle + +Update the dates shown on the main web page to the new SRU cycle +dates. + +EOD +) + +if [ "$(git diff $SRC 2>/dev/null)" != "" ]; then + git add $SRC && git commit -s -m"$MSG" +fi + +test -f "$TMP" && rm "$TMP" + +exit 0 +
Adds a new shell script which updates the entry web page kernel.ubuntu.com/index.html with a new set of dates and commits the result (if differing to before). Signed-off-by: Stefan Bader <stefan.bader@canonical.com> --- If anybody has a better name, I do not insist on the current one. The script itself takes the SRU cycle date and passes it into gen-sru-announce --html. Then takes that output and inserts it between the repective markers in the kernel.ubuntu.com/index.html file. The path is found relative to the script path. To make this work either the stable directory has to be in the PATH environment or a softlink pointing to it must be present in some path, or the script is called with a full path. -Stefan stable/update-kuc-sru-dates | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 stable/update-kuc-sru-dates