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
|
pankso@1
|
4 # before adding or modifing 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@16
|
11 # Share DB and status with the Cooker.
|
pankso@9
|
12 activity="$CACHE/activity"
|
pankso@16
|
13 command="$CACHE/command"
|
pankso@11
|
14 broken="$CACHE/broken"
|
pankso@47
|
15 blocked="$CACHE/blocked"
|
pankso@9
|
16
|
pankso@1
|
17 #
|
pankso@1
|
18 # Functions
|
pankso@1
|
19 #
|
pankso@1
|
20
|
pankso@1
|
21 usage() {
|
pankso@1
|
22 cat << EOT
|
pankso@1
|
23
|
pankso@147
|
24 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command] [list|--option]
|
pankso@1
|
25
|
pankso@1
|
26 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
|
paul@214
|
27 usage|help $(gettext "Display this short usage.")
|
paul@214
|
28 setup $(gettext "Setup your build environment.")
|
pankso@360
|
29 arm-setup $(gettext "Create packages DB lists and flavors.")
|
paul@214
|
30 test $(gettext "Test environment and cook a package.")
|
paul@214
|
31 list-wok $(gettext "List packages in the wok.")
|
paul@214
|
32 search $(gettext "Simple packages search function.")
|
paul@214
|
33 new $(gettext "Create a new package with a receipt".)
|
pankso@358
|
34 list $(gettext "Cook a list of packages.")
|
paul@214
|
35 clean-wok $(gettext "Clean-up all packages files.")
|
paul@214
|
36 clean-src $(gettext "Clean-up all packages sources.")
|
pankso@239
|
37 pkgdb $(gettext "Create packages DB lists and flavors.")
|
pankso@1
|
38
|
pankso@1
|
39 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
|
paul@214
|
40 --clean|-c Cook : $(gettext "clean the package in the wok.")
|
paul@214
|
41 --install|-i Cook : $(gettext "cook and install the package.")
|
paul@214
|
42 --getsrc|-gs Cook : $(gettext "get the package source tarball.")
|
paul@214
|
43 --block|-b Cook : $(gettext "Block a package so cook will skip it.")
|
paul@214
|
44 --unblock|-ub Cook : $(gettext "Unblock a blocked package.")
|
pankso@230
|
45 --interactive|-x New : $(gettext "create a receipt interactively.")
|
pankso@397
|
46 --wok Setup: $(gettext "clone the cooking wok from Hg repo.")
|
pankso@230
|
47 --stable Setup: $(gettext "clone the stable wok from Hg repo.")
|
pankso@230
|
48 --undigest Setup: $(gettext "clone the undigest wok from Hg repo.")
|
pankso@397
|
49 --tiny Setup: $(gettext "clone the tiny SliTaz wok from Hg repo.")
|
pankso@397
|
50 --forced Setup: $(gettext "force reinstall of chroot packages.")
|
pankso@239
|
51 --flavors Pkgdb: $(gettext "create up-to-date flavors files.")
|
pankso@1
|
52
|
pankso@1
|
53 EOT
|
pankso@1
|
54 exit 0
|
pankso@1
|
55 }
|
pankso@1
|
56
|
pankso@13
|
57 # Log activities, we want first letter capitalized.
|
pankso@9
|
58 log() {
|
pankso@27
|
59 grep ^[A-Z] | \
|
pankso@9
|
60 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
|
pankso@9
|
61 }
|
pankso@9
|
62
|
paul@62
|
63 # We don't want these escapes in web interface.
|
pankso@1
|
64 clean_log() {
|
pankso@1
|
65 sed -i -e s'|\[70G\[ \[1;32m| |' \
|
pankso@1
|
66 -e s'|\[0;39m \]||' $LOGS/$pkg.log
|
pankso@1
|
67 }
|
pankso@1
|
68
|
pankso@23
|
69 # Log broken packages.
|
pankso@23
|
70 broken() {
|
pankso@74
|
71 if ! grep -q "^$pkg$" $broken; then
|
pankso@74
|
72 echo "$pkg" >> $broken
|
pankso@74
|
73 fi
|
pankso@23
|
74 }
|
pankso@23
|
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
|
pankso@1
|
79 gettext -e "\nUnable to find package in the wok:"
|
pankso@1
|
80 echo -e " $pkg\n" && 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
|
pankso@9
|
86 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
|
pankso@9
|
87 exit 1
|
pankso@9
|
88 fi
|
pankso@9
|
89 }
|
pankso@9
|
90
|
paul@62
|
91 # Initialize files used in $CACHE
|
pankso@52
|
92 init_db_files() {
|
pankso@52
|
93 gettext "Creating directories structure in:"; echo " $SLITAZ"
|
pankso@52
|
94 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
|
pankso@52
|
95 gettext "Creating DB files in:"; echo " $CACHE"
|
pankso@52
|
96 for f in $activity $command $broken $blocked
|
pankso@52
|
97 do
|
pankso@52
|
98 touch $f
|
pankso@52
|
99 done
|
pankso@52
|
100 }
|
pankso@52
|
101
|
paul@62
|
102 # QA: check a receipt consistency before building.
|
pankso@9
|
103 receipt_quality() {
|
pankso@9
|
104 gettext -e "QA: checking package receipt...\n"
|
pankso@9
|
105 unset online
|
pankso@9
|
106 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
|
pankso@9
|
107 online="online"
|
pankso@9
|
108 fi
|
pankso@9
|
109 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
|
pankso@9
|
110 do
|
pankso@9
|
111 unset value
|
pascal@279
|
112 value="$(. $receipt ; eval echo \$$var)"
|
pankso@9
|
113 case "$var" in
|
pankso@9
|
114 PACKAGE|VERSION|SHORT_DESC)
|
pankso@9
|
115 if_empty_value ;;
|
pankso@9
|
116 CATEGORY)
|
pankso@9
|
117 [ -z "$value" ] && value="empty"
|
pankso@9
|
118 valid="base-system x-window utilities network graphics \
|
pankso@9
|
119 multimedia office development system-tools security games \
|
pankso@9
|
120 misc meta non-free"
|
pankso@9
|
121 if ! echo "$valid" | grep -q -w "$value"; then
|
paul@62
|
122 gettext "QA: unknown category:"; echo -e " $value\n"
|
pankso@9
|
123 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
|
pankso@61
|
131 gettext "QA: Unable to reach:"; echo -e " $value"
|
pankso@9
|
132 fi ;;
|
pankso@9
|
133 esac
|
pankso@9
|
134 done
|
pankso@9
|
135 }
|
pankso@9
|
136
|
pankso@9
|
137 # Executed before sourcing a receipt.
|
pankso@9
|
138 unset_receipt() {
|
pankso@9
|
139 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
|
pankso@368
|
140 unset HOST_ARCH CROSS_BUGS
|
pankso@9
|
141 }
|
pankso@9
|
142
|
paul@62
|
143 # Paths used in receipt and by cook itself.
|
pankso@1
|
144 set_paths() {
|
pankso@1
|
145 pkgdir=$WOK/$PACKAGE
|
pankso@1
|
146 src=$pkgdir/source/$PACKAGE-$VERSION
|
pankso@44
|
147 taz=$pkgdir/taz
|
pankso@44
|
148 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
|
pankso@1
|
149 fs=$pack/fs
|
pankso@1
|
150 stuff=$pkgdir/stuff
|
pankso@1
|
151 install=$pkgdir/install
|
pankso@1
|
152 if [ "$WANTED" ]; then
|
pascal@291
|
153 wanted=${WANTED%% *}
|
pascal@291
|
154 src=$WOK/$wanted/source/$wanted-$VERSION
|
pascal@291
|
155 install=$WOK/$wanted/install
|
pascal@291
|
156 wanted_stuff=$WOK/$wanted/stuff
|
pankso@1
|
157 fi
|
paul@243
|
158 # Kernel version is set from linux-api-headers since it is part of toolchain.
|
pankso@232
|
159 if [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
|
pankso@232
|
160 kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d '"' -f 2)
|
pankso@232
|
161 fi
|
pankso@9
|
162 # Old way compatibility.
|
pankso@1
|
163 _pkg=$install
|
pankso@1
|
164 }
|
pankso@1
|
165
|
pankso@144
|
166 # Create source tarball when URL is a SCM.
|
pankso@144
|
167 create_tarball() {
|
pankso@144
|
168 gettext "Creating tarball: "; echo "$tarball"
|
pankso@162
|
169 if [ "$LZMA_SRC" ]; then
|
pankso@162
|
170 tar -c $pkgsrc | lzma e $SRC/$tarball -si || exit 1
|
pankso@162
|
171 else
|
pankso@162
|
172 tar cjf $tarball $pkgsrc || exit 1
|
pankso@162
|
173 mv $tarball $SRC && rm -rf $pkgsrc
|
pankso@162
|
174 fi
|
pankso@144
|
175 }
|
pankso@144
|
176
|
pankso@145
|
177 # Get package source. For SCM we are in cache so clone here and create a
|
pankso@145
|
178 # tarball here.
|
pankso@1
|
179 get_source() {
|
pankso@115
|
180 pwd=$(pwd)
|
pankso@144
|
181 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
|
pankso@144
|
182 tarball=$pkgsrc.tar.bz2
|
pankso@162
|
183 [ "$LZMA_SRC" ] && tarball=$pkgsrc.tar.lzma
|
pankso@9
|
184 case "$WGET_URL" in
|
pankso@145
|
185 http://*|ftp://*)
|
pankso@9
|
186 # Busybox Wget is better!
|
pascal@268
|
187 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
|
pankso@145
|
188 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
|
pankso@145
|
189 https://*)
|
pankso@250
|
190 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
|
pankso@15
|
191 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
|
pankso@9
|
192 hg*|mercurial*)
|
pankso@29
|
193 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
|
pankso@9
|
194 url=${WGET_URL#hg|}
|
pankso@9
|
195 else
|
pankso@9
|
196 url=${WGET_URL#mercurial|}
|
pankso@9
|
197 fi
|
pankso@61
|
198 gettext -e "Getting source from Hg...\n"
|
pankso@61
|
199 echo "URL: $url"
|
pankso@9
|
200 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
|
pankso@246
|
201 if [ "$BRANCH" ]; then
|
pankso@246
|
202 echo "Hg branch: $BRANCH"
|
pankso@246
|
203 hg clone $url --rev $BRANCH $pkgsrc || \
|
pankso@246
|
204 (echo "ERROR: hg clone $url --rev $BRANCH" && exit 1)
|
pankso@246
|
205 else
|
pankso@246
|
206 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
|
pankso@246
|
207 fi
|
pankso@255
|
208 rm -rf $pkgsrc/.hg
|
pankso@144
|
209 create_tarball ;;
|
pankso@9
|
210 git*)
|
pankso@61
|
211 url=${WGET_URL#git|}
|
pankso@61
|
212 gettext -e "Getting source from Git...\n"
|
pankso@61
|
213 echo "URL: $url"
|
pankso@64
|
214 git clone $url $pkgsrc || (echo "ERROR: git clone $url" && exit 1)
|
pankso@63
|
215 if [ "$BRANCH" ]; then
|
pankso@146
|
216 echo "Git branch: $BRANCH"
|
pankso@358
|
217 cd $pkgsrc && git checkout $BRANCH && cd ..
|
pankso@63
|
218 fi
|
pankso@144
|
219 create_tarball ;;
|
pankso@144
|
220 cvs*)
|
pankso@144
|
221 url=${WGET_URL#cvs|}
|
pankso@144
|
222 mod=$PACKAGE
|
pankso@144
|
223 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
|
pankso@144
|
224 gettext -e "Getting source from CVS...\n"
|
pankso@144
|
225 echo "URL: $url"
|
pankso@146
|
226 [ "$CVS_MODULE" ] && echo "CVS module: $mod"
|
pankso@144
|
227 gettext "Cloning to: "; echo "$pwd/$mod"
|
pankso@144
|
228 cvs -d:$url co $mod && mv $mod $pkgsrc
|
pankso@144
|
229 create_tarball ;;
|
pankso@69
|
230 svn*|subversion*)
|
pankso@159
|
231 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
|
pankso@146
|
232 url=${WGET_URL#svn|}
|
pankso@146
|
233 else
|
pankso@146
|
234 url=${WGET_URL#subversion|}
|
pankso@146
|
235 fi
|
pankso@146
|
236 gettext -e "Getting source from SVN...\n"
|
pankso@146
|
237 echo "URL: $url"
|
pankso@161
|
238 if [ "$BRANCH" ]; then
|
pankso@161
|
239 echo t | svn co $url -r $BRANCH $pkgsrc
|
pankso@161
|
240 else
|
pankso@161
|
241 echo t | svn co $url $pkgsrc
|
pankso@161
|
242 fi
|
pankso@146
|
243 create_tarball ;;
|
pankso@9
|
244 *)
|
pankso@9
|
245 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
|
pankso@9
|
246 tee -a $LOGS/$PACKAGE.log
|
pankso@9
|
247 exit 1 ;;
|
pankso@9
|
248 esac
|
pankso@1
|
249 }
|
pankso@1
|
250
|
pankso@9
|
251 # Extract source package.
|
pankso@1
|
252 extract_source() {
|
pankso@177
|
253 if [ ! -s "$SRC/$TARBALL" ]; then
|
pankso@177
|
254 local url
|
pankso@177
|
255 url="http://mirror.slitaz.org/sources/packages"
|
pankso@177
|
256 url=$url/${TARBALL:0:1}/$TARBALL
|
pankso@177
|
257 gettext "Getting source from mirror:"; echo " $url"
|
pankso@177
|
258 busybox wget -c -P $SRC $url || echo -e "ERROR: wget $url"
|
pankso@177
|
259 fi
|
pankso@1
|
260 gettext "Extracting:"; echo " $TARBALL"
|
pankso@1
|
261 case "$TARBALL" in
|
pankso@120
|
262 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@178
|
263 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@1
|
264 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
|
pankso@42
|
265 *.tar) tar xf $SRC/$TARBALL ;;
|
pankso@42
|
266 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
|
pankso@42
|
267 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
268 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
269 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
|
pankso@238
|
270 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
|
pankso@191
|
271 *) cp $SRC/$TARBALL $(pwd) ;;
|
pankso@1
|
272 esac
|
pankso@1
|
273 }
|
pankso@1
|
274
|
pankso@9
|
275 # Display cooked package summary.
|
pankso@1
|
276 summary() {
|
pankso@1
|
277 cd $WOK/$pkg
|
pankso@1
|
278 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
|
pankso@1
|
279 fs=$(du -sh taz/* | awk '{print $1}')
|
pankso@44
|
280 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
|
pankso@44
|
281 files=$(cat taz/$pkg-*/files.list | wc -l)
|
pankso@18
|
282 cookdate=$(date "+%Y-%m-%d %H:%M")
|
pankso@101
|
283 sec=$time
|
pascal@280
|
284 div=$(( ($time + 30) / 60))
|
pankso@112
|
285 [ "$div" != 0 ] && min="~ ${div}m"
|
pankso@1
|
286 gettext "Summary for:"; echo " $PACKAGE $VERSION"
|
pankso@1
|
287 separator
|
pankso@67
|
288 [ "$prod" ] && echo "Produced : $prod"
|
pankso@1
|
289 cat << EOT
|
pankso@1
|
290 Packed : $fs
|
pankso@1
|
291 Compressed : $size
|
pankso@18
|
292 Files : $files
|
pankso@102
|
293 Cook time : ${sec}s $min
|
pankso@18
|
294 Cook date : $cookdate
|
pankso@392
|
295 Host arch : $ARCH
|
pankso@1
|
296 $(separator)
|
pankso@1
|
297 EOT
|
pankso@1
|
298 }
|
pankso@1
|
299
|
paul@62
|
300 # Display debugging error info.
|
pankso@15
|
301 debug_info() {
|
pankso@17
|
302 echo -e "\nDebug information"
|
pankso@15
|
303 separator
|
pankso@48
|
304 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
|
pankso@76
|
305 for error in \
|
pankso@77
|
306 ERROR "No package" "cp: can't" "can't open" "can't cd" \
|
pankso@76
|
307 "error:" "fatal error:"
|
pankso@34
|
308 do
|
pankso@34
|
309 fgrep "$error" $LOGS/$pkg.log
|
pankso@34
|
310 done
|
pankso@15
|
311 separator && echo ""
|
pankso@15
|
312 }
|
pankso@15
|
313
|
pankso@1
|
314 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
|
pankso@1
|
315 # so some packages need to copy these files with the receipt and genpkg_rules.
|
pankso@421
|
316 copy_generic_files() {
|
pankso@1
|
317 # $LOCALE is set in cook.conf
|
pankso@281
|
318 if [ "$LOCALE" ]; then
|
pankso@260
|
319 if [ -d "$install/usr/share/locale" ]; then
|
pankso@1
|
320 mkdir -p $fs/usr/share/locale
|
pankso@1
|
321 for i in $LOCALE
|
pankso@1
|
322 do
|
pankso@260
|
323 if [ -d "$install/usr/share/locale/$i" ]; then
|
pankso@260
|
324 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
|
pankso@1
|
325 fi
|
pankso@1
|
326 done
|
pankso@1
|
327 fi
|
pankso@1
|
328 fi
|
pankso@1
|
329
|
pankso@1
|
330 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
|
pankso@1
|
331 if [ "$GENERIC_PIXMAPS" != "no" ]; then
|
pankso@260
|
332 if [ -d "$install/usr/share/pixmaps" ]; then
|
pankso@1
|
333 mkdir -p $fs/usr/share/pixmaps
|
pankso@260
|
334 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
|
pankso@281
|
335 $fs/usr/share/pixmaps 2>/dev/null || continue
|
pankso@260
|
336 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
|
pankso@281
|
337 $fs/usr/share/pixmaps 2>/dev/null || continue
|
pankso@1
|
338 fi
|
pankso@1
|
339
|
pankso@1
|
340 # Custom or homemade PNG pixmap can be in stuff.
|
pankso@1
|
341 if [ -f "$stuff/$PACKAGE.png" ]; then
|
pankso@1
|
342 mkdir -p $fs/usr/share/pixmaps
|
pankso@1
|
343 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@1
|
344 fi
|
pankso@1
|
345 fi
|
pankso@1
|
346
|
pankso@1
|
347 # Desktop entry (.desktop).
|
erjo@284
|
348 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
|
erjo@284
|
349 if [ "$GENERIC_MENUS" != "no" ]; then
|
erjo@284
|
350 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
|
erjo@284
|
351 cp -a $install/usr/share/applications $fs/usr/share
|
erjo@284
|
352 fi
|
pankso@1
|
353 fi
|
pankso@1
|
354
|
pankso@1
|
355 # Homemade desktop file(s) can be in stuff.
|
pankso@1
|
356 if [ -d "$stuff/applications" ]; then
|
pankso@1
|
357 mkdir -p $fs/usr/share
|
pankso@1
|
358 cp -a $stuff/applications $fs/usr/share
|
pankso@1
|
359 fi
|
pankso@1
|
360 if [ -f "$stuff/$PACKAGE.desktop" ]; then
|
pankso@1
|
361 mkdir -p $fs/usr/share/applications
|
pankso@1
|
362 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@1
|
363 fi
|
pankso@1
|
364 }
|
pankso@1
|
365
|
pankso@67
|
366 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
|
pankso@415
|
367 # as removing uneeded files like in Python packages. Cross compiled binaries
|
pankso@415
|
368 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
|
pankso@421
|
369 strip_package() {
|
pankso@415
|
370 case "$ARCH" in
|
pankso@415
|
371 arm|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
|
pankso@415
|
372 *) export STRIP=strip ;;
|
pankso@415
|
373 esac
|
pankso@67
|
374 gettext "Executing strip on all files..."
|
pankso@1
|
375 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
|
pankso@1
|
376 do
|
pankso@1
|
377 if [ -d "$dir" ]; then
|
pankso@414
|
378 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@1
|
379 fi
|
pankso@1
|
380 done
|
pankso@414
|
381 find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@414
|
382 find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
|
pankso@1
|
383 status
|
pankso@67
|
384
|
pankso@117
|
385 # Remove Python .pyc and .pyo from packages.
|
pankso@150
|
386 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
|
pankso@68
|
387 gettext "Removing Python compiled files..."
|
pankso@67
|
388 find $fs -type f -name "*.pyc" -delete 2>/dev/null
|
pankso@67
|
389 find $fs -type f -name "*.pyo" -delete 2>/dev/null
|
pankso@117
|
390 status
|
pankso@117
|
391 fi
|
pankso@117
|
392
|
pankso@117
|
393 # Remove Perl perllocal.pod and .packlist from packages.
|
pankso@117
|
394 if echo "$DEPENDS" | fgrep -q "perl"; then
|
pankso@117
|
395 gettext "Removing Perl compiled files..."
|
pankso@67
|
396 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
|
pankso@67
|
397 find $fs -type f -name ".packlist" -delete 2>/dev/null
|
pankso@67
|
398 status
|
pankso@67
|
399 fi
|
pankso@1
|
400 }
|
pankso@1
|
401
|
pankso@8
|
402 # Remove installed deps.
|
pankso@8
|
403 remove_deps() {
|
pankso@8
|
404 # Now remove installed build deps.
|
pankso@113
|
405 diff="$CACHE/installed.cook.diff"
|
pankso@113
|
406 if [ -s "$CACHE/installed.cook.diff" ]; then
|
pankso@113
|
407 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
|
pankso@113
|
408 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
|
pankso@8
|
409 gettext "Build dependencies to remove:"; echo " $nb"
|
pankso@8
|
410 gettext "Removing:"
|
pankso@8
|
411 for dep in $deps
|
pankso@8
|
412 do
|
pankso@8
|
413 echo -n " $dep"
|
pankso@205
|
414 echo 'y' | tazpkg remove $dep >/dev/null
|
pankso@8
|
415 done
|
pankso@16
|
416 echo -e "\n"
|
pankso@113
|
417 # Keep the last diff for debug and info.
|
pankso@113
|
418 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
|
pankso@1
|
419 fi
|
pankso@1
|
420 }
|
pankso@1
|
421
|
pankso@1
|
422 # The main cook function.
|
pankso@1
|
423 cookit() {
|
pankso@11
|
424 echo "Cook: $PACKAGE $VERSION"
|
pankso@9
|
425 separator
|
pankso@1
|
426 set_paths
|
pankso@359
|
427
|
pankso@377
|
428 # Handle cross-tools.
|
pankso@359
|
429 case "$ARCH" in
|
pankso@359
|
430 arm|x86_64)
|
paul@387
|
431 # CROSS_COMPILE is used by at least Busybox and the kernel to set
|
pankso@405
|
432 # the cross-tools prefix but first check if sysroot is used.
|
pankso@405
|
433 if [ "$SYSROOT" ]; then
|
pankso@405
|
434 echo "cook: $ARCH sysroot: $SYSROOT"
|
pankso@405
|
435 else
|
pankso@405
|
436 echo "cook: adding /usr/cross/$ARCH/bin to PATH"
|
pankso@421
|
437 export PATH=$PATH:$CROSS_PREFIX/bin
|
pankso@405
|
438 fi
|
pankso@421
|
439 export CROSS_COMPILE=${HOST_SYSTEM}-
|
pankso@377
|
440 echo "cook: using cross-tools: $CROSS_COMPILE"
|
pankso@359
|
441 export CC=${HOST_SYSTEM}-gcc
|
pankso@377
|
442 export CXX=${HOST_SYSTEM}-g++
|
pankso@377
|
443 export AR=${HOST_SYSTEM}-ar
|
pankso@377
|
444 export AS=${HOST_SYSTEM}-as
|
pankso@377
|
445 export RANLIB=${HOST_SYSTEM}-ranlib
|
pankso@377
|
446 export LD=${HOST_SYSTEM}-ld
|
pankso@421
|
447 export STRIP=${HOST_SYSTEM}-strip ;;
|
pankso@359
|
448 esac
|
pankso@359
|
449
|
pankso@9
|
450 [ "$QA" ] && receipt_quality
|
pankso@44
|
451 cd $pkgdir
|
pankso@33
|
452 rm -rf install taz source
|
pankso@1
|
453
|
pankso@1
|
454 # Disable -pipe if less than 512Mb free RAM.
|
pankso@1
|
455 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
|
pankso@1
|
456 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
|
pankso@1
|
457 gettext -e "Disabling -pipe compile flag: $free RAM\n"
|
pankso@1
|
458 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
|
pankso@47
|
459 CXXFLAGS="${CXXFLAGS/-pipe}" && \
|
pankso@47
|
460 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
|
pankso@1
|
461 fi
|
pankso@1
|
462 unset free
|
pankso@1
|
463
|
pankso@232
|
464 # Export flags and path to be used by make and receipt.
|
pankso@44
|
465 DESTDIR=$pkgdir/install
|
pankso@232
|
466 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
|
pankso@358
|
467 #LDFLAGS
|
pankso@1
|
468
|
pankso@126
|
469 # Check for build deps and handle implicit depends of *-dev packages
|
pankso@126
|
470 # (ex: libusb-dev :: libusb).
|
pankso@215
|
471 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
|
pankso@215
|
472 touch $CACHE/installed.local $CACHE/installed.web
|
pankso@215
|
473 [ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
|
pankso@1
|
474 for dep in $BUILD_DEPENDS
|
pankso@1
|
475 do
|
pankso@126
|
476 implicit=${dep%-dev}
|
pankso@131
|
477 for i in $dep $implicit
|
pankso@126
|
478 do
|
pankso@131
|
479 if [ ! -f "$INSTALLED/$i/receipt" ]; then
|
paul@174
|
480 # Try local package first. In some cases implicit doesn't exist, ex:
|
paul@174
|
481 # libboost-dev exists but not libboost, so check if we got vers.
|
pankso@173
|
482 unset vers
|
pascal@343
|
483 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
|
pankso@131
|
484 if [ -f "$PKGS/$i-$vers.tazpkg" ]; then
|
pankso@215
|
485 echo $i-$vers.tazpkg >> $CACHE/installed.local
|
pankso@126
|
486 else
|
paul@227
|
487 # Priority to package version in wok (maybe more up-to-date)
|
paul@227
|
488 # than the mirrored one.
|
pankso@173
|
489 if [ "$vers" ]; then
|
pankso@202
|
490 if fgrep -q $i-$vers $DB/packages.list; then
|
pankso@215
|
491 echo $i >> $CACHE/installed.web
|
pankso@198
|
492 else
|
paul@211
|
493 # So package exists in wok but not available.
|
pankso@215
|
494 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
|
pankso@215
|
495 echo $i >> $CACHE/missing.dep
|
pankso@198
|
496 fi
|
pankso@225
|
497 else
|
pankso@225
|
498 # Package is not in wok but may be in repo.
|
pankso@225
|
499 if fgrep -q $i-$vers $DB/packages.list; then
|
pankso@225
|
500 echo $i >> $CACHE/installed.web
|
pankso@225
|
501 else
|
paul@227
|
502 echo "ERROR: unknown dep $i" && exit 1
|
pankso@225
|
503 fi
|
pankso@173
|
504 fi
|
pankso@126
|
505 fi
|
pankso@1
|
506 fi
|
pankso@126
|
507 done
|
pankso@1
|
508 done
|
pankso@225
|
509
|
pankso@215
|
510 # Get the list of installed packages
|
pankso@215
|
511 cd $INSTALLED && ls -1 > $CACHE/installed.list
|
pankso@358
|
512
|
paul@211
|
513 # Have we a missing build dep to cook ?
|
pankso@215
|
514 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
|
pankso@205
|
515 gettext -e "Auto cook config is set : AUTO_COOK\n"
|
pankso@204
|
516 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
|
pankso@224
|
517 for i in $(uniq $CACHE/missing.dep)
|
pankso@204
|
518 do
|
pankso@205
|
519 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
|
pankso@204
|
520 tee -a $LOGS/$PACKAGE.log.$$
|
pankso@205
|
521 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
|
pankso@205
|
522 fgrep "remove: " $LOGS/$i.log && \
|
pankso@205
|
523 fgrep "Removing: " $LOGS/$i.log && echo "") | \
|
pankso@204
|
524 tee -a $LOGS/$PACKAGE.log.$$ && break
|
pankso@204
|
525 done
|
pankso@215
|
526 rm -f $CACHE/missing.dep
|
pankso@204
|
527 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
|
pankso@204
|
528 fi
|
pankso@358
|
529
|
paul@211
|
530 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
|
paul@211
|
531 # is enabled and cook fails we have ERROR in log, if no auto cook we have
|
pankso@204
|
532 # missing dep in cached file.
|
pankso@215
|
533 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
|
pankso@215
|
534 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
|
pankso@215
|
535 echo "ERROR: missing dep $nb" && exit 1
|
pankso@202
|
536 fi
|
pankso@358
|
537
|
pankso@423
|
538 # Set root path when cross compiling. ARM tested but not x86_64
|
pankso@423
|
539 case "$ARCH" in
|
pankso@423
|
540 arm) root=$CROSS_PREFIX ;;
|
pankso@423
|
541 esac
|
pankso@423
|
542
|
pankso@215
|
543 # Install local packages.
|
pankso@215
|
544 cd $PKGS
|
pankso@224
|
545 for i in $(uniq $CACHE/installed.local)
|
pankso@215
|
546 do
|
pankso@224
|
547 gettext "Installing dep (pkg/local):"; echo " $i"
|
pankso@423
|
548 tazpkg install $i --root=$root >/dev/null
|
pankso@215
|
549 done
|
pankso@358
|
550
|
pankso@215
|
551 # Install web or cached packages (if mirror is set to $PKGS we only
|
pankso@215
|
552 # use local packages).
|
pankso@224
|
553 for i in $(uniq $CACHE/installed.web)
|
pankso@215
|
554 do
|
pankso@228
|
555 gettext "Installing dep (web/cache):"; echo " $i"
|
pankso@423
|
556 tazpkg get-install $i --root=$root >/dev/null
|
pankso@215
|
557 done
|
pankso@358
|
558
|
pankso@215
|
559 # If a cook failed deps are removed.
|
pankso@215
|
560 cd $INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
|
pankso@215
|
561 [ ! -s "installed.cook.diff" ] && \
|
pankso@215
|
562 busybox diff installed.list installed.cook > installed.cook.diff
|
pankso@215
|
563 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
|
pankso@202
|
564
|
pankso@1
|
565 # Get source tarball and make sure we have source dir named:
|
paul@62
|
566 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
|
paul@62
|
567 # tarball if it exists.
|
pankso@1
|
568 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
|
pankso@1
|
569 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
|
pankso@10
|
570 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
|
pankso@190
|
571 LZMA_SRC=""
|
pankso@1
|
572 else
|
pankso@1
|
573 get_source || exit 1
|
pankso@1
|
574 fi
|
pankso@1
|
575 fi
|
pankso@242
|
576 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
|
pankso@1
|
577 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
|
pascal@268
|
578 if ! extract_source ; then
|
pascal@268
|
579 get_source
|
pascal@268
|
580 extract_source || exit 1
|
pascal@268
|
581 fi
|
pankso@190
|
582 if [ "$LZMA_SRC" ]; then
|
pankso@190
|
583 cd $pkgdir/source
|
pankso@190
|
584 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
|
pankso@190
|
585 mv tmp tmp-1 && mkdir tmp
|
pankso@190
|
586 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
|
pankso@190
|
587 fi
|
pankso@190
|
588 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
|
pankso@358
|
589 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
|
pankso@190
|
590 fi
|
pankso@190
|
591 fi
|
pankso@190
|
592 cd $pkgdir/source/tmp
|
paul@62
|
593 # Some archives are not well done and don't extract to one dir (ex lzma).
|
pankso@57
|
594 files=$(ls | wc -l)
|
pankso@244
|
595 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
|
pankso@244
|
596 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
|
pankso@244
|
597 mv * ../$PACKAGE-$VERSION/$TARBALL
|
pankso@57
|
598 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
|
pankso@57
|
599 mv * ../$PACKAGE-$VERSION
|
pankso@1
|
600 cd .. && rm -rf tmp
|
pankso@1
|
601 fi
|
pankso@1
|
602
|
pankso@9
|
603 # Execute receipt rules.
|
pankso@44
|
604 if grep -q ^compile_rules $receipt; then
|
pankso@352
|
605 echo "Executing: compile_rules"
|
pankso@352
|
606 echo "CFLAGS : $CFLAGS"
|
pankso@358
|
607 #echo "LDFLAGS : $LDFLAGS"
|
pankso@55
|
608 [ -d "$src" ] && cd $src
|
pankso@97
|
609 compile_rules $@ || exit 1
|
pankso@10
|
610 # Stay compatible with _pkg
|
pankso@55
|
611 [ -d "$src/_pkg" ] && mv $src/_pkg $install
|
pankso@9
|
612 # QA: compile_rules success so valid.
|
pankso@9
|
613 mkdir -p $install
|
pankso@9
|
614 else
|
pankso@9
|
615 # QA: No compile_rules so no error, valid.
|
pankso@9
|
616 mkdir -p $install
|
pankso@1
|
617 fi
|
pankso@1
|
618 separator && echo ""
|
pankso@360
|
619
|
pankso@360
|
620 # Execute testsuite.
|
pankso@360
|
621 if grep -q ^testsuite $receipt; then
|
pankso@360
|
622 echo "Running testsuite"
|
pankso@360
|
623 separator
|
pankso@360
|
624 testsuite $@ || exit 1
|
pankso@360
|
625 separator && echo ""
|
pankso@360
|
626 fi
|
pankso@1
|
627 }
|
pankso@1
|
628
|
pankso@1
|
629 # Cook quality assurance.
|
pankso@1
|
630 cookit_quality() {
|
pankso@9
|
631 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
|
pankso@15
|
632 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
|
pankso@9
|
633 fi
|
pankso@9
|
634 # ERROR can be echoed any time in cookit()
|
pankso@33
|
635 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@17
|
636 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
637 rm -f $command && exit 1
|
pankso@1
|
638 fi
|
pankso@1
|
639 }
|
pankso@1
|
640
|
pankso@16
|
641 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
|
paul@62
|
642 # but it doesn't handle EXTRAVERSION.
|
pankso@1
|
643 packit() {
|
pankso@1
|
644 set_paths
|
pankso@359
|
645
|
pankso@359
|
646 # Handle cross compilation
|
pankso@359
|
647 case "$ARCH" in
|
pankso@359
|
648 arm|x86_64) VERSION="$VERSION-$ARCH" ;;
|
pankso@359
|
649 esac
|
pankso@359
|
650
|
pankso@55
|
651 echo "Pack: $PACKAGE $VERSION"
|
pankso@1
|
652 separator
|
pankso@359
|
653
|
pankso@44
|
654 if grep -q ^genpkg_rules $receipt; then
|
pankso@16
|
655 gettext -e "Executing: genpkg_rules\n"
|
pankso@259
|
656 set -e && cd $pkgdir && mkdir -p $fs
|
pankso@232
|
657 genpkg_rules || echo -e "\nERROR: genpkg_rules failed\n" >> \
|
pankso@234
|
658 $LOGS/$pkg.log
|
pankso@241
|
659 else
|
pankso@241
|
660 gettext "No packages rules: meta package"; echo
|
pankso@241
|
661 mkdir -p $fs
|
pankso@16
|
662 fi
|
pankso@98
|
663
|
pankso@98
|
664 # First QA check to stop now if genpkg_rules failed.
|
pankso@98
|
665 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@98
|
666 exit 1
|
pankso@98
|
667 fi
|
pankso@358
|
668
|
pankso@44
|
669 cd $taz
|
pankso@1
|
670 for file in receipt description.txt
|
pankso@1
|
671 do
|
pankso@1
|
672 [ ! -f "../$file" ] && continue
|
pankso@1
|
673 gettext "Copying"; echo -n " $file..."
|
pankso@1
|
674 cp -f ../$file $pack && chown 0.0 $pack/$file && status
|
pankso@1
|
675 done
|
pankso@119
|
676 copy_generic_files
|
pankso@358
|
677
|
paul@62
|
678 # Create files.list with redirecting find output.
|
pankso@16
|
679 gettext "Creating the list of files..." && cd $fs
|
pankso@16
|
680 find . -type f -print > ../files.list
|
pankso@16
|
681 find . -type l -print >> ../files.list
|
pankso@16
|
682 cd .. && sed -i s/'^.'/''/ files.list
|
pankso@16
|
683 status
|
pankso@43
|
684
|
pankso@119
|
685 # Strip and stuff files.
|
pankso@43
|
686 strip_package
|
pankso@43
|
687
|
pankso@43
|
688 # Md5sum of files.
|
pankso@16
|
689 gettext "Creating md5sum of files..."
|
pankso@16
|
690 while read file; do
|
pankso@16
|
691 [ -L "fs$file" ] && continue
|
pankso@16
|
692 [ -f "fs$file" ] || continue
|
pankso@16
|
693 case "$file" in
|
pankso@232
|
694 /lib/modules/*/modules.*|*.pyc) continue ;;
|
pankso@16
|
695 esac
|
pankso@16
|
696 md5sum "fs$file" | sed 's/ fs/ /'
|
pankso@16
|
697 done < files.list > md5sum
|
pankso@16
|
698 status
|
pankso@16
|
699 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
|
pankso@16
|
700 description.txt 2> /dev/null | awk \
|
pankso@16
|
701 '{ sz=$1 } END { print sz }')
|
pankso@358
|
702
|
pankso@16
|
703 # Build cpio archives.
|
pankso@16
|
704 gettext "Compressing the fs... "
|
pankso@16
|
705 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
|
pankso@16
|
706 rm -rf fs
|
pankso@16
|
707 status
|
pankso@16
|
708 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
|
pankso@16
|
709 md5sum description.txt 2> /dev/null | awk \
|
pankso@16
|
710 '{ sz=$1 } END { print sz }')
|
pankso@16
|
711 gettext "Updating receipt sizes..."
|
pankso@16
|
712 sed -i s/^PACKED_SIZE.*$// receipt
|
pankso@16
|
713 sed -i s/^UNPACKED_SIZE.*$// receipt
|
pankso@16
|
714 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
pankso@16
|
715 status
|
pankso@16
|
716
|
pankso@16
|
717 # Set extra version.
|
pankso@16
|
718 if [ "$EXTRAVERSION" ]; then
|
pankso@16
|
719 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
|
pankso@16
|
720 sed -i s/^EXTRAVERSION.*$// receipt
|
pankso@16
|
721 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
|
pankso@16
|
722 status
|
pankso@16
|
723 fi
|
pankso@16
|
724
|
pankso@16
|
725 # Compress.
|
pankso@16
|
726 gettext "Creating full cpio archive... "
|
pankso@16
|
727 find . -print | cpio -o -H newc --quiet > \
|
pankso@16
|
728 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
|
pankso@16
|
729 status
|
pankso@16
|
730 gettext "Restoring original package tree... "
|
pankso@16
|
731 unlzma -c fs.cpio.lzma | cpio -idm --quiet
|
pankso@16
|
732 status
|
pankso@16
|
733 rm fs.cpio.lzma && cd ..
|
pankso@43
|
734
|
pankso@43
|
735 # QA and give info.
|
pankso@43
|
736 tazpkg=$(ls *.tazpkg)
|
pankso@43
|
737 packit_quality
|
pankso@43
|
738 separator && gettext "Package:"; echo -e " $tazpkg\n"
|
pankso@1
|
739 }
|
pankso@1
|
740
|
paul@62
|
741 # Verify package quality and consistency.
|
pankso@8
|
742 packit_quality() {
|
pankso@157
|
743 #gettext "QA: Checking for broken link..."
|
pankso@157
|
744 #link=$(find $fs/usr -type l -follow)
|
pankso@157
|
745 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
|
pankso@157
|
746 #status
|
pankso@358
|
747
|
pankso@142
|
748 # Exit if any error found in log file.
|
pankso@33
|
749 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@32
|
750 rm -f $command && exit 1
|
pankso@8
|
751 fi
|
pankso@358
|
752
|
pankso@44
|
753 gettext "QA: Checking for empty package..."
|
pankso@45
|
754 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
|
pankso@259
|
755 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
|
pankso@44
|
756 echo -e "\nERROR: empty package"
|
pankso@32
|
757 rm -f $command && exit 1
|
pankso@8
|
758 else
|
pankso@134
|
759 # Ls sort by name so the first file is the one we want.
|
pankso@136
|
760 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
|
pankso@134
|
761 status
|
pankso@154
|
762 if [ -f "$old" ]; then
|
pankso@265
|
763 gettext "Removing old: $(basename $old)"
|
pankso@135
|
764 rm -f $old && status
|
pankso@154
|
765 fi
|
pankso@134
|
766 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
|
pankso@11
|
767 sed -i /^${pkg}$/d $broken
|
pankso@265
|
768 #gettext "Removing source tree..."
|
pankso@265
|
769 #rm -f $WOK/$pkg/source && status
|
pankso@8
|
770 fi
|
pankso@8
|
771 }
|
pankso@8
|
772
|
pankso@421
|
773 tac() {
|
pascal@285
|
774 sed '1!G;h;$!d' $1
|
pascal@285
|
775 }
|
pascal@285
|
776
|
pascal@285
|
777 # Launch the cook command into a chroot jail protected by aufs.
|
pascal@285
|
778 # The current filesystems are used read-only and updates are
|
pascal@285
|
779 # stored in a separate branch.
|
pascal@285
|
780 try_aufs_chroot() {
|
pascal@285
|
781
|
pascal@286
|
782 base=/dev/shm/aufsmnt$$
|
pascal@286
|
783
|
pascal@285
|
784 # Can we setup the chroot ? Is it already done ?
|
pascal@292
|
785 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
|
pascal@285
|
786 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
|
pascal@285
|
787 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
|
pascal@286
|
788 mkdir ${base}root ${base}rw || return
|
pascal@285
|
789
|
pascal@285
|
790 echo "Setup aufs chroot..."
|
pascal@285
|
791
|
pascal@285
|
792 # Sanity check
|
pascal@286
|
793 for i in / /proc /sys /dev/shm /home ; do
|
pascal@285
|
794 case " $AUFS_MOUNTS " in
|
pascal@285
|
795 *\ $i\ *) ;;
|
pascal@285
|
796 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
|
pascal@285
|
797 esac
|
pascal@285
|
798 done
|
pascal@285
|
799 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
|
pascal@285
|
800 mount --bind $mnt ${base}root$mnt
|
pascal@285
|
801 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
|
pascal@285
|
802 echo "Aufs mountage failure"
|
pascal@285
|
803 umount ${base}root
|
pascal@285
|
804 rmdir ${base}*
|
pascal@285
|
805 return
|
pascal@285
|
806 fi
|
pascal@285
|
807 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
|
pascal@285
|
808 done
|
pascal@285
|
809
|
pascal@285
|
810 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
|
pascal@285
|
811 status=$?
|
pascal@285
|
812
|
paul@342
|
813 echo "Leaving aufs chroot..."
|
pascal@285
|
814 tac ${base}rw/aufs-umount.sh | sh
|
pascal@285
|
815 rm -rf ${base}rw
|
pascal@285
|
816 umount ${base}root
|
pascal@285
|
817 rmdir $base*
|
pascal@285
|
818
|
pascal@285
|
819 # Install package if requested
|
pascal@285
|
820 if [ "$inst" ]; then
|
pascal@285
|
821 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pascal@285
|
822 cd $PKGS && tazpkg install \
|
pascal@285
|
823 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
|
pascal@285
|
824 else
|
pascal@285
|
825 gettext -e "Unable to install package, build has failed.\n\n"
|
pascal@285
|
826 exit 1
|
pascal@285
|
827 fi
|
pascal@285
|
828 fi
|
pankso@358
|
829
|
paul@387
|
830 # Skip install if target host doesn't match build system.
|
pankso@369
|
831 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
|
pankso@306
|
832 # Install package if part of the chroot to keep env up-to-date.
|
pankso@376
|
833 if [ -d "$INSTALLED/$pkg" ] && [ "$build" == "$ARCH" ]; then
|
pankso@308
|
834 . /etc/slitaz/cook.conf
|
pankso@308
|
835 . $WOK/$pkg/taz/$pkg-*/receipt
|
pankso@376
|
836 echo "Updating $ARCH chroot environment..."
|
pankso@308
|
837 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION})" | log
|
pankso@306
|
838 cd $PKGS && tazpkg install \
|
pankso@308
|
839 $pkg-${VERSION}${EXTRAVERSION}.tazpkg --forced
|
pankso@306
|
840 fi
|
pankso@358
|
841 exit $status
|
pascal@285
|
842 }
|
pascal@285
|
843
|
paul@387
|
844 # Create a XML feed for freshly built packages.
|
pankso@310
|
845 gen_rss() {
|
pankso@310
|
846 pubdate=$(date "+%a, %d %b %Y %X")
|
pankso@310
|
847 cat > $FEEDS/$pkg.xml << EOT
|
pankso@310
|
848 <item>
|
pankso@310
|
849 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
|
pankso@310
|
850 <link>${COOKER_URL}?pkg=$PACKAGE</link>
|
pankso@310
|
851 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
|
pankso@310
|
852 <pubDate>$pubdate</pubDate>
|
pankso@310
|
853 <description>$SHORT_DESC</description>
|
pankso@310
|
854 </item>
|
pankso@310
|
855 EOT
|
pankso@310
|
856 }
|
pankso@310
|
857
|
pankso@1
|
858 #
|
pankso@1
|
859 # Commands
|
pankso@1
|
860 #
|
pankso@1
|
861
|
pankso@1
|
862 case "$1" in
|
pankso@32
|
863 usage|help|-u|-h)
|
pankso@1
|
864 usage ;;
|
pankso@1
|
865 list-wok)
|
pankso@52
|
866 gettext -e "\nList of packages in:"; echo " $WOK"
|
pankso@1
|
867 separator
|
pankso@1
|
868 cd $WOK && ls -1
|
pankso@1
|
869 separator
|
pankso@1
|
870 echo -n "Packages: " && ls | wc -l
|
pankso@1
|
871 echo "" ;;
|
pankso@378
|
872 activity)
|
pankso@378
|
873 cat $activity ;;
|
pankso@69
|
874 search)
|
pankso@69
|
875 # Just a simple search function, we dont need more actually.
|
pankso@69
|
876 query="$2"
|
pankso@69
|
877 gettext -e "\nSearch results for:"; echo " $query"
|
pankso@69
|
878 separator
|
pankso@69
|
879 cd $WOK && ls -1 | grep "$query"
|
pankso@69
|
880 separator && echo "" ;;
|
pankso@1
|
881 setup)
|
pankso@1
|
882 # Setup a build environment
|
pankso@1
|
883 check_root
|
pankso@11
|
884 echo "Cook: setting up the environment" | log
|
pankso@1
|
885 gettext -e "\nSetting up your environment\n"
|
pankso@1
|
886 separator && cd $SLITAZ
|
pankso@52
|
887 init_db_files
|
pankso@397
|
888 gettext "Checking for packages to install..."; echo
|
pankso@397
|
889 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
|
pankso@397
|
890 # ARCH-setup or 'cross check-env' should be used before: cook setup
|
pankso@397
|
891 case "$ARCH" in
|
pankso@421
|
892 arm|x86_64)
|
pankso@397
|
893 if [ ! -x "/usr/bin/cross" ]; then
|
pankso@397
|
894 gettext "ERROR: cross is not installed"; echo
|
pankso@397
|
895 exit 1
|
pankso@397
|
896 fi
|
pankso@397
|
897 gettext "Using config file: /etc/slitaz/cross.conf"; echo
|
pankso@397
|
898 . /etc/slitaz/cross.conf ;;
|
pankso@397
|
899 esac
|
pankso@397
|
900 for pkg in $SETUP_PKGS; do
|
pankso@397
|
901 if [ "$forced" ]; then
|
pankso@421
|
902 tazpkg -gi $pkg --forced
|
pankso@397
|
903 else
|
pankso@407
|
904 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
|
pankso@397
|
905 fi
|
pankso@397
|
906 done
|
pankso@1
|
907
|
pankso@1
|
908 # Handle --options
|
pankso@1
|
909 case "$2" in
|
pankso@397
|
910 --wok)
|
pankso@230
|
911 hg clone $WOK_URL wok || exit 1 ;;
|
pankso@230
|
912 --stable)
|
pankso@230
|
913 hg clone $WOK_URL-stable wok || exit 1 ;;
|
pankso@230
|
914 --undigest)
|
pankso@230
|
915 hg clone $WOK_URL-undigest wok || exit 1 ;;
|
pankso@397
|
916 --tiny)
|
pankso@397
|
917 hg clone $WOK_URL-tiny wok || exit 1 ;;
|
pankso@1
|
918 esac
|
pankso@1
|
919
|
pankso@1
|
920 # SliTaz group and permissions
|
pankso@1
|
921 if ! grep -q ^slitaz /etc/group; then
|
pankso@1
|
922 gettext -e "Adding group: slitaz\n"
|
pankso@1
|
923 addgroup slitaz
|
pankso@1
|
924 fi
|
pankso@1
|
925 gettext -e "Setting permissions for slitaz group...\n"
|
pascal@277
|
926 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
|
pascal@277
|
927 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
|
pankso@1
|
928 separator
|
pankso@1
|
929 gettext -e "All done, ready to cook packages :-)\n\n" ;;
|
pankso@395
|
930 *-setup)
|
pankso@395
|
931 # Setup for cross compiling.
|
pankso@395
|
932 arch=${1%-setup}
|
pankso@397
|
933 check_root
|
pankso@397
|
934 echo ""
|
pankso@421
|
935 boldify $(gettext "Setting up your cross environment")
|
pankso@397
|
936 separator
|
pankso@397
|
937 init_db_files
|
pankso@359
|
938 sed -i \
|
pankso@396
|
939 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
|
pankso@359
|
940 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
|
pankso@395
|
941 /etc/slitaz/cook.conf
|
pankso@395
|
942 case "$arch" in
|
pankso@395
|
943 arm)
|
pankso@395
|
944 sed -i \
|
pankso@395
|
945 -e s'/CFLAGS=.*/CFLAGS="-march=armv6"/' \
|
pankso@395
|
946 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
|
pankso@397
|
947 -e s'/xorg-dev/""/' \
|
pankso@395
|
948 /etc/slitaz/cook.conf ;;
|
pankso@395
|
949 x86_64)
|
pankso@395
|
950 sed -i \
|
pankso@395
|
951 -e s'/CFLAGS=.*/CFLAGS=""/' \
|
pankso@395
|
952 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux/' \
|
pankso@395
|
953 /etc/slitaz/cook.conf ;;
|
pankso@395
|
954 esac
|
pankso@359
|
955 . /etc/slitaz/cook.conf
|
pankso@421
|
956 echo "Target arch : $ARCH"
|
pankso@421
|
957 echo "Configure args : $CONFIGURE_ARGS"
|
pankso@406
|
958 if [ "$SYSROOT" ]; then
|
pankso@421
|
959 echo "Arch sysroot : $SYSROOT"
|
pankso@406
|
960 CC=/usr/bin/${HOST_SYSTEM}-gcc
|
pankso@406
|
961 else
|
pankso@421
|
962 echo "Additional path : /usr/cross/$ARCH/bin"
|
pankso@406
|
963 CC=/usr/cross/$ARCH/bin/${HOST_SYSTEM}-gcc
|
pankso@406
|
964 fi
|
pankso@406
|
965 if [ -x $CC ]; then
|
pankso@421
|
966 echo "Cross compiler : ${HOST_SYSTEM}-gcc"
|
pankso@359
|
967 else
|
pankso@421
|
968 colorize "C compiler is missing: ${HOST_SYSTEM}-gcc" 36
|
paul@387
|
969 echo "Run 'cross compile' to cook a toolchain"
|
pankso@397
|
970 fi
|
pankso@421
|
971 separator && echo "" ;;
|
pankso@9
|
972 test)
|
pankso@9
|
973 # Test a cook environment.
|
pankso@13
|
974 echo "Cook test: testing the cook environment" | log
|
pankso@9
|
975 [ ! -d "$WOK" ] && exit 1
|
pankso@9
|
976 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
|
pankso@9
|
977 cook cooktest ;;
|
pankso@1
|
978 new)
|
pankso@1
|
979 # Create the package folder and an empty receipt.
|
pankso@1
|
980 pkg="$2"
|
pankso@1
|
981 [ "$pkg" ] || usage
|
pankso@1
|
982 echo ""
|
pankso@1
|
983 if [ -d "$WOK/$pkg" ]; then
|
paul@62
|
984 echo -n "$pkg " && gettext "package already exists."
|
pankso@1
|
985 echo -e "\n" && exit 1
|
pankso@1
|
986 fi
|
pankso@1
|
987 gettext "Creating"; echo -n " $WOK/$pkg"
|
pankso@1
|
988 mkdir $WOK/$pkg && cd $WOK/$pkg && status
|
pankso@1
|
989 gettext "Preparing the package receipt..."
|
pankso@1
|
990 cp $DATA/receipt .
|
pankso@1
|
991 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
|
pankso@358
|
992 status && echo ""
|
pankso@358
|
993
|
pankso@196
|
994 # Interactive mode, asking and seding.
|
pankso@196
|
995 case "$3" in
|
paul@214
|
996 --interactive|-x)
|
pankso@358
|
997 gettext -e "Entering interactive mode...\n"
|
paul@211
|
998 separator
|
pankso@196
|
999 echo "Package : $pkg"
|
pankso@196
|
1000 # Version.
|
pankso@196
|
1001 echo -n "Version : " ; read anser
|
pankso@196
|
1002 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
|
pankso@196
|
1003 # Category.
|
pankso@196
|
1004 echo -n "Category : " ; read anser
|
pankso@196
|
1005 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
|
pankso@196
|
1006 # Short description.
|
pankso@196
|
1007 echo -n "Short desc : " ; read anser
|
pankso@196
|
1008 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
|
pankso@196
|
1009 # Maintainer.
|
pankso@196
|
1010 echo -n "Maintainer : " ; read anser
|
pankso@196
|
1011 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
|
pankso@196
|
1012 # Web site.
|
pankso@196
|
1013 echo -n "Web site : " ; read anser
|
pankso@196
|
1014 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
|
pankso@196
|
1015 echo ""
|
pankso@196
|
1016 # Wget URL.
|
pankso@196
|
1017 echo "Wget URL to download source tarball."
|
pankso@196
|
1018 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
|
pankso@196
|
1019 echo -n "Wget url : " ; read anser
|
paul@211
|
1020 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
|
pankso@196
|
1021 # Ask for a stuff dir.
|
pankso@196
|
1022 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
|
pankso@196
|
1023 if [ "$anser" = "y" ]; then
|
pankso@196
|
1024 echo -n "Creating the stuff directory..."
|
pankso@196
|
1025 mkdir $WOK/$pkg/stuff && status
|
pankso@196
|
1026 fi
|
pankso@196
|
1027 # Ask for a description file.
|
pankso@196
|
1028 echo -n "Are you going to write a description ? (y/N) : " ; read anser
|
pankso@196
|
1029 if [ "$anser" = "y" ]; then
|
pankso@196
|
1030 echo -n "Creating the description.txt file..."
|
pankso@196
|
1031 echo "" > $WOK/$pkg/description.txt && status
|
pankso@196
|
1032 fi
|
paul@211
|
1033 separator
|
paul@211
|
1034 gettext -e "Receipt is ready to use.\n"
|
pankso@196
|
1035 echo "" ;;
|
pankso@196
|
1036 esac ;;
|
pankso@1
|
1037 list)
|
pankso@1
|
1038 # Cook a list of packages (better use the Cooker since it will order
|
pankso@1
|
1039 # packages before executing cook).
|
pankso@1
|
1040 check_root
|
pankso@1
|
1041 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
|
pankso@1
|
1042 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
|
pankso@1
|
1043 echo -e " $2\n" && exit 1
|
pankso@13
|
1044 echo "Cook list starting: $2" | log
|
pankso@1
|
1045 for pkg in $(cat $2)
|
pankso@1
|
1046 do
|
pankso@1
|
1047 cook $pkg || broken
|
pankso@1
|
1048 done ;;
|
pankso@1
|
1049 clean-wok)
|
pankso@1
|
1050 check_root
|
pankso@1
|
1051 gettext -e "\nCleaning all packages files..."
|
pankso@1
|
1052 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
|
pankso@1
|
1053 status && echo "" ;;
|
pankso@1
|
1054 clean-src)
|
pankso@1
|
1055 check_root
|
paul@62
|
1056 gettext -e "\nCleaning all packages sources..."
|
pankso@1
|
1057 rm -rf $WOK/*/source
|
pankso@1
|
1058 status && echo "" ;;
|
pankso@235
|
1059 pkgdb)
|
pankso@235
|
1060 # Create suitable packages list for TazPKG and only for built packages
|
pankso@235
|
1061 # as well as flavors files for TazLiTo. We dont need logs since we do it
|
paul@243
|
1062 # manually to ensure everything is fine before syncing the mirror.
|
pankso@239
|
1063 case "$2" in
|
pankso@239
|
1064 --flavors)
|
pankso@239
|
1065 continue ;;
|
pankso@239
|
1066 *)
|
pankso@240
|
1067 [ "$2" ] && PKGS="$2"
|
pankso@239
|
1068 [ ! -d "$PKGS" ] && \
|
pankso@240
|
1069 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
|
pankso@239
|
1070 esac
|
pankso@226
|
1071 time=$(date +%s)
|
pankso@239
|
1072 flavors=$SLITAZ/flavors
|
pankso@239
|
1073 live=$SLITAZ/live
|
pankso@235
|
1074 echo "cook:pkgdb" > $command
|
pankso@235
|
1075 echo "Cook pkgdb: Creating all packages lists" | log
|
pankso@235
|
1076 echo ""
|
pankso@239
|
1077 gettext "Creating lists for: "; echo "$PKGS"
|
pankso@1
|
1078 separator
|
pankso@235
|
1079 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
|
pankso@133
|
1080 cd $PKGS
|
pankso@192
|
1081 rm -f packages.*
|
pankso@235
|
1082 gettext -e "Creating: packages.list\n"
|
pankso@85
|
1083 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
|
pankso@235
|
1084 gettext -e "Creating: packages.md5\n"
|
pankso@1
|
1085 md5sum *.tazpkg > $PKGS/packages.md5
|
gokhlayeh@297
|
1086 md5sum packages.md5 | cut -f1 -d' ' > ID
|
pankso@235
|
1087 gettext -e "Creating lists from: "; echo "$WOK"
|
pankso@1
|
1088 cd $WOK
|
pankso@1
|
1089 for pkg in *
|
pankso@1
|
1090 do
|
pankso@1
|
1091 unset_receipt
|
pankso@1
|
1092 . $pkg/receipt
|
pankso@1
|
1093 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pascal@267
|
1094 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
|
pascal@274
|
1095 if [ -s $pkg/taz/*/receipt ]; then
|
pascal@274
|
1096 . $pkg/taz/*/receipt
|
pascal@274
|
1097 fi
|
pankso@192
|
1098 # packages.desc lets us search easily in DB
|
pankso@1
|
1099 cat >> $PKGS/packages.desc << EOT
|
pankso@235
|
1100 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
|
pankso@1
|
1101 EOT
|
pankso@192
|
1102 # packages.txt used by tazpkg and tazpkg-web also to provide
|
pankso@192
|
1103 # a human readable package list with version and description.
|
pankso@192
|
1104 cat >> $PKGS/packages.txt << EOT
|
pankso@192
|
1105 $PACKAGE
|
pankso@235
|
1106 ${VERSION}$EXTRAVERSION
|
pankso@235
|
1107 $SHORT_DESC
|
pankso@235
|
1108 $PACKED_SIZE ($UNPACKED_SIZE installed)
|
pankso@358
|
1109
|
pankso@192
|
1110 EOT
|
pankso@192
|
1111 # packages.equiv is used by tazpkg install to check depends.
|
pankso@1
|
1112 for i in $PROVIDE; do
|
pankso@1
|
1113 DEST=""
|
pankso@1
|
1114 echo $i | fgrep -q : && DEST="${i#*:}:"
|
pankso@1
|
1115 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
|
pankso@1
|
1116 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
|
pankso@1
|
1117 $PKGS/packages.equiv
|
pankso@1
|
1118 else
|
pankso@1
|
1119 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
|
pankso@1
|
1120 fi
|
pankso@1
|
1121 done
|
paul@197
|
1122 # files.list provides a list of all packages files.
|
pankso@194
|
1123 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
|
pankso@194
|
1124 $PKGS/files.list
|
pankso@1
|
1125 fi
|
pankso@1
|
1126 done
|
pankso@358
|
1127
|
pankso@213
|
1128 # Display list size.
|
pankso@235
|
1129 gettext -e "Done: packages.desc\n"
|
pankso@235
|
1130 gettext -e "Done: packages.txt\n"
|
pankso@235
|
1131 gettext -e "Done: packages.equiv\n"
|
pankso@358
|
1132
|
pankso@194
|
1133 # files.list.lzma
|
pankso@235
|
1134 gettext -e "Creating: files.list.lzma\n"
|
pankso@235
|
1135 cd $PKGS && lzma e files.list files.list.lzma
|
pankso@194
|
1136 rm -f files.list
|
pankso@358
|
1137
|
pankso@235
|
1138 # Display some info.
|
pankso@1
|
1139 separator
|
pankso@1
|
1140 nb=$(ls $PKGS/*.tazpkg | wc -l)
|
pankso@226
|
1141 time=$(($(date +%s) - $time))
|
pankso@235
|
1142 echo -e "Packages: $nb - Time: ${time}s\n"
|
pankso@358
|
1143
|
paul@243
|
1144 # Create all flavors files at once. Do we really need code to monitor
|
paul@243
|
1145 # flavors changes ? Lets just build them with packages lists before
|
pankso@235
|
1146 # syncing the mirror.
|
pankso@239
|
1147 [ "$2" == "--flavors" ] || exit 1
|
pankso@239
|
1148 [ ! -d "$flavors" ] && echo -e "Missing flavors: $flavors\n" && exit 1
|
pankso@239
|
1149 [ -d "$live" ] || mkdir -p $live
|
pankso@236
|
1150 gettext "Creating flavors files in:"; echo " $live"
|
pankso@239
|
1151 echo "Cook pkgdb: Creating all flavors" | log
|
pankso@235
|
1152 separator
|
pankso@236
|
1153 gettext -e "Recharging lists to use latest packages...\n"
|
pankso@329
|
1154 tazpkg recharge >/dev/null 2>/dev/null
|
pankso@358
|
1155
|
pankso@235
|
1156 # We need a custom tazlito config to set working dir to /home/slitaz.
|
pankso@235
|
1157 if [ ! -f "$live/tazlito.conf" ]; then
|
pankso@235
|
1158 echo "Creating configuration file: tazlito.conf"
|
pankso@235
|
1159 cp /etc/tazlito/tazlito.conf $live
|
pankso@235
|
1160 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
|
pankso@235
|
1161 $live/tazlito.conf
|
pankso@235
|
1162 fi
|
pankso@235
|
1163
|
pankso@239
|
1164 # Update Hg flavors repo and pack.
|
pankso@239
|
1165 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
|
pankso@358
|
1166
|
pankso@239
|
1167 cd $live
|
pankso@235
|
1168 echo "Starting to generate flavors..."
|
pankso@235
|
1169 rm -f flavors.list *.flavor
|
pankso@235
|
1170 for i in $flavors/*
|
pankso@235
|
1171 do
|
pankso@235
|
1172 fl=$(basename $i)
|
pankso@235
|
1173 echo "Packing flavor: $(basename $i)"
|
pankso@235
|
1174 tazlito pack-flavor $fl >/dev/null || exit 1
|
pankso@235
|
1175 tazlito show-flavor $fl --brief --noheader 2> \
|
pankso@235
|
1176 /dev/null >> flavors.list
|
pankso@235
|
1177 done
|
pankso@237
|
1178 cp -f $live/*.flavor $live/flavors.list $PKGS
|
pankso@235
|
1179 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
|
pankso@235
|
1180 echo "" && rm -f $command ;;
|
pankso@1
|
1181 *)
|
pankso@1
|
1182 # Just cook and generate a package.
|
pankso@1
|
1183 check_root
|
pankso@1
|
1184 time=$(date +%s)
|
pankso@1
|
1185 pkg="$1"
|
pankso@1
|
1186 [ -z "$pkg" ] && usage
|
pankso@44
|
1187 receipt="$WOK/$pkg/receipt"
|
pankso@1
|
1188 check_pkg_in_wok && echo ""
|
pankso@47
|
1189
|
pankso@377
|
1190 unset inst
|
pankso@377
|
1191 unset_receipt
|
pankso@377
|
1192 . $receipt
|
pankso@377
|
1193
|
pankso@377
|
1194 # Handle cross compilation.
|
pankso@377
|
1195 #
|
pankso@377
|
1196 # CROSS_NOTE: Actually we are running an ARM cooker but running
|
pankso@377
|
1197 # the cooker and build each commit in wok is not possible since
|
pankso@377
|
1198 # we dont cook the full wok for this arch. For ARM we need a set
|
paul@387
|
1199 # of packages to handle a touch screen desktop, servers but not
|
pankso@377
|
1200 # erland.
|
pankso@377
|
1201 #
|
pankso@377
|
1202 # The temporary solution is to build only reviewed and tested
|
pankso@377
|
1203 # packages with HOST_ARCH set in receipt.
|
pankso@377
|
1204 case "$ARCH" in
|
pankso@377
|
1205 arm)
|
pankso@377
|
1206 if [ ! "$HOST_ARCH" ]; then
|
pankso@379
|
1207 echo "cook: HOST_ARCH is not set in $pkg receipt"
|
paul@387
|
1208 echo "cook: This package is not included in: $ARCH"
|
pankso@377
|
1209 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
|
paul@387
|
1210 echo "Cook skip: $pkg is not included in: $ARCH" | log
|
pankso@377
|
1211 echo "" && exit 1
|
pankso@377
|
1212 fi ;;
|
pankso@377
|
1213 esac
|
pankso@377
|
1214
|
paul@387
|
1215 # Some packages are not included in some arch or fail to cross compile.
|
pankso@398
|
1216 : ${HOST_ARCH=i486}
|
pankso@381
|
1217 if ! $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
|
pankso@381
|
1218 echo "cook: HOST_ARCH=$HOST_ARCH"
|
paul@387
|
1219 echo "cook: $pkg doesn't cook or is not included in: $ARCH"
|
pankso@381
|
1220 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
|
paul@387
|
1221 echo "Cook skip: $pkg doesn't cook or is not included in: $ARCH" | log
|
pankso@381
|
1222 echo "" && exit 1
|
pankso@377
|
1223 fi
|
pankso@377
|
1224
|
pankso@47
|
1225 # Skip blocked, 3 lines also for the Cooker.
|
pankso@151
|
1226 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
|
pankso@47
|
1227 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
|
pankso@47
|
1228 fi
|
pankso@47
|
1229
|
pascal@289
|
1230 try_aufs_chroot "$@"
|
pascal@289
|
1231
|
pankso@47
|
1232 # Log and source receipt.
|
pankso@56
|
1233 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
|
pankso@16
|
1234 echo "cook:$pkg" > $command
|
pascal@285
|
1235
|
pascal@285
|
1236 # Display and log info if cook process stopped.
|
pascal@285
|
1237 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
|
pascal@285
|
1238 tee -a $LOGS/$pkg.log' INT
|
pascal@285
|
1239
|
pankso@1
|
1240 # Handle --options
|
pankso@1
|
1241 case "$2" in
|
pankso@1
|
1242 --clean|-c)
|
pankso@49
|
1243 gettext -e "Cleaning:"; echo -n " $pkg"
|
pankso@1
|
1244 cd $WOK/$pkg && rm -rf install taz source
|
pankso@1
|
1245 status && echo "" && exit 0 ;;
|
pankso@1
|
1246 --install|-i)
|
pankso@1
|
1247 inst='yes' ;;
|
pankso@49
|
1248 --getsrc|-gs)
|
pankso@49
|
1249 gettext "Getting source for:"; echo " $pkg"
|
pankso@45
|
1250 separator && get_source
|
pankso@39
|
1251 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
|
pankso@49
|
1252 --block|-b)
|
pankso@49
|
1253 gettext "Blocking:"; echo -n " $pkg"
|
pankso@49
|
1254 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
|
pankso@49
|
1255 status && echo "" && exit 0 ;;
|
pankso@49
|
1256 --unblock|-ub)
|
pankso@49
|
1257 gettext "Unblocking:"; echo -n " $pkg"
|
pankso@49
|
1258 sed -i "/^${pkg}$/"d $blocked
|
pankso@49
|
1259 status && echo "" && exit 0 ;;
|
pankso@358
|
1260
|
pankso@1
|
1261 esac
|
pankso@1
|
1262
|
paul@62
|
1263 # Check if wanted is built now so we have separate log files.
|
pankso@295
|
1264 for wanted in $WANTED ; do
|
pascal@291
|
1265 if grep -q "^$wanted$" $blocked; then
|
pascal@291
|
1266 echo "WANTED package is blocked: $wanted" | tee $LOGS/$pkg.log
|
pankso@221
|
1267 echo "" && rm -f $command && exit 1
|
pankso@217
|
1268 fi
|
pascal@291
|
1269 if grep -q "^$wanted$" $broken; then
|
pascal@291
|
1270 echo "WANTED package is broken: $wanted" | tee $LOGS/$pkg.log
|
pankso@221
|
1271 echo "" && rm -f $command && exit 1
|
pankso@218
|
1272 fi
|
pascal@291
|
1273 if [ ! -d "$WOK/$wanted/install" ]; then
|
pascal@291
|
1274 cook "$wanted" || exit 1
|
pankso@137
|
1275 fi
|
pascal@291
|
1276 done
|
pankso@1
|
1277
|
pankso@1
|
1278 # Cook and pack or exit on error and log everything.
|
pankso@97
|
1279 cookit $@ 2>&1 | tee $LOGS/$pkg.log
|
pankso@15
|
1280 remove_deps | tee -a $LOGS/$pkg.log
|
pankso@1
|
1281 cookit_quality
|
pankso@26
|
1282 packit 2>&1 | tee -a $LOGS/$pkg.log
|
pankso@1
|
1283 clean_log
|
pankso@33
|
1284
|
pankso@33
|
1285 # Exit if any error in packing.
|
pankso@33
|
1286 if grep -q ^ERROR $LOGS/$pkg.log; then
|
pankso@33
|
1287 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
1288 rm -f $command && exit 1
|
pankso@33
|
1289 fi
|
pankso@358
|
1290
|
pankso@310
|
1291 # Create an XML feed
|
pankso@310
|
1292 gen_rss
|
pankso@358
|
1293
|
pankso@1
|
1294 # Time and summary
|
pankso@1
|
1295 time=$(($(date +%s) - $time))
|
pankso@1
|
1296 summary | tee -a $LOGS/$pkg.log
|
pankso@50
|
1297 echo ""
|
pankso@1
|
1298
|
pankso@1
|
1299 # Install package if requested
|
pankso@1
|
1300 if [ "$inst" ]; then
|
pankso@1
|
1301 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pankso@1
|
1302 cd $PKGS && tazpkg install \
|
pankso@1
|
1303 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
|
pankso@1
|
1304 else
|
paul@62
|
1305 gettext -e "Unable to install package, build has failed.\n\n"
|
pankso@1
|
1306 exit 1
|
pankso@1
|
1307 fi
|
pankso@1
|
1308 fi
|
pankso@358
|
1309
|
pankso@369
|
1310 # Skip install if target host dont match build system.
|
pankso@369
|
1311 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
|
pankso@304
|
1312 # Install package if part of the chroot to keep env up-to-date.
|
pankso@369
|
1313 if [ -d "$INSTALLED/$PACKAGE" ] && [ -z "$AUFS_MOUNTS" ] && \
|
pankso@376
|
1314 [ "$build" == "$ARCH" ]; then
|
pankso@308
|
1315 echo "Updating chroot environment..."
|
pankso@308
|
1316 echo "Updating chroot: $PACKAGE (${VERSION}${EXTRAVERSION})" | log
|
pankso@304
|
1317 cd $PKGS && tazpkg install \
|
pankso@304
|
1318 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
|
pankso@303
|
1319 fi
|
pankso@358
|
1320
|
pankso@9
|
1321 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
|
pankso@17
|
1322 # You want automation: use the Cooker Build Bot.
|
pankso@1
|
1323 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
|
pankso@18
|
1324 rm -f $command ;;
|
pankso@1
|
1325 esac
|
pankso@1
|
1326
|
pankso@1
|
1327 exit 0
|