cookutils annotate cook @ rev 8

Handle correctly installed/uninstalled build deps
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 03 23:09:59 2011 +0200 (2011-05-03)
parents 04526db035f3
children 02bf2a847c08
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@8 194 # Remove installed deps.
pankso@8 195 remove_deps() {
pankso@8 196 # Now remove installed build deps.
pankso@8 197 deps=$(cat $CACHE/installed.diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
pankso@8 198 nb=$(echo $deps | wc -l)
pankso@8 199 if [ -s "$CACHE/installed.diff" ]; then
pankso@8 200 gettext "Build dependencies to remove:"; echo " $nb"
pankso@8 201 gettext "Removing:"
pankso@8 202 for dep in $deps
pankso@8 203 do
pankso@8 204 echo -n " $dep"
pankso@8 205 yes | tazpkg remove $dep >/dev/null
pankso@8 206 done
pankso@8 207 echo ""
pankso@8 208 mv -f $CACHE/installed.diff $CACHE/installed.last.diff
pankso@1 209 fi
pankso@1 210 }
pankso@1 211
pankso@1 212 # The main cook function.
pankso@1 213 cookit() {
pankso@1 214 set_paths
pankso@1 215 unset error
pankso@1 216 echo "Cooking: $PACKAGE $VERSION"
pankso@1 217 separator
pankso@1 218 rm -rf install taz source $CACHE/error
pankso@1 219
pankso@1 220 # Disable -pipe if less than 512Mb free RAM.
pankso@1 221 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
pankso@1 222 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
pankso@1 223 gettext -e "Disabling -pipe compile flag: $free RAM\n"
pankso@1 224 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
pankso@1 225 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
pankso@1 226 fi
pankso@1 227 unset free
pankso@1 228
pankso@1 229 # Export flags and path to be used by make
pankso@1 230 DESTDIR=$WOK/$PACKAGE/install
pankso@1 231 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS BUILD_HOST CONFIG_SITE
pankso@1 232 local LC_ALL=POSIX LANG=POSIX
pankso@1 233
pankso@1 234 # Check for build dep.
pankso@1 235 cd $INSTALLED && ls -1 > $CACHE/installed.list
pankso@1 236 [ "$DEPENDS" ] && gettext -e "Checking build dependencies...\n"
pankso@1 237 for dep in $BUILD_DEPENDS
pankso@1 238 do
pankso@1 239 if [ ! -d "$INSTALLED/$dep" ]; then
pankso@1 240 # Try local package first
pankso@1 241 if [ -f "$PKGS/$dep-*.tazpkg" ]; then
pankso@1 242 gettext "Installing dep (local):"; echo " $dep"
pankso@1 243 cd $PKGS && tazpkg install $dep-*.tazpkg >/dev/null
pankso@1 244 else
pankso@1 245 gettext "Installing dep (web/cache):"; echo " $dep"
pankso@1 246 tazpkg get-install $dep >/dev/null
pankso@1 247 fi
pankso@1 248 fi
pankso@1 249 done
pankso@1 250 ls -1 > $CACHE/installed.cook && cd $CACHE
pankso@8 251
pankso@8 252 # If a cook failed deps are not remove since we exit 1.
pankso@8 253 [ ! -s "installed.diff" ] && \
pankso@8 254 diff installed.list installed.cook > installed.diff
pankso@8 255 deps=$(cat installed.diff | grep ^+[a-zA-Z0-9] | wc -l)
pankso@1 256
pankso@1 257 # Get source tarball and make sure we have source dir named:
pankso@1 258 # $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma
pankso@1 259 # tarball if it exist.
pankso@1 260 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
pankso@1 261 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
pankso@1 262 TARBALL=$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
pankso@1 263 else
pankso@1 264 get_source || exit 1
pankso@1 265 fi
pankso@1 266 fi
pankso@1 267 if [ ! "$WANTED" ] && [ ! -d "$src" ]; then
pankso@1 268 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
pankso@1 269 extract_source || exit 1
pankso@1 270 mv * ../$PACKAGE-$VERSION
pankso@1 271 cd .. && rm -rf tmp
pankso@1 272 fi
pankso@1 273
pankso@1 274 # Execute receipt rules and stay compatible with _pkg.
pankso@1 275 if grep -q ^compile_rules $pkgdir/receipt; then
pankso@1 276 gettext -e "Executing: compile_rules\n"
pankso@1 277 cd $src && compile_rules || exit 1
pankso@1 278 [ -d $src/_pkg ] && mv $src/_pkg $install
pankso@1 279 fi
pankso@1 280 if grep -q ^genpkg_rules $pkgdir/receipt; then
pankso@1 281 gettext -e "Executing: genpkg_rules\n"
pankso@1 282 mkdir -p $fs && genpkg_rules || ( echo -e \
pankso@1 283 "\nERROR: genpkg_rules failed\n" | \
pankso@1 284 tee -a $LOGS/$pkg.log && exit 1 )
pankso@1 285 fi
pankso@1 286 separator && echo ""
pankso@1 287 }
pankso@1 288
pankso@1 289 # Cook quality assurance.
pankso@1 290 cookit_quality() {
pankso@1 291 if grep -q ^ERROR $LOGS/$pkg.log; then
pankso@1 292 exit 1
pankso@1 293 fi
pankso@1 294 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
pankso@8 295 echo -e "\nERROR: cook failed\n" | \
pankso@1 296 tee -a $LOGS/$pkg.log && exit 1
pankso@1 297 fi
pankso@1 298 }
pankso@1 299
pankso@1 300 # Create the package.
pankso@1 301 packit() {
pankso@1 302 set_paths
pankso@1 303 echo "Packing: $PACKAGE ${VERSION}${EXTRAVERSION}"
pankso@1 304 separator
pankso@1 305 cd $pkgdir/taz
pankso@1 306 strip_package
pankso@1 307 for file in receipt description.txt
pankso@1 308 do
pankso@1 309 [ ! -f "../$file" ] && continue
pankso@1 310 gettext "Copying"; echo -n " $file..."
pankso@1 311 cp -f ../$file $pack && chown 0.0 $pack/$file && status
pankso@1 312 done
pankso@1 313 copy_generic_files
pankso@1 314 # Use Tazpkg to create a tazpkg package...
pankso@1 315 tazpkg pack $PACKAGE-${VERSION}${EXTRAVERSION} | grep "\[*\]"
pankso@1 316 separator && echo ""
pankso@1 317 }
pankso@1 318
pankso@8 319 # Verify package quality and consitensy.
pankso@8 320 packit_quality() {
pankso@8 321 if grep -q ^ERROR $LOGS/$pkg.log; then
pankso@8 322 exit 1
pankso@8 323 fi
pankso@8 324 if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then
pankso@8 325 echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1
pankso@8 326 else
pankso@8 327 mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS
pankso@8 328 fi
pankso@8 329 }
pankso@8 330
pankso@1 331 #
pankso@1 332 # Commands
pankso@1 333 #
pankso@1 334
pankso@1 335 case "$1" in
pankso@1 336 usage|help)
pankso@1 337 usage ;;
pankso@1 338 list-wok)
pankso@1 339 gettext "List of packages in:"; echo " $WOK"
pankso@1 340 separator
pankso@1 341 cd $WOK && ls -1
pankso@1 342 separator
pankso@1 343 echo -n "Packages: " && ls | wc -l
pankso@1 344 echo "" ;;
pankso@1 345 setup)
pankso@1 346 # Setup a build environment
pankso@1 347 check_root
pankso@1 348 gettext -e "\nSetting up your environment\n"
pankso@1 349 separator && cd $SLITAZ
pankso@1 350 gettext "Creating directories structure in:"; echo " $SLITAZ"
pankso@1 351 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
pankso@1 352 gettext -e "Checking for packages to install...\n"
pankso@1 353 for pkg in slitaz-toolchain tazdev intltool gettext
pankso@1 354 do
pankso@1 355 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
pankso@1 356 done
pankso@1 357
pankso@1 358 # Handle --options
pankso@1 359 case "$2" in
pankso@1 360 --wok)
pankso@1 361 [ ! -d "$INSTALLED/mercurial" ] && tazpkg get-install mercurial
pankso@1 362 [ -d "$WOK" ] && echo -e "A wok already exist.\n" && exit 1
pankso@1 363 hg clone $HG_URL ;;
pankso@1 364 --chroot)
pankso@1 365 echo "TODO: create a chroot with tazdev" ;;
pankso@1 366 esac
pankso@1 367
pankso@1 368 # SliTaz group and permissions
pankso@1 369 if ! grep -q ^slitaz /etc/group; then
pankso@1 370 gettext -e "Adding group: slitaz\n"
pankso@1 371 addgroup slitaz
pankso@1 372 fi
pankso@1 373 gettext -e "Setting permissions for slitaz group...\n"
pankso@1 374 chown -R root.slitaz $SLITAZ
pankso@1 375 chmod -R g+w $SLITAZ
pankso@1 376 separator
pankso@1 377 gettext -e "All done, ready to cook packages :-)\n\n" ;;
pankso@1 378 new)
pankso@1 379 # Create the package folder and an empty receipt.
pankso@1 380 pkg="$2"
pankso@1 381 [ "$pkg" ] || usage
pankso@1 382 echo ""
pankso@1 383 if [ -d "$WOK/$pkg" ]; then
pankso@1 384 echo -n "$pkg " && gettext "package already exist."
pankso@1 385 echo -e "\n" && exit 1
pankso@1 386 fi
pankso@1 387 gettext "Creating"; echo -n " $WOK/$pkg"
pankso@1 388 mkdir $WOK/$pkg && cd $WOK/$pkg && status
pankso@1 389 gettext "Preparing the package receipt..."
pankso@1 390 cp $DATA/receipt .
pankso@1 391 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
pankso@1 392 status && echo "" ;;
pankso@1 393 list)
pankso@1 394 # Cook a list of packages (better use the Cooker since it will order
pankso@1 395 # packages before executing cook).
pankso@1 396 check_root
pankso@1 397 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
pankso@1 398 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
pankso@1 399 echo -e " $2\n" && exit 1
pankso@1 400 for pkg in $(cat $2)
pankso@1 401 do
pankso@1 402 cook $pkg || broken
pankso@1 403 done ;;
pankso@1 404 clean-wok)
pankso@1 405 check_root
pankso@1 406 gettext -e "\nCleaning all packages files..."
pankso@1 407 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
pankso@1 408 status && echo "" ;;
pankso@1 409 clean-src)
pankso@1 410 check_root
pankso@1 411 gettext -e "\nCleaning all packages source..."
pankso@1 412 rm -rf $WOK/*/source
pankso@1 413 status && echo "" ;;
pankso@1 414 pkglist)
pankso@1 415 # Create suitable packages list for TazPKG and only for builded packages.
pankso@1 416 [ "$2" ] && PKGS="$2"
pankso@1 417 [ ! -d "$PKGS" ] && \
pankso@1 418 gettext -e "\nPackages directory dont exist\n\n" && exit 1
pankso@1 419 cd $PKGS
pankso@1 420 gettext -e "\nCreating lists for:"; echo " $PKGS"
pankso@1 421 separator
pankso@1 422 rm -f packages.* files.list*
pankso@1 423 gettext -e "Creating: packages.list\n"
pankso@1 424 ls -1 | sed s'/.tazpkg//' > $PKGS/packages.list
pankso@1 425 gettext -e "Creating: packages.md5\n"
pankso@1 426 md5sum *.tazpkg > $PKGS/packages.md5
pankso@1 427 gettext -e "Creating: packages.desc\n"
pankso@1 428 gettext -e "Creating: packages.equiv\n"
pankso@1 429 cd $WOK
pankso@1 430 for pkg in *
pankso@1 431 do
pankso@1 432 unset_receipt
pankso@1 433 . $pkg/receipt
pankso@1 434 # packages.desc let us search easily in DB
pankso@1 435 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@1 436 cat >> $PKGS/packages.desc << EOT
pankso@1 437 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
pankso@1 438 EOT
pankso@1 439 # Packages.equiv is used by tazpkg install to check depends.
pankso@1 440 for i in $PROVIDE; do
pankso@1 441 DEST=""
pankso@1 442 echo $i | fgrep -q : && DEST="${i#*:}:"
pankso@1 443 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
pankso@1 444 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
pankso@1 445 $PKGS/packages.equiv
pankso@1 446 else
pankso@1 447 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
pankso@1 448 fi
pankso@1 449 done
pankso@1 450 fi
pankso@1 451 done
pankso@1 452 # files.list.lzma
pankso@1 453 #lzma e files.list files.list.lzma
pankso@1 454 separator
pankso@1 455 nb=$(ls $PKGS/*.tazpkg | wc -l)
pankso@1 456 echo -e "Packages: $nb\n" ;;
pankso@1 457 *)
pankso@1 458 # Just cook and generate a package.
pankso@1 459 check_root
pankso@1 460 time=$(date +%s)
pankso@1 461 pkg="$1"
pankso@1 462 [ -z "$pkg" ] && usage
pankso@1 463 check_pkg_in_wok && echo ""
pankso@1 464 unset inst
pankso@1 465 unset_receipt
pankso@1 466 cd $WOK/$pkg && . ./receipt
pankso@1 467
pankso@1 468 # Handle --options
pankso@1 469 case "$2" in
pankso@1 470 --clean|-c)
pankso@1 471 gettext -e "Cleaning package:"; echo -n " $pkg"
pankso@1 472 cd $WOK/$pkg && rm -rf install taz source
pankso@1 473 status && echo "" && exit 0 ;;
pankso@1 474 --install|-i)
pankso@1 475 inst='yes' ;;
pankso@1 476 esac
pankso@1 477
pankso@1 478 # Check if wanted is build now so we have separate log files.
pankso@1 479 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then
pankso@1 480 cook "$WANTED"
pankso@1 481 fi
pankso@1 482
pankso@1 483 # Cook and pack or exit on error and log everything.
pankso@1 484 cookit | tee $LOGS/$pkg.log
pankso@8 485 remove_deps
pankso@1 486 cookit_quality
pankso@1 487 packit | tee -a $LOGS/$pkg.log
pankso@1 488 clean_log
pankso@1 489 packit_quality
pankso@1 490
pankso@1 491 # Time and summary
pankso@1 492 time=$(($(date +%s) - $time))
pankso@1 493 summary | tee -a $LOGS/$pkg.log
pankso@1 494
pankso@1 495 # Install package if requested
pankso@1 496 if [ "$inst" ]; then
pankso@1 497 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@1 498 cd $PKGS && tazpkg install \
pankso@1 499 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
pankso@1 500 else
pankso@1 501 gettext -e "Unable to install package, build have failed.\n\n"
pankso@1 502 exit 1
pankso@1 503 fi
pankso@1 504 fi
pankso@1 505 # Finally we may want to build the *-dev package
pankso@1 506 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
pankso@1 507 ;;
pankso@1 508 esac
pankso@1 509
pankso@1 510 exit 0