tazwok annotate tazwok @ rev 38

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