From c400694da4d6bdcefe286442c26a1192fb19ba52 Mon Sep 17 00:00:00 2001
From: Michal Skalski <mskalski@mirantis.com>
Date: Sat, 30 Jan 2016 01:05:48 +0100
Subject: [PATCH] Increase size of var partition on Fuel Master

Because we want to store local mirrors it could happen
that there will be no enough space on var partition to build
installation os image.

Also sync with upstream changes.

Change-Id: I95161453d72bdee2b6992955b0634d33c64f0b4e
Signed-off-by: Michal Skalski <mskalski@mirantis.com>
---
 build/f_isoroot/f_kscfg/ks.cfg      | 46 ++++++++++++++++++++++++++-----------
 build/f_isoroot/f_kscfg/ks.cfg.orig | 44 +++++++++++++++++++++++++----------
 2 files changed, 65 insertions(+), 25 deletions(-)

diff --git a/build/f_isoroot/f_kscfg/ks.cfg b/build/f_isoroot/f_kscfg/ks.cfg
index 356a56267..12cb2cd71 100644
--- a/build/f_isoroot/f_kscfg/ks.cfg
+++ b/build/f_isoroot/f_kscfg/ks.cfg
@@ -283,7 +283,7 @@ volgroup os pv.001
 volgroup docker pv.002
 logvol swap --vgname=os --recommended --name=swap
 logvol / --vgname=os --size=10000 --name=root --fstype=ext4
-logvol /var --vgname=os --size=10000 --name=var --fstype=ext4
+logvol /var --vgname=os --size=15000 --name=var --fstype=ext4
 logvol /var/log --vgname=os --size=4000 --grow --name=varlog --fstype=ext4
 EOF
 
@@ -381,6 +381,38 @@ case "${repo}" in
     fi
   ;;
 esac
+
+
+# If not mounted, try to bind /run/install/repo since
+# anaconda shoud mount installation repo to that folder.
+if ! mountpoint -q "${SOURCE}"; then
+  if [ -d '/run/install/repo' ] && mountpoint -q '/run/install/repo'; then
+    mount -o bind '/run/install/repo' "${SOURCE}"
+  fi
+fi
+
+
+# If still not mounted, try to mount from LABEL / UUID.
+# It was moved from next phase here to keep all mounting stuff
+# in one place. All other scripts should use SOURCE variable
+# for access to dist files.
+
+iso_volume_id=OpenStack_Fuel
+iso_disk_uuid=will_be_substituted_with_actual_uuid
+FS="/mnt/sysimage/tmp/fs"
+
+if ! mountpoint -q "${SOURCE}"; then
+  if [ -e "/dev/disk/by-label/${iso_volume_id}" ]; then
+    mount "/dev/disk/by-label/${iso_volume_id}" "${SOURCE}"
+  elif [ -e "/dev/disk/by-uuid/${iso_disk_uuid}" ]; then
+    mkdir -p "${FS}"
+    mount "/dev/disk/by-uuid/${iso_disk_uuid}" "${FS}"
+    mount -o loop "${FS}/nailgun.iso" "${SOURCE}"
+  fi
+fi
+
+# Sleep to capture full log
+sleep 1
 %end
 
 
@@ -391,19 +423,7 @@ esac
 #!/bin/bash
 set -x
 
-# Mounting installation source
 SOURCE=/tmp/source
-FS=/tmp/fs
-
-mkdir -p ${SOURCE}
-mkdir -p ${FS}
-
-if test -e /dev/disk/by-label/OpenStack_Fuel; then
-    mount /dev/disk/by-label/OpenStack_Fuel ${SOURCE}
-elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
-    mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
-    mount -o loop ${FS}/nailgun.iso ${SOURCE}
-fi
 
 # this file is provided by fuel-openstack-metadata package
 OPENSTACK_VERSION=`cat /etc/fuel_openstack_version`
diff --git a/build/f_isoroot/f_kscfg/ks.cfg.orig b/build/f_isoroot/f_kscfg/ks.cfg.orig
index 0305aa77e..54aabf003 100644
--- a/build/f_isoroot/f_kscfg/ks.cfg.orig
+++ b/build/f_isoroot/f_kscfg/ks.cfg.orig
@@ -381,6 +381,38 @@ case "${repo}" in
     fi
   ;;
 esac
+
+
+# If not mounted, try to bind /run/install/repo since
+# anaconda shoud mount installation repo to that folder.
+if ! mountpoint -q "${SOURCE}"; then
+  if [ -d '/run/install/repo' ] && mountpoint -q '/run/install/repo'; then
+    mount -o bind '/run/install/repo' "${SOURCE}"
+  fi
+fi
+
+
+# If still not mounted, try to mount from LABEL / UUID.
+# It was moved from next phase here to keep all mounting stuff
+# in one place. All other scripts should use SOURCE variable
+# for access to dist files.
+
+iso_volume_id=OpenStack_Fuel
+iso_disk_uuid=will_be_substituted_with_actual_uuid
+FS="/mnt/sysimage/tmp/fs"
+
+if ! mountpoint -q "${SOURCE}"; then
+  if [ -e "/dev/disk/by-label/${iso_volume_id}" ]; then
+    mount "/dev/disk/by-label/${iso_volume_id}" "${SOURCE}"
+  elif [ -e "/dev/disk/by-uuid/${iso_disk_uuid}" ]; then
+    mkdir -p "${FS}"
+    mount "/dev/disk/by-uuid/${iso_disk_uuid}" "${FS}"
+    mount -o loop "${FS}/nailgun.iso" "${SOURCE}"
+  fi
+fi
+
+# Sleep to capture full log
+sleep 1
 %end
 
 
@@ -391,19 +423,7 @@ esac
 #!/bin/bash
 set -x
 
-# Mounting installation source
 SOURCE=/tmp/source
-FS=/tmp/fs
-
-mkdir -p ${SOURCE}
-mkdir -p ${FS}
-
-if test -e /dev/disk/by-label/OpenStack_Fuel; then
-    mount /dev/disk/by-label/OpenStack_Fuel ${SOURCE}
-elif test -e /dev/disk/by-uuid/will_be_substituted_with_actual_uuid; then
-    mount /dev/disk/by-uuid/will_be_substituted_with_actual_uuid ${FS}
-    mount -o loop ${FS}/nailgun.iso ${SOURCE}
-fi
 
 # this file is provided by fuel-openstack-metadata package
 OPENSTACK_VERSION=`cat /etc/fuel_openstack_version`
-- 
2.16.6