From cc07f9eadceee0ead97ec9e95825a73f0ebbf00e Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Mon, 11 Feb 2013 22:11:02 -0600
Subject: [PATCH] RootStock-NG: migrate all scripts from the old rootstock
 script

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 RootStock-NG.sh     | 59 +++++++++++++++++++++++++++-------------
 base_image.sh       | 60 ++++++++++++++++++++++++++++++++++++++---
 build_image.sh      | 65 ++++++++++++++++++++++++++++++++++++++++++++-
 host/rcn-ee-host.sh | 15 +++++++++++
 imx_build_image.sh  | 52 +++++++++++++++++++++++++++++++++++-
 lxde_image.sh       | 58 +++++++++++++++++++++++++++++++++++++++-
 nightly_build.sh    | 65 ++++++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 348 insertions(+), 26 deletions(-)

diff --git a/RootStock-NG.sh b/RootStock-NG.sh
index 3cd6b5645..8543eb357 100755
--- a/RootStock-NG.sh
+++ b/RootStock-NG.sh
@@ -26,6 +26,10 @@ TIME=$(date +%Y-%m-%d)
 
 DIR="$PWD"
 
+if [ -f ${DIR}/.project ] ; then
+	source ${DIR}/.project
+fi
+
 #Base
 base_pkg_list="git-core nano pastebinit wget"
 
@@ -106,6 +110,23 @@ run_project () {
 	sudo rm -rf ${tempdir}/ || true
 }
 
+run_roostock_ng () {
+	if [ ! -f ${DIR}/.project ] ; then
+		echo "error: [.project] file not defined"
+		exit 1
+	fi
+
+	if [ ! "${tempdir}" ] ; then
+		tempdir=$(mktemp -d)
+		echo "tempdir=\"${tempdir}\"" >> ${DIR}/.project
+	fi
+
+	/bin/bash -e "${DIR}/scripts/install_dependencies.sh" || { exit 1 ; }
+	/bin/bash -e "${DIR}/scripts/debootstrap.sh" || { exit 1 ; }
+	/bin/bash -e "${DIR}/scripts/chroot.sh" || { exit 1 ; }
+	sudo rm -rf ${tempdir}/ || true
+}
+
 mirror="http://rcn-ee.net/deb"
 #FIXME: just temp...
 case "${system}" in
@@ -135,31 +156,33 @@ if [ -f ${DIR}/release ] ; then
 	chroot_ENABLE_DEB_SRC="enable"
 fi
 
-full_name="Demo User"
-password="temppwd"
+run_roostock_ng
+
+#full_name="Demo User"
+#password="temppwd"
 
-distro="debian"
-user_name="${distro}"
+#distro="debian"
+#user_name="${distro}"
 
-dpkg_arch="armel"
+#dpkg_arch="armel"
 
-release="squeeze"
-run_project
+#release="squeeze"
+#run_project
 
-release="wheezy"
-run_project
+#release="wheezy"
+#run_project
 
-dpkg_arch="armhf"
-run_project
+#dpkg_arch="armhf"
+#run_project
 
-distro="ubuntu"
-user_name="${distro}"
+#distro="ubuntu"
+#user_name="${distro}"
 
-dpkg_arch="armhf"
-release="quantal"
-run_project
+#dpkg_arch="armhf"
+#release="quantal"
+#run_project
 
-release="raring"
-run_project
+#release="raring"
+#run_project
 
 #
diff --git a/base_image.sh b/base_image.sh
index 66798ef8b..279333057 100755
--- a/base_image.sh
+++ b/base_image.sh
@@ -25,6 +25,7 @@ HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
 
 unset USE_OEM
+unset ROOTSTOCKNG
 
 MINIMAL="-minimal"
 
@@ -75,6 +76,41 @@ function dl_rootstock {
 }
 
 function minimal_armel {
+	if [ "${ROOTSTOCKNG}" ] ; then
+		rm -f "${DIR}/.project" || true
+
+		pkgs="${MINIMAL_APT}${EXTRA}"
+
+		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
+
+		tempdir=$(mktemp -d)
+
+		cat > ${DIR}/.project <<-__EOF__
+			tempdir="${tempdir}"
+			distro="${distro}"
+
+			release="${DIST}"
+			dpkg_arch="${ARCH}"
+
+			apt_proxy="${apt_proxy}"
+			base_pkg_list="${base_pkg_list}"
+
+			image_hostname="${FQDN}"
+
+			user_name="${USER_LOGIN}"
+			full_name="${USER_NAME}"
+			password="${USER_PASS}"
+
+			chroot_ENABLE_DEB_SRC="${chroot_ENABLE_DEB_SRC}"
+
+			chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR}"
+
+		__EOF__
+
+		cat ${DIR}/.project
+
+		/bin/bash -e "${DIR}/RootStock-NG.sh" || { exit 1 ; }
+	else
 rm -f ${DIR}/deploy/arm*-rootfs-*.tar || true
 rm -f ${DIR}/deploy/vmlinuz-* || true
 rm -f ${DIR}/deploy/initrd.img-* || true
@@ -96,9 +132,11 @@ sudo ${DIR}/git/project-rootstock/rootstock  --imagesize ${IMAGESIZE} --fqdn ${F
 --seed ${MINIMAL_APT}${EXTRA} ${MIRROR} --components "${COMPONENTS}" \
 --dist ${DIST} --script ${DIR}/tools/${FIXUPSCRIPT} \
 --apt-upgrade --arch=${ARCH}
+fi
 }
 
 function compression {
+if [ ! "${ROOTSTOCKNG}" ] ; then
 	rm -rf ${DIR}/deploy/${TIME}/$BUILD || true
 	mkdir -p ${DIR}/deploy/${TIME}/$BUILD
 
@@ -128,10 +166,14 @@ function compression {
 	fi
 
 	cd ${DIR}/deploy/
+else
+	echo "later"
+fi
 }
 
 #12.10
 function quantal_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="quantal"
 
@@ -146,6 +188,7 @@ function quantal_release {
 
 #13.04
 function raring_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="raring"
 
@@ -159,13 +202,14 @@ function raring_release {
 }
 
 function squeeze_release {
+	distro="debian"
 	reset_vars
 	DIST=squeeze
 
 	EXTRA=",isc-dhcp-client,uboot-mkimage,${DEBIAN_ONLY}"
 	USER_LOGIN="debian"
 	FIXUPSCRIPT="fixup-debian-base.sh"
-	MIRROR=$MIRROR_DEB
+	MIRROR="${MIRROR_DEB}"
 	COMPONENTS="${DEB_COMPONENTS}"
 	BUILD="${SQUEEZE_CURRENT}${MINIMAL}-${ARCH}-${TIME}"
 	minimal_armel
@@ -173,13 +217,14 @@ function squeeze_release {
 }
 
 function wheezy_release {
+	distro="debian"
 	reset_vars
 	DIST=wheezy
 
 	EXTRA=",u-boot-tools,${DEBIAN_ONLY}"
 	USER_LOGIN="debian"
 	FIXUPSCRIPT="fixup-debian-base.sh"
-	MIRROR=$MIRROR_DEB
+	MIRROR="${MIRROR_DEB}"
 	COMPONENTS="${DEB_COMPONENTS}"
 	BUILD="${WHEEZY_CURRENT}${MINIMAL}-${ARCH}-${TIME}"
 	minimal_armel
@@ -187,13 +232,14 @@ function wheezy_release {
 }
 
 function sid_release {
+	distro="debian"
 	reset_vars
 	DIST=sid
 
 	EXTRA=",u-boot-tools,${DEBIAN_ONLY}"
 	USER_LOGIN="debian"
 	FIXUPSCRIPT="fixup-debian-base.sh"
-	MIRROR=$MIRROR_DEB
+	MIRROR="${MIRROR_DEB}"
 	COMPONENTS="${DEB_COMPONENTS}"
 	BUILD="${DIST}${MINIMAL}-${ARCH}-${TIME}"
 	minimal_armel
@@ -218,9 +264,15 @@ if [ -f ${DIR}/release ] ; then
 		MIRROR_UBU="--mirror http://ports.ubuntu.com/ubuntu-ports/"
 		MIRROR_DEB="--mirror http://ftp.us.debian.org/debian/"
 	fi
+
+	chroot_ENABLE_DEB_SRC="enable"
 fi
 
-dl_rootstock
+ROOTSTOCKNG=1
+
+if [ ! "${ROOTSTOCKNG}" ] ; then
+	dl_rootstock
+fi
 
 ARCH=armel
 if [ "-${HOST_ARCH}-" == "-armv7l-" ] ; then
diff --git a/build_image.sh b/build_image.sh
index 25292b09c..9c7912b28 100755
--- a/build_image.sh
+++ b/build_image.sh
@@ -25,6 +25,7 @@ HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
 
 unset USE_OEM
+unset ROOTSTOCKNG
 
 MINIMAL="-minimal"
 
@@ -81,6 +82,41 @@ function dl_rootstock {
 }
 
 function minimal_armel {
+	if [ "${ROOTSTOCKNG}" ] ; then
+		rm -f "${DIR}/.project" || true
+
+		pkgs="${MINIMAL_APT}${EXTRA}"
+
+		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
+
+		tempdir=$(mktemp -d)
+
+		cat > ${DIR}/.project <<-__EOF__
+			tempdir="${tempdir}"
+			distro="${distro}"
+
+			release="${DIST}"
+			dpkg_arch="${ARCH}"
+
+			apt_proxy="${apt_proxy}"
+			base_pkg_list="${base_pkg_list}"
+
+			image_hostname="${FQDN}"
+
+			user_name="${USER_LOGIN}"
+			full_name="${USER_NAME}"
+			password="${USER_PASS}"
+
+			chroot_ENABLE_DEB_SRC="${chroot_ENABLE_DEB_SRC}"
+
+			chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR}"
+
+		__EOF__
+
+		cat ${DIR}/.project
+
+		/bin/bash -e "${DIR}/RootStock-NG.sh" || { exit 1 ; }
+	else
 rm -f ${DIR}/deploy/arm*-rootfs-*.tar || true
 rm -f ${DIR}/deploy/vmlinuz-* || true
 rm -f ${DIR}/deploy/initrd.img-* || true
@@ -102,9 +138,11 @@ sudo ${DIR}/git/project-rootstock/rootstock  --imagesize ${IMAGESIZE} --fqdn ${F
 --seed ${MINIMAL_APT}${EXTRA} ${MIRROR} --components "${COMPONENTS}" \
 --dist ${DIST} --serial ${SERIAL} --script ${DIR}/tools/${FIXUPSCRIPT} \
 ${PRIMARY_KERNEL} ${SECONDARY_KERNEL} --apt-upgrade --arch=${ARCH}
+fi
 }
 
 function compression {
+if [ ! "${ROOTSTOCKNG}" ] ; then
 	rm -rf ${DIR}/deploy/${TIME}/$BUILD || true
 	mkdir -p ${DIR}/deploy/${TIME}/$BUILD
 
@@ -152,6 +190,9 @@ function compression {
 	fi
 
 	cd ${DIR}/deploy/
+else
+	echo "later"
+fi
 }
 
 function kernel_chooser {
@@ -200,6 +241,8 @@ function select_rcn-ee-net_kernel {
 	PRIMARY_KERNEL="--kernel-image ${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DEB_FILE}"
 	echo "Using: ${PRIMARY_KERNEL}"
 
+	chroot_KERNEL_HTTP_DIR="${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+
 	unset PRIMARY_DTB_FILE
 	if [ "x${ACTUAL_DTB_FILE}" != "x" ] ; then
 		PRIMARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
@@ -223,10 +266,20 @@ function select_rcn-ee-net_kernel {
 		SECONDARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
 		echo "Using dtbs: ${SECONDARY_DTB_FILE}"
 	fi
+
+	chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR} ${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+
+	if [ "${ROOTSTOCKNG}" ] ; then
+		SUBARCH="omap-psp"
+		KERNEL_ABI="STABLE"
+		kernel_chooser
+		chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR} ${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+	fi
 }
 
 #12.10
 function quantal_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="quantal"
 	select_rcn-ee-net_kernel
@@ -241,6 +294,7 @@ function quantal_release {
 
 #13.04
 function raring_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="raring"
 	select_rcn-ee-net_kernel
@@ -254,6 +308,7 @@ function raring_release {
 }
 
 function squeeze_release {
+	distro="debian"
 	reset_vars
 	DIST=squeeze
 	select_rcn-ee-net_kernel
@@ -268,6 +323,7 @@ function squeeze_release {
 }
 
 function wheezy_release {
+	distro="debian"
 	reset_vars
 	DIST=wheezy
 	select_rcn-ee-net_kernel
@@ -282,6 +338,7 @@ function wheezy_release {
 }
 
 function sid_release {
+	distro="debian"
 	reset_vars
 	DIST=sid
 	select_rcn-ee-net_kernel
@@ -314,9 +371,15 @@ if [ -f ${DIR}/release ] ; then
 		MIRROR_UBU="--mirror http://ports.ubuntu.com/ubuntu-ports/"
 		MIRROR_DEB="--mirror http://ftp.us.debian.org/debian/"
 	fi
+
+	chroot_ENABLE_DEB_SRC="enable"
 fi
 
-dl_rootstock
+ROOTSTOCKNG=1
+
+if [ ! "${ROOTSTOCKNG}" ] ; then
+	dl_rootstock
+fi
 
 ARCH=armhf
 quantal_release
diff --git a/host/rcn-ee-host.sh b/host/rcn-ee-host.sh
index 9810f7dd8..7c3ff257d 100644
--- a/host/rcn-ee-host.sh
+++ b/host/rcn-ee-host.sh
@@ -13,4 +13,19 @@ if [ "x${SYST}" == "xposeidon" ] || [ "x${SYST}" == "x${RELEASE_HOST}" ] ; then
 	DEB_MIRROR="http://192.168.1.95:81/dl/mirrors/deb"
 fi
 
+system=$(uname -n)
+mirror="http://rcn-ee.net/deb"
+#FIXME: just temp...
+case "${system}" in
+hades|work-e6400)
+	apt_proxy="192.168.0.10:3142/"
+	;;
+a53t|zeus|hestia|poseidon|panda-es-1gb-a3)
+	apt_proxy="rcn-ee.homeip.net:3142/"
+	mirror="http://rcn-ee.homeip.net:81/dl/mirrors/deb"
+	;;
+*)
+	apt_proxy=""
+	;;
+esac
 
diff --git a/imx_build_image.sh b/imx_build_image.sh
index 81b01ad42..559ab486e 100755
--- a/imx_build_image.sh
+++ b/imx_build_image.sh
@@ -25,6 +25,7 @@ HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
 
 unset USE_OEM
+unset ROOTSTOCKNG
 
 MINIMAL="-minimal"
 
@@ -81,6 +82,41 @@ function dl_rootstock {
 }
 
 function minimal_armel {
+	if [ "${ROOTSTOCKNG}" ] ; then
+		rm -f "${DIR}/.project" || true
+
+		pkgs="${MINIMAL_APT}${EXTRA}"
+
+		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
+
+		tempdir=$(mktemp -d)
+
+		cat > ${DIR}/.project <<-__EOF__
+			tempdir="${tempdir}"
+			distro="${distro}"
+
+			release="${DIST}"
+			dpkg_arch="${ARCH}"
+
+			apt_proxy="${apt_proxy}"
+			base_pkg_list="${base_pkg_list}"
+
+			image_hostname="${FQDN}"
+
+			user_name="${USER_LOGIN}"
+			full_name="${USER_NAME}"
+			password="${USER_PASS}"
+
+			chroot_ENABLE_DEB_SRC="${chroot_ENABLE_DEB_SRC}"
+
+			chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR}"
+
+		__EOF__
+
+		cat ${DIR}/.project
+
+		/bin/bash -e "${DIR}/RootStock-NG.sh" || { exit 1 ; }
+	else
 rm -f ${DIR}/deploy/arm*-rootfs-*.tar || true
 rm -f ${DIR}/deploy/vmlinuz-* || true
 rm -f ${DIR}/deploy/initrd.img-* || true
@@ -102,9 +138,11 @@ sudo ${DIR}/git/project-rootstock/rootstock  --imagesize ${IMAGESIZE} --fqdn ${F
 --seed ${MINIMAL_APT}${EXTRA} ${MIRROR} --components "${COMPONENTS}" \
 --dist ${DIST} --serial ${SERIAL} --script ${DIR}/tools/${FIXUPSCRIPT} \
 ${PRIMARY_KERNEL} ${SECONDARY_KERNEL} --apt-upgrade --arch=${ARCH}
+fi
 }
 
 function compression {
+if [ ! "${ROOTSTOCKNG}" ] ; then
 	rm -rf ${DIR}/deploy/${TIME}/$BUILD || true
 	mkdir -p ${DIR}/deploy/${TIME}/$BUILD
 
@@ -152,6 +190,9 @@ function compression {
 	fi
 
 	cd ${DIR}/deploy/
+else
+	echo "later"
+fi
 }
 
 function kernel_chooser {
@@ -200,6 +241,8 @@ function select_rcn-ee-net_kernel {
 	PRIMARY_KERNEL="--kernel-image ${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DEB_FILE}"
 	echo "Using: ${PRIMARY_KERNEL}"
 
+	chroot_KERNEL_HTTP_DIR="${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+
 	unset PRIMARY_DTB_FILE
 	if [ "x${ACTUAL_DTB_FILE}" != "x" ] ; then
 		PRIMARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
@@ -210,6 +253,7 @@ function select_rcn-ee-net_kernel {
 }
 
 function wheezy_release {
+	distro="debian"
 	reset_vars
 	DIST=wheezy
 	select_rcn-ee-net_kernel
@@ -242,9 +286,15 @@ if [ -f ${DIR}/release ] ; then
 		MIRROR_UBU="--mirror http://ports.ubuntu.com/ubuntu-ports/"
 		MIRROR_DEB="--mirror http://ftp.us.debian.org/debian/"
 	fi
+
+	chroot_ENABLE_DEB_SRC="enable"
 fi
 
-dl_rootstock
+ROOTSTOCKNG=1
+
+if [ ! "${ROOTSTOCKNG}" ] ; then
+	dl_rootstock
+fi
 
 ARCH=armhf
 wheezy_release
diff --git a/lxde_image.sh b/lxde_image.sh
index d824ef742..e60fe5294 100755
--- a/lxde_image.sh
+++ b/lxde_image.sh
@@ -25,6 +25,7 @@ HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
 
 unset USE_OEM
+unset ROOTSTOCKNG
 
 MINIMAL="-lxde"
 
@@ -81,6 +82,41 @@ function dl_rootstock {
 }
 
 function minimal_armel {
+	if [ "${ROOTSTOCKNG}" ] ; then
+		rm -f "${DIR}/.project" || true
+
+		pkgs="${MINIMAL_APT}${EXTRA}"
+
+		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
+
+		tempdir=$(mktemp -d)
+
+		cat > ${DIR}/.project <<-__EOF__
+			tempdir="${tempdir}"
+			distro="${distro}"
+
+			release="${DIST}"
+			dpkg_arch="${ARCH}"
+
+			apt_proxy="${apt_proxy}"
+			base_pkg_list="${base_pkg_list}"
+
+			image_hostname="${FQDN}"
+
+			user_name="${USER_LOGIN}"
+			full_name="${USER_NAME}"
+			password="${USER_PASS}"
+
+			chroot_ENABLE_DEB_SRC="${chroot_ENABLE_DEB_SRC}"
+
+			chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR}"
+
+		__EOF__
+
+		cat ${DIR}/.project
+
+		/bin/bash -e "${DIR}/RootStock-NG.sh" || { exit 1 ; }
+	else
 rm -f ${DIR}/deploy/arm*-rootfs-*.tar || true
 rm -f ${DIR}/deploy/vmlinuz-* || true
 rm -f ${DIR}/deploy/initrd.img-* || true
@@ -102,9 +138,11 @@ sudo ${DIR}/git/project-rootstock/rootstock  --imagesize ${IMAGESIZE} --fqdn ${F
 --seed ${MINIMAL_APT}${EXTRA} ${MIRROR} --components "${COMPONENTS}" \
 --dist ${DIST} --serial ${SERIAL} --script ${DIR}/tools/${FIXUPSCRIPT} \
 ${PRIMARY_KERNEL} ${SECONDARY_KERNEL} --apt-upgrade --arch=${ARCH}
+fi
 }
 
 function compression {
+if [ ! "${ROOTSTOCKNG}" ] ; then
 	rm -rf ${DIR}/deploy/${TIME}/$BUILD || true
 	mkdir -p ${DIR}/deploy/${TIME}/$BUILD
 
@@ -152,6 +190,9 @@ function compression {
 	fi
 
 	cd ${DIR}/deploy/
+else
+	echo "later"
+fi
 }
 
 function kernel_chooser {
@@ -200,6 +241,8 @@ function select_rcn-ee-net_kernel {
 	PRIMARY_KERNEL="--kernel-image ${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DEB_FILE}"
 	echo "Using: ${PRIMARY_KERNEL}"
 
+	chroot_KERNEL_HTTP_DIR="${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+
 	unset PRIMARY_DTB_FILE
 	if [ "x${ACTUAL_DTB_FILE}" != "x" ] ; then
 		PRIMARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
@@ -223,10 +266,13 @@ function select_rcn-ee-net_kernel {
 		SECONDARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
 		echo "Using dtbs: ${SECONDARY_DTB_FILE}"
 	fi
+
+	chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR} ${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
 }
 
 #12.10
 function quantal_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="quantal"
 	select_rcn-ee-net_kernel
@@ -241,6 +287,7 @@ function quantal_release {
 
 #13.04
 function raring_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="raring"
 	select_rcn-ee-net_kernel
@@ -254,6 +301,7 @@ function raring_release {
 }
 
 function squeeze_release {
+	distro="debian"
 	reset_vars
 	DIST=squeeze
 	select_rcn-ee-net_kernel
@@ -268,6 +316,7 @@ function squeeze_release {
 }
 
 function wheezy_release {
+	distro="debian"
 	reset_vars
 	DIST=wheezy
 	select_rcn-ee-net_kernel
@@ -282,6 +331,7 @@ function wheezy_release {
 }
 
 function sid_release {
+	distro="debian"
 	reset_vars
 	DIST=sid
 	select_rcn-ee-net_kernel
@@ -314,9 +364,15 @@ if [ -f ${DIR}/release ] ; then
 		MIRROR_UBU="--mirror http://ports.ubuntu.com/ubuntu-ports/"
 		MIRROR_DEB="--mirror http://ftp.us.debian.org/debian/"
 	fi
+
+	chroot_ENABLE_DEB_SRC="enable"
 fi
 
-dl_rootstock
+ROOTSTOCKNG=1
+
+if [ ! "${ROOTSTOCKNG}" ] ; then
+	dl_rootstock
+fi
 
 ARCH=armhf
 quantal_release
diff --git a/nightly_build.sh b/nightly_build.sh
index 5cd5c2a3f..225f4c475 100755
--- a/nightly_build.sh
+++ b/nightly_build.sh
@@ -25,6 +25,7 @@ HOST_ARCH=$(uname -m)
 TIME=$(date +%Y-%m-%d)
 
 unset USE_OEM
+unset ROOTSTOCKNG
 
 MINIMAL="-minimal"
 
@@ -81,6 +82,41 @@ function dl_rootstock {
 }
 
 function minimal_armel {
+	if [ "${ROOTSTOCKNG}" ] ; then
+		rm -f "${DIR}/.project" || true
+
+		pkgs="${MINIMAL_APT}${EXTRA}"
+
+		base_pkg_list=$(echo ${pkgs} | sed -e 's/,/ /g')
+
+		tempdir=$(mktemp -d)
+
+		cat > ${DIR}/.project <<-__EOF__
+			tempdir="${tempdir}"
+			distro="${distro}"
+
+			release="${DIST}"
+			dpkg_arch="${ARCH}"
+
+			apt_proxy="${apt_proxy}"
+			base_pkg_list="${base_pkg_list}"
+
+			image_hostname="${FQDN}"
+
+			user_name="${USER_LOGIN}"
+			full_name="${USER_NAME}"
+			password="${USER_PASS}"
+
+			chroot_ENABLE_DEB_SRC="${chroot_ENABLE_DEB_SRC}"
+
+			chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR}"
+
+		__EOF__
+
+		cat ${DIR}/.project
+
+		/bin/bash -e "${DIR}/RootStock-NG.sh" || { exit 1 ; }
+	else
 rm -f ${DIR}/deploy/arm*-rootfs-*.tar || true
 rm -f ${DIR}/deploy/vmlinuz-* || true
 rm -f ${DIR}/deploy/initrd.img-* || true
@@ -102,9 +138,11 @@ sudo ${DIR}/git/project-rootstock/rootstock  --imagesize ${IMAGESIZE} --fqdn ${F
 --seed ${MINIMAL_APT}${EXTRA} ${MIRROR} --components "${COMPONENTS}" \
 --dist ${DIST} --serial ${SERIAL} \
 ${PRIMARY_KERNEL} ${SECONDARY_KERNEL} --apt-upgrade --arch=${ARCH}
+fi
 }
 
 function compression {
+if [ ! "${ROOTSTOCKNG}" ] ; then
 	rm -rf ${DIR}/deploy/${TIME}/$BUILD || true
 	mkdir -p ${DIR}/deploy/${TIME}/$BUILD
 
@@ -152,6 +190,9 @@ function compression {
 	fi
 
 	cd ${DIR}/deploy/
+else
+	echo "later"
+fi
 }
 
 function kernel_chooser {
@@ -200,6 +241,8 @@ function select_rcn-ee-net_kernel {
 	PRIMARY_KERNEL="--kernel-image ${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DEB_FILE}"
 	echo "Using: ${PRIMARY_KERNEL}"
 
+	chroot_KERNEL_HTTP_DIR="${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+
 	unset PRIMARY_DTB_FILE
 	if [ "x${ACTUAL_DTB_FILE}" != "x" ] ; then
 		PRIMARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
@@ -223,10 +266,20 @@ function select_rcn-ee-net_kernel {
 		SECONDARY_DTB_FILE="${DEB_MIRROR}/${DIST}-${ARCH}/${FTP_DIR}/${ACTUAL_DTB_FILE}"
 		echo "Using dtbs: ${SECONDARY_DTB_FILE}"
 	fi
+
+	chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR} ${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+
+	if [ "${ROOTSTOCKNG}" ] ; then
+		SUBARCH="omap-psp"
+		KERNEL_ABI="STABLE"
+		kernel_chooser
+		chroot_KERNEL_HTTP_DIR="${chroot_KERNEL_HTTP_DIR} ${mirror}/${DIST}-${ARCH}/${FTP_DIR}/"
+	fi
 }
 
 #12.10
 function quantal_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="quantal"
 	select_rcn-ee-net_kernel
@@ -241,6 +294,7 @@ function quantal_release {
 
 #13.04
 function raring_release {
+	distro="ubuntu"
 	reset_vars
 	DIST="raring"
 	select_rcn-ee-net_kernel
@@ -254,6 +308,7 @@ function raring_release {
 }
 
 function squeeze_release {
+	distro="debian"
 	reset_vars
 	DIST=squeeze
 	select_rcn-ee-net_kernel
@@ -268,6 +323,7 @@ function squeeze_release {
 }
 
 function wheezy_release {
+	distro="debian"
 	reset_vars
 	DIST=wheezy
 	select_rcn-ee-net_kernel
@@ -282,6 +338,7 @@ function wheezy_release {
 }
 
 function sid_release {
+	distro="debian"
 	reset_vars
 	DIST=sid
 	select_rcn-ee-net_kernel
@@ -314,9 +371,15 @@ if [ -f ${DIR}/release ] ; then
 		MIRROR_UBU="--mirror http://ports.ubuntu.com/ubuntu-ports/"
 		MIRROR_DEB="--mirror http://ftp.us.debian.org/debian/"
 	fi
+
+	chroot_ENABLE_DEB_SRC="enable"
 fi
 
-dl_rootstock
+ROOTSTOCKNG=1
+
+if [ ! "${ROOTSTOCKNG}" ] ; then
+	dl_rootstock
+fi
 
 ARCH=armel
 wheezy_release
-- 
GitLab