Skip to contentSkip to conversation

Handle unsupported distros with a prettier message

PATCH Superseded Doug Goldstein 2 participants 6 messages Sep 9, 2015 – Sep 11, 2015

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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.

---
 lib/common-functions.sh | 4 ++++
 1 file changed, 4 insertions(+)
lib/common-functions.sh +4 -0
index c52174a..e96b105 100644
@@ -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
#1 lore raw

PATCH 2/3 Delete dangling white space

---
 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
index a79611e..be445a7 100755
@@ -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
index e96b105..4ab77ba 100644
@@ -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
index dbd92bd..5259f1e 100755
@@ -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
index 7965c0c..88997c6 100755
@@ -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
index 2b6c1dd..51e9e19 100755
@@ -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
index 14ffc0d..8e8213b 100755
@@ -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
index ec3ba5c..a7ae976 100755
@@ -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
Reviewed-by on v1 2/3
#2 lore raw

Re: [raisin][PATCH 2/3] Delete dangling white space

Quoted 1 line · Doug Goldstein

Thanks!

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
index a79611e..be445a7 100755
@@ -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
index e96b105..4ab77ba 100644
@@ -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
index dbd92bd..5259f1e 100755
@@ -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
index 7965c0c..88997c6 100755
@@ -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
index 2b6c1dd..51e9e19 100755
@@ -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
index 14ffc0d..8e8213b 100755
@@ -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
index ec3ba5c..a7ae976 100755
@@ -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
#3 lore raw

PATCH 3/3 Fix up coding style

In reply to Doug Goldstein
---
 lib/git-checkout.sh | 26 +++++++++++++-------------
 scripts/mkdeb       | 22 +++++++++++-----------
 2 files changed, 24 insertions(+), 24 deletions(-)
lib/git-checkout.sh +13 -13
index 2ca8f25..d462453 100755
@@ -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
index 5259f1e..3796300 100755
@@ -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
Reviewed-by on v1 3/3
#4 lore raw

Re: [raisin][PATCH 3/3] Fix up coding style

Quoted 1 line · Doug Goldstein
Quoted 98 lines
 lib/git-checkout.sh | 26 +++++++++++++-------------
 scripts/mkdeb       | 22 +++++++++++-----------
 2 files changed, 24 insertions(+), 24 deletions(-)
lib/git-checkout.sh +13 -13
index 2ca8f25..d462453 100755
@@ -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
index 5259f1e..3796300 100755
@@ -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
#5 lore raw
In reply to Doug Goldstein
Quoted 23 lines · Doug Goldstein

Handle unknown distros by saying "unknown" instead of an empty string and for Gentoo users actually mention it.

---
 lib/common-functions.sh | 4 ++++
 1 file changed, 4 insertions(+)
lib/common-functions.sh +3 -0
index c52174a..e96b105 100644
@@ -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.