-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
I had a look at the patch by Erik, and ended up doing the following improvements: * Use GNU getopt to properly handle long-opts * Quote echo'ed strings * Redirect error messages to stderr * Use test -n * Emit error when failing version tests Attached is both a diff and - due to the many changes - the complete script after my messing with it. How do you like the changes? Also, I wonder if the strings in the lines below should better be quoted too? host_upstream_version=${supported_host_version%%-*} target_upstream_version=${supported_target_version%%-*} VERSION=$1 - Jonas P.S. I will fix this bug but not use time on switching to SVN this weekend. - -- * Jonas Smedegaard - idealist og Internet-arkitekt * Tlf.: +45 40843136 Website: http://dr.jones.dk/ - Enden er nær: http://www.shibumi.org/eoti.htm -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFDUV+Zn7DbMsAkQLgRAvG4AKCGG14182dgzgAjJKhKmeh5EZmeNwCfYN1C gvxHISz+cNWxYLon2ROmJYs= =u7K3 -----END PGP SIGNATURE-----
--- mkinitrd.yaird.orig 2005-10-13 02:43:17.000000000 +0200 +++ mkinitrd.yaird 2005-10-15 21:44:09.000000000 +0200 @@ -24,40 +24,78 @@ PROG=mkinitrd.yaird outfile='' -while getopts "d:km:o:r:" flag; do - case $flag in - d) - echo "$PROG: $flag unsupported" +TEMP=`getopt -o d:km:o:r: --long supported-host-version:,supported-target-version: -n "$prg" -- "$@"` + +# Check for non-GNU getopt +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +eval set -- "$TEMP" + +while true ; do + case "$1" in + -d) + echo "$PROG: $1 unsupported" >&2 exit 1 ;; - k) - echo "$PROG: $flag unsupported" + -k) + echo "$PROG: $1 unsupported" >&2 exit 1 ;; - m) - # ignore - ;; - o) - outfile="$OPTARG" + -m) + # ignore + shift 2 + ;; + -o) + outfile="$2" + shift 2 ;; - r) - echo "$PROG: $flag unsupported" + -r) + echo "$PROG: $1 unsupported" >&2 exit 1 ;; + --supported-host-version) + supported_host_version="$2" + shift 2 + ;; + --supported-target-version) + supported_target_version="$2" + shift 2 + ;; + --) + shift + break + ;; *) - echo "$PROG: unknown option $flag" + echo "Internal error!" >&2 exit 1 ;; esac done -shift $(($OPTIND - 1)) + +if [ -n "$supported_host_version" ] || [ -n "$supported_target_version" ]; then + if [ -n "$supported_host_version" ]; then + host_upstream_version=${supported_host_version%%-*} + if dpkg --compare-versions "$host_upstream_version" lt "2.6.8"; then + echo "$PROG: host version too old" >&2 + exit 1 + fi + fi + if [ -n "$supported_target_version" ]; then + target_upstream_version=${supported_target_version%%-*} + if dpkg --compare-versions "$target_upstream_version" lt "2.6.8"; then + echo "$PROG: target version too old" >&2 + exit 1 + fi + fi + exit 0 +fi if [ "$outfile" = "" ]; then - echo "$PROG: no output file specified" + echo "$PROG: no output file specified" >&2 exit 1 fi if [ $# -gt 1 ]; then - echo "$PROG: extra arguments found" + echo "$PROG: extra arguments found" >&2 exit 1 fi @@ -76,7 +114,7 @@ case $VERSION in */*) - echo $PROG: $VERSION is not a valid kernel version >&2 + echo "$PROG: $VERSION is not a valid kernel version" >&2 exit 1 ;; esac
mkinitrd.yaird
Description: Binary data