Skip to content

Commit

Permalink
Cleanup build script (#4)
Browse files Browse the repository at this point in the history
* Use POSIX tests in build script

* Use $() instead of backticks in build script

* Quote variables in build script
  • Loading branch information
tssva authored and anmaped committed Nov 20, 2018
1 parent fc541a8 commit 71f6336
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions buildopenfang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ set -e
CPW=$(pwd)

DIR=_build
[[ -d $DIR ]] || { printf '%s does not exist!\n' "$DIR"; mkdir $DIR; }
[ -d $DIR ] || { printf '%s does not exist!\n' "$DIR"; mkdir $DIR; }

date=`date +"%Y-%m-%d %H:%M"`
ID="(`git rev-parse HEAD`) $date"
SHORTID=`git rev-parse --short HEAD`
date=$(date +"%Y-%m-%d %H:%M")
ID="($(git rev-parse HEAD)) $date"
SHORTID=$(git rev-parse --short HEAD)

echo $ID > fs/opt/version
echo "$ID" > fs/opt/version

cp --preserve=context fs $DIR/ -r;

sed -i "s/VERSION=.*/VERSION=\"$date\"/g" $DIR/fs/opt/autoupdate.sh
sed -i "s/TAG=.*/TAG=\"$TAG\"/g" $DIR/fs/opt/autoupdate.sh
sed -i "s/ID=.*/ID=\"$SHORTID\"/g" $DIR/fs/opt/autoupdate.sh

[[ "$1" = "stamp" ]] && { exit 0; }
[ "$1" = "stamp" ] && { exit 0; }

cd $DIR

BUILDROOT_VERSION=2016.02

[[ -d "buildroot-$BUILDROOT_VERSION" ]] || {
[ -d "buildroot-$BUILDROOT_VERSION" ] || {
wget https://buildroot.org/downloads/buildroot-$BUILDROOT_VERSION.tar.gz;
tar xvf buildroot-$BUILDROOT_VERSION.tar.gz;
rm buildroot-$BUILDROOT_VERSION.tar.gz;
cd buildroot-$BUILDROOT_VERSION
patch -p1 < $CPW/patches/add_fp_no_fused_madd.patch
patch -p1 < "$CPW"/patches/add_fp_no_fused_madd.patch
cd ..
}

cd buildroot-$BUILDROOT_VERSION

# update config files
cp --preserve=context $CPW/config/buildroot.config ./.config
cp --preserve=context $CPW/config/busybox.config ./package/busybox
cp --preserve=context $CPW/config/uClibc-ng.config ./package/uclibc
cp --preserve=context "$CPW"/config/buildroot.config ./.config
cp --preserve=context "$CPW"/config/busybox.config ./package/busybox
cp --preserve=context "$CPW"/config/uClibc-ng.config ./package/uclibc

[[ -d "dl" ]] || { mkdir dl; }
[ -d "dl" ] || { mkdir dl; }

cp --preserve=context ../../kernel-3.10.14.tar.xz dl/
cp --preserve=context ../../uboot-v2013.07.tar.xz dl/
Expand All @@ -55,24 +55,24 @@ WDIR=$CPW/$DIR/buildroot-$BUILDROOT_VERSION
GCCVER=$(gcc -dumpversion)
echo "GCC version: $GCCVER"
if [ "$GCCVER" -ge "5" ]; then
cp $CPW/patches/automake.in.patch $WDIR/package/automake
cp $CPW/patches/python2.7_gcc8__fix.patch $WDIR/package/python
cp $CPW/patches/lzop-gcc6.patch $WDIR/package/lzop
cp "$CPW"/patches/automake.in.patch "$WDIR"/package/automake
cp "$CPW"/patches/python2.7_gcc8__fix.patch "$WDIR"/package/python
cp "$CPW"/patches/lzop-gcc6.patch "$WDIR"/package/lzop
fi

# copy custom opendafang packages to buildroot directory
rm -r $WDIR/package/ffmpeg # use updated package version instead
cp --preserve=context $CPW/buildroot/* . -rf
rm -r "$WDIR"/package/ffmpeg # use updated package version instead
cp --preserve=context "$CPW"/buildroot/* . -rf

cp $CPW/v4l2rtspserver-v0.0.8.tar.gz $WDIR/dl/
cp "$CPW"/v4l2rtspserver-v0.0.8.tar.gz "$WDIR"/dl/

make

# constructs release with git hash label
echo "Compressing toolchain..."
tar -c -C $WDIR/output/host --transform s/./mipsel-ingenic-linux-uclibc/ --checkpoint=.1000 . | xz --best > $CPW/toolchain-$SHORTID.tar.xz
tar -c -C "$WDIR"/output/host --transform s/./mipsel-ingenic-linux-uclibc/ --checkpoint=.1000 . | xz --best > "$CPW"/toolchain-$SHORTID.tar.xz
echo "Compressing rootfs images..."
tar -c -C $WDIR/output/images --transform s/./openfang-images/ --checkpoint=.1000 . | xz --best > $CPW/images-$SHORTID.tar.xz
tar -c -C "$WDIR"/output/images --transform s/./openfang-images/ --checkpoint=.1000 . | xz --best > "$CPW"/images-$SHORTID.tar.xz
echo "Build completed successfully."


0 comments on commit 71f6336

Please sign in to comment.