cookutils annotate cook @ rev 465

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