File lxc-2.0.9-opensuse.patch of Package lxc

diff -Ndurp lxc-2.0.9/templates/lxc-opensuse.in lxc-2.0.9-opensuse/templates/lxc-opensuse.in
--- lxc-2.0.9/templates/lxc-opensuse.in	2017-10-19 20:13:25.000000000 +0300
+++ lxc-2.0.9-opensuse/templates/lxc-opensuse.in	2018-01-22 17:43:12.159247974 +0200
@@ -125,7 +125,7 @@ download_opensuse()
     arch=$2
 
     if [ ! -x ${BUILD} ]; then
-       echo "Could not create openSUSE template :"
+       echo "Could not create openSUSE template:"
        echo "you need to install \"build\" package"
        return 1
     fi
@@ -142,24 +142,24 @@ download_opensuse()
     echo "Downloading opensuse minimal ..."
     mkdir -p "$cache/partial-$arch-packages"
 
-    oss_repo_url="http://download.opensuse.org/distribution/$DISTRO/repo/oss/"
-    if [[ $DISTRO == "tumbleweed" ]]; then
-        oss_repo_url="http://download.opensuse.org/$DISTRO/repo/oss/"
-    fi
+    [ $DISTRO = "tumbleweed" ] && oss_repo_url="http://download.opensuse.org/$DISTRO/repo/oss/" || oss_repo_url="http://download.opensuse.org/distribution/$DISTRO/repo/oss/"
+
     zypper --quiet --root $cache/partial-$arch-packages --non-interactive ar "$oss_repo_url" repo-oss || return 1
 
-    update_repo_url="http://download.opensuse.org/update/$DISTRO/repo/oss"
     # Leap update repos were rearranged
-    if [[ $DISTRO == "leap/4"* ]]; then
-        update_repo_url="http://download.opensuse.org/update/$DISTRO/oss/"
-    fi
+    case "$DISTRO" in
+        leap/42.*) update_repo_url="http://download.opensuse.org/update/$DISTRO/oss/" ;;
+        *) update_repo_url="http://download.opensuse.org/update/$DISTRO/repo/oss" ;;
+    esac
     # tumbleweed has no update repo
-    if [[ $DISTRO != "tumbleweed" ]]; then
-        zypper --quiet --root $cache/partial-$arch-packages --non-interactive ar "$update_repo_url" update || return 1
-    fi
+    [ $DISTRO = "tumbleweed" ] || zypper --quiet --root $cache/partial-$arch-packages --non-interactive ar "$update_repo_url" update || return 1
 
     zypper --quiet --root $cache/partial-$arch-packages --non-interactive --gpg-auto-import-keys update || return 1
-    zypper --root $cache/partial-$arch-packages --non-interactive in --auto-agree-with-licenses --download-only zypper lxc patterns-openSUSE-base bash iputils sed tar rsyslog || return 1
+
+    case "$DISTRO" in
+        leap/42.*|tumbleweed) zypper --root $cache/partial-$arch-packages --non-interactive in --auto-agree-with-licenses --download-only zypper lxc patterns-openSUSE-base bash iputils sed tar net-tools iproute2 || return 1 ;;
+        *) zypper --root $cache/partial-$arch-packages --non-interactive in --auto-agree-with-licenses --download-only zypper lxc patterns-openSUSE-base bash iputils sed tar rsyslog || return 1 ;;
+    esac
 
     cat > $cache/partial-$arch-packages/opensuse.conf << EOF
 Preinstall: aaa_base bash coreutils diffutils
@@ -179,34 +179,31 @@ Support: ncurses-utils
 Support: iputils
 Support: udev
 Support: netcfg
-Support: hwinfo insserv-compat module-init-tools openSUSE-release openssh
+Support: module-init-tools openSUSE-release openssh
 Support: pwdutils sysconfig
 
 Ignore: rpm:suse-build-key,build-key
 Ignore: systemd:systemd-presets-branding
 EOF
 
-    if [ $DISTRO = "13.2" ]
-    then
-	echo "Support: python3-base" >> $cache/partial-$arch-packages/opensuse.conf
-    fi
+    [ $DISTRO != "13.2" ] || echo "Support: python3-base" >> $cache/partial-$arch-packages/opensuse.conf
 
-    if [[ $DISTRO == "tumbleweed" ]]; then
-	echo "Preinstall: liblua5_3 libncurses6 libreadline7" >> $cache/partial-$arch-packages/opensuse.conf
+    if [ $DISTRO = "tumbleweed" ]; then
+        echo "Preinstall: liblua5_3-5 libncurses6 libreadline7" >> $cache/partial-$arch-packages/opensuse.conf
     else
-	echo "Preinstall: liblua5_1 libncurses5 libreadline6" >> $cache/partial-$arch-packages/opensuse.conf
-	echo "Support: rpcbind" >> $cache/partial-$arch-packages/opensuse.conf
-    fi
-
-    # dhcpcd is not in the default repos since Leap 42.1, neither in tumbleweed
-    if [[ $DISTRO != "leap/4"* ]] && [[ $DISTRO != "tumbleweed" ]]; then
-        echo "Support: dhcpcd" >> $cache/partial-$arch-packages/opensuse.conf
+        # Tumbleweed doesn't seem to have hwinfo and insserv-compat
+        echo "Preinstall: liblua5_1 libncurses5 libreadline6" >> $cache/partial-$arch-packages/opensuse.conf
+        echo "Preinstall: insserv-compat" >> $cache/partial-$arch-packages/opensuse.conf
+        echo "Support: rpcbind" >> $cache/partial-$arch-packages/opensuse.conf
+        echo "Support: hwinfo insserv-compat" >> $cache/partial-$arch-packages/opensuse.conf
     fi
 
-    # Leap and tumbleweed doesn't seem to have iproute2 utils installed
-    if [[ $DISTRO == "leap/4"* ]] || [[ $DISTRO == "tumbleweed" ]]; then
-        echo "Support: net-tools iproute2" >> $cache/partial-$arch-packages/opensuse.conf
-    fi
+    case "$DISTRO" in
+        # Leap and tumbleweed doesn't seem to have iproute2 utils installed
+        leap/42.*|tumbleweed) echo "Support: net-tools iproute2" >> $cache/partial-$arch-packages/opensuse.conf ;;
+        # dhcpcd is not in the default repos since Leap 42.1, neither in tumbleweed
+        *) echo "Support: dhcpcd" >> $cache/partial-$arch-packages/opensuse.conf ;;
+    esac
 
     if [ "$arch" = "i686" ]; then
         mkdir -p $cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/i686/
@@ -223,16 +220,14 @@ EOF
     [ -d $cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch ] || mkdir -p $cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch
 
     repos=("--repository" "$cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/$arch" "--repository" "$cache/partial-$arch-packages/var/cache/zypp/packages/repo-oss/suse/noarch")
-    if [[ $DISTRO != "tumbleweed" ]]; then # tumbleweed has no update repo
-	repos+=("--repository" "$cache/partial-$arch-packages/var/cache/zypp/packages/update/$arch" "--repository" "$cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch")
+    if [ $DISTRO != "tumbleweed" ]; then # tumbleweed has no update repo
+        repos+=("--repository" "$cache/partial-$arch-packages/var/cache/zypp/packages/update/$arch" "--repository" "$cache/partial-$arch-packages/var/cache/zypp/packages/update/noarch")
     fi
 
     CLEAN_BUILD=1 BUILD_ARCH="$arch" BUILD_ROOT="$cache/partial-$arch" BUILD_DIST="$cache/partial-$arch-packages/opensuse.conf" PATH="$PATH:$BUILD_DIR" $BUILD_DIR/init_buildsystem  --clean --configdir $BUILD_DIR/configs --cachedir $cache/partial-$arch-cache ${repos[*]} || return 1
 
     chroot $cache/partial-$arch /usr/bin/zypper --quiet --non-interactive ar "$oss_repo_url" repo-oss || return 1
-    if [[ $DISTRO != "tumbleweed" ]]; then
-        chroot $cache/partial-$arch /usr/bin/zypper --quiet --non-interactive ar "$update_repo_url" update || return 1
-    fi
+    [ $DISTRO = "tumbleweed" ] || chroot $cache/partial-$arch /usr/bin/zypper --quiet --non-interactive ar "$update_repo_url" update || return 1
 
 #   really clean the image
     rm -fr $cache/partial-$arch/{.build,.guessed_dist,.srcfiles*,installed-pkg}
@@ -345,14 +340,9 @@ lxc.rootfs = $rootfs_path
         # Seems that \s doesn't work in brackets.
         KEY=$(expr "${LINE}" : '\s*\([^	 ]*\)\s*=')
 
-        if [[ "${KEY}" != "lxc.network.hwaddr" ]]
-        then
+        if [ "${KEY}" != "lxc.network.hwaddr" ]; then
             echo "${LINE}" >> $path/config
-
-            if [[ "${KEY}" == "lxc.network.link" ]]
-            then
-                echo "lxc.network.hwaddr = $(create_hwaddr)" >> $path/config
-            fi
+            [ "${KEY}" != "lxc.network.link" ] || echo "lxc.network.hwaddr = $(create_hwaddr)" >> $path/config
         fi
     done < $path/config.def
 
@@ -401,9 +391,7 @@ clean()
 {
     cache="${LXC_CACHE_PATH:-@LOCALSTATEDIR@/cache/lxc/opensuse}"
 
-    if [ ! -e $cache ]; then
-        exit 0
-    fi
+    [ -e $cache ] || exit 0
 
     # lock, so we won't purge while someone is creating a repository
     (
@@ -424,7 +412,7 @@ usage()
     cat <<EOF
 $1 -h|--help -p|--path=<path> -r|--release nn.n --clean
 Please give the release as 13.1, 13.2 etc.
-If no release is given, openSUSE Leap 42.2 is installed.
+If no release is given, openSUSE Leap 42.3 is installed.
 EOF
     return 0
 }
@@ -470,33 +458,30 @@ if [ -z "$path" ]; then
 fi
 
 if grep -q Harlequin /etc/os-release || grep -q Tumbleweed /etc/os-release ; then
-    BVER=`rpm -q --qf '%{version}\n' build`
+    BVER=$(rpm -q --qf '%{version}\n' build)
     if [ $? -ne 0 -o "$BVER" -lt "20141120" ]; then
-	echo "Building openSUSE containers with your version of the build package is broken. Please install the update to version 20141120 or newer."
-	exit 1
+        echo "Building openSUSE containers with your version of the build package is broken. Please install the update to version 20141120 or newer."
+        exit 1
     fi
 fi
 
 if [ -z "$DISTRO" ]; then
     echo ""
-    echo "No release selected, using openSUSE Leap 42.2"
-    DISTRO="leap/42.2"
+    echo "No release selected, using openSUSE Leap 42.3"
+    DISTRO="leap/42.3"
 else
     echo ""
     case "$DISTRO" in
 	13.1)
 	    echo "Selected openSUSE 13.1"
 	    ;;
-
 	13.2)
 	    echo "Selected openSUSE 13.2"
 	    ;;
-
 	42.1|leap/42.1|leap)
 	    echo "Selected openSUSE Leap 42.1"
 	    DISTRO="leap/42.1"
 	    ;;
-
         42.2|leap/42.2|422)
             echo "Selected openSUSE Leap 42.2"
             DISTRO="leap/42.2"
@@ -509,7 +494,6 @@ else
             echo "Selected openSUSE Leap Tumbleweed"
             DISTRO="tumbleweed"
             ;;
-
 	*)
 	    echo "You have chosen an invalid release, quitting..."
 	    exit 1
@@ -526,11 +510,7 @@ fi
 # detect rootfs
 config="$path/config"
 if [ -z "$rootfs" ]; then
-    if grep -q '^lxc.rootfs' $config 2>/dev/null ; then
-        rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config)
-    else
-        rootfs=$path/rootfs
-    fi
+    grep -q '^lxc.rootfs' $config 2>/dev/null && rootfs=$(awk -F= '/^lxc.rootfs =/{ print $2 }' $config) || rootfs=$path/rootfs
 fi
 
 install_opensuse $rootfs
openSUSE Build Service is sponsored by