cookutils annotate cook @ rev 230

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