tazwok annotate tazwok @ rev 14

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