cookutils annotate cook @ rev 597

cook: some .tar.xz are bz2 files...
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Apr 05 13:48:40 2013 +0200 (2013-04-05)
parents 8fbd30a8686a
children 24dbe04170be
rev   line source
pankso@1 1 #!/bin/sh
pankso@1 2 #
pankso@1 3 # Cook - A tool to cook and generate SliTaz packages. Read the README
pankso@1 4 # before adding or modifing any code in cook!
pankso@1 5 #
pankso@1 6 # Copyright (C) SliTaz GNU/Linux - GNU gpl v3
pankso@1 7 # Author: Christophe Lincoln <pankso@slitaz.org>
pankso@1 8 #
pankso@422 9 . /usr/lib/slitaz/libcook.sh
pankso@1 10
al@596 11 VERSION="3.1.4"
al@596 12
al@596 13 # Internationalization.
al@596 14 . /usr/bin/gettext.sh
al@596 15 TEXTDOMAIN='cook'
al@596 16 export TEXTDOMAIN
al@596 17
al@596 18 _() echo -e "$(eval_gettext "$1")"
al@596 19 _n() echo -en "$(eval_gettext "$1")"
al@596 20 # to disable i18n:
al@596 21 # _() echo -e "$1"
al@596 22 # _n() echo -en "$1"
al@596 23
al@596 24
pankso@1 25 #
pankso@1 26 # Functions
pankso@1 27 #
pankso@1 28
pankso@1 29 usage() {
pankso@1 30 cat << EOT
pankso@1 31
al@596 32 $(_ "\033[1mUsage:\033[0m cook [package|command] [list|--option]")
pankso@1 33
al@596 34 $(_ "\033[1mCommands:\033[0m")
al@596 35 usage|help $(_ "Display this short usage.")
al@596 36 setup $(_ "Setup your build environment.")
al@596 37 *-setup $(_ "Setup a cross environment.")
al@596 38 test $(_ "Test environment and cook a package.")
al@596 39 list-wok $(_ "List packages in the wok.")
al@596 40 search $(_ "Simple packages search function.")
al@596 41 new $(_ "Create a new package with a receipt.")
al@596 42 list $(_ "Cook a list of packages.")
al@596 43 clean-wok $(_ "Clean-up all packages files.")
al@596 44 clean-src $(_ "Clean-up all packages sources.")
al@596 45 pkgdb $(_ "Create packages DB lists and flavors.")
pankso@1 46
al@596 47 $(_ "\033[1mOptions:\033[0m")
al@596 48 --clean|-c Cook : $(_ "clean the package in the wok.")
al@596 49 --install|-i Cook : $(_ "cook and install the package.")
al@596 50 --getsrc|-gs Cook : $(_ "get the package source tarball.")
al@596 51 --block|-b Cook : $(_ "block a package so cook will skip it.")
al@596 52 --unblock|-ub Cook : $(_ "unblock a blocked package.")
al@596 53 --pack Cook : $(_ "repack an already built package.")
al@596 54 --interactive|-x New : $(_ "create a receipt interactively.")
al@596 55 --wok Setup: $(_ "clone the cooking wok from Hg repo.")
al@596 56 --stable Setup: $(_ "clone the stable wok from Hg repo.")
al@596 57 --undigest Setup: $(_ "clone the undigest wok from Hg repo.")
al@596 58 --tiny Setup: $(_ "clone the tiny SliTaz wok from Hg repo.")
al@596 59 --forced Setup: $(_ "force reinstall of chroot packages.")
al@596 60 --flavors Pkgdb: $(_ "create up-to-date flavors files.")
pankso@1 61
pankso@1 62 EOT
pankso@1 63 exit 0
pankso@1 64 }
pankso@1 65
paul@62 66 # We don't want these escapes in web interface.
pankso@1 67 clean_log() {
pankso@1 68 sed -i -e s'|\[70G\[ \[1;32m| |' \
pankso@1 69 -e s'|\[0;39m \]||' $LOGS/$pkg.log
pankso@1 70 }
pankso@1 71
paul@62 72 # Be sure package exists in wok.
pankso@1 73 check_pkg_in_wok() {
pankso@1 74 if [ ! -d "$WOK/$pkg" ]; then
al@596 75 newline; _ "Unable to find package in the wok: \$pkg"; newline
al@596 76 exit 1
pankso@1 77 fi
pankso@1 78 }
pankso@1 79
pankso@9 80 if_empty_value() {
pankso@9 81 if [ -z "$value" ]; then
al@596 82 # L10n: QA is quality assurance
al@596 83 _ "QA: empty variable: \${var}=\"\""; newline
pankso@9 84 exit 1
pankso@9 85 fi
pankso@9 86 }
pankso@9 87
paul@62 88 # Initialize files used in $CACHE
pankso@52 89 init_db_files() {
al@596 90 _ "Creating directories structure in: \$SLITAZ"
xfred222@559 91 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
al@596 92 _ "Creating DB files in: \$CACHE"
pankso@52 93 for f in $activity $command $broken $blocked
pankso@52 94 do
pankso@52 95 touch $f
pankso@52 96 done
pankso@52 97 }
pankso@52 98
paul@62 99 # QA: check a receipt consistency before building.
pankso@9 100 receipt_quality() {
al@596 101 _ "QA: checking package receipt..."
pankso@9 102 unset online
pankso@9 103 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
pankso@9 104 online="online"
pankso@9 105 fi
pankso@9 106 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
pankso@9 107 do
pankso@9 108 unset value
pascal@279 109 value="$(. $receipt ; eval echo \$$var)"
pankso@9 110 case "$var" in
pankso@9 111 PACKAGE|VERSION|SHORT_DESC)
pankso@9 112 if_empty_value ;;
pankso@9 113 CATEGORY)
pankso@9 114 [ -z "$value" ] && value="empty"
al@596 115 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
pankso@9 116 if ! echo "$valid" | grep -q -w "$value"; then
al@596 117 _ "QA: unknown category: \$value"
al@596 118 _ "Please, use one of: \$valid" | busybox fold -s
al@596 119 newline; exit 1
pankso@9 120 fi ;;
pankso@9 121 WEB_SITE)
paul@62 122 # We don't check WGET_URL since if dl is needed it will fail.
paul@62 123 # Break also if we're not online. Here error is not fatal.
pankso@9 124 if_empty_value
pankso@9 125 [ -z "$online" ] || break
pankso@199 126 if ! busybox wget -T 12 -s $value 2>/dev/null; then
al@596 127 _ "QA: unable to reach: \$value"
pankso@9 128 fi ;;
pankso@9 129 esac
pankso@9 130 done
pankso@9 131 }
pankso@9 132
paul@62 133 # Paths used in receipt and by cook itself.
pankso@1 134 set_paths() {
pankso@1 135 pkgdir=$WOK/$PACKAGE
slaxemulator@492 136 basesrc=$pkgdir/source
slaxemulator@492 137 tmpsrc=$basesrc/tmp
slaxemulator@492 138 src=$basesrc/$PACKAGE-$VERSION
pankso@44 139 taz=$pkgdir/taz
pankso@44 140 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
pankso@1 141 fs=$pack/fs
pankso@1 142 stuff=$pkgdir/stuff
pankso@1 143 install=$pkgdir/install
slaxemulator@492 144 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
slaxemulator@492 145 lzma_tarball="$pkgsrc.tar.lzma"
slaxemulator@492 146 if [ "$PATCH" ]; then
slaxemulator@492 147 [ "${PTARBALL}" ] || PTARBALL="$(basename $PATCH)"
slaxemulator@492 148 fi
pankso@1 149 if [ "$WANTED" ]; then
slaxemulator@492 150 basesrc=$WOK/$WANTED/source
slaxemulator@492 151 src=$basesrc/$WANTED-$VERSION
slaxemulator@492 152 install=$WOK/$WANTED/install
slaxemulator@492 153 wanted_stuff=$WOK/$WANTED/stuff
pankso@1 154 fi
slaxemulator@456 155 if [ "$SOURCE" ]; then
slaxemulator@456 156 source_stuff=$WOK/$SOURCE/stuff
slaxemulator@456 157 fi
slaxemulator@492 158 # Kernel version is set from linux
slaxemulator@492 159 if [ -f "$WOK/linux/receipt" ]; then
slaxemulator@492 160 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d '"' -f 2)
slaxemulator@492 161 kbasevers=${kvers:0:3}
slaxemulator@492 162 fi
slaxemulator@492 163 # Python version
slaxemulator@492 164 if [ -f "$WOK/python/receipt" ]; then
slaxemulator@492 165 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d '"' -f 2)
slaxemulator@492 166 fi
slaxemulator@492 167 # perl version for some packages needed it
slaxemulator@492 168 if [ -f "$WOK/perl/receipt" ]; then
slaxemulator@492 169 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d '"' -f 2)
pankso@232 170 fi
pankso@9 171 # Old way compatibility.
pankso@1 172 _pkg=$install
pankso@1 173 }
pankso@1 174
pankso@144 175 # Create source tarball when URL is a SCM.
pankso@144 176 create_tarball() {
slaxemulator@498 177 local tarball
slaxemulator@498 178 tarball=$pkgsrc.tar.bz2
slaxemulator@498 179 [ "$LZMA_SRC" ] && tarball=$lzma_tarball
al@596 180 _ "Creating tarball: \$tarball"
pankso@162 181 if [ "$LZMA_SRC" ]; then
slaxemulator@498 182 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
slaxemulator@498 183 LZMA_SRC=""
pankso@162 184 else
pankso@162 185 tar cjf $tarball $pkgsrc || exit 1
pankso@162 186 mv $tarball $SRC && rm -rf $pkgsrc
pankso@162 187 fi
slaxemulator@498 188 TARBALL=$tarball
pankso@144 189 }
pankso@144 190
pankso@145 191 # Get package source. For SCM we are in cache so clone here and create a
pankso@145 192 # tarball here.
pankso@1 193 get_source() {
ernia@571 194 set_paths
pankso@115 195 pwd=$(pwd)
pankso@9 196 case "$WGET_URL" in
pankso@145 197 http://*|ftp://*)
pankso@9 198 # Busybox Wget is better!
pascal@268 199 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
al@596 200 (_ "ERROR: wget \$WGET_URL" && exit 1) ;;
pankso@145 201 https://*)
pankso@250 202 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
al@596 203 (_ "ERROR: wget \$WGET_URL" && exit 1) ;;
pankso@9 204 hg*|mercurial*)
pankso@29 205 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
pankso@9 206 url=${WGET_URL#hg|}
pankso@9 207 else
pankso@9 208 url=${WGET_URL#mercurial|}
pankso@9 209 fi
al@596 210 _ "Getting source from Hg..."
al@596 211 _ "URL: \$url"
al@596 212 _ "Cloning to: \$pwd/\$pkgsrc"
pankso@246 213 if [ "$BRANCH" ]; then
al@596 214 _ "Hg branch: \$BRANCH"
pankso@246 215 hg clone $url --rev $BRANCH $pkgsrc || \
al@596 216 (_ "ERROR: hg clone \$url --rev \$BRANCH" && exit 1)
pankso@246 217 else
al@596 218 hg clone $url $pkgsrc || (_ "ERROR: hg clone \$url" && exit 1)
pankso@246 219 fi
pankso@255 220 rm -rf $pkgsrc/.hg
pankso@144 221 create_tarball ;;
pankso@9 222 git*)
pankso@61 223 url=${WGET_URL#git|}
al@596 224 _ "Getting source from Git..."
al@596 225 _ "URL: \$url"
al@596 226 git clone $url $pkgsrc || (_ "ERROR: git clone \$url" && exit 1)
pankso@63 227 if [ "$BRANCH" ]; then
al@596 228 _ "Git branch: \$BRANCH"
pankso@358 229 cd $pkgsrc && git checkout $BRANCH && cd ..
pankso@63 230 fi
pankso@144 231 create_tarball ;;
pankso@144 232 cvs*)
pankso@144 233 url=${WGET_URL#cvs|}
pankso@144 234 mod=$PACKAGE
pankso@144 235 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
al@596 236 _ "Getting source from CVS..."
al@596 237 _ "URL: \$url"
al@596 238 [ "$CVS_MODULE" ] && _ "CVS module: \$mod"
al@596 239 _ "Cloning to: \$pwd/\$mod"
pankso@144 240 cvs -d:$url co $mod && mv $mod $pkgsrc
pankso@144 241 create_tarball ;;
pankso@69 242 svn*|subversion*)
pankso@159 243 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
pankso@146 244 url=${WGET_URL#svn|}
pankso@146 245 else
pankso@146 246 url=${WGET_URL#subversion|}
pankso@146 247 fi
al@596 248 _ "Getting source from SVN..."
al@596 249 _ "URL: \$url"
pankso@161 250 if [ "$BRANCH" ]; then
pankso@161 251 echo t | svn co $url -r $BRANCH $pkgsrc
pankso@161 252 else
pankso@161 253 echo t | svn co $url $pkgsrc
pankso@161 254 fi
pankso@146 255 create_tarball ;;
al@590 256 bzr*)
al@590 257 url=${WGET_URL#bzr|}
al@596 258 _ "Getting source from bazaar..."
al@590 259 cd $SRC
al@590 260 pkgsrc=${url#*:}
al@590 261 if [ "$BRANCH" ]; then
al@590 262 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
al@590 263 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
al@590 264 else
al@590 265 echo "bzr -Ossl.cert_reqs=none branch $url"
al@590 266 bzr -Ossl.cert_reqs=none branch $url
al@590 267 cd $pkgsrc && BRANCH=$(bzr revno) && cd ..
al@596 268 _ "Don't forget to add to receipt:"
al@596 269 echo 'BRANCH="'$BRANCH'"'; newline
al@590 270 fi
al@590 271 mv $pkgsrc $pkgsrc-$BRANCH
al@590 272 pkgsrc=$pkgsrc-$BRANCH
al@590 273 create_tarball ;;
pankso@9 274 *)
al@596 275 (newline; _ "ERROR: Unable to handle: \$WGET_URL"; newline) | \
pankso@9 276 tee -a $LOGS/$PACKAGE.log
pankso@9 277 exit 1 ;;
pankso@9 278 esac
pankso@1 279 }
pankso@1 280
pankso@9 281 # Extract source package.
pankso@1 282 extract_source() {
pankso@177 283 if [ ! -s "$SRC/$TARBALL" ]; then
pankso@177 284 local url
slaxemulator@458 285 url="$MIRROR_URL/sources/packages"
pankso@177 286 url=$url/${TARBALL:0:1}/$TARBALL
al@596 287 _ "Getting source from mirror: \$url"
al@596 288 busybox wget -c -P $SRC $url || _ "ERROR: wget \$url"
pankso@177 289 fi
al@596 290 _ "Extracting: \$TARBALL"
pankso@1 291 case "$TARBALL" in
pankso@120 292 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
pankso@178 293 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
pankso@1 294 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
pankso@42 295 *.tar) tar xf $SRC/$TARBALL ;;
pankso@42 296 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
pascal@597 297 *.xz) unxz -c $SRC/$TARBALL | tar xf - || tar xf $SRC/$TARBALL 2>/dev/null;;
pankso@42 298 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
pankso@42 299 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
pankso@238 300 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
pankso@191 301 *) cp $SRC/$TARBALL $(pwd) ;;
pankso@1 302 esac
pankso@1 303 }
pankso@1 304
pankso@9 305 # Display cooked package summary.
pankso@1 306 summary() {
pankso@1 307 cd $WOK/$pkg
slaxemulator@499 308 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
slaxemulator@499 309 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
slaxemulator@499 310 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}')
pankso@44 311 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
slaxemulator@499 312 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
slaxemulator@499 313 [ "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
al@596 314 cookdate=$(date "$(_ '+%Y-%m-%d %H:%M')")
pankso@101 315 sec=$time
pascal@280 316 div=$(( ($time + 30) / 60))
al@596 317 # L10n: 'm' is for minutes (approximate cooking time)
al@596 318 min=$(_n "~ \${div}m"); [ "$div" = 0 ] && min=""
al@596 319 _ "Summary for: \$PACKAGE \$VERSION"
pankso@1 320 separator
al@596 321 # L10n: keep the same width of translations to get a consistent view
al@596 322 [ "$srcdir" ] && _ "Source dir : \$srcdir"
al@596 323 [ "$TARBALL" ] && _ "Src file : \$TARBALL"
al@596 324 [ "$srcsize" ] && _ "Src size : \$srcsize"
al@596 325 [ "$prod" ] && _ "Produced : \$prod"
al@596 326 _ "Packed : \$fs"
al@596 327 _ "Compressed : \$size"
al@596 328 _ "Files : \$files"
al@596 329 # L10n: 's' is for seconds (cooking time)
al@596 330 _ "Cook time : \${sec}s \$min"
al@596 331 _ "Cook date : \$cookdate"
al@596 332 _ "Host arch : \$ARCH"
al@596 333 separator
pankso@1 334 }
pankso@1 335
paul@62 336 # Display debugging error info.
pankso@15 337 debug_info() {
al@596 338 newline; _ "Debug information"; separator
al@596 339 # L10n: specify your format of date and time (to help: man date)
al@596 340 # L10n: not bad one is '+%x %R'
al@596 341 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
al@596 342 _ "Cook date: \$datenow"
al@596 343 # L10n: Please, translate all messages beginning with ERROR in a same way
al@596 344 lerror=$(_n "ERROR")
pankso@76 345 for error in \
al@596 346 ERROR $lerror "No package" "cp: can't" "can't open" "can't cd" \
pascal@473 347 "error:" "fatal error:" "undefined reference to" \
pascal@508 348 "Unable to connect to" "link: cannot find the library" \
pascal@508 349 "CMake Error"
pankso@34 350 do
pankso@34 351 fgrep "$error" $LOGS/$pkg.log
pankso@34 352 done
al@596 353 separator; newline
pankso@15 354 }
pankso@15 355
pankso@1 356 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@1 357 # so some packages need to copy these files with the receipt and genpkg_rules.
slaxemulator@500 358 copy_generic_files()
slaxemulator@500 359 {
pankso@1 360 # $LOCALE is set in cook.conf
slaxemulator@500 361 if [ "$LOCALE" -a "$WANTED" = "" ]; then
pankso@260 362 if [ -d "$install/usr/share/locale" ]; then
pankso@1 363 mkdir -p $fs/usr/share/locale
pankso@1 364 for i in $LOCALE
pankso@1 365 do
pankso@260 366 if [ -d "$install/usr/share/locale/$i" ]; then
pankso@260 367 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
pankso@1 368 fi
pankso@1 369 done
pankso@1 370 fi
pankso@1 371 fi
pankso@1 372
pankso@1 373 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
pankso@1 374 if [ "$GENERIC_PIXMAPS" != "no" ]; then
pankso@260 375 if [ -d "$install/usr/share/pixmaps" ]; then
pankso@1 376 mkdir -p $fs/usr/share/pixmaps
slaxemulator@500 377 if [ -f "$install/usr/share/pixmaps/$PACKAGE.png" ]; then
slaxemulator@500 378 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
slaxemulator@500 379 $fs/usr/share/pixmaps
slaxemulator@500 380 elif [ -f "$install/usr/share/pixmaps/$PACKAGE.xpm" ]; then
slaxemulator@500 381 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
slaxemulator@500 382 $fs/usr/share/pixmaps
slaxemulator@500 383 fi
pankso@1 384 fi
pankso@1 385
pankso@1 386 # Custom or homemade PNG pixmap can be in stuff.
pankso@1 387 if [ -f "$stuff/$PACKAGE.png" ]; then
pankso@1 388 mkdir -p $fs/usr/share/pixmaps
pankso@1 389 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@1 390 fi
pankso@1 391 fi
pankso@1 392
pankso@1 393 # Desktop entry (.desktop).
erjo@284 394 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
erjo@284 395 if [ "$GENERIC_MENUS" != "no" ]; then
erjo@284 396 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
slaxemulator@500 397 mkdir -p $fs/usr/share
erjo@284 398 cp -a $install/usr/share/applications $fs/usr/share
erjo@284 399 fi
pankso@1 400 fi
pankso@1 401
pankso@1 402 # Homemade desktop file(s) can be in stuff.
pankso@1 403 if [ -d "$stuff/applications" ]; then
pankso@1 404 mkdir -p $fs/usr/share
pankso@1 405 cp -a $stuff/applications $fs/usr/share
pankso@1 406 fi
pankso@1 407 if [ -f "$stuff/$PACKAGE.desktop" ]; then
pankso@1 408 mkdir -p $fs/usr/share/applications
pankso@1 409 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@1 410 fi
slaxemulator@500 411
slaxemulator@500 412 # Add custom licenses
slaxemulator@500 413 if [ -d "$stuff/licenses" ]; then
slaxemulator@500 414 mkdir -p $fs/usr/share/licenses
slaxemulator@500 415 cp -a $stuff/licenses $fs/usr/share/licenses/$PACKAGE
slaxemulator@500 416 fi
pankso@1 417 }
pankso@1 418
al@596 419 # Find and strip: --strip-all (-s) or --strip-debug on static libs as well
pankso@415 420 # as removing uneeded files like in Python packages. Cross compiled binaries
pankso@415 421 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
pankso@421 422 strip_package() {
pankso@415 423 case "$ARCH" in
pankso@415 424 arm|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
pankso@415 425 *) export STRIP=strip ;;
pankso@415 426 esac
al@596 427 _n "Executing strip on all files..."
pankso@1 428 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@1 429 do
pankso@1 430 if [ -d "$dir" ]; then
pankso@414 431 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
pankso@1 432 fi
pankso@1 433 done
pankso@414 434 find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
pankso@414 435 find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
pankso@1 436 status
pankso@67 437
pankso@117 438 # Remove Python .pyc and .pyo from packages.
pankso@150 439 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
al@596 440 _n "Removing Python compiled files..."
pankso@67 441 find $fs -type f -name "*.pyc" -delete 2>/dev/null
pankso@67 442 find $fs -type f -name "*.pyo" -delete 2>/dev/null
pankso@117 443 status
pankso@117 444 fi
pankso@117 445
pankso@117 446 # Remove Perl perllocal.pod and .packlist from packages.
pankso@117 447 if echo "$DEPENDS" | fgrep -q "perl"; then
al@596 448 _n "Removing Perl compiled files..."
pankso@67 449 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
pankso@67 450 find $fs -type f -name ".packlist" -delete 2>/dev/null
pankso@67 451 status
pankso@67 452 fi
pankso@1 453 }
pankso@1 454
pankso@8 455 # Remove installed deps.
pankso@8 456 remove_deps() {
pankso@8 457 # Now remove installed build deps.
pankso@113 458 diff="$CACHE/installed.cook.diff"
pankso@113 459 if [ -s "$CACHE/installed.cook.diff" ]; then
pankso@113 460 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
pankso@113 461 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
al@596 462 _n "Build dependencies to remove: "; echo $nb $root
al@596 463 _n "Removing:"
pankso@8 464 for dep in $deps
pankso@8 465 do
pankso@8 466 echo -n " $dep"
pankso@426 467 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
pankso@8 468 done
al@596 469 newline; newline
pankso@113 470 # Keep the last diff for debug and info.
pankso@113 471 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
pankso@1 472 fi
pankso@1 473 }
pankso@1 474
pankso@1 475 # The main cook function.
pankso@1 476 cookit() {
al@596 477 _ "Cook: \$PACKAGE \$VERSION"; separator
pankso@1 478 set_paths
pankso@359 479
pankso@377 480 # Handle cross-tools.
pankso@359 481 case "$ARCH" in
pankso@359 482 arm|x86_64)
paul@387 483 # CROSS_COMPILE is used by at least Busybox and the kernel to set
al@596 484 # the cross-tools prefix. Sysroot is the root of our target arch
pankso@443 485 sysroot=$CROSS_TREE/sysroot
pankso@443 486 tools=$CROSS_TREE/tools
pankso@443 487 # Set root path when cross compiling. ARM tested but not x86_64
pankso@443 488 # When cross compiling we must install build deps in $sysroot.
pankso@443 489 arch="-${ARCH}"
pankso@443 490 root=$sysroot
al@596 491 _ "\$ARCH sysroot: \$sysroot"
al@596 492 _ "Adding \$tools/bin to PATH"
pankso@443 493 export PATH=$PATH:$tools/bin
pankso@446 494 export PKG_CONFIG_PATH=$sysroot/usr/lib/pkgconfig
pankso@421 495 export CROSS_COMPILE=${HOST_SYSTEM}-
al@596 496 _ "Using cross-tools: \$CROSS_COMPILE"
pankso@438 497 if [ "$ARCH" == "x86_64" ]; then
pankso@438 498 export CC="${HOST_SYSTEM}-gcc -m64"
pankso@438 499 export CXX="${HOST_SYSTEM}-g++ -m64"
pankso@438 500 else
pankso@438 501 export CC=${HOST_SYSTEM}-gcc
pankso@438 502 export CXX=${HOST_SYSTEM}-g++
pankso@438 503 fi
pankso@377 504 export AR=${HOST_SYSTEM}-ar
pankso@377 505 export AS=${HOST_SYSTEM}-as
pankso@377 506 export RANLIB=${HOST_SYSTEM}-ranlib
pankso@377 507 export LD=${HOST_SYSTEM}-ld
pankso@443 508 export STRIP=${HOST_SYSTEM}-strip ;;
pankso@359 509 esac
pankso@359 510
pankso@9 511 [ "$QA" ] && receipt_quality
pankso@44 512 cd $pkgdir
pankso@33 513 rm -rf install taz source
pankso@1 514
pankso@1 515 # Disable -pipe if less than 512Mb free RAM.
pankso@1 516 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
pankso@1 517 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
al@596 518 _ "Disabling -pipe compile flag: \$free RAM"
pankso@1 519 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
pankso@47 520 CXXFLAGS="${CXXFLAGS/-pipe}" && \
pankso@47 521 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
pankso@1 522 fi
pankso@1 523 unset free
pankso@1 524
pankso@232 525 # Export flags and path to be used by make and receipt.
pankso@44 526 DESTDIR=$pkgdir/install
al@596 527 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
pankso@232 528 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
pankso@358 529 #LDFLAGS
pankso@1 530
pankso@126 531 # Check for build deps and handle implicit depends of *-dev packages
pankso@126 532 # (ex: libusb-dev :: libusb).
pankso@215 533 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
pankso@215 534 touch $CACHE/installed.local $CACHE/installed.web
al@596 535 [ "$BUILD_DEPENDS" ] && _ "Checking build dependencies..."
al@596 536 [ "$root" ] && _ "Using packages DB: \${root}\$DB"
pankso@1 537 for dep in $BUILD_DEPENDS
pankso@1 538 do
pankso@126 539 implicit=${dep%-dev}
pankso@131 540 for i in $dep $implicit
pankso@126 541 do
pankso@426 542 if [ ! -f "${root}$INSTALLED/$i/receipt" ]; then
paul@174 543 # Try local package first. In some cases implicit doesn't exist, ex:
paul@174 544 # libboost-dev exists but not libboost, so check if we got vers.
pankso@173 545 unset vers
pascal@343 546 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
pankso@435 547 # We may have a local package.
pankso@435 548 if [ ! "$vers" ]; then
pankso@435 549 vers=$(grep "^$i |" $PKGS/packages.desc | awk '{print $3}')
pankso@435 550 fi
pankso@435 551 debug "bdep: $i version: $vers"
pankso@426 552 if [ -f "$PKGS/$i-${vers}${arch}.tazpkg" ]; then
pankso@426 553 echo $i-${vers}${arch}.tazpkg >> $CACHE/installed.local
pankso@126 554 else
paul@227 555 # Priority to package version in wok (maybe more up-to-date)
paul@227 556 # than the mirrored one.
pankso@173 557 if [ "$vers" ]; then
pankso@426 558 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
pankso@215 559 echo $i >> $CACHE/installed.web
pankso@198 560 else
paul@211 561 # So package exists in wok but not available.
al@596 562 _ "Missing dep (wok/pkg): \$i \$vers"
pankso@215 563 echo $i >> $CACHE/missing.dep
pankso@198 564 fi
pankso@225 565 else
pankso@435 566 # Package is not in wok but may be in online repo.
pankso@426 567 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
pankso@225 568 echo $i >> $CACHE/installed.web
pankso@225 569 else
al@596 570 _ "ERROR: unknown dep \$i"; exit 1
pankso@225 571 fi
pankso@173 572 fi
pankso@126 573 fi
pankso@1 574 fi
pankso@126 575 done
pankso@1 576 done
pankso@225 577
pankso@215 578 # Get the list of installed packages
pankso@426 579 cd ${root}$INSTALLED && ls -1 > $CACHE/installed.list
pankso@358 580
al@596 581 # Have we a missing build dep to cook?
pankso@215 582 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
al@596 583 _ "Auto cook config is set: AUTO_COOK"
pankso@204 584 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
pankso@224 585 for i in $(uniq $CACHE/missing.dep)
pankso@204 586 do
al@596 587 (_ "Building dep (wok/pkg) : \$i \$vers") | \
pankso@204 588 tee -a $LOGS/$PACKAGE.log.$$
al@596 589 # programmers: next two messages are exact copy from remove_deps()
al@596 590 togrep1=$(_n "Build dependencies to remove: ")
al@596 591 togrep2=$(_n "Removing:")
al@596 592 cook $i || (_ "ERROR: can't cook dep '\$i'" && newline && \
al@596 593 fgrep $togrep1 $LOGS/$i.log && \
al@596 594 fgrep $togrep2 $LOGS/$i.log && newline) | \
pankso@204 595 tee -a $LOGS/$PACKAGE.log.$$ && break
pankso@204 596 done
pankso@215 597 rm -f $CACHE/missing.dep
pankso@204 598 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
pankso@204 599 fi
pankso@358 600
paul@211 601 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
paul@211 602 # is enabled and cook fails we have ERROR in log, if no auto cook we have
pankso@204 603 # missing dep in cached file.
al@596 604 lerror=$(_n "ERROR")
al@596 605 if fgrep -q $lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
pankso@215 606 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
al@596 607 _ "ERROR: missing dep \$nb" && exit 1
pankso@202 608 fi
pankso@358 609
pankso@426 610 # Install local packages: package-version${arch}
pankso@215 611 cd $PKGS
pankso@224 612 for i in $(uniq $CACHE/installed.local)
pankso@215 613 do
al@596 614 _ "Installing dep (pkg/local): \$i"
pankso@423 615 tazpkg install $i --root=$root >/dev/null
pankso@215 616 done
pankso@358 617
pankso@215 618 # Install web or cached packages (if mirror is set to $PKGS we only
pankso@215 619 # use local packages).
pankso@224 620 for i in $(uniq $CACHE/installed.web)
pankso@215 621 do
al@596 622 _ "Installing dep (web/cache): \$i"
pankso@423 623 tazpkg get-install $i --root=$root >/dev/null
pankso@215 624 done
pankso@358 625
pankso@215 626 # If a cook failed deps are removed.
pankso@426 627 cd ${root}$INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
pankso@215 628 [ ! -s "installed.cook.diff" ] && \
pankso@215 629 busybox diff installed.list installed.cook > installed.cook.diff
pankso@215 630 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
pankso@202 631
pankso@1 632 # Get source tarball and make sure we have source dir named:
paul@62 633 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
paul@62 634 # tarball if it exists.
pankso@1 635 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
pankso@1 636 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
pankso@10 637 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
pankso@190 638 LZMA_SRC=""
pankso@1 639 else
pankso@1 640 get_source || exit 1
pankso@1 641 fi
pankso@1 642 fi
pankso@242 643 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
pankso@1 644 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
pascal@268 645 if ! extract_source ; then
pascal@268 646 get_source
pascal@268 647 extract_source || exit 1
pascal@268 648 fi
pankso@190 649 if [ "$LZMA_SRC" ]; then
pankso@190 650 cd $pkgdir/source
pankso@190 651 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
pankso@190 652 mv tmp tmp-1 && mkdir tmp
pankso@190 653 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
pankso@190 654 fi
pankso@190 655 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
pankso@358 656 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
pankso@190 657 fi
pankso@190 658 fi
pankso@190 659 cd $pkgdir/source/tmp
paul@62 660 # Some archives are not well done and don't extract to one dir (ex lzma).
pankso@57 661 files=$(ls | wc -l)
pankso@244 662 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
pankso@244 663 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
pankso@244 664 mv * ../$PACKAGE-$VERSION/$TARBALL
pankso@57 665 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
pankso@57 666 mv * ../$PACKAGE-$VERSION
pankso@1 667 cd .. && rm -rf tmp
pankso@1 668 fi
pankso@1 669
pankso@9 670 # Execute receipt rules.
pankso@44 671 if grep -q ^compile_rules $receipt; then
al@596 672 _ "Executing: compile_rules"
pankso@352 673 echo "CFLAGS : $CFLAGS"
pankso@358 674 #echo "LDFLAGS : $LDFLAGS"
pankso@55 675 [ -d "$src" ] && cd $src
pankso@97 676 compile_rules $@ || exit 1
pankso@10 677 # Stay compatible with _pkg
pankso@55 678 [ -d "$src/_pkg" ] && mv $src/_pkg $install
pankso@9 679 # QA: compile_rules success so valid.
pankso@9 680 mkdir -p $install
pankso@9 681 else
al@596 682 # QA: no compile_rules so no error, valid.
pankso@9 683 mkdir -p $install
pankso@1 684 fi
al@596 685 separator; newline
pankso@360 686
pankso@360 687 # Execute testsuite.
pankso@360 688 if grep -q ^testsuite $receipt; then
al@596 689 _ "Running testsuite"; separator
pankso@360 690 testsuite $@ || exit 1
al@596 691 separator; newline
pankso@360 692 fi
pankso@1 693 }
pankso@1 694
pankso@1 695 # Cook quality assurance.
pankso@1 696 cookit_quality() {
pankso@9 697 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
al@596 698 _ "ERROR: cook failed" | tee -a $LOGS/$pkg.log
pankso@9 699 fi
pankso@9 700 # ERROR can be echoed any time in cookit()
al@596 701 lerror=$(_n "ERROR")
al@596 702 if grep -Eq "($lerror|undefined reference to)" $LOGS/$pkg.log; then
pankso@17 703 debug_info | tee -a $LOGS/$pkg.log
pankso@33 704 rm -f $command && exit 1
pankso@1 705 fi
pankso@1 706 }
pankso@1 707
pankso@16 708 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
paul@62 709 # but it doesn't handle EXTRAVERSION.
pankso@1 710 packit() {
pankso@1 711 set_paths
pankso@359 712
pankso@359 713 # Handle cross compilation
pankso@359 714 case "$ARCH" in
pankso@428 715 arm|x86_64) arch="-$ARCH" ;;
pankso@359 716 esac
pankso@359 717
al@596 718 _ "Pack: \$PACKAGE \${VERSION}\${arch}"; separator
pankso@359 719
pankso@44 720 if grep -q ^genpkg_rules $receipt; then
al@596 721 _ "Executing: genpkg_rules"
pankso@259 722 set -e && cd $pkgdir && mkdir -p $fs
al@596 723 genpkg_rules || (newline; _ "ERROR: genpkg_rules failed"; newline) >> \
pankso@234 724 $LOGS/$pkg.log
pankso@241 725 else
al@596 726 _ "No packages rules: meta package"
pankso@241 727 mkdir -p $fs
pankso@16 728 fi
pankso@98 729
pankso@98 730 # First QA check to stop now if genpkg_rules failed.
al@596 731 lerror=$(_n "ERROR")
al@596 732 if fgrep -q $lerror $LOGS/$pkg.log; then
pankso@98 733 exit 1
pankso@98 734 fi
pankso@358 735
pankso@44 736 cd $taz
pankso@1 737 for file in receipt description.txt
pankso@1 738 do
pankso@1 739 [ ! -f "../$file" ] && continue
al@596 740 _n "Copying \$file..."
pankso@1 741 cp -f ../$file $pack && chown 0.0 $pack/$file && status
pankso@1 742 done
pankso@119 743 copy_generic_files
pankso@358 744
paul@62 745 # Create files.list with redirecting find output.
al@596 746 _n "Creating the list of files..."
al@596 747 cd $fs
pankso@16 748 find . -type f -print > ../files.list
pankso@16 749 find . -type l -print >> ../files.list
pankso@16 750 cd .. && sed -i s/'^.'/''/ files.list
pankso@16 751 status
pankso@43 752
pankso@119 753 # Strip and stuff files.
pankso@43 754 strip_package
pankso@43 755
pankso@43 756 # Md5sum of files.
al@596 757 _n "Creating md5sum of files..."
pankso@16 758 while read file; do
pankso@16 759 [ -L "fs$file" ] && continue
pankso@16 760 [ -f "fs$file" ] || continue
pankso@16 761 case "$file" in
pankso@232 762 /lib/modules/*/modules.*|*.pyc) continue ;;
pankso@16 763 esac
pankso@16 764 md5sum "fs$file" | sed 's/ fs/ /'
pankso@16 765 done < files.list > md5sum
pankso@16 766 status
pankso@16 767 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
pankso@16 768 description.txt 2> /dev/null | awk \
pankso@16 769 '{ sz=$1 } END { print sz }')
pankso@358 770
pankso@16 771 # Build cpio archives.
al@596 772 _n "Compressing the fs..."
pankso@16 773 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
pankso@16 774 rm -rf fs
pankso@16 775 status
pankso@16 776 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
pankso@16 777 md5sum description.txt 2> /dev/null | awk \
pankso@16 778 '{ sz=$1 } END { print sz }')
al@596 779 _n "Updating receipt sizes..."
pankso@16 780 sed -i s/^PACKED_SIZE.*$// receipt
pankso@16 781 sed -i s/^UNPACKED_SIZE.*$// receipt
pankso@16 782 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pankso@16 783 status
pankso@16 784
pankso@16 785 # Set extra version.
pankso@16 786 if [ "$EXTRAVERSION" ]; then
al@596 787 _n "Updating receipt EXTRAVERSION: \$EXTRAVERSION"
pankso@16 788 sed -i s/^EXTRAVERSION.*$// receipt
pankso@16 789 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
pankso@16 790 status
pankso@16 791 fi
pankso@16 792
pankso@16 793 # Compress.
al@596 794 _n "Creating full cpio archive..."
pankso@16 795 find . -print | cpio -o -H newc --quiet > \
pankso@428 796 ../$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg
pankso@16 797 status
al@596 798 _n "Restoring original package tree..."
pankso@16 799 unlzma -c fs.cpio.lzma | cpio -idm --quiet
pankso@16 800 status
pankso@16 801 rm fs.cpio.lzma && cd ..
pankso@43 802
pankso@43 803 # QA and give info.
pankso@43 804 tazpkg=$(ls *.tazpkg)
pankso@43 805 packit_quality
al@596 806 separator; _ "Package: \$tazpkg"; newline
pankso@1 807 }
pankso@1 808
paul@62 809 # Verify package quality and consistency.
pankso@8 810 packit_quality() {
al@596 811 #gettext "QA: checking for broken link..."
pankso@157 812 #link=$(find $fs/usr -type l -follow)
pankso@157 813 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
pankso@157 814 #status
pankso@358 815
pankso@142 816 # Exit if any error found in log file.
al@596 817 lerror=$(_n "ERROR")
al@596 818 if fgrep -q $lerror $LOGS/$pkg.log; then
pankso@32 819 rm -f $command && exit 1
pankso@8 820 fi
pankso@358 821
al@596 822 _n "QA: checking for empty package..."
pankso@45 823 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
pankso@259 824 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
al@596 825 newline; _ "ERROR: empty package"
pankso@32 826 rm -f $command && exit 1
pankso@8 827 else
pankso@134 828 # Ls sort by name so the first file is the one we want.
pankso@136 829 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
pankso@134 830 status
pankso@154 831 if [ -f "$old" ]; then
al@596 832 old_pkg=$(basename $old)
al@596 833 _n "Removing old: \$old_pkg"
pankso@135 834 rm -f $old && status
pankso@154 835 fi
pankso@134 836 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
pankso@11 837 sed -i /^${pkg}$/d $broken
pankso@265 838 #gettext "Removing source tree..."
pankso@265 839 #rm -f $WOK/$pkg/source && status
pankso@8 840 fi
pankso@8 841 }
pankso@8 842
pankso@427 843 # Tic tac, tic tac...
pankso@421 844 tac() {
pascal@285 845 sed '1!G;h;$!d' $1
pascal@285 846 }
pascal@285 847
pankso@428 848 # Install package on --install or update the chroot.
pankso@428 849 install_package() {
pankso@428 850 case "$ARCH" in
pankso@428 851 arm|x86_64)
pankso@428 852 arch="-${ARCH}"
pankso@443 853 root=$CROSS_TREE/sysroot ;;
pankso@428 854 esac
pankso@428 855 # Install package if requested but skip install if target host doesn't
pankso@428 856 # match build system or it will break the build chroot.
pankso@428 857 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
pankso@428 858 if [ "$inst" ] && [ "$build" == "$ARCH" ]; then
pankso@428 859 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pankso@428 860 cd $PKGS && tazpkg install \
pankso@428 861 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
pankso@428 862 else
al@596 863 _ "Unable to install package, build has failed."; newline
pankso@428 864 exit 1
pankso@428 865 fi
pankso@428 866 fi
pankso@428 867
pankso@428 868 # Install package if part of the chroot to keep env up-to-date.
pankso@428 869 if [ -d "${root}$INSTALLED/$pkg" ]; then
pankso@428 870 . /etc/slitaz/cook.conf
pankso@428 871 . $WOK/$pkg/taz/$pkg-*/receipt
al@596 872 _ "Updating \$ARCH chroot environment..."
al@596 873 _ "Updating chroot: \$pkg (\${VERSION}\${EXTRAVERSION}\${arch})" | log
pankso@428 874 cd $PKGS && tazpkg install \
pankso@428 875 $pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
pankso@428 876 --forced --root=$root
pankso@428 877 fi
pankso@428 878 }
pankso@428 879
pascal@285 880 # Launch the cook command into a chroot jail protected by aufs.
pascal@285 881 # The current filesystems are used read-only and updates are
pascal@285 882 # stored in a separate branch.
pascal@285 883 try_aufs_chroot() {
pascal@285 884
pascal@286 885 base=/dev/shm/aufsmnt$$
pascal@286 886
al@596 887 # Can we setup the chroot? Is it already done?
pascal@292 888 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
pascal@594 889 grep -q ^AUFS_NOT_RAMFS $receipt && base=/mnt/aufsmnt$$
pascal@285 890 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
pascal@285 891 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
pascal@286 892 mkdir ${base}root ${base}rw || return
pascal@285 893
al@596 894 _ "Setup aufs chroot..."
pascal@285 895
pascal@285 896 # Sanity check
pascal@286 897 for i in / /proc /sys /dev/shm /home ; do
pascal@285 898 case " $AUFS_MOUNTS " in
pascal@285 899 *\ $i\ *) ;;
pascal@285 900 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
pascal@285 901 esac
pascal@285 902 done
pascal@285 903 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
pascal@285 904 mount --bind $mnt ${base}root$mnt
pascal@285 905 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
al@596 906 _ "Aufs mountage failure"
slaxemulator@519 907 umount ${base}root
slaxemulator@519 908 rmdir ${base}*
slaxemulator@519 909 return
pascal@285 910 fi
pascal@285 911 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
pascal@285 912 done
pascal@285 913
pascal@285 914 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
pascal@285 915 status=$?
pascal@285 916
al@596 917 _ "Leaving aufs chroot..."
pascal@285 918 tac ${base}rw/aufs-umount.sh | sh
pascal@285 919 rm -rf ${base}rw
pascal@285 920 umount ${base}root
pascal@285 921 rmdir $base*
pankso@428 922 # Dont install pkg twice... it's done after
pankso@428 923 #install_package
pankso@358 924 exit $status
pascal@285 925 }
pascal@285 926
paul@387 927 # Create a XML feed for freshly built packages.
pankso@310 928 gen_rss() {
pankso@310 929 pubdate=$(date "+%a, %d %b %Y %X")
pankso@310 930 cat > $FEEDS/$pkg.xml << EOT
pankso@310 931 <item>
pankso@310 932 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
pankso@310 933 <link>${COOKER_URL}?pkg=$PACKAGE</link>
pankso@310 934 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
pankso@310 935 <pubDate>$pubdate</pubDate>
pankso@310 936 <description>$SHORT_DESC</description>
pankso@310 937 </item>
pankso@310 938 EOT
pankso@310 939 }
pankso@310 940
pascal@576 941 # Truncate stdout log file to $1 Mb.
pascal@576 942 loglimit()
pascal@576 943 {
pascal@593 944 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
pascal@593 945 tee /dev/stderr | dd bs=1k count=$((1024*${1:-$DEFAULT_LOG_LIMIT})) conv=noerror 2> /dev/null
pascal@593 946 else
pascal@593 947 tee /dev/stderr
pascal@593 948 fi
pascal@576 949 }
pascal@576 950
pankso@1 951 #
pankso@1 952 # Commands
pankso@1 953 #
pankso@1 954
pankso@1 955 case "$1" in
pankso@32 956 usage|help|-u|-h)
pankso@1 957 usage ;;
pankso@1 958 list-wok)
al@596 959 newline; _ "List of packages in: \$WOK"; separator
pankso@1 960 cd $WOK && ls -1
pankso@1 961 separator
al@596 962 pkg_total=$(ls | wc -l)
al@596 963 _ "Packages: \$pkg_total"; newline ;;
pankso@378 964 activity)
pankso@378 965 cat $activity ;;
pankso@69 966 search)
pankso@69 967 # Just a simple search function, we dont need more actually.
pankso@69 968 query="$2"
al@596 969 newline; _ "Search results for: \$query"; separator
pankso@69 970 cd $WOK && ls -1 | grep "$query"
al@596 971 separator; newline ;;
pankso@1 972 setup)
pankso@1 973 # Setup a build environment
pankso@1 974 check_root
al@596 975 _ "Cook: setup environment" | log
al@596 976 newline; _ "Setting up your environment"; separator
al@596 977 cd $SLITAZ
pankso@52 978 init_db_files
al@596 979 _ "Checking for packages to install..."
pankso@397 980 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
pankso@397 981 # ARCH-setup or 'cross check-env' should be used before: cook setup
pankso@397 982 case "$ARCH" in
pankso@421 983 arm|x86_64)
pankso@397 984 if [ ! -x "/usr/bin/cross" ]; then
al@596 985 _ "ERROR: cross is not installed"
pankso@397 986 exit 1
pankso@397 987 fi
al@596 988 _ "Using config file: /etc/slitaz/cross.conf"
pankso@397 989 . /etc/slitaz/cross.conf ;;
pankso@397 990 esac
pankso@397 991 for pkg in $SETUP_PKGS; do
pankso@397 992 if [ "$forced" ]; then
pankso@421 993 tazpkg -gi $pkg --forced
pankso@397 994 else
pankso@407 995 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
pankso@397 996 fi
pankso@397 997 done
pankso@1 998
pankso@1 999 # Handle --options
pankso@1 1000 case "$2" in
pankso@397 1001 --wok)
pankso@230 1002 hg clone $WOK_URL wok || exit 1 ;;
pankso@230 1003 --stable)
pankso@230 1004 hg clone $WOK_URL-stable wok || exit 1 ;;
pankso@230 1005 --undigest)
pankso@230 1006 hg clone $WOK_URL-undigest wok || exit 1 ;;
pankso@397 1007 --tiny)
pankso@397 1008 hg clone $WOK_URL-tiny wok || exit 1 ;;
pankso@1 1009 esac
pankso@1 1010
pankso@1 1011 # SliTaz group and permissions
pankso@1 1012 if ! grep -q ^slitaz /etc/group; then
al@596 1013 _ "Adding group: slitaz"
pankso@1 1014 addgroup slitaz
pankso@1 1015 fi
al@596 1016 _ "Setting permissions for slitaz group..."
pascal@277 1017 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
pascal@277 1018 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
al@596 1019 separator; _ "All done, ready to cook packages :-)"; newline ;;
pankso@395 1020 *-setup)
pankso@395 1021 # Setup for cross compiling.
pankso@395 1022 arch=${1%-setup}
pankso@397 1023 check_root
al@596 1024 _ "Cook: setup \$arch cross environment" | log
al@596 1025 newline; boldify $(_n "Setting up your \$arch cross environment"); separator
pankso@397 1026 init_db_files
pankso@359 1027 sed -i \
pankso@396 1028 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
pankso@443 1029 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
pankso@359 1030 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
pankso@395 1031 /etc/slitaz/cook.conf
pankso@395 1032 case "$arch" in
pankso@395 1033 arm)
pankso@395 1034 sed -i \
pankso@443 1035 -e s'/CFLAGS=.*/CFLAGS="-march=armv6 -O2"/' \
pankso@395 1036 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
pankso@397 1037 -e s'/xorg-dev/""/' \
pankso@395 1038 /etc/slitaz/cook.conf ;;
pankso@395 1039 x86_64)
pankso@395 1040 sed -i \
pankso@395 1041 -e s'/CFLAGS=.*/CFLAGS=""/' \
pankso@395 1042 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux/' \
pankso@395 1043 /etc/slitaz/cook.conf ;;
pankso@395 1044 esac
pankso@359 1045 . /etc/slitaz/cook.conf
pankso@443 1046 sysroot=$CROSS_TREE/sysroot
pankso@443 1047 tools=/cross/$arch/tools
pankso@443 1048 root=$sysroot
pankso@443 1049 CC=$tools/bin/${HOST_SYSTEM}-gcc
al@596 1050 # L10n: keep the same width of translations to get a consistent view
al@596 1051 _ "Target arch : \$ARCH"
al@596 1052 _ "Configure args : \$CONFIGURE_ARGS"
al@596 1053 _ "Arch sysroot : \$sysroot"
al@596 1054 _ "Tools prefix : \$tools/bin"
paul@455 1055 # Tell the packages manager where to find packages.
al@596 1056 _ "Packages DB : \${root}\$DB"
pankso@429 1057 mkdir -p ${root}$INSTALLED
pankso@426 1058 cd ${root}$DB && rm -f *.bak
pankso@426 1059 for list in packages.list packages.desc packages.equiv packages.md5
pankso@426 1060 do
pankso@426 1061 rm -f $list && ln -s $SLITAZ/packages/$list $list
pankso@426 1062 done
pankso@429 1063 # We must have the cross compiled glibc-base installed or default
pankso@429 1064 # i486 package will be used as dep by tazpkg and then break the
pankso@429 1065 # cross environment
pankso@429 1066 if [ ! -f "${root}$INSTALLED/glibc-base/receipt" ]; then
al@596 1067 colorize 36 $(_ "WARNING: (e)glibc-base is not installed in sysroot")
pankso@429 1068 fi
pankso@426 1069 # Show GCC version or warn if not yet compiled.
pankso@406 1070 if [ -x $CC ]; then
al@596 1071 _ "Cross compiler : \${HOST_SYSTEM}-gcc"
pankso@359 1072 else
al@596 1073 colorize 36 $(_ "C compiler is missing: \${HOST_SYSTEM}-gcc")
al@596 1074 _ "Run 'cross compile' to cook a toolchain"
pankso@397 1075 fi
al@596 1076 separator; newline ;;
pankso@9 1077 test)
pankso@9 1078 # Test a cook environment.
al@596 1079 _ "Cook test: testing the cook environment" | log
pankso@9 1080 [ ! -d "$WOK" ] && exit 1
pankso@9 1081 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
pankso@9 1082 cook cooktest ;;
pankso@1 1083 new)
pankso@1 1084 # Create the package folder and an empty receipt.
pankso@1 1085 pkg="$2"
pankso@1 1086 [ "$pkg" ] || usage
pankso@427 1087 newline
pankso@1 1088 if [ -d "$WOK/$pkg" ]; then
al@596 1089 _ "\$pkg package already exists."
al@596 1090 exit 1
pankso@1 1091 fi
al@596 1092 _n "Creating \$WOK/\$pkg"
pankso@1 1093 mkdir $WOK/$pkg && cd $WOK/$pkg && status
al@596 1094 _n "Preparing the package receipt..."
pankso@1 1095 cp $DATA/receipt .
pankso@1 1096 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
pankso@427 1097 status && newline
pankso@358 1098
pankso@196 1099 # Interactive mode, asking and seding.
pankso@196 1100 case "$3" in
paul@214 1101 --interactive|-x)
al@596 1102 _ "Entering interactive mode..."
paul@211 1103 separator
al@596 1104 _ "Package : \$pkg"
al@596 1105 _n "Version : " ; read answer
al@596 1106 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
al@596 1107 _n "Category : " ; read answer
al@596 1108 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
al@596 1109 # L10n: Short description
al@596 1110 _n "Short desc : " ; read answer
al@596 1111 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
al@596 1112 _n "Maintainer : " ; read answer
al@596 1113 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
al@596 1114 _n "License : " ; read answer
al@596 1115 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
al@596 1116 _n "Web site : " ; read answer
al@596 1117 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
pankso@427 1118 newline
pankso@196 1119 # Wget URL.
al@596 1120 _ "Wget URL to download source tarball."
al@596 1121 _n "Example : " ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
al@596 1122 _n "Wget url : " ; read answer
al@596 1123 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$answer\""# receipt
pankso@196 1124 # Ask for a stuff dir.
al@596 1125 _n "Do you need a stuff directory? (y/N) : " ; read answer
al@596 1126 if [ "$answer" = "y" ]; then
al@596 1127 _n "Creating the stuff directory..."
pankso@196 1128 mkdir $WOK/$pkg/stuff && status
pankso@196 1129 fi
pankso@196 1130 # Ask for a description file.
al@596 1131 _n "Are you going to write a description? (y/N) : " ; read answer
al@596 1132 if [ "$answer" = "y" ]; then
al@596 1133 _n "Creating the description.txt file..."
pankso@427 1134 newline > $WOK/$pkg/description.txt && status
pankso@196 1135 fi
al@596 1136 separator; _ "Receipt is ready to use."; newline ;;
pankso@196 1137 esac ;;
pankso@1 1138 list)
pankso@1 1139 # Cook a list of packages (better use the Cooker since it will order
pankso@1 1140 # packages before executing cook).
pankso@1 1141 check_root
al@596 1142 [ -z "$2" ] && (newline; _ "No list in argument."; newline) && exit 1
al@596 1143 list2=$2
al@596 1144 [ ! -f "$2" ] && (newline; _ "No list found: \$list2"; newline) && exit 1
al@596 1145 _ "Cook list starting: \$list2" | log
pankso@1 1146 for pkg in $(cat $2)
pankso@1 1147 do
pankso@1 1148 cook $pkg || broken
pankso@1 1149 done ;;
pankso@1 1150 clean-wok)
pankso@1 1151 check_root
al@596 1152 newline; _n "Cleaning all packages files..."
pankso@1 1153 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
al@596 1154 status; newline ;;
pankso@1 1155 clean-src)
pankso@1 1156 check_root
al@596 1157 newline; _n "Cleaning all packages sources..."
pankso@1 1158 rm -rf $WOK/*/source
al@596 1159 status; newline ;;
pankso@235 1160 pkgdb)
pankso@235 1161 # Create suitable packages list for TazPKG and only for built packages
pankso@235 1162 # as well as flavors files for TazLiTo. We dont need logs since we do it
paul@243 1163 # manually to ensure everything is fine before syncing the mirror.
pankso@239 1164 case "$2" in
pankso@239 1165 --flavors)
pankso@239 1166 continue ;;
pankso@239 1167 *)
pankso@240 1168 [ "$2" ] && PKGS="$2"
pankso@239 1169 [ ! -d "$PKGS" ] && \
al@596 1170 newline && _ "Packages directory doesn't exist" && \
al@596 1171 newline && exit 1 ;;
pankso@239 1172 esac
pankso@226 1173 time=$(date +%s)
pankso@239 1174 flavors=$SLITAZ/flavors
pankso@239 1175 live=$SLITAZ/live
pankso@235 1176 echo "cook:pkgdb" > $command
al@596 1177 _ "Cook pkgdb: Creating all packages lists" | log
al@596 1178 newline; _ "Creating lists for: \$PKGS"; separator
al@596 1179 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
al@596 1180 _ "Cook pkgdb started: \$datenow"
pankso@133 1181 cd $PKGS
pankso@192 1182 rm -f packages.*
al@596 1183 _ "Creating: packages.list"
pankso@85 1184 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
al@596 1185 _ "Creating: packages.md5"
pankso@1 1186 md5sum *.tazpkg > $PKGS/packages.md5
gokhlayeh@297 1187 md5sum packages.md5 | cut -f1 -d' ' > ID
al@596 1188 _ "Creating lists from: \$WOK"
pankso@1 1189 cd $WOK
pankso@1 1190 for pkg in *
pankso@1 1191 do
pankso@1 1192 unset_receipt
pankso@1 1193 . $pkg/receipt
pankso@1 1194 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
pascal@267 1195 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
pascal@274 1196 if [ -s $pkg/taz/*/receipt ]; then
pascal@274 1197 . $pkg/taz/*/receipt
pascal@274 1198 fi
pankso@192 1199 # packages.desc lets us search easily in DB
pankso@1 1200 cat >> $PKGS/packages.desc << EOT
pankso@235 1201 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
pankso@1 1202 EOT
pankso@192 1203 # packages.txt used by tazpkg and tazpkg-web also to provide
pankso@192 1204 # a human readable package list with version and description.
pankso@192 1205 cat >> $PKGS/packages.txt << EOT
pankso@192 1206 $PACKAGE
pankso@235 1207 ${VERSION}$EXTRAVERSION
pankso@235 1208 $SHORT_DESC
pankso@235 1209 $PACKED_SIZE ($UNPACKED_SIZE installed)
pankso@358 1210
pankso@192 1211 EOT
pankso@192 1212 # packages.equiv is used by tazpkg install to check depends.
pankso@1 1213 for i in $PROVIDE; do
pankso@1 1214 DEST=""
pankso@1 1215 echo $i | fgrep -q : && DEST="${i#*:}:"
pankso@1 1216 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
pankso@1 1217 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
pankso@1 1218 $PKGS/packages.equiv
pankso@1 1219 else
pankso@1 1220 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
pankso@1 1221 fi
pankso@1 1222 done
paul@197 1223 # files.list provides a list of all packages files.
pankso@194 1224 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
pankso@194 1225 $PKGS/files.list
pankso@1 1226 fi
pankso@1 1227 done
pankso@358 1228
pankso@213 1229 # Display list size.
al@596 1230 _ "Done: packages.desc"
al@596 1231 _ "Done: packages.txt"
al@596 1232 _ "Done: packages.equiv"
pankso@358 1233
pankso@194 1234 # files.list.lzma
al@596 1235 _ "Creating: files.list.lzma"
pankso@235 1236 cd $PKGS && lzma e files.list files.list.lzma
pankso@194 1237 rm -f files.list
pankso@358 1238
pankso@235 1239 # Display some info.
pankso@1 1240 separator
pankso@1 1241 nb=$(ls $PKGS/*.tazpkg | wc -l)
pankso@226 1242 time=$(($(date +%s) - $time))
al@596 1243 # L10n: 's' is for seconds (cooking time)
al@596 1244 _ "Packages: \$nb - Time: \${time}s"; newline
pankso@358 1245
paul@243 1246 # Create all flavors files at once. Do we really need code to monitor
al@596 1247 # flavors changes? Lets just build them with packages lists before
pankso@235 1248 # syncing the mirror.
pankso@239 1249 [ "$2" == "--flavors" ] || exit 1
al@596 1250 [ ! -d "$flavors" ] && (_ "Missing flavors: \$flavors"; newline) && exit 1
pankso@239 1251 [ -d "$live" ] || mkdir -p $live
al@596 1252 _ "Creating flavors files in: \$live"
al@596 1253 _ "Cook pkgdb: Creating all flavors" | log
pankso@235 1254 separator
al@596 1255 _ "Recharging lists to use latest packages..."
pankso@329 1256 tazpkg recharge >/dev/null 2>/dev/null
pankso@358 1257
pankso@235 1258 # We need a custom tazlito config to set working dir to /home/slitaz.
pankso@235 1259 if [ ! -f "$live/tazlito.conf" ]; then
al@596 1260 _ "Creating configuration file: tazlito.conf"
pankso@235 1261 cp /etc/tazlito/tazlito.conf $live
pankso@235 1262 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
pankso@235 1263 $live/tazlito.conf
pankso@235 1264 fi
pankso@235 1265
pankso@239 1266 # Update Hg flavors repo and pack.
pankso@239 1267 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
pankso@358 1268
pankso@239 1269 cd $live
al@596 1270 _ "Starting to generate flavors..."
pankso@235 1271 rm -f flavors.list *.flavor
pankso@235 1272 for i in $flavors/*
pankso@235 1273 do
pankso@235 1274 fl=$(basename $i)
al@596 1275 _ "Packing flavor: \$fl"
pankso@235 1276 tazlito pack-flavor $fl >/dev/null || exit 1
pankso@235 1277 tazlito show-flavor $fl --brief --noheader 2> \
pankso@235 1278 /dev/null >> flavors.list
pankso@235 1279 done
pankso@237 1280 cp -f $live/*.flavor $live/flavors.list $PKGS
al@596 1281 separator
al@596 1282 fl_size=$(du -sh $live | awk '{print $1}')
al@596 1283 _ "Flavors size: \$fl_size"; newline
al@596 1284 rm -f $command
al@596 1285 separator
al@596 1286 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
al@596 1287 _ "Cook pkgdb end: \$datenow" ;;
pankso@1 1288 *)
pankso@1 1289 # Just cook and generate a package.
pankso@1 1290 check_root
pankso@1 1291 time=$(date +%s)
pankso@1 1292 pkg="$1"
pankso@1 1293 [ -z "$pkg" ] && usage
pankso@44 1294 receipt="$WOK/$pkg/receipt"
pankso@427 1295 check_pkg_in_wok && newline
pankso@47 1296
pankso@377 1297 unset inst
pankso@377 1298 unset_receipt
pankso@377 1299 . $receipt
pankso@377 1300
pankso@377 1301 # Handle cross compilation.
pankso@377 1302 #
pankso@377 1303 # CROSS_NOTE: Actually we are running an ARM cooker but running
pankso@377 1304 # the cooker and build each commit in wok is not possible since
pankso@377 1305 # we dont cook the full wok for this arch. For ARM we need a set
paul@387 1306 # of packages to handle a touch screen desktop, servers but not
al@596 1307 # erlang.
pankso@377 1308 #
pankso@377 1309 # The temporary solution is to build only reviewed and tested
pankso@377 1310 # packages with HOST_ARCH set in receipt.
pankso@377 1311 case "$ARCH" in
pankso@377 1312 arm)
pankso@377 1313 if [ ! "$HOST_ARCH" ]; then
al@596 1314 _ "cook: HOST_ARCH is not set in \$pkg receipt"
al@596 1315 _ "cook: This package is not included in: \$ARCH"
al@596 1316 [ "$CROSS_BUGS" ] && _ "bugs: \$CROSS_BUGS"
al@596 1317 _ "Cook skip: \$pkg is not included in: \$ARCH" | log
pankso@427 1318 newline && exit 1
pankso@377 1319 fi ;;
pankso@377 1320 esac
pankso@377 1321
paul@387 1322 # Some packages are not included in some arch or fail to cross compile.
pankso@398 1323 : ${HOST_ARCH=i486}
pankso@381 1324 if ! $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
al@596 1325 _ "cook: HOST_ARCH=\$HOST_ARCH"
al@596 1326 _ "cook: \$pkg doesn't cook or is not included in: \$ARCH"
al@596 1327 [ "$CROSS_BUGS" ] && _ "bugs: \$CROSS_BUGS"
al@596 1328 _ "Cook skip: \$pkg doesn't cook or is not included in: \$ARCH" | log
pankso@427 1329 newline && exit 1
pankso@377 1330 fi
pankso@377 1331
pankso@47 1332 # Skip blocked, 3 lines also for the Cooker.
pankso@151 1333 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
al@596 1334 _ "Blocked package: \$pkg"; newline
al@596 1335 exit 0
pankso@47 1336 fi
pankso@47 1337
pascal@289 1338 try_aufs_chroot "$@"
pascal@289 1339
pankso@47 1340 # Log and source receipt.
al@596 1341 _ "Cook started for: <a href='cooker.cgi?pkg=\$pkg'>\$pkg</a>" | log
pankso@16 1342 echo "cook:$pkg" > $command
pascal@285 1343
pascal@285 1344 # Display and log info if cook process stopped.
al@596 1345 # FIXME: gettext not worked (in single quotes) here!
al@596 1346 trap '_ "\n\nCook stopped: control-C\n\n" | \
pascal@285 1347 tee -a $LOGS/$pkg.log' INT
pascal@285 1348
pankso@1 1349 # Handle --options
pankso@1 1350 case "$2" in
pankso@1 1351 --clean|-c)
al@596 1352 _n "Cleaning: \$pkg"
pankso@1 1353 cd $WOK/$pkg && rm -rf install taz source
pankso@427 1354 status && newline && exit 0 ;;
pankso@1 1355 --install|-i)
pankso@1 1356 inst='yes' ;;
pankso@49 1357 --getsrc|-gs)
al@596 1358 _ "Getting source for: \$pkg"; separator
al@596 1359 get_source
al@596 1360 _ "Tarball: \$SRC/\$TARBALL"; newline
al@596 1361 exit 0 ;;
pankso@49 1362 --block|-b)
al@596 1363 _n "Blocking: \$pkg"
pankso@49 1364 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
pankso@427 1365 status && newline && exit 0 ;;
pankso@49 1366 --unblock|-ub)
al@596 1367 _n "Unblocking: \$pkg"
pankso@49 1368 sed -i "/^${pkg}$/"d $blocked
pankso@427 1369 status && newline && exit 0 ;;
slaxemulator@501 1370 --pack)
slaxemulator@501 1371 if [ -d $WOK/$pkg/taz ]; then
slaxemulator@501 1372 rm -rf $WOK/$pkg/taz
slaxemulator@501 1373 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
slaxemulator@501 1374 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
slaxemulator@501 1375 clean_log
slaxemulator@501 1376 else
al@596 1377 _ "Need to build \$pkg." && exit 0
slaxemulator@501 1378 fi
slaxemulator@501 1379 exit 0 ;;
pankso@1 1380 esac
pankso@1 1381
paul@62 1382 # Check if wanted is built now so we have separate log files.
pankso@295 1383 for wanted in $WANTED ; do
pascal@291 1384 if grep -q "^$wanted$" $blocked; then
al@596 1385 _ "WANTED package is blocked: \$wanted" | tee $LOGS/$pkg.log
pankso@427 1386 newline && rm -f $command && exit 1
pankso@217 1387 fi
pascal@291 1388 if grep -q "^$wanted$" $broken; then
al@596 1389 _ "WANTED package is broken: \$wanted" | tee $LOGS/$pkg.log
pankso@427 1390 newline && rm -f $command && exit 1
pankso@218 1391 fi
pascal@291 1392 if [ ! -d "$WOK/$wanted/install" ]; then
pascal@291 1393 cook "$wanted" || exit 1
pankso@137 1394 fi
pascal@291 1395 done
pankso@1 1396
pankso@1 1397 # Cook and pack or exit on error and log everything.
pascal@576 1398 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
pankso@15 1399 remove_deps | tee -a $LOGS/$pkg.log
pankso@1 1400 cookit_quality
pascal@576 1401 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
pankso@1 1402 clean_log
pankso@33 1403
pankso@33 1404 # Exit if any error in packing.
al@596 1405 lerror=$(_n "ERROR")
al@596 1406 if grep -Eq "(^$lerror|No such file or directory)" $LOGS/$pkg.log; then
pankso@33 1407 debug_info | tee -a $LOGS/$pkg.log
pankso@33 1408 rm -f $command && exit 1
pankso@33 1409 fi
pankso@358 1410
pankso@310 1411 # Create an XML feed
pankso@310 1412 gen_rss
pankso@358 1413
pankso@1 1414 # Time and summary
pankso@1 1415 time=$(($(date +%s) - $time))
pankso@1 1416 summary | tee -a $LOGS/$pkg.log
pankso@427 1417 newline
pankso@1 1418
pankso@428 1419 # We may want to install/update.
pankso@428 1420 install_package
pankso@358 1421
al@596 1422 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
pankso@17 1423 # You want automation: use the Cooker Build Bot.
pankso@18 1424 rm -f $command ;;
pankso@1 1425 esac
pankso@1 1426
pankso@1 1427 exit 0