Root/nanonote-files/data/qi_lb60/scripts/compile-openwrt-xburst.sh

1#!/bin/bash
2
3# This script file is using in build host, Xiangfu <xiangfu@openmobilefree.net>
4# $1: full_system minimal xbboot
5
6OPENWRT_DIR_NAME="openwrt-xburst."$1
7OPENWRT_DIR="/home/xiangfu/tmp/${OPENWRT_DIR_NAME}/"
8CONFIG_FILE_TYPE="config."$1
9
10MAKE_VARS=" V=s IGNORE_ERRORS=m "
11
12########################################################################
13DATE=$(date "+%Y-%m-%d")
14DATE_TIME=`date +"%Y%m%d-%H%M"`
15
16GET_FEEDS_VERSION_SH="/home/xiangfu/bin/get-feeds-revision.sh"
17PATCH_OPENWRT_SH="/home/xiangfu/bin/patch-openwrt.sh"
18
19IMAGES_URL="http://pertain.qi-hardware.com/~xiangfu/build-nanonote"
20IMAGES_DIR_BASE="/home/xiangfu/tmp/building/Nanonote/Ben"
21IMAGES_DIR="${IMAGES_DIR_BASE}/${OPENWRT_DIR_NAME}-${DATE_TIME}/"
22DEST_DIR="/home/xiangfu/tmp/build-nanonote"
23mkdir -p ${IMAGES_DIR}
24mkdir -p ${DEST_DIR}
25
26BUILD_LOG="${IMAGES_DIR}/BUILD_LOG"
27VERSIONS_FILE="${IMAGES_DIR}/VERSIONS"
28
29########################################################################
30if [ ! -d ${OPENWRT_DIR} ]; then
31  git clone git://projects.qi-hardware.com/openwrt-xburst.git ${OPENWRT_DIR}
32fi
33cd ${OPENWRT_DIR}
34
35
36echo "make distclean..."
37make distclean
38
39
40echo "updating git repo..."
41git fetch -a
42git reset --hard origin/master
43if [ "$?" != "0" ]; then
44    echo "ERROR: updating openwrt-xburst failed"
45    exit 1
46fi
47
48
49echo "update and install feeds..."
50cp /home/xiangfu/bin/feeds.conf ./
51./scripts/feeds update -a && ./scripts/feeds install -a
52if [ "$?" != "0" ]; then
53    echo "ERROR: update and install feeds failed"
54    exit 1
55fi
56cp feeds/qipackages/nanonote-files/data/qi_lb60/conf/${CONFIG_FILE_TYPE} \
57    .config
58sed -i '/CONFIG_ALL/s/.*/CONFIG_ALL=y/' .config
59yes "" | make oldconfig > /dev/null
60
61
62echo "getting version numbers of used repositories..."
63HEAD_NEW=`${GET_FEEDS_VERSION_SH} ${OPENWRT_DIR}`
64HEAD_OLD=`cat ${IMAGES_DIR}/../${OPENWRT_DIR_NAME}.VERSIONS`
65if [ "${HEAD_NEW}" == "${HEAD_OLD}" ]; then
66    echo "No new commit, ignore build"
67    rm -f ${BUILD_LOG} ${VERSIONS_FILE}
68    rmdir ${IMAGES_DIR}
69    exit 0
70fi
71${GET_FEEDS_VERSION_SH} ${OPENWRT_DIR} > ${VERSIONS_FILE}
72cp ${VERSIONS_FILE} ${IMAGES_DIR}/../${OPENWRT_DIR_NAME}.VERSIONS
73
74echo "copy files, create VERSION, link dl folder, last prepare..."
75rm -f files && ln -s feeds/qipackages/nanonote-files/files/
76if [ ! -d /home/xiangfu/tmp/dl ]; then
77  mkdir -p /home/xiangfu/tmp/dl
78fi
79rm -f dl && ln -s /home/xiangfu/tmp/dl/
80mkdir -p files/etc && echo ${DATE} > files/etc/VERSION
81mkdir -p files/etc/uci-defaults && \
82    echo -e "\0043\0041/bin/sh \ndate --set `date +"%Y%m%d%H%M"`\n \
83hwclock --systohc" > files/etc/uci-defaults/99-set-time
84
85
86echo "patch openwrt..."
87${PATCH_OPENWRT_SH} ${OPENWRT_DIR}
88
89
90echo "starting compiling - this may take several hours..."
91time make ${MAKE_VARS} > ${IMAGES_DIR}/BUILD_LOG 2>&1
92MAKE_RET="$?"
93
94
95echo "copy all files to IMAGES_DIR..."
96cp .config ${IMAGES_DIR}/config
97cp build_dir/linux-xburst_qi_lb60/linux-*/.config ${IMAGES_DIR}/kernel.config
98cp feeds.conf ${IMAGES_DIR}/
99cp -a bin/xburst/* ${IMAGES_DIR} 2>/dev/null
100mkdir -p ${IMAGES_DIR}/files
101cp -a files/* ${IMAGES_DIR}/files/
102
103(cd ${IMAGES_DIR} && \
104    grep -E "ERROR:\ package.*failed to build" BUILD_LOG | \
105    grep -v "package/kernel" > failed_packages.txt; \
106
107)
108
109if [ "$1" == "minimal" ]; then
110    cp ${IMAGES_DIR}/failed_packages.txt /home/xiangfu/tmp/building/Nanonote/Ben/
111fi
112
113if [ "${MAKE_RET}" == "0" ]; then
114    (cd ${IMAGES_DIR} && \
115        bzip2 -z openwrt-xburst-qi_lb60-root.ubi; \
116    bzip2 -z BUILD_LOG; \
117    )
118    mv ${IMAGES_DIR} ${DEST_DIR}
119
120    MSG="The build was successful: ${IMAGES_URL}/${OPENWRT_DIR_NAME}-${DATE_TIME}"
121    echo -e "say #qi-hardware ${MSG} \nclose" \
122        | nc turandot.qi-hardware.com 3858
123else
124    (cd ${IMAGES_DIR} && \
125    tail -n 100 BUILD_LOG > BUILD_LOG.last100; \
126    bzip2 -z BUILD_LOG; \
127    )
128
129    echo "ERROR: Build failed! please refer to the BUILD_LOG file"
130fi
131
132
133echo "Done"
134

Archive Download this file



interactive