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