cookutils annotate cook @ rev 777

cooker: serialize requests (a bit)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 29 17:50:14 2015 +0100 (2015-11-29)
parents e177315d46eb
children d8daf2802972
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
paul@647 4 # before adding or modifying 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 #
al@728 9
pankso@422 10 . /usr/lib/slitaz/libcook.sh
pankso@1 11
pankso@633 12 VERSION="3.2"
al@596 13
al@728 14
al@596 15 # Internationalization.
al@596 16
al@728 17 export TEXTDOMAIN='cook'
al@728 18 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
al@728 19 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
al@728 20 _p() {
al@728 21 local S="$1" P="$2" N="$3"; shift; shift; shift;
al@728 22 printf "$(ngettext "$S" "$P" "$N")" "$@"; }
al@596 23
al@596 24
pankso@1 25 #
pankso@1 26 # Functions
pankso@1 27 #
pankso@1 28
pankso@1 29 usage() {
al@728 30 cat <<EOT
pankso@1 31
al@728 32 $(boldify "$(_ 'Usage:')") $(_ 'cook [package|command] [list|--option]')
pankso@1 33
al@728 34 $(boldify "$(_ 'Commands:')")
al@728 35 usage|help $(_ 'Display this short usage.')
al@728 36 setup $(_ 'Setup your build environment.')
al@728 37 *-setup $(_ 'Setup a cross environment.')
al@728 38 * = {arm|armv6hf|armv7|x86_64}
al@728 39 test $(_ 'Test environment and cook a package.')
al@728 40 list-wok $(_ 'List packages in the wok.')
al@728 41 search $(_ 'Simple packages search function.')
al@728 42 new $(_ 'Create a new package with a receipt.')
al@728 43 list $(_ 'Cook a list of packages.')
al@728 44 clean-wok $(_ 'Clean-up all packages files.')
al@728 45 clean-src $(_ 'Clean-up all packages sources.')
al@728 46 uncook $(_ 'Check for uncooked packages')
al@728 47 pkgdb $(_ 'Create packages DB lists and flavors.')
pankso@1 48
al@728 49 $(boldify "$(_ 'Options:')")
al@728 50 cook <pkg>
al@728 51 --clean -c $(_ 'clean the package in the wok.')
al@728 52 --install -i $(_ 'cook and install the package.')
al@728 53 --getsrc -gs $(_ 'get the package source tarball.')
al@728 54 --block -b $(_ 'block a package so cook will skip it.')
al@728 55 --unblock -ub $(_ 'unblock a blocked package.')
al@728 56 --cdeps $(_ 'check dependencies of cooked package.')
al@728 57 --pack $(_ 'repack an already built package.')
al@728 58 --debug $(_ 'display debugging messages.')
al@728 59 --continue $(_ 'continue running compile_rules.')
al@728 60 cook new <pkg>
al@728 61 --interactive -x $(_ 'create a receipt interactively.')
al@728 62 cook setup
al@728 63 --wok $(_ 'clone the cooking wok from Hg repo.')
al@728 64 --stable $(_ 'clone the stable wok from Hg repo.')
al@728 65 --undigest $(_ 'clone the undigest wok from Hg repo.')
al@728 66 --tiny $(_ 'clone the tiny SliTaz wok from Hg repo.')
al@728 67 --forced $(_ 'force reinstall of chroot packages.')
al@728 68 cook pkgdb
al@728 69 --flavors $(_ 'create up-to-date flavors files.')
pankso@1 70
pankso@1 71 EOT
pankso@1 72 exit 0
pankso@1 73 }
pankso@1 74
al@728 75
paul@62 76 # We don't want these escapes in web interface.
al@728 77
pankso@1 78 clean_log() {
pankso@1 79 sed -i -e s'|\[70G\[ \[1;32m| |' \
pankso@1 80 -e s'|\[0;39m \]||' $LOGS/$pkg.log
pankso@1 81 }
pankso@1 82
al@728 83
paul@62 84 # Be sure package exists in wok.
al@728 85
pankso@1 86 check_pkg_in_wok() {
pankso@1 87 if [ ! -d "$WOK/$pkg" ]; then
al@728 88 newline; _ 'Unable to find package "%s" in the wok' "$pkg"; newline
al@596 89 exit 1
pankso@1 90 fi
pankso@1 91 }
pankso@1 92
al@728 93
pankso@9 94 if_empty_value() {
pankso@9 95 if [ -z "$value" ]; then
al@596 96 # L10n: QA is quality assurance
al@728 97 _ 'QA: empty variable: %s' "$var=\"\""; newline
pankso@9 98 exit 1
pankso@9 99 fi
pankso@9 100 }
pankso@9 101
al@728 102
paul@62 103 # Initialize files used in $CACHE
al@728 104
pankso@52 105 init_db_files() {
al@728 106 _ 'Creating directories structure in "%s"' "$SLITAZ"
xfred222@559 107 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
al@728 108 _ 'Creating DB files in "%s"' "$CACHE"
al@728 109 for f in $activity $command $broken $blocked; do
pankso@52 110 touch $f
pankso@52 111 done
pankso@52 112 }
pankso@52 113
al@728 114
paul@62 115 # QA: check a receipt consistency before building.
al@728 116
pankso@9 117 receipt_quality() {
al@728 118 _ 'QA: checking package receipt...'
pankso@9 119 unset online
pankso@9 120 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
al@728 121 online='online'
pankso@9 122 fi
al@728 123 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do
pankso@9 124 unset value
al@728 125 value="$(. $receipt; eval echo \$$var)"
pankso@9 126 case "$var" in
pankso@9 127 PACKAGE|VERSION|SHORT_DESC)
pankso@9 128 if_empty_value ;;
pankso@9 129 CATEGORY)
al@728 130 value="${value:-empty}"
al@596 131 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
al@728 132 if ! echo " $valid " | grep -q " $value "; then
al@728 133 _ 'QA: unknown category "%s"' "$value"
al@728 134 longline "$(_ 'Please, use one of: %s' "$valid")"
al@728 135 newline
al@728 136 exit 1
pankso@9 137 fi ;;
pankso@9 138 WEB_SITE)
paul@62 139 # We don't check WGET_URL since if dl is needed it will fail.
paul@62 140 # Break also if we're not online. Here error is not fatal.
pankso@9 141 if_empty_value
al@728 142 [ -z "$online" ] && break
pankso@199 143 if ! busybox wget -T 12 -s $value 2>/dev/null; then
al@728 144 _ 'QA: unable to reach "%s"' "$value"
pankso@9 145 fi ;;
pankso@9 146 esac
pankso@9 147 done
pankso@9 148 }
pankso@9 149
al@728 150
paul@62 151 # Paths used in receipt and by cook itself.
al@728 152
pankso@1 153 set_paths() {
al@728 154 pkgdir="$WOK/$PACKAGE"
al@728 155 basesrc="$pkgdir/source"
al@728 156 tmpsrc="$basesrc/tmp"
al@728 157 src="$basesrc/$PACKAGE-$VERSION"
al@728 158 taz="$pkgdir/taz"
al@728 159 pack="$taz/$PACKAGE-$VERSION$EXTRAVERSION"
al@728 160 fs="$pack/fs"
al@728 161 stuff="$pkgdir/stuff"
al@728 162 install="$pkgdir/install"
slaxemulator@492 163 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
slaxemulator@492 164 lzma_tarball="$pkgsrc.tar.lzma"
al@728 165 if [ -n "$PATCH" ]; then
al@728 166 [ -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)"
slaxemulator@492 167 fi
al@728 168 if [ -n "$WANTED" ]; then
al@728 169 basesrc="$WOK/$WANTED/source"
al@728 170 src="$basesrc/$WANTED-$VERSION"
al@728 171 install="$WOK/$WANTED/install"
al@728 172 wanted_stuff="$WOK/$WANTED/stuff"
pankso@1 173 fi
al@728 174 if [ -n "$SOURCE" ]; then
al@728 175 source_stuff="$WOK/$SOURCE/stuff"
slaxemulator@456 176 fi
mojo@620 177 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
slaxemulator@492 178 if [ -f "$WOK/linux/receipt" ]; then
al@728 179 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d\" -f2)
slaxemulator@492 180 kbasevers=${kvers:0:3}
mojo@620 181 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
al@728 182 kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d\" -f2)
mojo@620 183 kbasevers=${kvers:0:3}
pankso@662 184 fi
pankso@662 185 # Python version
slaxemulator@492 186 if [ -f "$WOK/python/receipt" ]; then
al@728 187 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d\" -f2)
slaxemulator@492 188 fi
al@728 189 # Perl version for some packages needed it
slaxemulator@492 190 if [ -f "$WOK/perl/receipt" ]; then
al@728 191 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d\" -f2)
pankso@232 192 fi
pankso@9 193 # Old way compatibility.
al@728 194 _pkg="$install"
pankso@1 195 }
pankso@1 196
al@728 197
pankso@144 198 # Create source tarball when URL is a SCM.
al@728 199
pankso@144 200 create_tarball() {
slaxemulator@498 201 local tarball
al@728 202 tarball="$pkgsrc.tar.bz2"
al@728 203 [ -n "$LZMA_SRC" ] && tarball="$lzma_tarball"
al@728 204 _ 'Creating tarball "%s"' "$tarball"
al@728 205 if [ -n "$LZMA_SRC" ]; then
slaxemulator@498 206 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
al@728 207 LZMA_SRC=''
pankso@162 208 else
al@728 209 tar -cjf $tarball $pkgsrc || exit 1
al@728 210 mv $tarball $SRC; rm -rf $pkgsrc
pankso@162 211 fi
al@728 212 TARBALL="$tarball"
pankso@144 213 }
pankso@144 214
al@728 215
pankso@145 216 # Get package source. For SCM we are in cache so clone here and create a
pankso@145 217 # tarball here.
al@728 218
pankso@1 219 get_source() {
pascal@610 220 local url
pascal@610 221 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
ernia@571 222 set_paths
pankso@115 223 pwd=$(pwd)
pankso@9 224 case "$WGET_URL" in
pankso@145 225 http://*|ftp://*)
pankso@9 226 # Busybox Wget is better!
pascal@268 227 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
pascal@610 228 busybox wget -T 60 -c -O $SRC/$TARBALL $url || \
al@728 229 (_ 'ERROR: %s' "wget $WGET_URL" && exit 1) ;;
al@728 230
pankso@145 231 https://*)
pankso@250 232 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
pascal@610 233 busybox wget -T 60 -c -O $SRC/$TARBALL $url || \
al@728 234 (_ 'ERROR: %s' "wget $WGET_URL" && exit 1) ;;
al@728 235
pankso@9 236 hg*|mercurial*)
al@728 237 if $(echo "$WGET_URL" | fgrep -q 'hg|'); then
pankso@9 238 url=${WGET_URL#hg|}
pankso@9 239 else
pankso@9 240 url=${WGET_URL#mercurial|}
pankso@9 241 fi
al@728 242 _ 'Getting source from %s...' 'Hg'
al@728 243 _ 'URL: %s' "$url"
al@728 244 _ 'Cloning to "%s"' "$pwd/$pkgsrc"
al@728 245 if [ -n "$BRANCH" ]; then
al@728 246 _ 'Hg branch: %s' "$BRANCH"
pankso@246 247 hg clone $url --rev $BRANCH $pkgsrc || \
al@728 248 (_ 'ERROR: %s' "hg clone $url --rev $BRANCH" && exit 1)
pankso@246 249 else
al@728 250 hg clone $url $pkgsrc || (_ 'ERROR: %s' "hg clone $url" && exit 1)
pankso@246 251 fi
pankso@255 252 rm -rf $pkgsrc/.hg
pankso@144 253 create_tarball ;;
al@728 254
pankso@9 255 git*)
pankso@61 256 url=${WGET_URL#git|}
al@728 257 _ 'Getting source from %s...' 'Git'
al@728 258 _ 'URL: %s' "$url"
al@688 259 cd $SRC
al@728 260 git clone $url $pkgsrc || (_ 'ERROR: %s' "git clone $url" && exit 1)
al@728 261 if [ -n "$BRANCH" ]; then
al@728 262 _ 'Git branch: %s' "$BRANCH"
al@728 263 cd $pkgsrc; git checkout $BRANCH; cd ..
pankso@63 264 fi
al@688 265 cd $SRC
pankso@144 266 create_tarball ;;
al@728 267
pankso@144 268 cvs*)
pankso@144 269 url=${WGET_URL#cvs|}
pankso@144 270 mod=$PACKAGE
al@728 271 [ -n "$CVS_MODULE" ] && mod=$CVS_MODULE
al@728 272 _ 'Getting source from %s...' 'CVS'
al@728 273 _ 'URL: %s' "$url"
al@728 274 [ -n "$CVS_MODULE" ] && _ 'CVS module: %s' "$mod"
al@728 275 _ 'Cloning to "%s"' "$pwd/$mod"
pankso@144 276 cvs -d:$url co $mod && mv $mod $pkgsrc
pankso@144 277 create_tarball ;;
al@728 278
pankso@69 279 svn*|subversion*)
pankso@159 280 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
pankso@146 281 url=${WGET_URL#svn|}
pankso@146 282 else
pankso@146 283 url=${WGET_URL#subversion|}
pankso@146 284 fi
al@728 285 _ 'Getting source from %s...' 'SVN'
al@728 286 _ 'URL: %s' "$url"
al@728 287 if [ -n "$BRANCH" ]; then
pankso@161 288 echo t | svn co $url -r $BRANCH $pkgsrc
pankso@161 289 else
pankso@161 290 echo t | svn co $url $pkgsrc
pankso@161 291 fi
pankso@146 292 create_tarball ;;
al@728 293
al@590 294 bzr*)
al@590 295 url=${WGET_URL#bzr|}
al@728 296 _ 'Getting source from %s...' 'bazaar'
al@590 297 cd $SRC
al@590 298 pkgsrc=${url#*:}
al@728 299 if [ -n "$BRANCH" ]; then
al@590 300 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
al@590 301 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
al@590 302 else
al@590 303 echo "bzr -Ossl.cert_reqs=none branch $url"
al@590 304 bzr -Ossl.cert_reqs=none branch $url
al@728 305 cd $pkgsrc; BRANCH=$(bzr revno); cd ..
al@596 306 _ "Don't forget to add to receipt:"
al@728 307 echo -e "BRANCH=\"$BRANCH\"\n"
al@590 308 fi
al@590 309 mv $pkgsrc $pkgsrc-$BRANCH
al@728 310 pkgsrc="$pkgsrc-$BRANCH"
al@590 311 create_tarball ;;
al@728 312
pankso@9 313 *)
al@728 314 (newline; _ 'ERROR: Unable to handle "%s"' "$WGET_URL"; newline) | \
pankso@9 315 tee -a $LOGS/$PACKAGE.log
pankso@9 316 exit 1 ;;
pankso@9 317 esac
pankso@1 318 }
pankso@1 319
al@728 320
pankso@9 321 # Extract source package.
al@728 322
pankso@1 323 extract_source() {
pankso@177 324 if [ ! -s "$SRC/$TARBALL" ]; then
pankso@177 325 local url
slaxemulator@458 326 url="$MIRROR_URL/sources/packages"
al@728 327 url="$url/${TARBALL:0:1}/$TARBALL"
al@728 328 _ 'Getting source from %s...' 'mirror'
al@728 329 _ 'URL: %s' "$url"
al@728 330 busybox wget -c -P $SRC $url || _ 'ERROR: %s' "wget $url"
pankso@177 331 fi
al@728 332 _ 'Extracting source archive "%s"' "$TARBALL"
pankso@1 333 case "$TARBALL" in
al@728 334 *.tar.gz|*.tgz) tar -xzf $SRC/$TARBALL 2>/dev/null ;;
al@728 335 *.tar.bz2|*.tbz|*.tbz2) tar -xjf $SRC/$TARBALL 2>/dev/null ;;
al@728 336 *.tar.lzma) tar -xaf $SRC/$TARBALL ;;
al@728 337 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;;
al@728 338 *.tar) tar -xf $SRC/$TARBALL ;;
al@728 339 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
al@728 340 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \
al@728 341 tar -xf $SRC/$TARBALL 2>/dev/null;;
al@728 342 *.7z) 7zr x $SRC/$TARBALL ;;
al@728 343 *.Z|*.z) uncompress -c $SRC/$TARBALL | tar -xf - ;;
al@728 344 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
al@728 345 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
al@728 346 *) cp $SRC/$TARBALL $(pwd) ;;
pankso@1 347 esac
pankso@1 348 }
pankso@1 349
al@728 350
pankso@9 351 # Display cooked package summary.
al@728 352
pankso@1 353 summary() {
pankso@1 354 cd $WOK/$pkg
slaxemulator@499 355 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
slaxemulator@499 356 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
slaxemulator@499 357 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}')
pankso@44 358 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
slaxemulator@499 359 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
al@728 360 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
al@728 361
al@728 362 sec="$time"
pascal@280 363 div=$(( ($time + 30) / 60))
al@728 364 case $div in
al@728 365 0) min='';;
al@728 366 # L10n: 'm' is for minutes (approximate cooking time)
al@728 367 *) min=$(_n '~ %dm' "$div");;
al@728 368 esac
al@728 369
al@728 370 _ 'Summary for: %s' "$PACKAGE $VERSION"
pankso@1 371 separator
al@728 372
al@596 373 # L10n: keep the same width of translations to get a consistent view
al@728 374 [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir"
al@728 375 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL"
al@728 376 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize"
al@728 377 [ -n "$prod" ] && _ 'Produced : %s' "$prod"
al@728 378 _ 'Packed : %s' "$fs"
al@728 379 _ 'Compressed : %s' "$size"
al@728 380 _ 'Files : %s' "$files"
al@596 381 # L10n: 's' is for seconds (cooking time)
al@728 382 _ 'Cook time : %ds %s' "$sec" "$min"
al@728 383 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")"
al@728 384 _ 'Host arch : %s' "$ARCH"
al@596 385 separator
pankso@1 386 }
pankso@1 387
al@728 388
paul@62 389 # Display debugging error info.
al@728 390
pankso@15 391 debug_info() {
al@728 392 newline; _ 'Debug information'; separator
al@596 393 # L10n: specify your format of date and time (to help: man date)
al@596 394 # L10n: not bad one is '+%x %R'
al@728 395 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
pascal@757 396 [ "$time" ] && _ 'Cook time: %ds' "$(($(date +%s) - $time))"
al@596 397 # L10n: Please, translate all messages beginning with ERROR in a same way
al@728 398 lerror=$(_n 'ERROR')
pankso@76 399 for error in \
al@728 400 ERROR $lerror 'No package' "cp: can't" "can't open" "can't cd" \
al@728 401 'error:' 'fatal error:' 'undefined reference to' \
al@728 402 'Unable to connect to' 'link: cannot find the library' \
al@728 403 'CMake Error' ': No such file or directory'
pankso@34 404 do
pankso@34 405 fgrep "$error" $LOGS/$pkg.log
pascal@625 406 done > $LOGS/$pkg.log.debug_info 2>&1
pascal@625 407 cat $LOGS/$pkg.log.debug_info
pascal@625 408 rm -f $LOGS/$pkg.log.debug_info
al@596 409 separator; newline
pankso@15 410 }
pankso@15 411
al@728 412
pankso@1 413 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@1 414 # so some packages need to copy these files with the receipt and genpkg_rules.
al@728 415
al@728 416 copy_generic_files() {
pankso@1 417 # $LOCALE is set in cook.conf
al@728 418 if [ -n "$LOCALE" -a -z "$WANTED" ]; then
pankso@260 419 if [ -d "$install/usr/share/locale" ]; then
pankso@1 420 mkdir -p $fs/usr/share/locale
al@728 421 for i in $LOCALE; do
pankso@260 422 if [ -d "$install/usr/share/locale/$i" ]; then
pankso@260 423 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
pankso@1 424 fi
pankso@1 425 done
pankso@1 426 fi
pankso@1 427 fi
pankso@1 428
pankso@1 429 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
al@728 430 if [ "$GENERIC_PIXMAPS" != 'no' ]; then
pankso@260 431 if [ -d "$install/usr/share/pixmaps" ]; then
pankso@1 432 mkdir -p $fs/usr/share/pixmaps
slaxemulator@500 433 if [ -f "$install/usr/share/pixmaps/$PACKAGE.png" ]; then
slaxemulator@500 434 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
slaxemulator@500 435 $fs/usr/share/pixmaps
slaxemulator@500 436 elif [ -f "$install/usr/share/pixmaps/$PACKAGE.xpm" ]; then
slaxemulator@500 437 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
slaxemulator@500 438 $fs/usr/share/pixmaps
slaxemulator@500 439 fi
pankso@1 440 fi
pankso@1 441
pankso@1 442 # Custom or homemade PNG pixmap can be in stuff.
pankso@1 443 if [ -f "$stuff/$PACKAGE.png" ]; then
pankso@1 444 mkdir -p $fs/usr/share/pixmaps
pankso@1 445 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@1 446 fi
pankso@1 447 fi
pankso@1 448
pankso@1 449 # Desktop entry (.desktop).
erjo@284 450 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
al@728 451 if [ "$GENERIC_MENUS" != 'no' ]; then
al@728 452 if [ -d "$install/usr/share/applications" ] && [ -z "$WANTED" ]; then
slaxemulator@500 453 mkdir -p $fs/usr/share
erjo@284 454 cp -a $install/usr/share/applications $fs/usr/share
erjo@284 455 fi
pankso@1 456 fi
pankso@1 457
pankso@1 458 # Homemade desktop file(s) can be in stuff.
pankso@1 459 if [ -d "$stuff/applications" ]; then
pankso@1 460 mkdir -p $fs/usr/share
pankso@1 461 cp -a $stuff/applications $fs/usr/share
pankso@1 462 fi
pankso@1 463 if [ -f "$stuff/$PACKAGE.desktop" ]; then
pankso@1 464 mkdir -p $fs/usr/share/applications
pankso@1 465 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@1 466 fi
pankso@662 467
slaxemulator@500 468 # Add custom licenses
slaxemulator@500 469 if [ -d "$stuff/licenses" ]; then
slaxemulator@500 470 mkdir -p $fs/usr/share/licenses
slaxemulator@500 471 cp -a $stuff/licenses $fs/usr/share/licenses/$PACKAGE
slaxemulator@500 472 fi
pankso@1 473 }
pankso@1 474
al@728 475
al@769 476 # Fix common errors and warnings in the .desktop files
al@769 477
al@769 478 fix_desktop_files() {
al@769 479 [ -d "$install/usr/share/applications" ] || return
al@769 480
al@769 481 if [ -n "$QA" -a -z "$(which desktop-file-validate)" ]; then
al@769 482 _n 'Installing dep (web/cache): %s' 'desktop-file-utils-extra'
al@769 483 tazpkg -gi desktop-file-utils-extra >/dev/null
al@769 484 status
al@769 485 fi
al@769 486
al@769 487 for desktop in $(find $install/usr/share/applications -name '*.desktop'); do
al@770 488 cp "$desktop" "$desktop.orig"
al@770 489
al@769 490 # Sort out .desktop file (is prerequisite to correct working of `fix-desktop-file`)
al@769 491 sdft "$desktop" -i
al@769 492
al@769 493 # Fix common errors in .desktop file
al@769 494 fix-desktop-file "$desktop"
al@769 495
al@769 496 if [ -n "$QA" ]; then
al@769 497 # Check the rest of errors, warnings and tips
al@769 498 _ 'QA: Checking %s...' "$(basename $desktop)"
al@769 499 diff "$desktop.orig" "$desktop"
al@769 500 desktop-file-validate "$desktop"
al@769 501 echo
al@769 502 fi
al@769 503
al@769 504 rm "$desktop.orig"
al@769 505 done
al@769 506 }
al@769 507
al@769 508
al@596 509 # Find and strip: --strip-all (-s) or --strip-debug on static libs as well
paul@647 510 # as removing unneeded files like in Python packages. Cross compiled binaries
pankso@415 511 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
al@728 512
pankso@421 513 strip_package() {
pankso@415 514 case "$ARCH" in
al@737 515 arm*|x86_64) export STRIP="$HOST_SYSTEM-strip" ;;
al@728 516 *) export STRIP='strip' ;;
pankso@415 517 esac
al@728 518 _n 'Executing strip on all files...'
al@728 519 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games; do
pankso@1 520 if [ -d "$dir" ]; then
pankso@414 521 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
pankso@1 522 fi
pankso@1 523 done
al@728 524 find $fs -name '*.so*' -exec $STRIP -s '{}' 2>/dev/null \;
al@728 525 find $fs -name '*.a' -exec $STRIP --strip-debug '{}' 2>/dev/null \;
pankso@1 526 status
pankso@67 527
pankso@117 528 # Remove Python .pyc and .pyo from packages.
al@739 529 #_n 'Removing Python compiled files...'
al@739 530 find $fs -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete 2>/dev/null
al@739 531 #status
pankso@117 532
pankso@117 533 # Remove Perl perllocal.pod and .packlist from packages.
al@739 534 #_n 'Removing Perl compiled files...'
al@739 535 find $fs -type f \( -name 'perllocal.pod' -o -name '.packlist' \) -delete 2>/dev/null
al@739 536 #status
pankso@1 537 }
pankso@1 538
al@728 539
al@769 540 # Update installed.cook.diff
al@769 541
al@769 542 update_installed_cook_diff() {
al@769 543 # If a cook failed deps are removed.
al@769 544 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
al@769 545 cd $CACHE
al@769 546 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
al@769 547 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
al@769 548 deps=$(cat /tmp/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
al@769 549 }
al@769 550
al@769 551
pankso@8 552 # Remove installed deps.
al@728 553
pankso@8 554 remove_deps() {
pankso@8 555 # Now remove installed build deps.
al@728 556 diff='/tmp/installed.cook.diff'
pascal@609 557 if [ -s $diff ]; then
pankso@113 558 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
pankso@113 559 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
al@728 560 _n 'Build dependencies to remove:'; echo " $nb"
al@728 561 [ -n "$root" ] && echo "root=\"$root\""
al@728 562 _n 'Removing:'
al@728 563 for dep in $deps; do
pankso@8 564 echo -n " $dep"
pankso@426 565 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
pankso@8 566 done
al@596 567 newline; newline
pankso@113 568 # Keep the last diff for debug and info.
pascal@609 569 mv -f $diff $CACHE/installed.diff
pankso@1 570 fi
pankso@1 571 }
pankso@1 572
al@728 573
pankso@1 574 # The main cook function.
al@728 575
pankso@1 576 cookit() {
al@728 577 _ 'Cook: %s' "$PACKAGE $VERSION"; separator
pankso@1 578 set_paths
pankso@359 579
pankso@377 580 # Handle cross-tools.
pankso@359 581 case "$ARCH" in
pankso@675 582 arm*|x86_64)
paul@387 583 # CROSS_COMPILE is used by at least Busybox and the kernel to set
al@596 584 # the cross-tools prefix. Sysroot is the root of our target arch
al@728 585 sysroot="$CROSS_TREE/sysroot"
al@728 586 tools="$CROSS_TREE/tools"
pankso@443 587 # Set root path when cross compiling. ARM tested but not x86_64
pankso@443 588 # When cross compiling we must install build deps in $sysroot.
al@737 589 arch="-$ARCH"
al@728 590 root="$sysroot"
al@728 591 _ '%s sysroot: %s' "$ARCH" "$sysroot"
al@728 592 _ 'Adding "%s" to PATH' "$tools/bin"
al@728 593 export PATH="$PATH:$tools/bin"
al@728 594 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
al@737 595 export CROSS_COMPILE="$HOST_SYSTEM-"
al@728 596 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
al@728 597 if [ "$ARCH" == 'x86_64' ]; then
al@737 598 export CC="$HOST_SYSTEM-gcc -m64"
al@737 599 export CXX="$HOST_SYSTEM-g++ -m64"
pankso@438 600 else
al@737 601 export CC="$HOST_SYSTEM-gcc"
al@737 602 export CXX="$HOST_SYSTEM-g++"
pankso@438 603 fi
al@737 604 export AR="$HOST_SYSTEM-ar"
al@737 605 export AS="$HOST_SYSTEM-as"
al@737 606 export RANLIB="$HOST_SYSTEM-ranlib"
al@737 607 export LD="$HOST_SYSTEM-ld"
al@737 608 export STRIP="$HOST_SYSTEM-strip"
al@737 609 export LIBTOOL="$HOST_SYSTEM-libtool" ;;
pankso@359 610 esac
pankso@359 611
al@728 612 [ -n "$QA" ] && receipt_quality
pankso@44 613 cd $pkgdir
al@728 614 [ -z "$continue" ] && rm -rf source 2>/dev/null
al@728 615 rm -rf install taz 2>/dev/null
pankso@1 616
pankso@1 617 # Disable -pipe if less than 512Mb free RAM.
al@728 618 free=$(free | awk '/buffers:/{print $4}')
pankso@1 619 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
al@728 620 _ 'Disabling -pipe compile flag: %d RAM free' "$free"
al@728 621 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
al@728 622 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
pankso@1 623 fi
pankso@1 624 unset free
pankso@1 625
pankso@232 626 # Export flags and path to be used by make and receipt.
al@728 627 DESTDIR="$pkgdir/install"
al@596 628 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
pankso@232 629 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
pankso@358 630 #LDFLAGS
pankso@1 631
pankso@126 632 # Check for build deps and handle implicit depends of *-dev packages
pankso@126 633 # (ex: libusb-dev :: libusb).
pankso@215 634 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
pankso@215 635 touch $CACHE/installed.local $CACHE/installed.web
al@728 636 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
al@728 637 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
al@728 638 for dep in $BUILD_DEPENDS; do
al@728 639 implicit="${dep%-dev}"
al@728 640 for i in $dep $implicit; do
al@737 641 if [ ! -f "$root$INSTALLED/$i/receipt" ]; then
paul@174 642 # Try local package first. In some cases implicit doesn't exist, ex:
paul@174 643 # libboost-dev exists but not libboost, so check if we got vers.
pankso@173 644 unset vers
pascal@343 645 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
pankso@435 646 # We may have a local package.
al@728 647 if [ -z "$vers" ]; then
al@728 648 vers=$(awk -F$'\t' -vp="$i" '$1==p{print $2; quit}' $PKGS/packages.info)
pankso@435 649 fi
pankso@435 650 debug "bdep: $i version: $vers"
al@728 651 if [ -f "$PKGS/$i-$vers$arch.tazpkg" ]; then
al@728 652 echo $i-$vers$arch.tazpkg >> $CACHE/installed.local
pankso@126 653 else
paul@227 654 # Priority to package version in wok (maybe more up-to-date)
paul@227 655 # than the mirrored one.
al@728 656 if [ -n "$vers" ]; then
al@728 657 if fgrep -q $i-$vers$arch $root$DB/packages.list; then
pankso@215 658 echo $i >> $CACHE/installed.web
pankso@198 659 else
paul@211 660 # So package exists in wok but not available.
al@728 661 _ 'Missing dep (wok/pkg): %s' "$i $vers"
pankso@215 662 echo $i >> $CACHE/missing.dep
pankso@198 663 fi
pankso@225 664 else
pankso@435 665 # Package is not in wok but may be in online repo.
al@737 666 if fgrep -q $i-$vers$arch $root$DB/packages.list; then
pankso@225 667 echo $i >> $CACHE/installed.web
pankso@225 668 else
al@728 669 _ 'ERROR: unknown dep "%s"' "$i"
al@728 670 exit 1
pankso@225 671 fi
pankso@173 672 fi
pankso@126 673 fi
pankso@1 674 fi
pankso@126 675 done
pankso@1 676 done
pankso@225 677
pankso@215 678 # Get the list of installed packages
al@728 679 cd $root$INSTALLED; ls -1 > $CACHE/installed.list
pankso@358 680
al@596 681 # Have we a missing build dep to cook?
al@728 682 if [ -s "$CACHE/missing.dep" ] && [ -n "$AUTO_COOK" ]; then
al@728 683 _ 'Auto cook config is set: %s' "$AUTO_COOK"
pankso@204 684 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
al@728 685 for i in $(uniq $CACHE/missing.dep); do
al@728 686 (_ 'Building dep (wok/pkg) : %s' "$i $vers") | \
pankso@204 687 tee -a $LOGS/$PACKAGE.log.$$
al@596 688 # programmers: next two messages are exact copy from remove_deps()
al@728 689 togrep1=$(_n 'Build dependencies to remove:')
al@728 690 togrep2=$(_n 'Removing:')
al@728 691 cook $i || (_ "ERROR: can't cook dep \"%s\"" "$i" && newline && \
al@596 692 fgrep $togrep1 $LOGS/$i.log && \
al@596 693 fgrep $togrep2 $LOGS/$i.log && newline) | \
pankso@204 694 tee -a $LOGS/$PACKAGE.log.$$ && break
pankso@204 695 done
pankso@215 696 rm -f $CACHE/missing.dep
pankso@204 697 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
pankso@204 698 fi
pankso@358 699
paul@211 700 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
paul@211 701 # is enabled and cook fails we have ERROR in log, if no auto cook we have
pankso@204 702 # missing dep in cached file.
al@728 703 lerror=$(_n 'ERROR')
pascal@613 704 if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
pankso@215 705 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
al@728 706 _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb"
al@728 707 exit 1
pankso@202 708 fi
pankso@358 709
al@737 710 # Install local packages: package-version$arch
pankso@215 711 cd $PKGS
al@728 712 for i in $(uniq $CACHE/installed.local); do
al@728 713 _ 'Installing dep (pkg/local): %s' "$i"
al@775 714 tazpkg install $i --root=$root >/dev/null 2>/dev/null
pankso@215 715 done
pankso@358 716
pankso@215 717 # Install web or cached packages (if mirror is set to $PKGS we only
pankso@215 718 # use local packages).
al@728 719 for i in $(uniq $CACHE/installed.web); do
al@728 720 _ 'Installing dep (web/cache): %s' "$i"
al@775 721 tazpkg get-install $i --root=$root >/dev/null 2>/dev/null
pankso@215 722 done
pankso@358 723
al@769 724 update_installed_cook_diff
pankso@202 725
pankso@1 726 # Get source tarball and make sure we have source dir named:
paul@62 727 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
paul@62 728 # tarball if it exists.
al@728 729 if [ -n "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
pankso@1 730 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
al@728 731 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
al@728 732 LZMA_SRC=''
pankso@1 733 else
pankso@1 734 get_source || exit 1
pankso@1 735 fi
pankso@1 736 fi
al@728 737 if [ -z "$WANTED" ] && [ -n "$TARBALL" ] && [ ! -d "$src" ]; then
al@728 738 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
pascal@268 739 if ! extract_source ; then
pascal@268 740 get_source
pascal@268 741 extract_source || exit 1
pascal@268 742 fi
al@728 743 if [ -n "$LZMA_SRC" ]; then
pankso@190 744 cd $pkgdir/source
pankso@190 745 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
al@728 746 mv tmp tmp-1; mkdir tmp
pankso@190 747 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
pankso@190 748 fi
pankso@190 749 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
al@728 750 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
pankso@190 751 fi
pankso@190 752 fi
pankso@190 753 cd $pkgdir/source/tmp
paul@62 754 # Some archives are not well done and don't extract to one dir (ex lzma).
pankso@57 755 files=$(ls | wc -l)
pankso@244 756 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
pankso@244 757 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
pankso@244 758 mv * ../$PACKAGE-$VERSION/$TARBALL
al@728 759 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
pankso@57 760 mv * ../$PACKAGE-$VERSION
al@728 761 cd ..; rm -rf tmp
pankso@1 762 fi
pankso@662 763
pankso@658 764 # Libtool shared libs path hack.
pankso@658 765 case "$ARCH" in
pankso@658 766 arm*) cross libhack ;;
pankso@658 767 esac
pankso@1 768
pankso@9 769 # Execute receipt rules.
pankso@44 770 if grep -q ^compile_rules $receipt; then
al@728 771 _ 'Executing: %s' 'compile_rules'
pankso@352 772 echo "CFLAGS : $CFLAGS"
pankso@358 773 #echo "LDFLAGS : $LDFLAGS"
pankso@55 774 [ -d "$src" ] && cd $src
pankso@97 775 compile_rules $@ || exit 1
pankso@10 776 # Stay compatible with _pkg
pankso@55 777 [ -d "$src/_pkg" ] && mv $src/_pkg $install
pankso@9 778 # QA: compile_rules success so valid.
pankso@9 779 mkdir -p $install
pankso@9 780 else
al@596 781 # QA: no compile_rules so no error, valid.
pankso@9 782 mkdir -p $install
pankso@1 783 fi
al@596 784 separator; newline
pankso@360 785
pankso@360 786 # Execute testsuite.
pankso@360 787 if grep -q ^testsuite $receipt; then
al@728 788 _ 'Running testsuite'; separator
pankso@360 789 testsuite $@ || exit 1
al@596 790 separator; newline
pankso@360 791 fi
al@769 792
al@769 793 fix_desktop_files
al@769 794 update_installed_cook_diff force
pankso@1 795 }
pankso@1 796
al@728 797
pankso@1 798 # Cook quality assurance.
al@728 799
pankso@1 800 cookit_quality() {
al@728 801 if [ ! -d "$WOK/$pkg/install" ] && [ -z "$WANTED" ]; then
al@728 802 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
pankso@9 803 fi
pankso@9 804 # ERROR can be echoed any time in cookit()
al@728 805 lerror=$(_n 'ERROR')
pascal@618 806 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
pascal@618 807 grep -Eq "(^$lerror|undefined reference to)" ; then
pankso@17 808 debug_info | tee -a $LOGS/$pkg.log
al@728 809 rm -f $command
al@728 810 exit 1
pankso@1 811 fi
pankso@1 812 }
pankso@1 813
al@728 814
al@728 815 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
paul@62 816 # but it doesn't handle EXTRAVERSION.
al@728 817
pankso@1 818 packit() {
pankso@1 819 set_paths
pankso@359 820
pankso@359 821 # Handle cross compilation
pankso@359 822 case "$ARCH" in
pankso@676 823 arm*|x86_64) arch="-$ARCH" ;;
pankso@359 824 esac
pankso@359 825
al@728 826 _ 'Pack: %s' "$PACKAGE $VERSION$arch"; separator
pankso@359 827
pankso@44 828 if grep -q ^genpkg_rules $receipt; then
al@728 829 _ 'Executing: %s' 'genpkg_rules'
al@728 830 set -e; cd $pkgdir; mkdir -p $fs
al@728 831 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
pankso@234 832 $LOGS/$pkg.log
pankso@241 833 else
al@728 834 _ 'No packages rules: meta package'
pankso@241 835 mkdir -p $fs
pankso@16 836 fi
pankso@98 837
pankso@98 838 # First QA check to stop now if genpkg_rules failed.
al@728 839 lerror=$(_n 'ERROR')
pascal@613 840 if fgrep -q ^$lerror $LOGS/$pkg.log; then
pankso@98 841 exit 1
pankso@98 842 fi
pankso@358 843
pankso@44 844 cd $taz
al@728 845 for file in receipt description.txt; do
pankso@1 846 [ ! -f "../$file" ] && continue
al@728 847 _n 'Copying "%s"...' "$file"
al@728 848 cp -f ../$file $pack; chown 0.0 $pack/$file; status
pankso@1 849 done
pankso@119 850 copy_generic_files
pankso@358 851
pankso@119 852 # Strip and stuff files.
pankso@43 853 strip_package
pankso@43 854
al@728 855 # Create files.list with redirecting find output.
al@728 856 _n 'Creating the list of files...'
al@728 857 cd $fs
al@728 858 find . -type f -print > ../files.list
al@728 859 find . -type l -print >> ../files.list
al@728 860 cd ..; sed -i s/'^.'/''/ files.list
al@728 861 status
al@728 862
pankso@43 863 # Md5sum of files.
al@728 864 _n 'Creating md5sum of files...'
pankso@16 865 while read file; do
pankso@16 866 [ -L "fs$file" ] && continue
pankso@16 867 [ -f "fs$file" ] || continue
pankso@16 868 case "$file" in
pankso@232 869 /lib/modules/*/modules.*|*.pyc) continue ;;
pankso@16 870 esac
pankso@16 871 md5sum "fs$file" | sed 's/ fs/ /'
pankso@16 872 done < files.list > md5sum
pankso@16 873 status
al@728 874
al@728 875 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
al@728 876 2>/dev/null | awk 'END{ print $1 }')
pankso@358 877
pankso@16 878 # Build cpio archives.
al@728 879 _n 'Compressing the FS...'
pankso@16 880 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pankso@16 881 rm -rf fs
pankso@16 882 status
al@728 883
al@728 884 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
al@728 885 2>/dev/null | awk 'END{ print $1 }')
al@728 886
al@728 887 _n 'Updating receipt sizes...'
pankso@16 888 sed -i s/^PACKED_SIZE.*$// receipt
pankso@16 889 sed -i s/^UNPACKED_SIZE.*$// receipt
pankso@16 890 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pankso@16 891 status
pankso@16 892
pankso@16 893 # Set extra version.
al@728 894 if [ -n "$EXTRAVERSION" ]; then
al@728 895 _n 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
pankso@16 896 sed -i s/^EXTRAVERSION.*$// receipt
pankso@16 897 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
pankso@16 898 status
pankso@16 899 fi
pankso@16 900
pankso@16 901 # Compress.
al@728 902 _n 'Creating full cpio archive...'
pankso@16 903 find . -print | cpio -o -H newc --quiet > \
al@737 904 ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
pankso@16 905 status
al@728 906
al@728 907 _n 'Restoring original package tree...'
pankso@16 908 unlzma -c fs.cpio.lzma | cpio -idm --quiet
pankso@16 909 status
al@728 910
al@728 911 rm fs.cpio.lzma; cd ..
pankso@43 912
pankso@43 913 # QA and give info.
pankso@43 914 tazpkg=$(ls *.tazpkg)
pankso@43 915 packit_quality
al@728 916 separator; _ 'Package "%s" created' "$tazpkg"; newline
pankso@1 917 }
pankso@1 918
al@728 919
paul@62 920 # Verify package quality and consistency.
al@728 921
pankso@8 922 packit_quality() {
al@596 923 #gettext "QA: checking for broken link..."
pankso@157 924 #link=$(find $fs/usr -type l -follow)
pankso@157 925 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
pankso@157 926 #status
pankso@358 927
pankso@142 928 # Exit if any error found in log file.
al@728 929 lerror=$(_n 'ERROR')
pascal@613 930 if fgrep -q ^$lerror $LOGS/$pkg.log; then
al@728 931 rm -f $command
al@728 932 exit 1
pankso@8 933 fi
pankso@358 934
al@728 935 _n 'QA: checking for empty package...'
pankso@45 936 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
al@728 937 if [ "$files" == 0 ] && [ "$CATEGORY" != 'meta' ]; then
al@728 938 newline; _ 'ERROR: empty package'
al@728 939 rm -f $command
al@728 940 exit 1
pankso@8 941 else
pankso@134 942 # Ls sort by name so the first file is the one we want.
al@728 943 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n1)
pankso@134 944 status
pankso@154 945 if [ -f "$old" ]; then
al@728 946 _n 'Removing old package "%s"' "$(basename $old)"
al@728 947 rm -f $old; status
pankso@154 948 fi
pankso@134 949 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
pankso@11 950 sed -i /^${pkg}$/d $broken
pankso@265 951 #gettext "Removing source tree..."
pankso@265 952 #rm -f $WOK/$pkg/source && status
pankso@8 953 fi
pankso@8 954 }
pankso@8 955
al@728 956
al@728 957 # Reverse "cat" command: prints input lines in the reverse order
al@728 958
pankso@421 959 tac() {
pascal@285 960 sed '1!G;h;$!d' $1
pascal@285 961 }
pascal@285 962
al@728 963
pankso@428 964 # Install package on --install or update the chroot.
al@728 965
pankso@428 966 install_package() {
pankso@428 967 case "$ARCH" in
pankso@676 968 arm*|x86_64)
al@737 969 arch="-$ARCH"
al@728 970 root="$CROSS_TREE/sysroot" ;;
pankso@428 971 esac
pankso@428 972 # Install package if requested but skip install if target host doesn't
pankso@428 973 # match build system or it will break the build chroot.
al@728 974 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
al@728 975 if [ -n "$inst" ] && [ "$build" == "$ARCH" ]; then
al@737 976 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
al@728 977 cd $PKGS
al@728 978 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
pankso@428 979 else
al@728 980 _ 'Unable to install package, build has failed.'; newline
pankso@428 981 exit 1
pankso@428 982 fi
pankso@428 983 fi
pankso@428 984
pankso@428 985 # Install package if part of the chroot to keep env up-to-date.
al@728 986 if [ -d "$root$INSTALLED/$pkg" ]; then
pankso@428 987 . /etc/slitaz/cook.conf
pankso@428 988 . $WOK/$pkg/taz/$pkg-*/receipt
al@728 989 _ 'Updating %s chroot environment...' "$ARCH"
al@728 990 _ 'Updating chroot: %s' "$pkg ($VERSION$EXTRAVERSION$arch)" | log
al@728 991 cd $PKGS
al@728 992 tazpkg install $pkg-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
pankso@428 993 fi
pankso@428 994 }
pankso@428 995
al@728 996
pascal@696 997 # remove chroot jail
al@728 998
pascal@696 999 umount_aufs() {
pascal@696 1000 tac ${1}rw/aufs-umount.sh | sh
pascal@696 1001 rm -rf ${1}rw
pascal@696 1002 umount ${1}root
pascal@697 1003 rmdir ${1}r*
pascal@696 1004 }
pascal@696 1005
al@728 1006
pascal@285 1007 # Launch the cook command into a chroot jail protected by aufs.
pascal@285 1008 # The current filesystems are used read-only and updates are
pascal@285 1009 # stored in a separate branch.
al@728 1010
pascal@285 1011 try_aufs_chroot() {
pascal@285 1012
al@728 1013 base="/dev/shm/aufsmnt$$"
pascal@286 1014
al@596 1015 # Can we setup the chroot? Is it already done?
pascal@292 1016 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
al@728 1017 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
pascal@285 1018 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
pascal@285 1019 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
pascal@286 1020 mkdir ${base}root ${base}rw || return
pascal@285 1021
al@728 1022 _ 'Setup aufs chroot...'
pascal@285 1023
pascal@285 1024 # Sanity check
pascal@286 1025 for i in / /proc /sys /dev/shm /home ; do
pascal@285 1026 case " $AUFS_MOUNTS " in
pascal@285 1027 *\ $i\ *) ;;
pascal@285 1028 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
pascal@285 1029 esac
pascal@285 1030 done
pascal@691 1031 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
pascal@285 1032 mount --bind $mnt ${base}root$mnt
pascal@285 1033 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
al@728 1034 _ 'Aufs mount failure'
slaxemulator@519 1035 umount ${base}root
pascal@628 1036 rm -rf ${base}r*
slaxemulator@519 1037 return
pascal@285 1038 fi
pascal@285 1039 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
pascal@285 1040 done
pascal@696 1041 trap "umount_aufs ${base}" INT
pascal@285 1042
pascal@285 1043 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
pascal@285 1044 status=$?
pascal@285 1045
al@728 1046 _ 'Leaving aufs chroot...'
al@737 1047 umount_aufs $base
pascal@683 1048 # Install package outside the aufs jail
pascal@683 1049 install_package
pankso@358 1050 exit $status
pascal@285 1051 }
pascal@285 1052
al@728 1053
al@705 1054 # Encode predefined XML entities
al@728 1055
al@705 1056 xml_ent() {
al@705 1057 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
al@705 1058 }
al@705 1059
al@728 1060
paul@387 1061 # Create a XML feed for freshly built packages.
al@728 1062
pankso@310 1063 gen_rss() {
al@728 1064 pubdate=$(date '+%a, %d %b %Y %X')
al@728 1065 cat > $FEEDS/$pkg.xml <<EOT
pankso@310 1066 <item>
al@737 1067 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
pankso@310 1068 <link>${COOKER_URL}?pkg=$PACKAGE</link>
al@737 1069 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
pankso@310 1070 <pubDate>$pubdate</pubDate>
al@705 1071 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
pankso@310 1072 </item>
pankso@310 1073 EOT
pankso@310 1074 }
pankso@310 1075
al@728 1076
pankso@662 1077 # Truncate stdout log file to $1 Mb.
al@728 1078
al@728 1079 loglimit() {
pascal@593 1080 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
pascal@621 1081 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
pascal@593 1082 else
pascal@593 1083 tee /dev/stderr
pascal@593 1084 fi
pascal@576 1085 }
pascal@576 1086
al@728 1087
al@598 1088 # Search file in mirrored packages
al@728 1089
al@728 1090 search_file_mirror() {
al@598 1091 busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u
al@598 1092 }
al@598 1093
al@728 1094
al@598 1095 # Search file in local wok packages
al@728 1096
al@728 1097 search_file_local() {
al@598 1098 # existing packages have precedence over the package/taz folder
al@598 1099 srch=$1
al@598 1100 { for package in $(find $PKGS -name '*.tazpkg'); do
al@728 1101 if [ -n "$(busybox cpio --to-stdout --quiet -i files.list < $package | \
al@728 1102 grep /$srch\$)" ]; then
al@598 1103 busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2
al@598 1104 fi
al@598 1105 done } | sort -u
al@598 1106 }
al@598 1107
al@728 1108
al@598 1109 # Ask in multiple choice
al@728 1110
al@728 1111 ask_multiple() {
al@598 1112 local multiples first my_choice
al@598 1113 multiples="$1"
al@598 1114 first=$(echo "$multiples" | head -n1)
al@728 1115 newline; _ 'Multiple choice:'; echo "$multiples"; newline
al@728 1116 _ 'Select one [%s]: ' "$first"; read my_choice
al@728 1117 found="${my_choice:-$first}"
al@598 1118 }
al@598 1119
al@728 1120
al@598 1121 # Search file in local cache (fast), local wok packages, mirrored packages
al@728 1122
al@728 1123 search_file() {
al@598 1124 local srch cache missing
al@728 1125 srch="$1"
al@728 1126 cache='/var/cache/ldsearch.cache'
al@728 1127 missing='/var/cache/missing.file'
al@598 1128 touch $cache $missing
al@728 1129 found=$(grep $srch $cache | cut -d$'\t' -f2)
al@728 1130 if [ -z "$found" ]; then
al@598 1131 found=$(search_file_local $srch)
al@728 1132 if [ -n "$found" ]; then
al@598 1133 if [ $(echo "$found" | wc -l) -gt 1 ]; then
al@598 1134 ask_multiple "$found"
al@598 1135 fi
al@728 1136 echo -e "$srch\t$found" >> $cache
al@598 1137 else
al@598 1138 found=$(search_file_mirror $srch)
al@728 1139 if [ -n "$found" ]; then
al@598 1140 if [ $(echo "$found" | wc -l) -gt 1 ]; then
al@598 1141 ask_multiple "$found"
al@598 1142 fi
al@728 1143 echo -e "$srch\t$found" >> $cache
al@598 1144 else
al@598 1145 echo "$srch" >> $missing
al@598 1146 fi
al@598 1147 fi
al@598 1148 fi
al@598 1149 }
al@598 1150
al@728 1151
al@731 1152 # Return size of file in human readible format
al@731 1153 # Note, "du" in opposite returns size occupied by file on disk (4KB multiple in most cases)
al@731 1154 filesize() {
al@731 1155 busybox ls -lh "$1" | awk '{print $5 "B"}'
al@731 1156 }
al@731 1157
al@731 1158
pankso@1 1159 #
pankso@671 1160 # Receipt functions to ease packaging
pankso@671 1161 #
pankso@671 1162
pankso@671 1163 get_dev_files() {
al@728 1164 _n 'Getting standard devel files...'
pankso@671 1165 mkdir -p $fs/usr/lib
pankso@671 1166 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
pascal@750 1167 cp -a $install/usr/lib/*a $fs/usr/lib
pankso@671 1168 cp -a $install/usr/include $fs/usr
pankso@671 1169 status
pankso@671 1170 }
pankso@671 1171
al@742 1172 dblog() { tee -a $LOGS/pkgdb.log; }
al@742 1173
al@742 1174
al@742 1175
al@728 1176
pankso@671 1177 #
pankso@1 1178 # Commands
pankso@1 1179 #
pankso@1 1180
pankso@1 1181 case "$1" in
pankso@32 1182 usage|help|-u|-h)
pankso@1 1183 usage ;;
al@728 1184
pankso@1 1185 list-wok)
al@728 1186 newline; _ 'List of %s packages in "%s"' "$ARCH" "$WOK"; separator
pankso@642 1187 cd $WOK
al@728 1188 if [ "$ARCH" != 'i486' ]; then
pankso@643 1189 count=0
al@728 1190 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
pankso@643 1191 do
pankso@643 1192 unset HOST_ARCH
pankso@643 1193 . $pkg
pankso@643 1194 count=$(($count + 1))
pankso@643 1195 colorize 34 "$PACKAGE"
pankso@643 1196 done
pankso@642 1197 else
pankso@643 1198 count=$(ls | wc -l)
pankso@643 1199 ls -1
pankso@642 1200 fi
pankso@1 1201 separator
al@728 1202 _p '%s package' '%s packages' "$count" "$(colorize 32 "$count")"
pankso@643 1203 newline ;;
al@728 1204
pankso@378 1205 activity)
pankso@378 1206 cat $activity ;;
al@728 1207
pankso@69 1208 search)
pankso@69 1209 # Just a simple search function, we dont need more actually.
pankso@69 1210 query="$2"
al@728 1211 newline; _ 'Search results for "%s"' "$query"; separator
al@728 1212 cd $WOK; ls -1 | grep "$query"
al@596 1213 separator; newline ;;
al@728 1214
pankso@1 1215 setup)
pankso@1 1216 # Setup a build environment
pankso@1 1217 check_root
al@728 1218 _ 'Cook: setup environment' | log
al@728 1219 newline; _ 'Setting up your environment'; separator
al@596 1220 cd $SLITAZ
pankso@52 1221 init_db_files
al@728 1222 _ 'Checking for packages to install...'
pankso@397 1223 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
pankso@645 1224 # ARCH-setup or 'cross check' should be used before: cook setup
pankso@397 1225 case "$ARCH" in
pankso@676 1226 arm*|x86_64)
al@728 1227 if [ ! -x '/usr/bin/cross' ]; then
al@728 1228 _ 'ERROR: %s is not installed' 'cross'
pankso@397 1229 exit 1
pankso@397 1230 fi
al@728 1231 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
pankso@397 1232 . /etc/slitaz/cross.conf ;;
pankso@397 1233 esac
pankso@397 1234 for pkg in $SETUP_PKGS; do
al@728 1235 if [ -n "$forced" ]; then
pankso@421 1236 tazpkg -gi $pkg --forced
pankso@397 1237 else
al@728 1238 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
pankso@397 1239 fi
pankso@397 1240 done
pankso@1 1241
pankso@1 1242 # Handle --options
pankso@1 1243 case "$2" in
al@728 1244 --wok) hg clone $WOK_URL wok || exit 1 ;;
al@728 1245 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
al@728 1246 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
al@728 1247 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
pankso@1 1248 esac
pankso@1 1249
pankso@1 1250 # SliTaz group and permissions
pankso@1 1251 if ! grep -q ^slitaz /etc/group; then
al@728 1252 _ 'Adding group "%s"' 'slitaz'
pankso@1 1253 addgroup slitaz
pankso@1 1254 fi
al@728 1255 _ 'Setting permissions for group "%s"...' 'slitaz'
pascal@277 1256 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
pascal@277 1257 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
al@728 1258 separator; _ 'All done, ready to cook packages :-)'; newline ;;
al@728 1259
pankso@395 1260 *-setup)
pankso@395 1261 # Setup for cross compiling.
al@728 1262 arch="${1%-setup}"
pankso@397 1263 check_root
pankso@644 1264 . /etc/slitaz/cook.conf
pankso@644 1265 for pkg in $CROSS_SETUP; do
al@728 1266 if [ -n "$forced" ]; then
pankso@644 1267 tazpkg -gi $pkg --forced
pankso@644 1268 else
al@728 1269 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
pankso@644 1270 fi
pankso@644 1271 done
al@728 1272
al@728 1273 _ 'Cook: setup %s cross environment' "$arch" | log
al@728 1274 newline; boldify $(_n 'Setting up your %s cross environment' "$arch"); separator
pankso@397 1275 init_db_files
pankso@359 1276 sed -i \
pankso@396 1277 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
pankso@443 1278 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
pankso@359 1279 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
pankso@395 1280 /etc/slitaz/cook.conf
pankso@395 1281 case "$arch" in
pankso@395 1282 arm)
al@728 1283 flags='-O2 -march=armv6'
pankso@650 1284 host="$ARCH-slitaz-linux-gnueabi" ;;
pankso@650 1285 armv6hf)
al@728 1286 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
pankso@650 1287 host="$ARCH-slitaz-linux-gnueabi" ;;
pankso@650 1288 armv7)
al@728 1289 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
pankso@650 1290 host="$ARCH-slitaz-linux-gnueabi" ;;
pankso@395 1291 x86_64)
al@728 1292 flags='-O2 -mtune=generic -pipe'
pankso@650 1293 host="$ARCH-slitaz-linux" ;;
pankso@395 1294 esac
pankso@650 1295 sed -i \
pankso@650 1296 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
pankso@677 1297 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
pankso@359 1298 . /etc/slitaz/cook.conf
al@728 1299 sysroot="$CROSS_TREE/sysroot"
al@728 1300 tools="/cross/$arch/tools"
al@728 1301 root="$sysroot"
al@596 1302 # L10n: keep the same width of translations to get a consistent view
al@728 1303 _ 'Target arch : %s' "$ARCH"
al@728 1304 _ 'Configure args : %s' "$CONFIGURE_ARGS"
al@728 1305 _ 'Build flags : %s' "$flags"
al@728 1306 _ 'Arch sysroot : %s' "$sysroot"
al@728 1307 _ 'Tools prefix : %s' "$tools/bin"
paul@455 1308 # Tell the packages manager where to find packages.
al@728 1309 _ 'Packages DB : %s' "$root$DB"
al@728 1310 mkdir -p $root$INSTALLED
al@728 1311 cd $root$DB; rm -f *.bak
al@728 1312 for list in packages.list packages.desc packages.equiv packages.md5; do
al@728 1313 rm -f $list
al@728 1314 ln -s $SLITAZ/packages/$list $list
pankso@426 1315 done
pankso@429 1316 # We must have the cross compiled glibc-base installed or default
pankso@429 1317 # i486 package will be used as dep by tazpkg and then break the
pankso@429 1318 # cross environment
al@728 1319 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
al@728 1320 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
pankso@429 1321 fi
pankso@426 1322 # Show GCC version or warn if not yet compiled.
al@737 1323 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
al@728 1324 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
pankso@359 1325 else
al@728 1326 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
al@728 1327 _ 'Run "%s" to cook a toolchain' 'cross compile'
pankso@397 1328 fi
al@596 1329 separator; newline ;;
al@728 1330
pankso@9 1331 test)
pankso@9 1332 # Test a cook environment.
al@728 1333 _ 'Cook test: testing the cook environment' | log
pankso@9 1334 [ ! -d "$WOK" ] && exit 1
pankso@9 1335 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
pankso@9 1336 cook cooktest ;;
al@728 1337
pankso@1 1338 new)
pankso@1 1339 # Create the package folder and an empty receipt.
pankso@1 1340 pkg="$2"
al@728 1341 [ -z "$pkg" ] && usage
pankso@427 1342 newline
pankso@1 1343 if [ -d "$WOK/$pkg" ]; then
al@728 1344 _ 'Package "%s" already exists.' "$pkg"
al@596 1345 exit 1
pankso@1 1346 fi
al@728 1347
al@728 1348 _n 'Creating folder "%s"' "$WOK/$pkg"
al@728 1349 mkdir $WOK/$pkg; cd $WOK/$pkg; status
al@728 1350
al@728 1351 _n 'Preparing the package receipt...'
pankso@1 1352 cp $DATA/receipt .
pankso@1 1353 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
al@728 1354 status; newline
pankso@358 1355
pankso@196 1356 # Interactive mode, asking and seding.
pankso@196 1357 case "$3" in
paul@214 1358 --interactive|-x)
al@728 1359 _ 'Entering interactive mode...'
paul@211 1360 separator
al@728 1361 _ 'Package : %s' "$pkg"
al@728 1362
al@728 1363 _n 'Version : ' ; read answer
al@596 1364 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
al@728 1365
al@728 1366 _n 'Category : ' ; read answer
al@596 1367 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
al@728 1368
al@596 1369 # L10n: Short description
al@728 1370 _n 'Short desc : ' ; read answer
al@596 1371 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
al@728 1372
al@728 1373 _n 'Maintainer : ' ; read answer
al@596 1374 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
al@728 1375
al@728 1376 _n 'License : ' ; read answer
al@596 1377 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
al@728 1378
al@728 1379 _n 'Web site : ' ; read answer
al@596 1380 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
pankso@427 1381 newline
al@728 1382
pankso@196 1383 # Wget URL.
al@728 1384 _ 'Wget URL to download source tarball.'
al@728 1385 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
al@728 1386 _n 'Wget url : ' ; read answer
al@728 1387 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
al@728 1388
pankso@196 1389 # Ask for a stuff dir.
al@728 1390 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
al@728 1391 if [ "$?" == 0 ]; then
al@728 1392 _n 'Creating the stuff directory...'
al@728 1393 mkdir $WOK/$pkg/stuff; status
pankso@196 1394 fi
al@728 1395
pankso@196 1396 # Ask for a description file.
al@728 1397 confirm "$(_n 'Are you going to write a description? (y/N)')"
al@728 1398 if [ "$?" == 0 ]; then
al@728 1399 _n 'Creating the "%s" file...' 'description.txt'
al@728 1400 touch $WOK/$pkg/description.txt; status
pankso@196 1401 fi
al@728 1402
al@728 1403 separator; _ 'Receipt is ready to use.'; newline ;;
pankso@196 1404 esac ;;
al@728 1405
pankso@1 1406 list)
pankso@1 1407 # Cook a list of packages (better use the Cooker since it will order
pankso@1 1408 # packages before executing cook).
pankso@1 1409 check_root
al@728 1410 if [ -z "$2" ]; then
al@728 1411 newline; _ 'No list in argument.'; newline
al@728 1412 exit 1
al@728 1413 fi
al@728 1414 if [ ! -f "$2" ]; then
al@728 1415 newline; _ 'List "%s" not found.' "$2"; newline
al@728 1416 exit 1
al@728 1417 fi
al@728 1418
al@728 1419 _ 'Starting cooking the list "%s"' "$2" | log
al@728 1420
al@728 1421 for pkg in $(cat $2); do
pankso@1 1422 cook $pkg || broken
pankso@1 1423 done ;;
al@728 1424
pankso@1 1425 clean-wok)
pankso@1 1426 check_root
al@728 1427 newline; _n 'Cleaning all packages files...'
pankso@1 1428 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
al@596 1429 status; newline ;;
al@728 1430
pankso@1 1431 clean-src)
pankso@1 1432 check_root
al@728 1433 newline; _n 'Cleaning all packages sources...'
pankso@1 1434 rm -rf $WOK/*/source
al@596 1435 status; newline ;;
al@728 1436
pankso@662 1437 uncook)
pankso@662 1438 cd $WOK
pankso@662 1439 count=0
al@728 1440 newline; _ 'Checking for uncooked packages'; separator
al@728 1441
al@728 1442 for pkg in *; do
pankso@664 1443 unset HOST_ARCH EXTRAVERSION
al@728 1444 [ ! -e $pkg/receipt ] && continue
pankso@662 1445 . $pkg/receipt
pankso@662 1446 # Source cooked pkg receipt to get EXTRAVERSION
pankso@663 1447 if [ -d "$WOK/$pkg/taz" ]; then
pankso@663 1448 cd $WOK/$pkg/taz/$pkg-*
al@728 1449 . receipt; cd $WOK
pankso@662 1450 fi
pankso@662 1451 case "$ARCH" in
pankso@662 1452 i486)
al@728 1453 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
al@728 1454 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
pankso@662 1455 count=$(($count + 1))
pankso@662 1456 colorize 34 "$pkg"
pankso@662 1457 fi ;;
pankso@676 1458 arm*)
paul@665 1459 # Check only packages included in arch
pascal@669 1460 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
pankso@662 1461 # *.tazpkg
al@728 1462 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
pankso@662 1463 count=$(($count + 1))
pankso@662 1464 colorize 34 "$pkg"
pankso@662 1465 fi
pankso@662 1466 fi ;;
pankso@662 1467 esac
pankso@662 1468 done
al@728 1469
pankso@662 1470 if [ "$count" -gt "0" ]; then
pankso@662 1471 separator
al@728 1472 _p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")"
pankso@662 1473 else
al@728 1474 _ 'All packages are cooked :-)'
pankso@662 1475 fi
pankso@662 1476 newline ;;
al@728 1477
pankso@235 1478 pkgdb)
pankso@235 1479 # Create suitable packages list for TazPKG and only for built packages
pankso@235 1480 # as well as flavors files for TazLiTo. We dont need logs since we do it
paul@243 1481 # manually to ensure everything is fine before syncing the mirror.
al@742 1482
al@742 1483 rm $LOGS/pkgdb.log 2>/dev/null
al@742 1484
pankso@239 1485 case "$2" in
al@744 1486 --flavors|--rmpkg) ;;
pankso@239 1487 *)
al@728 1488 [ -n "$2" ] && PKGS="$2"
al@728 1489 if [ ! -d "$PKGS" ]; then
al@742 1490 { newline; _ "Packages directory \"%s\" doesn't exist" "$PKGS"; newline; } | dblog
al@728 1491 exit 1
al@728 1492 fi ;;
pankso@239 1493 esac
al@728 1494
pankso@226 1495 time=$(date +%s)
al@728 1496 flavors="$SLITAZ/flavors"
al@728 1497 live="$SLITAZ/live"
al@725 1498
al@728 1499 echo 'cook:pkgdb' > $command
al@728 1500 _ 'Cook pkgdb: Creating all packages lists' | log
al@742 1501 newline; { _ 'Creating lists for "%s"' "$PKGS"; separator; } | dblog
al@728 1502
al@742 1503 { _ 'Cook pkgdb started: %s' "$(date "$(_ '+%%F %%R')")"; newline; } | dblog
al@725 1504
pankso@133 1505 cd $PKGS
pascal@699 1506 rm -f packages.* extra.list
al@729 1507 touch packages.equiv
al@725 1508
al@742 1509 _n 'Creating file "%s"' 'packages.list' | dblog
pankso@85 1510 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
al@742 1511 echo " ($(filesize $PKGS/packages.list))" | dblog
al@725 1512
al@742 1513 _n 'Creating file "%s"' 'packages.md5' | dblog
pankso@1 1514 md5sum *.tazpkg > $PKGS/packages.md5
al@742 1515 echo " ($(filesize $PKGS/packages.md5))" | dblog
al@744 1516 cp $PKGS/packages.md5 $PKGS/packages.toremove # list of duplicates
al@725 1517
al@728 1518 md5sum packages.md5 | cut -d' ' -f1 > ID
al@725 1519 ( cat ./ID | tr $'\n' ' '; date -ur ./ID +%s ) > IDs # md5 and timestamp
al@725 1520
al@742 1521 _n 'Creating file "%s"' 'descriptions.txt' | dblog
al@742 1522 rm $PKGS/descriptions.txt 2>/dev/null
al@741 1523 for i in $(ls $WOK | sort); do
al@741 1524 if [ -e "$WOK/$i/description.txt" ]; then
al@741 1525 echo "$i" >> descriptions.txt
al@741 1526 cat "$WOK/$i/description.txt" | sed 's|^$| |' >> descriptions.txt
al@741 1527 echo >> descriptions.txt
al@741 1528 fi
al@741 1529 done
al@742 1530 echo " ($(filesize $PKGS/descriptions.txt))" | dblog
al@741 1531
al@741 1532
al@742 1533 _ 'Creating lists from "%s"' "$WOK" | dblog
pankso@1 1534 cd $WOK
al@725 1535 for pkg in *; do
pankso@1 1536 unset_receipt
pankso@1 1537 . $pkg/receipt
pascal@600 1538 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
al@728 1539 [ -s $pkg/taz/*/receipt ] && . $pkg/taz/*/receipt
al@728 1540
al@728 1541 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ] || \
al@728 1542 [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
al@701 1543
pankso@192 1544 # packages.desc lets us search easily in DB
al@728 1545 cat >> $PKGS/packages.desc <<EOT
al@728 1546 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
pankso@1 1547 EOT
al@701 1548
pankso@192 1549 # packages.txt used by tazpkg and tazpkg-web also to provide
pankso@192 1550 # a human readable package list with version and description.
al@728 1551 cat >> $PKGS/packages.txt <<EOT
pankso@192 1552 $PACKAGE
al@728 1553 $VERSION$EXTRAVERSION
pankso@235 1554 $SHORT_DESC
pankso@235 1555 $PACKED_SIZE ($UNPACKED_SIZE installed)
pankso@358 1556
pankso@192 1557 EOT
al@701 1558
al@736 1559 # packages.info combines TazPkg separate files
al@736 1560 # and will substitute them all
al@701 1561 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
al@701 1562 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
al@736 1563 MD5="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" $PKGS/packages.md5 | awk '{print $1}')"
al@728 1564 cat >> $PKGS/packages.info <<EOT
al@736 1565 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5
al@701 1566 EOT
al@701 1567
pankso@192 1568 # packages.equiv is used by tazpkg install to check depends.
pankso@1 1569 for i in $PROVIDE; do
al@728 1570 DEST=''
pankso@1 1571 echo $i | fgrep -q : && DEST="${i#*:}:"
pankso@1 1572 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
pankso@1 1573 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
pankso@1 1574 $PKGS/packages.equiv
pankso@1 1575 else
pankso@1 1576 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
pankso@1 1577 fi
pankso@1 1578 done
al@701 1579
paul@197 1580 # files.list provides a list of all packages files.
pankso@194 1581 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
pankso@194 1582 $PKGS/files.list
al@744 1583
al@744 1584 # list of duplicates
al@744 1585 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION.tazpkg/d" $PKGS/packages.toremove
al@744 1586 else
al@746 1587 # if receipt variable HOST_ARCH absent/empty or contains ARCH
al@746 1588 if [ -z "$HOST_ARCH" -o "${HOST_ARCH/$ARCH/}" != "$HOST_ARCH" ]; then
al@746 1589 _ ' - absent: %s (%s)' "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$ARCH" | dblog
al@746 1590 fi
pankso@1 1591 fi
pankso@1 1592 done
pankso@358 1593
pankso@213 1594 # Display list size.
al@742 1595 _ 'Done: %s (%s)' 'packages.desc' "$(filesize $PKGS/packages.desc)" | dblog
al@742 1596 _ 'Done: %s (%s)' 'packages.txt' "$(filesize $PKGS/packages.txt)" | dblog
al@742 1597 _ 'Done: %s (%s)' 'packages.info' "$(filesize $PKGS/packages.info)" | dblog
al@742 1598 _ 'Done: %s (%s)' 'packages.equiv' "$(filesize $PKGS/packages.equiv)" | dblog
pankso@358 1599
al@727 1600 cd $PKGS
al@727 1601
al@744 1602
al@744 1603 # Check package duplicates
al@744 1604 if [ -s "$PKGS/packages.toremove" ]; then
al@744 1605 newline | dblog
al@744 1606 _ 'Removing duplicates:' | dblog
al@744 1607 while read pkgsum pkgfile; do
al@744 1608 echo " - $pkgfile" | dblog
al@744 1609 sed -i "/${pkgfile%.tazpkg}/d" $PKGS/packages.list
al@744 1610 sed -i "/ $pkgfile/d" $PKGS/packages.md5
al@744 1611 [ -n "$rmpkg" ] && rm $PKGS/$pkgfile # remove packages only with --rmpkg
al@744 1612 done < $PKGS/packages.toremove
al@744 1613 newline | dblog
al@744 1614 fi
al@745 1615 rm $PKGS/packages.toremove
al@744 1616
al@744 1617
pankso@194 1618 # files.list.lzma
al@742 1619 _n 'Creating file "%s"' 'files.list.lzma' | dblog
al@727 1620 touch files.list
al@729 1621 # pkgs.slitaz.org strongly depends on list sorted by packages names
al@729 1622 lzma e files.list files.list.lzma
al@742 1623 echo " ($(filesize $PKGS/files.list.lzma))" | dblog
al@725 1624
al@729 1625 # Pre-sorting filenames causes 10% smaller resulting lzma file
al@742 1626 _n 'Creating file "%s"' 'files-list.lzma' | dblog
al@729 1627 cat files.list | sort -k2 -o files.list.sorted
al@729 1628 lzma e files.list.sorted files-list.lzma
al@729 1629 rm -f files.list files.list.sorted
al@742 1630 echo " ($(filesize $PKGS/files-list.lzma))" | dblog
al@729 1631
al@729 1632 [ -e files.list.md5 ] && rm files.list.md5
al@729 1633 md5sum files-list.lzma | cut -d' ' -f1 | tr -d $'\n' > files-list.md5
pankso@358 1634
al@701 1635 # packages.info.lzma
al@701 1636 PI=packages.info
al@742 1637 _n 'Creating file "%s"' 'packages.info.lzma' | dblog
al@727 1638 touch $PI
al@727 1639 lzma e $PI $PI.lzma
al@742 1640 echo " ($(filesize $PKGS/packages.info.lzma))" | dblog
al@725 1641
al@725 1642 # Make bundle to fast recharge
al@742 1643 _n 'Creating file "%s"' 'bundle.tar.lzma' | dblog
al@725 1644 [ -f bundle.tar.lzma ] && rm bundle.tar.lzma
al@746 1645 # Make sure to get "mirrors" file
al@746 1646 until [ -e 'mirrors' ]; do
al@746 1647 wget -q http://mirror1.slitaz.org/mirrors
al@746 1648 echo -n '.' | dblog; sleep 5
al@746 1649 done
al@746 1650 # Make sure to get "extra.list" file
al@746 1651 until [ -e 'extra.list' ]; do
al@746 1652 wget -q -O extra.list http://mirror1.slitaz.org/packages/get.list
al@746 1653 echo -n '.' | dblog; sleep 5
al@746 1654 done
al@730 1655 busybox tar -chaf bundle.tar.lzma \
al@741 1656 mirrors extra.list files-list.md5 packages.info descriptions.txt \
al@725 1657 packages.desc packages.md5 packages.txt packages.list packages.equiv
al@727 1658 rm ./mirrors
al@742 1659 echo " ($(filesize $PKGS/bundle.tar.lzma))" | dblog
al@701 1660
pankso@235 1661 # Display some info.
al@742 1662 separator | dblog
pankso@1 1663 nb=$(ls $PKGS/*.tazpkg | wc -l)
pankso@226 1664 time=$(($(date +%s) - $time))
al@596 1665 # L10n: 's' is for seconds (cooking time)
al@742 1666 { _ 'Packages: %s - Time: %ss' "$nb" "$time"; newline; } | dblog
al@728 1667
pankso@358 1668
paul@243 1669 # Create all flavors files at once. Do we really need code to monitor
al@596 1670 # flavors changes? Lets just build them with packages lists before
pankso@235 1671 # syncing the mirror.
al@728 1672 [ "$2" != '--flavors' ] && exit 1
al@728 1673
al@728 1674 if [ ! -d "$flavors" ]; then
al@742 1675 { _ 'Missing flavors folder "%s"' "$flavors"; newline; } | dblog
al@728 1676 exit 1
al@728 1677 fi
al@728 1678
al@728 1679 [ ! -d "$live" ] && mkdir -p $live
al@742 1680 _ 'Creating flavors files in "%s"' "$live" | dblog
al@728 1681 _ 'Cook pkgdb: Creating all flavors' | log
al@742 1682 separator | dblog
al@728 1683
al@742 1684 _ 'Recharging lists to use latest packages...' | dblog
pankso@329 1685 tazpkg recharge >/dev/null 2>/dev/null
pankso@358 1686
pankso@235 1687 # We need a custom tazlito config to set working dir to /home/slitaz.
pankso@235 1688 if [ ! -f "$live/tazlito.conf" ]; then
al@742 1689 _ 'Creating configuration file "%s"' 'tazlito.conf' | dblog
pankso@235 1690 cp /etc/tazlito/tazlito.conf $live
pankso@235 1691 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
pankso@235 1692 $live/tazlito.conf
pankso@235 1693 fi
pankso@235 1694
pankso@239 1695 # Update Hg flavors repo and pack.
al@728 1696 if [ -d "$flavors/.hg" ]; then
al@728 1697 cd $flavors; hg pull -u
al@728 1698 fi
pankso@358 1699
pankso@239 1700 cd $live
al@742 1701 _ 'Starting to generate flavors...' | dblog
pankso@235 1702 rm -f flavors.list *.flavor
al@728 1703 for i in $flavors/*; do
pankso@235 1704 fl=$(basename $i)
al@742 1705 _ 'Packing flavor "%s"' "$fl" | dblog
pankso@235 1706 tazlito pack-flavor $fl >/dev/null || exit 1
al@728 1707 tazlito show-flavor $fl --brief --noheader 2>/dev/null >> flavors.list
pankso@235 1708 done
pankso@237 1709 cp -f $live/*.flavor $live/flavors.list $PKGS
al@742 1710 separator | dblog
al@742 1711 { _ 'Total flavors size: %s' "$(du -sh $live | awk '{print $1}')"; newline; } | dblog
al@596 1712 rm -f $command
al@742 1713 separator | dblog
al@742 1714 _ 'Cook pkgdb end: %s' "$(date "$(_ '+%%F %%R')")" | dblog
al@742 1715 ;;
al@728 1716
pankso@1 1717 *)
pankso@1 1718 # Just cook and generate a package.
pankso@1 1719 check_root
pankso@1 1720 time=$(date +%s)
pankso@1 1721 pkg="$1"
pankso@1 1722 [ -z "$pkg" ] && usage
pascal@751 1723 lastcooktime=$(sed '/^Cook time/!d;s|.*: *\([0-9]*\)s.*|\1|' \
pascal@763 1724 $LOGS/$pkg.log 2> /dev/null | sed '$!d')
pankso@44 1725 receipt="$WOK/$pkg/receipt"
al@728 1726 check_pkg_in_wok
al@728 1727 newline
pankso@47 1728
pankso@377 1729 unset inst
pankso@377 1730 unset_receipt
pankso@377 1731 . $receipt
al@728 1732
pankso@377 1733 # Handle cross compilation.
pankso@377 1734 case "$ARCH" in
pankso@676 1735 arm*)
al@728 1736 if [ -z "$HOST_ARCH" ]; then
al@728 1737 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
al@728 1738 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
al@728 1739 _ 'cook: %s' "$error"
al@728 1740 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
al@728 1741 _ 'Cook skip: %s' "$error" | log
al@728 1742 newline
al@728 1743 exit 1
pankso@377 1744 fi ;;
pankso@377 1745 esac
pankso@377 1746
paul@387 1747 # Some packages are not included in some arch or fail to cross compile.
pankso@398 1748 : ${HOST_ARCH=i486}
al@728 1749 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
pankso@675 1750 # Handle arm{v6hf,v7,..}
pankso@675 1751 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
al@728 1752 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
al@728 1753 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
al@728 1754 _ 'cook: %s' "error"
al@728 1755 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
al@728 1756 _ 'Cook skip: %s' "$error" | log
pascal@673 1757 sed -i /^${pkg}$/d $broken
al@728 1758 newline
al@728 1759 exit 0
pankso@377 1760 fi
pankso@377 1761
pankso@47 1762 # Skip blocked, 3 lines also for the Cooker.
al@728 1763 if grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ]; then
al@728 1764 _ 'Package "%s" is blocked' "$pkg"; newline
al@728 1765 exit 0
pankso@47 1766 fi
pankso@47 1767
pascal@289 1768 try_aufs_chroot "$@"
pascal@289 1769
pankso@47 1770 # Log and source receipt.
al@728 1771 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
pankso@16 1772 echo "cook:$pkg" > $command
pascal@751 1773 [ "$lastcooktime" ] &&
pascal@751 1774 echo "cook:$pkg $lastcooktime $(date +%s)" > $cooktime
pascal@285 1775
pascal@285 1776 # Display and log info if cook process stopped.
paul@647 1777 # FIXME: gettext not working (in single quotes) here!
al@596 1778 trap '_ "\n\nCook stopped: control-C\n\n" | \
pascal@285 1779 tee -a $LOGS/$pkg.log' INT
pascal@285 1780
pankso@1 1781 # Handle --options
pankso@1 1782 case "$2" in
pankso@1 1783 --clean|-c)
al@728 1784 _n 'Cleaning "%s"' "$pkg"
al@728 1785 cd $WOK/$pkg; rm -rf install taz source
al@728 1786 status; newline
al@728 1787 exit 0 ;;
al@728 1788
pankso@1 1789 --install|-i)
pankso@1 1790 inst='yes' ;;
al@728 1791
pankso@49 1792 --getsrc|-gs)
al@728 1793 _ 'Getting source for "%s"' "$pkg"; separator
al@596 1794 get_source
al@728 1795 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
al@596 1796 exit 0 ;;
al@728 1797
pankso@49 1798 --block|-b)
al@728 1799 _n 'Blocking package "%s"' "$pkg"
pankso@49 1800 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
al@728 1801 status; newline
al@728 1802 exit 0 ;;
al@728 1803
pankso@49 1804 --unblock|-ub)
al@728 1805 _n 'Unblocking package "%s"' "$pkg"
pankso@49 1806 sed -i "/^${pkg}$/"d $blocked
al@728 1807 status; newline
al@728 1808 exit 0 ;;
al@728 1809
slaxemulator@501 1810 --pack)
slaxemulator@501 1811 if [ -d $WOK/$pkg/taz ]; then
slaxemulator@501 1812 rm -rf $WOK/$pkg/taz
slaxemulator@501 1813 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
slaxemulator@501 1814 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
slaxemulator@501 1815 clean_log
slaxemulator@501 1816 else
al@728 1817 _ 'Need to build "%s"' "$pkg"
al@728 1818 exit 0
slaxemulator@501 1819 fi
slaxemulator@501 1820 exit 0 ;;
al@728 1821
al@598 1822 --cdeps)
al@728 1823 if [ ! -d $WOK/$pkg/taz ]; then
al@728 1824 _ 'Need to build "%s"' "$pkg"
al@728 1825 exit 0
al@728 1826 fi
al@728 1827
al@728 1828 _ 'Checking depends'; separator
al@728 1829 lddlist='/tmp/lddlist'; touch $lddlist
al@728 1830 missing='/var/cache/missing.file'
al@728 1831
al@598 1832 # find all deps using ldd
al@598 1833 for exe in $(find $WOK/$pkg/taz -type f -perm +111); do
al@598 1834 [ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] &&
al@598 1835 ldd $exe | sed 's| ||' | cut -d' ' -f1 >> $lddlist
al@728 1836 done #"
al@728 1837
al@598 1838 # remove exe/so duplicates
al@598 1839 sort -u $lddlist > $lddlist.sorted
al@728 1840
al@598 1841 # search packages
al@598 1842 for exefile in $(cat $lddlist.sorted); do
al@598 1843 search_file $exefile
al@728 1844 echo "$found" >> $lddlist.pkgs
al@728 1845 echo -n '.'
al@598 1846 done
al@598 1847 echo
al@728 1848
al@598 1849 # remove packages duplicates
al@598 1850 sort -u $lddlist.pkgs > $lddlist.final
al@598 1851 sort -u $missing > $missing.final
al@598 1852 rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing
al@598 1853 exit 0 ;;
pankso@1 1854 esac
pankso@1 1855
paul@62 1856 # Check if wanted is built now so we have separate log files.
pankso@295 1857 for wanted in $WANTED ; do
pascal@291 1858 if grep -q "^$wanted$" $blocked; then
al@728 1859 _ 'WANTED package "%s" is blocked' "$wanted" | tee $LOGS/$pkg.log
al@728 1860 newline
al@728 1861 rm -f $command
al@728 1862 exit 1
pankso@217 1863 fi
pascal@291 1864 if grep -q "^$wanted$" $broken; then
al@728 1865 _ 'WANTED package "%s" is broken' "$wanted" | tee $LOGS/$pkg.log
al@728 1866 newline
al@728 1867 rm -f $command
al@728 1868 exit 1
pankso@218 1869 fi
pascal@291 1870 if [ ! -d "$WOK/$wanted/install" ]; then
pascal@291 1871 cook "$wanted" || exit 1
pankso@137 1872 fi
pascal@291 1873 done
pankso@1 1874
pankso@1 1875 # Cook and pack or exit on error and log everything.
pascal@576 1876 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
pankso@15 1877 remove_deps | tee -a $LOGS/$pkg.log
pankso@1 1878 cookit_quality
pascal@576 1879 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
pankso@1 1880 clean_log
pankso@33 1881
pankso@33 1882 # Exit if any error in packing.
al@728 1883 lerror=$(_n 'ERROR')
pascal@615 1884 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
pascal@752 1885 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
pankso@33 1886 debug_info | tee -a $LOGS/$pkg.log
al@728 1887 rm -f $command
al@728 1888 exit 1
pankso@33 1889 fi
pankso@358 1890
pankso@310 1891 # Create an XML feed
pankso@310 1892 gen_rss
pankso@358 1893
pankso@1 1894 # Time and summary
pankso@1 1895 time=$(($(date +%s) - $time))
pankso@1 1896 summary | tee -a $LOGS/$pkg.log
pankso@427 1897 newline
pankso@1 1898
pascal@683 1899 # We may want to install/update (outside aufs jail !).
pascal@683 1900 [ -s /aufs-umount.sh ] ||
pankso@428 1901 install_package
pankso@358 1902
al@596 1903 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
pankso@17 1904 # You want automation: use the Cooker Build Bot.
pankso@18 1905 rm -f $command ;;
pankso@1 1906 esac
pankso@1 1907
pankso@1 1908 exit 0