cookutils annotate cook @ rev 10
Fiew small fixes
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed May 04 22:30:30 2011 +0200 (2011-05-04) |
parents | 02bf2a847c08 |
children | 92e7565b2519 |
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@1 | 9 |
pankso@1 | 10 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf |
pankso@1 | 11 [ -f "cook.conf" ] && . ./cook.conf |
pankso@1 | 12 |
pankso@9 | 13 # Share activity with the Cooker. |
pankso@9 | 14 activity="$CACHE/activity" |
pankso@9 | 15 |
pankso@1 | 16 # |
pankso@1 | 17 # Functions |
pankso@1 | 18 # |
pankso@1 | 19 |
pankso@1 | 20 usage() { |
pankso@1 | 21 cat << EOT |
pankso@1 | 22 |
pankso@1 | 23 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command|list] [--option] |
pankso@1 | 24 |
pankso@1 | 25 $(echo -e "\033[1m$(gettext "Commands:")\033[0m") |
pankso@1 | 26 usage|help $(gettext "Display this short usage.") |
pankso@1 | 27 list-wok $(gettext "List packages in the wok.") |
pankso@1 | 28 setup $(gettext "Setup your build environment.") |
pankso@9 | 29 test $(gettext "Test environment and cook a package.") |
pankso@1 | 30 new $(gettext "Create a new package with receipt".) |
pankso@1 | 31 list $(gettext "Cook a list of packages.") |
pankso@1 | 32 clean-wok $(gettext "Clean-up all packages files.") |
pankso@1 | 33 clean-src $(gettext "Clean-up all packages source.") |
pankso@1 | 34 pkglist $(gettext "Create all packages.* lists.") |
pankso@1 | 35 |
pankso@1 | 36 $(echo -e "\033[1m$(gettext "Options:")\033[0m") |
pankso@10 | 37 --clean|-c Cook : $(gettext "clean the package in the wok.") |
pankso@10 | 38 --install|-i Cook : $(gettext "and install the package.") |
pankso@10 | 39 --wok|-w Setup: $(gettext "create also a wok from Hg repo.") |
pankso@1 | 40 |
pankso@1 | 41 EOT |
pankso@1 | 42 exit 0 |
pankso@1 | 43 } |
pankso@1 | 44 |
pankso@1 | 45 # Be sure we root. |
pankso@1 | 46 check_root() { |
pankso@1 | 47 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0 |
pankso@1 | 48 } |
pankso@1 | 49 |
pankso@1 | 50 separator() { |
pankso@1 | 51 echo "================================================================================" |
pankso@1 | 52 } |
pankso@1 | 53 |
pankso@1 | 54 status() { |
pankso@1 | 55 echo -en "\\033[70G[ " |
pankso@1 | 56 if [ $? = 0 ]; then |
pankso@1 | 57 echo -en "\\033[1;32mOK" |
pankso@1 | 58 else |
pankso@1 | 59 echo -en "\\033[1;31mFailed" |
pankso@1 | 60 fi |
pankso@1 | 61 echo -e "\\033[0;39m ]" |
pankso@1 | 62 } |
pankso@1 | 63 |
pankso@9 | 64 # Log activities. |
pankso@9 | 65 log() { |
pankso@9 | 66 grep ^[a-zA-Z0-9] | \ |
pankso@9 | 67 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity |
pankso@9 | 68 } |
pankso@9 | 69 |
pankso@9 | 70 # We dont want those escape in web interface. |
pankso@1 | 71 clean_log() { |
pankso@1 | 72 sed -i -e s'|\[70G\[ \[1;32m| |' \ |
pankso@1 | 73 -e s'|\[0;39m \]||' $LOGS/$pkg.log |
pankso@1 | 74 } |
pankso@1 | 75 |
pankso@1 | 76 # Be sure package exist in wok. |
pankso@1 | 77 check_pkg_in_wok() { |
pankso@1 | 78 if [ ! -d "$WOK/$pkg" ]; then |
pankso@1 | 79 gettext -e "\nUnable to find package in the wok:" |
pankso@1 | 80 echo -e " $pkg\n" && exit 1 |
pankso@1 | 81 fi |
pankso@1 | 82 } |
pankso@1 | 83 |
pankso@9 | 84 if_empty_value() { |
pankso@9 | 85 if [ -z "$value" ]; then |
pankso@9 | 86 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n" |
pankso@9 | 87 exit 1 |
pankso@9 | 88 fi |
pankso@9 | 89 } |
pankso@9 | 90 |
pankso@9 | 91 # QA: check a receip consistency befor building. |
pankso@9 | 92 receipt_quality() { |
pankso@9 | 93 gettext -e "QA: checking package receipt...\n" |
pankso@9 | 94 unset online |
pankso@9 | 95 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then |
pankso@9 | 96 online="online" |
pankso@9 | 97 fi |
pankso@9 | 98 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE |
pankso@9 | 99 do |
pankso@9 | 100 unset value |
pankso@9 | 101 value=$(grep ^$var= receipt | cut -d \" -f 2) |
pankso@9 | 102 case "$var" in |
pankso@9 | 103 PACKAGE|VERSION|SHORT_DESC) |
pankso@9 | 104 if_empty_value ;; |
pankso@9 | 105 CATEGORY) |
pankso@9 | 106 [ -z "$value" ] && value="empty" |
pankso@9 | 107 valid="base-system x-window utilities network graphics \ |
pankso@9 | 108 multimedia office development system-tools security games \ |
pankso@9 | 109 misc meta non-free" |
pankso@9 | 110 if ! echo "$valid" | grep -q -w "$value"; then |
pankso@9 | 111 gettext "QA: unknow category:"; echo -e " $value\n" |
pankso@9 | 112 exit 1 |
pankso@9 | 113 fi ;; |
pankso@9 | 114 WEB_SITE) |
pankso@9 | 115 # We dont check WGET_URL since if dl is needed it will fail. |
pankso@9 | 116 # Break also if we not online. Here error is not fatal. |
pankso@9 | 117 if_empty_value |
pankso@9 | 118 [ -z "$online" ] || break |
pankso@9 | 119 if ! busybox wget -s $value 2>/dev/null; then |
pankso@9 | 120 gettext "QA: Unable to reach:"; echo -e " $value\n" |
pankso@9 | 121 fi ;; |
pankso@9 | 122 esac |
pankso@9 | 123 done |
pankso@9 | 124 } |
pankso@9 | 125 |
pankso@9 | 126 # Executed before sourcing a receipt. |
pankso@9 | 127 unset_receipt() { |
pankso@9 | 128 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL |
pankso@9 | 129 } |
pankso@9 | 130 |
pankso@1 | 131 # Path's used in receipt and by cook itself. |
pankso@1 | 132 set_paths() { |
pankso@1 | 133 pkgdir=$WOK/$PACKAGE |
pankso@1 | 134 src=$pkgdir/source/$PACKAGE-$VERSION |
pankso@1 | 135 pack=$pkgdir/taz/$PACKAGE-${VERSION}${EXTRAVERSION} |
pankso@1 | 136 fs=$pack/fs |
pankso@1 | 137 stuff=$pkgdir/stuff |
pankso@1 | 138 install=$pkgdir/install |
pankso@1 | 139 if [ "$WANTED" ]; then |
pankso@1 | 140 src=$WOK/$WANTED/source/$WANTED-$VERSION |
pankso@1 | 141 install=$WOK/$WANTED/install |
pankso@1 | 142 fi |
pankso@9 | 143 # Old way compatibility. |
pankso@1 | 144 _pkg=$install |
pankso@1 | 145 } |
pankso@1 | 146 |
pankso@9 | 147 # Get package source. |
pankso@1 | 148 get_source() { |
pankso@9 | 149 case "$WGET_URL" in |
pankso@9 | 150 http://*|ftp://*) |
pankso@9 | 151 # Busybox Wget is better! |
pankso@9 | 152 busybox wget -c -P $SRC $WGET_URL ;; |
pankso@9 | 153 hg*|mercurial*) |
pankso@9 | 154 # We are in cache so clone here and create a tarball |
pankso@9 | 155 pwd=$(pwd) |
pankso@9 | 156 if $(echo "$WGET_URL" | fgrep -q hg); then |
pankso@9 | 157 url=${WGET_URL#hg|} |
pankso@9 | 158 else |
pankso@9 | 159 url=${WGET_URL#mercurial|} |
pankso@9 | 160 fi |
pankso@10 | 161 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION |
pankso@9 | 162 tarball=$pkgsrc.tar.bz2 |
pankso@9 | 163 gettext "Getting source from Hg: "; echo $url |
pankso@9 | 164 gettext "Cloning to: "; echo "$pwd/$pkgsrc" |
pankso@9 | 165 hg clone $url $pkgsrc || exit 1 |
pankso@9 | 166 gettext "Creating tarball: "; echo "$tarball" |
pankso@9 | 167 tar cjf $tarball $pkgsrc || exit 1 |
pankso@9 | 168 mv $tarball $SRC && rm -rf $pkgsrc ;; |
pankso@9 | 169 git*) |
pankso@9 | 170 echo "TODO: git implementation in cook" && exit 1 ;; |
pankso@9 | 171 svn*) |
pankso@9 | 172 echo "TODO: svn implementation in cook" && exit 1 ;; |
pankso@9 | 173 *) |
pankso@9 | 174 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \ |
pankso@9 | 175 tee -a $LOGS/$PACKAGE.log |
pankso@9 | 176 exit 1 ;; |
pankso@9 | 177 esac |
pankso@1 | 178 } |
pankso@1 | 179 |
pankso@9 | 180 # Extract source package. |
pankso@1 | 181 extract_source() { |
pankso@1 | 182 gettext "Extracting:"; echo " $TARBALL" |
pankso@1 | 183 case "$TARBALL" in |
pankso@1 | 184 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL ;; |
pankso@1 | 185 *.tar.bz2) tar xjf $SRC/$TARBALL ;; |
pankso@1 | 186 *.tar.lzma) tar xaf $SRC/$TARBALL ;; |
pankso@1 | 187 *.zip) unzip $SRC/$TARBALL ;; |
pankso@1 | 188 esac |
pankso@1 | 189 } |
pankso@1 | 190 |
pankso@9 | 191 # Display cooked package summary. |
pankso@1 | 192 summary() { |
pankso@1 | 193 cd $WOK/$pkg |
pankso@1 | 194 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null) |
pankso@1 | 195 fs=$(du -sh taz/* | awk '{print $1}') |
pankso@1 | 196 size=$(du -sh $PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.* | awk '{print $1}') |
pankso@1 | 197 files=$(cat taz/$PACKAGE-*/files.list | wc -l) |
pankso@1 | 198 gettext "Summary for:"; echo " $PACKAGE $VERSION" |
pankso@1 | 199 separator |
pankso@1 | 200 [ "$prod" ] && echo "Produce : $prod" |
pankso@1 | 201 cat << EOT |
pankso@1 | 202 Packed : $fs |
pankso@1 | 203 Compressed : $size |
pankso@9 | 204 Cook time : ${time}s |
pankso@1 | 205 Files : $files |
pankso@1 | 206 $(separator) |
pankso@1 | 207 |
pankso@1 | 208 EOT |
pankso@1 | 209 } |
pankso@1 | 210 |
pankso@1 | 211 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths, |
pankso@1 | 212 # so some packages need to copy these files with the receipt and genpkg_rules. |
pankso@1 | 213 copy_generic_files() |
pankso@1 | 214 { |
pankso@1 | 215 # $LOCALE is set in cook.conf |
pankso@1 | 216 if [ "$LOCALE" ]; then |
pankso@1 | 217 if [ -d "$_pkg/usr/share/locale" ]; then |
pankso@1 | 218 mkdir -p $fs/usr/share/locale |
pankso@1 | 219 for i in $LOCALE |
pankso@1 | 220 do |
pankso@1 | 221 if [ -d "$_pkg/usr/share/locale/$i" ]; then |
pankso@1 | 222 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale |
pankso@1 | 223 fi |
pankso@1 | 224 done |
pankso@1 | 225 fi |
pankso@1 | 226 fi |
pankso@1 | 227 |
pankso@1 | 228 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no" |
pankso@1 | 229 if [ "$GENERIC_PIXMAPS" != "no" ]; then |
pankso@1 | 230 if [ -d "$_pkg/usr/share/pixmaps" ]; then |
pankso@1 | 231 mkdir -p $fs/usr/share/pixmaps |
pankso@1 | 232 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \ |
pankso@1 | 233 $fs/usr/share/pixmaps 2>/dev/null |
pankso@1 | 234 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \ |
pankso@1 | 235 $fs/usr/share/pixmaps 2>/dev/null |
pankso@1 | 236 fi |
pankso@1 | 237 |
pankso@1 | 238 # Custom or homemade PNG pixmap can be in stuff. |
pankso@1 | 239 if [ -f "$stuff/$PACKAGE.png" ]; then |
pankso@1 | 240 mkdir -p $fs/usr/share/pixmaps |
pankso@1 | 241 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps |
pankso@1 | 242 fi |
pankso@1 | 243 fi |
pankso@1 | 244 |
pankso@1 | 245 # Desktop entry (.desktop). |
pankso@1 | 246 if [ -d "$_pkg/usr/share/applications" ]; then |
pankso@1 | 247 cp -a $_pkg/usr/share/applications $fs/usr/share |
pankso@1 | 248 fi |
pankso@1 | 249 |
pankso@1 | 250 # Homemade desktop file(s) can be in stuff. |
pankso@1 | 251 if [ -d "$stuff/applications" ]; then |
pankso@1 | 252 mkdir -p $fs/usr/share |
pankso@1 | 253 cp -a $stuff/applications $fs/usr/share |
pankso@1 | 254 fi |
pankso@1 | 255 if [ -f "$stuff/$PACKAGE.desktop" ]; then |
pankso@1 | 256 mkdir -p $fs/usr/share/applications |
pankso@1 | 257 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications |
pankso@1 | 258 fi |
pankso@1 | 259 } |
pankso@1 | 260 |
pankso@1 | 261 # Find and strip : --strip-all (-s) or --strip-debug on static libs. |
pankso@1 | 262 strip_package() |
pankso@1 | 263 { |
pankso@1 | 264 gettext "Executing strip on all files" |
pankso@1 | 265 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games |
pankso@1 | 266 do |
pankso@1 | 267 if [ -d "$dir" ]; then |
pankso@1 | 268 find $dir -type f -exec strip -s '{}' 2>/dev/null \; |
pankso@1 | 269 fi |
pankso@1 | 270 done |
pankso@1 | 271 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \; |
pankso@1 | 272 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \; |
pankso@1 | 273 status |
pankso@1 | 274 } |
pankso@1 | 275 |
pankso@8 | 276 # Remove installed deps. |
pankso@8 | 277 remove_deps() { |
pankso@8 | 278 # Now remove installed build deps. |
pankso@9 | 279 diff="$CACHE/installed.diff" |
pankso@9 | 280 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//) |
pankso@9 | 281 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l) |
pankso@8 | 282 if [ -s "$CACHE/installed.diff" ]; then |
pankso@8 | 283 gettext "Build dependencies to remove:"; echo " $nb" |
pankso@8 | 284 gettext "Removing:" |
pankso@8 | 285 for dep in $deps |
pankso@8 | 286 do |
pankso@8 | 287 echo -n " $dep" |
pankso@8 | 288 yes | tazpkg remove $dep >/dev/null |
pankso@8 | 289 done |
pankso@8 | 290 echo "" |
pankso@8 | 291 mv -f $CACHE/installed.diff $CACHE/installed.last.diff |
pankso@1 | 292 fi |
pankso@1 | 293 } |
pankso@1 | 294 |
pankso@1 | 295 # The main cook function. |
pankso@1 | 296 cookit() { |
pankso@9 | 297 echo "Cooking: $PACKAGE $VERSION" |
pankso@9 | 298 separator |
pankso@1 | 299 set_paths |
pankso@9 | 300 [ "$QA" ] && receipt_quality |
pankso@1 | 301 rm -rf install taz source $CACHE/error |
pankso@1 | 302 |
pankso@1 | 303 # Disable -pipe if less than 512Mb free RAM. |
pankso@1 | 304 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ') |
pankso@1 | 305 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then |
pankso@1 | 306 gettext -e "Disabling -pipe compile flag: $free RAM\n" |
pankso@1 | 307 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ') |
pankso@1 | 308 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ') |
pankso@1 | 309 fi |
pankso@1 | 310 unset free |
pankso@1 | 311 |
pankso@1 | 312 # Export flags and path to be used by make |
pankso@1 | 313 DESTDIR=$WOK/$PACKAGE/install |
pankso@1 | 314 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS BUILD_HOST CONFIG_SITE |
pankso@1 | 315 local LC_ALL=POSIX LANG=POSIX |
pankso@1 | 316 |
pankso@1 | 317 # Check for build dep. |
pankso@1 | 318 cd $INSTALLED && ls -1 > $CACHE/installed.list |
pankso@1 | 319 [ "$DEPENDS" ] && gettext -e "Checking build dependencies...\n" |
pankso@1 | 320 for dep in $BUILD_DEPENDS |
pankso@1 | 321 do |
pankso@1 | 322 if [ ! -d "$INSTALLED/$dep" ]; then |
pankso@1 | 323 # Try local package first |
pankso@1 | 324 if [ -f "$PKGS/$dep-*.tazpkg" ]; then |
pankso@1 | 325 gettext "Installing dep (local):"; echo " $dep" |
pankso@1 | 326 cd $PKGS && tazpkg install $dep-*.tazpkg >/dev/null |
pankso@1 | 327 else |
pankso@1 | 328 gettext "Installing dep (web/cache):"; echo " $dep" |
pankso@1 | 329 tazpkg get-install $dep >/dev/null |
pankso@1 | 330 fi |
pankso@1 | 331 fi |
pankso@1 | 332 done |
pankso@1 | 333 ls -1 > $CACHE/installed.cook && cd $CACHE |
pankso@8 | 334 |
pankso@8 | 335 # If a cook failed deps are not remove since we exit 1. |
pankso@8 | 336 [ ! -s "installed.diff" ] && \ |
pankso@8 | 337 diff installed.list installed.cook > installed.diff |
pankso@8 | 338 deps=$(cat installed.diff | grep ^+[a-zA-Z0-9] | wc -l) |
pankso@1 | 339 |
pankso@1 | 340 # Get source tarball and make sure we have source dir named: |
pankso@1 | 341 # $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma |
pankso@1 | 342 # tarball if it exist. |
pankso@1 | 343 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then |
pankso@1 | 344 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then |
pankso@10 | 345 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma |
pankso@1 | 346 else |
pankso@1 | 347 get_source || exit 1 |
pankso@1 | 348 fi |
pankso@1 | 349 fi |
pankso@9 | 350 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then |
pankso@1 | 351 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp |
pankso@1 | 352 extract_source || exit 1 |
pankso@1 | 353 mv * ../$PACKAGE-$VERSION |
pankso@1 | 354 cd .. && rm -rf tmp |
pankso@1 | 355 fi |
pankso@1 | 356 |
pankso@9 | 357 # Execute receipt rules. |
pankso@1 | 358 if grep -q ^compile_rules $pkgdir/receipt; then |
pankso@1 | 359 gettext -e "Executing: compile_rules\n" |
pankso@9 | 360 [ -d "$src" ] && cd $src |
pankso@9 | 361 compile_rules || exit 1 |
pankso@10 | 362 # Stay compatible with _pkg |
pankso@10 | 363 [ -d $src/_pkg ] && mv $src/_pkg $install |
pankso@9 | 364 # QA: compile_rules success so valid. |
pankso@9 | 365 mkdir -p $install |
pankso@9 | 366 else |
pankso@9 | 367 # QA: No compile_rules so no error, valid. |
pankso@9 | 368 mkdir -p $install |
pankso@1 | 369 fi |
pankso@1 | 370 if grep -q ^genpkg_rules $pkgdir/receipt; then |
pankso@1 | 371 gettext -e "Executing: genpkg_rules\n" |
pankso@1 | 372 mkdir -p $fs && genpkg_rules || ( echo -e \ |
pankso@1 | 373 "\nERROR: genpkg_rules failed\n" | \ |
pankso@1 | 374 tee -a $LOGS/$pkg.log && exit 1 ) |
pankso@1 | 375 fi |
pankso@1 | 376 separator && echo "" |
pankso@1 | 377 } |
pankso@1 | 378 |
pankso@1 | 379 # Cook quality assurance. |
pankso@1 | 380 cookit_quality() { |
pankso@9 | 381 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then |
pankso@9 | 382 echo -e "\nERROR: cook failed\n" | tee -a $LOGS/$pkg.log |
pankso@9 | 383 fi |
pankso@9 | 384 # ERROR can be echoed any time in cookit() |
pankso@1 | 385 if grep -q ^ERROR $LOGS/$pkg.log; then |
pankso@1 | 386 exit 1 |
pankso@1 | 387 fi |
pankso@1 | 388 } |
pankso@1 | 389 |
pankso@1 | 390 # Create the package. |
pankso@1 | 391 packit() { |
pankso@1 | 392 set_paths |
pankso@1 | 393 echo "Packing: $PACKAGE ${VERSION}${EXTRAVERSION}" |
pankso@1 | 394 separator |
pankso@1 | 395 cd $pkgdir/taz |
pankso@1 | 396 strip_package |
pankso@1 | 397 for file in receipt description.txt |
pankso@1 | 398 do |
pankso@1 | 399 [ ! -f "../$file" ] && continue |
pankso@1 | 400 gettext "Copying"; echo -n " $file..." |
pankso@1 | 401 cp -f ../$file $pack && chown 0.0 $pack/$file && status |
pankso@1 | 402 done |
pankso@1 | 403 copy_generic_files |
pankso@1 | 404 # Use Tazpkg to create a tazpkg package... |
pankso@1 | 405 tazpkg pack $PACKAGE-${VERSION}${EXTRAVERSION} | grep "\[*\]" |
pankso@1 | 406 separator && echo "" |
pankso@1 | 407 } |
pankso@1 | 408 |
pankso@8 | 409 # Verify package quality and consitensy. |
pankso@8 | 410 packit_quality() { |
pankso@8 | 411 if grep -q ^ERROR $LOGS/$pkg.log; then |
pankso@8 | 412 exit 1 |
pankso@8 | 413 fi |
pankso@8 | 414 if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then |
pankso@8 | 415 echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1 |
pankso@8 | 416 else |
pankso@8 | 417 mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS |
pankso@8 | 418 fi |
pankso@8 | 419 } |
pankso@8 | 420 |
pankso@1 | 421 # |
pankso@1 | 422 # Commands |
pankso@1 | 423 # |
pankso@1 | 424 |
pankso@1 | 425 case "$1" in |
pankso@1 | 426 usage|help) |
pankso@1 | 427 usage ;; |
pankso@1 | 428 list-wok) |
pankso@1 | 429 gettext "List of packages in:"; echo " $WOK" |
pankso@1 | 430 separator |
pankso@1 | 431 cd $WOK && ls -1 |
pankso@1 | 432 separator |
pankso@1 | 433 echo -n "Packages: " && ls | wc -l |
pankso@1 | 434 echo "" ;; |
pankso@1 | 435 setup) |
pankso@1 | 436 # Setup a build environment |
pankso@1 | 437 check_root |
pankso@1 | 438 gettext -e "\nSetting up your environment\n" |
pankso@1 | 439 separator && cd $SLITAZ |
pankso@1 | 440 gettext "Creating directories structure in:"; echo " $SLITAZ" |
pankso@1 | 441 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS |
pankso@1 | 442 gettext -e "Checking for packages to install...\n" |
pankso@1 | 443 for pkg in slitaz-toolchain tazdev intltool gettext |
pankso@1 | 444 do |
pankso@1 | 445 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg |
pankso@1 | 446 done |
pankso@1 | 447 |
pankso@1 | 448 # Handle --options |
pankso@1 | 449 case "$2" in |
pankso@1 | 450 --wok) |
pankso@1 | 451 [ ! -d "$INSTALLED/mercurial" ] && tazpkg get-install mercurial |
pankso@1 | 452 [ -d "$WOK" ] && echo -e "A wok already exist.\n" && exit 1 |
pankso@1 | 453 hg clone $HG_URL ;; |
pankso@1 | 454 --chroot) |
pankso@1 | 455 echo "TODO: create a chroot with tazdev" ;; |
pankso@1 | 456 esac |
pankso@1 | 457 |
pankso@1 | 458 # SliTaz group and permissions |
pankso@1 | 459 if ! grep -q ^slitaz /etc/group; then |
pankso@1 | 460 gettext -e "Adding group: slitaz\n" |
pankso@1 | 461 addgroup slitaz |
pankso@1 | 462 fi |
pankso@1 | 463 gettext -e "Setting permissions for slitaz group...\n" |
pankso@1 | 464 chown -R root.slitaz $SLITAZ |
pankso@1 | 465 chmod -R g+w $SLITAZ |
pankso@1 | 466 separator |
pankso@1 | 467 gettext -e "All done, ready to cook packages :-)\n\n" ;; |
pankso@9 | 468 test) |
pankso@9 | 469 # Test a cook environment. |
pankso@9 | 470 echo "TODO: Use $DATA/cooktest \$(cp cooktest \$WOK and cook)" |
pankso@9 | 471 [ ! -d "$WOK" ] && exit 1 |
pankso@9 | 472 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK |
pankso@9 | 473 cook cooktest ;; |
pankso@1 | 474 new) |
pankso@1 | 475 # Create the package folder and an empty receipt. |
pankso@1 | 476 pkg="$2" |
pankso@1 | 477 [ "$pkg" ] || usage |
pankso@1 | 478 echo "" |
pankso@1 | 479 if [ -d "$WOK/$pkg" ]; then |
pankso@1 | 480 echo -n "$pkg " && gettext "package already exist." |
pankso@1 | 481 echo -e "\n" && exit 1 |
pankso@1 | 482 fi |
pankso@1 | 483 gettext "Creating"; echo -n " $WOK/$pkg" |
pankso@1 | 484 mkdir $WOK/$pkg && cd $WOK/$pkg && status |
pankso@1 | 485 gettext "Preparing the package receipt..." |
pankso@1 | 486 cp $DATA/receipt . |
pankso@1 | 487 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt |
pankso@1 | 488 status && echo "" ;; |
pankso@1 | 489 list) |
pankso@1 | 490 # Cook a list of packages (better use the Cooker since it will order |
pankso@1 | 491 # packages before executing cook). |
pankso@1 | 492 check_root |
pankso@1 | 493 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1 |
pankso@1 | 494 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \ |
pankso@1 | 495 echo -e " $2\n" && exit 1 |
pankso@1 | 496 for pkg in $(cat $2) |
pankso@1 | 497 do |
pankso@1 | 498 cook $pkg || broken |
pankso@1 | 499 done ;; |
pankso@1 | 500 clean-wok) |
pankso@1 | 501 check_root |
pankso@1 | 502 gettext -e "\nCleaning all packages files..." |
pankso@1 | 503 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source |
pankso@1 | 504 status && echo "" ;; |
pankso@1 | 505 clean-src) |
pankso@1 | 506 check_root |
pankso@1 | 507 gettext -e "\nCleaning all packages source..." |
pankso@1 | 508 rm -rf $WOK/*/source |
pankso@1 | 509 status && echo "" ;; |
pankso@1 | 510 pkglist) |
pankso@1 | 511 # Create suitable packages list for TazPKG and only for builded packages. |
pankso@1 | 512 [ "$2" ] && PKGS="$2" |
pankso@1 | 513 [ ! -d "$PKGS" ] && \ |
pankso@1 | 514 gettext -e "\nPackages directory dont exist\n\n" && exit 1 |
pankso@1 | 515 cd $PKGS |
pankso@1 | 516 gettext -e "\nCreating lists for:"; echo " $PKGS" |
pankso@1 | 517 separator |
pankso@1 | 518 rm -f packages.* files.list* |
pankso@1 | 519 gettext -e "Creating: packages.list\n" |
pankso@1 | 520 ls -1 | sed s'/.tazpkg//' > $PKGS/packages.list |
pankso@1 | 521 gettext -e "Creating: packages.md5\n" |
pankso@1 | 522 md5sum *.tazpkg > $PKGS/packages.md5 |
pankso@1 | 523 gettext -e "Creating: packages.desc\n" |
pankso@1 | 524 gettext -e "Creating: packages.equiv\n" |
pankso@1 | 525 cd $WOK |
pankso@1 | 526 for pkg in * |
pankso@1 | 527 do |
pankso@1 | 528 unset_receipt |
pankso@1 | 529 . $pkg/receipt |
pankso@1 | 530 # packages.desc let us search easily in DB |
pankso@1 | 531 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then |
pankso@1 | 532 cat >> $PKGS/packages.desc << EOT |
pankso@1 | 533 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE |
pankso@1 | 534 EOT |
pankso@1 | 535 # Packages.equiv is used by tazpkg install to check depends. |
pankso@1 | 536 for i in $PROVIDE; do |
pankso@1 | 537 DEST="" |
pankso@1 | 538 echo $i | fgrep -q : && DEST="${i#*:}:" |
pankso@1 | 539 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then |
pankso@1 | 540 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \ |
pankso@1 | 541 $PKGS/packages.equiv |
pankso@1 | 542 else |
pankso@1 | 543 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv |
pankso@1 | 544 fi |
pankso@1 | 545 done |
pankso@1 | 546 fi |
pankso@1 | 547 done |
pankso@1 | 548 # files.list.lzma |
pankso@1 | 549 #lzma e files.list files.list.lzma |
pankso@1 | 550 separator |
pankso@1 | 551 nb=$(ls $PKGS/*.tazpkg | wc -l) |
pankso@1 | 552 echo -e "Packages: $nb\n" ;; |
pankso@1 | 553 *) |
pankso@1 | 554 # Just cook and generate a package. |
pankso@1 | 555 check_root |
pankso@1 | 556 time=$(date +%s) |
pankso@1 | 557 pkg="$1" |
pankso@1 | 558 [ -z "$pkg" ] && usage |
pankso@1 | 559 check_pkg_in_wok && echo "" |
pankso@1 | 560 unset inst |
pankso@1 | 561 unset_receipt |
pankso@1 | 562 cd $WOK/$pkg && . ./receipt |
pankso@1 | 563 |
pankso@1 | 564 # Handle --options |
pankso@1 | 565 case "$2" in |
pankso@1 | 566 --clean|-c) |
pankso@1 | 567 gettext -e "Cleaning package:"; echo -n " $pkg" |
pankso@1 | 568 cd $WOK/$pkg && rm -rf install taz source |
pankso@1 | 569 status && echo "" && exit 0 ;; |
pankso@1 | 570 --install|-i) |
pankso@1 | 571 inst='yes' ;; |
pankso@1 | 572 esac |
pankso@1 | 573 |
pankso@1 | 574 # Check if wanted is build now so we have separate log files. |
pankso@1 | 575 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then |
pankso@1 | 576 cook "$WANTED" |
pankso@1 | 577 fi |
pankso@1 | 578 |
pankso@1 | 579 # Cook and pack or exit on error and log everything. |
pankso@1 | 580 cookit | tee $LOGS/$pkg.log |
pankso@8 | 581 remove_deps |
pankso@1 | 582 cookit_quality |
pankso@1 | 583 packit | tee -a $LOGS/$pkg.log |
pankso@1 | 584 clean_log |
pankso@1 | 585 packit_quality |
pankso@1 | 586 |
pankso@1 | 587 # Time and summary |
pankso@1 | 588 time=$(($(date +%s) - $time)) |
pankso@1 | 589 summary | tee -a $LOGS/$pkg.log |
pankso@1 | 590 |
pankso@1 | 591 # Install package if requested |
pankso@1 | 592 if [ "$inst" ]; then |
pankso@1 | 593 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then |
pankso@1 | 594 cd $PKGS && tazpkg install \ |
pankso@1 | 595 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced |
pankso@1 | 596 else |
pankso@1 | 597 gettext -e "Unable to install package, build have failed.\n\n" |
pankso@1 | 598 exit 1 |
pankso@1 | 599 fi |
pankso@1 | 600 fi |
pankso@9 | 601 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg" |
pankso@9 | 602 # You automation: use the Cooker Build Bot. |
pankso@1 | 603 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev |
pankso@1 | 604 ;; |
pankso@1 | 605 esac |
pankso@1 | 606 |
pankso@1 | 607 exit 0 |