-
Notifications
You must be signed in to change notification settings - Fork 6
/
makepackages
executable file
·131 lines (118 loc) · 3.55 KB
/
makepackages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
#
# makepackages - stupid script for lazy people which compiles certain packages
# Original Copyright (C) 2012 Philipp Psurek <[email protected]>
# Modified by Cyrus ([email protected])
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
rootdir=$(pwd)
feeds="ffadvgit ffadv"
targets="ar71xx"
config="all"
make_package(){
local package=$1
local feed=$2
echo "Make package $package from feed $feed"
cd ${rootdir}/openwrt/attitude_adjustment && make package/feeds/${feed}/${package}/compile
}
install_feeds(){
for feed in $feeds
do
cat ${rootdir}/openwrt/attitude_adjustment/feeds.conf.default ${rootdir}/feeds.conf > ${rootdir}/openwrt/attitude_adjustment/feeds.conf
cd ${rootdir}/openwrt/attitude_adjustment && ./scripts/feeds update ${feed}
for type in $config
do
grep -v -e "^#" -e "^$" ${rootdir}/config/packages/${config} \
| while read package feed; do
cd ${rootdir}/openwrt/attitude_adjustment
[ ! -e ${rootdir}/openwrt/attitude_adjustment/package/feeds/${feed} ] \
&& ./scripts/feeds install -p ${feed} ${package}
done
done
done
}
build_packages(){
local arch=$1
echo "Building config file(s) $config for arch $arch"
grep -v -e "^#" -e "^$" ${rootdir}/config/packages/${config} \
| while read package feed; do
make_package $package $feed
move_package $package $arch
done
}
generate_config(){
local arch=$1
cd ${rootdir}
./genconfig ${arch} > openwrt/attitude_adjustment/.config
cd ${rootdir}/openwrt/attitude_adjustment && while true; do echo; done \
| make oldconfig >/dev/null
}
move_package(){
local package=$1
local arch=$2
echo "Move package $package for arch $arch"
[[ ! -d ${rootdir}/packages/${arch} ]] && mkdir -p ${rootdir}/packages/${arch}
rm -f ${rootdir}/packages/${arch}/${package}*
mv ${rootdir}/openwrt/attitude_adjustment/bin/${arch}/packages/${package}* ${rootdir}/packages/${arch}/
}
index_packages(){
local arch=$1
local pkg_dir=${rootdir}/packages/${arch}/
cd $pkg_dir
rm -f md5sums Packages Packages.gz
md5sum * > md5sums
${rootdir}/openwrt/attitude_adjustment/scripts/ipkg-make-index.sh . > Packages
cat Packages | gzip > Packages.gz
cd ${rootdir}
}
fail() {
echo "$1" 1>&2
exit 1
}
printArgs () {
fail "Usage:
makepackage
build [config] : build packages
If no config is supplied the 'all'
config will be used
build_index : build package index & md5sums
install_packages [config] : install packages from feeds
"
}
[ $# -lt 1 ] && printArgs
[ ! -e ${rootdir}/openwrt/attitude_adjustment/package/feeds/ffadvgit ] && install_feeds
case "$1" in
build)
[ $# -gt 1 ] && config=$2
for arch in $targets
do
generate_config $arch
build_packages $arch
index_packages $arch
done
;;
build_index)
[ $# -gt 1 ] && config=$2
for arch in $targets
do
index_packages $arch
done
;;
install_packages)
[ $# -gt 1 ] && config=$2
install_feeds $config
;;
*)
printArgs
esac