rev |
line source |
pankso@1
|
1 #!/bin/sh
|
pankso@1
|
2 #
|
pankso@1
|
3 # Cook - A tool to cook and generate SliTaz packages. Read the README
|
paul@647
|
4 # before adding or modifying any code in cook!
|
pankso@1
|
5 #
|
pankso@1
|
6 # Copyright (C) SliTaz GNU/Linux - GNU gpl v3
|
pankso@1
|
7 # Author: Christophe Lincoln <pankso@slitaz.org>
|
pankso@1
|
8 #
|
pankso@422
|
9 . /usr/lib/slitaz/libcook.sh
|
pankso@1
|
10
|
pankso@633
|
11 VERSION="3.2"
|
al@596
|
12
|
al@596
|
13 # Internationalization.
|
al@596
|
14 . /usr/bin/gettext.sh
|
al@596
|
15 TEXTDOMAIN='cook'
|
al@596
|
16 export TEXTDOMAIN
|
al@596
|
17
|
al@596
|
18 _() echo -e "$(eval_gettext "$1")"
|
al@596
|
19 _n() echo -en "$(eval_gettext "$1")"
|
al@596
|
20 # to disable i18n:
|
al@596
|
21 # _() echo -e "$1"
|
al@596
|
22 # _n() echo -en "$1"
|
al@596
|
23
|
al@596
|
24
|
pankso@1
|
25 #
|
pankso@1
|
26 # Functions
|
pankso@1
|
27 #
|
pankso@1
|
28
|
pankso@1
|
29 usage() {
|
pankso@1
|
30 cat << EOT
|
pankso@1
|
31
|
al@596
|
32 $(_ "\033[1mUsage:\033[0m cook [package|command] [list|--option]")
|
pankso@1
|
33
|
al@596
|
34 $(_ "\033[1mCommands:\033[0m")
|
al@596
|
35 usage|help $(_ "Display this short usage.")
|
al@596
|
36 setup $(_ "Setup your build environment.")
|
al@596
|
37 *-setup $(_ "Setup a cross environment.")
|
al@596
|
38 test $(_ "Test environment and cook a package.")
|
al@596
|
39 list-wok $(_ "List packages in the wok.")
|
al@596
|
40 search $(_ "Simple packages search function.")
|
al@596
|
41 new $(_ "Create a new package with a receipt.")
|
al@596
|
42 list $(_ "Cook a list of packages.")
|
al@596
|
43 clean-wok $(_ "Clean-up all packages files.")
|
al@596
|
44 clean-src $(_ "Clean-up all packages sources.")
|
pankso@662
|
45 uncook $(_ "Check for uncooked packages")
|
al@596
|
46 pkgdb $(_ "Create packages DB lists and flavors.")
|
pankso@1
|
47
|
al@596
|
48 $(_ "\033[1mOptions:\033[0m")
|
al@596
|
49 --clean|-c Cook : $(_ "clean the package in the wok.")
|
al@596
|
50 --install|-i Cook : $(_ "cook and install the package.")
|
al@596
|
51 --getsrc|-gs Cook : $(_ "get the package source tarball.")
|
al@596
|
52 --block|-b Cook : $(_ "block a package so cook will skip it.")
|
al@596
|
53 --unblock|-ub Cook : $(_ "unblock a blocked package.")
|
al@598
|
54 --cdeps Cook : $(_ "check dependencies of cooked package.")
|
al@596
|
55 --pack Cook : $(_ "repack an already built package.")
|
pankso@662
|
56 --debug Cook : $(_ "display debugging messages.")
|
pankso@668
|
57 --continue Cook : $(_ "continue running compile_rules.")
|
al@596
|
58 --interactive|-x New : $(_ "create a receipt interactively.")
|
al@596
|
59 --wok Setup: $(_ "clone the cooking wok from Hg repo.")
|
al@596
|
60 --stable Setup: $(_ "clone the stable wok from Hg repo.")
|
al@596
|
61 --undigest Setup: $(_ "clone the undigest wok from Hg repo.")
|
al@596
|
62 --tiny Setup: $(_ "clone the tiny SliTaz wok from Hg repo.")
|
al@596
|
63 --forced Setup: $(_ "force reinstall of chroot packages.")
|
al@596
|
64 --flavors Pkgdb: $(_ "create up-to-date flavors files.")
|
pankso@1
|
65
|
pankso@1
|
66 EOT
|
pankso@1
|
67 exit 0
|
pankso@1
|
68 }
|
pankso@1
|
69
|
paul@62
|
70 # We don't want these escapes in web interface.
|
pankso@1
|
71 clean_log() {
|
pankso@1
|
72 sed -i -e s'|\[70G\[ \[1;32m| |' \
|
pankso@1
|
73 -e s'|\[0;39m \]||' $LOGS/$pkg.log
|
pankso@1
|
74 }
|
pankso@1
|
75
|
paul@62
|
76 # Be sure package exists in wok.
|
pankso@1
|
77 check_pkg_in_wok() {
|
pankso@1
|
78 if [ ! -d "$WOK/$pkg" ]; then
|
al@596
|
79 newline; _ "Unable to find package in the wok: \$pkg"; newline
|
al@596
|
80 exit 1
|
pankso@1
|
81 fi
|
pankso@1
|
82 }
|
pankso@1
|
83
|
pankso@9
|
84 if_empty_value() {
|
pankso@9
|
85 if [ -z "$value" ]; then
|
al@596
|
86 # L10n: QA is quality assurance
|
al@596
|
87 _ "QA: empty variable: \${var}=\"\""; newline
|
pankso@9
|
88 exit 1
|
pankso@9
|
89 fi
|
pankso@9
|
90 }
|
pankso@9
|
91
|
paul@62
|
92 # Initialize files used in $CACHE
|
pankso@52
|
93 init_db_files() {
|
al@596
|
94 _ "Creating directories structure in: \$SLITAZ"
|
xfred222@559
|
95 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
|
al@596
|
96 _ "Creating DB files in: \$CACHE"
|
pankso@52
|
97 for f in $activity $command $broken $blocked
|
pankso@52
|
98 do
|
pankso@52
|
99 touch $f
|
pankso@52
|
100 done
|
pankso@52
|
101 }
|
pankso@52
|
102
|
paul@62
|
103 # QA: check a receipt consistency before building.
|
pankso@9
|
104 receipt_quality() {
|
al@596
|
105 _ "QA: checking package receipt..."
|
pankso@9
|
106 unset online
|
pankso@9
|
107 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
|
pankso@9
|
108 online="online"
|
pankso@9
|
109 fi
|
pankso@9
|
110 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
|
pankso@9
|
111 do
|
pankso@9
|
112 unset value
|
pascal@279
|
113 value="$(. $receipt ; eval echo \$$var)"
|
pankso@9
|
114 case "$var" in
|
pankso@9
|
115 PACKAGE|VERSION|SHORT_DESC)
|
pankso@9
|
116 if_empty_value ;;
|
pankso@9
|
117 CATEGORY)
|
pankso@9
|
118 [ -z "$value" ] && value="empty"
|
al@596
|
119 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
|
pankso@9
|
120 if ! echo "$valid" | grep -q -w "$value"; then
|
al@596
|
121 _ "QA: unknown category: \$value"
|
al@596
|
122 _ "Please, use one of: \$valid" | busybox fold -s
|
al@596
|
123 newline; exit 1
|
pankso@9
|
124 fi ;;
|
pankso@9
|
125 WEB_SITE)
|
paul@62
|
126 # We don't check WGET_URL since if dl is needed it will fail.
|
paul@62
|
127 # Break also if we're not online. Here error is not fatal.
|
pankso@9
|
128 if_empty_value
|
pankso@9
|
129 [ -z "$online" ] || break
|
pankso@199
|
130 if ! busybox wget -T 12 -s $value 2>/dev/null; then
|
al@596
|
131 _ "QA: unable to reach: \$value"
|
pankso@9
|
132 fi ;;
|
pankso@9
|
133 esac
|
pankso@9
|
134 done
|
pankso@9
|
135 }
|
pankso@9
|
136
|
paul@62
|
137 # Paths used in receipt and by cook itself.
|
pankso@1
|
138 set_paths() {
|
pankso@1
|
139 pkgdir=$WOK/$PACKAGE
|
slaxemulator@492
|
140 basesrc=$pkgdir/source
|
slaxemulator@492
|
141 tmpsrc=$basesrc/tmp
|
slaxemulator@492
|
142 src=$basesrc/$PACKAGE-$VERSION
|
pankso@44
|
143 taz=$pkgdir/taz
|
pankso@44
|
144 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
|
pankso@1
|
145 fs=$pack/fs
|
pankso@1
|
146 stuff=$pkgdir/stuff
|
pankso@1
|
147 install=$pkgdir/install
|
slaxemulator@492
|
148 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
|
slaxemulator@492
|
149 lzma_tarball="$pkgsrc.tar.lzma"
|
slaxemulator@492
|
150 if [ "$PATCH" ]; then
|
slaxemulator@492
|
151 [ "${PTARBALL}" ] || PTARBALL="$(basename $PATCH)"
|
slaxemulator@492
|
152 fi
|
pankso@1
|
153 if [ "$WANTED" ]; then
|
slaxemulator@492
|
154 basesrc=$WOK/$WANTED/source
|
slaxemulator@492
|
155 src=$basesrc/$WANTED-$VERSION
|
slaxemulator@492
|
156 install=$WOK/$WANTED/install
|
slaxemulator@492
|
157 wanted_stuff=$WOK/$WANTED/stuff
|
pankso@1
|
158 fi
|
slaxemulator@456
|
159 if [ "$SOURCE" ]; then
|
slaxemulator@456
|
160 source_stuff=$WOK/$SOURCE/stuff
|
slaxemulator@456
|
161 fi
|
mojo@620
|
162 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
|
slaxemulator@492
|
163 if [ -f "$WOK/linux/receipt" ]; then
|
slaxemulator@492
|
164 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d '"' -f 2)
|
slaxemulator@492
|
165 kbasevers=${kvers:0:3}
|
mojo@620
|
166 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
|
mojo@620
|
167 kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d '"' -f 2)
|
mojo@620
|
168 kbasevers=${kvers:0:3}
|
pankso@662
|
169 fi
|
pankso@662
|
170 # Python version
|
slaxemulator@492
|
171 if [ -f "$WOK/python/receipt" ]; then
|
slaxemulator@492
|
172 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d '"' -f 2)
|
slaxemulator@492
|
173 fi
|
slaxemulator@492
|
174 # perl version for some packages needed it
|
slaxemulator@492
|
175 if [ -f "$WOK/perl/receipt" ]; then
|
slaxemulator@492
|
176 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d '"' -f 2)
|
pankso@232
|
177 fi
|
pankso@9
|
178 # Old way compatibility.
|
pankso@1
|
179 _pkg=$install
|
pankso@1
|
180 }
|
pankso@1
|
181
|
pankso@144
|
182 # Create source tarball when URL is a SCM.
|
pankso@144
|
183 create_tarball() {
|
slaxemulator@498
|
184 local tarball
|
slaxemulator@498
|
185 tarball=$pkgsrc.tar.bz2
|
slaxemulator@498
|
186 [ "$LZMA_SRC" ] && tarball=$lzma_tarball
|
al@596
|
187 _ "Creating tarball: \$tarball"
|
pankso@162
|
188 if [ "$LZMA_SRC" ]; then
|
slaxemulator@498
|
189 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
|
slaxemulator@498
|
190 LZMA_SRC=""
|
pankso@162
|
191 else
|
pankso@162
|
192 tar cjf $tarball $pkgsrc || exit 1
|
pankso@162
|
193 mv $tarball $SRC && rm -rf $pkgsrc
|
pankso@162
|
194 fi
|
slaxemulator@498
|
195 TARBALL=$tarball
|
pankso@144
|
196 }
|
pankso@144
|
197
|
pankso@145
|
198 # Get package source. For SCM we are in cache so clone here and create a
|
pankso@145
|
199 # tarball here.
|
pankso@1
|
200 get_source() {
|
pascal@610
|
201 local url
|
pascal@610
|
202 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
|
ernia@571
|
203 set_paths
|
pankso@115
|
204 pwd=$(pwd)
|
pankso@9
|
205 case "$WGET_URL" in
|
pankso@145
|
206 http://*|ftp://*)
|
pankso@9
|
207 # Busybox Wget is better!
|
pascal@268
|
208 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
|
pascal@610
|
209 busybox wget -T 60 -c -O $SRC/$TARBALL $url || \
|
al@596
|
210 (_ "ERROR: wget \$WGET_URL" && exit 1) ;;
|
pankso@145
|
211 https://*)
|
pankso@250
|
212 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
|
pascal@610
|
213 busybox wget -T 60 -c -O $SRC/$TARBALL $url || \
|
al@596
|
214 (_ "ERROR: wget \$WGET_URL" && exit 1) ;;
|
pankso@9
|
215 hg*|mercurial*)
|
pankso@29
|
216 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
|
pankso@9
|
217 url=${WGET_URL#hg|}
|
pankso@9
|
218 else
|
pankso@9
|
219 url=${WGET_URL#mercurial|}
|
pankso@9
|
220 fi
|
al@596
|
221 _ "Getting source from Hg..."
|
al@596
|
222 _ "URL: \$url"
|
al@596
|
223 _ "Cloning to: \$pwd/\$pkgsrc"
|
pankso@246
|
224 if [ "$BRANCH" ]; then
|
al@596
|
225 _ "Hg branch: \$BRANCH"
|
pankso@246
|
226 hg clone $url --rev $BRANCH $pkgsrc || \
|
al@596
|
227 (_ "ERROR: hg clone \$url --rev \$BRANCH" && exit 1)
|
pankso@246
|
228 else
|
al@596
|
229 hg clone $url $pkgsrc || (_ "ERROR: hg clone \$url" && exit 1)
|
pankso@246
|
230 fi
|
pankso@255
|
231 rm -rf $pkgsrc/.hg
|
pankso@144
|
232 create_tarball ;;
|
pankso@9
|
233 git*)
|
pankso@61
|
234 url=${WGET_URL#git|}
|
al@596
|
235 _ "Getting source from Git..."
|
al@596
|
236 _ "URL: \$url"
|
al@688
|
237 cd $SRC
|
al@596
|
238 git clone $url $pkgsrc || (_ "ERROR: git clone \$url" && exit 1)
|
pankso@63
|
239 if [ "$BRANCH" ]; then
|
al@596
|
240 _ "Git branch: \$BRANCH"
|
pankso@358
|
241 cd $pkgsrc && git checkout $BRANCH && cd ..
|
pankso@63
|
242 fi
|
al@688
|
243 cd $SRC
|
pankso@144
|
244 create_tarball ;;
|
pankso@144
|
245 cvs*)
|
pankso@144
|
246 url=${WGET_URL#cvs|}
|
pankso@144
|
247 mod=$PACKAGE
|
pankso@144
|
248 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
|
al@596
|
249 _ "Getting source from CVS..."
|
al@596
|
250 _ "URL: \$url"
|
al@596
|
251 [ "$CVS_MODULE" ] && _ "CVS module: \$mod"
|
al@596
|
252 _ "Cloning to: \$pwd/\$mod"
|
pankso@144
|
253 cvs -d:$url co $mod && mv $mod $pkgsrc
|
pankso@144
|
254 create_tarball ;;
|
pankso@69
|
255 svn*|subversion*)
|
pankso@159
|
256 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
|
pankso@146
|
257 url=${WGET_URL#svn|}
|
pankso@146
|
258 else
|
pankso@146
|
259 url=${WGET_URL#subversion|}
|
pankso@146
|
260 fi
|
al@596
|
261 _ "Getting source from SVN..."
|
al@596
|
262 _ "URL: \$url"
|
pankso@161
|
263 if [ "$BRANCH" ]; then
|
pankso@161
|
264 echo t | svn co $url -r $BRANCH $pkgsrc
|
pankso@161
|
265 else
|
pankso@161
|
266 echo t | svn co $url $pkgsrc
|
pankso@161
|
267 fi
|
pankso@146
|
268 create_tarball ;;
|
al@590
|
269 bzr*)
|
al@590
|
270 url=${WGET_URL#bzr|}
|
al@596
|
271 _ "Getting source from bazaar..."
|
al@590
|
272 cd $SRC
|
al@590
|
273 pkgsrc=${url#*:}
|
al@590
|
274 if [ "$BRANCH" ]; then
|
al@590
|
275 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
|
al@590
|
276 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
|
al@590
|
277 else
|
al@590
|
278 echo "bzr -Ossl.cert_reqs=none branch $url"
|
al@590
|
279 bzr -Ossl.cert_reqs=none branch $url
|
al@590
|
280 cd $pkgsrc && BRANCH=$(bzr revno) && cd ..
|
al@596
|
281 _ "Don't forget to add to receipt:"
|
al@596
|
282 echo 'BRANCH="'$BRANCH'"'; newline
|
al@590
|
283 fi
|
al@590
|
284 mv $pkgsrc $pkgsrc-$BRANCH
|
al@590
|
285 pkgsrc=$pkgsrc-$BRANCH
|
al@590
|
286 create_tarball ;;
|
pankso@9
|
287 *)
|
al@596
|
288 (newline; _ "ERROR: Unable to handle: \$WGET_URL"; newline) | \
|
pankso@9
|
289 tee -a $LOGS/$PACKAGE.log
|
pankso@9
|
290 exit 1 ;;
|
pankso@9
|
291 esac
|
pankso@1
|
292 }
|
pankso@1
|
293
|
pankso@9
|
294 # Extract source package.
|
pankso@1
|
295 extract_source() {
|
pankso@177
|
296 if [ ! -s "$SRC/$TARBALL" ]; then
|
pankso@177
|
297 local url
|
slaxemulator@458
|
298 url="$MIRROR_URL/sources/packages"
|
pankso@177
|
299 url=$url/${TARBALL:0:1}/$TARBALL
|
al@596
|
300 _ "Getting source from mirror: \$url"
|
al@596
|
301 busybox wget -c -P $SRC $url || _ "ERROR: wget \$url"
|
pankso@177
|
302 fi
|
al@596
|
303 _ "Extracting: \$TARBALL"
|
pankso@1
|
304 case "$TARBALL" in
|
pankso@120
|
305 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@178
|
306 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@1
|
307 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
|
pascal@698
|
308 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar xf - 2>/dev/null ;;
|
pankso@42
|
309 *.tar) tar xf $SRC/$TARBALL ;;
|
pankso@42
|
310 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
|
pascal@597
|
311 *.xz) unxz -c $SRC/$TARBALL | tar xf - || tar xf $SRC/$TARBALL 2>/dev/null;;
|
pascal@673
|
312 *.7z) 7zr x $SRC/$TARBALL ;;
|
pankso@42
|
313 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
314 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
|
pankso@238
|
315 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
|
pankso@191
|
316 *) cp $SRC/$TARBALL $(pwd) ;;
|
pankso@1
|
317 esac
|
pankso@1
|
318 }
|
pankso@1
|
319
|
pankso@9
|
320 # Display cooked package summary.
|
pankso@1
|
321 summary() {
|
pankso@1
|
322 cd $WOK/$pkg
|
slaxemulator@499
|
323 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
|
slaxemulator@499
|
324 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
|
slaxemulator@499
|
325 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}')
|
pankso@44
|
326 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
|
slaxemulator@499
|
327 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
|
slaxemulator@499
|
328 [ "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
|
al@596
|
329 cookdate=$(date "$(_ '+%Y-%m-%d %H:%M')")
|
pankso@101
|
330 sec=$time
|
pascal@280
|
331 div=$(( ($time + 30) / 60))
|
al@596
|
332 # L10n: 'm' is for minutes (approximate cooking time)
|
al@596
|
333 min=$(_n "~ \${div}m"); [ "$div" = 0 ] && min=""
|
al@596
|
334 _ "Summary for: \$PACKAGE \$VERSION"
|
pankso@1
|
335 separator
|
al@596
|
336 # L10n: keep the same width of translations to get a consistent view
|
al@596
|
337 [ "$srcdir" ] && _ "Source dir : \$srcdir"
|
al@596
|
338 [ "$TARBALL" ] && _ "Src file : \$TARBALL"
|
al@596
|
339 [ "$srcsize" ] && _ "Src size : \$srcsize"
|
al@596
|
340 [ "$prod" ] && _ "Produced : \$prod"
|
al@596
|
341 _ "Packed : \$fs"
|
al@596
|
342 _ "Compressed : \$size"
|
al@596
|
343 _ "Files : \$files"
|
al@596
|
344 # L10n: 's' is for seconds (cooking time)
|
al@596
|
345 _ "Cook time : \${sec}s \$min"
|
al@596
|
346 _ "Cook date : \$cookdate"
|
al@596
|
347 _ "Host arch : \$ARCH"
|
al@596
|
348 separator
|
pankso@1
|
349 }
|
pankso@1
|
350
|
paul@62
|
351 # Display debugging error info.
|
pankso@15
|
352 debug_info() {
|
al@596
|
353 newline; _ "Debug information"; separator
|
al@596
|
354 # L10n: specify your format of date and time (to help: man date)
|
al@596
|
355 # L10n: not bad one is '+%x %R'
|
al@596
|
356 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
|
al@596
|
357 _ "Cook date: \$datenow"
|
al@596
|
358 # L10n: Please, translate all messages beginning with ERROR in a same way
|
al@596
|
359 lerror=$(_n "ERROR")
|
pankso@76
|
360 for error in \
|
pascal@617
|
361 ERROR $lerror "No package" "cp: can't" "can't open" "can't cd" \
|
pascal@473
|
362 "error:" "fatal error:" "undefined reference to" \
|
pascal@508
|
363 "Unable to connect to" "link: cannot find the library" \
|
pascal@615
|
364 "CMake Error" ": No such file or directory"
|
pankso@34
|
365 do
|
pankso@34
|
366 fgrep "$error" $LOGS/$pkg.log
|
pascal@625
|
367 done > $LOGS/$pkg.log.debug_info 2>&1
|
pascal@625
|
368 cat $LOGS/$pkg.log.debug_info
|
pascal@625
|
369 rm -f $LOGS/$pkg.log.debug_info
|
al@596
|
370 separator; newline
|
pankso@15
|
371 }
|
pankso@15
|
372
|
pankso@1
|
373 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
|
pankso@1
|
374 # so some packages need to copy these files with the receipt and genpkg_rules.
|
slaxemulator@500
|
375 copy_generic_files()
|
slaxemulator@500
|
376 {
|
pankso@1
|
377 # $LOCALE is set in cook.conf
|
slaxemulator@500
|
378 if [ "$LOCALE" -a "$WANTED" = "" ]; then
|
pankso@260
|
379 if [ -d "$install/usr/share/locale" ]; then
|
pankso@1
|
380 mkdir -p $fs/usr/share/locale
|
pankso@1
|
381 for i in $LOCALE
|
pankso@1
|
382 do
|
pankso@260
|
383 if [ -d "$install/usr/share/locale/$i" ]; then
|
pankso@260
|
384 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
|
pankso@1
|
385 fi
|
pankso@1
|
386 done
|
pankso@1
|
387 fi
|
pankso@1
|
388 fi
|
pankso@1
|
389
|
pankso@1
|
390 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
|
pankso@1
|
391 if [ "$GENERIC_PIXMAPS" != "no" ]; then
|
pankso@260
|
392 if [ -d "$install/usr/share/pixmaps" ]; then
|
pankso@1
|
393 mkdir -p $fs/usr/share/pixmaps
|
slaxemulator@500
|
394 if [ -f "$install/usr/share/pixmaps/$PACKAGE.png" ]; then
|
slaxemulator@500
|
395 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
|
slaxemulator@500
|
396 $fs/usr/share/pixmaps
|
slaxemulator@500
|
397 elif [ -f "$install/usr/share/pixmaps/$PACKAGE.xpm" ]; then
|
slaxemulator@500
|
398 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
|
slaxemulator@500
|
399 $fs/usr/share/pixmaps
|
slaxemulator@500
|
400 fi
|
pankso@1
|
401 fi
|
pankso@1
|
402
|
pankso@1
|
403 # Custom or homemade PNG pixmap can be in stuff.
|
pankso@1
|
404 if [ -f "$stuff/$PACKAGE.png" ]; then
|
pankso@1
|
405 mkdir -p $fs/usr/share/pixmaps
|
pankso@1
|
406 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@1
|
407 fi
|
pankso@1
|
408 fi
|
pankso@1
|
409
|
pankso@1
|
410 # Desktop entry (.desktop).
|
erjo@284
|
411 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
|
erjo@284
|
412 if [ "$GENERIC_MENUS" != "no" ]; then
|
erjo@284
|
413 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
|
slaxemulator@500
|
414 mkdir -p $fs/usr/share
|
erjo@284
|
415 cp -a $install/usr/share/applications $fs/usr/share
|
erjo@284
|
416 fi
|
pankso@1
|
417 fi
|
pankso@1
|
418
|
pankso@1
|
419 # Homemade desktop file(s) can be in stuff.
|
pankso@1
|
420 if [ -d "$stuff/applications" ]; then
|
pankso@1
|
421 mkdir -p $fs/usr/share
|
pankso@1
|
422 cp -a $stuff/applications $fs/usr/share
|
pankso@1
|
423 fi
|
pankso@1
|
424 if [ -f "$stuff/$PACKAGE.desktop" ]; then
|
pankso@1
|
425 mkdir -p $fs/usr/share/applications
|
pankso@1
|
426 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@1
|
427 fi
|
pankso@662
|
428
|
slaxemulator@500
|
429 # Add custom licenses
|
slaxemulator@500
|
430 if [ -d "$stuff/licenses" ]; then
|
slaxemulator@500
|
431 mkdir -p $fs/usr/share/licenses
|
slaxemulator@500
|
432 cp -a $stuff/licenses $fs/usr/share/licenses/$PACKAGE
|
slaxemulator@500
|
433 fi
|
pankso@1
|
434 }
|
pankso@1
|
435
|
al@596
|
436 # Find and strip: --strip-all (-s) or --strip-debug on static libs as well
|
paul@647
|
437 # as removing unneeded files like in Python packages. Cross compiled binaries
|
pankso@415
|
438 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
|
pankso@421
|
439 strip_package() {
|
pankso@415
|
440 case "$ARCH" in
|
pankso@676
|
441 arm*|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
|
pankso@415
|
442 *) export STRIP=strip ;;
|
pankso@415
|
443 esac
|
al@596
|
444 _n "Executing strip on all files..."
|
pankso@1
|
445 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
|
pankso@1
|
446 do
|
pankso@1
|
447 if [ -d "$dir" ]; then
|
pankso@414
|
448 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@1
|
449 fi
|
pankso@1
|
450 done
|
pankso@414
|
451 find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@414
|
452 find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
|
pankso@1
|
453 status
|
pankso@67
|
454
|
pankso@117
|
455 # Remove Python .pyc and .pyo from packages.
|
pankso@150
|
456 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
|
al@596
|
457 _n "Removing Python compiled files..."
|
pankso@67
|
458 find $fs -type f -name "*.pyc" -delete 2>/dev/null
|
pankso@67
|
459 find $fs -type f -name "*.pyo" -delete 2>/dev/null
|
pankso@117
|
460 status
|
pankso@117
|
461 fi
|
pankso@117
|
462
|
pankso@117
|
463 # Remove Perl perllocal.pod and .packlist from packages.
|
pankso@117
|
464 if echo "$DEPENDS" | fgrep -q "perl"; then
|
al@596
|
465 _n "Removing Perl compiled files..."
|
pankso@67
|
466 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
|
pankso@67
|
467 find $fs -type f -name ".packlist" -delete 2>/dev/null
|
pankso@67
|
468 status
|
pankso@67
|
469 fi
|
pankso@1
|
470 }
|
pankso@1
|
471
|
pankso@8
|
472 # Remove installed deps.
|
pankso@8
|
473 remove_deps() {
|
pankso@8
|
474 # Now remove installed build deps.
|
pascal@609
|
475 diff="/tmp/installed.cook.diff"
|
pascal@609
|
476 if [ -s $diff ]; then
|
pankso@113
|
477 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
|
pankso@113
|
478 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
|
al@596
|
479 _n "Build dependencies to remove: "; echo $nb $root
|
al@596
|
480 _n "Removing:"
|
pankso@8
|
481 for dep in $deps
|
pankso@8
|
482 do
|
pankso@8
|
483 echo -n " $dep"
|
pankso@426
|
484 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
|
pankso@8
|
485 done
|
al@596
|
486 newline; newline
|
pankso@113
|
487 # Keep the last diff for debug and info.
|
pascal@609
|
488 mv -f $diff $CACHE/installed.diff
|
pankso@1
|
489 fi
|
pankso@1
|
490 }
|
pankso@1
|
491
|
pankso@1
|
492 # The main cook function.
|
pankso@1
|
493 cookit() {
|
al@596
|
494 _ "Cook: \$PACKAGE \$VERSION"; separator
|
pankso@1
|
495 set_paths
|
pankso@359
|
496
|
pankso@377
|
497 # Handle cross-tools.
|
pankso@359
|
498 case "$ARCH" in
|
pankso@675
|
499 arm*|x86_64)
|
paul@387
|
500 # CROSS_COMPILE is used by at least Busybox and the kernel to set
|
al@596
|
501 # the cross-tools prefix. Sysroot is the root of our target arch
|
pankso@443
|
502 sysroot=$CROSS_TREE/sysroot
|
pankso@443
|
503 tools=$CROSS_TREE/tools
|
pankso@443
|
504 # Set root path when cross compiling. ARM tested but not x86_64
|
pankso@443
|
505 # When cross compiling we must install build deps in $sysroot.
|
pankso@443
|
506 arch="-${ARCH}"
|
pankso@443
|
507 root=$sysroot
|
al@596
|
508 _ "\$ARCH sysroot: \$sysroot"
|
al@596
|
509 _ "Adding \$tools/bin to PATH"
|
pankso@443
|
510 export PATH=$PATH:$tools/bin
|
pankso@446
|
511 export PKG_CONFIG_PATH=$sysroot/usr/lib/pkgconfig
|
pankso@421
|
512 export CROSS_COMPILE=${HOST_SYSTEM}-
|
al@596
|
513 _ "Using cross-tools: \$CROSS_COMPILE"
|
pankso@438
|
514 if [ "$ARCH" == "x86_64" ]; then
|
pankso@438
|
515 export CC="${HOST_SYSTEM}-gcc -m64"
|
pankso@438
|
516 export CXX="${HOST_SYSTEM}-g++ -m64"
|
pankso@438
|
517 else
|
pankso@438
|
518 export CC=${HOST_SYSTEM}-gcc
|
pankso@438
|
519 export CXX=${HOST_SYSTEM}-g++
|
pankso@438
|
520 fi
|
pankso@377
|
521 export AR=${HOST_SYSTEM}-ar
|
pankso@377
|
522 export AS=${HOST_SYSTEM}-as
|
pankso@377
|
523 export RANLIB=${HOST_SYSTEM}-ranlib
|
pankso@377
|
524 export LD=${HOST_SYSTEM}-ld
|
pankso@667
|
525 export STRIP=${HOST_SYSTEM}-strip
|
pankso@667
|
526 export LIBTOOL=${HOST_SYSTEM}-libtool ;;
|
pankso@359
|
527 esac
|
pankso@359
|
528
|
pankso@9
|
529 [ "$QA" ] && receipt_quality
|
pankso@44
|
530 cd $pkgdir
|
pankso@668
|
531 [ "$continue" ] || rm -rf source 2> /dev/null
|
pankso@668
|
532 rm -rf install taz 2> /dev/null
|
pankso@1
|
533
|
pankso@1
|
534 # Disable -pipe if less than 512Mb free RAM.
|
pankso@1
|
535 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
|
pankso@1
|
536 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
|
pankso@668
|
537 _ "Disabling -pipe compile flag: \$free RAM"
|
pankso@668
|
538 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
|
pankso@668
|
539 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
|
pankso@1
|
540 fi
|
pankso@1
|
541 unset free
|
pankso@1
|
542
|
pankso@232
|
543 # Export flags and path to be used by make and receipt.
|
pankso@44
|
544 DESTDIR=$pkgdir/install
|
al@596
|
545 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
|
pankso@232
|
546 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
|
pankso@358
|
547 #LDFLAGS
|
pankso@1
|
548
|
pankso@126
|
549 # Check for build deps and handle implicit depends of *-dev packages
|
pankso@126
|
550 # (ex: libusb-dev :: libusb).
|
pankso@215
|
551 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
|
pankso@215
|
552 touch $CACHE/installed.local $CACHE/installed.web
|
al@596
|
553 [ "$BUILD_DEPENDS" ] && _ "Checking build dependencies..."
|
al@596
|
554 [ "$root" ] && _ "Using packages DB: \${root}\$DB"
|
pankso@1
|
555 for dep in $BUILD_DEPENDS
|
pankso@1
|
556 do
|
pankso@126
|
557 implicit=${dep%-dev}
|
pankso@131
|
558 for i in $dep $implicit
|
pankso@126
|
559 do
|
pankso@426
|
560 if [ ! -f "${root}$INSTALLED/$i/receipt" ]; then
|
paul@174
|
561 # Try local package first. In some cases implicit doesn't exist, ex:
|
paul@174
|
562 # libboost-dev exists but not libboost, so check if we got vers.
|
pankso@173
|
563 unset vers
|
pascal@343
|
564 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
|
pankso@435
|
565 # We may have a local package.
|
pankso@435
|
566 if [ ! "$vers" ]; then
|
pankso@435
|
567 vers=$(grep "^$i |" $PKGS/packages.desc | awk '{print $3}')
|
pankso@435
|
568 fi
|
pankso@435
|
569 debug "bdep: $i version: $vers"
|
pankso@426
|
570 if [ -f "$PKGS/$i-${vers}${arch}.tazpkg" ]; then
|
pankso@426
|
571 echo $i-${vers}${arch}.tazpkg >> $CACHE/installed.local
|
pankso@126
|
572 else
|
paul@227
|
573 # Priority to package version in wok (maybe more up-to-date)
|
paul@227
|
574 # than the mirrored one.
|
pankso@173
|
575 if [ "$vers" ]; then
|
pankso@426
|
576 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
|
pankso@215
|
577 echo $i >> $CACHE/installed.web
|
pankso@198
|
578 else
|
paul@211
|
579 # So package exists in wok but not available.
|
al@596
|
580 _ "Missing dep (wok/pkg): \$i \$vers"
|
pankso@215
|
581 echo $i >> $CACHE/missing.dep
|
pankso@198
|
582 fi
|
pankso@225
|
583 else
|
pankso@435
|
584 # Package is not in wok but may be in online repo.
|
pankso@426
|
585 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
|
pankso@225
|
586 echo $i >> $CACHE/installed.web
|
pankso@225
|
587 else
|
al@596
|
588 _ "ERROR: unknown dep \$i"; exit 1
|
pankso@225
|
589 fi
|
pankso@173
|
590 fi
|
pankso@126
|
591 fi
|
pankso@1
|
592 fi
|
pankso@126
|
593 done
|
pankso@1
|
594 done
|
pankso@225
|
595
|
pankso@215
|
596 # Get the list of installed packages
|
pankso@426
|
597 cd ${root}$INSTALLED && ls -1 > $CACHE/installed.list
|
pankso@358
|
598
|
al@596
|
599 # Have we a missing build dep to cook?
|
pankso@215
|
600 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
|
al@596
|
601 _ "Auto cook config is set: AUTO_COOK"
|
pankso@204
|
602 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
|
pankso@224
|
603 for i in $(uniq $CACHE/missing.dep)
|
pankso@204
|
604 do
|
al@596
|
605 (_ "Building dep (wok/pkg) : \$i \$vers") | \
|
pankso@204
|
606 tee -a $LOGS/$PACKAGE.log.$$
|
al@596
|
607 # programmers: next two messages are exact copy from remove_deps()
|
al@596
|
608 togrep1=$(_n "Build dependencies to remove: ")
|
al@596
|
609 togrep2=$(_n "Removing:")
|
al@596
|
610 cook $i || (_ "ERROR: can't cook dep '\$i'" && newline && \
|
al@596
|
611 fgrep $togrep1 $LOGS/$i.log && \
|
al@596
|
612 fgrep $togrep2 $LOGS/$i.log && newline) | \
|
pankso@204
|
613 tee -a $LOGS/$PACKAGE.log.$$ && break
|
pankso@204
|
614 done
|
pankso@215
|
615 rm -f $CACHE/missing.dep
|
pankso@204
|
616 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
|
pankso@204
|
617 fi
|
pankso@358
|
618
|
paul@211
|
619 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
|
paul@211
|
620 # is enabled and cook fails we have ERROR in log, if no auto cook we have
|
pankso@204
|
621 # missing dep in cached file.
|
al@596
|
622 lerror=$(_n "ERROR")
|
pascal@613
|
623 if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
|
pankso@215
|
624 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
|
al@596
|
625 _ "ERROR: missing dep \$nb" && exit 1
|
pankso@202
|
626 fi
|
pankso@358
|
627
|
pankso@426
|
628 # Install local packages: package-version${arch}
|
pankso@215
|
629 cd $PKGS
|
pankso@224
|
630 for i in $(uniq $CACHE/installed.local)
|
pankso@215
|
631 do
|
al@596
|
632 _ "Installing dep (pkg/local): \$i"
|
pankso@423
|
633 tazpkg install $i --root=$root >/dev/null
|
pankso@215
|
634 done
|
pankso@358
|
635
|
pankso@215
|
636 # Install web or cached packages (if mirror is set to $PKGS we only
|
pankso@215
|
637 # use local packages).
|
pankso@224
|
638 for i in $(uniq $CACHE/installed.web)
|
pankso@215
|
639 do
|
al@596
|
640 _ "Installing dep (web/cache): \$i"
|
pankso@423
|
641 tazpkg get-install $i --root=$root >/dev/null
|
pankso@215
|
642 done
|
pankso@358
|
643
|
pankso@215
|
644 # If a cook failed deps are removed.
|
pankso@426
|
645 cd ${root}$INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
|
pascal@609
|
646 [ ! -s "/tmp/installed.cook.diff" ] && \
|
pascal@609
|
647 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
|
pascal@609
|
648 deps=$(cat /tmp/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
|
pankso@202
|
649
|
pankso@1
|
650 # Get source tarball and make sure we have source dir named:
|
paul@62
|
651 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
|
paul@62
|
652 # tarball if it exists.
|
pankso@1
|
653 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
|
pankso@1
|
654 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
|
pankso@10
|
655 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
|
pankso@190
|
656 LZMA_SRC=""
|
pankso@1
|
657 else
|
pankso@1
|
658 get_source || exit 1
|
pankso@1
|
659 fi
|
pankso@1
|
660 fi
|
pankso@242
|
661 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
|
pankso@1
|
662 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
|
pascal@268
|
663 if ! extract_source ; then
|
pascal@268
|
664 get_source
|
pascal@268
|
665 extract_source || exit 1
|
pascal@268
|
666 fi
|
pankso@190
|
667 if [ "$LZMA_SRC" ]; then
|
pankso@190
|
668 cd $pkgdir/source
|
pankso@190
|
669 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
|
pankso@190
|
670 mv tmp tmp-1 && mkdir tmp
|
pankso@190
|
671 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
|
pankso@190
|
672 fi
|
pankso@190
|
673 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
|
pankso@358
|
674 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
|
pankso@190
|
675 fi
|
pankso@190
|
676 fi
|
pankso@190
|
677 cd $pkgdir/source/tmp
|
paul@62
|
678 # Some archives are not well done and don't extract to one dir (ex lzma).
|
pankso@57
|
679 files=$(ls | wc -l)
|
pankso@244
|
680 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
|
pankso@244
|
681 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
|
pankso@244
|
682 mv * ../$PACKAGE-$VERSION/$TARBALL
|
pankso@57
|
683 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
|
pankso@57
|
684 mv * ../$PACKAGE-$VERSION
|
pankso@1
|
685 cd .. && rm -rf tmp
|
pankso@1
|
686 fi
|
pankso@662
|
687
|
pankso@658
|
688 # Libtool shared libs path hack.
|
pankso@658
|
689 case "$ARCH" in
|
pankso@658
|
690 arm*) cross libhack ;;
|
pankso@658
|
691 esac
|
pankso@1
|
692
|
pankso@9
|
693 # Execute receipt rules.
|
pankso@44
|
694 if grep -q ^compile_rules $receipt; then
|
al@596
|
695 _ "Executing: compile_rules"
|
pankso@352
|
696 echo "CFLAGS : $CFLAGS"
|
pankso@358
|
697 #echo "LDFLAGS : $LDFLAGS"
|
pankso@55
|
698 [ -d "$src" ] && cd $src
|
pankso@97
|
699 compile_rules $@ || exit 1
|
pankso@10
|
700 # Stay compatible with _pkg
|
pankso@55
|
701 [ -d "$src/_pkg" ] && mv $src/_pkg $install
|
pankso@9
|
702 # QA: compile_rules success so valid.
|
pankso@9
|
703 mkdir -p $install
|
pankso@9
|
704 else
|
al@596
|
705 # QA: no compile_rules so no error, valid.
|
pankso@9
|
706 mkdir -p $install
|
pankso@1
|
707 fi
|
al@596
|
708 separator; newline
|
pankso@360
|
709
|
pankso@360
|
710 # Execute testsuite.
|
pankso@360
|
711 if grep -q ^testsuite $receipt; then
|
al@596
|
712 _ "Running testsuite"; separator
|
pankso@360
|
713 testsuite $@ || exit 1
|
al@596
|
714 separator; newline
|
pankso@360
|
715 fi
|
pankso@1
|
716 }
|
pankso@1
|
717
|
pankso@1
|
718 # Cook quality assurance.
|
pankso@1
|
719 cookit_quality() {
|
pankso@9
|
720 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
|
al@596
|
721 _ "ERROR: cook failed" | tee -a $LOGS/$pkg.log
|
pankso@9
|
722 fi
|
pankso@9
|
723 # ERROR can be echoed any time in cookit()
|
al@596
|
724 lerror=$(_n "ERROR")
|
pascal@618
|
725 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
|
pascal@618
|
726 grep -Eq "(^$lerror|undefined reference to)" ; then
|
pankso@17
|
727 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
728 rm -f $command && exit 1
|
pankso@1
|
729 fi
|
pankso@1
|
730 }
|
pankso@1
|
731
|
pankso@16
|
732 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
|
paul@62
|
733 # but it doesn't handle EXTRAVERSION.
|
pankso@1
|
734 packit() {
|
pankso@1
|
735 set_paths
|
pankso@359
|
736
|
pankso@359
|
737 # Handle cross compilation
|
pankso@359
|
738 case "$ARCH" in
|
pankso@676
|
739 arm*|x86_64) arch="-$ARCH" ;;
|
pankso@359
|
740 esac
|
pankso@359
|
741
|
al@596
|
742 _ "Pack: \$PACKAGE \${VERSION}\${arch}"; separator
|
pankso@359
|
743
|
pankso@44
|
744 if grep -q ^genpkg_rules $receipt; then
|
al@596
|
745 _ "Executing: genpkg_rules"
|
pankso@259
|
746 set -e && cd $pkgdir && mkdir -p $fs
|
al@596
|
747 genpkg_rules || (newline; _ "ERROR: genpkg_rules failed"; newline) >> \
|
pankso@234
|
748 $LOGS/$pkg.log
|
pankso@241
|
749 else
|
al@596
|
750 _ "No packages rules: meta package"
|
pankso@241
|
751 mkdir -p $fs
|
pankso@16
|
752 fi
|
pankso@98
|
753
|
pankso@98
|
754 # First QA check to stop now if genpkg_rules failed.
|
al@596
|
755 lerror=$(_n "ERROR")
|
pascal@613
|
756 if fgrep -q ^$lerror $LOGS/$pkg.log; then
|
pankso@98
|
757 exit 1
|
pankso@98
|
758 fi
|
pankso@358
|
759
|
pankso@44
|
760 cd $taz
|
pankso@1
|
761 for file in receipt description.txt
|
pankso@1
|
762 do
|
pankso@1
|
763 [ ! -f "../$file" ] && continue
|
al@596
|
764 _n "Copying \$file..."
|
pankso@1
|
765 cp -f ../$file $pack && chown 0.0 $pack/$file && status
|
pankso@1
|
766 done
|
pankso@119
|
767 copy_generic_files
|
pankso@358
|
768
|
paul@62
|
769 # Create files.list with redirecting find output.
|
al@596
|
770 _n "Creating the list of files..."
|
al@596
|
771 cd $fs
|
pankso@16
|
772 find . -type f -print > ../files.list
|
pankso@16
|
773 find . -type l -print >> ../files.list
|
pankso@16
|
774 cd .. && sed -i s/'^.'/''/ files.list
|
pankso@16
|
775 status
|
pankso@43
|
776
|
pankso@119
|
777 # Strip and stuff files.
|
pankso@43
|
778 strip_package
|
pankso@43
|
779
|
pankso@43
|
780 # Md5sum of files.
|
al@596
|
781 _n "Creating md5sum of files..."
|
pankso@16
|
782 while read file; do
|
pankso@16
|
783 [ -L "fs$file" ] && continue
|
pankso@16
|
784 [ -f "fs$file" ] || continue
|
pankso@16
|
785 case "$file" in
|
pankso@232
|
786 /lib/modules/*/modules.*|*.pyc) continue ;;
|
pankso@16
|
787 esac
|
pankso@16
|
788 md5sum "fs$file" | sed 's/ fs/ /'
|
pankso@16
|
789 done < files.list > md5sum
|
pankso@16
|
790 status
|
pankso@16
|
791 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
|
pankso@16
|
792 description.txt 2> /dev/null | awk \
|
pankso@16
|
793 '{ sz=$1 } END { print sz }')
|
pankso@358
|
794
|
pankso@16
|
795 # Build cpio archives.
|
al@596
|
796 _n "Compressing the fs..."
|
pankso@16
|
797 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
|
pankso@16
|
798 rm -rf fs
|
pankso@16
|
799 status
|
pankso@16
|
800 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
|
pankso@16
|
801 md5sum description.txt 2> /dev/null | awk \
|
pankso@16
|
802 '{ sz=$1 } END { print sz }')
|
al@596
|
803 _n "Updating receipt sizes..."
|
pankso@16
|
804 sed -i s/^PACKED_SIZE.*$// receipt
|
pankso@16
|
805 sed -i s/^UNPACKED_SIZE.*$// receipt
|
pankso@16
|
806 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
pankso@16
|
807 status
|
pankso@16
|
808
|
pankso@16
|
809 # Set extra version.
|
pankso@16
|
810 if [ "$EXTRAVERSION" ]; then
|
al@596
|
811 _n "Updating receipt EXTRAVERSION: \$EXTRAVERSION"
|
pankso@16
|
812 sed -i s/^EXTRAVERSION.*$// receipt
|
pankso@16
|
813 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
|
pankso@16
|
814 status
|
pankso@16
|
815 fi
|
pankso@16
|
816
|
pankso@16
|
817 # Compress.
|
al@596
|
818 _n "Creating full cpio archive..."
|
pankso@16
|
819 find . -print | cpio -o -H newc --quiet > \
|
pankso@428
|
820 ../$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg
|
pankso@16
|
821 status
|
al@596
|
822 _n "Restoring original package tree..."
|
pankso@16
|
823 unlzma -c fs.cpio.lzma | cpio -idm --quiet
|
pankso@16
|
824 status
|
pankso@16
|
825 rm fs.cpio.lzma && cd ..
|
pankso@43
|
826
|
pankso@43
|
827 # QA and give info.
|
pankso@43
|
828 tazpkg=$(ls *.tazpkg)
|
pankso@43
|
829 packit_quality
|
al@596
|
830 separator; _ "Package: \$tazpkg"; newline
|
pankso@1
|
831 }
|
pankso@1
|
832
|
paul@62
|
833 # Verify package quality and consistency.
|
pankso@8
|
834 packit_quality() {
|
al@596
|
835 #gettext "QA: checking for broken link..."
|
pankso@157
|
836 #link=$(find $fs/usr -type l -follow)
|
pankso@157
|
837 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
|
pankso@157
|
838 #status
|
pankso@358
|
839
|
pankso@142
|
840 # Exit if any error found in log file.
|
al@596
|
841 lerror=$(_n "ERROR")
|
pascal@613
|
842 if fgrep -q ^$lerror $LOGS/$pkg.log; then
|
pankso@32
|
843 rm -f $command && exit 1
|
pankso@8
|
844 fi
|
pankso@358
|
845
|
al@596
|
846 _n "QA: checking for empty package..."
|
pankso@45
|
847 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
|
pankso@259
|
848 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
|
al@596
|
849 newline; _ "ERROR: empty package"
|
pankso@32
|
850 rm -f $command && exit 1
|
pankso@8
|
851 else
|
pankso@134
|
852 # Ls sort by name so the first file is the one we want.
|
pankso@136
|
853 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
|
pankso@134
|
854 status
|
pankso@154
|
855 if [ -f "$old" ]; then
|
al@596
|
856 old_pkg=$(basename $old)
|
al@596
|
857 _n "Removing old: \$old_pkg"
|
pankso@135
|
858 rm -f $old && status
|
pankso@154
|
859 fi
|
pankso@134
|
860 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
|
pankso@11
|
861 sed -i /^${pkg}$/d $broken
|
pankso@265
|
862 #gettext "Removing source tree..."
|
pankso@265
|
863 #rm -f $WOK/$pkg/source && status
|
pankso@8
|
864 fi
|
pankso@8
|
865 }
|
pankso@8
|
866
|
pankso@427
|
867 # Tic tac, tic tac...
|
pankso@421
|
868 tac() {
|
pascal@285
|
869 sed '1!G;h;$!d' $1
|
pascal@285
|
870 }
|
pascal@285
|
871
|
pankso@428
|
872 # Install package on --install or update the chroot.
|
pankso@428
|
873 install_package() {
|
pankso@428
|
874 case "$ARCH" in
|
pankso@676
|
875 arm*|x86_64)
|
pankso@428
|
876 arch="-${ARCH}"
|
pankso@443
|
877 root=$CROSS_TREE/sysroot ;;
|
pankso@428
|
878 esac
|
pankso@428
|
879 # Install package if requested but skip install if target host doesn't
|
pankso@428
|
880 # match build system or it will break the build chroot.
|
pankso@428
|
881 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
|
pankso@428
|
882 if [ "$inst" ] && [ "$build" == "$ARCH" ]; then
|
pankso@428
|
883 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pankso@428
|
884 cd $PKGS && tazpkg install \
|
pankso@428
|
885 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
|
pankso@428
|
886 else
|
al@596
|
887 _ "Unable to install package, build has failed."; newline
|
pankso@428
|
888 exit 1
|
pankso@428
|
889 fi
|
pankso@428
|
890 fi
|
pankso@428
|
891
|
pankso@428
|
892 # Install package if part of the chroot to keep env up-to-date.
|
pankso@428
|
893 if [ -d "${root}$INSTALLED/$pkg" ]; then
|
pankso@428
|
894 . /etc/slitaz/cook.conf
|
pankso@428
|
895 . $WOK/$pkg/taz/$pkg-*/receipt
|
al@596
|
896 _ "Updating \$ARCH chroot environment..."
|
al@596
|
897 _ "Updating chroot: \$pkg (\${VERSION}\${EXTRAVERSION}\${arch})" | log
|
pankso@428
|
898 cd $PKGS && tazpkg install \
|
pankso@428
|
899 $pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
|
pankso@428
|
900 --forced --root=$root
|
pankso@428
|
901 fi
|
pankso@428
|
902 }
|
pankso@428
|
903
|
pascal@696
|
904 # remove chroot jail
|
pascal@696
|
905 umount_aufs() {
|
pascal@696
|
906 tac ${1}rw/aufs-umount.sh | sh
|
pascal@696
|
907 rm -rf ${1}rw
|
pascal@696
|
908 umount ${1}root
|
pascal@697
|
909 rmdir ${1}r*
|
pascal@696
|
910 }
|
pascal@696
|
911
|
pascal@285
|
912 # Launch the cook command into a chroot jail protected by aufs.
|
pascal@285
|
913 # The current filesystems are used read-only and updates are
|
pascal@285
|
914 # stored in a separate branch.
|
pascal@285
|
915 try_aufs_chroot() {
|
pascal@285
|
916
|
pascal@286
|
917 base=/dev/shm/aufsmnt$$
|
pascal@286
|
918
|
al@596
|
919 # Can we setup the chroot? Is it already done?
|
pascal@292
|
920 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
|
pascal@594
|
921 grep -q ^AUFS_NOT_RAMFS $receipt && base=/mnt/aufsmnt$$
|
pascal@285
|
922 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
|
pascal@285
|
923 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
|
pascal@286
|
924 mkdir ${base}root ${base}rw || return
|
pascal@285
|
925
|
al@596
|
926 _ "Setup aufs chroot..."
|
pascal@285
|
927
|
pascal@285
|
928 # Sanity check
|
pascal@286
|
929 for i in / /proc /sys /dev/shm /home ; do
|
pascal@285
|
930 case " $AUFS_MOUNTS " in
|
pascal@285
|
931 *\ $i\ *) ;;
|
pascal@285
|
932 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
|
pascal@285
|
933 esac
|
pascal@285
|
934 done
|
pascal@691
|
935 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
|
pascal@285
|
936 mount --bind $mnt ${base}root$mnt
|
pascal@285
|
937 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
|
al@596
|
938 _ "Aufs mountage failure"
|
slaxemulator@519
|
939 umount ${base}root
|
pascal@628
|
940 rm -rf ${base}r*
|
slaxemulator@519
|
941 return
|
pascal@285
|
942 fi
|
pascal@285
|
943 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
|
pascal@285
|
944 done
|
pascal@696
|
945 trap "umount_aufs ${base}" INT
|
pascal@285
|
946
|
pascal@285
|
947 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
|
pascal@285
|
948 status=$?
|
pascal@285
|
949
|
al@596
|
950 _ "Leaving aufs chroot..."
|
pascal@696
|
951 umount_aufs ${base}
|
pascal@683
|
952 # Install package outside the aufs jail
|
pascal@683
|
953 install_package
|
pankso@358
|
954 exit $status
|
pascal@285
|
955 }
|
pascal@285
|
956
|
paul@387
|
957 # Create a XML feed for freshly built packages.
|
pankso@310
|
958 gen_rss() {
|
pankso@310
|
959 pubdate=$(date "+%a, %d %b %Y %X")
|
pankso@310
|
960 cat > $FEEDS/$pkg.xml << EOT
|
pankso@310
|
961 <item>
|
pankso@310
|
962 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
|
pankso@310
|
963 <link>${COOKER_URL}?pkg=$PACKAGE</link>
|
pankso@310
|
964 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
|
pankso@310
|
965 <pubDate>$pubdate</pubDate>
|
pankso@310
|
966 <description>$SHORT_DESC</description>
|
pankso@310
|
967 </item>
|
pankso@310
|
968 EOT
|
pankso@310
|
969 }
|
pankso@310
|
970
|
pankso@662
|
971 # Truncate stdout log file to $1 Mb.
|
pascal@576
|
972 loglimit()
|
pascal@576
|
973 {
|
pascal@593
|
974 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
|
pascal@621
|
975 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
|
pascal@593
|
976 else
|
pascal@593
|
977 tee /dev/stderr
|
pascal@593
|
978 fi
|
pascal@576
|
979 }
|
pascal@576
|
980
|
al@598
|
981 # Search file in mirrored packages
|
al@598
|
982 search_file_mirror()
|
al@598
|
983 {
|
al@598
|
984 busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u
|
al@598
|
985 }
|
al@598
|
986
|
al@598
|
987 # Search file in local wok packages
|
al@598
|
988 search_file_local()
|
al@598
|
989 {
|
al@598
|
990 # existing packages have precedence over the package/taz folder
|
al@598
|
991 srch=$1
|
al@598
|
992 { for package in $(find $PKGS -name '*.tazpkg'); do
|
al@598
|
993 if [ ! "x$(busybox cpio --to-stdout --quiet -i files.list < $package | grep /$srch\$)" == "x" ]; then
|
al@598
|
994 busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2
|
al@598
|
995 fi
|
al@598
|
996 done } | sort -u
|
al@598
|
997 }
|
al@598
|
998
|
al@598
|
999 # Ask in multiple choice
|
al@598
|
1000 ask_multiple()
|
al@598
|
1001 {
|
al@598
|
1002 local multiples first my_choice
|
al@598
|
1003 multiples="$1"
|
al@598
|
1004 first=$(echo "$multiples" | head -n1)
|
al@598
|
1005 newline; _ "Multiple choice:\n$multiples\n"
|
al@598
|
1006 _ "Select one [$first]: "; read my_choice
|
al@598
|
1007 [ "x$my_choice" == "x" ] && my_choice="$first"
|
al@598
|
1008 found=$my_choice
|
al@598
|
1009 }
|
al@598
|
1010
|
al@598
|
1011 # Search file in local cache (fast), local wok packages, mirrored packages
|
al@598
|
1012 search_file()
|
al@598
|
1013 {
|
al@598
|
1014 local srch cache missing
|
al@598
|
1015 srch=$1
|
al@598
|
1016 cache=/var/cache/ldsearch.cache
|
al@598
|
1017 missing=/var/cache/missing.file
|
al@598
|
1018 touch $cache $missing
|
al@598
|
1019 found=$(grep $srch $cache | cut -d' ' -f2)
|
al@598
|
1020 if [ "x$found" == "x" ]; then
|
al@598
|
1021 found=$(search_file_local $srch)
|
al@598
|
1022 if [ "x$found" != "x" ]; then
|
al@598
|
1023 if [ $(echo "$found" | wc -l) -gt 1 ]; then
|
al@598
|
1024 ask_multiple "$found"
|
al@598
|
1025 fi
|
al@598
|
1026 echo "$srch $found" >> $cache
|
al@598
|
1027 else
|
al@598
|
1028 found=$(search_file_mirror $srch)
|
al@598
|
1029 if [ "x$found" != "x" ]; then
|
al@598
|
1030 if [ $(echo "$found" | wc -l) -gt 1 ]; then
|
al@598
|
1031 ask_multiple "$found"
|
al@598
|
1032 fi
|
al@598
|
1033 echo "$srch $found" >> $cache
|
al@598
|
1034 else
|
al@598
|
1035 echo "$srch" >> $missing
|
al@598
|
1036 fi
|
al@598
|
1037 fi
|
al@598
|
1038 fi
|
al@598
|
1039 }
|
al@598
|
1040
|
pankso@1
|
1041 #
|
pankso@671
|
1042 # Receipt functions to ease packaging
|
pankso@671
|
1043 #
|
pankso@671
|
1044
|
pankso@671
|
1045 get_dev_files() {
|
pankso@671
|
1046 _n "Getting standard devel files..."
|
pankso@671
|
1047 mkdir -p $fs/usr/lib
|
pankso@671
|
1048 cp -a $install/usr/lib/*.so* $fs/usr/lib
|
pankso@671
|
1049 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
|
pankso@671
|
1050 cp -a $install/usr/include $fs/usr
|
pankso@671
|
1051 status
|
pankso@671
|
1052 }
|
pankso@671
|
1053
|
pankso@671
|
1054 #
|
pankso@1
|
1055 # Commands
|
pankso@1
|
1056 #
|
pankso@1
|
1057
|
pankso@1
|
1058 case "$1" in
|
pankso@32
|
1059 usage|help|-u|-h)
|
pankso@1
|
1060 usage ;;
|
pankso@1
|
1061 list-wok)
|
pankso@642
|
1062 newline; _ "List of \$ARCH packages in: \$WOK"; separator
|
pankso@642
|
1063 cd $WOK
|
pankso@642
|
1064 if [ "$ARCH" != "i486" ]; then
|
pankso@643
|
1065 count=0
|
pascal@669
|
1066 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d : -f 1)
|
pankso@643
|
1067 do
|
pankso@643
|
1068 unset HOST_ARCH
|
pankso@643
|
1069 . $pkg
|
pankso@643
|
1070 count=$(($count + 1))
|
pankso@643
|
1071 colorize 34 "$PACKAGE"
|
pankso@643
|
1072 done
|
pankso@642
|
1073 else
|
pankso@643
|
1074 count=$(ls | wc -l)
|
pankso@643
|
1075 ls -1
|
pankso@642
|
1076 fi
|
pankso@1
|
1077 separator
|
pankso@643
|
1078 _n "Packages:"; colorize 32 " $count"
|
pankso@643
|
1079 newline ;;
|
pankso@378
|
1080 activity)
|
pankso@378
|
1081 cat $activity ;;
|
pankso@69
|
1082 search)
|
pankso@69
|
1083 # Just a simple search function, we dont need more actually.
|
pankso@69
|
1084 query="$2"
|
al@596
|
1085 newline; _ "Search results for: \$query"; separator
|
pankso@69
|
1086 cd $WOK && ls -1 | grep "$query"
|
al@596
|
1087 separator; newline ;;
|
pankso@1
|
1088 setup)
|
pankso@1
|
1089 # Setup a build environment
|
pankso@1
|
1090 check_root
|
al@596
|
1091 _ "Cook: setup environment" | log
|
al@596
|
1092 newline; _ "Setting up your environment"; separator
|
al@596
|
1093 cd $SLITAZ
|
pankso@52
|
1094 init_db_files
|
al@596
|
1095 _ "Checking for packages to install..."
|
pankso@397
|
1096 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
|
pankso@645
|
1097 # ARCH-setup or 'cross check' should be used before: cook setup
|
pankso@397
|
1098 case "$ARCH" in
|
pankso@676
|
1099 arm*|x86_64)
|
pankso@397
|
1100 if [ ! -x "/usr/bin/cross" ]; then
|
al@596
|
1101 _ "ERROR: cross is not installed"
|
pankso@397
|
1102 exit 1
|
pankso@397
|
1103 fi
|
al@596
|
1104 _ "Using config file: /etc/slitaz/cross.conf"
|
pankso@397
|
1105 . /etc/slitaz/cross.conf ;;
|
pankso@397
|
1106 esac
|
pankso@397
|
1107 for pkg in $SETUP_PKGS; do
|
pankso@397
|
1108 if [ "$forced" ]; then
|
pankso@421
|
1109 tazpkg -gi $pkg --forced
|
pankso@397
|
1110 else
|
pankso@407
|
1111 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
|
pankso@397
|
1112 fi
|
pankso@397
|
1113 done
|
pankso@1
|
1114
|
pankso@1
|
1115 # Handle --options
|
pankso@1
|
1116 case "$2" in
|
pankso@397
|
1117 --wok)
|
pankso@230
|
1118 hg clone $WOK_URL wok || exit 1 ;;
|
pankso@230
|
1119 --stable)
|
pankso@230
|
1120 hg clone $WOK_URL-stable wok || exit 1 ;;
|
pankso@230
|
1121 --undigest)
|
pankso@230
|
1122 hg clone $WOK_URL-undigest wok || exit 1 ;;
|
pankso@397
|
1123 --tiny)
|
pankso@397
|
1124 hg clone $WOK_URL-tiny wok || exit 1 ;;
|
pankso@1
|
1125 esac
|
pankso@1
|
1126
|
pankso@1
|
1127 # SliTaz group and permissions
|
pankso@1
|
1128 if ! grep -q ^slitaz /etc/group; then
|
al@596
|
1129 _ "Adding group: slitaz"
|
pankso@1
|
1130 addgroup slitaz
|
pankso@1
|
1131 fi
|
al@596
|
1132 _ "Setting permissions for slitaz group..."
|
pascal@277
|
1133 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
|
pascal@277
|
1134 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
|
al@596
|
1135 separator; _ "All done, ready to cook packages :-)"; newline ;;
|
pankso@395
|
1136 *-setup)
|
pankso@395
|
1137 # Setup for cross compiling.
|
pankso@395
|
1138 arch=${1%-setup}
|
pankso@397
|
1139 check_root
|
pankso@644
|
1140 . /etc/slitaz/cook.conf
|
pankso@644
|
1141 for pkg in $CROSS_SETUP; do
|
pankso@644
|
1142 if [ "$forced" ]; then
|
pankso@644
|
1143 tazpkg -gi $pkg --forced
|
pankso@644
|
1144 else
|
pankso@644
|
1145 [ -d "$INSTALLED/$pkg" ] || tazpkg -gi $pkg
|
pankso@644
|
1146 fi
|
pankso@644
|
1147 done
|
al@596
|
1148 _ "Cook: setup \$arch cross environment" | log
|
al@596
|
1149 newline; boldify $(_n "Setting up your \$arch cross environment"); separator
|
pankso@397
|
1150 init_db_files
|
pankso@359
|
1151 sed -i \
|
pankso@396
|
1152 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
|
pankso@443
|
1153 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
|
pankso@359
|
1154 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
|
pankso@395
|
1155 /etc/slitaz/cook.conf
|
pankso@395
|
1156 case "$arch" in
|
pankso@395
|
1157 arm)
|
pankso@650
|
1158 flags="-O2 -march=armv6"
|
pankso@650
|
1159 host="$ARCH-slitaz-linux-gnueabi" ;;
|
pankso@650
|
1160 armv6hf)
|
pankso@650
|
1161 flags="-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard"
|
pankso@650
|
1162 host="$ARCH-slitaz-linux-gnueabi" ;;
|
pankso@650
|
1163 armv7)
|
pankso@650
|
1164 flags="-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe"
|
pankso@650
|
1165 host="$ARCH-slitaz-linux-gnueabi" ;;
|
pankso@395
|
1166 x86_64)
|
erjo@682
|
1167 flags="-O2 -mtune=generic -pipe"
|
pankso@650
|
1168 host="$ARCH-slitaz-linux" ;;
|
pankso@395
|
1169 esac
|
pankso@650
|
1170 sed -i \
|
pankso@650
|
1171 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
|
pankso@677
|
1172 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
|
pankso@359
|
1173 . /etc/slitaz/cook.conf
|
pankso@443
|
1174 sysroot=$CROSS_TREE/sysroot
|
pankso@443
|
1175 tools=/cross/$arch/tools
|
pankso@443
|
1176 root=$sysroot
|
al@596
|
1177 # L10n: keep the same width of translations to get a consistent view
|
al@596
|
1178 _ "Target arch : \$ARCH"
|
al@596
|
1179 _ "Configure args : \$CONFIGURE_ARGS"
|
pankso@650
|
1180 _ "Build flags : \$flags"
|
al@596
|
1181 _ "Arch sysroot : \$sysroot"
|
al@596
|
1182 _ "Tools prefix : \$tools/bin"
|
paul@455
|
1183 # Tell the packages manager where to find packages.
|
al@596
|
1184 _ "Packages DB : \${root}\$DB"
|
pankso@429
|
1185 mkdir -p ${root}$INSTALLED
|
pankso@426
|
1186 cd ${root}$DB && rm -f *.bak
|
pankso@426
|
1187 for list in packages.list packages.desc packages.equiv packages.md5
|
pankso@426
|
1188 do
|
pankso@426
|
1189 rm -f $list && ln -s $SLITAZ/packages/$list $list
|
pankso@426
|
1190 done
|
pankso@429
|
1191 # We must have the cross compiled glibc-base installed or default
|
pankso@429
|
1192 # i486 package will be used as dep by tazpkg and then break the
|
pankso@429
|
1193 # cross environment
|
pankso@429
|
1194 if [ ! -f "${root}$INSTALLED/glibc-base/receipt" ]; then
|
al@596
|
1195 colorize 36 $(_ "WARNING: (e)glibc-base is not installed in sysroot")
|
pankso@429
|
1196 fi
|
pankso@426
|
1197 # Show GCC version or warn if not yet compiled.
|
pankso@677
|
1198 if [ -x "$tools/bin/${HOST_SYSTEM}-gcc" ]; then
|
al@596
|
1199 _ "Cross compiler : \${HOST_SYSTEM}-gcc"
|
pankso@359
|
1200 else
|
al@596
|
1201 colorize 36 $(_ "C compiler is missing: \${HOST_SYSTEM}-gcc")
|
al@596
|
1202 _ "Run 'cross compile' to cook a toolchain"
|
pankso@397
|
1203 fi
|
al@596
|
1204 separator; newline ;;
|
pankso@9
|
1205 test)
|
pankso@9
|
1206 # Test a cook environment.
|
al@596
|
1207 _ "Cook test: testing the cook environment" | log
|
pankso@9
|
1208 [ ! -d "$WOK" ] && exit 1
|
pankso@9
|
1209 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
|
pankso@9
|
1210 cook cooktest ;;
|
pankso@1
|
1211 new)
|
pankso@1
|
1212 # Create the package folder and an empty receipt.
|
pankso@1
|
1213 pkg="$2"
|
pankso@1
|
1214 [ "$pkg" ] || usage
|
pankso@427
|
1215 newline
|
pankso@1
|
1216 if [ -d "$WOK/$pkg" ]; then
|
al@596
|
1217 _ "\$pkg package already exists."
|
al@596
|
1218 exit 1
|
pankso@1
|
1219 fi
|
al@596
|
1220 _n "Creating \$WOK/\$pkg"
|
pankso@1
|
1221 mkdir $WOK/$pkg && cd $WOK/$pkg && status
|
al@596
|
1222 _n "Preparing the package receipt..."
|
pankso@1
|
1223 cp $DATA/receipt .
|
pankso@1
|
1224 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
|
pankso@427
|
1225 status && newline
|
pankso@358
|
1226
|
pankso@196
|
1227 # Interactive mode, asking and seding.
|
pankso@196
|
1228 case "$3" in
|
paul@214
|
1229 --interactive|-x)
|
al@596
|
1230 _ "Entering interactive mode..."
|
paul@211
|
1231 separator
|
al@596
|
1232 _ "Package : \$pkg"
|
al@596
|
1233 _n "Version : " ; read answer
|
al@596
|
1234 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
|
al@596
|
1235 _n "Category : " ; read answer
|
al@596
|
1236 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
|
al@596
|
1237 # L10n: Short description
|
al@596
|
1238 _n "Short desc : " ; read answer
|
al@596
|
1239 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
|
al@596
|
1240 _n "Maintainer : " ; read answer
|
al@596
|
1241 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
|
al@596
|
1242 _n "License : " ; read answer
|
al@596
|
1243 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
|
al@596
|
1244 _n "Web site : " ; read answer
|
al@596
|
1245 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
|
pankso@427
|
1246 newline
|
pankso@196
|
1247 # Wget URL.
|
al@596
|
1248 _ "Wget URL to download source tarball."
|
al@596
|
1249 _n "Example : " ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
|
al@596
|
1250 _n "Wget url : " ; read answer
|
al@596
|
1251 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$answer\""# receipt
|
pankso@196
|
1252 # Ask for a stuff dir.
|
al@596
|
1253 _n "Do you need a stuff directory? (y/N) : " ; read answer
|
al@596
|
1254 if [ "$answer" = "y" ]; then
|
al@596
|
1255 _n "Creating the stuff directory..."
|
pankso@196
|
1256 mkdir $WOK/$pkg/stuff && status
|
pankso@196
|
1257 fi
|
pankso@196
|
1258 # Ask for a description file.
|
al@596
|
1259 _n "Are you going to write a description? (y/N) : " ; read answer
|
al@596
|
1260 if [ "$answer" = "y" ]; then
|
al@596
|
1261 _n "Creating the description.txt file..."
|
pankso@427
|
1262 newline > $WOK/$pkg/description.txt && status
|
pankso@196
|
1263 fi
|
al@596
|
1264 separator; _ "Receipt is ready to use."; newline ;;
|
pankso@196
|
1265 esac ;;
|
pankso@1
|
1266 list)
|
pankso@1
|
1267 # Cook a list of packages (better use the Cooker since it will order
|
pankso@1
|
1268 # packages before executing cook).
|
pankso@1
|
1269 check_root
|
al@596
|
1270 [ -z "$2" ] && (newline; _ "No list in argument."; newline) && exit 1
|
al@596
|
1271 list2=$2
|
al@596
|
1272 [ ! -f "$2" ] && (newline; _ "No list found: \$list2"; newline) && exit 1
|
al@596
|
1273 _ "Cook list starting: \$list2" | log
|
pankso@1
|
1274 for pkg in $(cat $2)
|
pankso@1
|
1275 do
|
pankso@1
|
1276 cook $pkg || broken
|
pankso@1
|
1277 done ;;
|
pankso@1
|
1278 clean-wok)
|
pankso@1
|
1279 check_root
|
al@596
|
1280 newline; _n "Cleaning all packages files..."
|
pankso@1
|
1281 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
|
al@596
|
1282 status; newline ;;
|
pankso@1
|
1283 clean-src)
|
pankso@1
|
1284 check_root
|
al@596
|
1285 newline; _n "Cleaning all packages sources..."
|
pankso@1
|
1286 rm -rf $WOK/*/source
|
al@596
|
1287 status; newline ;;
|
pankso@662
|
1288 uncook)
|
pankso@662
|
1289 cd $WOK
|
pankso@662
|
1290 count=0
|
pankso@662
|
1291 newline
|
paul@665
|
1292 _ "Checking for uncooked packages"
|
pankso@662
|
1293 separator
|
pankso@662
|
1294 for pkg in *
|
pankso@662
|
1295 do
|
pankso@664
|
1296 unset HOST_ARCH EXTRAVERSION
|
pankso@662
|
1297 . $pkg/receipt
|
pankso@662
|
1298 # Source cooked pkg receipt to get EXTRAVERSION
|
pankso@663
|
1299 if [ -d "$WOK/$pkg/taz" ]; then
|
pankso@663
|
1300 cd $WOK/$pkg/taz/$pkg-*
|
pankso@663
|
1301 . receipt && cd $WOK
|
pankso@662
|
1302 fi
|
pankso@662
|
1303 case "$ARCH" in
|
pankso@662
|
1304 i486)
|
pankso@662
|
1305 debug "Package: $PKGS/${PACKAGE}-${VERSION}${EXTRAVERSION}.tazpkg"
|
pankso@662
|
1306 if [ ! -f "$PKGS/${PACKAGE}-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pankso@662
|
1307 count=$(($count + 1))
|
pankso@662
|
1308 colorize 34 "$pkg"
|
pankso@662
|
1309 fi ;;
|
pankso@676
|
1310 arm*)
|
paul@665
|
1311 # Check only packages included in arch
|
pascal@669
|
1312 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
|
pankso@662
|
1313 # *.tazpkg
|
pankso@662
|
1314 if [ ! -f "$PKGS/${PACKAGE}-${VERSION}${EXTRAVERSION}-${ARCH}.tazpkg" ]; then
|
pankso@662
|
1315 count=$(($count + 1))
|
pankso@662
|
1316 colorize 34 "$pkg"
|
pankso@662
|
1317 fi
|
pankso@662
|
1318 fi ;;
|
pankso@662
|
1319 esac
|
pankso@662
|
1320 done
|
pankso@662
|
1321 if [ "$count" -gt "0" ]; then
|
pankso@662
|
1322 separator
|
paul@665
|
1323 _n "Uncooked packages: "; colorize 31 "$count"
|
pankso@662
|
1324 else
|
pankso@662
|
1325 _ "All packages are cooked :-)"
|
pankso@662
|
1326 fi
|
pankso@662
|
1327 newline ;;
|
pankso@235
|
1328 pkgdb)
|
pankso@235
|
1329 # Create suitable packages list for TazPKG and only for built packages
|
pankso@235
|
1330 # as well as flavors files for TazLiTo. We dont need logs since we do it
|
paul@243
|
1331 # manually to ensure everything is fine before syncing the mirror.
|
pankso@239
|
1332 case "$2" in
|
pankso@239
|
1333 --flavors)
|
pankso@239
|
1334 continue ;;
|
pankso@239
|
1335 *)
|
pankso@240
|
1336 [ "$2" ] && PKGS="$2"
|
pankso@239
|
1337 [ ! -d "$PKGS" ] && \
|
al@596
|
1338 newline && _ "Packages directory doesn't exist" && \
|
al@596
|
1339 newline && exit 1 ;;
|
pankso@239
|
1340 esac
|
pankso@226
|
1341 time=$(date +%s)
|
pankso@239
|
1342 flavors=$SLITAZ/flavors
|
pankso@239
|
1343 live=$SLITAZ/live
|
pankso@235
|
1344 echo "cook:pkgdb" > $command
|
al@596
|
1345 _ "Cook pkgdb: Creating all packages lists" | log
|
al@596
|
1346 newline; _ "Creating lists for: \$PKGS"; separator
|
al@596
|
1347 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
|
al@596
|
1348 _ "Cook pkgdb started: \$datenow"
|
pankso@133
|
1349 cd $PKGS
|
pascal@699
|
1350 rm -f packages.* extra.list
|
pascal@699
|
1351 ln -s ../get.list extra.list
|
al@596
|
1352 _ "Creating: packages.list"
|
pankso@85
|
1353 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
|
al@596
|
1354 _ "Creating: packages.md5"
|
pankso@1
|
1355 md5sum *.tazpkg > $PKGS/packages.md5
|
gokhlayeh@297
|
1356 md5sum packages.md5 | cut -f1 -d' ' > ID
|
al@596
|
1357 _ "Creating lists from: \$WOK"
|
pankso@1
|
1358 cd $WOK
|
pankso@1
|
1359 for pkg in *
|
pankso@1
|
1360 do
|
pankso@1
|
1361 unset_receipt
|
pankso@1
|
1362 . $pkg/receipt
|
pascal@600
|
1363 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
|
pascal@600
|
1364 if [ -s $pkg/taz/*/receipt ]; then
|
pascal@600
|
1365 . $pkg/taz/*/receipt
|
pascal@600
|
1366 fi
|
mojo@700
|
1367 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ] || \
|
mojo@700
|
1368 [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}-${ARCH}.tazpkg" ]; then
|
al@701
|
1369
|
pankso@192
|
1370 # packages.desc lets us search easily in DB
|
pankso@1
|
1371 cat >> $PKGS/packages.desc << EOT
|
pankso@235
|
1372 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
|
pankso@1
|
1373 EOT
|
al@701
|
1374
|
pankso@192
|
1375 # packages.txt used by tazpkg and tazpkg-web also to provide
|
pankso@192
|
1376 # a human readable package list with version and description.
|
pankso@192
|
1377 cat >> $PKGS/packages.txt << EOT
|
pankso@192
|
1378 $PACKAGE
|
pankso@235
|
1379 ${VERSION}$EXTRAVERSION
|
pankso@235
|
1380 $SHORT_DESC
|
pankso@235
|
1381 $PACKED_SIZE ($UNPACKED_SIZE installed)
|
pankso@358
|
1382
|
pankso@192
|
1383 EOT
|
al@701
|
1384
|
al@701
|
1385 # packages.info combines two previous files
|
al@701
|
1386 # and will substitute them both
|
al@701
|
1387 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
|
al@701
|
1388 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
|
al@701
|
1389 cat >> $PKGS/packages.info << EOT
|
al@701
|
1390 $PACKAGE ${VERSION}$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS
|
al@701
|
1391 EOT
|
al@701
|
1392
|
pankso@192
|
1393 # packages.equiv is used by tazpkg install to check depends.
|
pankso@1
|
1394 for i in $PROVIDE; do
|
pankso@1
|
1395 DEST=""
|
pankso@1
|
1396 echo $i | fgrep -q : && DEST="${i#*:}:"
|
pankso@1
|
1397 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
|
pankso@1
|
1398 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
|
pankso@1
|
1399 $PKGS/packages.equiv
|
pankso@1
|
1400 else
|
pankso@1
|
1401 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
|
pankso@1
|
1402 fi
|
pankso@1
|
1403 done
|
al@701
|
1404
|
paul@197
|
1405 # files.list provides a list of all packages files.
|
pankso@194
|
1406 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
|
pankso@194
|
1407 $PKGS/files.list
|
pankso@1
|
1408 fi
|
pankso@1
|
1409 done
|
pankso@358
|
1410
|
pankso@213
|
1411 # Display list size.
|
al@596
|
1412 _ "Done: packages.desc"
|
al@596
|
1413 _ "Done: packages.txt"
|
al@596
|
1414 _ "Done: packages.equiv"
|
pankso@358
|
1415
|
pankso@194
|
1416 # files.list.lzma
|
al@596
|
1417 _ "Creating: files.list.lzma"
|
pascal@699
|
1418 touch $PKGS/files.list
|
al@701
|
1419 cd $PKGS; lzma e files.list files.list.lzma
|
pankso@194
|
1420 rm -f files.list
|
pankso@358
|
1421
|
al@701
|
1422 # packages.info.lzma
|
al@701
|
1423 PI=packages.info
|
al@701
|
1424 _ 'Creating: packages.info.lzma'
|
al@701
|
1425 touch $PKGS/$PI
|
al@701
|
1426 cd $PKGS; lzma e $PI $PI.lzma
|
al@701
|
1427 rm -f $PI
|
al@701
|
1428
|
pankso@235
|
1429 # Display some info.
|
pankso@1
|
1430 separator
|
pankso@1
|
1431 nb=$(ls $PKGS/*.tazpkg | wc -l)
|
pankso@226
|
1432 time=$(($(date +%s) - $time))
|
al@596
|
1433 # L10n: 's' is for seconds (cooking time)
|
al@596
|
1434 _ "Packages: \$nb - Time: \${time}s"; newline
|
pankso@358
|
1435
|
paul@243
|
1436 # Create all flavors files at once. Do we really need code to monitor
|
al@596
|
1437 # flavors changes? Lets just build them with packages lists before
|
pankso@235
|
1438 # syncing the mirror.
|
pankso@239
|
1439 [ "$2" == "--flavors" ] || exit 1
|
al@596
|
1440 [ ! -d "$flavors" ] && (_ "Missing flavors: \$flavors"; newline) && exit 1
|
pankso@239
|
1441 [ -d "$live" ] || mkdir -p $live
|
al@596
|
1442 _ "Creating flavors files in: \$live"
|
al@596
|
1443 _ "Cook pkgdb: Creating all flavors" | log
|
pankso@235
|
1444 separator
|
al@596
|
1445 _ "Recharging lists to use latest packages..."
|
pankso@329
|
1446 tazpkg recharge >/dev/null 2>/dev/null
|
pankso@358
|
1447
|
pankso@235
|
1448 # We need a custom tazlito config to set working dir to /home/slitaz.
|
pankso@235
|
1449 if [ ! -f "$live/tazlito.conf" ]; then
|
al@596
|
1450 _ "Creating configuration file: tazlito.conf"
|
pankso@235
|
1451 cp /etc/tazlito/tazlito.conf $live
|
pankso@235
|
1452 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
|
pankso@235
|
1453 $live/tazlito.conf
|
pankso@235
|
1454 fi
|
pankso@235
|
1455
|
pankso@239
|
1456 # Update Hg flavors repo and pack.
|
pankso@239
|
1457 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
|
pankso@358
|
1458
|
pankso@239
|
1459 cd $live
|
al@596
|
1460 _ "Starting to generate flavors..."
|
pankso@235
|
1461 rm -f flavors.list *.flavor
|
pankso@235
|
1462 for i in $flavors/*
|
pankso@235
|
1463 do
|
pankso@235
|
1464 fl=$(basename $i)
|
al@596
|
1465 _ "Packing flavor: \$fl"
|
pankso@235
|
1466 tazlito pack-flavor $fl >/dev/null || exit 1
|
pankso@235
|
1467 tazlito show-flavor $fl --brief --noheader 2> \
|
pankso@235
|
1468 /dev/null >> flavors.list
|
pankso@235
|
1469 done
|
pankso@237
|
1470 cp -f $live/*.flavor $live/flavors.list $PKGS
|
al@596
|
1471 separator
|
al@596
|
1472 fl_size=$(du -sh $live | awk '{print $1}')
|
al@596
|
1473 _ "Flavors size: \$fl_size"; newline
|
al@596
|
1474 rm -f $command
|
al@596
|
1475 separator
|
al@596
|
1476 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
|
al@596
|
1477 _ "Cook pkgdb end: \$datenow" ;;
|
pankso@1
|
1478 *)
|
pankso@1
|
1479 # Just cook and generate a package.
|
pankso@1
|
1480 check_root
|
pankso@1
|
1481 time=$(date +%s)
|
pankso@1
|
1482 pkg="$1"
|
pankso@1
|
1483 [ -z "$pkg" ] && usage
|
pankso@44
|
1484 receipt="$WOK/$pkg/receipt"
|
pankso@427
|
1485 check_pkg_in_wok && newline
|
pankso@47
|
1486
|
pankso@377
|
1487 unset inst
|
pankso@377
|
1488 unset_receipt
|
pankso@377
|
1489 . $receipt
|
pankso@666
|
1490
|
pankso@377
|
1491 # Handle cross compilation.
|
pankso@377
|
1492 case "$ARCH" in
|
pankso@676
|
1493 arm*)
|
pankso@377
|
1494 if [ ! "$HOST_ARCH" ]; then
|
al@596
|
1495 _ "cook: HOST_ARCH is not set in \$pkg receipt"
|
al@596
|
1496 _ "cook: This package is not included in: \$ARCH"
|
al@596
|
1497 [ "$CROSS_BUGS" ] && _ "bugs: \$CROSS_BUGS"
|
al@596
|
1498 _ "Cook skip: \$pkg is not included in: \$ARCH" | log
|
pankso@427
|
1499 newline && exit 1
|
pankso@377
|
1500 fi ;;
|
pankso@377
|
1501 esac
|
pankso@377
|
1502
|
paul@387
|
1503 # Some packages are not included in some arch or fail to cross compile.
|
pankso@398
|
1504 : ${HOST_ARCH=i486}
|
pankso@662
|
1505 debug "Host arch $HOST_ARCH"
|
pankso@675
|
1506 # Handle arm{v6hf,v7,..}
|
pankso@675
|
1507 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
|
al@596
|
1508 _ "cook: HOST_ARCH=\$HOST_ARCH"
|
al@596
|
1509 _ "cook: \$pkg doesn't cook or is not included in: \$ARCH"
|
al@596
|
1510 [ "$CROSS_BUGS" ] && _ "bugs: \$CROSS_BUGS"
|
al@596
|
1511 _ "Cook skip: \$pkg doesn't cook or is not included in: \$ARCH" | log
|
pascal@673
|
1512 sed -i /^${pkg}$/d $broken
|
pascal@673
|
1513 newline && exit 0
|
pankso@377
|
1514 fi
|
pankso@377
|
1515
|
pankso@47
|
1516 # Skip blocked, 3 lines also for the Cooker.
|
pankso@151
|
1517 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
|
al@596
|
1518 _ "Blocked package: \$pkg"; newline
|
al@596
|
1519 exit 0
|
pankso@47
|
1520 fi
|
pankso@47
|
1521
|
pascal@289
|
1522 try_aufs_chroot "$@"
|
pascal@289
|
1523
|
pankso@47
|
1524 # Log and source receipt.
|
al@596
|
1525 _ "Cook started for: <a href='cooker.cgi?pkg=\$pkg'>\$pkg</a>" | log
|
pankso@16
|
1526 echo "cook:$pkg" > $command
|
pascal@285
|
1527
|
pascal@285
|
1528 # Display and log info if cook process stopped.
|
paul@647
|
1529 # FIXME: gettext not working (in single quotes) here!
|
al@596
|
1530 trap '_ "\n\nCook stopped: control-C\n\n" | \
|
pascal@285
|
1531 tee -a $LOGS/$pkg.log' INT
|
pascal@285
|
1532
|
pankso@1
|
1533 # Handle --options
|
pankso@1
|
1534 case "$2" in
|
pankso@1
|
1535 --clean|-c)
|
al@596
|
1536 _n "Cleaning: \$pkg"
|
pankso@1
|
1537 cd $WOK/$pkg && rm -rf install taz source
|
pankso@427
|
1538 status && newline && exit 0 ;;
|
pankso@1
|
1539 --install|-i)
|
pankso@1
|
1540 inst='yes' ;;
|
pankso@49
|
1541 --getsrc|-gs)
|
al@596
|
1542 _ "Getting source for: \$pkg"; separator
|
al@596
|
1543 get_source
|
al@596
|
1544 _ "Tarball: \$SRC/\$TARBALL"; newline
|
al@596
|
1545 exit 0 ;;
|
pankso@49
|
1546 --block|-b)
|
al@596
|
1547 _n "Blocking: \$pkg"
|
pankso@49
|
1548 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
|
pankso@427
|
1549 status && newline && exit 0 ;;
|
pankso@49
|
1550 --unblock|-ub)
|
al@596
|
1551 _n "Unblocking: \$pkg"
|
pankso@49
|
1552 sed -i "/^${pkg}$/"d $blocked
|
pankso@427
|
1553 status && newline && exit 0 ;;
|
slaxemulator@501
|
1554 --pack)
|
slaxemulator@501
|
1555 if [ -d $WOK/$pkg/taz ]; then
|
slaxemulator@501
|
1556 rm -rf $WOK/$pkg/taz
|
slaxemulator@501
|
1557 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
|
slaxemulator@501
|
1558 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
|
slaxemulator@501
|
1559 clean_log
|
slaxemulator@501
|
1560 else
|
al@596
|
1561 _ "Need to build \$pkg." && exit 0
|
slaxemulator@501
|
1562 fi
|
slaxemulator@501
|
1563 exit 0 ;;
|
al@598
|
1564 --cdeps)
|
al@598
|
1565 [ ! -d $WOK/$pkg/taz ] && _ "Need to build \$pkg." && exit 0
|
al@598
|
1566 _ "Checking depends"; separator
|
al@598
|
1567 lddlist=/tmp/lddlist; touch $lddlist
|
al@598
|
1568 missing=/var/cache/missing.file
|
al@598
|
1569 # find all deps using ldd
|
al@598
|
1570 for exe in $(find $WOK/$pkg/taz -type f -perm +111); do
|
al@598
|
1571 [ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] &&
|
al@598
|
1572 ldd $exe | sed 's| ||' | cut -d' ' -f1 >> $lddlist
|
al@598
|
1573 done
|
al@598
|
1574 # remove exe/so duplicates
|
al@598
|
1575 sort -u $lddlist > $lddlist.sorted
|
al@598
|
1576 # search packages
|
al@598
|
1577 for exefile in $(cat $lddlist.sorted); do
|
al@598
|
1578 search_file $exefile
|
al@598
|
1579 echo $found >> $lddlist.pkgs
|
al@598
|
1580 echo -n "."
|
al@598
|
1581 done
|
al@598
|
1582 echo
|
al@598
|
1583 # remove packages duplicates
|
al@598
|
1584 sort -u $lddlist.pkgs > $lddlist.final
|
al@598
|
1585 sort -u $missing > $missing.final
|
al@598
|
1586 rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing
|
al@598
|
1587 exit 0 ;;
|
pankso@1
|
1588 esac
|
pankso@1
|
1589
|
paul@62
|
1590 # Check if wanted is built now so we have separate log files.
|
pankso@295
|
1591 for wanted in $WANTED ; do
|
pascal@291
|
1592 if grep -q "^$wanted$" $blocked; then
|
al@596
|
1593 _ "WANTED package is blocked: \$wanted" | tee $LOGS/$pkg.log
|
pankso@427
|
1594 newline && rm -f $command && exit 1
|
pankso@217
|
1595 fi
|
pascal@291
|
1596 if grep -q "^$wanted$" $broken; then
|
al@596
|
1597 _ "WANTED package is broken: \$wanted" | tee $LOGS/$pkg.log
|
pankso@427
|
1598 newline && rm -f $command && exit 1
|
pankso@218
|
1599 fi
|
pascal@291
|
1600 if [ ! -d "$WOK/$wanted/install" ]; then
|
pascal@291
|
1601 cook "$wanted" || exit 1
|
pankso@137
|
1602 fi
|
pascal@291
|
1603 done
|
pankso@1
|
1604
|
pankso@1
|
1605 # Cook and pack or exit on error and log everything.
|
pascal@576
|
1606 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
|
pankso@15
|
1607 remove_deps | tee -a $LOGS/$pkg.log
|
pankso@1
|
1608 cookit_quality
|
pascal@576
|
1609 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
|
pankso@1
|
1610 clean_log
|
pankso@33
|
1611
|
pankso@33
|
1612 # Exit if any error in packing.
|
al@596
|
1613 lerror=$(_n "ERROR")
|
pascal@615
|
1614 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
|
pascal@615
|
1615 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors)"; then
|
pankso@33
|
1616 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
1617 rm -f $command && exit 1
|
pankso@33
|
1618 fi
|
pankso@358
|
1619
|
pankso@310
|
1620 # Create an XML feed
|
pankso@310
|
1621 gen_rss
|
pankso@358
|
1622
|
pankso@1
|
1623 # Time and summary
|
pankso@1
|
1624 time=$(($(date +%s) - $time))
|
pankso@1
|
1625 summary | tee -a $LOGS/$pkg.log
|
pankso@427
|
1626 newline
|
pankso@1
|
1627
|
pascal@683
|
1628 # We may want to install/update (outside aufs jail !).
|
pascal@683
|
1629 [ -s /aufs-umount.sh ] ||
|
pankso@428
|
1630 install_package
|
pankso@358
|
1631
|
al@596
|
1632 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
|
pankso@17
|
1633 # You want automation: use the Cooker Build Bot.
|
pankso@18
|
1634 rm -f $command ;;
|
pankso@1
|
1635 esac
|
pankso@1
|
1636
|
pankso@1
|
1637 exit 0
|