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