cookutils annotate cook @ rev 838

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