1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-11-26 01:03:08 +02:00

add build script file using in buildhost

This commit is contained in:
Xiangfu Liu 2011-04-18 22:53:45 +08:00
parent 3eb5448f26
commit df9db34bce
3 changed files with 115 additions and 131 deletions

View File

@ -1,131 +0,0 @@
#!/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="data/qi_lb60/conf/feeds.conf"
test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
if [ "${0}" != "data/qi_lb60/scripts/build" ]; then
echo "Please call me that way: data/qi_lb60/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 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] [source] [branch] [revision]" > ${VERSIONS_FILE}
rev=$(git log | head -n 1 | cut -b8-)
branch=$(git branch | grep "*" | cut -b3-)
echo "openwrt git git://projects.qi-hardware.com/openwrt-xburst.git ${branch} ${rev}" >> ${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 log | head -n 1)) && cd ../../
rev=${tmp[1]}
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 :)"

View File

@ -0,0 +1,81 @@
#!/bin/bash
DATE=$(date "+%Y-%m-%d")
TIME=$(date "+%H-%M-%S")
DATE_TIME=`date +"%m%d%Y-%H%M"`
# this script file is using in build host
# $1: full_system minimal xbboot
OPENWRT_DIR_NAME="openwrt-xburst."$1
CONFIG_FILE_TYPE="config."$1
# you may need change those Variables
BASE_DIR="/home/xiangfu/compile-log/"
OPENWRT_DIR="/home/xiangfu/${OPENWRT_DIR_NAME}/"
GET_FEEDS_VERSION_SH="/home/xiangfu/bin/get-feeds-revision.sh"
IMAGE_DIR="${BASE_DIR}/${OPENWRT_DIR_NAME}-${DATE_TIME}/"
BUILD_LOG="${IMAGE_DIR}/BUILD_LOG"
VERSIONS_FILE="${IMAGE_DIR}/VERSIONS"
MAKE_VARS=" V=99 IGNORE_ERRORS=m "
########################################################################
cd ${OPENWRT_DIR}
echo "make distclean ..."
make distclean
echo "updating git repo..."
git fetch -a
git reset --hard origin/master
if [ "$?" != "0" ]; then
echo "ERROR: updating openwrt-xburst failed"
exit 1
fi
echo "update and install feeds..."
./scripts/feeds update -a && ./scripts/feeds install -a
if [ "$?" != "0" ]; then
echo "ERROR: update and install feeds failed"
exit 1
fi
cp feeds/qipackages/nanonote-files/data/qi_lb60/conf/${CONFIG_FILE_TYPE} .config
sed -i '/CONFIG_ALL/s/.*/CONFIG_ALL=y/' .config
yes "" | make oldconfig > /dev/null
echo "copy files, create VERSION, copy dl folder, last prepare..."
rm -f files && ln -s feeds/qipackages/nanonote-files/data/qi_lb60/files/
rm -f dl && ln -s ~/dl
mkdir -p files/etc && echo ${DATE} > files/etc/VERSION
echo "starting compiling - this may take several hours..."
mkdir -p ${IMAGE_DIR}
time make ${MAKE_VARS} > ${IMAGE_DIR}/BUILD_LOG 2>&1
if [ "$?" != "0" ]; then
echo "ERROR: Build failed! Please refer to the log file"
tail -n 100 ${IMAGE_DIR}/BUILD_LOG > ${IMAGE_DIR}/BUILD_LOG.`date +"%m%d%Y-%H%M"`.last100
fi
echo "getting version numbers of used repositories..."
${GET_FEEDS_VERSION_SH} ${OPENWRT_DIR} > ${VERSIONS_FILE}
echo "copy all files to IMAGE_DIR..."
cp .config ${IMAGE_DIR}/config
cp feeds.conf ${IMAGE_DIR}/
cp -a bin/xburst/* ${IMAGE_DIR} 2>/dev/null
mkdir -p ${IMAGE_DIR}/files
cp -a files/* ${IMAGE_DIR}/files/
(cd ${IMAGE_DIR}; \
bzip2 -z BUILD_LOG; \
bzip2 -z openwrt-xburst-qi_lb60-root.ubi; \
)
echo "DONE :)"

View File

@ -0,0 +1,34 @@
#!/bin/bash
cd $1
FEEDS_CONF="feeds.conf.default"
test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
echo "# base :: openwrt [scm-protocol] [source] [branch] [revision]"
repo=$(git config -l | grep remote.origin.url | cut -d "=" -f 2)
rev=$(git log | head -n 1 | cut -b8-)
branch=$(git branch | grep "*" | cut -b3-)
echo "openwrt git ${repo} ${branch} ${rev}"
echo "# feeds :: [feedname] [scm-protocol] [revision]"
IFS=$'\n'
for feed in $feeds; do
IFS=' ' arr=(${feed:4})
proto=${arr[0]}
dir=${arr[1]}
if [ "$proto" = "svn" ]; then
cd feeds/${dir} && rev=`svn info | grep -E "^Revision" | cut -d " " -f2` && cd ../../
fi
if [ "$proto" = "git" ]; then
cd feeds/${dir} && rev=`git log | head -n 1 | cut -d " " -f2` && cd ../../
fi
if [ "$proto" = "link" ]; then
rev=`date "+%Y-%m-%d"`
fi
echo "${dir} ${proto} ${rev}"
done