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="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 :)"
132

Archive Download this file



interactive