From 20d3ceba796ae7e0e722b4d2b94f7134eb43ab4a Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Tue, 12 Feb 2013 10:21:50 -0600
Subject: [PATCH] RootStock-NG: specify final output directory

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 RootStock-NG.sh    |  2 ++
 base_image.sh      | 36 +++++++++++++++++++++++++++++++++++-
 build_image.sh     | 36 +++++++++++++++++++++++++++++++++++-
 imx_build_image.sh | 36 +++++++++++++++++++++++++++++++++++-
 lxde_image.sh      | 35 ++++++++++++++++++++++++++++++++++-
 nightly_build.sh   | 36 +++++++++++++++++++++++++++++++++++-
 scripts/chroot.sh  | 37 ++++++++++++++-----------------------
 7 files changed, 190 insertions(+), 28 deletions(-)

diff --git a/RootStock-NG.sh b/RootStock-NG.sh
index 8543eb357..d00d057d2 100755
--- a/RootStock-NG.sh
+++ b/RootStock-NG.sh
@@ -84,6 +84,8 @@ run_project () {
 
 	cat > ${DIR}/.project <<-__EOF__
 		tempdir="${tempdir}"
+		export_filename="${export_filename}"
+
 		distro="${distro}"
 
 		release="${release}"
diff --git a/base_image.sh b/base_image.sh
index 279333057..a0b5a8bcd 100755
--- a/base_image.sh
+++ b/base_image.sh
@@ -23,6 +23,7 @@
 SYST=$(uname -n)
 HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
+time=$(date +%Y-%m-%d)
 
 unset USE_OEM
 unset ROOTSTOCKNG
@@ -83,10 +84,26 @@ function minimal_armel {
 
 		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
 
+		#Actual Releases will use version numbers..
+		case "${DIST}" in
+		squeeze)
+			#http://www.debian.org/releases/squeeze/
+			export_filename="${distro}-6.0.6-minimal-${ARCH}-${time}"
+			;;
+		quantal)
+			export_filename="${distro}-12.10-minimal-${ARCH}-${time}"
+			;;
+		*)
+			export_filename="${distro}-${DIST}-minimal-${ARCH}-${time}"
+			;;
+		esac
+
 		tempdir=$(mktemp -d)
 
 		cat > ${DIR}/.project <<-__EOF__
 			tempdir="${tempdir}"
+			export_filename="${export_filename}"
+
 			distro="${distro}"
 
 			release="${DIST}"
@@ -167,7 +184,23 @@ if [ ! "${ROOTSTOCKNG}" ] ; then
 
 	cd ${DIR}/deploy/
 else
-	echo "later"
+	echo "Starting Compression"
+	cd ${DIR}/deploy/
+
+	if [ -f ${DIR}/release ] ; then
+		tar cvf ${export_filename}.tar ./${export_filename}
+		xz -z -7 -v ${export_filename}.tar
+
+		if [ "x${SYST}" == "x${RELEASE_HOST}" ] ; then
+			if [ -d /mnt/farm/testing/pending/ ] ; then
+				cp -v ${export_filename}.tar.xz /mnt/farm/testing/pending/${export_filename}.tar.xz
+			fi
+		fi
+
+	else
+		tar cvf ${export_filename}.tar ./${export_filename}
+	fi
+	cd ${DIR}/
 fi
 }
 
@@ -249,6 +282,7 @@ function sid_release {
 source ${DIR}/var/defaults.sh
 source ${DIR}/var/check_host.sh
 
+mirror="http://rcn-ee.net/deb"
 if [ -f ${DIR}/rcn-ee.host ] ; then
 	source ${DIR}/host/rcn-ee-host.sh
 fi
diff --git a/build_image.sh b/build_image.sh
index 9c7912b28..3e2d937d3 100755
--- a/build_image.sh
+++ b/build_image.sh
@@ -23,6 +23,7 @@
 SYST=$(uname -n)
 HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
+time=$(date +%Y-%m-%d)
 
 unset USE_OEM
 unset ROOTSTOCKNG
@@ -89,10 +90,26 @@ function minimal_armel {
 
 		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
 
+		#Actual Releases will use version numbers..
+		case "${DIST}" in
+		squeeze)
+			#http://www.debian.org/releases/squeeze/
+			export_filename="${distro}-6.0.6-console-${ARCH}-${time}"
+			;;
+		quantal)
+			export_filename="${distro}-12.10-console-${ARCH}-${time}"
+			;;
+		*)
+			export_filename="${distro}-${DIST}-console-${ARCH}-${time}"
+			;;
+		esac
+
 		tempdir=$(mktemp -d)
 
 		cat > ${DIR}/.project <<-__EOF__
 			tempdir="${tempdir}"
+			export_filename="${export_filename}"
+
 			distro="${distro}"
 
 			release="${DIST}"
@@ -191,7 +208,23 @@ if [ ! "${ROOTSTOCKNG}" ] ; then
 
 	cd ${DIR}/deploy/
 else
-	echo "later"
+	echo "Starting Compression"
+	cd ${DIR}/deploy/
+
+	if [ -f ${DIR}/release ] ; then
+		tar cvf ${export_filename}.tar ./${export_filename}
+		xz -z -7 -v ${export_filename}.tar
+
+		if [ "x${SYST}" == "x${RELEASE_HOST}" ] ; then
+			if [ -d /mnt/farm/testing/pending/ ] ; then
+				cp -v ${export_filename}.tar.xz /mnt/farm/testing/pending/${export_filename}.tar.xz
+			fi
+		fi
+
+	else
+		tar cvf ${export_filename}.tar ./${export_filename}
+	fi
+	cd ${DIR}/
 fi
 }
 
@@ -355,6 +388,7 @@ function sid_release {
 source ${DIR}/var/defaults.sh
 source ${DIR}/var/check_host.sh
 
+mirror="http://rcn-ee.net/deb"
 if [ -f ${DIR}/rcn-ee.host ] ; then
 	source ${DIR}/host/rcn-ee-host.sh
 	source ${DIR}/host/rcn-ee-demo-image.sh
diff --git a/imx_build_image.sh b/imx_build_image.sh
index 559ab486e..dc967049e 100755
--- a/imx_build_image.sh
+++ b/imx_build_image.sh
@@ -23,6 +23,7 @@
 SYST=$(uname -n)
 HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
+time=$(date +%Y-%m-%d)
 
 unset USE_OEM
 unset ROOTSTOCKNG
@@ -89,10 +90,26 @@ function minimal_armel {
 
 		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
 
+		#Actual Releases will use version numbers..
+		case "${DIST}" in
+		squeeze)
+			#http://www.debian.org/releases/squeeze/
+			export_filename="${distro}-6.0.6-console-${ARCH}-${time}"
+			;;
+		quantal)
+			export_filename="${distro}-12.10-console-${ARCH}-${time}"
+			;;
+		*)
+			export_filename="${distro}-${DIST}-console-${ARCH}-${time}"
+			;;
+		esac
+
 		tempdir=$(mktemp -d)
 
 		cat > ${DIR}/.project <<-__EOF__
 			tempdir="${tempdir}"
+			export_filename="${export_filename}"
+
 			distro="${distro}"
 
 			release="${DIST}"
@@ -191,7 +208,23 @@ if [ ! "${ROOTSTOCKNG}" ] ; then
 
 	cd ${DIR}/deploy/
 else
-	echo "later"
+	echo "Starting Compression"
+	cd ${DIR}/deploy/
+
+	if [ -f ${DIR}/release ] ; then
+		tar cvf ${export_filename}.tar ./${export_filename}
+		xz -z -7 -v ${export_filename}.tar
+
+		if [ "x${SYST}" == "x${RELEASE_HOST}" ] ; then
+			if [ -d /mnt/farm/testing/pending/ ] ; then
+				cp -v ${export_filename}.tar.xz /mnt/farm/testing/pending/${export_filename}.tar.xz
+			fi
+		fi
+
+	else
+		tar cvf ${export_filename}.tar ./${export_filename}
+	fi
+	cd ${DIR}/
 fi
 }
 
@@ -270,6 +303,7 @@ function wheezy_release {
 source ${DIR}/var/defaults.sh
 source ${DIR}/var/check_host.sh
 
+mirror="http://rcn-ee.net/deb"
 if [ -f ${DIR}/rcn-ee.host ] ; then
 	source ${DIR}/host/rcn-ee-host.sh
 	source ${DIR}/host/rcn-ee-demo-image.sh
diff --git a/lxde_image.sh b/lxde_image.sh
index e60fe5294..1fe8c17f4 100755
--- a/lxde_image.sh
+++ b/lxde_image.sh
@@ -89,10 +89,26 @@ function minimal_armel {
 
 		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
 
+		#Actual Releases will use version numbers..
+		case "${DIST}" in
+		squeeze)
+			#http://www.debian.org/releases/squeeze/
+			export_filename="${distro}-6.0.6-lxde-${ARCH}-${time}"
+			;;
+		quantal)
+			export_filename="${distro}-12.10-lxde-${ARCH}-${time}"
+			;;
+		*)
+			export_filename="${distro}-${DIST}-lxde-${ARCH}-${time}"
+			;;
+		esac
+
 		tempdir=$(mktemp -d)
 
 		cat > ${DIR}/.project <<-__EOF__
 			tempdir="${tempdir}"
+			export_filename="${export_filename}"
+
 			distro="${distro}"
 
 			release="${DIST}"
@@ -191,7 +207,23 @@ if [ ! "${ROOTSTOCKNG}" ] ; then
 
 	cd ${DIR}/deploy/
 else
-	echo "later"
+	echo "Starting Compression"
+	cd ${DIR}/deploy/
+
+	if [ -f ${DIR}/release ] ; then
+		tar cvf ${export_filename}.tar ./${export_filename}
+		xz -z -7 -v ${export_filename}.tar
+
+		if [ "x${SYST}" == "x${RELEASE_HOST}" ] ; then
+			if [ -d /mnt/farm/testing/pending/ ] ; then
+				cp -v ${export_filename}.tar.xz /mnt/farm/testing/pending/${export_filename}.tar.xz
+			fi
+		fi
+
+	else
+		tar cvf ${export_filename}.tar ./${export_filename}
+	fi
+	cd ${DIR}/
 fi
 }
 
@@ -348,6 +380,7 @@ function sid_release {
 source ${DIR}/var/defaults.sh
 source ${DIR}/var/check_host.sh
 
+mirror="http://rcn-ee.net/deb"
 if [ -f ${DIR}/rcn-ee.host ] ; then
 	source ${DIR}/host/rcn-ee-host.sh
 	source ${DIR}/host/rcn-ee-demo-image.sh
diff --git a/nightly_build.sh b/nightly_build.sh
index 225f4c475..a21da26aa 100755
--- a/nightly_build.sh
+++ b/nightly_build.sh
@@ -23,6 +23,7 @@
 SYST=$(uname -n)
 HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
+time=$(date +%Y-%m-%d)
 
 unset USE_OEM
 unset ROOTSTOCKNG
@@ -89,10 +90,26 @@ function minimal_armel {
 
 		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
 
+		#Actual Releases will use version numbers..
+		case "${DIST}" in
+		squeeze)
+			#http://www.debian.org/releases/squeeze/
+			export_filename="${distro}-6.0.6-console-${ARCH}-${time}"
+			;;
+		quantal)
+			export_filename="${distro}-12.10-console-${ARCH}-${time}"
+			;;
+		*)
+			export_filename="${distro}-${DIST}-console-${ARCH}-${time}"
+			;;
+		esac
+
 		tempdir=$(mktemp -d)
 
 		cat > ${DIR}/.project <<-__EOF__
 			tempdir="${tempdir}"
+			export_filename="${export_filename}"
+
 			distro="${distro}"
 
 			release="${DIST}"
@@ -191,7 +208,23 @@ if [ ! "${ROOTSTOCKNG}" ] ; then
 
 	cd ${DIR}/deploy/
 else
-	echo "later"
+	echo "Starting Compression"
+	cd ${DIR}/deploy/
+
+	if [ -f ${DIR}/release ] ; then
+		tar cvf ${export_filename}.tar ./${export_filename}
+		xz -z -7 -v ${export_filename}.tar
+
+		if [ "x${SYST}" == "x${RELEASE_HOST}" ] ; then
+			if [ -d /mnt/farm/testing/pending/ ] ; then
+				cp -v ${export_filename}.tar.xz /mnt/farm/testing/pending/${export_filename}.tar.xz
+			fi
+		fi
+
+	else
+		tar cvf ${export_filename}.tar ./${export_filename}
+	fi
+	cd ${DIR}/
 fi
 }
 
@@ -355,6 +388,7 @@ function sid_release {
 source ${DIR}/var/defaults.sh
 source ${DIR}/var/check_host.sh
 
+mirror="http://rcn-ee.net/deb"
 if [ -f ${DIR}/rcn-ee.host ] ; then
 	source ${DIR}/host/rcn-ee-host.sh
 	source ${DIR}/host/rcn-ee-demo-image.sh
diff --git a/scripts/chroot.sh b/scripts/chroot.sh
index 9882ca3c1..178f752e6 100755
--- a/scripts/chroot.sh
+++ b/scripts/chroot.sh
@@ -32,6 +32,11 @@ check_defines () {
 		exit 1
 	fi
 
+	if [ ! "${export_filename}" ] ; then
+		echo "scripts/deboostrap_first_stage.sh: Error: export_filename undefined"
+		exit 1
+	fi
+
 	if [ ! "${distro}" ] ; then
 		echo "scripts/deboostrap_first_stage.sh: Error: distro undefined"
 		exit 1
@@ -459,40 +464,26 @@ if [ -f ${tempdir}/usr/bin/qemu-arm-static ] ; then
 	sudo rm -f ${tempdir}/usr/bin/qemu-arm-static || true
 fi
 
-#Actual Releases will use version numbers..
-case "${release}" in
-squeeze)
-	#http://www.debian.org/releases/squeeze/
-	final_dir="${DIR}/deploy/${distro}-6.0.6-console-${dpkg_arch}-${time}"
-	;;
-quantal)
-	final_dir="${DIR}/deploy/${distro}-12.10-console-${dpkg_arch}-${time}"
-	;;
-*)
-	final_dir="${DIR}/deploy/${distro}-${release}-console-${dpkg_arch}-${time}"
-	;;
-esac
-
-mkdir -p ${final_dir} || true
+mkdir -p ${DIR}/deploy/${export_filename}/ || true
 
 if ls ${tempdir}/boot/vmlinuz-* >/dev/null 2>&1 ; then
-	sudo mv -v ${tempdir}/boot/vmlinuz-* ${final_dir}/
+	sudo mv -v ${tempdir}/boot/vmlinuz-* ${DIR}/deploy/${export_filename}/
 fi
 
 if ls ${tempdir}/boot/initrd.img-* >/dev/null 2>&1 ; then
-	sudo mv -v ${tempdir}/boot/initrd.img-* ${final_dir}/
+	sudo mv -v ${tempdir}/boot/initrd.img-* ${DIR}/deploy/${export_filename}/
 fi
 
 if ls ${tempdir}/boot/*dtbs.tar.gz >/dev/null 2>&1 ; then
-	sudo mv -v ${tempdir}/boot/*dtbs.tar.gz ${final_dir}/
+	sudo mv -v ${tempdir}/boot/*dtbs.tar.gz ${DIR}/deploy/${export_filename}/
 fi
 
-echo "${user_name}:${password}" | sudo tee ${final_dir}/user_password.list
+echo "${user_name}:${password}" | sudo tee ${DIR}/deploy/${export_filename}/user_password.list
 
 report_size
 chroot_umount
 
-sudo cp -v ${DIR}/tools/setup_sdcard.sh ${final_dir}/
+sudo cp -v ${DIR}/tools/setup_sdcard.sh ${DIR}/deploy/${export_filename}/
 
 if [ "x${chroot_ENABLE_DEB_SRC}" == "xenable" ] ; then
 	cd ${tempdir}/tmp/pkg_src/
@@ -504,9 +495,9 @@ if [ "x${chroot_ENABLE_DEB_SRC}" == "xenable" ] ; then
 fi
 
 cd ${tempdir}
-sudo LANG=C tar --numeric-owner -cf ${final_dir}/${dpkg_arch}-rootfs-${distro}-${release}.tar .
+sudo LANG=C tar --numeric-owner -cf ${DIR}/deploy/${export_filename}/${dpkg_arch}-rootfs-${distro}-${release}.tar .
 cd ${DIR}/
-ls -lh ${final_dir}/${dpkg_arch}-rootfs-${distro}-${release}.tar
+ls -lh ${DIR}/deploy/${export_filename}/${dpkg_arch}-rootfs-${distro}-${release}.tar
 
-sudo chown -R ${USER}:${USER} ${final_dir}/
+sudo chown -R ${USER}:${USER} ${DIR}/deploy/${export_filename}/
 #
-- 
GitLab