cookutils annotate cook @ rev 745

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