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

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

Archive Download this file



interactive