cookutils annotate cook @ rev 1

Added: cook
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 03 22:30:38 2011 +0200 (2011-05-03)
parents
children b222a2ef4b1a
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@1 9
pankso@1 10 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
pankso@1 11 [ -f "cook.conf" ] && . ./cook.conf
pankso@1 12
pankso@1 13 #
pankso@1 14 # Functions
pankso@1 15 #
pankso@1 16
pankso@1 17 usage() {
pankso@1 18 cat << EOT
pankso@1 19
pankso@1 20 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command|list] [--option]
pankso@1 21
pankso@1 22 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
pankso@1 23 usage|help $(gettext "Display this short usage.")
pankso@1 24 list-wok $(gettext "List packages in the wok.")
pankso@1 25 setup $(gettext "Setup your build environment.")
pankso@1 26 new $(gettext "Create a new package with receipt".)
pankso@1 27 list $(gettext "Cook a list of packages.")
pankso@1 28 clean-wok $(gettext "Clean-up all packages files.")
pankso@1 29 clean-src $(gettext "Clean-up all packages source.")
pankso@1 30 pkglist $(gettext "Create all packages.* lists.")
pankso@1 31
pankso@1 32 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
pankso@1 33 --clean|-c $(gettext "Clean the package in the wok.")
pankso@1 34 --install|-i $(gettext "Cook and install the package.")
pankso@1 35 --wok|-w $(gettext "Setup also a wok from Hg repo.")
pankso@1 36
pankso@1 37 EOT
pankso@1 38 exit 0
pankso@1 39 }
pankso@1 40
pankso@1 41 # Be sure we root.
pankso@1 42 check_root() {
pankso@1 43 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0
pankso@1 44 }
pankso@1 45
pankso@1 46 separator() {
pankso@1 47 echo "================================================================================"
pankso@1 48 }
pankso@1 49
pankso@1 50 status() {
pankso@1 51 echo -en "\\033[70G[ "
pankso@1 52 if [ $? = 0 ]; then
pankso@1 53 echo -en "\\033[1;32mOK"
pankso@1 54 else
pankso@1 55 echo -en "\\033[1;31mFailed"
pankso@1 56 fi
pankso@1 57 echo -e "\\033[0;39m ]"
pankso@1 58 }
pankso@1 59
pankso@1 60 clean_log() {
pankso@1 61 sed -i -e s'|\[70G\[ \[1;32m| |' \
pankso@1 62 -e s'|\[0;39m \]||' $LOGS/$pkg.log
pankso@1 63 }
pankso@1 64
pankso@1 65 unset_receipt() {
pankso@1 66 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE
pankso@1 67 }
pankso@1 68
pankso@1 69 # Be sure package exist in wok.
pankso@1 70 check_pkg_in_wok() {
pankso@1 71 if [ ! -d "$WOK/$pkg" ]; then
pankso@1 72 gettext -e "\nUnable to find package in the wok:"
pankso@1 73 echo -e " $pkg\n" && exit 1
pankso@1 74 fi
pankso@1 75 }
pankso@1 76
pankso@1 77 # Path's used in receipt and by cook itself.
pankso@1 78 set_paths() {
pankso@1 79 pkgdir=$WOK/$PACKAGE
pankso@1 80 src=$pkgdir/source/$PACKAGE-$VERSION
pankso@1 81 pack=$pkgdir/taz/$PACKAGE-${VERSION}${EXTRAVERSION}
pankso@1 82 fs=$pack/fs
pankso@1 83 stuff=$pkgdir/stuff
pankso@1 84 install=$pkgdir/install
pankso@1 85 if [ "$WANTED" ]; then
pankso@1 86 src=$WOK/$WANTED/source/$WANTED-$VERSION
pankso@1 87 install=$WOK/$WANTED/install
pankso@1 88 fi
pankso@1 89 # Old way compatibility
pankso@1 90 _pkg=$install
pankso@1 91 }
pankso@1 92
pankso@1 93 # Get package source
pankso@1 94 get_source() {
pankso@1 95 wget -P $SRC $WGET_URL
pankso@1 96 }
pankso@1 97
pankso@1 98 # Extract source package
pankso@1 99 extract_source() {
pankso@1 100 gettext "Extracting:"; echo " $TARBALL"
pankso@1 101 case "$TARBALL" in
pankso@1 102 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL ;;
pankso@1 103 *.tar.bz2) tar xjf $SRC/$TARBALL ;;
pankso@1 104 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
pankso@1 105 *.zip) unzip $SRC/$TARBALL ;;
pankso@1 106 esac
pankso@1 107 }
pankso@1 108
pankso@1 109 # Display cooked package summary
pankso@1 110 summary() {
pankso@1 111 cd $WOK/$pkg
pankso@1 112 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
pankso@1 113 fs=$(du -sh taz/* | awk '{print $1}')
pankso@1 114 size=$(du -sh $PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.* | awk '{print $1}')
pankso@1 115 files=$(cat taz/$PACKAGE-*/files.list | wc -l)
pankso@1 116 gettext "Summary for:"; echo " $PACKAGE $VERSION"
pankso@1 117 separator
pankso@1 118 [ "$prod" ] && echo "Produce : $prod"
pankso@1 119 cat << EOT
pankso@1 120 Packed : $fs
pankso@1 121 Compressed : $size
pankso@1 122 Files : $files
pankso@1 123 Cook time : ${time}s
pankso@1 124 $(separator)
pankso@1 125
pankso@1 126 EOT
pankso@1 127 }
pankso@1 128
pankso@1 129 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@1 130 # so some packages need to copy these files with the receipt and genpkg_rules.
pankso@1 131 copy_generic_files()
pankso@1 132 {
pankso@1 133 # $LOCALE is set in cook.conf
pankso@1 134 if [ "$LOCALE" ]; then
pankso@1 135 if [ -d "$_pkg/usr/share/locale" ]; then
pankso@1 136 mkdir -p $fs/usr/share/locale
pankso@1 137 for i in $LOCALE
pankso@1 138 do
pankso@1 139 if [ -d "$_pkg/usr/share/locale/$i" ]; then
pankso@1 140 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
pankso@1 141 fi
pankso@1 142 done
pankso@1 143 fi
pankso@1 144 fi
pankso@1 145
pankso@1 146 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
pankso@1 147 if [ "$GENERIC_PIXMAPS" != "no" ]; then
pankso@1 148 if [ -d "$_pkg/usr/share/pixmaps" ]; then
pankso@1 149 mkdir -p $fs/usr/share/pixmaps
pankso@1 150 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
pankso@1 151 $fs/usr/share/pixmaps 2>/dev/null
pankso@1 152 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
pankso@1 153 $fs/usr/share/pixmaps 2>/dev/null
pankso@1 154 fi
pankso@1 155
pankso@1 156 # Custom or homemade PNG pixmap can be in stuff.
pankso@1 157 if [ -f "$stuff/$PACKAGE.png" ]; then
pankso@1 158 mkdir -p $fs/usr/share/pixmaps
pankso@1 159 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@1 160 fi
pankso@1 161 fi
pankso@1 162
pankso@1 163 # Desktop entry (.desktop).
pankso@1 164 if [ -d "$_pkg/usr/share/applications" ]; then
pankso@1 165 cp -a $_pkg/usr/share/applications $fs/usr/share
pankso@1 166 fi
pankso@1 167
pankso@1 168 # Homemade desktop file(s) can be in stuff.
pankso@1 169 if [ -d "$stuff/applications" ]; then
pankso@1 170 mkdir -p $fs/usr/share
pankso@1 171 cp -a $stuff/applications $fs/usr/share
pankso@1 172 fi
pankso@1 173 if [ -f "$stuff/$PACKAGE.desktop" ]; then
pankso@1 174 mkdir -p $fs/usr/share/applications
pankso@1 175 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@1 176 fi
pankso@1 177 }
pankso@1 178
pankso@1 179 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
pankso@1 180 strip_package()
pankso@1 181 {
pankso@1 182 gettext "Executing strip on all files"
pankso@1 183 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@1 184 do
pankso@1 185 if [ -d "$dir" ]; then
pankso@1 186 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
pankso@1 187 fi
pankso@1 188 done
pankso@1 189 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
pankso@1 190 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
pankso@1 191 status
pankso@1 192 }
pankso@1 193
pankso@1 194 # Verify package quality and consitensy.
pankso@1 195 packit_quality() {
pankso@1 196 if grep -q ^ERROR $LOGS/$pkg.log; then
pankso@1 197 exit 1
pankso@1 198 fi
pankso@1 199 if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then
pankso@1 200 echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1
pankso@1 201 else
pankso@1 202 mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS
pankso@1 203 fi
pankso@1 204 }
pankso@1 205
pankso@1 206 # The main cook function.
pankso@1 207 cookit() {
pankso@1 208 set_paths
pankso@1 209 unset error
pankso@1 210 echo "Cooking: $PACKAGE $VERSION"
pankso@1 211 separator
pankso@1 212 rm -rf install taz source $CACHE/error
pankso@1 213
pankso@1 214 # Disable -pipe if less than 512Mb free RAM.
pankso@1 215 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
pankso@1 216 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
pankso@1 217 gettext -e "Disabling -pipe compile flag: $free RAM\n"
pankso@1 218 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
pankso@1 219 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
pankso@1 220 fi
pankso@1 221 unset free
pankso@1 222
pankso@1 223 # Export flags and path to be used by make
pankso@1 224 DESTDIR=$WOK/$PACKAGE/install
pankso@1 225 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS BUILD_HOST CONFIG_SITE
pankso@1 226 local LC_ALL=POSIX LANG=POSIX
pankso@1 227
pankso@1 228 # Check for build dep.
pankso@1 229 cd $INSTALLED && ls -1 > $CACHE/installed.list
pankso@1 230 [ "$DEPENDS" ] && gettext -e "Checking build dependencies...\n"
pankso@1 231 for dep in $BUILD_DEPENDS
pankso@1 232 do
pankso@1 233 if [ ! -d "$INSTALLED/$dep" ]; then
pankso@1 234 # Try local package first
pankso@1 235 if [ -f "$PKGS/$dep-*.tazpkg" ]; then
pankso@1 236 gettext "Installing dep (local):"; echo " $dep"
pankso@1 237 cd $PKGS && tazpkg install $dep-*.tazpkg >/dev/null
pankso@1 238 else
pankso@1 239 gettext "Installing dep (web/cache):"; echo " $dep"
pankso@1 240 tazpkg get-install $dep >/dev/null
pankso@1 241 fi
pankso@1 242 fi
pankso@1 243 done
pankso@1 244 ls -1 > $CACHE/installed.cook && cd $CACHE
pankso@1 245 diff installed.list installed.cook | \
pankso@1 246 grep ^+[a-zA-Z0-9] | sed s/^+// > installed.deps
pankso@1 247 deps=$(cat installed.deps | wc -l)
pankso@1 248
pankso@1 249 # Get source tarball and make sure we have source dir named:
pankso@1 250 # $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma
pankso@1 251 # tarball if it exist.
pankso@1 252 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
pankso@1 253 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
pankso@1 254 TARBALL=$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
pankso@1 255 else
pankso@1 256 get_source || exit 1
pankso@1 257 fi
pankso@1 258 fi
pankso@1 259 if [ ! "$WANTED" ] && [ ! -d "$src" ]; then
pankso@1 260 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
pankso@1 261 extract_source || exit 1
pankso@1 262 mv * ../$PACKAGE-$VERSION
pankso@1 263 cd .. && rm -rf tmp
pankso@1 264 fi
pankso@1 265
pankso@1 266 # Execute receipt rules and stay compatible with _pkg.
pankso@1 267 if grep -q ^compile_rules $pkgdir/receipt; then
pankso@1 268 gettext -e "Executing: compile_rules\n"
pankso@1 269 cd $src && compile_rules || exit 1
pankso@1 270 [ -d $src/_pkg ] && mv $src/_pkg $install
pankso@1 271 fi
pankso@1 272 if grep -q ^genpkg_rules $pkgdir/receipt; then
pankso@1 273 gettext -e "Executing: genpkg_rules\n"
pankso@1 274 mkdir -p $fs && genpkg_rules || ( echo -e \
pankso@1 275 "\nERROR: genpkg_rules failed\n" | \
pankso@1 276 tee -a $LOGS/$pkg.log && exit 1 )
pankso@1 277 fi
pankso@1 278
pankso@1 279 # Now remove installed build deps.
pankso@1 280 if [ "$deps" -gt 0 ]; then
pankso@1 281 gettext "Removing build dependencies:"; echo " $deps"
pankso@1 282 for dep in $(cat $CACHE/installed.deps)
pankso@1 283 do
pankso@1 284 yes | tazpkg remove $dep >/dev/null
pankso@1 285 done
pankso@1 286 fi
pankso@1 287 separator && echo ""
pankso@1 288 }
pankso@1 289
pankso@1 290 # Cook quality assurance.
pankso@1 291 cookit_quality() {
pankso@1 292 if grep -q ^ERROR $LOGS/$pkg.log; then
pankso@1 293 exit 1
pankso@1 294 fi
pankso@1 295 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
pankso@1 296 echo -e "ERROR: cook failed\n" | \
pankso@1 297 tee -a $LOGS/$pkg.log && exit 1
pankso@1 298 fi
pankso@1 299 }
pankso@1 300
pankso@1 301 # Create the package.
pankso@1 302 packit() {
pankso@1 303 set_paths
pankso@1 304 echo "Packing: $PACKAGE ${VERSION}${EXTRAVERSION}"
pankso@1 305 separator
pankso@1 306 cd $pkgdir/taz
pankso@1 307 strip_package
pankso@1 308 for file in receipt description.txt
pankso@1 309 do
pankso@1 310 [ ! -f "../$file" ] && continue
pankso@1 311 gettext "Copying"; echo -n " $file..."
pankso@1 312 cp -f ../$file $pack && chown 0.0 $pack/$file && status
pankso@1 313 done
pankso@1 314 copy_generic_files
pankso@1 315 # Use Tazpkg to create a tazpkg package...
pankso@1 316 tazpkg pack $PACKAGE-${VERSION}${EXTRAVERSION} | grep "\[*\]"
pankso@1 317 separator && echo ""
pankso@1 318 }
pankso@1 319
pankso@1 320 #
pankso@1 321 # Commands
pankso@1 322 #
pankso@1 323
pankso@1 324 case "$1" in
pankso@1 325 usage|help)
pankso@1 326 usage ;;
pankso@1 327 list-wok)
pankso@1 328 gettext "List of packages in:"; echo " $WOK"
pankso@1 329 separator
pankso@1 330 cd $WOK && ls -1
pankso@1 331 separator
pankso@1 332 echo -n "Packages: " && ls | wc -l
pankso@1 333 echo "" ;;
pankso@1 334 setup)
pankso@1 335 # Setup a build environment
pankso@1 336 check_root
pankso@1 337 gettext -e "\nSetting up your environment\n"
pankso@1 338 separator && cd $SLITAZ
pankso@1 339 gettext "Creating directories structure in:"; echo " $SLITAZ"
pankso@1 340 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
pankso@1 341 gettext -e "Checking for packages to install...\n"
pankso@1 342 for pkg in slitaz-toolchain tazdev intltool gettext
pankso@1 343 do
pankso@1 344 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
pankso@1 345 done
pankso@1 346
pankso@1 347 # Handle --options
pankso@1 348 case "$2" in
pankso@1 349 --wok)
pankso@1 350 [ ! -d "$INSTALLED/mercurial" ] && tazpkg get-install mercurial
pankso@1 351 [ -d "$WOK" ] && echo -e "A wok already exist.\n" && exit 1
pankso@1 352 hg clone $HG_URL ;;
pankso@1 353 --chroot)
pankso@1 354 echo "TODO: create a chroot with tazdev" ;;
pankso@1 355 esac
pankso@1 356
pankso@1 357 # SliTaz group and permissions
pankso@1 358 if ! grep -q ^slitaz /etc/group; then
pankso@1 359 gettext -e "Adding group: slitaz\n"
pankso@1 360 addgroup slitaz
pankso@1 361 fi
pankso@1 362 gettext -e "Setting permissions for slitaz group...\n"
pankso@1 363 chown -R root.slitaz $SLITAZ
pankso@1 364 chmod -R g+w $SLITAZ
pankso@1 365 separator
pankso@1 366 gettext -e "All done, ready to cook packages :-)\n\n" ;;
pankso@1 367 new)
pankso@1 368 # Create the package folder and an empty receipt.
pankso@1 369 pkg="$2"
pankso@1 370 [ "$pkg" ] || usage
pankso@1 371 echo ""
pankso@1 372 if [ -d "$WOK/$pkg" ]; then
pankso@1 373 echo -n "$pkg " && gettext "package already exist."
pankso@1 374 echo -e "\n" && exit 1
pankso@1 375 fi
pankso@1 376 gettext "Creating"; echo -n " $WOK/$pkg"
pankso@1 377 mkdir $WOK/$pkg && cd $WOK/$pkg && status
pankso@1 378 gettext "Preparing the package receipt..."
pankso@1 379 cp $DATA/receipt .
pankso@1 380 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
pankso@1 381 status && echo "" ;;
pankso@1 382 list)
pankso@1 383 # Cook a list of packages (better use the Cooker since it will order
pankso@1 384 # packages before executing cook).
pankso@1 385 check_root
pankso@1 386 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
pankso@1 387 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
pankso@1 388 echo -e " $2\n" && exit 1
pankso@1 389 for pkg in $(cat $2)
pankso@1 390 do
pankso@1 391 cook $pkg || broken
pankso@1 392 done ;;
pankso@1 393 clean-wok)
pankso@1 394 check_root
pankso@1 395 gettext -e "\nCleaning all packages files..."
pankso@1 396 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
pankso@1 397 status && echo "" ;;
pankso@1 398 clean-src)
pankso@1 399 check_root
pankso@1 400 gettext -e "\nCleaning all packages source..."
pankso@1 401 rm -rf $WOK/*/source
pankso@1 402 status && echo "" ;;
pankso@1 403 pkglist)
pankso@1 404 # Create suitable packages list for TazPKG and only for builded packages.
pankso@1 405 [ "$2" ] && PKGS="$2"
pankso@1 406 [ ! -d "$PKGS" ] && \
pankso@1 407 gettext -e "\nPackages directory dont exist\n\n" && exit 1
pankso@1 408 cd $PKGS
pankso@1 409 gettext -e "\nCreating lists for:"; echo " $PKGS"
pankso@1 410 separator
pankso@1 411 rm -f packages.* files.list*
pankso@1 412 gettext -e "Creating: packages.list\n"
pankso@1 413 ls -1 | sed s'/.tazpkg//' > $PKGS/packages.list
pankso@1 414 gettext -e "Creating: packages.md5\n"
pankso@1 415 md5sum *.tazpkg > $PKGS/packages.md5
pankso@1 416 gettext -e "Creating: packages.desc\n"
pankso@1 417 gettext -e "Creating: packages.equiv\n"
pankso@1 418 cd $WOK
pankso@1 419 for pkg in *
pankso@1 420 do
pankso@1 421 unset_receipt
pankso@1 422 . $pkg/receipt
pankso@1 423 # packages.desc let us search easily in DB
pankso@1 424 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@1 425 cat >> $PKGS/packages.desc << EOT
pankso@1 426 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
pankso@1 427 EOT
pankso@1 428 # Packages.equiv is used by tazpkg install to check depends.
pankso@1 429 for i in $PROVIDE; do
pankso@1 430 DEST=""
pankso@1 431 echo $i | fgrep -q : && DEST="${i#*:}:"
pankso@1 432 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
pankso@1 433 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
pankso@1 434 $PKGS/packages.equiv
pankso@1 435 else
pankso@1 436 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
pankso@1 437 fi
pankso@1 438 done
pankso@1 439 fi
pankso@1 440 done
pankso@1 441 # files.list.lzma
pankso@1 442 #lzma e files.list files.list.lzma
pankso@1 443 separator
pankso@1 444 nb=$(ls $PKGS/*.tazpkg | wc -l)
pankso@1 445 echo -e "Packages: $nb\n" ;;
pankso@1 446 *)
pankso@1 447 # Just cook and generate a package.
pankso@1 448 check_root
pankso@1 449 time=$(date +%s)
pankso@1 450 pkg="$1"
pankso@1 451 [ -z "$pkg" ] && usage
pankso@1 452 check_pkg_in_wok && echo ""
pankso@1 453 unset inst
pankso@1 454 unset_receipt
pankso@1 455 cd $WOK/$pkg && . ./receipt
pankso@1 456
pankso@1 457 # Handle --options
pankso@1 458 case "$2" in
pankso@1 459 --clean|-c)
pankso@1 460 gettext -e "Cleaning package:"; echo -n " $pkg"
pankso@1 461 cd $WOK/$pkg && rm -rf install taz source
pankso@1 462 status && echo "" && exit 0 ;;
pankso@1 463 --install|-i)
pankso@1 464 inst='yes' ;;
pankso@1 465 esac
pankso@1 466
pankso@1 467 # Check if wanted is build now so we have separate log files.
pankso@1 468 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then
pankso@1 469 cook "$WANTED"
pankso@1 470 fi
pankso@1 471
pankso@1 472 # Cook and pack or exit on error and log everything.
pankso@1 473 cookit | tee $LOGS/$pkg.log
pankso@1 474 cookit_quality
pankso@1 475 packit | tee -a $LOGS/$pkg.log
pankso@1 476 clean_log
pankso@1 477 packit_quality
pankso@1 478
pankso@1 479 # Time and summary
pankso@1 480 time=$(($(date +%s) - $time))
pankso@1 481 summary | tee -a $LOGS/$pkg.log
pankso@1 482
pankso@1 483 # Install package if requested
pankso@1 484 if [ "$inst" ]; then
pankso@1 485 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@1 486 cd $PKGS && tazpkg install \
pankso@1 487 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
pankso@1 488 else
pankso@1 489 gettext -e "Unable to install package, build have failed.\n\n"
pankso@1 490 exit 1
pankso@1 491 fi
pankso@1 492 fi
pankso@1 493 # Finally we may want to build the *-dev package
pankso@1 494 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
pankso@1 495 ;;
pankso@1 496 esac
pankso@1 497
pankso@1 498 exit 0