tazwok annotate tazwok @ rev 32

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