Date:2011-04-18 16:53:45 (12 years 11 months ago)
Author:Xiangfu Liu
Commit:df9db34bcefdd93c9f857b24d430afa317a39e55
Message:add build script file using in buildhost

Files: nanonote-files/data/qi_lb60/scripts/build (1 diff)
nanonote-files/data/qi_lb60/scripts/compile-openwrt-xburst.sh (1 diff)
nanonote-files/data/qi_lb60/scripts/get-feeds-revision.sh (1 diff)

Change Details

nanonote-files/data/qi_lb60/scripts/build
1#!/bin/bash
2
3BASE_DIR="xburst"
4
5LOG="${BASE_DIR}/LOG"
6
7BUILD_LOG="${BASE_DIR}/BUILD_LOG"
8
9DATE=$(date "+%Y-%m-%d")
10TIME=$(date "+%H-%M-%S")
11DATE_TIME="${DATE}_${TIME}"
12
13FEEDS_CONF="data/qi_lb60/conf/feeds.conf"
14test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
15
16if [ "${0}" != "data/qi_lb60/scripts/build" ]; then
17    echo "Please call me that way: data/qi_lb60/scripts/build"
18    echo " - out of the main directory"
19    exit 1
20fi
21
22if [ ! -f ".config" ]; then
23    echo "OpenWrt didn't get configured yet."
24    exit 1
25fi
26
27if [ -f "config" ]; then
28    echo "file <config> exists."
29    echo "That means normally, a previous build failed"
30    echo "Please examine the situation"
31    exit 1
32fi
33
34echo "This script will move previous builds to bak/!"
35echo "This script will compile base on last commit"
36echo " your modifications will backup by git stash"
37echo " those modifications will apply again after compile"
38echo "This script comes without any kind of warranty!"
39echo " "
40echo "Are you brave, dude? [NO/yes]"
41
42read brave
43
44echo " "
45
46if [ "${brave}" != "yes" ]; then
47    exit 1
48fi
49
50echo "cleaning up toolchain..."
51mkdir bak 2>/dev/null
52BAK="build_dir staging_dir tmp bin .config.old feeds xburst config"
53for bak in $BAK; do
54    mv "${bak}" "bak/${bak}_${DATE_TIME}" 2> /dev/null && echo "backed up <${bak}>"
55done
56rm -rf package/feeds/*
57
58mv .config config
59mkdir xburst
60
61echo "updating git repo..."
62git stash
63git pull > /dev/null
64if [ "$?" != "0" ]; then
65    echo "ERROR: updating openwrt-xburst failed"
66    exit 1
67fi
68
69echo "updating feeds..."
70scripts/feeds update -a > /dev/null 2>&1
71if [ "$?" != "0" ]; then
72    echo "ERROR: updating feeds failed"
73    exit 1
74fi
75echo "installing feeds..."
76scripts/feeds install -a > /dev/null 2>&1
77if [ "$?" != "0" ]; then
78    echo "ERROR: installing feeds failed"
79    exit 1
80fi
81
82echo "getting version numbers of used repositories..."
83feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
84VERSIONS_FILE="xburst/VERSIONS"
85echo "# base :: 'openwrt' [scm-protocol] [source] [branch] [revision]" > ${VERSIONS_FILE}
86rev=$(git log | head -n 1 | cut -b8-)
87branch=$(git branch | grep "*" | cut -b3-)
88echo "openwrt git git://projects.qi-hardware.com/openwrt-xburst.git ${branch} ${rev}" >> ${VERSIONS_FILE}
89echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE}
90IFS=$'\n'
91for feed in $feeds; do
92        IFS=' ' arr=(${feed:4})
93        proto=${arr[0]}
94        dir=${arr[1]}
95        url=${arr[2]}
96        if [ "$proto" = "svn" ]; then
97                cd feeds/${arr[1]} && tmp=($(svn info | grep -E "^Revision")) && cd ../../
98                rev=${tmp[1]}
99        fi
100        if [ "$proto" = "git" ]; then
101                cd feeds/${arr[1]} && tmp=($(git log | head -n 1)) && cd ../../
102                rev=${tmp[1]}
103        fi
104        echo "${dir} ${proto} ${rev}" >> ${VERSIONS_FILE}
105done
106
107mkdir -p files/etc
108echo ${DATE} > files/etc/VERSION
109
110mv config .config
111
112yes "" | make oldconfig
113
114echo "starting compiling - this may take several hours..."
115
116time make V=99 > xburst/BUILD_LOG 2>&1
117
118if [ "$?" != "0" ]; then
119    echo "ERROR: Build failed!"
120    echo "Please refer to the log file"
121    exit 1
122fi
123
124git stash pop
125
126cp .config xburst/config
127cp bin/xburst/* xburst/ 2>/dev/null
128mkdir xburst/files
129cp -a files/* xburst/files/
130
131echo "DONE :)"
nanonote-files/data/qi_lb60/scripts/compile-openwrt-xburst.sh
1#!/bin/bash
2DATE=$(date "+%Y-%m-%d")
3TIME=$(date "+%H-%M-%S")
4DATE_TIME=`date +"%m%d%Y-%H%M"`
5
6# this script file is using in build host
7
8# $1: full_system minimal xbboot
9OPENWRT_DIR_NAME="openwrt-xburst."$1
10CONFIG_FILE_TYPE="config."$1
11
12# you may need change those Variables
13BASE_DIR="/home/xiangfu/compile-log/"
14OPENWRT_DIR="/home/xiangfu/${OPENWRT_DIR_NAME}/"
15GET_FEEDS_VERSION_SH="/home/xiangfu/bin/get-feeds-revision.sh"
16
17IMAGE_DIR="${BASE_DIR}/${OPENWRT_DIR_NAME}-${DATE_TIME}/"
18BUILD_LOG="${IMAGE_DIR}/BUILD_LOG"
19VERSIONS_FILE="${IMAGE_DIR}/VERSIONS"
20
21MAKE_VARS=" V=99 IGNORE_ERRORS=m "
22
23########################################################################
24cd ${OPENWRT_DIR}
25
26echo "make distclean ..."
27make distclean
28
29
30echo "updating git repo..."
31git fetch -a
32git reset --hard origin/master
33if [ "$?" != "0" ]; then
34    echo "ERROR: updating openwrt-xburst failed"
35    exit 1
36fi
37
38
39echo "update and install feeds..."
40./scripts/feeds update -a && ./scripts/feeds install -a
41if [ "$?" != "0" ]; then
42    echo "ERROR: update and install feeds failed"
43    exit 1
44fi
45cp feeds/qipackages/nanonote-files/data/qi_lb60/conf/${CONFIG_FILE_TYPE} .config
46sed -i '/CONFIG_ALL/s/.*/CONFIG_ALL=y/' .config
47yes "" | make oldconfig > /dev/null
48
49
50echo "copy files, create VERSION, copy dl folder, last prepare..."
51rm -f files && ln -s feeds/qipackages/nanonote-files/data/qi_lb60/files/
52rm -f dl && ln -s ~/dl
53mkdir -p files/etc && echo ${DATE} > files/etc/VERSION
54
55
56echo "starting compiling - this may take several hours..."
57mkdir -p ${IMAGE_DIR}
58time make ${MAKE_VARS} > ${IMAGE_DIR}/BUILD_LOG 2>&1
59if [ "$?" != "0" ]; then
60    echo "ERROR: Build failed! Please refer to the log file"
61    tail -n 100 ${IMAGE_DIR}/BUILD_LOG > ${IMAGE_DIR}/BUILD_LOG.`date +"%m%d%Y-%H%M"`.last100
62fi
63
64
65echo "getting version numbers of used repositories..."
66${GET_FEEDS_VERSION_SH} ${OPENWRT_DIR} > ${VERSIONS_FILE}
67
68
69echo "copy all files to IMAGE_DIR..."
70cp .config ${IMAGE_DIR}/config
71cp feeds.conf ${IMAGE_DIR}/
72cp -a bin/xburst/* ${IMAGE_DIR} 2>/dev/null
73mkdir -p ${IMAGE_DIR}/files
74cp -a files/* ${IMAGE_DIR}/files/
75
76(cd ${IMAGE_DIR}; \
77 bzip2 -z BUILD_LOG; \
78 bzip2 -z openwrt-xburst-qi_lb60-root.ubi; \
79)
80
81echo "DONE :)"
nanonote-files/data/qi_lb60/scripts/get-feeds-revision.sh
1#!/bin/bash
2
3cd $1
4
5FEEDS_CONF="feeds.conf.default"
6test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
7
8feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
9
10echo "# base :: openwrt [scm-protocol] [source] [branch] [revision]"
11repo=$(git config -l | grep remote.origin.url | cut -d "=" -f 2)
12rev=$(git log | head -n 1 | cut -b8-)
13branch=$(git branch | grep "*" | cut -b3-)
14echo "openwrt git ${repo} ${branch} ${rev}"
15
16echo "# feeds :: [feedname] [scm-protocol] [revision]"
17IFS=$'\n'
18for feed in $feeds; do
19        IFS=' ' arr=(${feed:4})
20        proto=${arr[0]}
21        dir=${arr[1]}
22
23        if [ "$proto" = "svn" ]; then
24                cd feeds/${dir} && rev=`svn info | grep -E "^Revision" | cut -d " " -f2` && cd ../../
25        fi
26        if [ "$proto" = "git" ]; then
27                cd feeds/${dir} && rev=`git log | head -n 1 | cut -d " " -f2` && cd ../../
28        fi
29        if [ "$proto" = "link" ]; then
30                rev=`date "+%Y-%m-%d"`
31        fi
32
33        echo "${dir} ${proto} ${rev}"
34done

Archive Download the corresponding diff file



interactive