Handle unsupported distros with a prettier message
Subsystems (2)
PATCH 1/3 Handle unsupported distros with a prettier message
Handle unknown distros by saying "unknown" instead of an empty string and for Gentoo users actually mention it.
Signed-off-by Doug Goldstein <[email protected]>
--- lib/common-functions.sh | 4 ++++ 1 file changed, 4 insertions(+)
lib/common-functions.sh +4 -0
@@ -150,6 +150,9 @@ function get_distro() { sed -r 's/\"|\(|\)//g' | awk '{print $2}'` os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \ | sed 's/\"//g'` + elif [[ -f /etc/gentoo-release ]] + then + os_VENDOR="Gentoo" fi # Simply distro version string
@@ -175,6 +178,7 @@ function get_distro() { PKGTYPE="rpm" ;; *) + [ -z $os_VENDOR ] && os_VENDOR="unknown" DISTRO=$os_VENDOR PKGTYPE="unknown" ;;
Signature · 1 line
2.4.6
PATCH 2/3 Delete dangling white space
Signed-off-by Doug Goldstein <[email protected]>
--- lib/commands.sh | 4 ++-- lib/common-functions.sh | 10 +++++----- scripts/mkdeb | 8 ++++---- scripts/mkrpm | 4 ++-- tests/busybox-hvm | 8 ++++---- tests/busybox-hvm-migrate | 4 ++-- tests/busybox-pv | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-)
lib/commands.sh +2 -2
@@ -50,12 +50,12 @@ function install-builddep() { function build() { check-builddep - + mkdir -p "$INST_DIR" &>/dev/null # build and install under $DESTDIR for_each_component build - + build_package xen-system }
lib/common-functions.sh +5 -5
@@ -20,9 +20,9 @@ function common_init() { export PREFIX=${PREFIX-/usr} export INST_DIR=${DESTDIR-dist} export PREPEND="[raisin]" - + INST_DIR=`readlink -f $INST_DIR` - + # execution if [[ $EUID -eq 0 ]] then
@@ -62,7 +62,7 @@ function get_components() { COMPONENTS="$ENABLED_COMPONENTS" fi - if [[ -z "$COMPONENTS" ]] + if [[ -z "$COMPONENTS" ]] then local component for component in `cat "$BASEDIR"/components/series`
@@ -85,7 +85,7 @@ function get_tests() { TESTS="$ENABLED_TESTS" fi - if [[ -z "$TESTS" ]] + if [[ -z "$TESTS" ]] then local t for t in `cat "$BASEDIR"/tests/series`
@@ -384,7 +384,7 @@ function init_tests() { else error_echo "I don't know distro $DISTRO. It might be missing packages." fi - + if [[ -n "${missing[@]}" ]] then verbose_echo "Installing ${missing[@]}"
scripts/mkdeb +4 -4
@@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# mkdeb: package $INST_DIR output in a .deb +# mkdeb: package $INST_DIR output in a .deb # # Takes 1 argument: the package name # It relies on RAISIN_ARCH and INST_DIR being set correctly
@@ -8,10 +8,10 @@ set -e if [[ -z "$1" ]] -then +then echo "usage: $0 package_name" exit 1 -fi +fi name=$1
@@ -41,7 +41,7 @@ cp config raise deb/opt/raisin # Debian doesn't use /usr/lib64 for 64-bit libraries if [[ -d deb/usr/lib64 ]] -then +then cp -a deb/usr/lib64/* deb/usr/lib/ rm -rf deb/usr/lib64 fi
scripts/mkrpm +2 -2
@@ -8,10 +8,10 @@ set -e if [[ -z "$1" ]] -then +then echo "usage: $0 package_name" exit 1 -fi +fi name="$1"
tests/busybox-hvm +4 -4
@@ -16,17 +16,17 @@ function busybox-hvm-test() { echo $PREPEND busybox hvm test only valid on x86 exit 0 fi - + TMPDIR=`mktemp -d` cd $TMPDIR - + allocate_disk busybox-vm-disk $((20*1024*1024)) LOOP=`create_loop busybox-vm-disk` LOOP_P0=`create_one_partition busybox-vm-disk` busybox_rootfs $LOOP_P0 busybox_network_init $LOOP_P0 bootloader_init $LOOP $LOOP_P0 - + cat >busybox-hvm <<EOF builder = "hvm" memory = 512
@@ -37,7 +37,7 @@ serial="pty" boot="c" vif=['bridge=xenbr1'] EOF - + $SUDO xl create busybox-hvm check_guest_alive }
tests/busybox-hvm-migrate +2 -2
@@ -15,7 +15,7 @@ function busybox-hvm-migrate-test() { echo $PREPEND busybox hvm test only valid on x86 exit 0 fi - + busybox-hvm-test TMPSCRIPT=`mktemp`
@@ -26,7 +26,7 @@ function busybox-hvm-migrate-test() { shift \$* EOF - + chmod +x $TMPSCRIPT xl migrate -s $TMPSCRIPT raisin-test localhost check_guest_alive
tests/busybox-pv +3 -3
@@ -13,12 +13,12 @@ function busybox-pv-cleanup() { function busybox-pv-test() { TMPDIR=`mktemp -d` cd $TMPDIR - + allocate_disk busybox-vm-disk $((20*1024*1024)) LOOP=`create_loop busybox-vm-disk` busybox_rootfs $LOOP busybox_network_init $LOOP - + cat >busybox-pv <<EOF kernel = "`get_host_kernel`" ramdisk = "`get_host_initrd`"
@@ -31,7 +31,7 @@ serial="pty" boot="c" vif=['bridge=xenbr1'] EOF - + $SUDO xl create busybox-pv check_guest_alive }
Signature · 1 line
2.4.6
Re: [raisin][PATCH 2/3] Delete dangling white space
Quoted 1 line · Doug Goldstein
Signed-off-by Doug Goldstein <[email protected]>
Thanks!
Reviewed-by Stefano Stabellini <[email protected]>
Quoted 209 lines
lib/commands.sh | 4 ++-- lib/common-functions.sh | 10 +++++----- scripts/mkdeb | 8 ++++---- scripts/mkrpm | 4 ++-- tests/busybox-hvm | 8 ++++---- tests/busybox-hvm-migrate | 4 ++-- tests/busybox-pv | 6 +++--- 7 files changed, 22 insertions(+), 22 deletions(-)lib/commands.sh +2
-2@@ -50,12 +50,12 @@ function install-builddep() { function build() { check-builddep - + mkdir -p "$INST_DIR" &>/dev/null # build and install under $DESTDIR for_each_component build - + build_package xen-system }lib/common-functions.sh +5
-5@@ -20,9 +20,9 @@ function common_init() { export PREFIX=${PREFIX-/usr} export INST_DIR=${DESTDIR-dist} export PREPEND="[raisin]" - + INST_DIR=`readlink -f $INST_DIR` - + # execution if [[ $EUID -eq 0 ]] then@@ -62,7 +62,7 @@ function get_components() { COMPONENTS="$ENABLED_COMPONENTS" fi - if [[ -z "$COMPONENTS" ]] + if [[ -z "$COMPONENTS" ]] then local component for component in `cat "$BASEDIR"/components/series`@@ -85,7 +85,7 @@ function get_tests() { TESTS="$ENABLED_TESTS" fi - if [[ -z "$TESTS" ]] + if [[ -z "$TESTS" ]] then local t for t in `cat "$BASEDIR"/tests/series`@@ -384,7 +384,7 @@ function init_tests() { else error_echo "I don't know distro $DISTRO. It might be missing packages." fi - + if [[ -n "${missing[@]}" ]] then verbose_echo "Installing ${missing[@]}"scripts/mkdeb +4
-4@@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# mkdeb: package $INST_DIR output in a .deb +# mkdeb: package $INST_DIR output in a .deb # # Takes 1 argument: the package name # It relies on RAISIN_ARCH and INST_DIR being set correctly@@ -8,10 +8,10 @@ set -e if [[ -z "$1" ]] -then +then echo "usage: $0 package_name" exit 1 -fi +fi name=$1@@ -41,7 +41,7 @@ cp config raise deb/opt/raisin # Debian doesn't use /usr/lib64 for 64-bit libraries if [[ -d deb/usr/lib64 ]] -then +then cp -a deb/usr/lib64/* deb/usr/lib/ rm -rf deb/usr/lib64 fiscripts/mkrpm +2
-2@@ -8,10 +8,10 @@ set -e if [[ -z "$1" ]] -then +then echo "usage: $0 package_name" exit 1 -fi +fi name="$1"tests/busybox-hvm +4
-4@@ -16,17 +16,17 @@ function busybox-hvm-test() { echo $PREPEND busybox hvm test only valid on x86 exit 0 fi - + TMPDIR=`mktemp -d` cd $TMPDIR - + allocate_disk busybox-vm-disk $((20*1024*1024)) LOOP=`create_loop busybox-vm-disk` LOOP_P0=`create_one_partition busybox-vm-disk` busybox_rootfs $LOOP_P0 busybox_network_init $LOOP_P0 bootloader_init $LOOP $LOOP_P0 - + cat >busybox-hvm <<EOF builder = "hvm" memory = 512@@ -37,7 +37,7 @@ serial="pty" boot="c" vif=['bridge=xenbr1'] EOF - + $SUDO xl create busybox-hvm check_guest_alive }tests/busybox-hvm-migrate +2
-2@@ -15,7 +15,7 @@ function busybox-hvm-migrate-test() { echo $PREPEND busybox hvm test only valid on x86 exit 0 fi - + busybox-hvm-test TMPSCRIPT=`mktemp`@@ -26,7 +26,7 @@ function busybox-hvm-migrate-test() { shift \$* EOF - + chmod +x $TMPSCRIPT xl migrate -s $TMPSCRIPT raisin-test localhost check_guest_alivetests/busybox-pv +3
-3@@ -13,12 +13,12 @@ function busybox-pv-cleanup() { function busybox-pv-test() { TMPDIR=`mktemp -d` cd $TMPDIR - + allocate_disk busybox-vm-disk $((20*1024*1024)) LOOP=`create_loop busybox-vm-disk` busybox_rootfs $LOOP busybox_network_init $LOOP - + cat >busybox-pv <<EOF kernel = "`get_host_kernel`" ramdisk = "`get_host_initrd`"@@ -31,7 +31,7 @@ serial="pty" boot="c" vif=['bridge=xenbr1'] EOF - + $SUDO xl create busybox-pv check_guest_alive }Signature · 1 line
2.4.6
PATCH 3/3 Fix up coding style
In reply to Doug GoldsteinSigned-off-by Doug Goldstein <[email protected]>
--- lib/git-checkout.sh | 26 +++++++++++++------------- scripts/mkdeb | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-)
lib/git-checkout.sh +13 -13
@@ -3,8 +3,8 @@ function git-checkout() { if [[ $# -lt 3 ]] then - echo "Usage: $0 <tree> <tag> <dir>" - exit 1 + echo "Usage: $0 <tree> <tag> <dir>" + exit 1 fi TREE=$1
@@ -15,17 +15,17 @@ function git-checkout() { if [[ ! -d $DIR-remote ]] then - rm -rf $DIR-remote $DIR-remote.tmp - mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp - $GIT clone $TREE $DIR-remote.tmp - if [[ "$TAG" ]] - then - cd $DIR-remote.tmp - $GIT branch -D dummy >/dev/null 2>&1 ||: - $GIT checkout -b dummy $TAG - cd .. - fi - mv $DIR-remote.tmp $DIR-remote + rm -rf $DIR-remote $DIR-remote.tmp + mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp + $GIT clone $TREE $DIR-remote.tmp + if [[ "$TAG" ]] + then + cd $DIR-remote.tmp + $GIT branch -D dummy >/dev/null 2>&1 ||: + $GIT checkout -b dummy $TAG + cd .. + fi + mv $DIR-remote.tmp $DIR-remote fi rm -f $DIR ln -sf $DIR-remote $DIR
scripts/mkdeb +11 -11
@@ -9,8 +9,8 @@ set -e if [[ -z "$1" ]] then - echo "usage: $0 package_name" - exit 1 + echo "usage: $0 package_name" + exit 1 fi name=$1
@@ -19,13 +19,13 @@ cd "$BASEDIR" # map the architecture, if necessary case "$RAISIN_ARCH" in - x86_32|x86_32p) arch=i386 ;; - x86_64) arch=amd64 ;; - arm32) arch=armhf ;; - arm64) arch=$RAISIN_ARCH;; - *) echo "Unknown ARCH $RAISIN_ARCH" >&2 - exit 1 - ;; + x86_32|x86_32p) arch=i386 ;; + x86_64) arch=amd64 ;; + arm32) arch=armhf ;; + arm64) arch=$RAISIN_ARCH;; + *) echo "Unknown ARCH $RAISIN_ARCH" >&2 + exit 1 + ;; esac # Prepare the directory to package
@@ -42,8 +42,8 @@ cp config raise deb/opt/raisin # Debian doesn't use /usr/lib64 for 64-bit libraries if [[ -d deb/usr/lib64 ]] then - cp -a deb/usr/lib64/* deb/usr/lib/ - rm -rf deb/usr/lib64 + cp -a deb/usr/lib64/* deb/usr/lib/ + rm -rf deb/usr/lib64 fi # Fill in the debian boilerplate
Signature · 1 line
2.4.6
Re: [raisin][PATCH 3/3] Fix up coding style
Quoted 1 line · Doug Goldstein
Signed-off-by Doug Goldstein <[email protected]>
Reviewed-by Stefano Stabellini <[email protected]>
Quoted 98 lines
lib/git-checkout.sh | 26 +++++++++++++------------- scripts/mkdeb | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 24 deletions(-)lib/git-checkout.sh +13
-13@@ -3,8 +3,8 @@ function git-checkout() { if [[ $# -lt 3 ]] then - echo "Usage: $0 <tree> <tag> <dir>" - exit 1 + echo "Usage: $0 <tree> <tag> <dir>" + exit 1 fi TREE=$1@@ -15,17 +15,17 @@ function git-checkout() { if [[ ! -d $DIR-remote ]] then - rm -rf $DIR-remote $DIR-remote.tmp - mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp - $GIT clone $TREE $DIR-remote.tmp - if [[ "$TAG" ]] - then - cd $DIR-remote.tmp - $GIT branch -D dummy >/dev/null 2>&1 ||: - $GIT checkout -b dummy $TAG - cd .. - fi - mv $DIR-remote.tmp $DIR-remote + rm -rf $DIR-remote $DIR-remote.tmp + mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp + $GIT clone $TREE $DIR-remote.tmp + if [[ "$TAG" ]] + then + cd $DIR-remote.tmp + $GIT branch -D dummy >/dev/null 2>&1 ||: + $GIT checkout -b dummy $TAG + cd .. + fi + mv $DIR-remote.tmp $DIR-remote fi rm -f $DIR ln -sf $DIR-remote $DIRscripts/mkdeb +11
-11@@ -9,8 +9,8 @@ set -e if [[ -z "$1" ]] then - echo "usage: $0 package_name" - exit 1 + echo "usage: $0 package_name" + exit 1 fi name=$1@@ -19,13 +19,13 @@ cd "$BASEDIR" # map the architecture, if necessary case "$RAISIN_ARCH" in - x86_32|x86_32p) arch=i386 ;; - x86_64) arch=amd64 ;; - arm32) arch=armhf ;; - arm64) arch=$RAISIN_ARCH;; - *) echo "Unknown ARCH $RAISIN_ARCH" >&2 - exit 1 - ;; + x86_32|x86_32p) arch=i386 ;; + x86_64) arch=amd64 ;; + arm32) arch=armhf ;; + arm64) arch=$RAISIN_ARCH;; + *) echo "Unknown ARCH $RAISIN_ARCH" >&2 + exit 1 + ;; esac # Prepare the directory to package@@ -42,8 +42,8 @@ cp config raise deb/opt/raisin # Debian doesn't use /usr/lib64 for 64-bit libraries if [[ -d deb/usr/lib64 ]] then - cp -a deb/usr/lib64/* deb/usr/lib/ - rm -rf deb/usr/lib64 + cp -a deb/usr/lib64/* deb/usr/lib/ + rm -rf deb/usr/lib64 fi # Fill in the debian boilerplateSignature · 1 line
2.4.6
Quoted 23 lines · Doug Goldstein
Handle unknown distros by saying "unknown" instead of an empty string and for Gentoo users actually mention it.
Signed-off-by Doug Goldstein <[email protected]>--- lib/common-functions.sh | 4 ++++ 1 file changed, 4 insertions(+)lib/common-functions.sh +3
-0@@ -150,6 +150,9 @@ function get_distro() { sed -r 's/\"|\(|\)//g' | awk '{print $2}'` os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \ | sed 's/\"//g'` + elif [[ -f /etc/gentoo-release ]] + then + os_VENDOR="Gentoo" fi # Simply distro version string
lib/common-functions.sh function get_distro() { · line 184
Quoted 7 lines
lib/common-functions.sh +1
-0@@ -175,6 +178,7 @@ function get_distro() { PKGTYPE="rpm" ;; *) + [ -z $os_VENDOR ] && os_VENDOR="unknown" DISTRO=$os_VENDOR PKGTYPE="unknown" ;;
Thanks again for the patch.
For consistency with the code style, could you please turn this into:
if [[ -z $os_VENDOR ]]
then
os_VENDOR="unknown"
fi
You could also move it above the case.