From 4e9ff25f47883e9d807a39cbc898b49ea5d5faff Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Thu, 19 Feb 2015 14:07:26 -0600
Subject: [PATCH] publish: more automation

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 publish/rcn-ee_bb.org-stable.sh | 124 ++++++++------------------
 publish/rcn-ee_elinux.sh        | 151 ++++++++++++++++++++++----------
 2 files changed, 144 insertions(+), 131 deletions(-)

diff --git a/publish/rcn-ee_bb.org-stable.sh b/publish/rcn-ee_bb.org-stable.sh
index 6af2c02d7..d56d43d4e 100755
--- a/publish/rcn-ee_bb.org-stable.sh
+++ b/publish/rcn-ee_bb.org-stable.sh
@@ -108,118 +108,68 @@ generate_img () {
 }
 
 ###Production lxde images: (BBB: 4GB eMMC)
-base_rootfs="${debian_lxde_4gb_stable}"
-blend="lxde-4gb"
-extract_base_rootfs
+base_rootfs="${debian_lxde_4gb_stable}" ; blend="lxde-4gb" ; extract_base_rootfs
 
-options="--img-4gb BBB-blank-eMMC-flasher-\${base_rootfs} ${bb_blank_flasher} --enable-systemd --bbb-flasher"
-generate_img
-options="--img-4gb BBB-eMMC-flasher-\${base_rootfs} --enable-systemd --bbb-flasher"
-generate_img
-options="--img-4gb bone-\${base_rootfs} ${beaglebone} --enable-systemd"
-generate_img
+options="--img-4gb BBB-blank-eMMC-flasher-\${base_rootfs} ${bb_blank_flasher} --enable-systemd --bbb-flasher" ; generate_img
+options="--img-4gb BBB-eMMC-flasher-\${base_rootfs} --enable-systemd --bbb-flasher" ; generate_img
+options="--img-4gb bone-\${base_rootfs} ${beaglebone} --enable-systemd" ; generate_img
 
 ###lxde images: (BBB: 2GB eMMC)
-base_rootfs="${debian_lxde_stable}"
-blend="lxde"
-extract_base_rootfs
+base_rootfs="${debian_lxde_stable}" ; blend="lxde" ; extract_base_rootfs
 
-options="--img-2gb BBB-eMMC-flasher-\${base_rootfs} ${beaglebone} --enable-systemd --bbb-flasher"
-generate_img
+options="--img-2gb BBB-eMMC-flasher-\${base_rootfs} ${beaglebone} --enable-systemd --bbb-flasher" ; generate_img
 
 ###console images: (also single partition)
-base_rootfs="${debian_console_stable}"
-blend="console"
-extract_base_rootfs
+base_rootfs="${debian_console_stable}" ; blend="console" ; extract_base_rootfs
 
-options="--img-2gb BBG-blank-eMMC-flasher-\${base_rootfs} ${bb_blank_flasher_console} --enable-systemd --bbg-flasher"
-options="--img-2gb BBB-blank-eMMC-flasher-\${base_rootfs} ${bb_blank_flasher_console} --enable-systemd --bbb-flasher"
-options="--img-2gb BBB-eMMC-flasher-\${base_rootfs} ${beaglebone_console} --enable-systemd --bbb-flasher"
-generate_img
-options="--img-2gb bone-\${base_rootfs} ${beaglebone_console} --enable-systemd"
-generate_img
+options="--img-2gb BBG-blank-eMMC-flasher-\${base_rootfs} ${bb_blank_flasher_console} --enable-systemd --bbg-flasher" ; generate_img
+options="--img-2gb BBB-blank-eMMC-flasher-\${base_rootfs} ${bb_blank_flasher_console} --enable-systemd --bbb-flasher" ; generate_img
+options="--img-2gb BBB-eMMC-flasher-\${base_rootfs} ${beaglebone_console} --enable-systemd --bbb-flasher" ; generate_img
+options="--img-2gb bone-\${base_rootfs} ${beaglebone_console} --enable-systemd" ; generate_img
 
 ###machinekit:
-base_rootfs="${debian_machinekit_wheezy}"
-blend="machinekit"
-extract_base_rootfs
-options="--img-4gb bone-\${base_rootfs} ${beaglebone} --enable-systemd"
-generate_img
+base_rootfs="${debian_machinekit_wheezy}" ; blend="machinekit" ; extract_base_rootfs
+
+options="--img-4gb bone-\${base_rootfs} ${beaglebone} --enable-systemd" ; generate_img
 
 ###lxqt image
-base_rootfs="${debian_lxqt_4gb_next}"
-blend="lxqt-4gb"
-extract_base_rootfs
+base_rootfs="${debian_lxqt_4gb_next}" ; blend="lxqt-4gb" ; extract_base_rootfs
 
-options="--img-4gb BBB-eMMC-flasher-\${base_rootfs} ${beaglebone} --bbb-flasher"
-generate_img
-options="--img-4gb bone-\${base_rootfs} ${beaglebone}"
-generate_img
-options="--img-4gb bbx15-\${base_rootfs} ${am57xx-beagle-x15}"
-generate_img
-options="--img-4gb omap5-uevm-\${base_rootfs} ${omap5-uevm}"
-generate_img
+options="--img-4gb BBB-eMMC-flasher-\${base_rootfs} ${beaglebone} --bbb-flasher" ; generate_img
+options="--img-4gb bone-\${base_rootfs} ${beaglebone}" ; generate_img
+options="--img-4gb bbx15-\${base_rootfs} ${am57xx-beagle-x15}" ; generate_img
+options="--img-4gb omap5-uevm-\${base_rootfs} ${omap5-uevm}" ; generate_img
 
 ###archive *.tar
-base_rootfs="${debian_lxde_4gb_stable}"
-blend="lxde-4gb"
-archive_base_rootfs
-
-base_rootfs="${debian_lxde_stable}"
-blend="lxde"
-archive_base_rootfs
-
-base_rootfs="${debian_console_stable}"
-blend="console"
-archive_base_rootfs
-
-base_rootfs="${debian_machinekit_wheezy}"
-blend="machinekit"
-archive_base_rootfs
-
-base_rootfs="${debian_lxqt_4gb_next}"
-blend="lxqt-4gb"
-archive_base_rootfs
+base_rootfs="${debian_lxde_4gb_stable}" ; blend="lxde-4gb" ; archive_base_rootfs
+base_rootfs="${debian_lxde_stable}" ; blend="lxde" ; archive_base_rootfs
+base_rootfs="${debian_console_stable}" ; blend="console" ; archive_base_rootfs
+base_rootfs="${debian_machinekit_wheezy}" ; blend="machinekit" ; archive_base_rootfs
+base_rootfs="${debian_lxqt_4gb_next}" ; blend="lxqt-4gb" ; archive_base_rootfs
 
 ###archive *.img
 blend="lxde-4gb"
-wfile="BBB-blank-eMMC-flasher-${debian_lxde_4gb_stable}-4gb.img"
-archive_img
-wfile="BBB-eMMC-flasher-${debian_lxde_4gb_stable}-4gb.img"
-archive_img
-wfile="bone-${debian_lxde_4gb_stable}-4gb.img"
-archive_img
+wfile="BBB-blank-eMMC-flasher-${debian_lxde_4gb_stable}-4gb.img" ; archive_img
+wfile="BBB-eMMC-flasher-${debian_lxde_4gb_stable}-4gb.img" ; archive_img
+wfile="bone-${debian_lxde_4gb_stable}-4gb.img" ; archive_img
 
 blend="lxde"
-wfile="BBB-eMMC-flasher-${debian_lxde_stable}-2gb.img"
-archive_img
+wfile="BBB-eMMC-flasher-${debian_lxde_stable}-2gb.img" ; archive_img
 
 blend="console"
-wfile="BBB-blank-eMMC-flasher-${debian_console_stable}-2gb.img"
-archive_img
-wfile="BBG-blank-eMMC-flasher-${debian_console_stable}-2gb.img"
-archive_img
-wfile="BBB-eMMC-flasher-${debian_console_stable}-2gb.img"
-archive_img
-wfile="bone-${debian_console_stable}-2gb.img"
-archive_img
+wfile="BBB-blank-eMMC-flasher-${debian_console_stable}-2gb.img" ;archive_img
+wfile="BBG-blank-eMMC-flasher-${debian_console_stable}-2gb.img" ;archive_img
+wfile="BBB-eMMC-flasher-${debian_console_stable}-2gb.img" ; archive_img
+wfile="bone-${debian_console_stable}-2gb.img" ; archive_img
 
 blend="machinekit"
-wfile="bone-${debian_machinekit_wheezy}-4gb.img"
-archive_img
+wfile="bone-${debian_machinekit_wheezy}-4gb.img" ; archive_img
 
 blend="lxqt-4gb"
-wfile="BBB-eMMC-flasher-${debian_lxqt_4gb_next}-4gb.img"
-archive_img
-
-wfile="bone-${debian_lxqt_4gb_next}-4gb.img"
-archive_img
-
-wfile="bbx15-${debian_lxqt_4gb_next}-4gb.img"
-archive_img
-
-wfile="omap5-uevm-${debian_lxqt_4gb_next}-4gb.img"
-archive_img
+wfile="BBB-eMMC-flasher-${debian_lxqt_4gb_next}-4gb.img" ; archive_img
+wfile="bone-${debian_lxqt_4gb_next}-4gb.img" ; archive_img
+wfile="bbx15-${debian_lxqt_4gb_next}-4gb.img" ; archive_img
+wfile="omap5-uevm-${debian_lxqt_4gb_next}-4gb.img" ; archive_img
 
 __EOF__
 
diff --git a/publish/rcn-ee_elinux.sh b/publish/rcn-ee_elinux.sh
index 35f48e16d..e1e60767b 100755
--- a/publish/rcn-ee_elinux.sh
+++ b/publish/rcn-ee_elinux.sh
@@ -1,6 +1,7 @@
 #!/bin/bash -e
 
 time=$(date +%Y-%m-%d)
+mirror_dir="/var/www/html/rcn-ee.net/rootfs/"
 DIR="$PWD"
 
 export apt_proxy=apt-proxy:3142/
@@ -11,60 +12,122 @@ fi
 
 ./RootStock-NG.sh -c rcn-ee_console_debian_stable_armhf
 ./RootStock-NG.sh -c rcn-ee_console_debian_testing_armhf
-
 ./RootStock-NG.sh -c rcn-ee_console_ubuntu_stable_armhf
 
 debian_stable="debian-7.8-console-armhf-${time}"
 debian_testing="debian-jessie-console-armhf-${time}"
-
 ubuntu_stable="ubuntu-14.04.1-console-armhf-${time}"
+
 archive="xz -z -8 -v"
 
 cat > ${DIR}/deploy/gift_wrap_final_images.sh <<-__EOF__
 #!/bin/bash
 
-${archive} ${ubuntu_stable}.tar
-${archive} ${debian_stable}.tar
-
-tar xf ${debian_stable}.tar.xz
-tar xf ${ubuntu_stable}.tar.xz
-
-cd ${debian_stable}/
-sudo ./setup_sdcard.sh --img BBB-eMMC-flasher-${debian_stable} --dtb beaglebone --bbb-flasher --enable-systemd  --bbb-old-bootloader-in-emmc
-sudo ./setup_sdcard.sh --img bone-${debian_stable} --dtb beaglebone --enable-systemd --bbb-old-bootloader-in-emmc
-sudo ./setup_sdcard.sh --img bb-${debian_stable} --dtb omap3-beagle --enable-systemd
-sudo ./setup_sdcard.sh --img bbxm-${debian_stable} --dtb omap3-beagle-xm --enable-systemd
-sudo ./setup_sdcard.sh --img omap5-uevm-${debian_stable} --dtb omap5-uevm --enable-systemd
-sudo ./setup_sdcard.sh --img bbx15-${debian_stable} --dtb am57xx-beagle-x15 --enable-systemd
-mv *.img ../
-cd ..
-rm -rf ${debian_stable}/ || true
-
-cd ${ubuntu_stable}/
-sudo ./setup_sdcard.sh --img BBB-eMMC-flasher-${ubuntu_stable}.img --dtb beaglebone --bbb-flasher  --bbb-old-bootloader-in-emmc
-sudo ./setup_sdcard.sh --img bone-${ubuntu_stable}.img --dtb beaglebone --bbb-old-bootloader-in-emmc
-sudo ./setup_sdcard.sh --img bb-${ubuntu_stable}.img --dtb omap3-beagle
-sudo ./setup_sdcard.sh --img bbxm-${ubuntu_stable}.img --dtb omap3-beagle-xm
-sudo ./setup_sdcard.sh --img omap5-uevm-${ubuntu_stable}.img --dtb omap5-uevm
-sudo ./setup_sdcard.sh --img bbx15-${ubuntu_stable} --dtb am57xx-beagle-x15
-mv *.img ../
-cd ..
-rm -rf ${ubuntu_stable}/ || true
-
-${archive} ${debian_testing}.tar
-
-${archive} BBB-eMMC-flasher-${debian_stable}-2gb.img
-${archive} bone-${debian_stable}-2gb.img
-${archive} bb-${debian_stable}-2gb.img
-${archive} bbxm-${debian_stable}-2gb.img
-${archive} omap5-uevm-${debian_stable}-2gb.img
-${archive} bbx15-${debian_stable}-2gb.img
-${archive} BBB-eMMC-flasher-${ubuntu_stable}-2gb.img
-${archive} bone-${ubuntu_stable}-2gb.img
-${archive} bb-${ubuntu_stable}-2gb.img
-${archive} bbxm-${ubuntu_stable}-2gb.img
-${archive} omap5-uevm-${ubuntu_stable}-2gb.img
-${archive} bbx15-${ubuntu_stable}-2gb.img
+copy_base_rootfs_to_mirror () {
+        if [ -d ${mirror_dir} ] ; then
+                if [ ! -d ${mirror_dir}/${time}/ ] ; then
+                        mkdir -p ${mirror_dir}/${time}/ || true
+                fi
+                if [ -d ${mirror_dir}/${time}/ ] ; then
+                        if [ -f \${base_rootfs}.tar.xz ] ; then
+                                cp -v \${base_rootfs}.tar.xz ${mirror_dir}/${time}/
+                        fi
+                fi
+        fi
+}
+
+archive_base_rootfs () {
+        if [ -d ./\${base_rootfs} ] ; then
+                rm -rf \${base_rootfs} || true
+        fi
+
+        if [ ! -f \${base_rootfs}.tar.xz ] ; then
+                ${archive} \${base_rootfs}.tar
+        fi
+        copy_base_rootfs_to_mirror
+}
+
+extract_base_rootfs () {
+        if [ -d ./\${base_rootfs} ] ; then
+                rm -rf \${base_rootfs} || true
+        fi
+
+        if [ -f \${base_rootfs}.tar.xz ] ; then
+                tar xf \${base_rootfs}.tar.xz
+        else
+                tar xf \${base_rootfs}.tar
+        fi
+}
+
+copy_img_to_mirror () {
+        if [ -d ${mirror_dir} ] ; then
+                if [ ! -d ${mirror_dir}/${time}/\${blend}/ ] ; then
+                        mkdir -p ${mirror_dir}/${time}/\${blend}/ || true
+                fi
+                if [ -d ${mirror_dir}/${time}/\${blend}/ ] ; then
+                        if [ -f \${wfile}.xz ] ; then
+                                cp -v \${wfile}.xz ${mirror_dir}/${time}/\${blend}/
+                        fi
+                fi
+        fi
+}
+
+archive_img () {
+        if [ -f \${wfile} ] ; then
+                ${archive} \${wfile}
+                copy_img_to_mirror
+        fi
+}
+
+generate_img () {
+        cd \${base_rootfs}/
+        sudo ./setup_sdcard.sh \${options}
+        mv *.img ../
+        cd ..
+}
+
+#Debian Stable
+base_rootfs="${debian_stable}" ; extract_base_rootfs
+
+options="--img BBB-eMMC-flasher-${debian_stable} --dtb beaglebone --bbb-flasher --enable-systemd  --bbb-old-bootloader-in-emmc" ; generate_img
+options="--img bone-${debian_stable} --dtb beaglebone --enable-systemd --bbb-old-bootloader-in-emmc" ; generate_img
+options="--img bb-${debian_stable} --dtb omap3-beagle --enable-systemd" ; generate_img
+options="--img bbxm-${debian_stable} --dtb omap3-beagle-xm --enable-systemd" ; generate_img
+options="--img omap5-uevm-${debian_stable} --dtb omap5-uevm --enable-systemd" ; generate_img
+options="--img bbx15-${debian_stable} --dtb am57xx-beagle-x15 --enable-systemd" ; generate_img
+
+#Ubuntu Stable
+base_rootfs="${ubuntu_stable}" ; extract_base_rootfs
+
+options="--img BBB-eMMC-flasher-${ubuntu_stable} --dtb beaglebone --bbb-flasher  --bbb-old-bootloader-in-emmc" ; generate_img
+options="--img bone-${ubuntu_stable} --dtb beaglebone --bbb-old-bootloader-in-emmc" ; generate_img
+options="--img bb-${ubuntu_stable} --dtb omap3-beagle" ; generate_img
+options="--img bbxm-${ubuntu_stable} --dtb omap3-beagle-xm" ; generate_img
+options="--img omap5-uevm-${ubuntu_stable} --dtb omap5-uevm" ; generate_img
+options="--img bbx15-${ubuntu_stable} --dtb am57xx-beagle-x15" ; generate_img
+
+#Archive tar:
+base_rootfs="${debian_stable}" ; archive_base_rootfs
+base_rootfs="${ubuntu_stable}" ; archive_base_rootfs
+base_rootfs="${debian_testing}" ; archive_base_rootfs
+
+#Archive img:
+blend="microsd"
+wfile="bone-${debian_stable}-2gb.img" ; archive_img
+wfile="bb-${debian_stable}-2gb.img" ; archive_img
+wfile="bbxm-${debian_stable}-2gb.img" ; archive_img
+wfile="omap5-uevm-${debian_stable}-2gb.img" ; archive_img
+wfile="bbx15-${debian_stable}-2gb.img" ; archive_img
+
+wfile="bone-${ubuntu_stable}-2gb.img" ; archive_img
+wfile="bb-${ubuntu_stable}-2gb.img" ; archive_img
+wfile="bbxm-${ubuntu_stable}-2gb.img" ; archive_img
+wfile="omap5-uevm-${ubuntu_stable}-2gb.img" ; archive_img
+wfile="bbx15-${ubuntu_stable}-2gb.img" ; archive_img
+
+blend="flasher"
+wfile="BBB-eMMC-flasher-${debian_stable}-2gb.img" ; archive_img
+wfile="BBB-eMMC-flasher-${ubuntu_stable}-2gb.img" ; archive_img
 
 __EOF__
 
-- 
GitLab