cookutils annotate cook @ rev 519

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