From d24bd2b690d1f989b33ab5eda4c4064d93d30134 Mon Sep 17 00:00:00 2001 From: "Garg, Nikhil" Date: Fri, 26 Oct 2018 10:41:07 +1100 Subject: [PATCH 1/2] check directory and file and print sane errors --- bin/build-stage0-image | 20 ++++++++++++++++---- bin/build-stage1-image | 26 +++++++++++++++++++++++--- bin/build-stage2-image | 30 +++++++++++++++++++++++++++--- bin/build-stage3-image | 27 ++++++++++++++++++++++++--- bin/rebuild-image-space | 11 +++++++++-- 5 files changed, 99 insertions(+), 15 deletions(-) diff --git a/bin/build-stage0-image b/bin/build-stage0-image index 5239761..b9fd691 100755 --- a/bin/build-stage0-image +++ b/bin/build-stage0-image @@ -1,15 +1,26 @@ #!/bin/bash set -e echo "Setting downloading and setting up images" -cd /root/images/stage0/ -if [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROIDC" ]; then + +function arch(){ + local out=$(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) + echo $out +} + +if [ -d /root/images/stage0 ];then + cd /root/images/stage0/ +else + ./rebuild-image-space +fi + +if [ $(arch) == "ODROIDC" ]; then echo "Odroid C1+ detected, starting process..." if [ $(lsb_release -r | tr "\t" " " | sed "s/\ //g" | cut -d ":" -f 2) = "16.04" ]; then wget https://odroid.in/ubuntu_16.04lts/ubuntu-16.04.3-minimal-odroid-c1-20170914.img.xz -O stage0_c1+.img.xz elif [ $(lsb_release -r | tr "\t" " " | sed "s/\ //g" | cut -d ":" -f 2) = "18.04" ]; then wget https://odroid.in/ubuntu_18.04lts/ubuntu-18.04.1-3.10-minimal-odroid-c1-20180802.img.xz -O stage0_c1+.img.xz fi -elif [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ] || [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU3" ]; then +elif [ $(arch) == "ODROID-XU4" ] || [ $(arch) == "ODROID-XU3" ]; then echo "Odroid XU4 detected, starting process..." if [ $(lsb_release -r | tr "\t" " " | sed "s/\ //g" | cut -d ":" -f 2) = "16.04" ]; then wget https://odroid.in/ubuntu_16.04lts/ubuntu-16.04.3-4.14-minimal-odroid-xu4-20171213.img.xz -O stage0_xu4.img.xz @@ -17,5 +28,6 @@ elif [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ] | wget https://odroid.in/ubuntu_18.04lts/ubuntu-18.04-4.14-minimal-odroid-xu4-20180531.img.xz -O stage0_xu4.img.xz fi else - echo "This machine is neither a C1+ nor a XU4. Please follow steps from https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." + echo "This machine is neither a C1+ nor a XU4. Please follow steps from \ + https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." fi diff --git a/bin/build-stage1-image b/bin/build-stage1-image index 09f7aa2..84391ed 100755 --- a/bin/build-stage1-image +++ b/bin/build-stage1-image @@ -1,18 +1,37 @@ #!/bin/bash +function arch(){ + local out=$(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) + echo $out +} + stage1_dir="/root/images/stage1" set -e set -x -if [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROIDC" ]; then +if [ ! -d ../stage0 ];then + echo "Run build-stage0-image first" + exit +fi + +if [ $(arch) == "ODROIDC" ] && [ ! -f ../stage0/stage0_c1+.img.xz ];then + echo "Run build-stage0-image first" + exit +elif [ $(arch) == "ODROID-XU4" ] && [ ! -f ../stage0/stage0_xu4.img.xz ];then + echo "Run build-stage0-image first" + exit +fi + + +if [ $(arch) == "ODROIDC" ]; then echo "Odroid C1+ detected, starting process..." cd $stage1_dir cp ../stage0/stage0_c1+.img.xz . unxz stage0_c1+.img.xz mv stage0_c1+.img stage1_c1+.img image_file="stage1_c1+.img" -elif [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ] || [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU3" ]; then +elif [ $(arch) = "ODROID-XU4" ] || [ $(arch) = "ODROID-XU3" ]; then echo "Odroid XU4 detected, starting process..." cd $stage1_dir cp ../stage0/stage0_xu4.img.xz . @@ -20,7 +39,8 @@ elif [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ] | mv stage0_xu4.img stage1_xu4.img image_file="stage1_xu4.img" else - echo "This machine is neither a C1+ nor a XU4. Please follow steps from https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." + echo "This machine is neither a C1+ nor a XU4. Please follow steps \ + from https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." fi diff --git a/bin/build-stage2-image b/bin/build-stage2-image index 05f1e0d..59315f6 100755 --- a/bin/build-stage2-image +++ b/bin/build-stage2-image @@ -1,19 +1,43 @@ #!/bin/bash set -e set -x + +function arch(){ + local out=$(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) + echo $out +} + + current_dir=`pwd` stage2_dir="/root/images/stage2" -if [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROIDC" ]; then + +if [ ! -d ../stage1 ];then + echo "Run build-stage1-image first" + exit +fi + +if [ $(arch) == "ODROIDC" ] && [ ! -f ../stage1/stage1_c1+.img.xz ];then + echo "Run build-stage1-image first" + exit +elif [ $(arch) == "ODROID-XU4" ] && [ ! -f ../stage1/stage1_xu4.img.xz ];then + echo "Run build-stage1-image first" + exit +fi + + +if [ $(arch) == "ODROIDC" ]; then echo "Odroid C1+ detected, starting process..." cd $stage2_dir cp ../stage1/stage1_c1+.img ./stage2_c1+.img -elif [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ] || [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU3" ]; then +elif [ $(arch) == "ODROID-XU4" ] || [ $(arch) == "ODROID-XU3" ]; then echo "Odroid XU4 detected, starting process..." cd $stage2_dir cp ../stage1/stage1_xu4.img ./stage2_xu4.img else - echo "This machine is neither a C1+ nor a XU4. Please follow steps from https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." + echo "This machine is neither a C1+ nor a XU4. Please follow steps from \ + https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." fi + cd $current_dir ./build-stage2-image.py -b $stage2_dir "$1" diff --git a/bin/build-stage3-image b/bin/build-stage3-image index 4cd2517..017bd94 100755 --- a/bin/build-stage3-image +++ b/bin/build-stage3-image @@ -1,21 +1,42 @@ #!/bin/bash set -e set -x + +function arch(){ + local out=$(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) + echo $out +} + current_dir=`pwd` stage3_dir="/root/images/stage3" -if [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROIDC" ]; then +if [ ! -d ../stage2 ];then + echo "Run build-stage2-image first" + exit +fi + +if [ $(arch) == "ODROIDC" ] && [ ! -f ../stage2/stage2_c1+.img.xz ];then + echo "Run build-stage2-image first" + exit +elif [ $(arch) == "ODROID-XU4" ] && [ ! -f ../stage2/stage2_xu4.img.xz ];then + echo "Run build-stage2-image first" + exit +fi + + +if [ $(arch) == "ODROIDC" ]; then echo "Odroid C1+ detected, starting process..." cd $stage3_dir cp ../stage2/stage2_c1+.img ./stage3_c1+.img cd $current_dir ./build-stage3-image.py --build-dir=$stage3_dir --node-controller --revision=1 --deployment=AoT --version="$1" -elif [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ] || [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU3" ]; then +elif [ $(arch) == "ODROID-XU4" ] || [ $(arch) == "ODROID-XU3" ]; then echo "Odroid XU4 detected, starting process..." cd $stage3_dir cp ../stage2/stage2_xu4.img ./stage3_xu4.img cd $current_dir ./build-stage3-image.py --build-dir=$stage3_dir --edge-processor --revision=1 --deployment=AoT --version="$1" else - echo "This machine is neither a C1+ nor a XU4. Please follow steps from https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." + echo "This machine is neither a C1+ nor a XU4. Please follow steps from \ + https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." fi diff --git a/bin/rebuild-image-space b/bin/rebuild-image-space index 99cf225..4dfaa75 100755 --- a/bin/rebuild-image-space +++ b/bin/rebuild-image-space @@ -1,7 +1,13 @@ #!/bin/bash set -e set -x -if [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROIDC" ] || [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROID-XU4" ]; then + +function arch(){ + local out=$(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) + echo $out +} + +if [ $(arch) == "ODROIDC" ] || [ $(arch) == "ODROID-XU4" ]; then echo "Odroid build-system detected, starting process..." cd /root/ if [ -d "images" ]; then mv images images_$(date +%s); fi @@ -11,7 +17,8 @@ if [ $(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) = "ODROIDC" ] || [ $ mkdir -p images/stage2 mkdir -p images/stage3 else - echo "This machine is neither a C1+ nor a XU4. Please follow steps from https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." + echo "This machine is neither a C1+ nor a XU4. Please follow steps from \ + https://github.com/waggle-sensor/waggle_image/tree/master/build_image_docs to build images." fi From 3d72327d5ededa86250c053585ecdcedf0e80dde Mon Sep 17 00:00:00 2001 From: "Garg, Nikhil" Date: Fri, 26 Oct 2018 10:48:12 +1100 Subject: [PATCH 2/2] fixed a possible error with bin scripts directory --- bin/build-stage0-image | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/build-stage0-image b/bin/build-stage0-image index b9fd691..79d3b58 100755 --- a/bin/build-stage0-image +++ b/bin/build-stage0-image @@ -2,6 +2,8 @@ set -e echo "Setting downloading and setting up images" +cwd = `pwd` + function arch(){ local out=$(cat /proc/cpuinfo | grep Hardware | cut -d ":" -f 2) echo $out @@ -10,7 +12,9 @@ function arch(){ if [ -d /root/images/stage0 ];then cd /root/images/stage0/ else + cd $cwd ./rebuild-image-space + cd /root/images/stage0/ fi if [ $(arch) == "ODROIDC" ]; then