cookutils annotate cook @ rev 215

cook: dont install anything if we have missing dep
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 24 02:01:43 2011 +0200 (2011-05-24)
parents 1e9981880495
children e403679496d9
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@16 13 # Share DB and status with the Cooker.
pankso@9 14 activity="$CACHE/activity"
pankso@16 15 command="$CACHE/command"
pankso@11 16 broken="$CACHE/broken"
pankso@47 17 blocked="$CACHE/blocked"
pankso@9 18
pankso@172 19 # Old style compatibility
pankso@172 20 SOURCES_REPOSITORY=$SRC
pankso@172 21
pankso@1 22 #
pankso@1 23 # Functions
pankso@1 24 #
pankso@1 25
pankso@1 26 usage() {
pankso@1 27 cat << EOT
pankso@1 28
pankso@147 29 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command] [list|--option]
pankso@1 30
pankso@1 31 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
paul@214 32 usage|help $(gettext "Display this short usage.")
paul@214 33 setup $(gettext "Setup your build environment.")
paul@214 34 test $(gettext "Test environment and cook a package.")
paul@214 35 list-wok $(gettext "List packages in the wok.")
paul@214 36 search $(gettext "Simple packages search function.")
paul@214 37 new $(gettext "Create a new package with a receipt".)
paul@214 38 list $(gettext "Cook a list of packages.")
paul@214 39 clean-wok $(gettext "Clean-up all packages files.")
paul@214 40 clean-src $(gettext "Clean-up all packages sources.")
paul@214 41 pkglist $(gettext "Create all packages.* lists.")
pankso@1 42
pankso@1 43 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
paul@214 44 --clean|-c Cook : $(gettext "clean the package in the wok.")
paul@214 45 --install|-i Cook : $(gettext "cook and install the package.")
paul@214 46 --getsrc|-gs Cook : $(gettext "get the package source tarball.")
paul@214 47 --block|-b Cook : $(gettext "Block a package so cook will skip it.")
paul@214 48 --unblock|-ub Cook : $(gettext "Unblock a blocked package.")
paul@214 49 --interactive|-x Cook : $(gettext "create a receipt interactively.")
paul@214 50 --wok|-w Setup: $(gettext "create also a wok from Hg repo.")
pankso@1 51
pankso@1 52 EOT
pankso@1 53 exit 0
pankso@1 54 }
pankso@1 55
paul@62 56 # Be sure we're root.
pankso@1 57 check_root() {
pankso@1 58 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0
pankso@1 59 }
pankso@1 60
pankso@1 61 separator() {
pankso@1 62 echo "================================================================================"
pankso@1 63 }
pankso@1 64
pankso@1 65 status() {
pankso@1 66 echo -en "\\033[70G[ "
pankso@1 67 if [ $? = 0 ]; then
pankso@1 68 echo -en "\\033[1;32mOK"
pankso@1 69 else
pankso@1 70 echo -en "\\033[1;31mFailed"
pankso@1 71 fi
pankso@1 72 echo -e "\\033[0;39m ]"
pankso@1 73 }
pankso@1 74
pankso@13 75 # Log activities, we want first letter capitalized.
pankso@9 76 log() {
pankso@27 77 grep ^[A-Z] | \
pankso@9 78 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
pankso@9 79 }
pankso@9 80
paul@62 81 # We don't want these escapes in web interface.
pankso@1 82 clean_log() {
pankso@1 83 sed -i -e s'|\[70G\[ \[1;32m| |' \
pankso@1 84 -e s'|\[0;39m \]||' $LOGS/$pkg.log
pankso@1 85 }
pankso@1 86
pankso@23 87 # Log broken packages.
pankso@23 88 broken() {
pankso@74 89 if ! grep -q "^$pkg$" $broken; then
pankso@74 90 echo "$pkg" >> $broken
pankso@74 91 fi
pankso@23 92 }
pankso@23 93
paul@62 94 # Be sure package exists in wok.
pankso@1 95 check_pkg_in_wok() {
pankso@1 96 if [ ! -d "$WOK/$pkg" ]; then
pankso@1 97 gettext -e "\nUnable to find package in the wok:"
pankso@1 98 echo -e " $pkg\n" && exit 1
pankso@1 99 fi
pankso@1 100 }
pankso@1 101
pankso@9 102 if_empty_value() {
pankso@9 103 if [ -z "$value" ]; then
pankso@9 104 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
pankso@9 105 exit 1
pankso@9 106 fi
pankso@9 107 }
pankso@9 108
paul@62 109 # Initialize files used in $CACHE
pankso@52 110 init_db_files() {
pankso@52 111 gettext "Creating directories structure in:"; echo " $SLITAZ"
pankso@52 112 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
pankso@52 113 gettext "Creating DB files in:"; echo " $CACHE"
pankso@52 114 for f in $activity $command $broken $blocked
pankso@52 115 do
pankso@52 116 touch $f
pankso@52 117 done
pankso@52 118 }
pankso@52 119
paul@62 120 # QA: check a receipt consistency before building.
pankso@9 121 receipt_quality() {
pankso@9 122 gettext -e "QA: checking package receipt...\n"
pankso@9 123 unset online
pankso@9 124 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
pankso@9 125 online="online"
pankso@9 126 fi
pankso@9 127 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
pankso@9 128 do
pankso@9 129 unset value
pankso@44 130 value=$(grep ^$var= $receipt | cut -d \" -f 2)
pankso@9 131 case "$var" in
pankso@9 132 PACKAGE|VERSION|SHORT_DESC)
pankso@9 133 if_empty_value ;;
pankso@9 134 CATEGORY)
pankso@9 135 [ -z "$value" ] && value="empty"
pankso@9 136 valid="base-system x-window utilities network graphics \
pankso@9 137 multimedia office development system-tools security games \
pankso@9 138 misc meta non-free"
pankso@9 139 if ! echo "$valid" | grep -q -w "$value"; then
paul@62 140 gettext "QA: unknown category:"; echo -e " $value\n"
pankso@9 141 exit 1
pankso@9 142 fi ;;
pankso@9 143 WEB_SITE)
paul@62 144 # We don't check WGET_URL since if dl is needed it will fail.
paul@62 145 # Break also if we're not online. Here error is not fatal.
pankso@9 146 if_empty_value
pankso@9 147 [ -z "$online" ] || break
pankso@199 148 if ! busybox wget -T 12 -s $value 2>/dev/null; then
pankso@61 149 gettext "QA: Unable to reach:"; echo -e " $value"
pankso@9 150 fi ;;
pankso@9 151 esac
pankso@9 152 done
pankso@9 153 }
pankso@9 154
pankso@9 155 # Executed before sourcing a receipt.
pankso@9 156 unset_receipt() {
pankso@9 157 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
pankso@9 158 }
pankso@9 159
paul@62 160 # Paths used in receipt and by cook itself.
pankso@1 161 set_paths() {
pankso@1 162 pkgdir=$WOK/$PACKAGE
pankso@1 163 src=$pkgdir/source/$PACKAGE-$VERSION
pankso@44 164 taz=$pkgdir/taz
pankso@44 165 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
pankso@1 166 fs=$pack/fs
pankso@1 167 stuff=$pkgdir/stuff
pankso@1 168 install=$pkgdir/install
pankso@1 169 if [ "$WANTED" ]; then
pankso@1 170 src=$WOK/$WANTED/source/$WANTED-$VERSION
pankso@1 171 install=$WOK/$WANTED/install
pankso@121 172 wanted_stuff=$WOK/$WANTED/stuff
pankso@1 173 fi
pankso@9 174 # Old way compatibility.
pankso@1 175 _pkg=$install
pankso@1 176 }
pankso@1 177
pankso@144 178 # Create source tarball when URL is a SCM.
pankso@144 179 create_tarball() {
pankso@144 180 gettext "Creating tarball: "; echo "$tarball"
pankso@162 181 if [ "$LZMA_SRC" ]; then
pankso@162 182 tar -c $pkgsrc | lzma e $SRC/$tarball -si || exit 1
pankso@162 183 else
pankso@162 184 tar cjf $tarball $pkgsrc || exit 1
pankso@162 185 mv $tarball $SRC && rm -rf $pkgsrc
pankso@162 186 fi
pankso@144 187 }
pankso@144 188
pankso@145 189 # Get package source. For SCM we are in cache so clone here and create a
pankso@145 190 # tarball here.
pankso@1 191 get_source() {
pankso@115 192 pwd=$(pwd)
pankso@144 193 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
pankso@144 194 tarball=$pkgsrc.tar.bz2
pankso@162 195 [ "$LZMA_SRC" ] && tarball=$pkgsrc.tar.lzma
pankso@9 196 case "$WGET_URL" in
pankso@145 197 http://*|ftp://*)
pankso@9 198 # Busybox Wget is better!
pankso@199 199 busybox wget -T 12 -c -P $SRC $WGET_URL || \
pankso@145 200 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
pankso@145 201 https://*)
pankso@145 202 wget -c --no-check-certificate -P $SRC $WGET_URL || \
pankso@15 203 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
pankso@9 204 hg*|mercurial*)
pankso@29 205 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
pankso@9 206 url=${WGET_URL#hg|}
pankso@9 207 else
pankso@9 208 url=${WGET_URL#mercurial|}
pankso@9 209 fi
pankso@61 210 gettext -e "Getting source from Hg...\n"
pankso@61 211 echo "URL: $url"
pankso@9 212 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
pankso@15 213 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
pankso@144 214 create_tarball ;;
pankso@9 215 git*)
pankso@61 216 url=${WGET_URL#git|}
pankso@61 217 gettext -e "Getting source from Git...\n"
pankso@61 218 echo "URL: $url"
pankso@64 219 git clone $url $pkgsrc || (echo "ERROR: git clone $url" && exit 1)
pankso@63 220 if [ "$BRANCH" ]; then
pankso@146 221 echo "Git branch: $BRANCH"
pankso@64 222 cd $pkgsrc && git checkout $BRANCH && cd ..
pankso@63 223 fi
pankso@144 224 create_tarball ;;
pankso@144 225 cvs*)
pankso@144 226 url=${WGET_URL#cvs|}
pankso@144 227 mod=$PACKAGE
pankso@144 228 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
pankso@144 229 gettext -e "Getting source from CVS...\n"
pankso@144 230 echo "URL: $url"
pankso@146 231 [ "$CVS_MODULE" ] && echo "CVS module: $mod"
pankso@144 232 gettext "Cloning to: "; echo "$pwd/$mod"
pankso@144 233 cvs -d:$url co $mod && mv $mod $pkgsrc
pankso@144 234 create_tarball ;;
pankso@69 235 svn*|subversion*)
pankso@159 236 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
pankso@146 237 url=${WGET_URL#svn|}
pankso@146 238 else
pankso@146 239 url=${WGET_URL#subversion|}
pankso@146 240 fi
pankso@146 241 gettext -e "Getting source from SVN...\n"
pankso@146 242 echo "URL: $url"
pankso@161 243 if [ "$BRANCH" ]; then
pankso@161 244 echo t | svn co $url -r $BRANCH $pkgsrc
pankso@161 245 else
pankso@161 246 echo t | svn co $url $pkgsrc
pankso@161 247 fi
pankso@146 248 create_tarball ;;
pankso@9 249 *)
pankso@9 250 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
pankso@9 251 tee -a $LOGS/$PACKAGE.log
pankso@9 252 exit 1 ;;
pankso@9 253 esac
pankso@1 254 }
pankso@1 255
pankso@9 256 # Extract source package.
pankso@1 257 extract_source() {
pankso@177 258 if [ ! -s "$SRC/$TARBALL" ]; then
pankso@177 259 local url
pankso@177 260 url="http://mirror.slitaz.org/sources/packages"
pankso@177 261 url=$url/${TARBALL:0:1}/$TARBALL
pankso@177 262 gettext "Getting source from mirror:"; echo " $url"
pankso@177 263 busybox wget -c -P $SRC $url || echo -e "ERROR: wget $url"
pankso@177 264 fi
pankso@1 265 gettext "Extracting:"; echo " $TARBALL"
pankso@1 266 case "$TARBALL" in
pankso@120 267 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
pankso@178 268 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
pankso@1 269 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
pankso@42 270 *.tar) tar xf $SRC/$TARBALL ;;
pankso@42 271 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
pankso@42 272 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
pankso@42 273 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
pankso@42 274 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
pankso@191 275 *) cp $SRC/$TARBALL $(pwd) ;;
pankso@1 276 esac
pankso@1 277 }
pankso@1 278
pankso@9 279 # Display cooked package summary.
pankso@1 280 summary() {
pankso@1 281 cd $WOK/$pkg
pankso@1 282 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
pankso@1 283 fs=$(du -sh taz/* | awk '{print $1}')
pankso@44 284 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
pankso@44 285 files=$(cat taz/$pkg-*/files.list | wc -l)
pankso@18 286 cookdate=$(date "+%Y-%m-%d %H:%M")
pankso@101 287 sec=$time
pankso@104 288 div=$(($time / 60))
pankso@112 289 [ "$div" != 0 ] && min="~ ${div}m"
pankso@1 290 gettext "Summary for:"; echo " $PACKAGE $VERSION"
pankso@1 291 separator
pankso@67 292 [ "$prod" ] && echo "Produced : $prod"
pankso@1 293 cat << EOT
pankso@1 294 Packed : $fs
pankso@1 295 Compressed : $size
pankso@18 296 Files : $files
pankso@102 297 Cook time : ${sec}s $min
pankso@18 298 Cook date : $cookdate
pankso@1 299 $(separator)
pankso@1 300 EOT
pankso@1 301 }
pankso@1 302
paul@62 303 # Display debugging error info.
pankso@15 304 debug_info() {
pankso@17 305 echo -e "\nDebug information"
pankso@15 306 separator
pankso@48 307 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
pankso@76 308 for error in \
pankso@77 309 ERROR "No package" "cp: can't" "can't open" "can't cd" \
pankso@76 310 "error:" "fatal error:"
pankso@34 311 do
pankso@34 312 fgrep "$error" $LOGS/$pkg.log
pankso@34 313 done
pankso@15 314 separator && echo ""
pankso@15 315 }
pankso@15 316
pankso@1 317 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@1 318 # so some packages need to copy these files with the receipt and genpkg_rules.
pankso@1 319 copy_generic_files()
pankso@1 320 {
pankso@1 321 # $LOCALE is set in cook.conf
pankso@1 322 if [ "$LOCALE" ]; then
pankso@1 323 if [ -d "$_pkg/usr/share/locale" ]; then
pankso@1 324 mkdir -p $fs/usr/share/locale
pankso@1 325 for i in $LOCALE
pankso@1 326 do
pankso@1 327 if [ -d "$_pkg/usr/share/locale/$i" ]; then
pankso@1 328 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
pankso@1 329 fi
pankso@1 330 done
pankso@1 331 fi
pankso@1 332 fi
pankso@1 333
pankso@1 334 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
pankso@1 335 if [ "$GENERIC_PIXMAPS" != "no" ]; then
pankso@1 336 if [ -d "$_pkg/usr/share/pixmaps" ]; then
pankso@1 337 mkdir -p $fs/usr/share/pixmaps
pankso@1 338 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
pankso@1 339 $fs/usr/share/pixmaps 2>/dev/null
pankso@1 340 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
pankso@1 341 $fs/usr/share/pixmaps 2>/dev/null
pankso@1 342 fi
pankso@1 343
pankso@1 344 # Custom or homemade PNG pixmap can be in stuff.
pankso@1 345 if [ -f "$stuff/$PACKAGE.png" ]; then
pankso@1 346 mkdir -p $fs/usr/share/pixmaps
pankso@1 347 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@1 348 fi
pankso@1 349 fi
pankso@1 350
pankso@1 351 # Desktop entry (.desktop).
pankso@1 352 if [ -d "$_pkg/usr/share/applications" ]; then
pankso@1 353 cp -a $_pkg/usr/share/applications $fs/usr/share
pankso@1 354 fi
pankso@1 355
pankso@1 356 # Homemade desktop file(s) can be in stuff.
pankso@1 357 if [ -d "$stuff/applications" ]; then
pankso@1 358 mkdir -p $fs/usr/share
pankso@1 359 cp -a $stuff/applications $fs/usr/share
pankso@1 360 fi
pankso@1 361 if [ -f "$stuff/$PACKAGE.desktop" ]; then
pankso@1 362 mkdir -p $fs/usr/share/applications
pankso@1 363 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@1 364 fi
pankso@1 365 }
pankso@1 366
pankso@67 367 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
pankso@68 368 # as removing uneeded files like in Python packages.
pankso@1 369 strip_package()
pankso@1 370 {
pankso@67 371 gettext "Executing strip on all files..."
pankso@1 372 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@1 373 do
pankso@1 374 if [ -d "$dir" ]; then
pankso@1 375 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
pankso@1 376 fi
pankso@1 377 done
pankso@1 378 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
pankso@1 379 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
pankso@1 380 status
pankso@67 381
pankso@117 382 # Remove Python .pyc and .pyo from packages.
pankso@150 383 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
pankso@68 384 gettext "Removing Python compiled files..."
pankso@67 385 find $fs -type f -name "*.pyc" -delete 2>/dev/null
pankso@67 386 find $fs -type f -name "*.pyo" -delete 2>/dev/null
pankso@117 387 status
pankso@117 388 fi
pankso@117 389
pankso@117 390 # Remove Perl perllocal.pod and .packlist from packages.
pankso@117 391 if echo "$DEPENDS" | fgrep -q "perl"; then
pankso@117 392 gettext "Removing Perl compiled files..."
pankso@67 393 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
pankso@67 394 find $fs -type f -name ".packlist" -delete 2>/dev/null
pankso@67 395 status
pankso@67 396 fi
pankso@1 397 }
pankso@1 398
pankso@8 399 # Remove installed deps.
pankso@8 400 remove_deps() {
pankso@8 401 # Now remove installed build deps.
pankso@113 402 diff="$CACHE/installed.cook.diff"
pankso@113 403 if [ -s "$CACHE/installed.cook.diff" ]; then
pankso@113 404 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
pankso@113 405 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
pankso@8 406 gettext "Build dependencies to remove:"; echo " $nb"
pankso@8 407 gettext "Removing:"
pankso@8 408 for dep in $deps
pankso@8 409 do
pankso@8 410 echo -n " $dep"
pankso@205 411 echo 'y' | tazpkg remove $dep >/dev/null
pankso@8 412 done
pankso@16 413 echo -e "\n"
pankso@113 414 # Keep the last diff for debug and info.
pankso@113 415 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
pankso@1 416 fi
pankso@1 417 }
pankso@1 418
pankso@1 419 # The main cook function.
pankso@1 420 cookit() {
pankso@11 421 echo "Cook: $PACKAGE $VERSION"
pankso@9 422 separator
pankso@1 423 set_paths
pankso@9 424 [ "$QA" ] && receipt_quality
pankso@44 425 cd $pkgdir
pankso@33 426 rm -rf install taz source
pankso@1 427
pankso@1 428 # Disable -pipe if less than 512Mb free RAM.
pankso@1 429 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
pankso@1 430 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
pankso@1 431 gettext -e "Disabling -pipe compile flag: $free RAM\n"
pankso@1 432 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
pankso@47 433 CXXFLAGS="${CXXFLAGS/-pipe}" && \
pankso@47 434 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
pankso@1 435 fi
pankso@1 436 unset free
pankso@1 437
pankso@1 438 # Export flags and path to be used by make
pankso@44 439 DESTDIR=$pkgdir/install
pankso@215 440 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
pankso@1 441
pankso@126 442 # Check for build deps and handle implicit depends of *-dev packages
pankso@126 443 # (ex: libusb-dev :: libusb).
pankso@215 444 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
pankso@215 445 touch $CACHE/installed.local $CACHE/installed.web
pankso@215 446 [ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
pankso@1 447 for dep in $BUILD_DEPENDS
pankso@1 448 do
pankso@126 449 implicit=${dep%-dev}
pankso@131 450 for i in $dep $implicit
pankso@126 451 do
pankso@131 452 if [ ! -f "$INSTALLED/$i/receipt" ]; then
paul@174 453 # Try local package first. In some cases implicit doesn't exist, ex:
paul@174 454 # libboost-dev exists but not libboost, so check if we got vers.
pankso@173 455 unset vers
pankso@198 456 vers=$(grep ^VERSION= $WOK/$i/receipt 2>/dev/null | cut -d '"' -f 2)
pankso@131 457 if [ -f "$PKGS/$i-$vers.tazpkg" ]; then
pankso@215 458 echo $i-$vers.tazpkg >> $CACHE/installed.local
pankso@126 459 else
pankso@173 460 if [ "$vers" ]; then
pankso@202 461 if fgrep -q $i-$vers $DB/packages.list; then
pankso@215 462 echo $i >> $CACHE/installed.web
pankso@198 463 else
paul@211 464 # So package exists in wok but not available.
pankso@215 465 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
pankso@215 466 echo $i >> $CACHE/missing.dep
pankso@198 467 fi
pankso@173 468 fi
pankso@126 469 fi
pankso@1 470 fi
pankso@126 471 done
pankso@1 472 done
pankso@8 473
pankso@215 474 # Get the list of installed packages
pankso@215 475 cd $INSTALLED && ls -1 > $CACHE/installed.list
pankso@204 476
paul@211 477 # Have we a missing build dep to cook ?
pankso@215 478 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
pankso@205 479 gettext -e "Auto cook config is set : AUTO_COOK\n"
pankso@204 480 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
pankso@215 481 for i in $(cat $CACHE/missing.dep)
pankso@204 482 do
pankso@205 483 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
pankso@204 484 tee -a $LOGS/$PACKAGE.log.$$
pankso@205 485 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
pankso@205 486 fgrep "remove: " $LOGS/$i.log && \
pankso@205 487 fgrep "Removing: " $LOGS/$i.log && echo "") | \
pankso@204 488 tee -a $LOGS/$PACKAGE.log.$$ && break
pankso@204 489 done
pankso@215 490 rm -f $CACHE/missing.dep
pankso@204 491 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
pankso@204 492 fi
pankso@204 493
paul@211 494 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
paul@211 495 # is enabled and cook fails we have ERROR in log, if no auto cook we have
pankso@204 496 # missing dep in cached file.
pankso@215 497 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
pankso@215 498 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
pankso@215 499 echo "ERROR: missing dep $nb" && exit 1
pankso@202 500 fi
pankso@215 501
pankso@215 502 # Install local packages.
pankso@215 503 cd $PKGS
pankso@215 504 for i in $(cat $CACHE/installed.local)
pankso@215 505 do
pankso@215 506 gettext "Installing dep (pkg/local):"; echo " $i $vers"
pankso@215 507 tazpkg install $i >/dev/null
pankso@215 508 done
pankso@215 509
pankso@215 510 # Install web or cached packages (if mirror is set to $PKGS we only
pankso@215 511 # use local packages).
pankso@215 512 for i in $(cat $CACHE/installed.web)
pankso@215 513 do
pankso@215 514 gettext "Installing dep (web/cache):"; echo " $i $vers"
pankso@215 515 tazpkg get-install $i >/dev/null
pankso@215 516 done
pankso@215 517
pankso@215 518 # If a cook failed deps are removed.
pankso@215 519 cd $INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
pankso@215 520 [ ! -s "installed.cook.diff" ] && \
pankso@215 521 busybox diff installed.list installed.cook > installed.cook.diff
pankso@215 522 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
pankso@202 523
pankso@1 524 # Get source tarball and make sure we have source dir named:
paul@62 525 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
paul@62 526 # tarball if it exists.
pankso@1 527 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
pankso@1 528 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
pankso@10 529 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
pankso@190 530 LZMA_SRC=""
pankso@1 531 else
pankso@1 532 get_source || exit 1
pankso@1 533 fi
pankso@1 534 fi
pankso@9 535 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
pankso@1 536 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
pankso@1 537 extract_source || exit 1
pankso@190 538 if [ "$LZMA_SRC" ]; then
pankso@190 539 cd $pkgdir/source
pankso@190 540 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
pankso@190 541 mv tmp tmp-1 && mkdir tmp
pankso@190 542 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
pankso@190 543 fi
pankso@190 544 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
pankso@190 545 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
pankso@190 546 fi
pankso@190 547 fi
pankso@190 548 cd $pkgdir/source/tmp
paul@62 549 # Some archives are not well done and don't extract to one dir (ex lzma).
pankso@57 550 files=$(ls | wc -l)
pankso@57 551 [ "$files" == 1 ] && mv * ../$PACKAGE-$VERSION
pankso@57 552 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
pankso@57 553 mv * ../$PACKAGE-$VERSION
pankso@1 554 cd .. && rm -rf tmp
pankso@1 555 fi
pankso@1 556
pankso@9 557 # Execute receipt rules.
pankso@44 558 if grep -q ^compile_rules $receipt; then
pankso@1 559 gettext -e "Executing: compile_rules\n"
pankso@55 560 [ -d "$src" ] && cd $src
pankso@97 561 compile_rules $@ || exit 1
pankso@10 562 # Stay compatible with _pkg
pankso@55 563 [ -d "$src/_pkg" ] && mv $src/_pkg $install
pankso@9 564 # QA: compile_rules success so valid.
pankso@9 565 mkdir -p $install
pankso@9 566 else
pankso@9 567 # QA: No compile_rules so no error, valid.
pankso@9 568 mkdir -p $install
pankso@1 569 fi
pankso@1 570 separator && echo ""
pankso@1 571 }
pankso@1 572
pankso@1 573 # Cook quality assurance.
pankso@1 574 cookit_quality() {
pankso@9 575 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
pankso@15 576 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
pankso@9 577 fi
pankso@9 578 # ERROR can be echoed any time in cookit()
pankso@33 579 if fgrep -q ERROR: $LOGS/$pkg.log; then
pankso@17 580 debug_info | tee -a $LOGS/$pkg.log
pankso@33 581 rm -f $command && exit 1
pankso@1 582 fi
pankso@1 583 }
pankso@1 584
pankso@16 585 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
paul@62 586 # but it doesn't handle EXTRAVERSION.
pankso@1 587 packit() {
pankso@1 588 set_paths
pankso@55 589 echo "Pack: $PACKAGE $VERSION"
pankso@1 590 separator
pankso@44 591 if grep -q ^genpkg_rules $receipt; then
pankso@16 592 gettext -e "Executing: genpkg_rules\n"
pankso@16 593 cd $pkgdir
pankso@182 594 mkdir -p $fs && ( set -e; genpkg_rules ) || echo -e \
pankso@98 595 "\nERROR: genpkg_rules failed\n" >> $LOGS/$pkg.log
pankso@16 596 fi
pankso@98 597
pankso@98 598 # First QA check to stop now if genpkg_rules failed.
pankso@98 599 if fgrep -q ERROR: $LOGS/$pkg.log; then
pankso@98 600 exit 1
pankso@98 601 fi
pankso@98 602
pankso@44 603 cd $taz
pankso@1 604 for file in receipt description.txt
pankso@1 605 do
pankso@1 606 [ ! -f "../$file" ] && continue
pankso@1 607 gettext "Copying"; echo -n " $file..."
pankso@1 608 cp -f ../$file $pack && chown 0.0 $pack/$file && status
pankso@1 609 done
pankso@119 610 copy_generic_files
pankso@16 611
paul@62 612 # Create files.list with redirecting find output.
pankso@16 613 gettext "Creating the list of files..." && cd $fs
pankso@16 614 find . -type f -print > ../files.list
pankso@16 615 find . -type l -print >> ../files.list
pankso@16 616 cd .. && sed -i s/'^.'/''/ files.list
pankso@16 617 status
pankso@43 618
pankso@119 619 # Strip and stuff files.
pankso@43 620 strip_package
pankso@43 621
pankso@43 622 # Md5sum of files.
pankso@16 623 gettext "Creating md5sum of files..."
pankso@16 624 while read file; do
pankso@16 625 [ -L "fs$file" ] && continue
pankso@16 626 [ -f "fs$file" ] || continue
pankso@16 627 case "$file" in
pankso@16 628 /lib/modules/*/modules.*|*.pyc) continue;;
pankso@16 629 esac
pankso@16 630 md5sum "fs$file" | sed 's/ fs/ /'
pankso@16 631 done < files.list > md5sum
pankso@16 632 status
pankso@16 633 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
pankso@16 634 description.txt 2> /dev/null | awk \
pankso@16 635 '{ sz=$1 } END { print sz }')
pankso@16 636
pankso@16 637 # Build cpio archives.
pankso@16 638 gettext "Compressing the fs... "
pankso@16 639 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pankso@16 640 rm -rf fs
pankso@16 641 status
pankso@16 642 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
pankso@16 643 md5sum description.txt 2> /dev/null | awk \
pankso@16 644 '{ sz=$1 } END { print sz }')
pankso@16 645 gettext "Updating receipt sizes..."
pankso@16 646 sed -i s/^PACKED_SIZE.*$// receipt
pankso@16 647 sed -i s/^UNPACKED_SIZE.*$// receipt
pankso@16 648 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pankso@16 649 status
pankso@16 650
pankso@16 651 # Set extra version.
pankso@16 652 if [ "$EXTRAVERSION" ]; then
pankso@16 653 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
pankso@16 654 sed -i s/^EXTRAVERSION.*$// receipt
pankso@16 655 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
pankso@16 656 status
pankso@16 657 fi
pankso@16 658
pankso@16 659 # Compress.
pankso@16 660 gettext "Creating full cpio archive... "
pankso@16 661 find . -print | cpio -o -H newc --quiet > \
pankso@16 662 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
pankso@16 663 status
pankso@16 664 gettext "Restoring original package tree... "
pankso@16 665 unlzma -c fs.cpio.lzma | cpio -idm --quiet
pankso@16 666 status
pankso@16 667 rm fs.cpio.lzma && cd ..
pankso@43 668
pankso@43 669 # QA and give info.
pankso@43 670 tazpkg=$(ls *.tazpkg)
pankso@43 671 packit_quality
pankso@43 672 separator && gettext "Package:"; echo -e " $tazpkg\n"
pankso@1 673 }
pankso@1 674
paul@62 675 # Verify package quality and consistency.
pankso@8 676 packit_quality() {
pankso@157 677 #gettext "QA: Checking for broken link..."
pankso@157 678 #link=$(find $fs/usr -type l -follow)
pankso@157 679 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
pankso@157 680 #status
pankso@142 681
pankso@142 682 # Exit if any error found in log file.
pankso@33 683 if fgrep -q ERROR: $LOGS/$pkg.log; then
pankso@32 684 rm -f $command && exit 1
pankso@8 685 fi
pankso@142 686
pankso@44 687 gettext "QA: Checking for empty package..."
pankso@45 688 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
pankso@45 689 if [ "$files" -lt 0 ] && [ "$CATEGORY" != "meta" ]; then
pankso@44 690 echo -e "\nERROR: empty package"
pankso@32 691 rm -f $command && exit 1
pankso@8 692 else
pankso@134 693 # Ls sort by name so the first file is the one we want.
pankso@136 694 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
pankso@134 695 status
pankso@154 696 if [ -f "$old" ]; then
pankso@154 697 echo -n "Removing old: $(basename $old)"
pankso@135 698 rm -f $old && status
pankso@154 699 fi
pankso@134 700 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
pankso@11 701 sed -i /^${pkg}$/d $broken
pankso@8 702 fi
pankso@8 703 }
pankso@8 704
pankso@1 705 #
pankso@1 706 # Commands
pankso@1 707 #
pankso@1 708
pankso@1 709 case "$1" in
pankso@32 710 usage|help|-u|-h)
pankso@1 711 usage ;;
pankso@1 712 list-wok)
pankso@52 713 gettext -e "\nList of packages in:"; echo " $WOK"
pankso@1 714 separator
pankso@1 715 cd $WOK && ls -1
pankso@1 716 separator
pankso@1 717 echo -n "Packages: " && ls | wc -l
pankso@1 718 echo "" ;;
pankso@69 719 search)
pankso@69 720 # Just a simple search function, we dont need more actually.
pankso@69 721 query="$2"
pankso@69 722 gettext -e "\nSearch results for:"; echo " $query"
pankso@69 723 separator
pankso@69 724 cd $WOK && ls -1 | grep "$query"
pankso@69 725 separator && echo "" ;;
pankso@1 726 setup)
pankso@1 727 # Setup a build environment
pankso@1 728 check_root
pankso@11 729 echo "Cook: setting up the environment" | log
pankso@1 730 gettext -e "\nSetting up your environment\n"
pankso@1 731 separator && cd $SLITAZ
pankso@52 732 init_db_files
pankso@1 733 gettext -e "Checking for packages to install...\n"
pankso@29 734 for pkg in $SETUP_PKGS
pankso@1 735 do
pankso@52 736 [ ! -f "$INSTALLED/$pkg/receipt" ] && tazpkg get-install $pkg
pankso@1 737 done
pankso@1 738
pankso@1 739 # Handle --options
pankso@1 740 case "$2" in
pankso@49 741 --wok|-w)
pankso@52 742 [ ! -f "$INSTALLED/mercurial/receipt" ] && \
pankso@52 743 tazpkg get-install mercurial
paul@62 744 [ -d "$WOK" ] && echo -e "A wok already exists.\n" && exit 1
pankso@176 745 hg clone $WOK_URL ;;
pankso@1 746 esac
pankso@1 747
pankso@1 748 # SliTaz group and permissions
pankso@1 749 if ! grep -q ^slitaz /etc/group; then
pankso@1 750 gettext -e "Adding group: slitaz\n"
pankso@1 751 addgroup slitaz
pankso@1 752 fi
pankso@1 753 gettext -e "Setting permissions for slitaz group...\n"
pankso@1 754 chown -R root.slitaz $SLITAZ
pankso@1 755 chmod -R g+w $SLITAZ
pankso@1 756 separator
pankso@1 757 gettext -e "All done, ready to cook packages :-)\n\n" ;;
pankso@9 758 test)
pankso@9 759 # Test a cook environment.
pankso@13 760 echo "Cook test: testing the cook environment" | log
pankso@9 761 [ ! -d "$WOK" ] && exit 1
pankso@9 762 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
pankso@9 763 cook cooktest ;;
pankso@1 764 new)
pankso@1 765 # Create the package folder and an empty receipt.
pankso@1 766 pkg="$2"
pankso@1 767 [ "$pkg" ] || usage
pankso@1 768 echo ""
pankso@1 769 if [ -d "$WOK/$pkg" ]; then
paul@62 770 echo -n "$pkg " && gettext "package already exists."
pankso@1 771 echo -e "\n" && exit 1
pankso@1 772 fi
pankso@1 773 gettext "Creating"; echo -n " $WOK/$pkg"
pankso@1 774 mkdir $WOK/$pkg && cd $WOK/$pkg && status
pankso@1 775 gettext "Preparing the package receipt..."
pankso@1 776 cp $DATA/receipt .
pankso@1 777 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
pankso@196 778 status && echo ""
pankso@196 779
pankso@196 780 # Interactive mode, asking and seding.
pankso@196 781 case "$3" in
paul@214 782 --interactive|-x)
paul@211 783 gettext -e "Entering interactive mode...\n"
paul@211 784 separator
pankso@196 785 echo "Package : $pkg"
pankso@196 786 # Version.
pankso@196 787 echo -n "Version : " ; read anser
pankso@196 788 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
pankso@196 789 # Category.
pankso@196 790 echo -n "Category : " ; read anser
pankso@196 791 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
pankso@196 792 # Short description.
pankso@196 793 echo -n "Short desc : " ; read anser
pankso@196 794 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
pankso@196 795 # Maintainer.
pankso@196 796 echo -n "Maintainer : " ; read anser
pankso@196 797 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
pankso@196 798 # Web site.
pankso@196 799 echo -n "Web site : " ; read anser
pankso@196 800 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
pankso@196 801 echo ""
pankso@196 802 # Wget URL.
pankso@196 803 echo "Wget URL to download source tarball."
pankso@196 804 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
pankso@196 805 echo -n "Wget url : " ; read anser
paul@211 806 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
pankso@196 807 # Ask for a stuff dir.
pankso@196 808 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
pankso@196 809 if [ "$anser" = "y" ]; then
pankso@196 810 echo -n "Creating the stuff directory..."
pankso@196 811 mkdir $WOK/$pkg/stuff && status
pankso@196 812 fi
pankso@196 813 # Ask for a description file.
pankso@196 814 echo -n "Are you going to write a description ? (y/N) : " ; read anser
pankso@196 815 if [ "$anser" = "y" ]; then
pankso@196 816 echo -n "Creating the description.txt file..."
pankso@196 817 echo "" > $WOK/$pkg/description.txt && status
pankso@196 818 fi
paul@211 819 separator
paul@211 820 gettext -e "Receipt is ready to use.\n"
pankso@196 821 echo "" ;;
pankso@196 822 esac ;;
pankso@1 823 list)
pankso@1 824 # Cook a list of packages (better use the Cooker since it will order
pankso@1 825 # packages before executing cook).
pankso@1 826 check_root
pankso@1 827 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
pankso@1 828 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
pankso@1 829 echo -e " $2\n" && exit 1
pankso@13 830 echo "Cook list starting: $2" | log
pankso@1 831 for pkg in $(cat $2)
pankso@1 832 do
pankso@1 833 cook $pkg || broken
pankso@1 834 done ;;
pankso@1 835 clean-wok)
pankso@1 836 check_root
pankso@1 837 gettext -e "\nCleaning all packages files..."
pankso@1 838 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
pankso@1 839 status && echo "" ;;
pankso@1 840 clean-src)
pankso@1 841 check_root
paul@62 842 gettext -e "\nCleaning all packages sources..."
pankso@1 843 rm -rf $WOK/*/source
pankso@1 844 status && echo "" ;;
pankso@1 845 pkglist)
paul@62 846 # Create suitable packages list for TazPKG and only for built packages.
pankso@1 847 [ "$2" ] && PKGS="$2"
pankso@1 848 [ ! -d "$PKGS" ] && \
paul@62 849 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1
pankso@133 850 echo "cook:pkglist" > $command
paul@62 851 echo "Cook pkglist: Creating all packages lists" | log
pankso@1 852 gettext -e "\nCreating lists for:"; echo " $PKGS"
pankso@1 853 separator
pankso@133 854 cd $PKGS
pankso@192 855 rm -f packages.*
pankso@213 856 gettext "Creating: packages.list: "
pankso@85 857 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
pankso@213 858 echo $(du -sh $PKGS/packages.list | awk '{print $1}')
pankso@213 859 gettext "Creating: packages.md5: "
pankso@1 860 md5sum *.tazpkg > $PKGS/packages.md5
pankso@213 861 echo $(du -sh $PKGS/packages.md5 | awk '{print $1}')
pankso@213 862 gettext -e "Creating lists from:"; echo " $WOK"
pankso@1 863 cd $WOK
pankso@1 864 for pkg in *
pankso@1 865 do
pankso@1 866 unset_receipt
pankso@1 867 . $pkg/receipt
pankso@1 868 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@192 869 # packages.desc lets us search easily in DB
pankso@1 870 cat >> $PKGS/packages.desc << EOT
pankso@1 871 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
pankso@1 872 EOT
pankso@192 873 # packages.txt used by tazpkg and tazpkg-web also to provide
pankso@192 874 # a human readable package list with version and description.
pankso@192 875 cat >> $PKGS/packages.txt << EOT
pankso@192 876 $PACKAGE
pankso@192 877 ${VERSION}$EXTRAVERSION
pankso@192 878 $SHORT_DESC
pankso@192 879 $PACKED_SIZE ($UNPACKED_SIZE installed)
pankso@192 880
pankso@192 881 EOT
pankso@192 882 # packages.equiv is used by tazpkg install to check depends.
pankso@1 883 for i in $PROVIDE; do
pankso@1 884 DEST=""
pankso@1 885 echo $i | fgrep -q : && DEST="${i#*:}:"
pankso@1 886 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
pankso@1 887 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
pankso@1 888 $PKGS/packages.equiv
pankso@1 889 else
pankso@1 890 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
pankso@1 891 fi
pankso@1 892 done
paul@197 893 # files.list provides a list of all packages files.
pankso@194 894 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
pankso@194 895 $PKGS/files.list
pankso@1 896 fi
pankso@1 897 done
pankso@155 898 cd $PKGS
pankso@213 899
pankso@213 900 # Display list size.
pankso@213 901 gettext "Done: packages.desc: "
pankso@213 902 echo $(du -sh $PKGS/packages.desc | awk '{print $1}')
pankso@213 903 gettext "Done: packages.txt: "
pankso@213 904 echo $(du -sh $PKGS/packages.txt | awk '{print $1}')
pankso@213 905 gettext "Done: packages.equiv: "
pankso@213 906 echo $(du -sh $PKGS/packages.equiv | awk '{print $1}')
pankso@155 907
pankso@194 908 # files.list.lzma
pankso@213 909 gettext "Creating: files.list.lzma: "
pankso@194 910 lzma e files.list files.list.lzma
pankso@194 911 rm -f files.list
pankso@213 912 echo $(du -sh $PKGS/files.list.lzma | awk '{print $1}')
pankso@148 913
pankso@1 914 separator
pankso@1 915 nb=$(ls $PKGS/*.tazpkg | wc -l)
pankso@133 916 echo -e "Packages: $nb\n"
pankso@133 917 rm -f $command ;;
pankso@1 918 *)
pankso@1 919 # Just cook and generate a package.
pankso@1 920 check_root
pankso@1 921 time=$(date +%s)
pankso@1 922 pkg="$1"
pankso@1 923 [ -z "$pkg" ] && usage
pankso@44 924 receipt="$WOK/$pkg/receipt"
pankso@1 925 check_pkg_in_wok && echo ""
pankso@47 926
pankso@128 927 # Display and log info if cook process stopped.
pankso@128 928 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
pankso@128 929 tee -a $LOGS/$pkg.log' INT
pankso@128 930
pankso@47 931 # Skip blocked, 3 lines also for the Cooker.
pankso@151 932 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
pankso@47 933 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
pankso@47 934 fi
pankso@47 935
pankso@47 936 # Log and source receipt.
pankso@56 937 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
pankso@16 938 echo "cook:$pkg" > $command
pankso@1 939 unset inst
pankso@1 940 unset_receipt
pankso@44 941 . $receipt
pankso@1 942
pankso@1 943 # Handle --options
pankso@1 944 case "$2" in
pankso@1 945 --clean|-c)
pankso@49 946 gettext -e "Cleaning:"; echo -n " $pkg"
pankso@1 947 cd $WOK/$pkg && rm -rf install taz source
pankso@1 948 status && echo "" && exit 0 ;;
pankso@1 949 --install|-i)
pankso@1 950 inst='yes' ;;
pankso@49 951 --getsrc|-gs)
pankso@49 952 gettext "Getting source for:"; echo " $pkg"
pankso@45 953 separator && get_source
pankso@39 954 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
pankso@49 955 --block|-b)
pankso@49 956 gettext "Blocking:"; echo -n " $pkg"
pankso@49 957 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
pankso@49 958 status && echo "" && exit 0 ;;
pankso@49 959 --unblock|-ub)
pankso@49 960 gettext "Unblocking:"; echo -n " $pkg"
pankso@49 961 sed -i "/^${pkg}$/"d $blocked
pankso@49 962 status && echo "" && exit 0 ;;
pankso@196 963
pankso@1 964 esac
pankso@1 965
paul@62 966 # Check if wanted is built now so we have separate log files.
pankso@1 967 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then
pankso@138 968 if ! grep -q "^$WANTED$" $broken; then
pankso@137 969 cook "$WANTED"
pankso@137 970 fi
pankso@1 971 fi
pankso@1 972
pankso@1 973 # Cook and pack or exit on error and log everything.
pankso@97 974 cookit $@ 2>&1 | tee $LOGS/$pkg.log
pankso@15 975 remove_deps | tee -a $LOGS/$pkg.log
pankso@1 976 cookit_quality
pankso@26 977 packit 2>&1 | tee -a $LOGS/$pkg.log
pankso@1 978 clean_log
pankso@33 979
pankso@33 980 # Exit if any error in packing.
pankso@33 981 if grep -q ^ERROR $LOGS/$pkg.log; then
pankso@33 982 debug_info | tee -a $LOGS/$pkg.log
pankso@33 983 rm -f $command && exit 1
pankso@33 984 fi
pankso@16 985
pankso@1 986 # Time and summary
pankso@1 987 time=$(($(date +%s) - $time))
pankso@1 988 summary | tee -a $LOGS/$pkg.log
pankso@50 989 echo ""
pankso@1 990
pankso@1 991 # Install package if requested
pankso@1 992 if [ "$inst" ]; then
pankso@1 993 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@1 994 cd $PKGS && tazpkg install \
pankso@1 995 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
pankso@1 996 else
paul@62 997 gettext -e "Unable to install package, build has failed.\n\n"
pankso@1 998 exit 1
pankso@1 999 fi
pankso@1 1000 fi
pankso@9 1001 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
pankso@17 1002 # You want automation: use the Cooker Build Bot.
pankso@1 1003 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
pankso@18 1004 rm -f $command ;;
pankso@1 1005 esac
pankso@1 1006
pankso@1 1007 exit 0