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