Root/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="feeds.conf.default"
14test -f "feeds.conf" && FEEDS_CONF="feeds.conf"
15
16if [ "${0}" != "./scripts/build" ]; then
17    echo "Please call me that way: ./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 checkout tracking_backfire
64git pull > /dev/null
65if [ "$?" != "0" ]; then
66    echo "ERROR: updating openwrt-xburst failed"
67    exit 1
68fi
69
70echo "updating feeds..."
71scripts/feeds update -a > /dev/null 2>&1
72if [ "$?" != "0" ]; then
73    echo "ERROR: updating feeds failed"
74    exit 1
75fi
76echo "installing feeds..."
77scripts/feeds install -a > /dev/null 2>&1
78if [ "$?" != "0" ]; then
79    echo "ERROR: installing feeds failed"
80    exit 1
81fi
82
83echo "getting version numbers of used repositories..."
84feeds="$(cat "${FEEDS_CONF}" | grep -v -E "^#")"
85VERSIONS_FILE="xburst/VERSIONS"
86echo "# base :: 'openwrt' [scm-protocol] [revision] [source] [branch]" > ${VERSIONS_FILE}
87tmp=($(git show-ref | head -n 1))
88rev=${tmp[0]}
89echo "openwrt git ${rev} git://projects.qi-hardware.com/openwrt-xburst.git tracking_backfire" >> ${VERSIONS_FILE}
90echo "# feeds :: [feedname] [scm-protocol] [revision]" >> ${VERSIONS_FILE}
91IFS=$'\n'
92for feed in $feeds; do
93        IFS=' ' arr=(${feed:4})
94        proto=${arr[0]}
95        dir=${arr[1]}
96        url=${arr[2]}
97        if [ "$proto" = "svn" ]; then
98                cd feeds/${arr[1]} && tmp=($(svn info | grep -E "^Revision")) && cd ../../
99                rev=${tmp[1]}
100        fi
101        if [ "$proto" = "git" ]; then
102                cd feeds/${arr[1]} && tmp=($(git show-ref | head -n 1)) && cd ../../
103                rev=${tmp[0]}
104        fi
105        echo "${dir} ${proto} ${rev}" >> ${VERSIONS_FILE}
106done
107
108mkdir -p files/etc
109echo ${DATE} > files/etc/VERSION
110
111mv config .config
112
113yes "" | make oldconfig
114
115echo "starting compiling - this may take several hours..."
116
117time make V=99 > xburst/BUILD_LOG 2>&1
118
119if [ "$?" != "0" ]; then
120    echo "ERROR: Build failed!"
121    echo "Please refer to the log file"
122    exit 1
123fi
124
125git stash pop
126
127cp .config xburst/config
128cp bin/xburst/* xburst/ 2>/dev/null
129mkdir xburst/files
130cp -a files/* xburst/files/
131
132echo "DONE :)"
133

Archive Download this file



interactive