Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
rcn-ee_bb.org-stable.sh 16.4 KiB
Newer Older
Robert Nelson's avatar
Robert Nelson committed
#!/bin/bash -e

time=$(date +%Y-%m-%d)
mirror_dir="/var/www/html/rcn-ee.us/rootfs/bb.org/testing"
Robert Nelson's avatar
Robert Nelson committed
DIR="$PWD"

git pull --no-edit https://github.com/beagleboard/image-builder master

Robert Nelson's avatar
Robert Nelson committed
export apt_proxy=apt-proxy:3142/

Robert Nelson's avatar
Robert Nelson committed
if [ -d ./deploy ] ; then
	sudo rm -rf ./deploy || true
Robert Nelson's avatar
Robert Nelson committed
if [ ! -f jenkins.build ] ; then
#./RootStock-NG.sh -c machinekit-debian-wheezy
./RootStock-NG.sh -c machinekit-debian-jessie
./RootStock-NG.sh -c bb.org-debian-jessie-console-v4.4
./RootStock-NG.sh -c bb.org-debian-jessie-iot-v4.4
Robert Nelson's avatar
Robert Nelson committed
./RootStock-NG.sh -c bb.org-debian-jessie-lxqt-2gb-v4.4
./RootStock-NG.sh -c bb.org-debian-jessie-lxqt-4gb-v4.4
./RootStock-NG.sh -c bb.org-debian-jessie-lxqt-4gb-xm
./RootStock-NG.sh -c seeed-debian-jessie-lxqt-4gb-v4.4
./RootStock-NG.sh -c seeed-debian-jessie-iot-v4.4
Robert Nelson's avatar
Robert Nelson committed
./RootStock-NG.sh -c bb.org-debian-jessie-oemflasher
./RootStock-NG.sh -c bb.org-debian-stretch-iot-v4.4
./RootStock-NG.sh -c bb.org-debian-stretch-lxqt-v4.4
./RootStock-NG.sh -c bb.org-debian-stretch-lxqt-xm
./RootStock-NG.sh -c bb.org-debian-stretch-wayland-v4.4
else
	mkdir -p ${DIR}/deploy/ || true
Robert Nelson's avatar
Robert Nelson committed
    debian_wheezy_machinekit="debian-7.11-machinekit-armhf-${time}"
Robert Nelson's avatar
Robert Nelson committed
    debian_jessie_machinekit="debian-8.7-machinekit-armhf-${time}"
Robert Nelson's avatar
Robert Nelson committed
       debian_jessie_console="debian-8.7-console-armhf-${time}"
           debian_jessie_iot="debian-8.7-iot-armhf-${time}"
      debian_jessie_lxqt_2gb="debian-8.7-lxqt-2gb-armhf-${time}"
      debian_jessie_lxqt_4gb="debian-8.7-lxqt-4gb-armhf-${time}"
   debian_jessie_lxqt_xm_4gb="debian-8.7-lxqt-xm-4gb-armhf-${time}"
    debian_jessie_oemflasher="debian-8.7-oemflasher-armhf-${time}"
Robert Nelson's avatar
Robert Nelson committed
     debian_jessie_seeed_iot="debian-8.7-seeed-iot-armhf-${time}"
debian_jessie_seeed_lxqt_4gb="debian-8.7-seeed-lxqt-4gb-armhf-${time}"
          debian_stretch_iot="debian-stretch-iot-armhf-${time}"
         debian_stretch_lxqt="debian-stretch-lxqt-armhf-${time}"
      debian_stretch_lxqt_xm="debian-stretch-lxqt-xm-armhf-${time}"
      debian_stretch_wayland="debian-stretch-wayland-armhf-${time}"
xz_img="xz -z -8"
Robert Nelson's avatar
Robert Nelson committed
#xz_tar="xz -z -8"
xz_tar="xz -T0 -z -8"
beaglebone="--dtb beaglebone --rootfs_label rootfs --hostname beaglebone --enable-cape-universal"
overlay="--enable-uboot-cape-overlays"
beagle_xm="--dtb omap3-beagle-xm --rootfs_label rootfs --hostname beagleboard"
Robert Nelson's avatar
Robert Nelson committed
beagle_x15="--dtb am57xx-beagle-x15 --rootfs_label rootfs \
--hostname BeagleBoard-X15"
Robert Nelson's avatar
Robert Nelson committed

cat > ${DIR}/deploy/gift_wrap_final_images.sh <<-__EOF__
#!/bin/bash
wait_till_Xgb_free () {
        memory=4096
        free_memory=\$(free --mega | grep Mem | awk '{print \$7}')
        until [ "\$free_memory" -gt "\$memory" ] ; do
Robert Nelson's avatar
Robert Nelson committed
                free_memory=\$(free --mega | grep Mem | awk '{print \$7}')
                echo "have [\$free_memory] need [\$memory]"
copy_base_rootfs_to_mirror () {
        wait_till_Xgb_free
        if [ -d ${mirror_dir}/ ] ; then
                if [ ! -d ${mirror_dir}/${time}/\${blend}/ ] ; then
                        mkdir -p ${mirror_dir}/${time}/\${blend}/ || true
Robert Nelson's avatar
Robert Nelson committed
                fi
                if [ -d ${mirror_dir}/${time}/\${blend}/ ] ; then
                        if [ ! -f ${mirror_dir}/${time}/\${blend}/\${base_rootfs}.tar.xz ] ; then
                                cp -v \${base_rootfs}.tar ${mirror_dir}/${time}/\${blend}/
                                cd ${mirror_dir}/${time}/\${blend}/
                                ${xz_tar} \${base_rootfs}.tar && sha256sum \${base_rootfs}.tar.xz > \${base_rootfs}.tar.xz.sha256sum &
archive_base_rootfs () {
Robert Nelson's avatar
Robert Nelson committed
        if [ -d ./\${base_rootfs} ] ; then
                rm -rf \${base_rootfs} || true
        fi
        if [ -f \${base_rootfs}.tar ] ; then
                copy_base_rootfs_to_mirror
Robert Nelson's avatar
Robert Nelson committed
        fi
}

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
Robert Nelson's avatar
Robert Nelson committed
        fi

        if [ -f \${base_rootfs}.tar ] ; then
                tar xf \${base_rootfs}.tar
        fi
copy_img_to_mirror () {
        wait_till_Xgb_free
        if [ -d ${mirror_dir} ] ; then
                if [ ! -d ${mirror_dir}/${time}/\${blend}/ ] ; then
                        mkdir -p ${mirror_dir}/${time}/\${blend}/ || true
                if [ -d ${mirror_dir}/${time}/\${blend}/ ] ; then
                        if [ -f \${wfile}.bmap ] ; then
                                mv -v \${wfile}.bmap ${mirror_dir}/${time}/\${blend}/
                                sync
                        if [ ! -f ${mirror_dir}/${time}/\${blend}/\${wfile}.img.zx ] ; then
                                mv -v \${wfile}.img ${mirror_dir}/${time}/\${blend}/
Robert Nelson's avatar
Robert Nelson committed
                                sync
                                if [ -f \${wfile}.img.xz.job.txt ] ; then
                                        mv -v \${wfile}.img.xz.job.txt ${mirror_dir}/${time}/\${blend}/
                                        sync
                                cd ${mirror_dir}/${time}/\${blend}/
                                ${xz_img} \${wfile}.img && sha256sum \${wfile}.img.xz > \${wfile}.img.xz.sha256sum &
archive_img () {
        if [ -f \${wfile}.img ] ; then
                if [ ! -f \${wfile}.bmap ] ; then
                        if [ -f /usr/bin/bmaptool ] ; then
                                bmaptool create -o \${wfile}.bmap \${wfile}.img
                        fi
                fi
                copy_img_to_mirror
Robert Nelson's avatar
Robert Nelson committed
        fi
generate_img () {
Robert Nelson's avatar
Robert Nelson committed
        if [ -d \${base_rootfs}/ ] ; then
                cd \${base_rootfs}/
                sudo ./setup_sdcard.sh \${options}
                sudo chown 1000:1000 *.img || true
                sudo chown 1000:1000 *.job.txt || true
                mv *.img ../ || true
                mv *.job.txt ../ || true
Robert Nelson's avatar
Robert Nelson committed
                cd ..
        fi
###machinekit (wheezy):
base_rootfs="${debian_wheezy_machinekit}" ; blend="machinekit" ; extract_base_rootfs

options="--img-4gb bone-\${base_rootfs} ${beaglebone} --enable-systemd" ; generate_img
###machinekit (jessie):
base_rootfs="${debian_jessie_machinekit}" ; blend="machinekit" ; extract_base_rootfs

options="--img-4gb bone-\${base_rootfs} ${beaglebone}" ; generate_img
###console images (jessie):
base_rootfs="${debian_jessie_console}" ; blend="console" ; extract_base_rootfs
options="--img-1gb a335-eeprom-\${base_rootfs} ${beaglebone}  --a335-flasher" ; generate_img
options="--img-1gb bp00-eeprom-\${base_rootfs} ${beaglebone}  --bp00-flasher" ; generate_img
options="--img-1gb bone-\${base_rootfs}        ${beaglebone}"                 ; generate_img
options="--img-1gb bbx15-\${base_rootfs}       ${beagle_x15}"                 ; generate_img
options="--img-1gb me06-blank-\${base_rootfs}  ${beaglebone}  --me06-flasher" ; generate_img
#options="--img-1gb BBB-blank-\${base_rootfs}   ${beaglebone}  --emmc-flasher" ; generate_img
#options="--img-1gb bbx15-blank-\${base_rootfs} ${beagle_x15}  --emmc-flasher"        ; generate_img
Robert Nelson's avatar
Robert Nelson committed

###iot image (jessie):
base_rootfs="${debian_jessie_iot}" ; blend="iot" ; extract_base_rootfs

options="--img-4gb bone-\${base_rootfs}        ${beaglebone}"                 ; generate_img
options="--img-4gb BBB-blank-\${base_rootfs}   ${beaglebone}  --emmc-flasher" ; generate_img
options="--img-4gb BBBL-blank-\${base_rootfs}  ${beaglebone}  --bbbl-flasher" ; generate_img
options="--img-4gb BBB-blank-uboot-overlay-\${base_rootfs}  ${beaglebone} --emmc-flasher ${overlay}" ; generate_img

#options="--img-4gb BBBW-blank-\${base_rootfs}  ${beaglebone}   --bbbw-flasher" ; generate_img

###lxqt-2gb image (jessie):
base_rootfs="${debian_jessie_lxqt_2gb}" ; blend="lxqt-2gb" ; extract_base_rootfs
Robert Nelson's avatar
Robert Nelson committed
options="--img-2gb bone-\${base_rootfs}  ${beaglebone}" ; generate_img
Robert Nelson's avatar
Robert Nelson committed
#options="--img-2gb BBB-blank-\${base_rootfs} ${beaglebone} --emmc-flasher" ; generate_img
###lxqt-4gb image (jessie):
base_rootfs="${debian_jessie_lxqt_4gb}" ; blend="lxqt-4gb" ; extract_base_rootfs
options="--img-4gb bone-\${base_rootfs}        ${beaglebone}"                 ; generate_img
options="--img-4gb bbx15-\${base_rootfs}       ${beagle_x15}"                 ; generate_img
options="--img-4gb BBB-blank-\${base_rootfs}   ${beaglebone}  --emmc-flasher" ; generate_img
options="--img-4gb BBBW-blank-\${base_rootfs}  ${beaglebone}  --bbbw-flasher" ; generate_img
options="--img-4gb BBB-blank-uboot-overlay-\${base_rootfs}  ${beaglebone} --emmc-flasher ${overlay}" ; generate_img
#options="--img-4gb m10a-blank-\${base_rootfs}  ${beaglebone}  --m10a-flasher" ; generate_img
#options="--img-4gb bbx15-blank-\${base_rootfs} ${beagle_x15}  --emmc-flasher" ; generate_img
###lxqt-xm-4gb image (jessie):
base_rootfs="${debian_jessie_lxqt_xm_4gb}" ; blend="lxqt-xm-4gb" ; extract_base_rootfs
options="--img-4gb bbxm-\${base_rootfs}  ${beagle_xm}" ; generate_img
###Seeed iot image (jessie):
base_rootfs="${debian_jessie_seeed_iot}" ; blend="seeed-iot" ; extract_base_rootfs
options="--img-4gb bone-\${base_rootfs}       ${beaglebone}"                ; generate_img
#options="--img-4gb BBGW-blank-\${base_rootfs} ${beaglebone} --bbgw-flasher" ; generate_img
###Seeed lxqt-4gb image (jessie):
base_rootfs="${debian_jessie_seeed_lxqt_4gb}" ; blend="seeed-lxqt-4gb" ; extract_base_rootfs

Robert Nelson's avatar
Robert Nelson committed
options="--img-4gb bone-\${base_rootfs}      ${beaglebone}"                ; generate_img
#options="--img-4gb BBG-blank-\${base_rootfs} ${beaglebone}  --bbg-flasher" ; generate_img
###iot image (stretch):
base_rootfs="${debian_stretch_iot}" ; blend="stretch-iot" ; extract_base_rootfs

options="--img-4gb bone-\${base_rootfs}       ${beaglebone} ${overlay}"                ; generate_img
options="--img-4gb bbx15-\${base_rootfs}      ${beagle_x15}"                           ; generate_img
options="--img-4gb BBB-blank-\${base_rootfs}  ${beaglebone} ${overlay} --emmc-flasher" ; generate_img
###lxqt image (stretch):
base_rootfs="${debian_stretch_lxqt}" ; blend="stretch-lxqt" ; extract_base_rootfs

options="--img-4gb bone-\${base_rootfs}       ${beaglebone} ${overlay}"                ; generate_img
options="--img-4gb bbx15-\${base_rootfs}      ${beagle_x15}"                           ; generate_img
options="--img-4gb BBB-blank-\${base_rootfs}  ${beaglebone} ${overlay} --emmc-flasher" ; generate_img

###lxqt image (stretch):
base_rootfs="${debian_stretch_lxqt_xm}" ; blend="stretch-lxqt-xm" ; extract_base_rootfs

options="--img-4gb bbxm-\${base_rootfs}  ${beagle_xm}" ; generate_img

### wayland image (stretch):
base_rootfs="${debian_stretch_wayland}" ; blend="stretch-wayland" ; extract_base_rootfs

options="--img-4gb bone-\${base_rootfs}       ${beaglebone} ${overlay}"      ; generate_img
options="--img-4gb bbx15-\${base_rootfs}      ${beagle_x15}"                 ; generate_img

Robert Nelson's avatar
Robert Nelson committed
###archive *.tar
base_rootfs="${debian_wheezy_machinekit}"     ; blend="machinekit"      ; archive_base_rootfs
base_rootfs="${debian_jessie_machinekit}"     ; blend="machinekit"      ; archive_base_rootfs
base_rootfs="${debian_jessie_console}"        ; blend="console"         ; archive_base_rootfs
base_rootfs="${debian_jessie_iot}"            ; blend="iot"             ; archive_base_rootfs
base_rootfs="${debian_jessie_lxqt_2gb}"       ; blend="lxqt-2gb"        ; archive_base_rootfs
base_rootfs="${debian_jessie_lxqt_4gb}"       ; blend="lxqt-4gb"        ; archive_base_rootfs
base_rootfs="${debian_jessie_lxqt_xm_4gb}"    ; blend="lxqt-xm-4gb"     ; archive_base_rootfs
Robert Nelson's avatar
Robert Nelson committed
base_rootfs="${debian_jessie_oemflasher}"     ; blend="oemflasher"      ; archive_base_rootfs
base_rootfs="${debian_jessie_seeed_iot}"      ; blend="seeed-iot"       ; archive_base_rootfs
base_rootfs="${debian_jessie_seeed_lxqt_4gb}" ; blend="seeed-lxqt-4gb"  ; archive_base_rootfs
base_rootfs="${debian_stretch_iot}"           ; blend="stretch-iot"     ; archive_base_rootfs
base_rootfs="${debian_stretch_lxqt}"          ; blend="stretch-lxqt"    ; archive_base_rootfs
base_rootfs="${debian_stretch_lxqt_xm}"       ; blend="stretch-lxqt-xm" ; archive_base_rootfs
base_rootfs="${debian_stretch_wayland}"       ; blend="stretch-wayland" ; archive_base_rootfs
Robert Nelson's avatar
Robert Nelson committed
###archive *.img
###machinekit (wheezy):
base_rootfs="${debian_wheezy_machinekit}" ; blend="machinekit"

wfile="bone-\${base_rootfs}-4gb" ; archive_img
###machinekit (jessie):
base_rootfs="${debian_jessie_machinekit}" ; blend="machinekit"

wfile="bone-\${base_rootfs}-4gb" ; archive_img

###console images (jessie):
base_rootfs="${debian_jessie_console}" ; blend="console"

wfile="a335-eeprom-\${base_rootfs}-1gb" ; archive_img
wfile="bp00-eeprom-\${base_rootfs}-1gb" ; archive_img
wfile="bone-\${base_rootfs}-1gb"        ; archive_img
wfile="bbx15-\${base_rootfs}-1gb"       ; archive_img
wfile="me06-blank-\${base_rootfs}-1gb"  ; archive_img
#wfile="BBB-blank-\${base_rootfs}-1gb"   ; archive_img
#wfile="bbx15-blank-\${base_rootfs}-1gb" ; archive_img

###iot image (jessie):
base_rootfs="${debian_jessie_iot}" ; blend="iot"
Robert Nelson's avatar
Robert Nelson committed
wfile="bone-\${base_rootfs}-4gb"        ; archive_img
Robert Nelson's avatar
Robert Nelson committed
wfile="BBB-blank-\${base_rootfs}-4gb"   ; archive_img
wfile="BBBL-blank-\${base_rootfs}-4gb"  ; archive_img
wfile="BBB-blank-uboot-overlay-\${base_rootfs}-4gb"  ; archive_img
#wfile="BBBW-blank-\${base_rootfs}-4gb" ; archive_img
###lxqt-2gb image (jessie):
Robert Nelson's avatar
Robert Nelson committed
base_rootfs="${debian_jessie_lxqt_2gb}" ; blend="lxqt-2gb"

Robert Nelson's avatar
Robert Nelson committed
wfile="bone-\${base_rootfs}-2gb"      ; archive_img
#wfile="BBB-blank-\${base_rootfs}-2gb" ; archive_img
###lxqt-4gb image (jessie):
base_rootfs="${debian_jessie_lxqt_4gb}" ; blend="lxqt-4gb"
wfile="bone-\${base_rootfs}-4gb"        ; archive_img
wfile="bbx15-\${base_rootfs}-4gb"       ; archive_img
wfile="BBB-blank-\${base_rootfs}-4gb"   ; archive_img
wfile="BBBW-blank-\${base_rootfs}-4gb"  ; archive_img
wfile="BBB-blank-uboot-overlay-\${base_rootfs}-4gb"  ; archive_img
#wfile="m10a-blank-\${base_rootfs}-4gb"  ; archive_img
#wfile="bbx15-blank-\${base_rootfs}-4gb" ; archive_img
###lxqt-xm-4gb image (jessie):
base_rootfs="${debian_jessie_lxqt_xm_4gb}" ; blend="lxqt-xm-4gb"
wfile="bbxm-\${base_rootfs}-4gb"      ; archive_img
###Seeed iot image (jessie):
base_rootfs="${debian_jessie_seeed_iot}" ; blend="seeed-iot"
Robert Nelson's avatar
Robert Nelson committed

wfile="bone-\${base_rootfs}-4gb"       ; archive_img
#wfile="BBGW-blank-\${base_rootfs}-4gb" ; archive_img
###Seeed lxqt-4gb image (jessie):
base_rootfs="${debian_jessie_seeed_lxqt_4gb}" ; blend="seeed-lxqt-4gb"
wfile="bone-\${base_rootfs}-4gb"      ; archive_img
#wfile="BBG-blank-\${base_rootfs}-4gb" ; archive_img

###iot image (stretch):
base_rootfs="${debian_stretch_iot}" ; blend="stretch-iot"

wfile="bone-\${base_rootfs}-4gb"           ; archive_img
wfile="BBB-blank-\${base_rootfs}-4gb"      ; archive_img
wfile="bbx15-\${base_rootfs}-4gb"          ; archive_img
###lxqt image (stretch):
base_rootfs="${debian_stretch_lxqt}" ; blend="stretch-lxqt"

wfile="bone-\${base_rootfs}-4gb"           ; archive_img
wfile="BBB-blank-\${base_rootfs}-4gb"      ; archive_img
wfile="bbx15-\${base_rootfs}-4gb"          ; archive_img

###lxqt-xm image (stretch):
base_rootfs="${debian_stretch_lxqt_xm}" ; blend="stretch-lxqt-xm"

wfile="bbxm-\${base_rootfs}-4gb"      ; archive_img

### wayland image (stretch):
base_rootfs="${debian_stretch_wayland}" ; blend="stretch-wayland"

wfile="bone-\${base_rootfs}-4gb"       ; archive_img
wfile="bbx15-\${base_rootfs}-4gb"      ; archive_img
Robert Nelson's avatar
Robert Nelson committed
__EOF__

chmod +x ${DIR}/deploy/gift_wrap_final_images.sh

image_prefix="bb.org"
Robert Nelson's avatar
Robert Nelson committed
#node:
if [ ! -d /var/www/html/farm/images/ ] ; then
	if [ ! -d /mnt/farm/images/ ] ; then
		#nfs mount...
		sudo mount -a
	fi

	if [ -d /mnt/farm/images/ ] ; then
		mkdir -p /mnt/farm/images/${image_prefix}-${time}/ || true
		echo "Copying: *.tar to server: images/${image_prefix}-${time}/"
		cp -v ${DIR}/deploy/*.tar /mnt/farm/images/${image_prefix}-${time}/ || true
		cp -v ${DIR}/deploy/gift_wrap_final_images.sh /mnt/farm/images/${image_prefix}-${time}/gift_wrap_final_images.sh || true
		chmod +x /mnt/farm/images/${image_prefix}-${time}/gift_wrap_final_images.sh || true
Robert Nelson's avatar
Robert Nelson committed
#x86:
if [ -d /var/www/html/farm/images/ ] ; then
	mkdir -p /var/www/html/farm/images/${image_prefix}-${time}/ || true
	echo "Copying: *.tar to server: images/${image_prefix}-${time}/"
	cp -v ${DIR}/deploy/gift_wrap_final_images.sh /var/www/html/farm/images/${image_prefix}-${time}/gift_wrap_final_images.sh || true
	chmod +x /var/www/html/farm/images/${image_prefix}-${time}/gift_wrap_final_images.sh || true
Robert Nelson's avatar
Robert Nelson committed
	sudo chown -R apt-cacher-ng:apt-cacher-ng /var/www/html/farm/images/${image_prefix}-${time}/ || true