1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-30 18:14:04 +02:00
openwrt-xburst/scripts/build
Xiangfu Liu 1ceee39ceb cleanup scripts/build a little. make it save un-commit stuff by git stash
Signed-off-by: Xiangfu Liu <xiangfu@sharism.cc>
2010-10-22 15:11:43 +08:00

133 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
BASE_DIR="xburst"
LOG="${BASE_DIR}/LOG"
BUILD_LOG="${BASE_DIR}/BUILD_LOG"
DATE=$(date "+%Y-%m-%d")
TIME=$(date "+%H-%M-%S")
DATE_TIME="${DATE}_${TIME}"
FEEDS_CONF="feeds.conf.default"
test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
if [ "${0}" != "./scripts/build" ]; then
echo "Please call me that way: ./scripts/build"
echo " - out of the main directory"
exit 1
fi
if [ ! -f ".config" ]; then
echo "OpenWrt didn't get configured yet."
exit 1
fi
if [ -f "config" ]; then
echo "file <config> exists."
echo "That means normally, a previous build failed"
echo "Please examine the situation"
exit 1
fi
echo "This script will move previous builds to bak/!"
echo "This script will compile base on last commit"
echo " your modifications will backup by git stash"
echo " those modifications will apply again after compile"
echo "This script comes without any kind of warranty!"
echo " "
echo "Are you brave, dude? [NO/yes]"
read brave
echo " "
if [ "${brave}" != "yes" ]; then
exit 1
fi
echo "cleaning up toolchain..."
mkdir bak 2>/dev/null
BAK="build_dir staging_dir tmp bin .config.old feeds xburst config"
for bak in $BAK; do
mv "${bak}" "bak/${bak}_${DATE_TIME}" 2> /dev/null && echo "backed up <${bak}>"
done
rm -rf package/feeds/*
mv .config config
mkdir xburst
echo "updating git repo..."
git stash
git checkout tracking_backfire
git pull > /dev/null
if [ "$?" != "0" ]; then
echo "ERROR: updating openwrt-xburst failed"
exit 1
fi
echo "updating feeds..."
scripts/feeds update -a > /dev/null 2>&1
if [ "$?" != "0" ]; then
echo "ERROR: updating feeds failed"
exit 1
fi
echo "installing feeds..."
scripts/feeds install -a > /dev/null 2>&1
if [ "$?" != "0" ]; then
echo "ERROR: installing feeds failed"
exit 1
fi
echo "getting version numbers of used repositories..."
feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
VERSIONS_FILE="xburst/VERSIONS"
echo "# base :: 'openwrt' [scm-protocol] [revision] [source] [branch]" > ${VERSIONS_FILE}
tmp=($(git show-ref | head -n 1))
rev=${tmp[0]}
echo "openwrt git ${rev} git://projects.qi-hardware.com/openwrt-xburst.git tracking_backfire" >> ${VERSIONS_FILE}
echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE}
IFS=$'\n'
for feed in $feeds; do
IFS=' ' arr=(${feed:4})
proto=${arr[0]}
dir=${arr[1]}
url=${arr[2]}
if [ "$proto" = "svn" ]; then
cd feeds/${arr[1]} && tmp=($(svn info | grep -E "^Revision")) && cd ../../
rev=${tmp[1]}
fi
if [ "$proto" = "git" ]; then
cd feeds/${arr[1]} && tmp=($(git show-ref | head -n 1)) && cd ../../
rev=${tmp[0]}
fi
echo "${dir} ${proto} ${rev}" >> ${VERSIONS_FILE}
done
mkdir -p files/etc
echo ${DATE} > files/etc/VERSION
mv config .config
yes "" | make oldconfig
echo "starting compiling - this may take several hours..."
time make V=99 > xburst/BUILD_LOG 2>&1
if [ "$?" != "0" ]; then
echo "ERROR: Build failed!"
echo "Please refer to the log file"
exit 1
fi
git stash pop
cp .config xburst/config
cp bin/xburst/* xburst/ 2>/dev/null
mkdir xburst/files
cp -a files/* xburst/files/
echo "DONE :)"