tazwok annotate tazwok @ rev 25

Strip generated packages automaticly
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 05 00:27:57 2008 +0100 (2008-02-05)
parents 47584d26ad16
children f0821ee32fd3
rev   line source
pankso@7 1 #!/bin/sh
pankso@7 2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
pankso@7 3 #
pankso@7 4 # Tazwok can compile source package and creat binary packages suitable for
pankso@7 5 # Tazpkg (Tiny Autonomus zone package manager). You can build individuals
pankso@7 6 # package or a list a packages with one command, rebuild the full distro,
pankso@7 7 # generate a packages repository and also list and get info about packages.
pankso@7 8 #
pankso@19 9 # (C) 2007-2008 SliTaz - GNU General Public License.
pankso@7 10 #
pankso@22 11 VERSION=1.3.1
pankso@7 12
pankso@7 13 ####################
pankso@7 14 # Tazwok variables #
pankso@7 15 ####################
pankso@7 16
pankso@7 17 # Packages categories.
pankso@25 18 CATEGORIES="
pankso@25 19 base-system
pankso@25 20 utilities
pankso@25 21 network
pankso@25 22 graphics
pankso@25 23 multimedia
pankso@25 24 office
pankso@25 25 development
pankso@25 26 system-tools
pankso@25 27 security
pankso@25 28 meta"
pankso@7 29
pankso@7 30 # Use words rater than numbers in the code.
pankso@7 31 COMMAND=$1
pankso@7 32 PACKAGE=$2
pankso@7 33 LIST=$2
pankso@7 34
pankso@7 35 # Include config file or exit if any file found.
pankso@7 36 if [ -f "/etc/tazwok.conf" ]; then
pankso@7 37 . /etc/tazwok.conf
pankso@7 38 else
pankso@7 39 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
pankso@7 40 echo -e "Please read the Tazwok documentation.\n"
pankso@7 41 exit 0
pankso@7 42 fi
pankso@7 43
pankso@7 44 # Creat Taz wok needed directories if user is root.
pankso@7 45 if test $(id -u) = 0 ; then
pankso@7 46 # Check for the wok directory.
pankso@7 47 if [ ! -d "$WOK" ]; then
pankso@7 48 echo "Creating the wok directory..."
pankso@7 49 mkdir -p $WOK
pankso@7 50 chmod 777 $WOK
pankso@7 51 fi
pankso@7 52 # Check for the packages repository.
pankso@7 53 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
pankso@7 54 echo "Creating the packages repository..."
pankso@7 55 mkdir -p $PACKAGES_REPOSITORY
pankso@7 56 fi
pankso@7 57 # Check for the sources repository.
pankso@7 58 if [ ! -d "$SOURCES_REPOSITORY" ]; then
pankso@7 59 echo "Creating the sources repository..."
pankso@17 60 mkdir -p $SOURCES_REPOSITORY
pankso@7 61 fi
pankso@7 62 fi
pankso@7 63
pankso@7 64 # The path to the most important file used by Tazwok.
pankso@7 65 # The receipt is used to compile the source code and
pankso@7 66 # gen suitables packages for Tazpkg.
pankso@7 67 RECEIPT="$WOK/$PACKAGE/receipt"
pankso@7 68
pankso@7 69 # The path to the process log file.
pankso@7 70 LOG="$WOK/$PACKAGE/process.log"
pankso@7 71
pankso@7 72 ####################
pankso@7 73 # Tazwok functions #
pankso@7 74 ####################
pankso@7 75
pankso@7 76 # Print the usage (English).
pankso@7 77 usage ()
pankso@7 78 {
pankso@7 79 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
pankso@7 80 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir] [--option]
pankso@7 81 \033[1mCommands: \033[0m\n
pankso@7 82 usage Print this short usage.
pankso@7 83 stats Print Tazwok statistics from the config file and the wok.
pankso@7 84 list List all packages in the wok tree or by category.
pankso@7 85 info Get informations about a package in the wok.
pankso@7 86 check-log Check the process log file of a package.
pankso@7 87 search Search for a package in the wok by pattern or name.
pankso@7 88 compile Configure and build the package using the receipt rules.
pankso@7 89 genpkg Generate a suitable package for Tazpkg with the rules.
pankso@7 90 cook Compile and generate a package directly.
pankso@7 91 cook-list Cook all packages specified in the list by order.
pankso@7 92 clean Clean all generated files in the package tree.
pankso@7 93 new-tree Prepare a new package tree and receipt (--interactive).
pankso@7 94 gen-list Generate a packages.list and md5sum for a repository.
pankso@7 95 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
pankso@7 96 remove Remove a package from the wok.\n"
pankso@7 97 }
pankso@7 98
pankso@7 99 # Status function.
pankso@7 100 status()
pankso@7 101 {
pankso@7 102 local CHECK=$?
pankso@7 103 echo -en "\\033[70G[ "
pankso@7 104 if [ $CHECK = 0 ]; then
pankso@7 105 echo -en "\\033[1;33mOK"
pankso@7 106 else
pankso@7 107 echo -en "\\033[1;31mFailed"
pankso@7 108 fi
pankso@7 109 echo -e "\\033[0;39m ]"
pankso@7 110 }
pankso@7 111
pankso@7 112 # Check if user is root.
pankso@7 113 check_root()
pankso@7 114 {
pankso@7 115 if test $(id -u) != 0 ; then
pankso@7 116 echo -e "\nYou must be root to run `basename $0` with this option."
pankso@7 117 echo -e "Please type 'su' and root password to become super-user.\n"
pankso@7 118 exit 0
pankso@7 119 fi
pankso@7 120 }
pankso@7 121
pankso@7 122 # Check for a package name on cmdline.
pankso@7 123 check_for_package_on_cmdline()
pankso@7 124 {
pankso@7 125 if [ -z "$PACKAGE" ]; then
pankso@7 126 echo -e "\nYou must specify a package name on the command line."
pankso@7 127 echo -e "Example : tazwok $COMMAND package\n"
pankso@7 128 exit 0
pankso@7 129 fi
pankso@7 130 }
pankso@7 131
pankso@7 132 # Check for the receipt of a package used to cook.
pankso@7 133 check_for_receipt()
pankso@7 134 {
pankso@7 135 if [ ! -f "$RECEIPT" ]; then
pankso@7 136 echo -e "\nUnable to find the receipt : $RECEIPT\n"
pankso@7 137 exit 0
pankso@7 138 fi
pankso@7 139 }
pankso@7 140
pankso@7 141 # Check for a specified file list on cmdline.
pankso@7 142 check_for_list()
pankso@7 143 {
pankso@7 144 if [ -z "$LIST" ]; then
pankso@7 145 echo -e "\nPlease specify the path to the list of packages to cook.\n"
pankso@7 146 exit 0
pankso@7 147 fi
pankso@7 148 # Check if the list of packages exist.
pankso@7 149 if [ -f "$LIST" ]; then
pankso@7 150 LIST=`cat $LIST`
pankso@7 151 else
pankso@7 152 echo -e "\nUnable to find $LIST packages list.\n"
pankso@7 153 exit 0
pankso@7 154 fi
pankso@7 155 }
pankso@7 156
pankso@7 157 # Check for the wanted package if specified in WANTED
pankso@7 158 # receipt variable. Set the $src/$_pkg variable to help compiling
pankso@7 159 # and generating packages.
pankso@7 160 check_for_wanted()
pankso@7 161 {
pankso@7 162 if [ ! "$WANTED" = "" ]; then
pankso@7 163 echo -n "Checking for the wanted package..."
pankso@7 164 if [ ! -d "$WOK/$WANTED" ]; then
pankso@7 165 echo -e "\nWanted package is missing in the work directory.\n"
pankso@7 166 exit 0
pankso@7 167 fi
pankso@7 168 status
pankso@7 169 # Set wanted src path.
pankso@7 170 src=$WOK/$WANTED/$WANTED-$VERSION
pankso@7 171 _pkg=$src/_pkg
pankso@7 172 fi
pankso@7 173 }
pankso@7 174
pankso@18 175 # Check for build dependencies and notify user.
pankso@18 176 check_for_build_depends()
pankso@18 177 {
pankso@18 178 echo "Checking for build dependencies..."
pankso@18 179 for pkg in $BUILD_DEPENDS
pankso@18 180 do
pankso@18 181 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@18 182 MISSING_PACKAGE=$pkg
pankso@18 183 fi
pankso@18 184 done
pankso@18 185 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@18 186 echo "================================================================================"
pankso@18 187 for pkg in $BUILD_DEPENDS
pankso@18 188 do
pankso@18 189 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@18 190 MISSING_PACKAGE=$pkg
pankso@18 191 echo "Missing : $pkg"
pankso@18 192 fi
pankso@18 193 done
pankso@18 194 echo "================================================================================"
pankso@18 195 echo "You can continue or exit to install missing dependencies."
pankso@18 196 echo -n "Continue or exit (y/N) ? "; read anser
pankso@18 197 if [ "$anser" == "y" ]; then
pankso@18 198 continue
pankso@18 199 else
pankso@18 200 exit 0
pankso@18 201 fi
pankso@18 202 fi
pankso@18 203 }
pankso@18 204
pankso@7 205 # Configure and make a package with the receipt.
pankso@7 206 compile_package()
pankso@7 207 {
pankso@7 208 check_for_package_on_cmdline
pankso@7 209 # Include the receipt to get all needed variables and functions
pankso@7 210 # and cd into the work directory to start the work.
pankso@7 211 check_for_receipt
pankso@7 212 . $RECEIPT
pankso@7 213 # Log the package name and date.
pankso@7 214 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
pankso@7 215 echo "package $PACKAGE (compile)" >> $LOG
pankso@7 216 # Set wanted $src variable to help compiling.
pankso@7 217 if [ ! "$SOURCE" = "" ]; then
pankso@7 218 src=$WOK/$PACKAGE/$SOURCE-$VERSION
pankso@7 219 else
pankso@7 220 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
pankso@7 221 fi
pankso@18 222 check_for_build_depends
pankso@7 223 check_for_wanted
pankso@7 224 echo ""
pankso@7 225 echo "Starting to cook $PACKAGE..."
pankso@7 226 echo "================================================================================"
pankso@7 227 # Check for src tarball and wget if needed.
pankso@7 228 if [ ! "$TARBALL" = "" ]; then
pankso@7 229 echo "Checking for source tarball... "
pankso@7 230 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
pankso@7 231 cd $SOURCES_REPOSITORY
pankso@7 232 wget $WGET_URL
pankso@7 233 # Exit if download failed to avoid errors.
pankso@7 234 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
pankso@7 235 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
pankso@7 236 exit 1
pankso@7 237 fi
pankso@7 238 else
pankso@7 239 echo -n "Source tarball exit... "
pankso@7 240 status
pankso@7 241 fi
pankso@7 242 # Untaring source if necessary. We dont need to extract source if
pankso@7 243 # the package is build with a wanted source package.
pankso@7 244 if [ "$WANTED" = "" ]; then
pankso@7 245 if [ ! -d $src ]; then
pankso@7 246 # Log process.
pankso@7 247 echo "untaring $TARBALL" >> $LOG
pankso@7 248 echo -n "Untaring $TARBALL... "
pankso@7 249 if [ "`basename $TARBALL | grep tar.bz2`" ]; then
pankso@7 250 tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
pankso@7 251 else
pankso@7 252 tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
pankso@7 253 fi
pankso@7 254 status
pankso@7 255 else
pankso@7 256 echo -n "Source direcory exit... " && status
pankso@7 257 fi
pankso@7 258 fi
pankso@7 259 fi
pankso@7 260 cd $WOK/$PACKAGE
pankso@7 261 # Log and execute compile_rules function if it exist, to configure and
pankso@7 262 # make the package if it exist.
pankso@7 263 if [ `cat $RECEIPT | grep compile_rules` ]; then
pankso@7 264 echo "executing compile_rules" >> $LOG
pankso@7 265 compile_rules
pankso@7 266 # Exit if compilation failed so the binary package
pankso@7 267 # is not generated when using the cook comand.
pankso@7 268 local CHECK=$?
pankso@7 269 if [ $CHECK = 0 ]; then
pankso@7 270 echo "================================================================================"
pankso@7 271 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
pankso@7 272 echo ""
pankso@7 273 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
pankso@7 274 else
pankso@7 275 echo "================================================================================"
pankso@7 276 echo "Compilation failed. Please read the compilator output."
pankso@7 277 echo "" && exit 1
pankso@7 278 fi
pankso@7 279 else
pankso@7 280 echo "no compile_rules" >> $LOG
pankso@7 281 echo -e "No compile rules for $PACKAGE...\n"
pankso@7 282 fi
pankso@7 283 }
pankso@7 284
pankso@22 285 # Copy all generic files (locale, pixmaps, .desktop). We use standard path,
pankso@22 286 # so some packages need to copy these files with the receipt and genpkg_rules.
pankso@22 287 # This function is executed by gen_package when 'tazwok genpkg'.
pankso@22 288 copy_generic_files()
pankso@22 289 {
pankso@22 290 # In most case locale are in $_pkg/usr/share/locale so we copy files
pankso@22 291 # using generic variables and $LOCALE from Tazwok config file.
pankso@22 292 if [ ! "$LOCALE" = "" ]; then
pankso@22 293 if [ -d "$_pkg/usr/share/locale" ]; then
pankso@22 294 mkdir -p $fs/usr/share/locale
pankso@22 295 for i in $LOCALE
pankso@22 296 do
pankso@22 297 cp -a $_pkg/usr/share/locale/$i \
pankso@22 298 $fs/usr/share/locale 2>/dev/null
pankso@22 299 done
pankso@22 300 fi
pankso@22 301 fi
pankso@22 302 # Pixmaps. Some icons/images can be add trough genpkg_rules and
pankso@22 303 # generic copy can be disable with GENERIC_PIXMAPS="no" in pkg receipt.
pankso@22 304 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
pankso@22 305 if [ -d "$_pkg/usr/share/pixmaps" ]; then
pankso@22 306 mkdir -p $fs/usr/share/pixmaps
pankso@22 307 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.* \
pankso@22 308 $fs/usr/share/pixmaps 2>/dev/null
pankso@23 309 fi
pankso@23 310 # Custom or home made PNG pixmap can be in stuff.
pankso@23 311 if [ -f "stuff/$PACKAGE.png" ]; then
pankso@23 312 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@22 313 fi
pankso@22 314 fi
pankso@22 315 # Desktop entry (.desktop).
pankso@22 316 if [ -d "$_pkg/usr/share/applications" ]; then
pankso@22 317 cp -a $_pkg/usr/share/applications $fs/usr/share
pankso@23 318 fi
pankso@23 319 # Home made desktop file can be in stuff.
pankso@23 320 if [ -f "stuff/$PACKAGE.desktop" ]; then
pankso@23 321 mkdir -p $fs/usr/share/applications
pankso@23 322 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@22 323 fi
pankso@22 324 }
pankso@22 325
pankso@25 326 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
pankso@25 327 strip_package()
pankso@25 328 {
pankso@25 329 echo -n "Executing strip on all files..."
pankso@25 330 # Binaries.
pankso@25 331 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@25 332 do
pankso@25 333 if [ -d "$dir" ]; then
pankso@25 334 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
pankso@25 335 fi
pankso@25 336 done
pankso@25 337 # Libraries.
pankso@25 338 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
pankso@25 339 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
pankso@25 340 status
pankso@25 341 }
pankso@25 342
pankso@7 343 # Creat a package tree and build the gziped cpio archive
pankso@7 344 # to make a SliTaz (.tazpkg) package.
pankso@7 345 gen_package()
pankso@7 346 {
pankso@7 347 check_root
pankso@7 348 check_for_package_on_cmdline
pankso@7 349 check_for_receipt
pankso@7 350 . $RECEIPT
pankso@7 351 check_for_wanted
pankso@7 352 cd $WOK/$PACKAGE
pankso@7 353 # Remove old Tazwok package files.
pankso@7 354 if [ -d "taz" ]; then
pankso@7 355 rm -rf taz
pankso@7 356 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
pankso@7 357 fi
pankso@7 358 # Creat the package tree and set usful variables.
pankso@7 359 mkdir -p taz/$PACKAGE-$VERSION/fs
pankso@7 360 fs=taz/$PACKAGE-$VERSION/fs
pankso@7 361 # Set $src for standards package and $_pkg variables.
pankso@7 362 if [ "$WANTED" = "" ]; then
pankso@7 363 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
pankso@7 364 _pkg=$src/_pkg
pankso@7 365 fi
pankso@7 366 if [ ! "$SOURCE" = "" ]; then
pankso@7 367 src=$WOK/$PACKAGE/$SOURCE-$VERSION
pankso@7 368 _pkg=$src/_pkg
pankso@7 369 fi
pankso@7 370 cd $WOK/$PACKAGE
pankso@22 371 # Execute genpkg_rules and copy generic files to build the package.
pankso@7 372 echo ""
pankso@7 373 echo "Bulding $PACKAGE with the receipt..."
pankso@7 374 echo "================================================================================"
pankso@22 375 if [ `cat $RECEIPT | grep ^genpkg_rules` ]; then
pankso@7 376 # Log process.
pankso@7 377 echo "executing genpkg_rules" >> $LOG
pankso@7 378 genpkg_rules
pankso@25 379 cd $WOK/$PACKAGE
pankso@24 380 # Skip generic files for packages with a WANTED variable
pankso@24 381 # (dev and splited pkgs).
pankso@24 382 if [ ! "$WANTED" = "" ]; then
pankso@24 383 continue
pankso@24 384 else
pankso@24 385 copy_generic_files
pankso@24 386 fi
pankso@25 387 strip_package
pankso@7 388 else
pankso@7 389 echo "No package rules to gen $PACKAGE..."
pankso@22 390 exit 1
pankso@7 391 fi
pankso@22 392 # Copy the receipt and description (if exist) in the binary package tree.
pankso@7 393 cd $WOK/$PACKAGE
pankso@7 394 echo -n "Copying the receipt..."
pankso@7 395 cp receipt taz/$PACKAGE-$VERSION
pankso@7 396 status
pankso@7 397 if [ -f "description.txt" ]; then
pankso@7 398 echo -n "Copying the description file..."
pankso@7 399 cp description.txt taz/$PACKAGE-$VERSION
pankso@7 400 status
pankso@7 401 fi
pankso@7 402 # Creat the files.list by redirecting find outpout.
pankso@7 403 echo -n "Creating the list of files..."
pascal@15 404 cd taz/$PACKAGE-$VERSION
pascal@13 405 LAST_FILE=""
pascal@15 406 ( find fs -print; echo ) | while read file; do
pascal@13 407 if [ "$LAST_FILE" != "" ]; then
pascal@15 408 case "$file" in
pascal@13 409 $LAST_FILE/*)
pascal@15 410 case "$(ls -ld "$LAST_FILE")" in
pascal@15 411 drwxr-xr-x\ *\ root\ *\ root\ *);;
pascal@15 412 *) echo ${LAST_FILE#fs};;
pascal@13 413 esac;;
pascal@15 414 *) echo ${LAST_FILE#fs};;
pascal@13 415 esac
pascal@13 416 fi
pascal@15 417 LAST_FILE="$file"
pascal@15 418 done > files.list
pankso@7 419 status
pankso@7 420 # Build cpio archives. Find, cpio and gzip the fs, finish by
pankso@7 421 # removing the fs tree.
pankso@7 422 echo -n "Compressing the fs... "
pascal@13 423 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
pankso@7 424 echo -n "Creating full cpio archive... "
pankso@7 425 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
pankso@7 426 # Restore package tree in case we want to browse it.
pankso@7 427 echo -n "Restoring original package tree... "
pascal@14 428 zcat fs.cpio.gz | cpio -id
pascal@14 429 rm fs.cpio.gz && cd ..
pankso@7 430 # Log process.
pankso@7 431 echo "$PACKAGE-$VERSION.tazpkg (done)" >> $LOG
pankso@7 432 echo "================================================================================"
pankso@7 433 echo "Package $PACKAGE ($VERSION) generated."
pankso@7 434 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg`"
pankso@7 435 echo ""
pankso@7 436 }
pankso@7 437
pankso@7 438 ###################
pankso@7 439 # Tazwok commands #
pankso@7 440 ###################
pankso@7 441
pankso@7 442 case "$COMMAND" in
pankso@7 443 stats)
pankso@7 444 # Tazwok general statistics from the config file the wok.
pankso@7 445 #
pankso@7 446 echo ""
pankso@7 447 echo -e "\033[1mTazwok configuration statistics\033[0m
pankso@7 448 ================================================================================
pankso@7 449 Wok directory : $WOK
pankso@7 450 Packages repository : $PACKAGES_REPOSITORY
pankso@7 451 Sources repository : $SOURCES_REPOSITORY
pankso@7 452 Packages in the wok : `ls -1 $WOK | wc -l`
pankso@16 453 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
pankso@7 454 ================================================================================"
pankso@7 455 echo ""
pankso@7 456 ;;
pankso@7 457 list)
pankso@7 458 # List packages in wok directory. User can specifiy a category
pankso@7 459 #
pankso@7 460 if [ "$2" = "category" ]; then
pankso@7 461 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
pankso@7 462 exit 0
pankso@7 463 fi
pankso@7 464 # Check for an asked category.
pankso@7 465 if [ -n "$2" ]; then
pankso@7 466 ASKED_CATEGORY=$2
pankso@7 467 echo ""
pankso@7 468 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
pankso@7 469 echo "================================================================================"
pankso@7 470 for pkg in $WOK/*
pankso@7 471 do
pankso@7 472 . $pkg/receipt
pankso@7 473 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@7 474 echo -n "$PACKAGE"
pankso@7 475 echo -e "\033[24G $VERSION"
pankso@7 476 packages=$(($packages+1))
pankso@7 477 fi
pankso@7 478 done
pankso@7 479 echo "================================================================================"
pankso@7 480 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
pankso@7 481 else
pankso@7 482 # By default list all packages and version.
pankso@7 483 echo ""
pankso@7 484 echo -e "\033[1mList of packages in the wok\033[0m"
pankso@7 485 echo "================================================================================"
pankso@7 486 for pkg in $WOK/*
pankso@7 487 do
pankso@7 488 . $pkg/receipt
pankso@7 489 echo -n "$PACKAGE"
pankso@7 490 echo -en "\033[24G $VERSION"
pankso@7 491 echo -e "\033[42G $CATEGORY"
pankso@7 492 packages=$(($packages+1))
pankso@7 493 done
pankso@7 494 echo "================================================================================"
pankso@7 495 echo -e "$packages packages avalaible in the wok.\n"
pankso@7 496 fi
pankso@7 497 ;;
pankso@7 498 info)
pankso@7 499 # Informations about package.
pankso@7 500 #
pankso@7 501 check_for_package_on_cmdline
pankso@7 502 check_for_receipt
pankso@7 503 . $WOK/$PACKAGE/receipt
pankso@7 504 echo ""
pankso@7 505 echo -e "\033[1mTazwok package informations\033[0m
pankso@7 506 ================================================================================
pankso@7 507 Package : $PACKAGE
pankso@7 508 Version : $VERSION
pankso@7 509 Category : $CATEGORY
pankso@7 510 Short desc : $SHORT_DESC
pankso@7 511 Maintainer : $MAINTAINER"
pankso@7 512 if [ ! "$WEB_SITE" = "" ]; then
pankso@7 513 echo "Web site : $WEB_SITE"
pankso@7 514 fi
pankso@7 515 if [ ! "$DEPENDS" = "" ]; then
pankso@7 516 echo "Depends : $DEPENDS"
pankso@7 517 fi
pankso@7 518 if [ ! "$WANTED" = "" ]; then
pankso@7 519 echo "Wanted src : $WANTED"
pankso@7 520 fi
pankso@7 521 echo "================================================================================"
pankso@7 522 echo ""
pankso@7 523
pankso@7 524 ;;
pankso@7 525 check-log)
pankso@7 526 # We just cat the file log to view process info.
pankso@7 527 #
pankso@7 528 if [ ! -f "$LOG" ]; then
pankso@7 529 echo -e "\nNo process log found. The package is probably not cook.\n"
pankso@7 530 exit 0
pankso@7 531 else
pankso@7 532 echo ""
pankso@7 533 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
pankso@7 534 echo "================================================================================"
pankso@7 535 cat $LOG
pankso@7 536 echo "================================================================================"
pankso@7 537 echo ""
pankso@7 538 fi
pankso@7 539 ;;
pankso@7 540 search)
pankso@7 541 # Search for a package by pattern or name.
pankso@7 542 #
pankso@7 543 if [ -z "$2" ]; then
pankso@7 544 echo -e "\nPlease specify a pattern or a package name to search."
pankso@7 545 echo -e "Example : 'tazwok search gcc'.\n"
pankso@7 546 exit 0
pankso@7 547 fi
pankso@7 548 echo ""
pankso@7 549 echo -e "\033[1mSearch result for :\033[0m $2"
pankso@7 550 echo "================================================================================"
pankso@7 551 list=`ls -1 $WOK | grep $2`
pankso@7 552 for pkg in $list
pankso@7 553 do
pankso@7 554 . $WOK/$pkg/receipt
pankso@7 555 echo -n "$PACKAGE "
pankso@7 556 echo -en "\033[24G $VERSION"
pankso@7 557 echo -e "\033[42G $CATEGORY"
pankso@7 558 packages=$(($packages+1))
pankso@7 559 done
pankso@7 560 echo "================================================================================"
pankso@7 561 echo "$packages packages found for : $2"
pankso@7 562 echo ""
pankso@7 563 ;;
pankso@7 564 compile)
pankso@7 565 # Configure and make a package with the receipt.
pankso@7 566 #
pankso@7 567 compile_package
pankso@7 568 ;;
pankso@7 569 genpkg)
pankso@7 570 # Generate a package
pankso@7 571 #
pankso@7 572 gen_package
pankso@7 573 ;;
pankso@7 574 cook)
pankso@7 575 # Compile and generate a package. Just execute tazwok with
pankso@7 576 # the good commands.
pankso@7 577 #
pankso@7 578 check_root
pankso@7 579 compile_package
pankso@7 580 gen_package
pankso@7 581 ;;
pankso@7 582 cook-list)
pankso@7 583 # Cook all packages listed in a file. The path to the cooklist must
pankso@7 584 # be specified on the cmdline.
pankso@7 585 #
pankso@7 586 check_root
pankso@7 587 check_for_list
pankso@7 588 for pkg in $LIST
pankso@7 589 do
pankso@7 590 tazwok compile $pkg
pankso@7 591 tazwok genpkg $pkg
pankso@7 592 done
pankso@7 593 ;;
pankso@7 594 clean)
pankso@7 595 # Clean up a package work directory.
pankso@7 596 #
pankso@7 597 check_for_package_on_cmdline
pankso@7 598 check_for_receipt
pankso@7 599 . $RECEIPT
pankso@7 600 cd $WOK/$PACKAGE
pankso@7 601 echo ""
pankso@7 602 echo "Cleaning $PACKAGE..."
pankso@7 603 echo "================================================================================"
pankso@7 604 if [ -d "taz" ]; then
pankso@7 605 echo -n "Removing taz files..."
pankso@7 606 rm -rf taz && status
pankso@7 607 fi
pankso@7 608 # Remove source tree if exist.
pankso@7 609 if [ -d "$PACKAGE-$VERSION" ]; then
pankso@7 610 echo -n "Removing source files..."
pankso@7 611 rm -rf $PACKAGE-$VERSION && status
pankso@7 612 fi
pankso@7 613 if [ -d "$SOURCE-$VERSION" ]; then
pankso@7 614 echo -n "Removing source files..."
pankso@7 615 rm -rf $SOURCE-$VERSION && status
pankso@7 616 fi
pankso@7 617 # Remove an envental $PACKAGE-build directory.
pankso@7 618 if [ -d "$PACKAGE-build" ]; then
pankso@7 619 echo -n "Removing build tree..."
pankso@7 620 rm -rf $PACKAGE-build && status
pankso@7 621 fi
pankso@7 622 # Remove process log file.
pankso@7 623 if [ -f "process.log" ]; then
pankso@7 624 echo -n "Removing process log file..."
pankso@7 625 rm process.log && status
pankso@7 626 fi
pankso@7 627 echo "$PACKAGE is clean. You can cook it again..."
pankso@7 628 echo ""
pankso@7 629 ;;
pankso@7 630 gen-clean-wok)
pankso@7 631 # Generate a clean wok from the current wok by copying all receipt
pankso@7 632 # and stuff directory.
pankso@7 633 #
pankso@7 634 if [ -z "$2" ]; then
pankso@7 635 echo -e "\nPlease specify the destination for the new clean wok.\n"
pankso@7 636 exit 0
pankso@7 637 else
pankso@7 638 dest=$2
pankso@7 639 mkdir -p $dest
pankso@7 640 fi
pankso@7 641 echo "New wok is going to : $dest"
pankso@7 642 for pkg in `ls -1 $WOK`
pankso@7 643 do
pankso@7 644 echo "----"
pankso@7 645 echo -n "Preparing $pkg..."
pankso@7 646 mkdir -p $dest/$pkg
pankso@7 647 status
pankso@7 648 echo -n "Copying the receipt..."
pankso@7 649 cp -a $WOK/$pkg/receipt $dest/$pkg
pankso@7 650 status
pankso@7 651 if [ -d "$WOK/$pkg/stuff" ]; then
pankso@7 652 echo -n "Copying all the stuff directory..."
pankso@7 653 cp -a $WOK/$pkg/stuff $dest/$pkg
pankso@7 654 status
pankso@7 655 fi
pankso@7 656 done
pankso@7 657 echo "================================================================================"
pankso@7 658 echo "Clean wok generated in : $dest"
pankso@7 659 echo "Packages cleaned : `ls -1 $dest | wc -l`"
pankso@7 660 echo ""
pankso@7 661 ;;
pankso@7 662 clean-wok)
pankso@7 663 # Clean all packages in the work directory
pankso@7 664 #
pankso@7 665 for pkg in `ls -1 $WOK`
pankso@7 666 do
pankso@7 667 tazwok clean $pkg
pankso@7 668 done
pankso@7 669 echo "================================================================================"
pankso@7 670 echo "`ls -1 $WOK | wc -l` packages cleaned."
pankso@7 671 echo ""
pankso@7 672 ;;
pankso@7 673 gen-list)
pankso@7 674 # cd in the directory to creat a packages.list and the md5sum file.
pankso@7 675 # Sed is used to remove all the .tazpkg extensions from the
pankso@7 676 # packages.list. The directory to move in by default is the repository
pankso@7 677 # if $3 is not empty cd into $3.
pankso@7 678 #
pankso@7 679 if [ -z "$2" ]; then
pankso@7 680 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
pankso@7 681 else
pankso@7 682 if [ -d "$2" ]; then
pankso@7 683 PACKAGES_REPOSITORY=$2
pankso@7 684 else
pankso@7 685 echo -e "\nUnable to find directory : $2\n"
pankso@7 686 exit 0
pankso@7 687 fi
pankso@7 688 fi
pankso@7 689 cd $PACKAGES_REPOSITORY
pankso@7 690 # Remove old packages.list and md5sum, it well be soon rebuild.
pankso@7 691 rm -f packages.list packages.md5
pankso@7 692 echo ""
pankso@7 693 echo "Repository path : $PACKAGES_REPOSITORY"
pankso@7 694 echo -n "Creating the packages list... "
pankso@17 695 ls -1 *.tazpkg > /tmp/packages.list
pankso@7 696 sed -i s/'.tazpkg'/''/ /tmp/packages.list
pankso@7 697 status
pankso@7 698 echo -n "Building the md5sum for all packages... "
pankso@7 699 md5sum * > packages.md5
pankso@7 700 status
pankso@7 701 mv /tmp/packages.list $PACKAGES_REPOSITORY
pankso@7 702 echo "================================================================================"
pankso@7 703 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
pankso@7 704 echo "$pkgs packages in the repository."
pankso@7 705 echo ""
pankso@7 706 ;;
pankso@7 707 new-tree)
pankso@7 708 # Just creat a few directories and gen a empty receipt to prepare
pankso@7 709 # the creation of a new package.
pankso@7 710 #
pankso@7 711 check_for_package_on_cmdline
pankso@7 712 if [ -d $WOK/$PACKAGE ]; then
pankso@7 713 echo -e "\n$PACKAGE package tree already exist.\n"
pankso@7 714 exit 0
pankso@7 715 fi
pankso@7 716 echo "Creating : $WOK/$PACKAGE"
pankso@7 717 mkdir $WOK/$PACKAGE
pankso@7 718 cd $WOK/$PACKAGE
pankso@7 719 echo -n "Preparing the receipt..."
pankso@7 720 #
pankso@7 721 # Default receipt begin.
pankso@7 722 #
pankso@7 723 echo "# SliTaz package receipt." > receipt
pankso@7 724 echo "" >> receipt
pankso@7 725 echo "PACKAGE=\"$PACKAGE\"" >> receipt
pankso@7 726 # Finish the empty receipt.
pankso@7 727 cat >> receipt << "EOF"
pankso@7 728 VERSION=""
pankso@7 729 CATEGORY=""
pankso@7 730 SHORT_DESC=""
pankso@7 731 MAINTAINER=""
pankso@7 732 DEPENDS=""
pankso@7 733 TARBALL="$PACKAGE-$VERSION.tar.gz"
pankso@7 734 WEB_SITE=""
pankso@7 735 WGET_URL=""
pankso@7 736
pankso@7 737 # Rules to configure and make the package.
pankso@7 738 compile_rules()
pankso@7 739 {
pankso@7 740 cd $src
pankso@7 741 ./configure --prefix=/usr --infodir=/usr/share/info \
pankso@7 742 --mandir=/usr/share/man $CONFIGURE_ARGS
pankso@7 743 make
pankso@7 744 make DESTDIR=$PWD/_pkg install
pankso@7 745 }
pankso@7 746
pankso@7 747 # Rules to gen a SliTaz package suitable for Tazpkg.
pankso@7 748 genpkg_rules()
pankso@7 749 {
pankso@7 750 mkdir -p $fs/usr
pankso@7 751 cp -a $_pkg/usr/bin $fs/usr
pankso@7 752 strip -s $fs/usr/bin/*
pankso@7 753 }
pankso@7 754
pankso@7 755 EOF
pankso@7 756 #
pankso@7 757 # Default receipt end.
pankso@7 758 #
pankso@7 759 status
pankso@7 760 # Interactive mode, asking and seding.
pankso@7 761 if [ "$3" = "--interactive" ]; then
pankso@7 762 echo "Entering in interactive mode..."
pankso@7 763 echo "================================================================================"
pankso@7 764 echo "Package : $PACKAGE"
pankso@7 765 # Version.
pankso@7 766 echo -n "Version : " ; read anser
pankso@7 767 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
pankso@7 768 # Category.
pankso@7 769 echo -n "Category : " ; read anser
pankso@7 770 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
pankso@7 771 # Short description.
pankso@7 772 echo -n "Short desc : " ; read anser
pankso@7 773 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
pankso@7 774 # Maintainer.
pankso@7 775 echo -n "Maintainer : " ; read anser
pankso@7 776 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
pankso@7 777 # Web site.
pankso@7 778 echo -n "Web site : " ; read anser
pankso@7 779 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
pankso@7 780 echo ""
pankso@7 781 # Wget URL.
pankso@7 782 echo "Wget URL to download source tarball."
pankso@7 783 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
pankso@7 784 echo -n "Wget url : " ; read anser
pankso@7 785 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
pankso@7 786 # Ask for a stuff dir.
pankso@7 787 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
pankso@7 788 if [ "$anser" = "y" ]; then
pankso@7 789 echo -n "Creating the stuff directory..."
pankso@7 790 mkdir stuff && status
pankso@7 791 fi
pankso@7 792 # Ask for a description file.
pankso@7 793 echo -n "Are you going to write a description ? (y/N) : " ; read anser
pankso@7 794 if [ "$anser" = "y" ]; then
pankso@7 795 echo -n "Creating the description.txt file..."
pankso@7 796 echo "" > description.txt && status
pankso@7 797 fi
pankso@7 798 echo "================================================================================"
pankso@7 799 echo ""
pankso@7 800 fi
pankso@7 801 ;;
pankso@7 802 remove)
pankso@7 803 # Remove a package from the wok.
pankso@7 804 #
pankso@7 805 check_for_package_on_cmdline
pankso@7 806 echo ""
pankso@7 807 echo -n "Removing $PACKAGE..."
pankso@7 808 rm -rf $WOK/$PACKAGE && status
pankso@7 809 echo ""
pankso@7 810 ;;
pankso@7 811 usage|*)
pankso@7 812 # Print usage also for all unknow commands.
pankso@7 813 #
pankso@7 814 usage
pankso@7 815 ;;
pankso@7 816 esac
pankso@7 817
pankso@7 818 exit 0