tazwok rev 7

Add tazwok using version 1.2
author Christophe Lincoln <pankso@slitaz.org>
date Wed Dec 12 18:54:31 2007 +0100 (2007-12-12)
parents 93cdf8506d92
children 16b2b1a5afc9
files tazwok
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tazwok	Wed Dec 12 18:54:31 2007 +0100
     1.3 @@ -0,0 +1,701 @@
     1.4 +#!/bin/sh
     1.5 +# Tazwok - SliTaz source compiler and binary packages generator/cooker.
     1.6 +#
     1.7 +# Tazwok can compile source package and creat binary packages suitable for
     1.8 +# Tazpkg (Tiny Autonomus zone package manager). You can build individuals
     1.9 +# package or a list a packages with one command, rebuild the full distro,
    1.10 +# generate a packages repository and also list and get info about packages.
    1.11 +#
    1.12 +# (C) 2007 SliTaz - GNU General Public License.
    1.13 +# Author : <pankso@slitaz.org>
    1.14 +#
    1.15 +VERSION=1.2
    1.16 +
    1.17 +####################
    1.18 +# Tazwok variables #
    1.19 +####################
    1.20 +
    1.21 +# Packages categories.
    1.22 +CATEGORIES="base-system base-apps x-window extra"
    1.23 +
    1.24 +# Use words rater than numbers in the code.
    1.25 +COMMAND=$1
    1.26 +PACKAGE=$2
    1.27 +LIST=$2
    1.28 +
    1.29 +# Include config file or exit if any file found.
    1.30 +if [ -f "/etc/tazwok.conf" ]; then
    1.31 +	. /etc/tazwok.conf
    1.32 +else
    1.33 +	echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
    1.34 +	echo -e "Please read the Tazwok documentation.\n"
    1.35 +	exit 0
    1.36 +fi
    1.37 +
    1.38 +# Creat Taz wok needed directories if user is root.
    1.39 +if test $(id -u) = 0 ; then
    1.40 +	# Check for the wok directory.
    1.41 +	if [ ! -d "$WOK" ]; then
    1.42 +		echo "Creating the wok directory..."
    1.43 +		mkdir -p $WOK
    1.44 +		chmod 777 $WOK
    1.45 +	fi
    1.46 +	# Check for the packages repository.
    1.47 +	if [ ! -d "$PACKAGES_REPOSITORY" ]; then
    1.48 +		echo "Creating the packages repository..."
    1.49 +		mkdir -p $PACKAGES_REPOSITORY
    1.50 +	fi
    1.51 +	# Check for the sources repository.
    1.52 +	if [ ! -d "$SOURCES_REPOSITORY" ]; then
    1.53 +		echo "Creating the sources repository..."
    1.54 +		mkdir -p $PACKAGES_REPOSITORY
    1.55 +	fi
    1.56 +fi
    1.57 +
    1.58 +# The path to the most important file used by Tazwok.
    1.59 +# The receipt is used to compile the source code and
    1.60 +# gen suitables packages for Tazpkg.
    1.61 +RECEIPT="$WOK/$PACKAGE/receipt"
    1.62 +
    1.63 +# The path to the process log file.
    1.64 +LOG="$WOK/$PACKAGE/process.log"
    1.65 +
    1.66 +####################
    1.67 +# Tazwok functions #
    1.68 +####################
    1.69 +
    1.70 +# Print the usage (English).
    1.71 +usage ()
    1.72 +{
    1.73 +	echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
    1.74 +\033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir] [--option]
    1.75 +\033[1mCommands: \033[0m\n
    1.76 +  usage          Print this short usage.
    1.77 +  stats          Print Tazwok statistics from the config file and the wok.
    1.78 +  list           List all packages in the wok tree or by category.
    1.79 +  info           Get informations about a package in the wok.
    1.80 +  check-log      Check the process log file of a package.
    1.81 +  search         Search for a package in the wok by pattern or name.
    1.82 +  compile        Configure and build the package using the receipt rules.
    1.83 +  genpkg         Generate a suitable package for Tazpkg with the rules.
    1.84 +  cook           Compile and generate a package directly.
    1.85 +  cook-list      Cook all packages specified in the list by order.
    1.86 +  clean          Clean all generated files in the package tree.
    1.87 +  new-tree       Prepare a new package tree and receipt (--interactive).
    1.88 +  gen-list       Generate a packages.list and md5sum for a repository.
    1.89 +  gen-clean-wok  Gen a clean wok in a dir ('clean-wok' cleans current wok).
    1.90 +  remove         Remove a package from the wok.\n"
    1.91 +}
    1.92 +
    1.93 +# Status function.
    1.94 +status()
    1.95 +{
    1.96 +	local CHECK=$?
    1.97 +	echo -en "\\033[70G[ "
    1.98 +	if [ $CHECK = 0 ]; then
    1.99 +		echo -en "\\033[1;33mOK"
   1.100 +	else
   1.101 +		echo -en "\\033[1;31mFailed"
   1.102 +	fi
   1.103 +	echo -e "\\033[0;39m ]"
   1.104 +}
   1.105 +
   1.106 +# Check if user is root.
   1.107 +check_root()
   1.108 +{
   1.109 +	if test $(id -u) != 0 ; then
   1.110 +	   echo -e "\nYou must be root to run `basename $0` with this option."
   1.111 +	   echo -e "Please type 'su' and root password to become super-user.\n"
   1.112 +	   exit 0
   1.113 +	fi
   1.114 +}
   1.115 +
   1.116 +# Check for a package name on cmdline.
   1.117 +check_for_package_on_cmdline()
   1.118 +{
   1.119 +	if [ -z "$PACKAGE" ]; then
   1.120 +		echo -e "\nYou must specify a package name on the command line."
   1.121 +		echo -e "Example : tazwok $COMMAND package\n"
   1.122 +		exit 0
   1.123 +	fi
   1.124 +}
   1.125 +
   1.126 +# Check for the receipt of a package used to cook.
   1.127 +check_for_receipt()
   1.128 +{
   1.129 +	if [ ! -f "$RECEIPT" ]; then
   1.130 +		echo -e "\nUnable to find the receipt : $RECEIPT\n"
   1.131 +		exit 0
   1.132 +	fi
   1.133 +}
   1.134 +
   1.135 +# Check for a specified file list on cmdline.
   1.136 +check_for_list()
   1.137 +{
   1.138 +	if [ -z "$LIST" ]; then
   1.139 +		echo -e "\nPlease specify the path to the list of packages to cook.\n"
   1.140 +		exit 0
   1.141 +	fi
   1.142 +	# Check if the list of packages exist.
   1.143 +	if [ -f "$LIST" ]; then
   1.144 +		LIST=`cat $LIST`
   1.145 +	else
   1.146 +		echo -e "\nUnable to find $LIST packages list.\n"
   1.147 +		exit 0
   1.148 +	fi
   1.149 +}
   1.150 +
   1.151 +# Check for the wanted package if specified in WANTED
   1.152 +# receipt variable. Set the $src/$_pkg variable to help compiling
   1.153 +# and generating packages.
   1.154 +check_for_wanted()
   1.155 +{
   1.156 +	if [ ! "$WANTED" = "" ]; then
   1.157 +		echo -n "Checking for the wanted package..."
   1.158 +		if [ ! -d "$WOK/$WANTED" ]; then
   1.159 +			echo -e "\nWanted package is missing in the work directory.\n"
   1.160 +			exit 0
   1.161 +		fi
   1.162 +		status
   1.163 +		# Set wanted src path.
   1.164 +		src=$WOK/$WANTED/$WANTED-$VERSION
   1.165 +		_pkg=$src/_pkg
   1.166 +	fi
   1.167 +}
   1.168 +
   1.169 +# Configure and make a package with the receipt.
   1.170 +compile_package()
   1.171 +{
   1.172 +	check_for_package_on_cmdline
   1.173 +	# Include the receipt to get all needed variables and functions
   1.174 +	# and cd into the work directory to start the work.
   1.175 +	check_for_receipt
   1.176 +	. $RECEIPT
   1.177 +	# Log the package name and date.
   1.178 +	echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
   1.179 +	echo "package $PACKAGE (compile)" >> $LOG
   1.180 +	# Set wanted $src variable to help compiling.
   1.181 +	if [ ! "$SOURCE" = "" ]; then
   1.182 +		src=$WOK/$PACKAGE/$SOURCE-$VERSION
   1.183 +	else
   1.184 +		src=$WOK/$PACKAGE/$PACKAGE-$VERSION
   1.185 +	fi
   1.186 +	check_for_wanted
   1.187 +	echo ""
   1.188 +	echo "Starting to cook $PACKAGE..."
   1.189 +	echo "================================================================================"
   1.190 +	# Check for src tarball and wget if needed.
   1.191 +	if [ ! "$TARBALL" = "" ]; then
   1.192 +		echo "Checking for source tarball... "
   1.193 +		if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   1.194 +			cd $SOURCES_REPOSITORY
   1.195 +			wget $WGET_URL
   1.196 +			# Exit if download failed to avoid errors.
   1.197 +			if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   1.198 +				echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
   1.199 +				exit 1
   1.200 +			fi
   1.201 +		else
   1.202 +			echo -n "Source tarball exit... "
   1.203 +			status
   1.204 +		fi
   1.205 +		# Untaring source if necessary. We dont need to extract source if
   1.206 +		# the package is build with a wanted source package.
   1.207 +		if [ "$WANTED" = "" ]; then
   1.208 +			if [ ! -d $src ]; then
   1.209 +				# Log process.
   1.210 +				echo "untaring $TARBALL" >> $LOG
   1.211 +				echo -n "Untaring $TARBALL... "
   1.212 +				if [ "`basename $TARBALL | grep tar.bz2`" ]; then
   1.213 +					tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
   1.214 +				else
   1.215 +					tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
   1.216 +				fi
   1.217 +				status
   1.218 +			else
   1.219 +				echo -n "Source direcory exit... " && status
   1.220 +			fi
   1.221 +		fi
   1.222 +	fi
   1.223 +	cd $WOK/$PACKAGE
   1.224 +	# Log and execute compile_rules function if it exist, to configure and
   1.225 +	# make the package if it exist.
   1.226 +	if [ `cat $RECEIPT | grep compile_rules` ]; then
   1.227 +		echo "executing compile_rules" >> $LOG
   1.228 +		compile_rules
   1.229 +		# Exit if compilation failed so the binary package
   1.230 +		# is not generated when using the cook comand.
   1.231 +		local CHECK=$?
   1.232 +		if [ $CHECK = 0 ]; then
   1.233 +			echo "================================================================================"
   1.234 +			echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
   1.235 +			echo ""
   1.236 +			echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
   1.237 +		else
   1.238 +			echo "================================================================================"
   1.239 +			echo "Compilation failed. Please read the compilator output."
   1.240 +			echo "" && exit 1
   1.241 +		fi
   1.242 +	else
   1.243 +		echo "no compile_rules" >> $LOG
   1.244 +		echo -e "No compile rules for $PACKAGE...\n"
   1.245 +	fi
   1.246 +}
   1.247 +
   1.248 +# Creat a package tree and build the gziped cpio archive
   1.249 +# to make a SliTaz (.tazpkg) package.
   1.250 +gen_package()
   1.251 +{
   1.252 +	check_root
   1.253 +	check_for_package_on_cmdline
   1.254 +	check_for_receipt
   1.255 +	. $RECEIPT
   1.256 +	check_for_wanted
   1.257 +	cd $WOK/$PACKAGE
   1.258 +	# Remove old Tazwok package files.
   1.259 +	if [ -d "taz" ]; then
   1.260 +		rm -rf taz
   1.261 +		rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
   1.262 +	fi
   1.263 +	# Creat the package tree and set usful variables.
   1.264 +	mkdir -p taz/$PACKAGE-$VERSION/fs
   1.265 +	fs=taz/$PACKAGE-$VERSION/fs
   1.266 +	# Set $src for standards package and $_pkg variables.
   1.267 +	if [ "$WANTED" = "" ]; then
   1.268 +		src=$WOK/$PACKAGE/$PACKAGE-$VERSION
   1.269 +		_pkg=$src/_pkg
   1.270 +	fi
   1.271 +	if [ ! "$SOURCE" = "" ]; then
   1.272 +		src=$WOK/$PACKAGE/$SOURCE-$VERSION
   1.273 +		_pkg=$src/_pkg
   1.274 +	fi
   1.275 +	cd $WOK/$PACKAGE
   1.276 +	# Execute genpkg_rules to build the package.
   1.277 +	echo ""
   1.278 +	echo "Bulding $PACKAGE with the receipt..."
   1.279 +	echo "================================================================================"
   1.280 +	if [ `cat $RECEIPT | grep genpkg_rules` ]; then
   1.281 +		# Log process.
   1.282 +		echo "executing genpkg_rules" >> $LOG
   1.283 +		genpkg_rules
   1.284 +	else
   1.285 +		echo "No package rules to gen $PACKAGE..."
   1.286 +	fi
   1.287 +	# Copy the receipt and description (if exist) in
   1.288 +	# the binary package tree.
   1.289 +	cd $WOK/$PACKAGE
   1.290 +	echo -n "Copying the receipt..."
   1.291 +	cp receipt taz/$PACKAGE-$VERSION
   1.292 +	status
   1.293 +	if [ -f "description.txt" ]; then
   1.294 +		echo -n "Copying the description file..."
   1.295 +		cp description.txt taz/$PACKAGE-$VERSION
   1.296 +		status
   1.297 +	fi
   1.298 +	# Creat the files.list by redirecting find outpout.
   1.299 +	echo -n "Creating the list of files..."
   1.300 +	cd taz/$PACKAGE-$VERSION/fs
   1.301 +	find . -type f -print > ../files.list
   1.302 +	find . -type l -print >> ../files.list
   1.303 +	cd .. && sed -i s/'^.'/''/ files.list
   1.304 +	status
   1.305 +	# Build cpio archives. Find, cpio and gzip the fs, finish by
   1.306 +	# removing the fs tree.
   1.307 +	echo -n "Compressing the fs... "
   1.308 +	find fs -print | cpio -o -H newc > fs.cpio
   1.309 +	gzip fs.cpio && rm -rf fs
   1.310 +	echo -n "Creating full cpio archive... "
   1.311 +	find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
   1.312 +	# Restore package tree in case we want to browse it.
   1.313 +	echo -n "Restoring original package tree... "
   1.314 +	gzip -d fs.cpio.gz && cpio -id < fs.cpio
   1.315 +	rm fs.cpio && cd ..
   1.316 +	# Log process.
   1.317 +	echo "$PACKAGE-$VERSION.tazpkg (done)" >> $LOG
   1.318 +	echo "================================================================================"
   1.319 +	echo "Package $PACKAGE ($VERSION) generated."
   1.320 +	echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg`"
   1.321 +	echo ""
   1.322 +}
   1.323 +
   1.324 +###################
   1.325 +# Tazwok commands #
   1.326 +###################
   1.327 +
   1.328 +case "$COMMAND" in
   1.329 +	stats)
   1.330 +		# Tazwok general statistics from the config file the wok.
   1.331 +		#
   1.332 +		echo ""
   1.333 +		echo -e "\033[1mTazwok configuration statistics\033[0m
   1.334 +================================================================================
   1.335 +Wok directory        : $WOK
   1.336 +Packages repository  : $PACKAGES_REPOSITORY
   1.337 +Sources repository   : $SOURCES_REPOSITORY
   1.338 +Packages in the wok  : `ls -1 $WOK | wc -l`
   1.339 +Cooked packages      : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg | wc -l`
   1.340 +================================================================================"
   1.341 +		echo ""
   1.342 +		;;
   1.343 +	list)
   1.344 +		# List packages in wok directory. User can specifiy a category
   1.345 +		#
   1.346 +		if [ "$2" = "category" ]; then
   1.347 +			echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
   1.348 +			exit 0
   1.349 +		fi
   1.350 +		# Check for an asked category.
   1.351 +		if [ -n "$2" ]; then
   1.352 +			ASKED_CATEGORY=$2
   1.353 +			echo ""
   1.354 +			echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
   1.355 +			echo "================================================================================"
   1.356 +			for pkg in $WOK/*
   1.357 +			do
   1.358 +				. $pkg/receipt
   1.359 +				if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
   1.360 +					echo -n "$PACKAGE"
   1.361 +					echo -e "\033[24G $VERSION"
   1.362 +					packages=$(($packages+1))
   1.363 +				fi
   1.364 +			done
   1.365 +			echo "================================================================================"
   1.366 +			echo -e "$packages packages in category $ASKED_CATEGORY.\n"
   1.367 +		else
   1.368 +			# By default list all packages and version.
   1.369 +			echo ""
   1.370 +			echo -e "\033[1mList of packages in the wok\033[0m"
   1.371 +			echo "================================================================================"
   1.372 +			for pkg in $WOK/*
   1.373 +			do
   1.374 +				. $pkg/receipt
   1.375 +				echo -n "$PACKAGE"
   1.376 +				echo -en "\033[24G $VERSION"
   1.377 +				echo -e "\033[42G $CATEGORY"
   1.378 +				packages=$(($packages+1))
   1.379 +			done
   1.380 +			echo "================================================================================"
   1.381 +			echo -e "$packages packages avalaible in the wok.\n"
   1.382 +		fi
   1.383 +		;;
   1.384 +	info)
   1.385 +		# Informations about package.
   1.386 +		#
   1.387 +		check_for_package_on_cmdline
   1.388 +		check_for_receipt
   1.389 +		. $WOK/$PACKAGE/receipt
   1.390 +		echo ""
   1.391 +		echo -e "\033[1mTazwok package informations\033[0m
   1.392 +================================================================================
   1.393 +Package	   : $PACKAGE
   1.394 +Version	   : $VERSION
   1.395 +Category   : $CATEGORY
   1.396 +Short desc : $SHORT_DESC
   1.397 +Maintainer : $MAINTAINER"
   1.398 +		if [ ! "$WEB_SITE" = "" ]; then
   1.399 +			echo "Web site   : $WEB_SITE"
   1.400 +		fi
   1.401 +		if [ ! "$DEPENDS" = "" ]; then
   1.402 +			echo "Depends    : $DEPENDS"
   1.403 +		fi
   1.404 +		if [ ! "$WANTED" = "" ]; then
   1.405 +			echo "Wanted src : $WANTED"
   1.406 +		fi
   1.407 +		echo "================================================================================"
   1.408 +		echo ""
   1.409 +		
   1.410 +		;;
   1.411 +	check-log)
   1.412 +		# We just cat the file log to view process info.
   1.413 +		#
   1.414 +		if [ ! -f "$LOG" ]; then
   1.415 +			echo -e "\nNo process log found. The package is probably not cook.\n"
   1.416 +			exit 0
   1.417 +		else
   1.418 +			echo ""
   1.419 +			echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
   1.420 +			echo "================================================================================"
   1.421 +			cat $LOG
   1.422 +			echo "================================================================================"
   1.423 +			echo ""
   1.424 +		fi
   1.425 +		;;
   1.426 +	search)
   1.427 +		# Search for a package by pattern or name.
   1.428 +		#
   1.429 +		if [ -z "$2" ]; then
   1.430 +			echo -e "\nPlease specify a pattern or a package name to search."
   1.431 +			echo -e "Example : 'tazwok search gcc'.\n"
   1.432 +			exit 0
   1.433 +		fi
   1.434 +		echo ""
   1.435 +		echo -e "\033[1mSearch result for :\033[0m $2"
   1.436 +		echo "================================================================================"
   1.437 +		list=`ls -1 $WOK | grep $2`
   1.438 +		for pkg in $list
   1.439 +		do
   1.440 +			. $WOK/$pkg/receipt
   1.441 +			echo -n "$PACKAGE "
   1.442 +			echo -en "\033[24G $VERSION"
   1.443 +			echo -e "\033[42G $CATEGORY"
   1.444 +			packages=$(($packages+1))
   1.445 +		done
   1.446 +		echo "================================================================================"
   1.447 +		echo "$packages packages found for : $2"
   1.448 +		echo ""
   1.449 +		;;
   1.450 +	compile)
   1.451 +		# Configure and make a package with the receipt.
   1.452 +		#
   1.453 +		compile_package
   1.454 +		;;
   1.455 +	genpkg)
   1.456 +		# Generate a package
   1.457 +		#
   1.458 +		gen_package
   1.459 +		;;
   1.460 +	cook)
   1.461 +		# Compile and generate a package. Just execute tazwok with
   1.462 +		# the good commands.
   1.463 +		#
   1.464 +		check_root
   1.465 +		compile_package
   1.466 +		gen_package
   1.467 +		;;
   1.468 +	cook-list)
   1.469 +		# Cook all packages listed in a file. The path to the cooklist must
   1.470 +		# be specified on the cmdline.
   1.471 +		#
   1.472 +		check_root
   1.473 +		check_for_list
   1.474 +		for pkg in $LIST
   1.475 +		do
   1.476 +			tazwok compile $pkg
   1.477 +			tazwok genpkg $pkg
   1.478 +		done
   1.479 +		;;
   1.480 +	clean)
   1.481 +		# Clean up a package work directory.
   1.482 +		#
   1.483 +		check_for_package_on_cmdline
   1.484 +		check_for_receipt
   1.485 +		. $RECEIPT
   1.486 +		cd $WOK/$PACKAGE
   1.487 +		echo ""
   1.488 +		echo "Cleaning $PACKAGE..."
   1.489 +		echo "================================================================================"
   1.490 +		if [ -d "taz" ]; then
   1.491 +			echo -n "Removing taz files..."
   1.492 +			rm -rf taz && status
   1.493 +		fi
   1.494 +		# Remove source tree if exist.
   1.495 +		if [ -d "$PACKAGE-$VERSION" ]; then
   1.496 +			echo -n "Removing source files..."
   1.497 +			rm -rf $PACKAGE-$VERSION && status
   1.498 +		fi
   1.499 +		if [ -d "$SOURCE-$VERSION" ]; then
   1.500 +			echo -n "Removing source files..."
   1.501 +			rm -rf $SOURCE-$VERSION && status
   1.502 +		fi
   1.503 +		# Remove an envental $PACKAGE-build directory.
   1.504 +		if [ -d "$PACKAGE-build" ]; then
   1.505 +			echo -n "Removing build tree..."
   1.506 +			rm -rf $PACKAGE-build && status
   1.507 +		fi
   1.508 +		# Remove process log file.
   1.509 +		if [ -f "process.log" ]; then
   1.510 +			echo -n "Removing process log file..."
   1.511 +			rm process.log && status
   1.512 +		fi
   1.513 +		echo "$PACKAGE is clean. You can cook it again..."
   1.514 +		echo ""
   1.515 +		;;
   1.516 +	gen-clean-wok)
   1.517 +		# Generate a clean wok from the current wok by copying all receipt
   1.518 +		# and stuff directory.
   1.519 +		#
   1.520 +		if [ -z "$2" ]; then
   1.521 +			echo -e "\nPlease specify the destination for the new clean wok.\n"
   1.522 +			exit 0
   1.523 +		else
   1.524 +			dest=$2
   1.525 +			mkdir -p $dest
   1.526 +		fi
   1.527 +		echo "New wok is going to : $dest"
   1.528 +		for pkg in `ls -1 $WOK`
   1.529 +		do
   1.530 +			echo "----"
   1.531 +			echo -n "Preparing $pkg..."
   1.532 +			mkdir -p $dest/$pkg
   1.533 +			status
   1.534 +			echo -n "Copying the receipt..."
   1.535 +			cp -a $WOK/$pkg/receipt $dest/$pkg
   1.536 +			status
   1.537 +			if [ -d "$WOK/$pkg/stuff" ]; then
   1.538 +				echo -n "Copying all the stuff directory..."
   1.539 +				cp -a $WOK/$pkg/stuff $dest/$pkg
   1.540 +				status
   1.541 +			fi
   1.542 +		done
   1.543 +		echo "================================================================================"
   1.544 +		echo "Clean wok generated in : $dest"
   1.545 +		echo "Packages cleaned       : `ls -1 $dest | wc -l`"
   1.546 +		echo ""
   1.547 +		;;
   1.548 +	clean-wok)
   1.549 +		# Clean all packages in the work directory
   1.550 +		#
   1.551 +		for pkg in `ls -1 $WOK`
   1.552 +		do
   1.553 +			tazwok clean $pkg
   1.554 +		done
   1.555 +		echo "================================================================================"
   1.556 +		echo "`ls -1 $WOK | wc -l` packages cleaned."
   1.557 +		echo ""
   1.558 +		;;
   1.559 +	gen-list)
   1.560 +		# cd in the directory to creat a packages.list and the md5sum file.
   1.561 +		# Sed is used to remove all the .tazpkg extensions from the
   1.562 +		# packages.list. The directory to move in by default is the repository
   1.563 +		# if $3 is not empty cd into $3.
   1.564 +		#
   1.565 +		if [ -z "$2" ]; then
   1.566 +			PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
   1.567 +		else
   1.568 +			if [ -d "$2" ]; then
   1.569 +				PACKAGES_REPOSITORY=$2
   1.570 +			else
   1.571 +				echo -e "\nUnable to find directory : $2\n"
   1.572 +				exit 0
   1.573 +			fi
   1.574 +		fi
   1.575 +		cd $PACKAGES_REPOSITORY
   1.576 +		# Remove old packages.list and md5sum, it well be soon rebuild.
   1.577 +		rm -f packages.list packages.md5
   1.578 +		echo ""
   1.579 +		echo "Repository path : $PACKAGES_REPOSITORY"
   1.580 +		echo -n "Creating the packages list... "
   1.581 +		ls -1 > /tmp/packages.list
   1.582 +		sed -i s/'.tazpkg'/''/ /tmp/packages.list
   1.583 +		status
   1.584 +		echo -n "Building the md5sum for all packages... "
   1.585 +		md5sum * > packages.md5
   1.586 +		status
   1.587 +		mv /tmp/packages.list $PACKAGES_REPOSITORY
   1.588 +		echo "================================================================================"
   1.589 +		pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
   1.590 +		echo "$pkgs packages in the repository."
   1.591 +		echo ""
   1.592 +		;;
   1.593 +	new-tree)
   1.594 +		# Just creat a few directories and gen a empty receipt to prepare
   1.595 +		# the creation of a new package.
   1.596 +		#
   1.597 +		check_for_package_on_cmdline
   1.598 +		if [ -d $WOK/$PACKAGE ]; then
   1.599 +			echo -e "\n$PACKAGE package tree already exist.\n"
   1.600 +			exit 0
   1.601 +		fi
   1.602 +		echo "Creating : $WOK/$PACKAGE"
   1.603 +		mkdir $WOK/$PACKAGE
   1.604 +		cd $WOK/$PACKAGE
   1.605 +		echo -n "Preparing the receipt..."
   1.606 +		#
   1.607 +		# Default receipt begin.
   1.608 +		#
   1.609 +		echo "# SliTaz package receipt." > receipt
   1.610 +		echo "" >> receipt
   1.611 +		echo "PACKAGE=\"$PACKAGE\"" >> receipt
   1.612 +# Finish the empty receipt.
   1.613 +cat >> receipt << "EOF"
   1.614 +VERSION=""
   1.615 +CATEGORY=""
   1.616 +SHORT_DESC=""
   1.617 +MAINTAINER=""
   1.618 +DEPENDS=""
   1.619 +TARBALL="$PACKAGE-$VERSION.tar.gz"
   1.620 +WEB_SITE=""
   1.621 +WGET_URL=""
   1.622 +
   1.623 +# Rules to configure and make the package.
   1.624 +compile_rules()
   1.625 +{
   1.626 +	cd $src
   1.627 +	./configure --prefix=/usr --infodir=/usr/share/info \
   1.628 +	--mandir=/usr/share/man $CONFIGURE_ARGS
   1.629 +	make
   1.630 +	make DESTDIR=$PWD/_pkg install
   1.631 +}
   1.632 +
   1.633 +# Rules to gen a SliTaz package suitable for Tazpkg.
   1.634 +genpkg_rules()
   1.635 +{
   1.636 +	mkdir -p $fs/usr
   1.637 +	cp -a $_pkg/usr/bin $fs/usr
   1.638 +	strip -s $fs/usr/bin/*
   1.639 +}
   1.640 +
   1.641 +EOF
   1.642 +#
   1.643 +# Default receipt end.
   1.644 +#
   1.645 +		status
   1.646 +		# Interactive mode, asking and seding.
   1.647 +		if [ "$3" = "--interactive" ]; then
   1.648 +			echo "Entering in interactive mode..."
   1.649 +			echo "================================================================================"
   1.650 +			echo "Package       : $PACKAGE"
   1.651 +			# Version.
   1.652 +			echo -n "Version       : " ; read anser
   1.653 +			sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
   1.654 +			# Category.
   1.655 +			echo -n "Category      : " ; read anser
   1.656 +			sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
   1.657 +			# Short description.
   1.658 +			echo -n "Short desc    : " ; read anser
   1.659 +			sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
   1.660 +			# Maintainer.
   1.661 +			echo -n "Maintainer    : " ; read anser
   1.662 +			sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
   1.663 +			# Web site.
   1.664 +			echo -n "Web site      : " ; read anser
   1.665 +			sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt	
   1.666 +			echo ""
   1.667 +			# Wget URL.
   1.668 +			echo "Wget URL to download source tarball."
   1.669 +			echo "Example  : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
   1.670 +			echo -n "Wget url : " ; read anser
   1.671 +			sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
   1.672 +			# Ask for a stuff dir.
   1.673 +			echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
   1.674 +			if [ "$anser" = "y" ]; then
   1.675 +				echo -n "Creating the stuff directory..."
   1.676 +				mkdir stuff && status
   1.677 +			fi
   1.678 +			# Ask for a description file.
   1.679 +			echo -n "Are you going to write a description ? (y/N) : " ; read anser
   1.680 +			if [ "$anser" = "y" ]; then
   1.681 +				echo -n "Creating the description.txt file..."
   1.682 +				echo "" > description.txt && status
   1.683 +			fi
   1.684 +			echo "================================================================================"
   1.685 +			echo ""
   1.686 +		fi
   1.687 +		;;
   1.688 +	remove)
   1.689 +		# Remove a package from the wok.
   1.690 +		#
   1.691 +		check_for_package_on_cmdline
   1.692 +		echo ""
   1.693 +		echo -n "Removing $PACKAGE..."
   1.694 +		rm -rf $WOK/$PACKAGE && status
   1.695 +		echo ""
   1.696 +		;;
   1.697 +	usage|*)
   1.698 +		# Print usage also for all unknow commands.
   1.699 +		#
   1.700 +		usage
   1.701 +		;;
   1.702 +esac
   1.703 +
   1.704 +exit 0