cookutils annotate cook @ rev 807

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