4
Fork 0
CronosAgent/OpenWRT/build.sh
2016-08-04 11:18:57 +03:00

41 lines
889 B
Bash
Executable file

#!/bin/bash
PACKAGE=cronosagent
PROJECT=$(pwd)/..
OPENWRT=${HOME}/openwrt
test -d $OPENWRT/package/$PACKAGE
if [ "$?" -eq "0" ]
then
# Remove existing package in buildroot
rm -rf $OPENWRT/package/$PACKAGE
fi
# Create package directory and copy all stuff
mkdir -p $OPENWRT/package/$PACKAGE/source
cp -R $PROJECT $OPENWRT/package/$PACKAGE/source
rm -rf $OPENWRT/package/$PACKAGE/source/.git
pushd . > /dev/null
cd $OPENWRT
# Make Makefile visible to Buildroot
mv package/$PACKAGE/source/OpenWRT/Makefile package/$PACKAGE
grep "CONFIG_PACKAGE_${PACKAGE}=m" .config > /dev/null
if [ "$?" -ne "0" ]
then
# Give user to choose package $PACKAGE
make menuconfig
make
fi
# Build package
make package/$PACKAGE/compile V=ws 2>&1 | tee $PROJECT/../build.log | grep -i error
# Copy built packages
find bin -name ${PACKAGE}*.ipk | xargs -l -I {} mv {} $PROJECT/..
popd > /dev/null