cookutils annotate cook @ rev 1010

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