Author: geissert Date: 2011-01-06 00:07:52 +0000 (Thu, 06 Jan 2011) New Revision: 15797 Modified: bin/gen-DSA Log: A few more tweaks to bin/gen-DSA Use --save instead of piping the output to a file Modified: bin/gen-DSA ==================================================================--- bin/gen-DSA 2011-01-05 23:02:24 UTC (rev 15796) +++ bin/gen-DSA 2011-01-06 00:07:52 UTC (rev 15797) @@ -24,16 +24,24 @@ STABLE=lenny TESTING=squeeze +export LANG=C + [ -f doc/DSA.template ] || { echo "error: call this script from the root of the repository" >&2 exit 1 } [ $# -ge 3 ] || { - echo "usage: $0 DSA package vulnerability [cve(s) [bugnumber]]" >&2 + echo "usage: $0 [--save] DSA package vulnerability [cve(s) [bugnumber]]" >&2 exit 1 } +save=false +if [ "$1" = "--save" ]; then + save=true + shift +fi + DSAID="$1" PACKAGE="$(printf ''%s'' "$2" | tr "[:upper:]" "[:lower:]")" VULNERABILITY="$3" @@ -96,5 +104,35 @@ [ -z "$version" ] || setvar "${dist}_VERSION" "$version" done -cat $tmpf -rm -f "$tmpf" + +if ! $save; then + cat $tmpf + echo + echo " ---- " + echo "Pass --save as the first parameter to save the text to DSA-$DSAID" + echo "(the data/DSA/list entry will also be added)" + rm -f "$tmpf" + exit +else + mv -i $tmpf "DSA-$DSAID" || { rm -f $tmpf; exit; } + dsa_entry=$(mktemp) + cat <<EOF > $dsa_entry +[$(date +"%d %b %Y")] DSA-$DSAID $PACKAGE - $VULNERABILITY +EOF + + if [ "$CVE" ]; then + CVE="$(printf ''%s'' "$CVE" | sed ''s/[ ,;]+/ /g'')" + printf "\t{%s}\n" "$CVE" >> $dsa_entry + fi + + for dist in $OLDSTABLE $STABLE; do + version="$(eval ''printf "%s" "$''"$dist"_VERSION''"'')" + [ -z "$version" ] || \ + printf "\t[%s] - %s %s\n" "$dist" "$PACKAGE" "$version" >> $dsa_entry + done + tmp_list="$(mktemp)" + cat $dsa_entry data/DSA/list > $tmp_list + cat $tmp_list > data/DSA/list + rm -f $tmp_list + echo "DSA text written to ./DSA-$DSAID" +fi