Skip to content

Commit

Permalink
Merge pull request #17 from nikhil003/master
Browse files Browse the repository at this point in the history
check directory and file and print sane errors
  • Loading branch information
rajeshxsankaran authored Nov 5, 2018
2 parents b80f3aa + 3d72327 commit 1bd675f
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 15 deletions.
24 changes: 20 additions & 4 deletions bin/build-stage0-image
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
#!/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

cwd = `pwd`

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
cd $cwd
./rebuild-image-space
cd /root/images/stage0/
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
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-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
26 changes: 23 additions & 3 deletions bin/build-stage1-image
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
#!/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 .
unxz stage0_xu4.img.xz
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


Expand Down
30 changes: 27 additions & 3 deletions bin/build-stage2-image
Original file line number Diff line number Diff line change
@@ -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"
27 changes: 24 additions & 3 deletions bin/build-stage3-image
Original file line number Diff line number Diff line change
@@ -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
11 changes: 9 additions & 2 deletions bin/rebuild-image-space
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


Expand Down

0 comments on commit 1bd675f

Please sign in to comment.