cookutils annotate cook @ rev 927

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