tazwok rev 186

Tazwok-experimental branch
author Antoine Bodin <gokhlayeh@slitaz.org>
date Thu Feb 24 01:41:30 2011 +0100 (2011-02-24)
parents 92fd61a02140
children 2b7574e6483f
files .hgtags AUTHORS Makefile examples/config.site examples/tazwok.conf tazwok web/conf.php web/favicon.ico web/index.php web/log.php web/pics/website/header.png web/pics/website/logo.png web/pics/website/xhtml10.png web/slitaz.css
line diff
     1.1 --- a/.hgtags	Sat Sep 25 13:54:51 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,14 +0,0 @@
     1.4 -a900f34b0d9f939f8ba93f1869b674d38b2fe5fd 1.2
     1.5 -c1f5210739992b7ce57ff511d3e21a2198823328 1.3
     1.6 -44c4e497c492ede0908042de76ed23605a546b7d 1.4
     1.7 -db1bca7bbc4ce02999a0355ede50b91231aeb216 1.5
     1.8 -cf0fe7f9801b9bb357e3eb860d02abd42d1cf86a 1.6
     1.9 -53d5ede9c0fb372eac4a3162024dc14311c070a1 1.7
    1.10 -093a2c27d4b735a1810923b1f5fad6573d242f67 2.0
    1.11 -66111a634d5d88cba5a617c5fc1473a8aea7910a 2.1
    1.12 -3fa6decf700e712334eba1a7888a3e133817ba6d 2.2
    1.13 -770760bb3d4424f06b3dda7bf9cc8126032d36a7 2.3
    1.14 -fafab4c5cd1faec820bf0681b07fc1a5e908c7d9 3.0
    1.15 -3a48fb61c93d42cb5284145d776e6a841b89cb03 3.1
    1.16 -05bf754a184d52646d9f744ec10804e3d6fee827 3.2
    1.17 -9d945d5750254465174d173c469a551c29be7c72 3.2.1
     2.1 --- a/AUTHORS	Sat Sep 25 13:54:51 2010 +0200
     2.2 +++ b/AUTHORS	Thu Feb 24 01:41:30 2011 +0100
     2.3 @@ -1,3 +1,4 @@
     2.4  Christophe Lincoln <pankso@slitaz.org>
     2.5  Pascal Bellard <pascal.bellard@slitaz.org>
     2.6  Paul Issott <paul@slitaz.org>
     2.7 +Antoine Bodin <gokhlayeh@slitaz.org>
     2.8 \ No newline at end of file
     3.1 --- a/Makefile	Sat Sep 25 13:54:51 2010 +0200
     3.2 +++ b/Makefile	Thu Feb 24 01:41:30 2011 +0100
     3.3 @@ -8,12 +8,14 @@
     3.4  install:
     3.5  	@echo "Installing Tazwok into $(PREFIX)/bin..."
     3.6  	install -g root -o root -m 0777 tazwok $(PREFIX)/bin
     3.7 -	install -g root -o root -m 0644 examples/tazwok.conf /etc
     3.8 +	install -g root -o root -m 0644 examples/tazwok.conf /etc/slitaz
     3.9 +	install -g root -o root -m 0644 examples/config.site /etc
    3.10  	@echo "Installing documentation files..."
    3.11  	install -g root -o root -m 0755 -d $(DOCDIR)/tazwok
    3.12  	install -g root -o root -m 0644 doc/* $(DOCDIR)/tazwok
    3.13  
    3.14  uninstall:
    3.15  	rm -f $(PREFIX)/bin/tazwok
    3.16 -	rm -f /etc/tazwok.conf
    3.17 +	rm -f /etc/slitaz/tazwok.conf
    3.18 +	rm -f /etc/config.site
    3.19  	rm -rf $(DOCDIR)/tazwok
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/examples/config.site	Thu Feb 24 01:41:30 2011 +0100
     4.3 @@ -0,0 +1,63 @@
     4.4 +# This file contains default option passed to ./configure at compile time.
     4.5 +# Variables are setted this way :
     4.6 +# { [ "$var" = NONE ] || [ ! "$var" ] ; } && var=
     4.7 +# This is because config.site overwrite options passed directly in
     4.8 +# configure, like ./configure --var=
     4.9 +#
    4.10 +# Here, we don't want overwrite default configuration : we want to
    4.11 +# setup configure with default path only if nothing has been given
    4.12 +# on the configure command-line. This allow contributors to overwrite
    4.13 +# the defaults path filled here in the recipes.
    4.14 +#
    4.15 +# Path to the config.site is given to configure using the environnment
    4.16 +# variable CONFIG_SITE
    4.17 +# tazwok does that work before executing compile rules.
    4.18 +#
    4.19 +# If you want to use you're own config.site, you can use :
    4.20 +# export CONFIG_SITE=path_to_my_config.site
    4.21 +# in the compilation_rules of a receipt.
    4.22 +# It can be usefull if you want to share default configuration between
    4.23 +# some groups of packages like GNOME or KDE ones.
    4.24 +#
    4.25 +# To make tazwok configuration easier, we use variable from
    4.26 +# /etc/tazwok.conf here. Note that only concerns configure options :
    4.27 +# make flags (MAKEFLAGS, CFLAGS, CXXFLAGS and DESTDIR) are exported
    4.28 +# to environment variables; options setted here are thoses we can't
    4.29 +# export in environnment variables because it doesn't works.
    4.30 +
    4.31 +# Some variable are prefixed by "${prefix}" instead of "${datarootdir}".
    4.32 +# For thoses case we use "${datadir}" because there's configure script
    4.33 +# generally don't know about "${datarootdir}" (too olds). 
    4.34 +if echo "$localedir" | grep -q \${prefix}; then
    4.35 +	localedir=$( echo "$localedir" | sed 's/${prefix}/${datarootdir}/')
    4.36 +fi
    4.37 +if echo "$infodir" | grep -q \${prefix}; then
    4.38 +	infodir=$( echo "$infodir" | sed 's/${prefix}/${datarootdir}/')
    4.39 +fi
    4.40 +if echo "$mandir" | grep -q \${prefix}; then
    4.41 +	mandir=$( echo "$mandir" | sed 's/${prefix}/${datarootdir}/')
    4.42 +fi
    4.43 +
    4.44 +# Use default values if one of theses configure variable is not set.
    4.45 +{ [ "$prefix" = NONE ] || [ ! "$prefix" ] ; } && prefix=$default_prefix
    4.46 +{ [ "$datarootdir" = NONE ] || [ ! "$datarootdir" ] ; } && datarootdir=$default_datarootdir
    4.47 +{ [ "$datadir" = NONE ] || [ ! "$datadir" ] ; } && datadir=$datarootdir
    4.48 +{ [ "$localedir" = NONE ] || [ ! "$localedir" ] ; } && localedir=$default_localedir
    4.49 +{ [ "$infodir" = NONE ] || [ ! "$infodir" ] ; } && infodir=$default_infodir
    4.50 +{ [ "$mandir" = NONE ] || [ ! "$mandir" ] ; } && mandir=$default_mandir
    4.51 +{ [ "$build" = NONE ] || [ ! "$build" ] ; } && build=$default_build
    4.52 +{ [ "$host" = NONE ] || [ ! "$host" ] ; } && host=$default_host
    4.53 +
    4.54 +# Print information about theses variables.
    4.55 +echo "prefix = $prefix
    4.56 +datarootdir = $datarootdir
    4.57 +datadir = $datadir
    4.58 +localedir= $localedir
    4.59 +infodir = $infodir
    4.60 +mandir = $mandir
    4.61 +build = $build
    4.62 +host = $host
    4.63 +"
    4.64 +
    4.65 +# config.site is used by tazwok to check that config.site script has been used.
    4.66 +touch /tmp/config.site
     5.1 --- a/examples/tazwok.conf	Sat Sep 25 13:54:51 2010 +0200
     5.2 +++ b/examples/tazwok.conf	Thu Feb 24 01:41:30 2011 +0100
     5.3 @@ -1,24 +1,55 @@
     5.4  # tazwok.conf: Tazwok configuration file.
     5.5  #
     5.6  
     5.7 -# Wok directory/tree to find receipts and build packages.
     5.8 -# By default on SliTaz the directory is /home/slitaz/wok.
     5.9 -WOK="/home/slitaz/wok"
    5.10 +# Time to wait before uploading a (set of) package from packages-incoming
    5.11 +# to packages repository. In days, must be between 0 and 366.
    5.12 +incoming_delay="0"
    5.13  
    5.14 -# The path to the source tarballs of the binary packages.
    5.15 -SOURCES_REPOSITORY="/home/slitaz/src"
    5.16 +# Default makeflags.
    5.17 +MAKEFLAGS="-j$((`grep processor /proc/cpuinfo | wc -l`+1))"
    5.18  
    5.19 -# This path sets the binary packages repository. It's where all
    5.20 -# gen *.tazpkg will be stored when using the gen-repository command.
    5.21 -PACKAGES_REPOSITORY="/home/slitaz/packages"
    5.22 +# Default architecture.
    5.23 +ARCH="i486"
    5.24  
    5.25  # Default build host.
    5.26 -BUILD_HOST=i486-pc-linux-gnu
    5.27 +BUILD_HOST="$ARCH-pc-linux-gnu"
    5.28 +
    5.29 +# Default compilation flags.
    5.30 +# More details at :
    5.31 +# http://www.gentoo.org/doc/en/gcc-optimization.xml
    5.32 +# http://en.gentoo-wiki.com/wiki/Safe_Cflags
    5.33 +#
    5.34 +# Note : -pipe will be automatically disabled if you have less that
    5.35 +# 512MB of free RAM to avoid gcc crashes.
    5.36 +#
    5.37 +# Default SliTaz flags - wide compatibility & optimized for i386 as it's the
    5.38 +# slowest CPU :
    5.39 +#CFLAGS="-mtune=$ARCH -O2 -pipe -fomit-frame-pointer"
    5.40 +# Where ARCH=i386
    5.41 +#
    5.42 +# Cook compatible packages partially optimized for you're own hardware :
    5.43 +#CFLAGS="-mtune=$ARCH -O2 -pipe -fomit-frame-pointer"
    5.44 +# Where ARCH=you're arch
    5.45 +#
    5.46 +# Cook packages fully optimized for you're hardware - Warning, compatible only
    5.47 +# with same hardware and newest of the same family :
    5.48 +#CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
    5.49 +CFLAGS="-mtune=$ARCH -O2 -pipe -fomit-frame-pointer"
    5.50 +CXXFLAGS="$CFLAGS"
    5.51  
    5.52  # Default tool prefix.
    5.53  TOOLPREFIX="${BUILD_HOST}-"
    5.54  
    5.55  # Default arguments for GNU configure.
    5.56 +default_prefix=/usr
    5.57 +default_datarootdir=$default_prefix/share
    5.58 +default_datadir=$default_datarootdir
    5.59 +default_localedir=$default_datarootdir/locale
    5.60 +default_infodir=$default_datarootdir/info
    5.61 +default_mandir=$default_datarootdir/man
    5.62 +default_build="$BUILD_HOST"
    5.63 +default_host="$BUILD_HOST"
    5.64 +# CONFIGURE_ARGS is here only for backward compatibility.
    5.65  CONFIGURE_ARGS="--build=$BUILD_HOST --host=$BUILD_HOST"
    5.66  
    5.67  # Translation files to be included in packages. Note that you can specify
    5.68 @@ -45,3 +76,49 @@
    5.69  # tazpkg compression "gzip" or "lzma".
    5.70  COMPRESSION="lzma"
    5.71  
    5.72 +# Slitaz Toolchain : the tools used to compile all other packages.
    5.73 +# Toolchain packages doesn't need to be included as build_depends
    5.74 +# because they are in the chroot by default. The order in this
    5.75 +# variable is important : it's the compile order for the temporary
    5.76 +# toolchain which can be used to recook the base chroot, then all
    5.77 +# the wok. Toolchain is compiled this way according the LFS book :
    5.78 +# First - binutils, GCC; at this point they are linked to the host system.
    5.79 +# Second - the temp toolchain using the order defined in this variable.
    5.80 +# This toolchain is cross-compiled against a self-depend glibc.
    5.81 +# Third - all the wok in normal order, including the toolchain packages.
    5.82 +# This cook order is used only if glibc/binutils/gcc/linux-api-headers
    5.83 +# is updated to the next minor version or more (y.x.z -> y.x+1.z).
    5.84 +SLITAZ_TOOLCHAIN="linux-api-headers
    5.85 +glibc
    5.86 +binutils
    5.87 +gcc
    5.88 +busybox
    5.89 +ncurses
    5.90 +bash
    5.91 +bzip2
    5.92 +gawk
    5.93 +gettext
    5.94 +m4
    5.95 +make
    5.96 +patch
    5.97 +perl
    5.98 +texinfo
    5.99 +autoconf
   5.100 +automake
   5.101 +zlib
   5.102 +lzma"
   5.103 +
   5.104 +# Slitaz toolchain extra : package which are needed to cook other
   5.105 +# but which are not in the core temporary toolchain.
   5.106 +# Note : order is not important here.
   5.107 +SLITAZ_TOOLCHAIN_EXTRA="tazpkg
   5.108 +tazwok
   5.109 +pkg-config
   5.110 +libtool
   5.111 +libpthread-stubs"
   5.112 +
   5.113 +# Cook options :
   5.114 +# Repack sources in .tar.lzma format.
   5.115 +repack_src="yes"
   5.116 +# Allow cleaning RAM cache.
   5.117 +clean_cache="yes"
     6.1 --- a/tazwok	Sat Sep 25 13:54:51 2010 +0200
     6.2 +++ b/tazwok	Thu Feb 24 01:41:30 2011 +0100
     6.3 @@ -8,88 +8,20 @@
     6.4  #
     6.5  # (C) 2007-2009 SliTaz - GNU General Public License.
     6.6  #
     6.7 -VERSION=3.2.1
     6.8  
     6.9 -####################
    6.10 -# Tazwok variables #
    6.11 -####################
    6.12 +VERSION=3.9.0
    6.13 +. /usr/lib/slitaz/libtaz
    6.14 +source_lib commons
    6.15  
    6.16 -# Packages categories
    6.17 -#
    6.18 -# We may move this to a centralized config for Tazwok, Tazpkg and Tazbb.
    6.19 -# /var/lib/tazpkg/categories ?
    6.20 -#
    6.21 -CATEGORIES="
    6.22 -base-system
    6.23 -x-window
    6.24 -utilities
    6.25 -network
    6.26 -graphics
    6.27 -multimedia
    6.28 -office
    6.29 -development
    6.30 -system-tools
    6.31 -security
    6.32 -games
    6.33 -misc
    6.34 -meta
    6.35 -non-free"
    6.36 +# Use text instead of numbers, don't get $2 here if it's an option.
    6.37 +[ "$2" = "${2#--}" ] && PACKAGE=$2 && LIST=$2 && ARG=$2
    6.38 +COMMAND=$1
    6.39  
    6.40 -# Use words rather than numbers in the code.
    6.41 -COMMAND=$1
    6.42 -PACKAGE=$2
    6.43 -LIST=$2
    6.44 +########################################################################
    6.45 +# TAZWOK USAGE
    6.46 +########################
    6.47 +# Print the usage (English).
    6.48  
    6.49 -LOCALSTATE=/var/lib/tazpkg
    6.50 -INSTALLED=$LOCALSTATE/installed
    6.51 -
    6.52 -# Include config file or exit if no file found.
    6.53 -if [ -f "./tazwok.conf" ]; then
    6.54 -	. ./tazwok.conf
    6.55 -elif [ -f "/etc/tazwok.conf" ]; then
    6.56 -	. /etc/tazwok.conf
    6.57 -else
    6.58 -	echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
    6.59 -	echo -e "Please read the Tazwok documentation.\n"
    6.60 -	exit 0
    6.61 -fi
    6.62 -
    6.63 -# Create Tazwok needed directories if user is root.
    6.64 -if test $(id -u) = 0 ; then
    6.65 -	# Check for the wok directory.
    6.66 -	if [ ! -d "$WOK" ]; then
    6.67 -		echo "Creating the wok directory..."
    6.68 -		mkdir -p $WOK
    6.69 -		chmod 777 $WOK
    6.70 -	fi
    6.71 -	# Check for the packages repository.
    6.72 -	if [ ! -d "$PACKAGES_REPOSITORY" ]; then
    6.73 -		echo "Creating the packages repository..."
    6.74 -		mkdir -p $PACKAGES_REPOSITORY
    6.75 -	fi
    6.76 -	# Check for the sources repository.
    6.77 -	if [ ! -d "$SOURCES_REPOSITORY" ]; then
    6.78 -		echo "Creating the sources repository..."
    6.79 -		mkdir -p $SOURCES_REPOSITORY
    6.80 -	fi
    6.81 -fi
    6.82 -
    6.83 -# The path to the most important file used by Tazwok.
    6.84 -# The receipt is used to compile the source code and
    6.85 -# generate suitable packages for Tazpkg.
    6.86 -RECEIPT="$WOK/$PACKAGE/receipt"
    6.87 -
    6.88 -# The path to the process log file.
    6.89 -LOG="$WOK/$PACKAGE/process.log"
    6.90 -
    6.91 -# Limit memory usage
    6.92 -ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
    6.93 -
    6.94 -####################
    6.95 -# Tazwok functions #
    6.96 -####################
    6.97 -
    6.98 -# Print the usage (English).
    6.99  usage ()
   6.100  {
   6.101  	echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
   6.102 @@ -99,58 +31,123 @@
   6.103    stats          Print Tazwok statistics from the config file and the wok.
   6.104    edit           Edit a package receipt in the current wok.
   6.105    build-depends  Generate a list of packages to build a wok.
   6.106 -  cmp|compare    Compare the wok and the cooked pkgs (--remove old pkgs).
   6.107 +  cmp|compare*   Compare the wok and the cooked pkgs (--remove old pkgs).
   6.108    list           List all packages in the wok tree or by category.
   6.109    info           Get information about a package in the wok.
   6.110    check          Check every receipt for common errors.
   6.111    check-log      Check the process log file of a package.
   6.112 -  check-depends  Check every receipt for DEPENDS - doesn't scan ELF files.
   6.113 +  check-depends* Check every receipt for DEPENDS - doesn't scan ELF files.
   6.114    check-src      Check upstream tarball for package in the wok.
   6.115    search         Search for a package in the wok by pattern or name.
   6.116    compile        Configure and build a package using the receipt rules.
   6.117    genpkg         Generate a suitable package for Tazpkg with the rules.
   6.118    cook           Compile and generate a package directly.
   6.119    cook-list      Cook all packages specified in the list by order.
   6.120 +  cook-commit    Cook all modified receipts.
   6.121 +  cook-all       Cook all packages excepted toolchain.
   6.122 +  cook-toolchain Cook the toolchain packages.
   6.123 +  gen-cooklist   Generate a sorted cooklist using packages or list (--list) in argument.
   6.124 +  sort-cooklist  Sort the cooklist given in argument.
   6.125 +  get-src        Download the tarball of the package given in argument.
   6.126    clean          Clean all generated files in the package tree.
   6.127    new-tree       Prepare a new package tree and receipt (--interactive).
   6.128 -  gen-list       Generate a packages list for a repository (--text).
   6.129 +  gen-list       (Re-)Generate a packages list for a repository.
   6.130 +  gen-wok-db     (Re-)Generate wok lists with depends and wanted datas.
   6.131    gen-clean-wok  Gen a clean wok in a dir ('clean-wok' cleans current wok).
   6.132 +  clean-wok      Clean entirely the wok.
   6.133    remove         Remove a package from the wok.
   6.134    hgup           Pull and update a wok under Hg.
   6.135    maintainers    List all maintainers in the wok.
   6.136 -  maintained-by  List packages maintained by a contributor.\n"
   6.137 +  maintained-by  List packages maintained by a contributor.\n
   6.138 + 
   6.139 + You can use `basename $0` command --help to list avaible options.
   6.140 + \033[1mImportant - *: \033[0m Commands which need a rewrite."
   6.141  }
   6.142  
   6.143 -# Status function.
   6.144 -status()
   6.145 +# This function display an error message without returning any error code.
   6.146 +# It also log the message in source package's warnings.txt; this file can be
   6.147 +# used on an eventual package page on website to display cooking warnings.
   6.148 +tazwok_warning()
   6.149  {
   6.150 -	local CHECK=$?
   6.151 -	echo -en "\\033[70G[ "
   6.152 -	if [ $CHECK = 0 ]; then
   6.153 -		echo -en "\\033[1;33mOK"
   6.154 -	else
   6.155 -		echo -en "\\033[1;31mFailed"
   6.156 -	fi
   6.157 -	echo -e "\\033[0;39m ]"
   6.158 +	echo -e "tazwok: $1" >&2
   6.159 +	echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
   6.160 +	return
   6.161  }
   6.162  
   6.163 -# Check if user is root.
   6.164 -check_root()
   6.165 +########################################################################
   6.166 +# TAZWOK VARIABLES & INITIAL CONFIGURATION
   6.167 +########################
   6.168 +
   6.169 +get_tazwok_config()
   6.170  {
   6.171 -	if test $(id -u) != 0 ; then
   6.172 -	   echo -e "\nYou must be root to run `basename $0` with this option."
   6.173 -	   echo -e "Please type 'su' and root password to become super-user.\n"
   6.174 -	   exit 0
   6.175 +	# Get configuration file.
   6.176 +	get_config
   6.177 +
   6.178 +	# Define & get options.
   6.179 +	get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
   6.180 +	get_options
   6.181 +
   6.182 +	if [ "$undigest" ]; then
   6.183 +		LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
   6.184 +	else
   6.185 +		LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
   6.186  	fi
   6.187 +
   6.188 +	# The path to the most important files/dir used by Tazwok.
   6.189 +	PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
   6.190 +	WOK=$LOCAL_REPOSITORY/wok
   6.191 +	INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
   6.192 +	SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
   6.193 +	set_common_path
   6.194 +
   6.195 +	# /!\ This part needs some changes.
   6.196 +	# Basically, get theses files from the net if they are missing.
   6.197 +	dbtype=wok
   6.198 +	dep_db=$INCOMING_REPOSITORY/wok-depends.txt
   6.199 +	wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
   6.200 +	target_db=$INCOMING_REPOSITORY/wok-depends.txt
   6.201 +
   6.202 +	# Check commons directories, create them if user is root.
   6.203 +	if test $(id -u) = 0 ; then
   6.204 +		check_dir $WOK || chmod 777 $WOK
   6.205 +		check_dir $PACKAGES_REPOSITORY
   6.206 +		check_dir $SOURCES_REPOSITORY
   6.207 +		check_dir $INCOMING_REPOSITORY
   6.208 +		check_dir $LOCAL_REPOSITORY/log
   6.209 +	fi
   6.210 +	
   6.211 +	# Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
   6.212 +	# them if they are missing.
   6.213 +	for file in broken blocked commit incoming genpkglist cooklist; do
   6.214 +		[ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
   6.215 +	done
   6.216 +	
   6.217 +	# Limit memory usage.
   6.218 +	ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
   6.219  }
   6.220  
   6.221 +# Used in several functions.
   6.222 +set_common_path()
   6.223 +{
   6.224 +	# The receipt is used to compile the source code and
   6.225 +	# generate suitable packages for Tazpkg.
   6.226 +	RECEIPT="$WOK/$PACKAGE/receipt"
   6.227 +
   6.228 +	# The path to the process log file.
   6.229 +	LOG="$WOK/$PACKAGE/process.log"
   6.230 +}
   6.231 +
   6.232 +########################################################################
   6.233 +# TAZWOK CHECK FUNCTIONS
   6.234 +########################
   6.235 +
   6.236  # Check for a package name on cmdline.
   6.237  check_for_package_on_cmdline()
   6.238  {
   6.239 -	if [ -z "$PACKAGE" ]; then
   6.240 -		echo -e "\nYou must specify a package name on the command line."
   6.241 -		echo -e "Example : tazwok $COMMAND package\n"
   6.242 -		exit 0
   6.243 +	if [ ! "$PACKAGE" ]; then
   6.244 +		echo -e "\nYou must specify a package name on the command line." >&2
   6.245 +		echo -e "Example : tazwok $COMMAND package\n" >&2
   6.246 +		exit 1
   6.247  	fi
   6.248  }
   6.249  
   6.250 @@ -158,25 +155,80 @@
   6.251  check_for_receipt()
   6.252  {
   6.253  	if [ ! -f "$RECEIPT" ]; then
   6.254 -		echo -e "\nUnable to find the receipt : $RECEIPT\n"
   6.255 -		exit 0
   6.256 +		echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
   6.257 +		exit 1
   6.258  	fi
   6.259  }
   6.260  
   6.261  # Check for a specified file list on cmdline.
   6.262  check_for_list()
   6.263  {
   6.264 -	if [ -z "$LIST" ]; then
   6.265 -		echo -e "\nPlease specify the path to the list of packages to cook.\n"
   6.266 -		exit 0
   6.267 +	if [ ! "$LIST" ]; then
   6.268 +		echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
   6.269 +		exit 1
   6.270  	fi
   6.271 +	
   6.272  	# Check if the list of packages exists.
   6.273  	if [ -f "$LIST" ]; then
   6.274  		LIST=`cat $LIST`
   6.275  	else
   6.276 -		echo -e "\nUnable to find $LIST packages list.\n"
   6.277 -		exit 0
   6.278 +		echo -e "\nUnable to find $LIST packages list.\n" >&2
   6.279 +		exit 1
   6.280  	fi
   6.281 +	
   6.282 +	if [ ! "$LIST" ]; then
   6.283 +		echo -e "\nList is empty.\n" >&2
   6.284 +		exit 1
   6.285 +	fi
   6.286 +}
   6.287 +
   6.288 +
   6.289 +########################################################################
   6.290 +# TAZWOK CORE FUNCTIONS
   6.291 +########################
   6.292 +
   6.293 +remove_src()
   6.294 +{
   6.295 +	look_for_cookopt !remove_src && return
   6.296 +	if [ ! -d $WOK/$PACKAGE/install ] && [ "$_pkg" ] && [ -d "$_pkg" ]; then
   6.297 +		check_for_var_modification _pkg src || return
   6.298 +		mv "$_pkg" $WOK/$PACKAGE/install
   6.299 +	fi
   6.300 +	
   6.301 +	# Don't remove sources if a package use src variable in his
   6.302 +	# genpkg_rules: it maybe need something inside.
   6.303 +	for i in $PACKAGE $(look_for_rwanted); do
   6.304 +		sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
   6.305 +			grep -q \$src && tazwok_warning "Sources will not be removed \
   6.306 +because $i use \$src in his receipt." && return
   6.307 +	done
   6.308 +	
   6.309 +	report step "Removing sources directory"
   6.310 +	rm -fr "$src"
   6.311 +	report end-step
   6.312 +}
   6.313 +
   6.314 +# Check $COOK_OPT; usage : get_cookopt particular_opt
   6.315 +# Return error if not founded
   6.316 +# Return args if the opt is in the format opt=arg1:arg2:etc
   6.317 +look_for_cookopt()
   6.318 +{
   6.319 +	for arg in $COOK_OPT; do
   6.320 +		case $arg in
   6.321 +			$1=*)
   6.322 +				arg=${arg#$1=}
   6.323 +				while [ "$arg" ]; do
   6.324 +					echo "${arg%%:*}"
   6.325 +					[ "${arg/:}" = "$arg" ] && return
   6.326 +					arg=${arg#*:}
   6.327 +				done
   6.328 +			;;
   6.329 +			$1)
   6.330 +				return
   6.331 +			;;
   6.332 +		esac
   6.333 +	done
   6.334 +	return 1
   6.335  }
   6.336  
   6.337  # Check for the wanted package if specified in WANTED
   6.338 @@ -184,12 +236,12 @@
   6.339  # and generate packages.
   6.340  check_for_wanted()
   6.341  {
   6.342 -	if [ ! "$WANTED" = "" ]; then
   6.343 -		echo -n "Checking for the wanted package..."
   6.344 +	if [ "$WANTED" ]; then
   6.345 +		report "Checking for the wanted package"
   6.346  		if [ ! -d "$WOK/$WANTED" ]; then
   6.347 -			echo -e "\nWanted package is missing in the work directory.\n"
   6.348 -			exit 0
   6.349 +			report exit "\nWanted package is missing in the work directory.\n"
   6.350  		fi
   6.351 +		
   6.352  		# Checking for buildtree of Wanted package
   6.353  		if [ ! -d "$WOK/$WANTED/taz" ]; then
   6.354  			echo -e "\n\nSource files of wanted package is missing in the work directory."
   6.355 @@ -197,14 +249,14 @@
   6.356  			if [ "$anser" == "y" ]; then
   6.357  				tazwok cook $WANTED
   6.358  			else
   6.359 -				echo -e "\nWanted package source tree is missing in the work directory.\n"
   6.360 -				exit 0
   6.361 +				report exit "\nWanted package source tree is missing in the work directory.\n"
   6.362  			fi
   6.363  		fi
   6.364 -		status
   6.365 +		report end-step
   6.366 +		
   6.367  		# Set wanted src path.
   6.368 -		src=$WOK/$WANTED/$WANTED-$VERSION
   6.369 -		_pkg=$src/_pkg
   6.370 +		set_src_path && set_pkg_path
   6.371 +		
   6.372  	fi
   6.373  }
   6.374  
   6.375 @@ -212,42 +264,314 @@
   6.376  # Check for build dependencies, notify user and install if specified.
   6.377  check_for_build_depends()
   6.378  {
   6.379 -	echo "Checking for build dependencies..."
   6.380 -	for pkg in $BUILD_DEPENDS
   6.381 +	report step "Looking for build dependencies"
   6.382 +
   6.383 +	# Keep the list of previously installed build_depends then compare
   6.384 +	# it with new build_depends to know what to install and what to
   6.385 +	# what to remove.
   6.386 +	plan_remove=" $MISSING_PACKAGE $remove_later "
   6.387 +	[ ! "${plan_remove// }" ] && unset plan_remove
   6.388 +	unset MISSING_PACKAGE remove_later
   6.389 +	rwanted=$(look_for_rwanted)
   6.390 +
   6.391 +	for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
   6.392 +		grep -v -e "Don't make the command fail" $(for i in $(look_for_rwanted); do echo " -e $i"; done))
   6.393  	do
   6.394 -		if [ ! -d "$INSTALLED/$pkg" ]; then
   6.395 -			MISSING_PACKAGE=$pkg
   6.396 +
   6.397 +		# Delay the removing of previous cook depends if they are needed
   6.398 +		# for next cook too.
   6.399 +		if [ ! -d "$INSTALLED/$pkg" ] ; then
   6.400 +			MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
   6.401 +		fi
   6.402 +		if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
   6.403 +			plan_remove="${plan_remove/ $pkg / }"
   6.404 +			remove_later="$remove_later $pkg"
   6.405 +		fi
   6.406 +		if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
   6.407 +			broken="$broken$pkg "
   6.408  		fi
   6.409  	done
   6.410 -	if [ ! "$MISSING_PACKAGE" = "" ]; then
   6.411 -		echo "================================================================================"
   6.412 -		for pkg in $BUILD_DEPENDS
   6.413 -		do
   6.414 -			if [ ! -d "$INSTALLED/$pkg" ]; then
   6.415 -				MISSING_PACKAGE=$pkg
   6.416 +	
   6.417 +	# Don't cook if a depend is broken.
   6.418 +	if [ "$broken" ]; then
   6.419 +		MISSING_PACKAGE=$plan_remove
   6.420 +		echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
   6.421 +		unset plan_remove broken
   6.422 +		
   6.423 +		# Set report step to failed.
   6.424 +		report_return_code=1
   6.425 +		report end-step
   6.426 +		return 1
   6.427 +	fi
   6.428 +	if [ "$MISSING_PACKAGE" ]; then
   6.429 +		install_missing()
   6.430 +		{
   6.431 +			echo "Installing missing packages : $MISSING_PACKAGE"
   6.432 +			for pkg in $MISSING_PACKAGE; do
   6.433 +				[ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
   6.434 +			done
   6.435 +		}
   6.436 +		if [ "$auto_install" = yes ]; then
   6.437 +			install_missing
   6.438 +		else
   6.439 +			echo "================================================================================"
   6.440 +			for pkg in $MISSING_PACKAGE
   6.441 +			do
   6.442  				echo "Missing : $pkg"
   6.443 -			fi
   6.444 +			done
   6.445 +			echo "================================================================================"
   6.446 +			echo "You can continue, exit or install missing dependencies."
   6.447 +			echo -n "Install, continue or exit (install/y/N) ? "; read answer
   6.448 +			case $answer in
   6.449 +				install)
   6.450 +					install_missing ;;
   6.451 +				y|yes)
   6.452 +					unset MISSING_PACKAGE;;
   6.453 +				*)
   6.454 +					report stop
   6.455 +					exit 0 ;;
   6.456 +			esac
   6.457 +		fi
   6.458 +	fi
   6.459 +	report end-step
   6.460 +	remove_build_depends $plan_remove
   6.461 +	unset plan_remove
   6.462 +}
   6.463 +
   6.464 +remove_build_depends()
   6.465 +{
   6.466 +	[ "$1" ] || return
   6.467 +	report step "Removing previous build dependencies"
   6.468 +	echo "Removing theses packages : $@"
   6.469 +	for pkg in $@; do
   6.470 +		[ -d "$INSTALLED/$pkg" ] && echo y | tazpkg remove $pkg
   6.471 +	done
   6.472 +	report end-step
   6.473 +}
   6.474 +
   6.475 +# Check if we can use the new way to handle tarball
   6.476 +# or if we keep the previous method by check for
   6.477 +# _pkg=/src= in receipt and reverse-wanted.
   6.478 +check_for_var_modification()
   6.479 +{
   6.480 +	for var in $@; do
   6.481 +		for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
   6.482 +			[ -f $WOK/$pkg/receipt ] || continue
   6.483 +			grep -q "$var=" $WOK/$pkg/receipt && return 1
   6.484  		done
   6.485 -		echo "================================================================================"
   6.486 -		echo "You can continue, exit or install missing dependencies."
   6.487 -		echo -n "Install, continue or exit (install/y/N) ? "; read anser
   6.488 -		case $anser in
   6.489 -			install)
   6.490 -				for pkg in $BUILD_DEPENDS
   6.491 -				do
   6.492 -					if [ ! -d "$INSTALLED/$pkg" ]; then
   6.493 -						tazpkg get-install $pkg
   6.494 -					fi
   6.495 -				done ;;
   6.496 -			y|yes)
   6.497 -				;;
   6.498 -			*)
   6.499 -				exit 0 ;;
   6.500 -		esac
   6.501 +	done
   6.502 +	
   6.503 +	# Tweak to make if; then...; fi function working with this one.
   6.504 +	echo -n ""
   6.505 +}
   6.506 +
   6.507 +set_src_path()
   6.508 +{
   6.509 +	if check_for_var_modification src _pkg; then
   6.510 +		src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
   6.511 +	else
   6.512 +		src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
   6.513  	fi
   6.514  }
   6.515  
   6.516 -# Check for loop in deps tree.
   6.517 +set_pkg_path()
   6.518 +{
   6.519 +	if	[ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
   6.520 +		_pkg=$WOK/${WANTED:-$PACKAGE}/install
   6.521 +	else
   6.522 +		_pkg=$src/_pkg
   6.523 +	fi
   6.524 +	
   6.525 +}
   6.526 +
   6.527 +# Output $VERSION-$EXTRAVERSION using packages.txt
   6.528 +get_pkg_version()
   6.529 +{
   6.530 +	[ "$PACKAGE" ] || return
   6.531 +	grep -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
   6.532 +}
   6.533 +
   6.534 +
   6.535 +remove_previous_tarball()
   6.536 +{
   6.537 +	[ "$prev_VERSION" ] || return
   6.538 +	if [ "$VERSION" != "$prev_VERSION" ]; then
   6.539 +		rm -f $SOURCES_REPOSITORY/$PACKAGE-$prev_VERSION.tar.lzma
   6.540 +	fi
   6.541 +}
   6.542 +
   6.543 +remove_previous_package()
   6.544 +{
   6.545 +	[ "$prev_VERSION" ] || return
   6.546 +	if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
   6.547 +		rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
   6.548 +	fi
   6.549 +}
   6.550 +
   6.551 +# Check for src tarball and wget if needed.
   6.552 +check_for_tarball()
   6.553 +{
   6.554 +	if [ "$WGET_URL" ]; then
   6.555 +		report step "Checking for source tarball"
   6.556 +			
   6.557 +		if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
   6.558 +			[ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ] ; then
   6.559 +			cd $SOURCES_REPOSITORY
   6.560 +			download $WGET_URL
   6.561 +			
   6.562 +			# If source tarball is unreachable, try to find it on SliTaz
   6.563 +			# mirror.
   6.564 +			if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   6.565 +				report step "Download failed, try with mirror copy... "
   6.566 +				download http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma
   6.567 +			fi
   6.568 +			if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
   6.569 +				[ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
   6.570 +				report step "Download failed, try with mirror copy (again)... "
   6.571 +				file=$(basename $WGET_URL)
   6.572 +				download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
   6.573 +			fi
   6.574 +
   6.575 +			# Exit if download failed to avoid errors.
   6.576 +			if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   6.577 +				echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
   6.578 +				report end-step
   6.579 +				return 1
   6.580 +			fi
   6.581 +			
   6.582 +		fi
   6.583 +		report end-step
   6.584 +		
   6.585 +		# Untaring source if necessary. We don't need to extract source if
   6.586 +		# the package is built with a wanted source package.
   6.587 +		if [ ! "$WANTED" ]; then
   6.588 +			report step "Untaring source tarball"
   6.589 +			if [ "$target" ]; then
   6.590 +				src="$target"
   6.591 +			else
   6.592 +				set_src_path
   6.593 +			fi
   6.594 +			if [ ! -d "$src" ]; then
   6.595 +				
   6.596 +				# Log process.
   6.597 +				echo "untaring source tarball" >> $LOG
   6.598 +				
   6.599 +				tmp_src=$WOK/$PACKAGE/tmp-src-$$
   6.600 +				mkdir $tmp_src
   6.601 +				if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
   6.602 +					lzma d $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -so | \
   6.603 +						tar xf - -C $tmp_src
   6.604 +				else
   6.605 +					case "$TARBALL" in
   6.606 +						*zip|*xpi) ( cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL );;
   6.607 +						*bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   6.608 +						*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   6.609 +						*lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   6.610 +						*xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   6.611 +						*Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
   6.612 +						*) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
   6.613 +					esac || return 1
   6.614 +					
   6.615 +					# Check if uncompressed tarbal is in a root dir or not.
   6.616 +					if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
   6.617 +						if check_for_var_modification src _pkg; then
   6.618 +							mv $tmp_src $tmp_src-1
   6.619 +							mkdir $tmp_src
   6.620 +							mv $tmp_src-1 $tmp_src/$PACKAGE-$VERSION
   6.621 +						else
   6.622 +							mv $tmp_src/* $WOK/$PACKAGE
   6.623 +							repack_src=no
   6.624 +							rm -r $tmp_src
   6.625 +						fi
   6.626 +					fi
   6.627 +					
   6.628 +					if [ "$repack_src" = yes ]; then
   6.629 +						report step "Repacking sources in .tar.lzma format"
   6.630 +						cd $tmp_src
   6.631 +						tar -c * | lzma e $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -si
   6.632 +						rm $SOURCES_REPOSITORY/$TARBALL
   6.633 +						prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
   6.634 +
   6.635 +						# Remove previous tarball if it's not used either by
   6.636 +						# incoming and legacy packages.
   6.637 +						[ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
   6.638 +							remove_previous_tarball
   6.639 +
   6.640 +					fi
   6.641 +				fi
   6.642 +				if [ -d "$tmp_src" ]; then
   6.643 +					if ! check_for_var_modification src _pkg; then
   6.644 +						src="${src%/*}/$(ls $tmp_src)"
   6.645 +					fi
   6.646 +					mv $(echo $tmp_src/*) "$src"
   6.647 +					rm -r $tmp_src
   6.648 +								
   6.649 +					# Permissions settings.
   6.650 +					chown -R root.root "$src"
   6.651 +				fi
   6.652 +			else
   6.653 +				echo "There's already something at $src. Abord." >&2
   6.654 +			fi
   6.655 +			report end-step
   6.656 +		fi
   6.657 +	fi
   6.658 +}
   6.659 +
   6.660 +# Log and execute compile_rules function if it exists, to configure and
   6.661 +# make the package if it exists.
   6.662 +check_for_compile_rules()
   6.663 +{
   6.664 +	if grep -q ^compile_rules $RECEIPT; then
   6.665 +		echo "executing compile_rules" >> $LOG
   6.666 +		report step "Executing compile_rules"
   6.667 +		cd $WOK/$PACKAGE
   6.668 +		rm -f /tmp/config.site
   6.669 +
   6.670 +		# Free some RAM by cleaning cache if option is enabled.
   6.671 +		freeram=$(free | grep '^-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
   6.672 +		#if [ "$clean_cache" = yes ] && [ "$freeram" -lt 524288 ]; then
   6.673 +		#	sync; echo 3 > /proc/sys/vm/drop_caches
   6.674 +		#	freeram=$(free | grep ^Total | tr -s ' ' | cut -f 4 -d ' ')
   6.675 +		#fi
   6.676 +
   6.677 +		# Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
   6.678 +		# RAM are available.
   6.679 +		if [ "$CFLAGS" != "${CFLAGS/-pipe}" ] || \
   6.680 +			[ "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
   6.681 +
   6.682 +			if [ "$freeram" -lt 524288 ]; then
   6.683 +				tazwok_warning "Disabling -pipe compile flag because only $freeramb of RAM are available."
   6.684 +				CFLAGS="${CFLAGS/-pipe}"
   6.685 +				CXXFLAGS="${CXXFLAGS/-pipe}"
   6.686 +			fi
   6.687 +		fi
   6.688 +		unset freeram
   6.689 +
   6.690 +		# Set cook environnement variables.
   6.691 +		[ "$src" ] || set_src_path
   6.692 +		[ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
   6.693 +		[ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
   6.694 +		export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
   6.695 +			CONFIG_SITE default_prefix \
   6.696 +			default_datarootdir default_datadir default_localedir \
   6.697 +			default_infodir default_mandir default_build default_host
   6.698 +		local LC_ALL=POSIX LANG=POSIX
   6.699 +		compile_rules
   6.700 +
   6.701 +		# Check if config.site has been used.
   6.702 +		# /!\ disabled since it screw the return_code of the step.
   6.703 +		#if [ -f /tmp/config.site ]; then
   6.704 +		#	rm /tmp/config.site
   6.705 +		#else
   6.706 +		#	tazwok_warning "config.site hasn't been used during \
   6.707 +#configuration process."
   6.708 +		#fi
   6.709 +
   6.710 +		report end-step
   6.711 +	fi
   6.712 +}
   6.713 +
   6.714 +# Check for loop in deps tree. /!\ can be removed
   6.715  check_for_deps_loop()
   6.716  {
   6.717  	local list
   6.718 @@ -257,6 +581,7 @@
   6.719  	shift
   6.720  	[ -n "$1" ] || return
   6.721  	list=""
   6.722 +	
   6.723  	# Filter out already processed deps
   6.724  	for i in $@; do
   6.725  		case " $ALL_DEPS" in
   6.726 @@ -278,119 +603,29 @@
   6.727  download()
   6.728  {
   6.729  	for file in $@; do
   6.730 -		wget $file && break
   6.731 +		wget -q $file && break
   6.732  	done
   6.733  }
   6.734  
   6.735 -# Configure and make a package with the receipt.
   6.736 -compile_package()
   6.737 -{
   6.738 -	check_for_package_on_cmdline
   6.739 -	# Include the receipt to get all needed variables and functions
   6.740 -	# and cd into the work directory to start the work.
   6.741 -	check_for_receipt
   6.742 -	. $RECEIPT
   6.743 -	# Log the package name and date.
   6.744 -	echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
   6.745 -	echo "package $PACKAGE (compile)" >> $LOG
   6.746 -	# Set wanted $src variable to help compiling.
   6.747 -	if [ ! "$SOURCE" = "" ]; then
   6.748 -		src=$WOK/$PACKAGE/$SOURCE-$VERSION
   6.749 -	else
   6.750 -		src=$WOK/$PACKAGE/$PACKAGE-$VERSION
   6.751 -	fi
   6.752 -	check_for_build_depends
   6.753 -	check_for_wanted
   6.754 -	echo ""
   6.755 -	echo "Starting to cook $PACKAGE..."
   6.756 -	echo "================================================================================"
   6.757 -	# Check for src tarball and wget if needed.
   6.758 -	if [ ! "$WGET_URL" = "" ]; then
   6.759 -		echo "Checking for source tarball... "
   6.760 -		if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   6.761 -			cd $SOURCES_REPOSITORY
   6.762 -			download $WGET_URL
   6.763 -			#wget $WGET_URL
   6.764 -			if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   6.765 -				echo "Download failed, try with mirror copy... "
   6.766 -				file=$(basename $WGET_URL)
   6.767 -				download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
   6.768 -			fi
   6.769 -			# Exit if download failed to avoid errors.
   6.770 -			if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
   6.771 -				echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
   6.772 -				exit 1
   6.773 -			fi
   6.774 -		else
   6.775 -			echo -n "Source tarball exit... "
   6.776 -			status
   6.777 -		fi
   6.778 -		# Untaring source if necessary. We don't need to extract source if
   6.779 -		# the package is built with a wanted source package.
   6.780 -		if [ "$WANTED" = "" ]; then
   6.781 -			if [ ! -d $src ]; then
   6.782 -				# Log process.
   6.783 -				echo "untaring $TARBALL" >> $LOG
   6.784 -				echo -n "Untaring $TARBALL... "
   6.785 -				case "$TARBALL" in
   6.786 -				*zip|*xpi) ( cd $WOK/$PACKAGE; unzip -o $SOURCES_REPOSITORY/$TARBALL );;
   6.787 -				*bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
   6.788 -				*tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
   6.789 -				*xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $WOK/$PACKAGE;;
   6.790 -				*Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $WOK/$PACKAGE;;
   6.791 -				*) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
   6.792 -				esac
   6.793 -				status
   6.794 -				# Permissions settings
   6.795 -				chown -R root.root $WOK/$PACKAGE/$PACKAGE-* 2>/dev/null
   6.796 -				chown -R root.root $WOK/$PACKAGE/$SOURCE-* 2>/dev/null
   6.797 -			else
   6.798 -				echo -n "Source directory exit... " && status
   6.799 -			fi
   6.800 -		fi
   6.801 -	fi
   6.802 -	cd $WOK/$PACKAGE
   6.803 -	# Log and execute compile_rules function if it exists, to configure and
   6.804 -	# make the package if it exists.
   6.805 -	if grep -q ^compile_rules $RECEIPT; then
   6.806 -		echo "executing compile_rules" >> $LOG
   6.807 -		compile_rules
   6.808 -		# Exit if compilation failed so the binary package
   6.809 -		# is not generated when using the cook command.
   6.810 -		local CHECK=$?
   6.811 -		if [ $CHECK = 0 ]; then
   6.812 -			echo "================================================================================"
   6.813 -			echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
   6.814 -			echo ""
   6.815 -			echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
   6.816 +# Regenerate every package that wants a PACKAGE compiled
   6.817 +# /!\
   6.818  
   6.819 -		else
   6.820 -			echo "================================================================================"
   6.821 -			echo "Compilation failed. Please read the compiler output."
   6.822 -			echo "" && exit 1
   6.823 -		fi
   6.824 -	else
   6.825 -		echo "no compile_rules" >> $LOG
   6.826 -		echo -e "No compile rules for $PACKAGE...\n"
   6.827 -	fi
   6.828 -}
   6.829 -
   6.830 -# Regenerate every package that wants a PACKAGE compiled
   6.831  refresh_packages_from_compile()
   6.832  {
   6.833  	# make tazwok genpkg happy
   6.834  	mkdir $WOK/$PACKAGE/taz
   6.835 -	for i in $( grep -l "^WANTED=\"$PACKAGE\"" $WOK/*/receipt) ; do
   6.836 -		tazwok genpkg $(basename $(dirname $i))
   6.837 -		ps ww | grep -q tazbb && (
   6.838 -			TAZBB_NO_INSTALL=
   6.839 -			EXTRAVERSION=
   6.840 -			. $i
   6.841 -			pkg=$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg
   6.842 -			[ -n "$TAZBB_NO_INSTALL" ] ||
   6.843 -			yes | tazpkg install $PACKAGES_REPOSITORY/$pkg --forced
   6.844 -		)
   6.845 +	
   6.846 +	# Cook rwanted in default or specied order
   6.847 +	genlist=" $(look_for_rwanted | tr '\n' ' ') "
   6.848 +	for i in $(look_for_cookopt genpkg | tac); do
   6.849 +		[ "${genlist/ $i }" = "$genlist" ] && continue
   6.850 +		genlist=" $i${genlist/ $i / }"
   6.851  	done
   6.852 +	for i in $genlist; do
   6.853 +		tazwok genpkg $i --SLITAZ_VERSION=$SLITAZ_VERSION \
   6.854 +			--undigest=$undigest --SLITAZ_DIR=$SLITAZ_DIR
   6.855 +	done
   6.856 +	
   6.857  	# Still needs tazwok genpkg for this package
   6.858  	rm -rf $WOK/$PACKAGE/taz
   6.859  }
   6.860 @@ -402,7 +637,7 @@
   6.861  {
   6.862  	# In most cases, locales are in $_pkg/usr/share/locale so we copy files
   6.863  	# using generic variables and $LOCALE from Tazwok config file.
   6.864 -	if [ ! "$LOCALE" = "" ]; then
   6.865 +	if [ "$LOCALE"  ]; then
   6.866  		if [ -d "$_pkg/usr/share/locale" ]; then
   6.867  			for i in $LOCALE
   6.868  			do
   6.869 @@ -413,10 +648,11 @@
   6.870  			done
   6.871  		fi
   6.872  	fi
   6.873 +	
   6.874  	# Pixmaps (PNG or/and XPM only). Some icons/images can be added through
   6.875  	# genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
   6.876  	# in pkg receipt.
   6.877 -	if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
   6.878 +	if [ "$GENERIC_PIXMAPS" != "no" ]; then
   6.879  		if [ -d "$_pkg/usr/share/pixmaps" ]; then
   6.880  			mkdir -p $fs/usr/share/pixmaps
   6.881  			cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
   6.882 @@ -424,16 +660,19 @@
   6.883  			cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
   6.884  				$fs/usr/share/pixmaps 2>/dev/null
   6.885  		fi
   6.886 +		
   6.887  		# Custom or homemade PNG pixmap can be in stuff.
   6.888  		if [ -f "stuff/$PACKAGE.png" ]; then
   6.889  			mkdir -p $fs/usr/share/pixmaps
   6.890  			cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
   6.891  		fi
   6.892  	fi
   6.893 +	
   6.894  	# Desktop entry (.desktop).
   6.895  	if [ -d "$_pkg/usr/share/applications" ]; then
   6.896  		cp -a $_pkg/usr/share/applications $fs/usr/share
   6.897  	fi
   6.898 +	
   6.899  	# Homemade desktop file(s) can be in stuff.
   6.900  	if [ -d "stuff/applications" ]; then
   6.901  		mkdir -p $fs/usr/share
   6.902 @@ -448,7 +687,9 @@
   6.903  # Find and strip : --strip-all (-s) or --strip-debug on static libs.
   6.904  strip_package()
   6.905  {
   6.906 -	echo -n "Executing strip on all files..."
   6.907 +	look_for_cookopt !strip && return
   6.908 +	report step "Executing strip on all files"
   6.909 +	
   6.910  	# Binaries.
   6.911  	for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
   6.912  	do
   6.913 @@ -456,10 +697,20 @@
   6.914  			find $dir -type f -exec strip -s '{}' 2>/dev/null \;
   6.915  		fi
   6.916  	done
   6.917 +	
   6.918  	# Libraries.
   6.919  	find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
   6.920  	find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
   6.921 -	status
   6.922 +	report end-step
   6.923 +}
   6.924 +
   6.925 +# Remove .pyc and .pyo files from packages
   6.926 +py_compiled_files_remove()
   6.927 +{
   6.928 +	report step "Removing all .pyc and .pyo files from package ..."
   6.929 +	find $fs -type f -name "*.pyc" -delete 2>/dev/null
   6.930 +	find $fs -type f -name "*.pyo" -delete 2>/dev/null
   6.931 +	report end-step
   6.932  }
   6.933  
   6.934  # Check FSH in a slitaz package (Path: /:/usr)
   6.935 @@ -472,7 +723,7 @@
   6.936  	for i in `ls -d * usr/* 2>/dev/null`
   6.937  	do
   6.938  		if ! echo $FSH | grep -q $i; then
   6.939 -			echo "Wrong path: /$i"
   6.940 +			echo "Wrong path: /$i" >&2
   6.941  			error=1
   6.942  		fi
   6.943  	done
   6.944 @@ -495,11 +746,25 @@
   6.945  $PACKAGE package generation aborted.
   6.946  
   6.947  _EOT_
   6.948 +
   6.949  		# Dont generate a corrupted package.
   6.950  		cd $WOK/$PACKAGE && rm -rf taz
   6.951 -		exit 1
   6.952 +		report exit
   6.953  	fi
   6.954 -	echo ""
   6.955 +}
   6.956 +
   6.957 +gen_cookmd5()
   6.958 +{
   6.959 +	# md5sum of cooking stuff make tazwok able to check for changes
   6.960 +	# without hg.
   6.961 +	cd $WOK/$PACKAGE
   6.962 +	md5sum receipt > md5
   6.963 +	[ -f description.txt ] && md5sum description.txt >> md5
   6.964 +	if [ -d stuff ]; then
   6.965 +		find stuff | while read file; do
   6.966 +			md5sum $file >> md5
   6.967 +		done
   6.968 +	fi
   6.969  }
   6.970  
   6.971  # Create a package tree and build the gziped cpio archive
   6.972 @@ -511,72 +776,78 @@
   6.973  	check_for_receipt
   6.974  	EXTRAVERSION=""
   6.975  	. $RECEIPT
   6.976 +	
   6.977  	# May compute VERSION
   6.978  	if grep -q ^get_version $RECEIPT; then
   6.979  		get_version
   6.980  	fi
   6.981  	check_for_wanted
   6.982  	cd $WOK/$PACKAGE
   6.983 +	
   6.984  	# Remove old Tazwok package files.
   6.985 -	if [ -d "taz" ]; then
   6.986 -		rm -rf taz
   6.987 -	fi
   6.988 +	[ -d "taz" ] &&	rm -rf taz
   6.989 +	
   6.990  	# Create the package tree and set useful variables.
   6.991  	mkdir -p taz/$PACKAGE-$VERSION/fs
   6.992  	fs=taz/$PACKAGE-$VERSION/fs
   6.993 +	
   6.994  	# Set $src for standard package and $_pkg variables.
   6.995 -	if [ "$WANTED" = "" ]; then
   6.996 -		src=$WOK/$PACKAGE/$PACKAGE-$VERSION
   6.997 -		_pkg=$src/_pkg
   6.998 -	fi
   6.999 -	if [ ! "$SOURCE" = "" ]; then
  6.1000 -		src=$WOK/$PACKAGE/$SOURCE-$VERSION
  6.1001 -		_pkg=$src/_pkg
  6.1002 -	fi
  6.1003 -	cd $WOK/$PACKAGE
  6.1004 +	set_src_path && set_pkg_path
  6.1005 +	
  6.1006  	# Execute genpkg_rules, check package and copy generic files to build
  6.1007  	# the package.
  6.1008 -	echo ""
  6.1009 -	echo "Building $PACKAGE with the receipt..."
  6.1010 -	echo "================================================================================"
  6.1011 +	report step "Building $PACKAGE with the receipt"
  6.1012 +	report open-bloc
  6.1013  	if grep -q ^genpkg_rules $RECEIPT; then
  6.1014 +		
  6.1015  		# Log process.
  6.1016  		echo "executing genpkg_rules" >> $LOG
  6.1017 +		report step "Executing genpkg_rules"
  6.1018  		genpkg_rules
  6.1019 +		report end-step
  6.1020  		check_fsh
  6.1021  		cd $WOK/$PACKAGE
  6.1022 +		
  6.1023  		# Skip generic files for packages with a WANTED variable
  6.1024  		# (dev and splited pkgs).
  6.1025 -		if [ "$WANTED" = "" ]; then
  6.1026 +		if [ ! "$WANTED" ]; then
  6.1027  			copy_generic_files
  6.1028  		fi
  6.1029  		strip_package
  6.1030 +		py_compiled_files_remove
  6.1031  	else
  6.1032 -		echo "No package rules to gen $PACKAGE..."
  6.1033 -		exit 1
  6.1034 +		echo "No package rules to gen $PACKAGE..." >&2
  6.1035 +		report exit
  6.1036  	fi
  6.1037 +	
  6.1038  	# Copy the receipt and description (if exists) into the binary package tree.
  6.1039  	cd $WOK/$PACKAGE
  6.1040 -	echo -n "Copying the receipt..."
  6.1041 +	report step "Copying the receipt"
  6.1042  	cp receipt taz/$PACKAGE-$VERSION
  6.1043 -	status
  6.1044 +	report end-step
  6.1045  	if grep -q ^get_version $RECEIPT; then
  6.1046 -		echo -n "Updating version in receipt..."
  6.1047 +		report step "Updating version in receipt"
  6.1048  		sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
  6.1049  			taz/$PACKAGE-$VERSION/receipt
  6.1050 -		status
  6.1051 +		report end-step
  6.1052  	fi
  6.1053  	if [ -f "description.txt" ]; then
  6.1054 -		echo -n "Copying the description file..."
  6.1055 +		report step "Copying the description file"
  6.1056  		cp description.txt taz/$PACKAGE-$VERSION
  6.1057 -		status
  6.1058 +		report end-step
  6.1059  	fi
  6.1060 +	
  6.1061 +	# Generate md5 of cooking stuff to look for commit later.
  6.1062 +	gen_cookmd5
  6.1063 +	echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
  6.1064 +	cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
  6.1065 +	
  6.1066  	# Create the files.list by redirecting find output.
  6.1067 -	echo -n "Creating the list of files..."
  6.1068 +	report step "Creating the list of files"
  6.1069  	cd taz/$PACKAGE-$VERSION
  6.1070    	LAST_FILE=""
  6.1071    	( find fs -print; echo ) | while read file; do
  6.1072 -		if [ "$LAST_FILE" != "" ]; then
  6.1073 +		if [ "$LAST_FILE" ]; then
  6.1074  			case "$file" in
  6.1075  			$LAST_FILE/*)
  6.1076  				case "$(ls -ld "$LAST_FILE")" in
  6.1077 @@ -588,28 +859,60 @@
  6.1078  		fi
  6.1079  		LAST_FILE="$file"
  6.1080  	done > files.list
  6.1081 -	status
  6.1082 -	if [ -z "$EXTRAVERSION" ]; then
  6.1083 +	
  6.1084 +	# Next, check if something has changed in lib files.
  6.1085 +	if [ ! "$cook_rdep" ]; then
  6.1086 +		report step "Look for changes in libraries"
  6.1087 +		
  6.1088 +		# Find the most recent previous files.list.
  6.1089 +		# /!\ need some work to check only for minor update (not micro)
  6.1090 +		if grep -q ^$PACKAGE$ $INCOMING_REPOSITORY/packages.txt 2>/dev/null; then
  6.1091 +			files_list_dir=$PACKAGES_INCOMING
  6.1092 +		elif grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/packages.txt 2>/dev/null; then
  6.1093 +			files_list_dir=$PACKAGES_REPOSITORY
  6.1094 +		elif [ "$undigest" ] && grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/packages.txt 2>/dev/null; then
  6.1095 +			files_list_dir=$SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming
  6.1096 +		elif [ "$undigest" ] && grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt 2>/dev/null; then
  6.1097 +			files_list_dir=$SLITAZ_DIR/$SLITAZ_VERSION/packages
  6.1098 +		fi
  6.1099 +		
  6.1100 +		# If founded, generate libs.list (new and previous)
  6.1101 +		if [ "$files_list_dir" ] && [ -f $files_list_dir/files.list.lzma ]; then
  6.1102 +			grep -e '\.so$' -e '\.so.[0-9]' files.list >> $tmp/libs.list.new
  6.1103 +			if [ -f $tmp/libs.list.new ]; then
  6.1104 +				lzma d $files_list_dir/files.list.lzma $tmp/files.list 2>/dev/null
  6.1105 +				grep ^$PACKAGE: $tmp/files.list >> $tmp/libs.list.previous
  6.1106 +				
  6.1107 +				# If something as changed in libs path/names, plan recook of all
  6.1108 +				# reverse build depends. 
  6.1109 +				[ "$(diff -q $tmp/libs.list.old $tmp/libs.list.previous 2>/dev/null)" ] && cook_rdep=yes
  6.1110 +				rm $tmp/libs.list.new $tmp/files.list $tmp/libs.list.old 2>/dev/null
  6.1111 +				unset files_list_dir
  6.1112 +			fi
  6.1113 +		fi
  6.1114 +		report end-step
  6.1115 +	fi
  6.1116 +	if [ ! "$EXTRAVERSION" ]; then
  6.1117  		case "$PACKAGE" in
  6.1118  		linux*);;
  6.1119  		*) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
  6.1120  			head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
  6.1121  		esac
  6.1122  	fi
  6.1123 -	rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
  6.1124 -	echo -n "Creating md5sum of files..."
  6.1125 +	rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
  6.1126 +	report step "Creating md5sum of files"
  6.1127  	while read file; do
  6.1128  		[ -L "fs$file" ] && continue
  6.1129  		[ -f "fs$file" ] || continue
  6.1130  		md5sum "fs$file" | sed 's/  fs/  /'
  6.1131  	done < files.list > md5sum
  6.1132 -	#[ -s md5sum ] || rm -f md5sum
  6.1133 -	status
  6.1134  	UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
  6.1135  		2> /dev/null | awk '{ sz=$1 } END { print sz }')
  6.1136 +	
  6.1137  	# Build cpio archives. Find, cpio and gzip the fs, finish by
  6.1138  	# removing the fs tree.
  6.1139 -	echo -n "Compressing the fs... "
  6.1140 +	# Don't log this because compression always output error messages.
  6.1141 +	report end-step
  6.1142  	find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
  6.1143  	tazpkg-lzma)	gzip > fs.cpio.gz;;
  6.1144  	*-lzma)		lzma e fs.cpio.lzma -si;;
  6.1145 @@ -617,132 +920,1047 @@
  6.1146  	esac && rm -rf fs
  6.1147  	PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
  6.1148  		description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
  6.1149 -	status
  6.1150 -	echo -n "Updating receipt sizes..."
  6.1151 +	report step "Updating receipt sizes"
  6.1152  	sed -i '/^PACKED_SIZE/d' receipt
  6.1153  	sed -i '/^UNPACKED_SIZE/d' receipt
  6.1154  	sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
  6.1155  	sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
  6.1156 -	status
  6.1157  	if [ -n "$EXTRAVERSION" ]; then
  6.1158 -		echo -n "Updating receipt EXTRAVERSION..."
  6.1159 +		report step "Updating receipt EXTRAVERSION"
  6.1160  		sed -i s/^EXTRAVERSION.*$// receipt
  6.1161  		sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
  6.1162 -		status
  6.1163  	fi
  6.1164 -	echo -n "Creating full cpio archive... "
  6.1165 -	find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
  6.1166 -	status
  6.1167 +	prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
  6.1168 +	remove_previous_package $INCOMING_REPOSITORY
  6.1169 +	report step "Creating full cpio archive"
  6.1170 +	find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
  6.1171 +	
  6.1172  	# Restore package tree in case we want to browse it.
  6.1173 -	echo -n "Restoring original package tree... "
  6.1174 -	( zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma ) | cpio -id
  6.1175 +	report step "Restoring original package tree"
  6.1176 +	( zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma ) | cpio --quiet -id
  6.1177  	rm fs.cpio.* && cd ..
  6.1178 +	
  6.1179  	# Log process.
  6.1180  	echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
  6.1181 -	echo "================================================================================"
  6.1182 +	report close-bloc
  6.1183  	echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
  6.1184 -	echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
  6.1185 +	echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
  6.1186  	echo ""
  6.1187 +	
  6.1188 +	# Remove package from broken & genpkg list if needed.
  6.1189 +	if grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
  6.1190 +		sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
  6.1191 +		regen_cooklist=yes
  6.1192 +	fi
  6.1193 +	
  6.1194 +	# Remove package from genpkglist.
  6.1195 +	sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/genpkglist
  6.1196  }
  6.1197  
  6.1198 -# Optional text packages list for gen-list.
  6.1199 -gen_textlist()
  6.1200 +########################################################################
  6.1201 +######################## START OF NEW FUNCTIONS ########################
  6.1202 +########################################################################
  6.1203 +
  6.1204 +########################################################################
  6.1205 +# This section contains functions used by several other functions
  6.1206 +# bellow.
  6.1207 +########################
  6.1208 +
  6.1209 +# Look for receipt/files.list in wok. If they can't be found, get them
  6.1210 +# from package. Accept one argument : absolute path to package.
  6.1211 +get_pkg_files()
  6.1212  {
  6.1213 -	rm -f packages.desc packages.equiv
  6.1214 -	DATE=`date +%Y-%m-%d\ \%H:%M:%S`
  6.1215 -	echo -n "Creating the text packages list... "
  6.1216 -	cat >> packages.txt << _EOT_
  6.1217 -# SliTaz GNU/Linux - Packages list
  6.1218 -#
  6.1219 -# Packages : _packages_
  6.1220 -# Date     : $DATE
  6.1221 -#
  6.1222 -_EOT_
  6.1223 +	pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
  6.1224 +	mkdir -p $pkg_files_dir && \
  6.1225 +		cd $pkg_files_dir && \
  6.1226 +		cpio --quiet -idm receipt < $1 && \
  6.1227 +		cpio --quiet -idm files.list < $1
  6.1228 +}
  6.1229  
  6.1230 -	# Extract informations from package if needed & possible.
  6.1231 -	for dir in $WOK/*; do
  6.1232 -		pkg=$(cd $PACKAGES_REPOSITORY && echo ${dir##*/}* | sed -e 's/ .*//' -e 's/.tazpkg//' -e "s~${dir%/*}/~~")
  6.1233 -		if [ ! -f $dir/taz/$pkg/receipt ] && [ -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then
  6.1234 -			mkdir -p $dir/taz/$pkg
  6.1235 -			(cd $dir/taz/$pkg
  6.1236 -			cpio --quiet -i receipt < $PACKAGES_REPOSITORY/$pkg.tazpkg
  6.1237 -			cpio --quiet -i files.list < $PACKAGES_REPOSITORY/$pkg.tazpkg) > /dev/null 2>&1
  6.1238 +########################################################################
  6.1239 +# This section contains functions to generate packages/wok databases.
  6.1240 +########################
  6.1241 +
  6.1242 +# Generic actions in both gen-packages-db/gen-wok-db
  6.1243 +gen_db()
  6.1244 +{
  6.1245 +	report step "Generating $dbtype database"
  6.1246 +	report open-bloc
  6.1247 +	report step "Removing old files"
  6.1248 +	for file in $files_list; do
  6.1249 +		[ -f $file ] && rm $file
  6.1250 +		[ "${file##*.}" != lzma ] && touch $file
  6.1251 +	done
  6.1252 +	
  6.1253 +	# Generate wok/packages data lists.
  6.1254 +	gen_${dbtype}_db
  6.1255 +	report close-bloc
  6.1256 +}
  6.1257 +
  6.1258 +gen_packages_db()
  6.1259 +{
  6.1260 +	# pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
  6.1261 +	[ ! "$pkg_repository" ] && pkg_repository=$PACKAGES_REPOSITORY
  6.1262 +	cd $pkg_repository
  6.1263 +	packages_db_start
  6.1264 +	unset RECEIPT
  6.1265 +	report step "Reading datas from all packages"
  6.1266 +	for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do
  6.1267 +		get_packages_info
  6.1268 +	done
  6.1269 +	report end-step
  6.1270 +	packages_db_end
  6.1271 +}
  6.1272 +
  6.1273 +update_packages_db()
  6.1274 +{
  6.1275 +	[ ! "$pkg_repository" ] && pkg_repository=$PACKAGES_REPOSITORY
  6.1276 +	cd $pkg_repository
  6.1277 +	
  6.1278 +	# If files are missing, generate the lists - not only update.
  6.1279 +	dbtype=packages
  6.1280 +	files_list="packages.list packages.equiv packages.md5 packages.desc packages.txt"
  6.1281 +	for file in $files_list; do
  6.1282 +		if [ ! -f "$file" ]; then
  6.1283 +			gen_db
  6.1284 +			return
  6.1285 +		fi
  6.1286 +	done
  6.1287 +	if	[ -f files.list.lzma ]; then
  6.1288 +		lzma d files.list.lzma files.list
  6.1289 +	else
  6.1290 +		gen_db
  6.1291 +	fi
  6.1292 +	packages_db_start
  6.1293 +	report step "Updating packages lists"
  6.1294 +	touch $tmp/pkglist
  6.1295 +	
  6.1296 +	# Look for removed/update packages.
  6.1297 +	for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
  6.1298 +		pkg=$(echo $pkg_repository/`grep ^$PACKAGE- packages.list | sed 1!d`*.tazpkg | grep -v '\*')
  6.1299 +		if [ ! "$pkg" ]; then
  6.1300 +			pkg=$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg
  6.1301 +			erase_package_info
  6.1302 +		else
  6.1303 +			echo $pkg >> $tmp/pkglist
  6.1304 +			if [ "$pkg" -nt "packages.list" ]; then
  6.1305 +				erase_package_info
  6.1306 +				get_packages_info
  6.1307 +			fi
  6.1308  		fi
  6.1309  	done
  6.1310  	
  6.1311 -	for pkg in $WOK/*
  6.1312 -	do
  6.1313 -	[ ! -f $pkg/receipt ] && continue
  6.1314 -	PROVIDE=""
  6.1315 -	PACKAGE=""
  6.1316 -	PACKED_SIZE=""
  6.1317 -	if [ -f $pkg/taz/*/receipt ]; then
  6.1318 -		. $pkg/taz/*/receipt
  6.1319 +	# Look for new packages.
  6.1320 +	for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do
  6.1321 +		if ! grep -q ^$pkg$ $tmp/pkglist; then
  6.1322 +			get_packages_info
  6.1323 +		fi
  6.1324 +	done
  6.1325 +	rm $tmp/pkglist
  6.1326 +	report end-step
  6.1327 +	packages_db_end
  6.1328 +}
  6.1329 +
  6.1330 +packages_db_start()
  6.1331 +{
  6.1332 +	if [ ! -s packages.txt ]; then
  6.1333 +			echo "# SliTaz GNU/Linux - Packages list
  6.1334 +#
  6.1335 +# Packages : unknow
  6.1336 +# Date     : $(date +%Y-%m-%d\ \%H:%M:%S)
  6.1337 +#" > packages.txt
  6.1338  	else
  6.1339 -		. $pkg/receipt
  6.1340 +		sed -e 's/^# Packages :.*/# Packages : unknow/' \
  6.1341 +			-e "s/# Date     :.*/# Date     : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
  6.1342 +			-i packages.txt
  6.1343  	fi
  6.1344 -	cat >> packages.txt << _EOT_
  6.1345 +	
  6.1346 +	# Needed in some case as tazwok define RECEIPT at configuration time
  6.1347 +	# in this particular case it can broke the script.
  6.1348 +	unset RECEIPT
  6.1349 +}
  6.1350 +
  6.1351 +erase_package_info()
  6.1352 +{
  6.1353 +	cd $pkg_repository
  6.1354 +	sed "/^$PACKAGE$/,/^$/d" -i packages.txt
  6.1355 +	sed "/^$PACKAGE /d" -i packages.desc
  6.1356 +	sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" 	-e "s/ $PACKAGE$//" \
  6.1357 +		-e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
  6.1358 +		-e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
  6.1359 +		-e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
  6.1360 +		-i packages.equiv
  6.1361 +	sed "/^$PACKAGE:/d" -i files.list
  6.1362 +	sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
  6.1363 +	sed "/ $(basename $pkg)$/d" -i packages.md5
  6.1364 +}
  6.1365 +
  6.1366 +get_packages_info()
  6.1367 +{
  6.1368 +	# If there's no taz folder in the wok, extract infos from the
  6.1369 +	# package.
  6.1370 +	get_pkg_files $pkg
  6.1371 +	source_receipt
  6.1372 +	echo "Getting datas from $PACKAGE"
  6.1373 +
  6.1374 +	cat >> $pkg_repository/packages.txt << _EOT_
  6.1375  
  6.1376  $PACKAGE
  6.1377 -    $VERSION
  6.1378 +    $VERSION$EXTRAVERSION
  6.1379      $SHORT_DESC
  6.1380  _EOT_
  6.1381 -	if [ -n "$PACKED_SIZE" ]; then
  6.1382 -		cat >> packages.txt << _EOT_
  6.1383 +		[ "$PACKED_SIZE" ] && cat >> $pkg_repository/packages.txt << _EOT_
  6.1384      $PACKED_SIZE ($UNPACKED_SIZE installed)
  6.1385  _EOT_
  6.1386 -	fi
  6.1387 +
  6.1388  	# Packages.desc is used by Tazpkgbox <tree>.
  6.1389 -	echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
  6.1390 +	echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
  6.1391 +
  6.1392  	# Packages.equiv is used by tazpkg install to check depends
  6.1393 -	touch packages.equiv
  6.1394  	for i in $PROVIDE; do
  6.1395  		DEST=""
  6.1396  		echo $i | grep -q : && DEST="${i#*:}:"
  6.1397 -		if grep -qs ^${i%:*}= packages.equiv; then
  6.1398 -			sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" packages.equiv
  6.1399 +		if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
  6.1400 +			sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
  6.1401  		else
  6.1402 -			echo "${i%:*}=$DEST$PACKAGE" >> packages.equiv
  6.1403 +			echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
  6.1404 +		fi
  6.1405 +	done	
  6.1406 +
  6.1407 +	if [ -f files.list ]; then 
  6.1408 +		{ echo "$PACKAGE"; cat files.list; } | awk '
  6.1409 +BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
  6.1410 +	fi
  6.1411 +
  6.1412 +	cd .. && rm -r "$pkg_files_dir"
  6.1413 +
  6.1414 +	cd $pkg_repository
  6.1415 +	echo $(basename ${pkg%.tazpkg}) >> packages.list
  6.1416 +	[ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
  6.1417 +	echo "$package_md5" >> packages.md5
  6.1418 +	unset package_md5
  6.1419 +}
  6.1420 +
  6.1421 +source_receipt()
  6.1422 +{
  6.1423 +	unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
  6.1424 +		MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
  6.1425 +		PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
  6.1426 +		src _pkg DESTDIR CONFIG_SITE
  6.1427 +	. ${RECEIPT:-$PWD/receipt}
  6.1428 +}
  6.1429 +
  6.1430 +packages_db_end()
  6.1431 +{
  6.1432 +	cd $pkg_repository
  6.1433 +	pkgs=$(wc -l packages.list | sed 's/ .*//')
  6.1434 +	sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
  6.1435 +	
  6.1436 +	# If lists was updated it's generally needed to sort them well.
  6.1437 +	if ! sort -c packages.list 2> /dev/null; then
  6.1438 +		report step "Sorting packages lists"
  6.1439 +		for file in packages.list packages.desc packages.equiv; do
  6.1440 +			[ -f $file ] || continue
  6.1441 +			sort -o $file $file
  6.1442 +		done
  6.1443 +		report end-step
  6.1444 +	fi
  6.1445 +	
  6.1446 +	# Dont log this because lzma always output error.
  6.1447 +	lzma e files.list files.list.lzma
  6.1448 +	rm files.list 2>/dev/null
  6.1449 +	if ! grep -q ^$pkg_repository$ $LOCAL_STATE/mirror && \
  6.1450 +		! { [ -d $LOCAL_STATE/undigest ] && \
  6.1451 +		grep -q ^$pkg_repository$ $LOCAL_STATE/undigest/*/mirror; }; then
  6.1452 +		tazpkg add-undigest $(basename `echo $pkg_repository | sed 's~/packages~~'`) $pkg_repository
  6.1453 +	fi
  6.1454 +}
  6.1455 +
  6.1456 +########################################################################
  6.1457 +# This section contains functions to generate wok database.
  6.1458 +########################
  6.1459 +
  6.1460 +gen_wok_db()
  6.1461 +{
  6.1462 +	get_wok_info $(echo $WOK/*/receipt | sed -e "s~$WOK/~~g" -e "s~/receipt~~g")
  6.1463 +	sort_db
  6.1464 +	report close-bloc
  6.1465 +}
  6.1466 +
  6.1467 +get_wok_info()
  6.1468 +{
  6.1469 +	report step "Getting datas from wok"
  6.1470 +	report open-bloc
  6.1471 +	
  6.1472 +	report step "Generating wok-wanted.txt"
  6.1473 +	for PACKAGE in $@; do
  6.1474 +		RECEIPT=$WOK/$PACKAGE/receipt
  6.1475 +		source_receipt
  6.1476 +		[ "$WANTED" ] || continue
  6.1477 +		echo -e $PACKAGE"\t"$WANTED >> $wan_db
  6.1478 +	done
  6.1479 +	
  6.1480 +	report step "Generating wok-depends.txt"
  6.1481 +	for PACKAGE in $@; do
  6.1482 +		RECEIPT=$WOK/$PACKAGE/receipt
  6.1483 +		if [ -s $RECEIPT ]; then
  6.1484 +			source_receipt
  6.1485 +			echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
  6.1486  		fi
  6.1487  	done
  6.1488 -	packages=$(($packages+1))
  6.1489 -	done && status
  6.1490 -	echo -n "Creating the text files list... "
  6.1491 -	for pkg in $WOK/*
  6.1492 -	do
  6.1493 -	if [ -f $pkg/taz/*/files.list ]; then
  6.1494 -		. $pkg/taz/*/receipt
  6.1495 -		( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
  6.1496 -BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
  6.1497 -	else
  6.1498 -		echo "No files_list in $pkg" 1>&2
  6.1499 -	fi
  6.1500 -	done | lzma e files.list.lzma -si && status
  6.1501 -	sed -i s/"_packages_"/"$packages"/ packages.txt
  6.1502 +	report end-step
  6.1503  }
  6.1504  
  6.1505 -# Return the date of the last commit in seconds since Jan 1 1970
  6.1506 -hgdate()
  6.1507 +sort_db()
  6.1508  {
  6.1509 -	local pkg
  6.1510 -	local date
  6.1511 -	local mon
  6.1512 -	# Default date is Jan 1 1970
  6.1513 -	[ -d $WOK/.hg -a -x /usr/bin/hg ] || { echo "010100001970"; return; }
  6.1514 -	pkg=$(basename $1)
  6.1515 -	# Get date for last commit
  6.1516 -	date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
  6.1517 -		2> /dev/null) | grep date: | head -1 | cut -c 6-)"
  6.1518 -	[ -n "$date" ] || { echo "010100001970"; return; }
  6.1519 -	case "$(echo $date | awk '{ print $2 }')" in
  6.1520 -	Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
  6.1521 -	May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
  6.1522 -	Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
  6.1523 -	esac
  6.1524 -	# Reformat, don't mind about TZ: we look for days or months delta
  6.1525 -	echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
  6.1526 +	report step "Generating cookorder.txt"
  6.1527 +	rm $PACKAGES_REPOSITORY/blocked && touch $PACKAGES_REPOSITORY/blocked
  6.1528 +	cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
  6.1529 +		grep -q ^$PACKAGE$'\t' $wan_db && continue
  6.1530 +		
  6.1531 +		# Replace each BUILD_DEPENDS with a WANTED package by it's
  6.1532 +		# WANTED package.
  6.1533 +		replace_by_wanted()
  6.1534 +		{
  6.1535 +			for p in $BUILD_DEPENDS; do
  6.1536 +				if grep -q ^$p$'\t' $wan_db; then
  6.1537 +					echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
  6.1538 +				else
  6.1539 +					echo -n $p' '
  6.1540 +				fi
  6.1541 +			done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
  6.1542 +		}
  6.1543 +		echo -e $PACKAGE"\t $(replace_by_wanted) "
  6.1544 +	done > $tmp/db
  6.1545 +	while [ -s "$tmp/db" ]; do
  6.1546 +		status=start
  6.1547 +		for pkg in $(cut -f 1 $tmp/db); do
  6.1548 +			 if ! grep -q ' '$pkg' ' $tmp/db; then
  6.1549 +				echo $pkg >> $tmp/cookorder
  6.1550 +				sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
  6.1551 +				status=proceed
  6.1552 +			fi
  6.1553 +		done
  6.1554 +		if [ "$status" = start ]; then
  6.1555 +			cp -f $tmp/db /tmp/remain-depends.txt
  6.1556 +			echo "Can't go further because there's depency(ies) loop(s). The remaining packages will be commentend in the cookorder and will be unbuild in case of major update until the problem is solved." >&2
  6.1557 +			for blocked in $(cut -f 1 $tmp/db); do
  6.1558 +				echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
  6.1559 +			done
  6.1560 +			break
  6.1561 +		fi
  6.1562 +	done
  6.1563 +	[ -s $tmp/cookorder ] || touch $tmp/cookorder
  6.1564 +	
  6.1565 +	# The toolchain packages are moved in first position.
  6.1566 +	grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
  6.1567 +		--look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
  6.1568 +		$tmp/cookorder | tac 
  6.1569 +	grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
  6.1570 +		--look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
  6.1571 +		$tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
  6.1572 +	for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
  6.1573 +		sed "/^$pkg$/d" -i $tmp/cookorder
  6.1574 +	done
  6.1575 +
  6.1576 +	tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
  6.1577 +	report end-step
  6.1578  }
  6.1579  
  6.1580 +########################################################################
  6.1581 +# SCAN CORE
  6.1582 +########################
  6.1583 +# Include various scan core-functions. It's not intended to be used
  6.1584 +# directly : prefer scan wrappers in next section.
  6.1585 +
  6.1586 +look_for_dep()
  6.1587 +{
  6.1588 +	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
  6.1589 +		grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
  6.1590 +			| cut -f 2
  6.1591 +	else
  6.1592 +		grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
  6.1593 +			cut -f 2
  6.1594 +	fi
  6.1595 +}
  6.1596 +
  6.1597 +look_for_bdep()
  6.1598 +{
  6.1599 +#	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
  6.1600 +#		grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
  6.1601 +#		| cut -f 3
  6.1602 +#	else
  6.1603 +#		grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
  6.1604 +#			cut -f 3
  6.1605 +#	fi
  6.1606 +	look_for_all
  6.1607 +}
  6.1608 +
  6.1609 +look_for_all()
  6.1610 +{
  6.1611 +	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
  6.1612 +		grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
  6.1613 +			| cut -f 2,3 | sed 's/ 	 / /'
  6.1614 +	else
  6.1615 +		grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
  6.1616 +			cut -f 2,3 | sed 's/ 	 / /'
  6.1617 +	fi
  6.1618 +}
  6.1619 +
  6.1620 +filter()
  6.1621 +{
  6.1622 +	for pkg in $(cat); do
  6.1623 +		if grep -q ^$pkg$'\t' $dep_db; then
  6.1624 +			{ grep ^$pkg$'\t' $wan_db || echo $pkg
  6.1625 +			} | sed 's/\t/ /'
  6.1626 +		else
  6.1627 +			echo "Error: $pkg can't be found." >&2
  6.1628 +		fi
  6.1629 +	done
  6.1630 +}
  6.1631 +
  6.1632 +look_for_all_filtered()
  6.1633 +{
  6.1634 +	look_for_all | filter
  6.1635 +}
  6.1636 +
  6.1637 +look_for_rdep()
  6.1638 +{
  6.1639 +	grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
  6.1640 +	if [ "$undigest" ]; then
  6.1641 +		for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
  6.1642 +			if [ ! -f "WOK$/$rdep/receipt" ]; then
  6.1643 +				echo "$rdep"
  6.1644 +			fi
  6.1645 +		done
  6.1646 +	fi
  6.1647 +}
  6.1648 +
  6.1649 +look_for_rbdep()
  6.1650 +{
  6.1651 +	grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
  6.1652 +		cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1
  6.1653 +	if [ "$undigest" ]; then
  6.1654 +		for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
  6.1655 +			| cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1); do
  6.1656 +			if [ ! -f "WOK$/$rdep/receipt" ]; then
  6.1657 +				echo "$rdep"
  6.1658 +			fi
  6.1659 +		done
  6.1660 +	fi	
  6.1661 +}
  6.1662 +
  6.1663 +# Return WANTED if it exists.
  6.1664 +look_for_wanted()
  6.1665 +{
  6.1666 +	if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
  6.1667 +		grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
  6.1668 +	else
  6.1669 +		grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
  6.1670 +	fi
  6.1671 +}
  6.1672 +
  6.1673 +# Return packages which wants PACKAGE.
  6.1674 +look_for_rwanted()
  6.1675 +{
  6.1676 +	grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
  6.1677 +	if [ "$undigest" ]; then
  6.1678 +		for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
  6.1679 +			if [ ! -f "$WOK/$rwanted/receipt" ]; then
  6.1680 +				echo "$rwanted"
  6.1681 +			fi
  6.1682 +		done
  6.1683 +	fi
  6.1684 +}
  6.1685 +
  6.1686 +look_for_dev()
  6.1687 +{
  6.1688 +	[ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev && return
  6.1689 +	[ "$undigest" ] && [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && \
  6.1690 +		echo $PACKAGE-dev
  6.1691 +}
  6.1692 +
  6.1693 +########################################################################
  6.1694 +# SCAN
  6.1695 +########################
  6.1696 +# Use wok-wanted.txt and wok-depeds.txt to scan depends.
  6.1697 +# Option in command line (must be first arg) :
  6.1698 +#   --look_for=bdep/rbdep - Look for depends or reverse depends.
  6.1699 +#   --with_dev - Add development packages (*-dev) in the result.
  6.1700 +#   --with_wanted - Add package+reverse wanted in the result.
  6.1701 +#   --with_args - Include packages in argument in the result.
  6.1702 +
  6.1703 +scan()
  6.1704 +{
  6.1705 +	# Get packages in argument.
  6.1706 +	local PACKAGE pkg_list=
  6.1707 +	for arg in $@; do
  6.1708 +		[ "$arg" = "${arg#--}" ] || continue
  6.1709 +		pkg_list="$pkg_list $arg"
  6.1710 +	done
  6.1711 +	
  6.1712 +	# Get options.
  6.1713 +	[ "$pkg_list" ] || return
  6.1714 +	local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
  6.1715 +		get_options_list="look_for with_dev with_wanted with_args cooklist"
  6.1716 +	get_options
  6.1717 +	
  6.1718 +	# Cooklist is a special case where we need to modify a little
  6.1719 +	# scan behavior
  6.1720 +	if [ "$cooklist" ]; then
  6.1721 +		look_for=all_filtered && with_args=yes && with_dev= && with_wanted= && rwan=yes
  6.1722 +		pkg_list=$(echo $pkg_list | filter)
  6.1723 +	fi
  6.1724 +	
  6.1725 +	##############################################################
  6.1726 +	# ADD TO LISTS PROPOSAL ######################################
  6.1727 +	##############################################################
  6.1728 +	#
  6.1729 +	include_wanted()
  6.1730 +	{
  6.1731 +		for pkg in $(cat); do
  6.1732 +			{ grep ^$pkg$'\t' $wan_db || echo $pkg
  6.1733 +			} | sed 's/\t/ /'
  6.1734 +		done
  6.1735 +	}
  6.1736 +	
  6.1737 +	no_duplication()
  6.1738 +	{
  6.1739 +		for pkg in $(cat); do
  6.1740 +			grep -q ^$pkg$ $tmp/list $tmp/dep && continue
  6.1741 +			echo $pkg
  6.1742 +		done
  6.1743 +	}
  6.1744 +		
  6.1745 +	append_to_list()
  6.1746 +	{
  6.1747 +		no_duplication  >> $tmp/list
  6.1748 +		# OU
  6.1749 +		include_wanted | no_duplication >> $tmp/list
  6.1750 +	}
  6.1751 +	#
  6.1752 +	##############################################################
  6.1753 +	mkdir -p $tmp
  6.1754 +	for PACKAGE in $(echo $pkg_list | filter); do
  6.1755 +		look_for_$look_for
  6.1756 +	done  | tr ' ' '\n' | sort -u > $tmp/list
  6.1757 +	[ "$look_for" = bdep ] && look_for=dep
  6.1758 +	while [ -s $tmp/list ]; do
  6.1759 +		PACKAGE=$(sed 1!d $tmp/list)
  6.1760 +		sed 1d -i $tmp/list
  6.1761 +		echo $PACKAGE >> $tmp/dep
  6.1762 +		for depend in $(look_for_$look_for); do
  6.1763 +			if ! grep -q ^$depend$ $tmp/list $tmp/dep; then
  6.1764 +				echo $depend >> $tmp/list
  6.1765 +			fi
  6.1766 +		done
  6.1767 +	done
  6.1768 +	[ "$with_args" ] && echo $pkg_list | tr ' ' '\n' >> $tmp/dep
  6.1769 +	if [ -s $tmp/dep ]; then
  6.1770 +		if [ "$with_wanted" ]; then
  6.1771 +			cat $tmp/dep | while read PACKAGE; do
  6.1772 +				look_for_rwanted >> $tmp/dep
  6.1773 +			done
  6.1774 +		elif [ "$with_dev" ]; then
  6.1775 +			cat $tmp/dep | while read PACKAGE; do
  6.1776 +				look_for_dev >> $tmp/dep
  6.1777 +			done
  6.1778 +		fi
  6.1779 +		if [ "$cooklist" ]; then
  6.1780 +			
  6.1781 +			# Make report quiet.
  6.1782 +			report(){ : ; }
  6.1783 +			
  6.1784 +			mv $tmp/dep $tmp/cooklist
  6.1785 +			sort_cooklist
  6.1786 +			rm $tmp/cooklist
  6.1787 +		else
  6.1788 +			cat $tmp/dep | sort -u
  6.1789 +		fi
  6.1790 +	fi
  6.1791 +	rm $tmp/dep $tmp/list 2>/dev/null
  6.1792 +}
  6.1793 +
  6.1794 +########################################################################
  6.1795 +# This section contains functions to check package repository and
  6.1796 +# find which packages to cook.
  6.1797 +########################
  6.1798 +
  6.1799 +# Actually its becomes more than check commit... Maybe put this in report
  6.1800 +# function is a good idea.
  6.1801 +check_for_commit()
  6.1802 +{
  6.1803 +	report step "Checking for commits"
  6.1804 +	
  6.1805 +	# Clean the list... Later we will perfom a partial clean only to keep
  6.1806 +	# some usefull informations
  6.1807 +	rm $PACKAGES_REPOSITORY/commit 2>/dev/null
  6.1808 +	
  6.1809 +	# If there's a packages-incoming repository we need to check it too.
  6.1810 +	for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do
  6.1811 +		source_receipt
  6.1812 +	
  6.1813 +		# We use md5 of cooking stuff in the packaged receipt to check
  6.1814 +		# commit. We look consecutively in 3 different locations :
  6.1815 +		# - in the wok/PACKAGE/taz folder
  6.1816 +		# - in the receipt in the package in incoming repository
  6.1817 +		# - in the receipt in the package in packages repository
  6.1818 +		# If md5sum match, there's no commit.
  6.1819 +		# If there's not md5sum datas, because the package was cooked
  6.1820 +		# with a previous version of tazwok, we don't put in in commit
  6.1821 +		# list (need a cook-all to refresh them)
  6.1822 +		# If there's no receipt available, package is missing so we put
  6.1823 +		# it in commit list.
  6.1824 +		# First look for package in packages-incoming.
  6.1825 +		check_for_commit_using_md5sum()
  6.1826 +		{
  6.1827 +			if [ ! -f $WOK/$PACKAGE/md5 ]; then
  6.1828 +				sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
  6.1829 +					sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
  6.1830 +				cd $WOK/$PACKAGE
  6.1831 +			fi
  6.1832 +	
  6.1833 +			# Use md5sum list in receipt to check for commit.
  6.1834 +			if [ -s md5 ]; then					
  6.1835 +				if md5sum -cs md5; then
  6.1836 +					return_code=0
  6.1837 +	
  6.1838 +					# If md5sum check if ok, check for new files in
  6.1839 +					# cooking stuff.
  6.1840 +					for file in receipt description.txt $( [ -d stuff ] && find stuff); do
  6.1841 +						if [ -f $file ] && ! grep -q ' '$file$ md5; then
  6.1842 +							set_commited
  6.1843 +						fi
  6.1844 +					done
  6.1845 +				else
  6.1846 +					set_commited
  6.1847 +				fi
  6.1848 +			else
  6.1849 +				gen_cookmd5
  6.1850 +			fi
  6.1851 +		}
  6.1852 +		set_commited()
  6.1853 +		{
  6.1854 +			echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
  6.1855 +			echo "Commit: $PACKAGE ($VERSION)"
  6.1856 +			gen_cookmd5
  6.1857 +		}
  6.1858 +		taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | grep -v '\*')
  6.1859 +		if [ -f $WOK/$PACKAGE/md5 ]; then
  6.1860 +			cd $WOK/$PACKAGE
  6.1861 +			check_for_commit_using_md5sum
  6.1862 +		elif [ "$taz_dir" ]; then
  6.1863 +			cd $taz_dir
  6.1864 +			check_for_commit_using_md5sum
  6.1865 +		else
  6.1866 +			pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
  6.1867 +			[ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
  6.1868 +			if [ "$pkg" ]; then
  6.1869 +				get_pkg_files $pkg
  6.1870 +				check_for_commit_using_md5sum
  6.1871 +				rm -r $pkg_files_dir
  6.1872 +				continue
  6.1873 +			fi
  6.1874 +			set_commited
  6.1875 +		fi
  6.1876 +	done
  6.1877 +	report end-step
  6.1878 +}
  6.1879 +
  6.1880 +gen_cook_list()
  6.1881 +{
  6.1882 +	if [ -s $PACKAGES_REPOSITORY/commit ]; then
  6.1883 +		report step "Generate genpkg & cook lists."
  6.1884 +		cd $PACKAGES_REPOSITORY
  6.1885 +		#cp commit $tmp/commit
  6.1886 +		#if [ -s broken ]; then	
  6.1887 +			## dep_scan return deps including the packages given in argument.
  6.1888 +			## To avoid that, we firt generate a list of direct rdepends of
  6.1889 +			## brokens without packages in argument, then we generate the
  6.1890 +			## full rdeps list. We do this because we don't want to block
  6.1891 +			## packages at source of broken tree if a fix as been commited.
  6.1892 +			#for PACKAGE in $(cat broken); do
  6.1893 +				#look_for_rdep >> $tmp/broken
  6.1894 +			#done
  6.1895 +			#cat $tmp/broken
  6.1896 +			#look_for=rdep && with_wanted=yes
  6.1897 +			#for PACKAGE in $(dep_scan `cat $tmp/broken`); do
  6.1898 +				#if grep -q ^$PACKAGE$ $tmp/commit; then
  6.1899 +					#sed "/^$PACKAGE$/d" -i $tmp/commit
  6.1900 +				#fi
  6.1901 +			#done
  6.1902 +			#rm $tmp/broken
  6.1903 +		#fi
  6.1904 +		for PACKAGE in $(cat commit); do
  6.1905 +			WANTED="$(look_for_wanted)"
  6.1906 +			if [ "$WANTED" ]; then
  6.1907 +
  6.1908 +				# If cook of wanted package is planned, this one will be
  6.1909 +				# packaged at the same time. Else if wanted package is
  6.1910 +				# broken or blocked, ignore the commit. Else, put the
  6.1911 +				# package in genpkglist.
  6.1912 +				{ grep -q ^$WANTED$ commit || grep -q ^$WANTED$ broken || \
  6.1913 +					grep -q ^$WANTED$ cooklist || grep -q ^$WANTED$ blocked || \
  6.1914 +					grep -q ^$WANTED$ genpkglist
  6.1915 +				} && continue
  6.1916 +				echo $WANTED >> genpkglist
  6.1917 +			else
  6.1918 +				{ grep -q ^$PACKAGE$ blocked || grep -q ^$PACKAGE$ cooklist 
  6.1919 +				} && continue
  6.1920 +				echo $PACKAGE >> cooklist
  6.1921 +				sed "/^$PACKAGE$/d" -i broken
  6.1922 +			fi
  6.1923 +		done
  6.1924 +		#rm $tmp/commit
  6.1925 +		if [ -s genpkglist ]; then
  6.1926 +			echo "genpkglist:"
  6.1927 +			cat genpkglist
  6.1928 +		fi
  6.1929 +		report end-step
  6.1930 +	fi
  6.1931 +	cooklist=$PACKAGES_REPOSITORY/cooklist
  6.1932 +	sort_cooklist
  6.1933 +}
  6.1934 +
  6.1935 +sort_cooklist()
  6.1936 +{
  6.1937 +	[ ! "$cooklist" ] && cooklist=$PACKAGES_REPOSITORY/cooklist
  6.1938 +	[ -s $cooklist ] || [ -s "$tmp/cooklist" ] || return
  6.1939 +	[ -s $PACKAGES_REPOSITORY/cookorder.txt ] || gen_wok_db
  6.1940 +	[ ! -s "$tmp/cooklist" ] && cp -a $cooklist $tmp/cooklist
  6.1941 +	report step "Sorting cooklist"
  6.1942 +
  6.1943 +	# Use cookorder.txt to sort cooklist.
  6.1944 +	cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
  6.1945 +		if grep -q ^$PACKAGE$ $tmp/cooklist; then
  6.1946 +			sed "/^$PACKAGE$/d" -i $tmp/cooklist
  6.1947 +			echo $PACKAGE >> $tmp/cooklist.tmp
  6.1948 +		fi
  6.1949 +	done
  6.1950 +
  6.1951 +	# Remaining packages in cooklist are thoses without compile_rules.
  6.1952 +	# They can be cooked first in any order.
  6.1953 +	mv -f $tmp/cooklist.tmp $tmp/cooklist
  6.1954 +	[ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
  6.1955 +		cat $tmp/cooklist > $cooklist
  6.1956 +	cat $tmp/cooklist
  6.1957 +	report end-step
  6.1958 +}
  6.1959 +
  6.1960 +
  6.1961 +
  6.1962 +#remove_old_packages()
  6.1963 +#{
  6.1964 +	#report step "Removing old packages"
  6.1965 +	#echo -n "" >> $tmp/oldpkg
  6.1966 +	#if [ -f $INCOMING_REPOSITORY/packages.txt ]; then
  6.1967 +		
  6.1968 +	 #&& incoming=y
  6.1969 +	#for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do
  6.1970 +		#source_receipt
  6.1971 +		## First look for package in packages-incoming.
  6.1972 +		#if [ "$incoming" ]; then
  6.1973 +			#pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
  6.1974 +		#fi
  6.1975 +		#if [ "$pkg" ]; then
  6.1976 +			#echo $pkg >> $tmp/oldpkg
  6.1977 +			## The package in PACKAGES_REPOSITORY, even if old, should not be removed yet.
  6.1978 +			#echo $PACKAGES_REPOSITORY/$(grep ^$PACKAGE- $PACKAGES_REPOSITORY/packages.list 2>/dev/null)*.tazpkg >> $tmp/oldpkg
  6.1979 +		#else
  6.1980 +			#echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg >> $tmp/oldpkg
  6.1981 +		#fi
  6.1982 +	#done
  6.1983 +	#for pkg in $(echo $PACKAGES_REPOSITORY/*.tazpkg | grep -v '\*') \
  6.1984 +		#$(echo $INCOMING_REPOSITORY/*.tazpkg | grep -v '\*'); do
  6.1985 +		#grep -q ^$pkg$ $tmp/oldpkg && continue
  6.1986 +		#echo "Removing $pkg"
  6.1987 +		##rm $pkg
  6.1988 +	#done
  6.1989 +	#rm $tmp/oldpkg
  6.1990 +#}
  6.1991 +
  6.1992 +check_for_incoming()
  6.1993 +{
  6.1994 +	[ -s $INCOMING_REPOSITORY/packages.txt ] || return
  6.1995 +	report step "Checking packages-incoming repository"
  6.1996 +	cd $INCOMING_REPOSITORY
  6.1997 +	grep ^[0-9,a-z,A-Z] packages.txt > $tmp/incoming
  6.1998 +	scan `cat $PACKAGES_REPOSITORY/broken` --look_for=bdep --with_wanted > $tmp/broken
  6.1999 +	for PACKAGE in $(scan `cat $tmp/broken` --look_for=rdep --with_wanted --with_args); do
  6.2000 +		sed "/^$PACKAGE$/d" -i $tmp/incoming
  6.2001 +		for rwanted in $(look_for_rwanted); do
  6.2002 +			sed "/^$rwanted$/d" -i $tmp/incoming
  6.2003 +		done
  6.2004 +	done
  6.2005 +	rm $tmp/broken
  6.2006 +	if [ "$incoming_delay" != 0 ]; then
  6.2007 +		cat $tmp/incoming | while read PACKAGE; do
  6.2008 +			[ "$(grep ^$PACKAGE$ $tmp/incoming)" ] || continue
  6.2009 +			dep_list=$( { scan $PACKAGE --look_for=bdep --with_wanted && \
  6.2010 +				scan $PACKAGE --look_for=rdep --with_wanted --with_args; } \
  6.2011 +				| sort -u )
  6.2012 +			for dep in $dep_list; do
  6.2013 +				[ "$(find -name "`get_pkg_version $INCOMING_REPOSITORY`.tazpkg" -mtime +$incoming_delay)" ] && continue
  6.2014 +				for pkg in $dep_list; do
  6.2015 +					sed "/^$pkg$/d" -i $tmp/incoming
  6.2016 +				done && break
  6.2017 +			done
  6.2018 +		done
  6.2019 +	fi
  6.2020 +	if [ -s "$tmp/incoming" ]; then
  6.2021 +		for PACKAGE in $(cat $tmp/incoming); do
  6.2022 +			prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
  6.2023 +			remove_previous_package $PACKAGES_REPOSITORY
  6.2024 +			remove_previous_tarball
  6.2025 +			cur_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
  6.2026 +			mv -f $PACKAGE-$cur_VERSION.tazpkg $PACKAGES_REPOSITORY
  6.2027 +			echo "Moving $PACKAGE to main repository."
  6.2028 +		done
  6.2029 +	pkg_repository=$INCOMING_REPOSITORY && update_packages_db
  6.2030 +	pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
  6.2031 +	fi
  6.2032 +	report end-step
  6.2033 +}
  6.2034 +
  6.2035 +########################################################################
  6.2036 +# TAZWOK MAIN FUNCTIONS
  6.2037 +########################
  6.2038 +
  6.2039 +clean()
  6.2040 +{
  6.2041 +	cd $WOK/$PACKAGE
  6.2042 +	ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
  6.2043 +		-e ^stuff$ || return
  6.2044 +	
  6.2045 +	report step "Cleaning $PACKAGE"
  6.2046 +	# Check for clean_wok function.
  6.2047 +	if grep -q ^clean_wok $RECEIPT; then
  6.2048 +		clean_wok
  6.2049 +	fi
  6.2050 +	# Clean should only have a receipt, stuff and optional desc.
  6.2051 +	for f in `ls .`
  6.2052 +	do
  6.2053 +		case $f in
  6.2054 +			receipt|stuff|description.txt)
  6.2055 +				continue ;;
  6.2056 +			*)
  6.2057 +				echo "Removing: $f"
  6.2058 +				rm -rf $f
  6.2059 +		esac
  6.2060 +	done
  6.2061 +	report end-step
  6.2062 +}
  6.2063 +
  6.2064 +# Configure and make a package with the receipt.
  6.2065 +compile_package()
  6.2066 +{
  6.2067 +	check_for_package_on_cmdline
  6.2068 +
  6.2069 +	# Include the receipt to get all needed variables and functions
  6.2070 +	# and cd into the work directory to start the work.
  6.2071 +	check_for_receipt
  6.2072 +	source_receipt
  6.2073 +
  6.2074 +	# Log the package name and date.
  6.2075 +	echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
  6.2076 +	echo "package $PACKAGE (compile)" >> $LOG
  6.2077 +
  6.2078 +	# Set wanted $src variable to help compiling.
  6.2079 +	[ ! "$src" ] && set_src_path
  6.2080 +	check_for_build_depends || return 1
  6.2081 +	check_for_wanted 
  6.2082 +	unset target
  6.2083 +	check_for_tarball && check_for_compile_rules
  6.2084 +}
  6.2085 +
  6.2086 +# Cook command also include all features to manage lists which keep
  6.2087 +# track of wok/packages state.
  6.2088 +cook()
  6.2089 +{
  6.2090 +	cook_code=
  6.2091 +	set_common_path
  6.2092 +	check_for_receipt
  6.2093 +	source_receipt
  6.2094 +
  6.2095 +	# Define log path and start report.
  6.2096 +	[ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
  6.2097 +	report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
  6.2098 +	report step "Cooking $PACKAGE"
  6.2099 +	report open-bloc
  6.2100 +
  6.2101 +	# Clean package if needed.
  6.2102 +	clean $PACKAGE
  6.2103 +
  6.2104 +	# Remove PACKAGE from commit & cook lists.
  6.2105 +	sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
  6.2106 +	sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
  6.2107 +	[ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
  6.2108 +	
  6.2109 +	if compile_package; then
  6.2110 +		refresh_packages_from_compile
  6.2111 +		gen_package
  6.2112 +		remove_src
  6.2113 +
  6.2114 +		# Plan recook of reverse build depends if gen_package has detect
  6.2115 +		# a change in libraries.
  6.2116 +		if [ "$cook_rdep" ]; then
  6.2117 +			report step "Look for packages which need a refresh"
  6.2118 +			for rdep in $(scan $PACKAGE --look_for=rdep); do
  6.2119 +				sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
  6.2120 +				if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
  6.2121 +					echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
  6.2122 +					echo $rdep >> $tmp/cooklist
  6.2123 +					regen_cooklist=yes
  6.2124 +				fi
  6.2125 +			done
  6.2126 +			report end-step
  6.2127 +		fi
  6.2128 +
  6.2129 +		# Update packages-incoming repository.
  6.2130 +		store_pkgname=$PACKAGE
  6.2131 +		pkg_repository=$INCOMING_REPOSITORY
  6.2132 +		update_packages_db
  6.2133 +
  6.2134 +		PACKAGE=$store_pkgname
  6.2135 +		unset store_pkgname
  6.2136 +		
  6.2137 +		# Upgrade to cooked packages if it was previously installed.
  6.2138 +		report step "Look for package(s) to upgrade"
  6.2139 +		for pkg in $(look_for_rwanted) $PACKAGE; do
  6.2140 +			if [ -d $INSTALLED/$pkg ]; then
  6.2141 +				tazpkg get-install $pkg --forced
  6.2142 +			fi
  6.2143 +		done
  6.2144 +		report end-step
  6.2145 +	else
  6.2146 +
  6.2147 +		# Set package as broken.
  6.2148 +		if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
  6.2149 +			echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
  6.2150 +		fi
  6.2151 +		gen_cookmd5
  6.2152 +		cook_code=1
  6.2153 +	fi
  6.2154 +
  6.2155 +	# Remove build_depends in cook mode (if in cooklist, it's done when
  6.2156 +	# checking build_depends of next package and we remove only unneeded
  6.2157 +	# packages to keep chroot minimal and gain some time).
  6.2158 +	[ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
  6.2159 +
  6.2160 +	# Regen the cooklist if it was planned and command is not cook.
  6.2161 +	[ "$regen_cooklist" ] && unset regen_cooklist && \
  6.2162 +		[ "$COMMAND" != cook ] && sort_cooklist
  6.2163 +
  6.2164 +	# Some hacks to set the bloc & function status as failed if cook was
  6.2165 +	# failed.
  6.2166 +	report_return_code=$cook_code
  6.2167 +	report close-bloc
  6.2168 +	report end-sublog
  6.2169 +	return $cook_code
  6.2170 +}
  6.2171 +
  6.2172 +genpkg_list()
  6.2173 +{
  6.2174 +	while [ -s $PACKAGES_REPOSITORY/genpkglist ]; do
  6.2175 +		PACKAGE=$(sed 1!d $PACKAGES_REPOSITORY/genpkglist)
  6.2176 +		gen_package
  6.2177 +	done
  6.2178 +}
  6.2179 +
  6.2180 +cook_list()
  6.2181 +{
  6.2182 +	if [ ! -s $cooklist ]; then
  6.2183 +		echo "Nothing to cook."
  6.2184 +		return
  6.2185 +	fi
  6.2186 +	if [ -f /usr/bin/tazchroot ]; then
  6.2187 +		# Note : options -main variables- are automatically keeped by
  6.2188 +		# the sub-applications tazchroot/tazwok; as well as report data.
  6.2189 +		cd $LOCAL_REPOSITORY
  6.2190 +		[ ! -f tazchroot.conf ] && configure_tazchroot
  6.2191 +		tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
  6.2192 +		return
  6.2193 +	fi
  6.2194 +	while [ -s $tmp/cooklist ]; do
  6.2195 +		PACKAGE=$(sed 1!d $tmp/cooklist)
  6.2196 +		cook
  6.2197 +	done
  6.2198 +	remove_build_depends $MISSING_PACKAGE $remove_later
  6.2199 +}
  6.2200 +
  6.2201 +configure_tazchroot()
  6.2202 +{
  6.2203 +	cat >> $LOCAL_REPOSITORY/tazchroot.conf << EOF
  6.2204 +# Tazchroot configuration file - created by tazwok.
  6.2205 +
  6.2206 +# Default chroot path
  6.2207 +SLITAZ_DIR=$SLITAZ_DIR
  6.2208 +SLITAZ_VERSION=$SLITAZ_VERSION
  6.2209 +$( [ "$undigest" ] && echo "undigest=$undigest" )
  6.2210 +LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
  6.2211 +chroot_dir=\$LOCAL_REPOSITORY/chroot
  6.2212 +
  6.2213 +# Default scripts path (theses scripts are added in the
  6.2214 +# $chroot_dir/usr/bin and can be called with tazchroot script)
  6.2215 +script_dir=/var/lib/tazchroot
  6.2216 +
  6.2217 +# List of directories to mount.
  6.2218 +list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do [ -d "$LOCAL_REPOSITORY/$dir" ] && echo $LOCAL_REPOSITORY/$dir; done)
  6.2219 +$SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
  6.2220 +
  6.2221 +create_chroot()
  6.2222 +{
  6.2223 +	mkdir -p \$chroot_dir
  6.2224 +	for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
  6.2225 +		tazpkg get-install \$pkg --root="\$chroot_dir"
  6.2226 +	done
  6.2227 +
  6.2228 +	# Store list of installed packages needed by cleanchroot.
  6.2229 +	ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCAL_STATE/chroot-pkgs
  6.2230 +
  6.2231 +	sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
  6.2232 +		-e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
  6.2233 +		-i \$chroot_dir/etc/slitaz/slitaz.conf
  6.2234 +$( [ "$undigest" ] && echo '	echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
  6.2235 +	sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
  6.2236 +}
  6.2237 +
  6.2238 +mount_chroot()
  6.2239 +{
  6.2240 +	cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
  6.2241 +	echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCAL_STATE/mirror
  6.2242 +	mkdir -p \$chroot_dir\$LOCAL_STATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
  6.2243 +	echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCAL_STATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
  6.2244 +$( [ "$undigest" ] && echo '	mkdir -p $chroot_dir$LOCAL_STATE/undigest/$SLITAZ_VERSION
  6.2245 +	echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCAL_STATE/undigest/$SLITAZ_VERSION/mirror' )
  6.2246 +	echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCAL_STATE/priority
  6.2247 +	mount -t proc proc \$chroot_dir/proc
  6.2248 +	mount -t sysfs sysfs \$chroot_dir/sys
  6.2249 +	mount -t devpts devpts \$chroot_dir/dev/pts
  6.2250 +	mount -t tmpfs shm \$chroot_dir/dev/shm 
  6.2251 +	for dir in \$list_dir; do
  6.2252 +		mkdir -p \$dir \$chroot_dir\$dir
  6.2253 +		mount \$dir \$chroot_dir\$dir
  6.2254 +	done
  6.2255 +}
  6.2256 +
  6.2257 +umount_chroot()
  6.2258 +{
  6.2259 +	for dir in \$list_dir; do
  6.2260 +		umount \$chroot_dir\$dir
  6.2261 +	done
  6.2262 +	umount \$chroot_dir/dev/shm
  6.2263 +	umount \$chroot_dir/dev/pts
  6.2264 +	umount \$chroot_dir/sys
  6.2265 +	umount \$chroot_dir/proc
  6.2266 +}
  6.2267 +EOF
  6.2268 +}
  6.2269 +
  6.2270 +########################################################################
  6.2271 +######################### END OF NEW FUNCTIONS #########################
  6.2272 +########################################################################
  6.2273 +
  6.2274  # List packages providing a virtual package
  6.2275  whoprovide()
  6.2276  {
  6.2277 @@ -755,49 +1973,69 @@
  6.2278  	done
  6.2279  }
  6.2280  
  6.2281 -###################
  6.2282 -# Tazwok commands #
  6.2283 -###################
  6.2284 +########################################################################
  6.2285 +# TAZWOK COMMANDS
  6.2286 +########################
  6.2287  
  6.2288  case "$COMMAND" in
  6.2289  	stats)
  6.2290  		# Tazwok general statistics from the wok config file.
  6.2291  		#
  6.2292 -		echo ""
  6.2293 -		echo -e "\033[1mTazwok configuration statistics\033[0m
  6.2294 +		get_tazwok_config
  6.2295 +		echo -e "\n\033[1mTazwok configuration statistics\033[0m
  6.2296  ================================================================================
  6.2297  Wok directory        : $WOK
  6.2298  Packages repository  : $PACKAGES_REPOSITORY
  6.2299 +Incoming repository  : $INCOMING_REPOSITORY
  6.2300  Sources repository   : $SOURCES_REPOSITORY
  6.2301 +Log directory        : $LOCAL_REPOSITORY/log
  6.2302  Packages in the wok  : `ls -1 $WOK | wc -l`
  6.2303  Cooked packages      : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
  6.2304 -================================================================================"
  6.2305 -		echo "" ;;
  6.2306 +Incoming packages    : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
  6.2307 +================================================================================\n"
  6.2308 +	;;
  6.2309  	edit)
  6.2310 +		get_tazwok_config
  6.2311  		check_for_package_on_cmdline
  6.2312  		check_for_receipt
  6.2313 -		$EDITOR $WOK/$PACKAGE/receipt ;;
  6.2314 +		$EDITOR $WOK/$PACKAGE/receipt
  6.2315 +	;;
  6.2316  	build-depends)
  6.2317 -		# List dependencies to rebuild wok
  6.2318 -		cd $WOK
  6.2319 -		ALL_DEPS="slitaz-toolchain"
  6.2320 -		echo $ALL_DEPS
  6.2321 -		for pkg in $(ls $2)
  6.2322 -		do
  6.2323 -			[ -f $pkg/receipt ] || continue
  6.2324 -			BUILD_DEPENDS=""
  6.2325 -			. $pkg/receipt
  6.2326 -			for i in $BUILD_DEPENDS; do
  6.2327 -				case " $ALL_DEPS " in
  6.2328 -				*\ $i\ *);;
  6.2329 -				*)	ALL_DEPS="$ALL_DEPS $i"
  6.2330 -					echo $i;;
  6.2331 -				esac
  6.2332 -			done
  6.2333 -		done
  6.2334 -		;;
  6.2335 +		# List dependencies to rebuild wok, or only a package
  6.2336 +		get_tazwok_config
  6.2337 +		if [ "$PACKAGE" = toolchain-cooklist ]; then
  6.2338 +			mkdir -p $tmp
  6.2339 +			scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
  6.2340 +				--cooklist
  6.2341 +		elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
  6.2342 +			scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
  6.2343 +				--look_for=dep --with_dev --with_args
  6.2344 +		else
  6.2345 +			check_for_package_on_cmdline
  6.2346 +			scan $PACKAGE --look_for=bdep --with_dev
  6.2347 +		fi
  6.2348 +	;;
  6.2349 +	gen-cooklist)
  6.2350 +		get_options_list="list"
  6.2351 +		get_tazwok_config
  6.2352 +		if [ "$list" ]; then
  6.2353 +			LIST="$list"
  6.2354 +			check_for_list
  6.2355 +		else
  6.2356 +			LIST=$(for pkg in $@; do
  6.2357 +				[ "$pkg" = "${pkg#--}" ] || continue
  6.2358 +				echo -n "$pkg "
  6.2359 +			done)
  6.2360 +			if [ ! "$LIST" ]; then
  6.2361 +				echo "Please give packages or a list file in argument." >&2
  6.2362 +				exit
  6.2363 +			fi
  6.2364 +		fi
  6.2365 +		scan $LIST --cooklist
  6.2366 +	;;
  6.2367  	check-depends)
  6.2368 -		# Check package depends
  6.2369 +		# Check package depends /!\ 
  6.2370 +		get_tazwok_config
  6.2371  		echo ""
  6.2372  		echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
  6.2373  ================================================================================"
  6.2374 @@ -876,9 +2114,10 @@
  6.2375  		done
  6.2376  		cd /tmp
  6.2377  		rm -rf $TMPDIR
  6.2378 -		;;
  6.2379 +	;;
  6.2380  	check)
  6.2381  		# Check wok consistency
  6.2382 +		get_tazwok_config
  6.2383  		echo ""
  6.2384  		echo -e "\033[1mWok and packages checking\033[0m
  6.2385  ================================================================================"
  6.2386 @@ -886,28 +2125,16 @@
  6.2387  		for pkg in $(ls)
  6.2388  		do
  6.2389  			[ -f $pkg/receipt ] || continue
  6.2390 -			PACKAGE=""
  6.2391 -			VERSION=""
  6.2392 -			EXTRAVERSION=""
  6.2393 -			CATEGORY=""
  6.2394 -			SHORT_DESC=""
  6.2395 -			MAINTAINER=""
  6.2396 -			WEB_SITE=""
  6.2397 -			WGET_URL=""
  6.2398 -			DEPENDS=""
  6.2399 -			BUILD_DEPENDS=""
  6.2400 -			WANTED=""
  6.2401 -			PACKED_SIZE=""
  6.2402 -			UNPACKED_SIZE=""
  6.2403 -			. $pkg/receipt
  6.2404 -			[ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
  6.2405 -			[ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
  6.2406 -			[ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE"
  6.2407 -			[ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE"
  6.2408 -			[ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION"
  6.2409 +			RECEIPT= $pkg/receipt
  6.2410 +			source_receipt
  6.2411 +			[ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
  6.2412 +			[ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
  6.2413 +			[ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
  6.2414 +			[ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
  6.2415 +			[ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
  6.2416  			if [ -n "$WANTED" ]; then
  6.2417  				if [ ! -f $WANTED/receipt ]; then
  6.2418 -					echo "Package $PACKAGE wants unknown $WANTED package"
  6.2419 +					echo "Package $PACKAGE wants unknown $WANTED package" >&2
  6.2420  				else
  6.2421  					BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
  6.2422  					if [ "$VERSION" = "$WANTED" ]; then
  6.2423 @@ -916,7 +2143,7 @@
  6.2424  						BASEVERSION=$VERSION
  6.2425  					fi
  6.2426  					if [ "$VERSION" != "$BASEVERSION" ]; then
  6.2427 -						echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)"
  6.2428 +						echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
  6.2429  					fi
  6.2430  				fi
  6.2431  			fi
  6.2432 @@ -924,39 +2151,39 @@
  6.2433  			if [ -n "$CATEGORY" ]; then
  6.2434  				case " $(echo $CATEGORIES) " in
  6.2435  				*\ $CATEGORY\ *);;
  6.2436 -				*) echo "Package $PACKAGE has an invalid CATEGORY";;
  6.2437 +				*) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
  6.2438  				esac
  6.2439  			else
  6.2440 -				echo"Package $PACKAGE has no CATEGORY"
  6.2441 +				echo"Package $PACKAGE has no CATEGORY" >&2
  6.2442  			fi
  6.2443 -			[ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
  6.2444 -			[ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
  6.2445 +			[ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
  6.2446 +			[ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
  6.2447  			case "$WGET_URL" in
  6.2448  			ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
  6.2449 -				echo "Package $PACKAGE has a wrong WGET_URL";;
  6.2450 +				echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
  6.2451  			'') ;;
  6.2452 -			*)  echo "Package $PACKAGE has an invalid WGET_URL";;
  6.2453 +			*)  echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
  6.2454  			esac
  6.2455  			case "$WEB_SITE" in
  6.2456  			ftp*|http*);;
  6.2457 -			'') echo "Package $PACKAGE has no WEB_SITE";;
  6.2458 -			*)  echo "Package $PACKAGE has an invalid WEB_SITE";;
  6.2459 +			'') echo "Package $PACKAGE has no WEB_SITE" >&2;;
  6.2460 +			*)  echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
  6.2461  			esac
  6.2462  			case "$MAINTAINER" in
  6.2463 -			*\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
  6.2464 +			*\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
  6.2465  			esac
  6.2466  			case "$MAINTAINER" in
  6.2467  			*@*);;
  6.2468 -			*) echo "Package $PACKAGE MAINTAINER is not an email address";;
  6.2469 +			*) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
  6.2470  			esac
  6.2471 -			MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
  6.2472 +			MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
  6.2473  			for i in $DEPENDS; do
  6.2474  				[ -d $i ] && continue
  6.2475  				[ -n "$(whoprovide $i)" ] && continue
  6.2476  				echo -e "$MSG  $i"
  6.2477  				MSG=""
  6.2478  			done
  6.2479 -			MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
  6.2480 +			MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
  6.2481  			for i in $BUILD_DEPENDS; do
  6.2482  				[ -d $i ] && continue
  6.2483  				[ -n "$(whoprovide $i)" ] && continue
  6.2484 @@ -971,77 +2198,11 @@
  6.2485  				echo "$pkg should be rebuilt after $i installation"
  6.2486  			done
  6.2487  		done
  6.2488 -		;;
  6.2489 -	cmp|compare)
  6.2490 -		# Compare the wok and packages repository to help with maintaining
  6.2491 -		# a mirror.
  6.2492 -		echo ""
  6.2493 -		echo -e "\033[1mWok and packages comparison\033[0m
  6.2494 -================================================================================"
  6.2495 -		for pkg in $WOK/*
  6.2496 -		do
  6.2497 -			[ ! -f $pkg/receipt ] && continue
  6.2498 -			WANTED=""
  6.2499 -			. $pkg/receipt
  6.2500 -			echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
  6.2501 -			tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
  6.2502 -			if [ -z "$tpkg" ]; then
  6.2503 -				echo "Missing package: $PACKAGE ($VERSION)"
  6.2504 -				echo "$PACKAGE" >> /tmp/pkgs.missing.$$
  6.2505 -			elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
  6.2506 -				echo "Obsolete package: $PACKAGE ($VERSION)"
  6.2507 -				echo "$PACKAGE" >> /tmp/pkgs.missing.$$
  6.2508 -			elif [ $pkg/receipt -nt $tpkg ]; then
  6.2509 -				echo "Refresh package: $PACKAGE ($VERSION)"
  6.2510 -				echo "$PACKAGE" >> /tmp/pkgs.missing.$$
  6.2511 -			else
  6.2512 -				srcdate=$(hgdate $pkg)
  6.2513 -				pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
  6.2514 -				echo "DEBUG:$srcdate|$pkgdate"
  6.2515 -				if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
  6.2516 -					echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
  6.2517 -					echo "$PACKAGE" >> /tmp/pkgs.missing.$$
  6.2518 -				else
  6.2519 -					continue
  6.2520 -				fi
  6.2521 -			fi
  6.2522 -			if [ "$2" = "--cook" ]; then
  6.2523 -				if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
  6.2524 -					yes '' | tazwok cook $WANTED
  6.2525 -				fi
  6.2526 -				yes '' | tazwok cook $PACKAGE
  6.2527 -			fi
  6.2528 -		done
  6.2529 -		for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
  6.2530 -		do
  6.2531 -			# grep $pkg in /tmp/wok.list.$$
  6.2532 -			# may include EXTRAVERSION or computed VERSION
  6.2533 -			for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
  6.2534 -				case "$pkg" in
  6.2535 -				${i%.tazpkg}*.tazpkg) continue 2;;
  6.2536 -				esac
  6.2537 -			done
  6.2538 -			# Not found
  6.2539 -			echo $pkg >> /tmp/pkgs.old.$$
  6.2540 -			if [ "$2" = "--remove" ]; then
  6.2541 -				echo "Removing package: $pkg"
  6.2542 -				rm $PACKAGES_REPOSITORY/$pkg
  6.2543 -			else
  6.2544 -				echo "Old package:     $pkg"
  6.2545 -			fi
  6.2546 -		done
  6.2547 -		cd /tmp
  6.2548 -		echo "================================================================================"
  6.2549 -		echo "Wok: `cat wok.list.$$ | wc -l` - \
  6.2550 -Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
  6.2551 -Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
  6.2552 -Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
  6.2553 -		echo ""
  6.2554 -		rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
  6.2555 -		;;
  6.2556 +	;;
  6.2557  	list)
  6.2558  		# List packages in wok directory. User can specify a category.
  6.2559  		#
  6.2560 +		get_tazwok_config
  6.2561  		if [ "$2" = "category" ]; then
  6.2562  			echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
  6.2563  			exit 0
  6.2564 @@ -1063,7 +2224,7 @@
  6.2565  				fi
  6.2566  			done
  6.2567  			echo "================================================================================"
  6.2568 -			echo -e "$packages packages in category $ASKED_CATEGORY.\n"
  6.2569 +			echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
  6.2570  		else
  6.2571  			# By default list all packages and version.
  6.2572  			echo ""
  6.2573 @@ -1079,12 +2240,13 @@
  6.2574  				packages=$(($packages+1))
  6.2575  			done
  6.2576  			echo "================================================================================"
  6.2577 -			echo -e "$packages packages available in the wok.\n"
  6.2578 +			echo -e "$PACKAGEs packages available in the wok.\n"
  6.2579  		fi
  6.2580  		;;
  6.2581  	info)
  6.2582  		# Information about a package.
  6.2583  		#
  6.2584 +		get_tazwok_config
  6.2585  		check_for_package_on_cmdline
  6.2586  		check_for_receipt
  6.2587  		. $WOK/$PACKAGE/receipt
  6.2588 @@ -1107,14 +2269,14 @@
  6.2589  		fi
  6.2590  		echo "================================================================================"
  6.2591  		echo ""
  6.2592 -
  6.2593 -		;;
  6.2594 +	;;
  6.2595  	check-log)
  6.2596  		# We just cat the file log to view process info.
  6.2597  		#
  6.2598 +		get_tazwok_config
  6.2599  		if [ ! -f "$LOG" ]; then
  6.2600 -			echo -e "\nNo process log found. The package is probably not cooked.\n"
  6.2601 -			exit 0
  6.2602 +			echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
  6.2603 +			exit 1
  6.2604  		else
  6.2605  			echo ""
  6.2606  			echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
  6.2607 @@ -1123,14 +2285,15 @@
  6.2608  			echo "================================================================================"
  6.2609  			echo ""
  6.2610  		fi
  6.2611 -		;;
  6.2612 +	;;
  6.2613  	search)
  6.2614  		# Search for a package by pattern or name.
  6.2615  		#
  6.2616 +		get_tazwok_config
  6.2617  		if [ -z "$2" ]; then
  6.2618 -			echo -e "\nPlease specify a pattern or a package name to search."
  6.2619 -			echo -e "Example : 'tazwok search gcc'.\n"
  6.2620 -			exit 0
  6.2621 +			echo -e "\nPlease specify a pattern or a package name to search." >&2
  6.2622 +			echo -e "Example : 'tazwok search gcc'.\n" >&2
  6.2623 +			exit 1
  6.2624  		fi
  6.2625  		echo ""
  6.2626  		echo -e "\033[1mSearch result for :\033[0m $2"
  6.2627 @@ -1142,182 +2305,188 @@
  6.2628  			echo -n "$PACKAGE "
  6.2629  			echo -en "\033[24G $VERSION"
  6.2630  			echo -e "\033[42G $CATEGORY"
  6.2631 -			packages=$(($packages+1))
  6.2632 +			packages=$(($PACKAGEs+1))
  6.2633  		done
  6.2634  		echo "================================================================================"
  6.2635 -		echo "$packages packages found for : $2"
  6.2636 +		echo "$PACKAGEs packages found for : $2"
  6.2637  		echo ""
  6.2638 -		;;
  6.2639 +	;;
  6.2640  	compile)
  6.2641  		# Configure and make a package with the receipt.
  6.2642  		#
  6.2643 +		get_tazwok_config
  6.2644 +		source_lib report
  6.2645 +		report start
  6.2646  		compile_package
  6.2647 -		;;
  6.2648 +	;;
  6.2649  	genpkg)
  6.2650  		# Generate a package.
  6.2651  		#
  6.2652 +		get_tazwok_config
  6.2653 +		source_lib report
  6.2654 +		report start
  6.2655 +		mkdir $tmp
  6.2656  		gen_package
  6.2657 -		;;
  6.2658 +	;;
  6.2659  	cook)
  6.2660  		# Compile and generate a package. Just execute tazwok with
  6.2661  		# the good commands.
  6.2662  		#
  6.2663  		check_root
  6.2664 -		compile_package
  6.2665 -		refresh_packages_from_compile
  6.2666 -		gen_package
  6.2667 -		;;
  6.2668 +		get_tazwok_config
  6.2669 +		source_lib report
  6.2670 +		report start
  6.2671 +		mkdir -p $tmp
  6.2672 +		cook
  6.2673 +	;;
  6.2674 +	sort-cooklist)
  6.2675 +		if [ ! "$LIST" ]; then
  6.2676 +			echo "Usage : tazwok sort-cooklist cooklist" >&2\
  6.2677 +			exit 1
  6.2678 +		fi
  6.2679 +		get_tazwok_config
  6.2680 +		source_lib report
  6.2681 +		report start
  6.2682 +		mkdir -p $tmp
  6.2683 +		cooklist=$LIST
  6.2684 +		sort_cooklist
  6.2685 +		cp -af $tmp/cooklist $cooklist
  6.2686 +	;;
  6.2687  	cook-list)
  6.2688  		# Cook all packages listed in a file. The path to the cooklist must
  6.2689  		# be specified on the cmdline.
  6.2690 +		# /!\ 
  6.2691 +		check_root
  6.2692 +		get_tazwok_config
  6.2693 +		source_lib report
  6.2694 +		report start
  6.2695 +		mkdir -p $tmp
  6.2696 +		cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
  6.2697 +		if [ "$LIST" ]; then
  6.2698 +			sort_cooklist
  6.2699 +		else
  6.2700 +			cp $cooklist $tmp/cooklist
  6.2701 +		fi
  6.2702 +		cook_list
  6.2703 +	;;
  6.2704 +	clean)
  6.2705 +		# Clean up a package work directory + thoses which want it.
  6.2706  		#
  6.2707 -		check_root
  6.2708 -		check_for_list
  6.2709 -		for pkg in $LIST
  6.2710 -		do
  6.2711 -			tazwok cook $pkg
  6.2712 -		done
  6.2713 -		;;
  6.2714 -	clean)
  6.2715 -		# Clean up a package work directory.
  6.2716 -		#
  6.2717 +		get_tazwok_config
  6.2718  		check_for_package_on_cmdline
  6.2719  		check_for_receipt
  6.2720 +		source_lib report
  6.2721 +		report start
  6.2722  		. $RECEIPT
  6.2723 -		cd $WOK/$PACKAGE
  6.2724 -		echo ""
  6.2725 -		echo "Cleaning $PACKAGE..."
  6.2726 -		echo "================================================================================"
  6.2727 -		# Check for clean_wok function.
  6.2728 -		if grep -q ^clean_wok $RECEIPT; then
  6.2729 -			clean_wok
  6.2730 -		fi
  6.2731 -		# Clean should only have a receipt, stuff and optional desc.
  6.2732 -		for f in `ls .`
  6.2733 -		do
  6.2734 -			case $f in
  6.2735 -				receipt|stuff|description.txt)
  6.2736 -					continue ;;
  6.2737 -				*)
  6.2738 -					echo -n "Removing: $f"
  6.2739 -					rm -rf $f
  6.2740 -					status ;;
  6.2741 -			esac
  6.2742 -		done
  6.2743 -			echo "================================================================================"
  6.2744 -		echo "$PACKAGE is clean. You can cook it again..."
  6.2745 -		echo "" ;;
  6.2746 +		clean
  6.2747 +	;;
  6.2748  	gen-clean-wok)
  6.2749  		# Generate a clean wok from the current wok by copying all receipts
  6.2750  		# and stuff directory.
  6.2751  		#
  6.2752 -		if [ -z "$2" ]; then
  6.2753 -			echo -e "\nPlease specify the destination for the new clean wok.\n"
  6.2754 -			exit 0
  6.2755 +		get_tazwok_config
  6.2756 +		source_lib report
  6.2757 +		report start
  6.2758 +		if [ -z "$ARG" ]; then
  6.2759 +			echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
  6.2760 +			exit 1
  6.2761  		else
  6.2762 -			dest=$2
  6.2763 +			dest=$ARG
  6.2764  			mkdir -p $dest
  6.2765  		fi
  6.2766 -		echo "New wok is going to : $dest"
  6.2767 +		report step "Creating clean wok in : $dest"
  6.2768  		for pkg in `ls -1 $WOK`
  6.2769  		do
  6.2770 -			echo "----"
  6.2771 -			echo -n "Preparing $pkg..."
  6.2772  			mkdir -p $dest/$pkg
  6.2773 -			status
  6.2774 -			echo -n "Copying the receipt..."
  6.2775  			cp -a $WOK/$pkg/receipt $dest/$pkg
  6.2776 -			status
  6.2777 +			[ -f $WOK/$pkg/description.txt ] && \
  6.2778 +				cp -a $WOK/$pkg/description.txt $dest/$pkg
  6.2779  			if [ -d "$WOK/$pkg/stuff" ]; then
  6.2780 -				echo -n "Copying the stuff directory..."
  6.2781  				cp -a $WOK/$pkg/stuff $dest/$pkg
  6.2782 -				status
  6.2783  			fi
  6.2784  		done
  6.2785 -		echo "================================================================================"
  6.2786 -		echo "Clean wok generated in : $dest"
  6.2787 +		[ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
  6.2788 +		report end-step
  6.2789  		echo "Packages cleaned       : `ls -1 $dest | wc -l`"
  6.2790  		echo ""
  6.2791 -		;;
  6.2792 +	;;
  6.2793  	clean-wok)
  6.2794  		# Clean all packages in the work directory
  6.2795  		#
  6.2796 -		for pkg in `ls -1 $WOK`
  6.2797 +		get_tazwok_config
  6.2798 +		source_lib report
  6.2799 +		report start
  6.2800 +		report step "Cleaning wok"
  6.2801 +		report open-bloc
  6.2802 +		for PACKAGE in `ls -1 $WOK`
  6.2803  		do
  6.2804 -			tazwok clean $pkg
  6.2805 +			set_common_path
  6.2806 +			source_receipt
  6.2807 +			clean
  6.2808  		done
  6.2809 -		echo "================================================================================"
  6.2810 +		report close-bloc
  6.2811  		echo "`ls -1 $WOK | wc -l` packages cleaned."
  6.2812 -		echo ""
  6.2813 -		;;
  6.2814 +	;;
  6.2815  	gen-list)
  6.2816 -		# Sed is used to remove all the .tazpkg extensions from the
  6.2817 -		# packages.list. The directory to move into by default is the repository,
  6.2818 -		# if $2 is not empty cd into $2. A text packages list can also be gen
  6.2819 -		# with the option --text.
  6.2820 +		check_root
  6.2821 +		get_tazwok_config
  6.2822 +		source_lib report
  6.2823 +		report start
  6.2824 +		dbtype=packages
  6.2825 +		mode=gen
  6.2826 +		for pkg_repository in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
  6.2827 +			files_list="$pkg_repository/files.list.lzma \
  6.2828 +				$pkg_repository/packages.list \
  6.2829 +				$pkg_repository/packages.txt \
  6.2830 +				$pkg_repository/packages.desc \
  6.2831 +				$pkg_repository/packages.equiv \
  6.2832 +				$pkg_repository/packages.md5"
  6.2833 +			gen_db
  6.2834 +			echo "$pkgs packages in the repository."
  6.2835 +			echo ""
  6.2836 +		done
  6.2837 +	;;
  6.2838 +	check-list)
  6.2839 +		# The directory to move into by default is the repository,
  6.2840 +		# if $2 is not empty cd into $2.
  6.2841  		#
  6.2842 -		fakewok=""
  6.2843 -		if [ "$2" == "--text" ]; then
  6.2844 -			textlist="yes"
  6.2845 -			
  6.2846 -			# Fakewok can be deleted, actually we just warning users about that.
  6.2847 -			if [ "$3" == "--fakewok" ]; then
  6.2848 -				echo "WARNING: fakewok is deprecated - tazwok extract datas from packages automatically when necessary."
  6.2849 -				WOK=/tmp/fakewok-$$
  6.2850 -				fakewok="$WOK"
  6.2851 -				mkdir -p $WOK
  6.2852 -				for i in $PACKAGES_REPOSITORY/*.tazpkg; do
  6.2853 -					(cd $WOK; cpio -i receipt files.list 2>/dev/null) < $i
  6.2854 -					. $WOK/receipt
  6.2855 -					mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
  6.2856 -					mv $WOK/receipt $WOK/files.list \
  6.2857 -						$WOK/$PACKAGE/taz/$PACKAGE-$VERSION
  6.2858 -					ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
  6.2859 -				done
  6.2860 -			fi
  6.2861 -		elif [ -z "$2" ]; then
  6.2862 +		get_tazwok_config
  6.2863 +		if [ -z "$2" ]; then
  6.2864  			PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
  6.2865  		else
  6.2866  			if [ -d "$2" ]; then
  6.2867  				PACKAGES_REPOSITORY=$2
  6.2868  			else
  6.2869 -				echo -e "\nUnable to find directory : $2\n"
  6.2870 -				exit 0
  6.2871 +				echo -e "\nUnable to find directory : $2\n" >&2
  6.2872 +				exit 1
  6.2873  			fi
  6.2874  		fi
  6.2875 +		
  6.2876 +		# Use report shared library to control output.
  6.2877 +		tmp=/tmp/tazwok-$$
  6.2878 +		mkdir $tmp
  6.2879 +		source_lib report
  6.2880 +		dbtype=packages
  6.2881 +		mode=update
  6.2882  		cd $PACKAGES_REPOSITORY
  6.2883 -		# Remove old packages.list and md5sum, they will soon be rebuilt.
  6.2884 -		rm -f packages.list packages.md5 packages.txt
  6.2885 -		echo ""
  6.2886 -		echo -e "\033[1mGenerating packages lists\033[0m"
  6.2887 -		echo "================================================================================"
  6.2888 -		echo -n "Repository path : $PACKAGES_REPOSITORY" && status
  6.2889 -		# Generate packages.txt
  6.2890 -		if [ "$textlist" == "yes" ]; then
  6.2891 -			gen_textlist
  6.2892 -			[ "$fakewok" == "" ] || rm -rf $fakewok
  6.2893 -		fi
  6.2894 -		echo -n "Creating the raw packages list... "
  6.2895 -		ls -1 *.tazpkg > /tmp/packages.list
  6.2896 -		sed -i s/'.tazpkg'/''/ /tmp/packages.list
  6.2897 -		status
  6.2898 -		echo -n "Building the md5sum for all packages... "
  6.2899 -		md5sum *.tazpkg > packages.md5
  6.2900 -		status
  6.2901 -		mv /tmp/packages.list $PACKAGES_REPOSITORY
  6.2902 -		echo "================================================================================"
  6.2903 -		pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
  6.2904 +		for pkg in $(echo *.tazpkg); do
  6.2905 +			package_md5=$(md5sum $pkg)
  6.2906 +			[ "$PACKAGE_md5" = "$(grep ' '$pkg$ packages.md5)" ] && continue
  6.2907 +			erase_package_info
  6.2908 +			get_packages_info
  6.2909 +		done
  6.2910  		echo "$pkgs packages in the repository."
  6.2911  		echo ""
  6.2912 -		;;
  6.2913 +	;;
  6.2914  	new-tree)
  6.2915  		# Just create a few directories and generate an empty receipt to prepare
  6.2916  		# the creation of a new package.
  6.2917  		#
  6.2918 +		get_tazwok_config
  6.2919  		check_for_package_on_cmdline
  6.2920  		if [ -d $WOK/$PACKAGE ]; then
  6.2921 -			echo -e "\n$PACKAGE package tree already exists.\n"
  6.2922 -			exit 0
  6.2923 +			echo -e "\n$PACKAGE package tree already exists.\n" >&2
  6.2924 +			exit 1
  6.2925  		fi
  6.2926  		echo "Creating : $WOK/$PACKAGE"
  6.2927  		mkdir $WOK/$PACKAGE
  6.2928 @@ -1405,10 +2574,11 @@
  6.2929  			echo "================================================================================"
  6.2930  			echo ""
  6.2931  		fi
  6.2932 -		;;
  6.2933 +	;;
  6.2934  	remove)
  6.2935  		# Remove a package from the wok.
  6.2936  		#
  6.2937 +		get_tazwok_config
  6.2938  		check_for_package_on_cmdline
  6.2939  		echo ""
  6.2940  		echo -n "Please confirm deletion (y/N) : "; read anser
  6.2941 @@ -1417,15 +2587,18 @@
  6.2942  			rm -rf $WOK/$PACKAGE && status
  6.2943  			echo ""
  6.2944  		fi
  6.2945 -		;;
  6.2946 +	;;
  6.2947  	hgup)
  6.2948  		# Pull and update a Hg wok.
  6.2949 +		get_tazwok_config
  6.2950  		if ls -l $WOK/.hg/hgrc | grep -q "root"; then
  6.2951  			check_root
  6.2952  		fi
  6.2953  		cd $WOK
  6.2954 -		hg pull && hg update ;;
  6.2955 +		hg pull && hg update
  6.2956 +	;;
  6.2957  	maintainers)
  6.2958 +		get_tazwok_config
  6.2959  		echo ""
  6.2960  		echo "List of maintainers for: $WOK"
  6.2961  		echo "================================================================================"
  6.2962 @@ -1442,12 +2615,14 @@
  6.2963  		echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
  6.2964  		echo ""
  6.2965  		# Remove tmp files
  6.2966 -		rm -f /tmp/slitaz-maintainers ;;
  6.2967 +		rm -f /tmp/slitaz-maintainers
  6.2968 +	;;
  6.2969  	maintained-by)
  6.2970  		# Search for packages maintained by a contributor.
  6.2971 +		get_tazwok_config
  6.2972  		if [ ! -n "$2" ]; then
  6.2973 -			echo "Specify a name or email of a maintainer."
  6.2974 -			exit 0
  6.2975 +			echo "Specify a name or email of a maintainer." >&2
  6.2976 +			exit 1
  6.2977  		fi
  6.2978  		echo "Maintainer packages"
  6.2979  		echo "================================================================================"
  6.2980 @@ -1456,37 +2631,172 @@
  6.2981  			. $pkg/receipt
  6.2982  			if echo "$MAINTAINER" | grep -q "$2"; then
  6.2983  				echo "$PACKAGE"
  6.2984 -				packages=$(($packages+1))
  6.2985 +				packages=$(($PACKAGEs+1))
  6.2986  			fi
  6.2987  		done
  6.2988  		echo "================================================================================"
  6.2989 -		echo "Packages maintained by $2: $packages"
  6.2990 -		echo "" ;;
  6.2991 +		echo "Packages maintained by $2: $PACKAGEs"
  6.2992 +		echo ""
  6.2993 +	;;
  6.2994  	check-src)
  6.2995  		# Verify if upstream package is still available
  6.2996  		#
  6.2997 +		get_tazwok_config
  6.2998  		check_for_package_on_cmdline
  6.2999  		check_for_receipt
  6.3000 -		. $WOK/$PACKAGE/receipt
  6.3001 +		source_receipt
  6.3002  		check_src()
  6.3003  		{
  6.3004  			for url in $@; do
  6.3005  				busybox wget -s $url  2>/dev/null && break
  6.3006  			done
  6.3007  		}
  6.3008 -		if [ ! -z "$WGET_URL" ];then
  6.3009 +		if [ "$WGET_URL" ];then
  6.3010  			echo -n "$PACKAGE : "
  6.3011  			check_src $WGET_URL
  6.3012  			status
  6.3013  		else
  6.3014  			echo "No tarball to check for $PACKAGE"
  6.3015  		fi
  6.3016 -		;;
  6.3017 +	;;
  6.3018 +	get-src)
  6.3019 +		check_root
  6.3020 +		get_options_list="target"
  6.3021 +		get_tazwok_config
  6.3022 +		check_for_package_on_cmdline
  6.3023 +		check_for_receipt
  6.3024 +		source_receipt
  6.3025 +		if [ "$WGET_URL" ];then
  6.3026 +			source_lib report
  6.3027 +			report start
  6.3028 +			check_for_tarball
  6.3029 +		else
  6.3030 +			echo "No tarball to download for $PACKAGE"
  6.3031 +		fi
  6.3032 +	;;
  6.3033 +	check-commit)
  6.3034 +		check_root
  6.3035 +		get_tazwok_config
  6.3036 +		source_lib report
  6.3037 +		report start
  6.3038 +		mkdir -p $tmp
  6.3039 +		check_for_commit
  6.3040 +		gen_cook_list
  6.3041 +	;;
  6.3042 +	cook-commit)
  6.3043 +		check_root
  6.3044 +		get_tazwok_config
  6.3045 +		source_lib report
  6.3046 +		report start
  6.3047 +		mkdir -p $tmp
  6.3048 +		check_for_commit
  6.3049 +		# 2) update cook-database (actually complete regeneration)
  6.3050 +		dbtype=wok
  6.3051 +		mode=gen
  6.3052 +		files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
  6.3053 +		gen_db
  6.3054 +		# 3) check cooklist
  6.3055 +		# 	3.1) rename pkgs with wanted variable to wanted pkg
  6.3056 +		gen_cook_list
  6.3057 +		cook_list
  6.3058 +	;;
  6.3059 +	cook-all)
  6.3060 +		check_root
  6.3061 +		get_tazwok_config
  6.3062 +		source_lib report
  6.3063 +		report start
  6.3064 +		mkdir -p $tmp
  6.3065 +		# 2) update cook-database (actually complete regeneration)
  6.3066 +		dbtype=wok
  6.3067 +		mode=gen
  6.3068 +		files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
  6.3069 +		gen_db
  6.3070 +		# Add all packages, without toolchain, in cooklist.
  6.3071 +		# Recook toolchain need to be coded.
  6.3072 +		echo -n "" > $PACKAGES_REPOSITORY/cooklist
  6.3073 +		for pkg in $(cd $WOK && echo *); do
  6.3074 +			echo $pkg >> $PACKAGES_REPOSITORY/cooklist
  6.3075 +		done
  6.3076 +		for pkg in $(scan gcc --look_for=all --with_wanted --with_args); do
  6.3077 +			sed "/^$pkg$/d" -i $PACKAGES_REPOSITORY/cooklist
  6.3078 +		done
  6.3079 +		sort_cooklist
  6.3080 +		cook_list
  6.3081 +	;;
  6.3082 +	gen-wok-db)
  6.3083 +		check_root
  6.3084 +		get_tazwok_config
  6.3085 +		source_lib report
  6.3086 +		report start
  6.3087 +		mkdir $tmp
  6.3088 +		dbtype=wok
  6.3089 +		mode=gen
  6.3090 +		files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
  6.3091 +		gen_db
  6.3092 +	;;
  6.3093 +	report)
  6.3094 +		check_root
  6.3095 +		get_tazwok_config
  6.3096 +		cd $PACKAGES_REPOSITORY
  6.3097 +		for i in commit genpkglist cooklist incoming broken blocked; do
  6.3098 +			if [ -s $i ]; then
  6.3099 +				echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
  6.3100 +			fi
  6.3101 +		done
  6.3102 +	;;
  6.3103 +	check-incoming)
  6.3104 +		check_root
  6.3105 +		get_tazwok_config
  6.3106 +		source_lib report
  6.3107 +		report start
  6.3108 +		mkdir $tmp
  6.3109 +		check_for_incoming
  6.3110 +	;;
  6.3111 +	remove-old)
  6.3112 +		check_root
  6.3113 +		get_tazwok_config
  6.3114 +		source_lib report
  6.3115 +		report start
  6.3116 +		mkdir $tmp
  6.3117 +		remove_old_packages
  6.3118 +	;;
  6.3119 +	chroot)
  6.3120 +		check_root
  6.3121 +		get_tazwok_config
  6.3122 +		# Merge this and the other chroot function ?.
  6.3123 +		if [ -f /usr/bin/tazchroot ]; then
  6.3124 +			cd $LOCAL_REPOSITORY
  6.3125 +			[ ! -f tazchroot.conf ] && configure_tazchroot
  6.3126 +			tazchroot
  6.3127 +		else
  6.3128 +			echo "The packages tazchroot need to be installed" >&2
  6.3129 +			exit 1
  6.3130 +		fi
  6.3131 +	;;
  6.3132 +	cook-toolchain)
  6.3133 +		check_root
  6.3134 +		get_tazwok_config
  6.3135 +		echo -n "" > $PACKAGES_REPOSITORY/broken
  6.3136 +		if [ -f /usr/bin/tazchroot ]; then
  6.3137 +			cd $LOCAL_REPOSITORY
  6.3138 +			[ ! -f tazchroot.conf ] && configure_tazchroot
  6.3139 +			tazchroot cook-toolchain
  6.3140 +			# Buggy : chroot can be elsewhere.
  6.3141 +			rm -r $LOCAL_REPOSITORY/chroot
  6.3142 +			# /!\ to be writed :
  6.3143 +			# next rm chroot and plan cook-all by pushing all packages
  6.3144 +			# in cooklist.
  6.3145 +		else
  6.3146 +			echo "The packages tazchroot need to be installed" >&2
  6.3147 +			exit 1
  6.3148 +		fi
  6.3149 +	;;
  6.3150  	usage|*)
  6.3151  		# Print usage also for all unknown commands.
  6.3152  		#
  6.3153  		usage
  6.3154 -		;;
  6.3155 +	;;
  6.3156  esac
  6.3157  
  6.3158 -exit 0
  6.3159 +[ -d "$tmp" ] && rm -r $tmp
  6.3160 +report stop 2>/dev/null || exit 0
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/web/conf.php	Thu Feb 24 01:41:30 2011 +0100
     7.3 @@ -0,0 +1,12 @@
     7.4 +<?php
     7.5 +
     7.6 +// Tazwok web interface configuration
     7.7 +
     7.8 +$chroot     = "/home/slitaz/$version/chroot";
     7.9 +$lockfile   = "$chroot/home/slitaz/$version/packages/lock";
    7.10 +$db_dir     = "$chroot/home/slitaz/$version/packages";
    7.11 +$log_dir    = "$chroot/home/slitaz/$version/log";
    7.12 +$packages   = "$chroot/home/slitaz/$version/packages";
    7.13 +$hgurl      = "http://hg.slitaz.org/$wok";
    7.14 +
    7.15 +?>
     8.1 Binary file web/favicon.ico has changed
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/web/index.php	Thu Feb 24 01:41:30 2011 +0100
     9.3 @@ -0,0 +1,199 @@
     9.4 +<?php
     9.5 +$version='cooking';
     9.6 +$notversion='stable';
     9.7 +$wok='wok';
     9.8 +if (isset($_GET['stable'])) {
     9.9 +	$version='stable';
    9.10 +	$notversion='cooking';
    9.11 +	$wok='wok-stable';
    9.12 +}
    9.13 +include("conf.php");
    9.14 +?>
    9.15 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    9.16 +    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    9.17 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    9.18 +<head>
    9.19 +    <title>SliTaz Build Bot</title>
    9.20 +    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    9.21 +    <meta name="description" content="Tazbb web interface" />
    9.22 +    <meta name="robots" content="index nofollow" />
    9.23 +    <link rel="shortcut icon" href="favicon.ico" />
    9.24 +    <link rel="stylesheet" type="text/css" href="slitaz.css" />
    9.25 +</head>
    9.26 +
    9.27 +<body bgcolor="#ffffff">
    9.28 +<!-- Header -->
    9.29 +<div id="header">
    9.30 +    <a name="top"></a>
    9.31 +<!-- Access -->                                                                 
    9.32 +<div id="access">
    9.33 +    <a href="/<?php if ($version != 'stable')
    9.34 +echo "?stable"; ?>" title="Slitaz <?php
    9.35 +echo $notversion ?> packages"><?php echo $notversion ?></a>                          
    9.36 +</div>                                                                         
    9.37 +    <a href="http://bb.slitaz.org/"><img id="logo"
    9.38 +    src="pics/website/logo.png" title="bb.slitaz.org" alt="bb.slitaz.org"
    9.39 +    style="border: 0px solid ; width: 200px; height: 74px;" /></a>
    9.40 +    <p id="titre">#!/bb/packages/<?php echo $version; ?></p>
    9.41 +</div>
    9.42 +
    9.43 +<!-- Navigation menu -->
    9.44 +<div id="nav">
    9.45 +
    9.46 +<div class="nav_box">
    9.47 +<h4>SliTaz Network</h4>
    9.48 +<ul>
    9.49 +	<li><a href="http://www.slitaz.org/">Main Website</a></li>
    9.50 +	<li><a href="http://doc.slitaz.org/">Documentation</a></li>
    9.51 +	<li><a href="http://forum.slitaz.org/">Community Forum</a></li>
    9.52 +	<li><a href="http://labs.slitaz.org/">SliTaz Labs</a></li>
    9.53 +	<li><a href="http://pkgs.slitaz.org/">Packages Database</a></li>
    9.54 +	<li><a href="http://twitter.com/slitaz">SliTaz on Twitter</a></li>
    9.55 +	<li><a href="http://www.distrowatch.com/slitaz">SliTaz on DistroWatch</a></li>
    9.56 +</ul>
    9.57 +</div>
    9.58 +
    9.59 +<div class="nav_box">
    9.60 +<h4>SliTaz Developers</h4>
    9.61 +<ul>
    9.62 +	<li><a href="http://hg.slitaz.org/">Hg Repositories</a></li>
    9.63 +	<li><a href="http://tank.slitaz.org/">Tank Server</a></li>
    9.64 +	<li><a href="http://people.slitaz.org/">People Stuff</a></li>
    9.65 +	<li><a href="http://labs.slitaz.org/wiki/distro">Distro Wiki</a></li>
    9.66 +	
    9.67 +</ul>
    9.68 +</div>
    9.69 +
    9.70 +<!-- End navigation menu -->
    9.71 +</div>
    9.72 +
    9.73 +<!-- Content top. -->
    9.74 +<div id="content_top">
    9.75 +<div class="top_left"></div>
    9.76 +<div class="top_right"></div>
    9.77 +</div>
    9.78 +
    9.79 +<!-- Content -->
    9.80 +<div id="content">
    9.81 +
    9.82 +<h1><font color="#3E1220">Build Bot</font></h1>
    9.83 +<h2><font color="#DF8F06">/usr/bin/tazbb</font></h2>
    9.84 +
    9.85 +<p>
    9.86 +Tazwok is the <a href="http://www.slitaz.org/">SliTaz GNU/Linux</a> Build Bot,
    9.87 +it automatically cooks and tests packages commited in the wok. SliTaz
    9.88 +<a href="http://pkgs.slitaz.org/">packages</a> are cooked on the project
    9.89 +main server: code name <a href="http://tank.slitaz.org">Tank</a>. This
    9.90 +web interface gives the current status of the build bot and the last report
    9.91 +about any packages modified by the SliTaz contributors in the Mercurial
    9.92 +repositories, aka <a href="http://hg.slitaz.org/">Hg repos</a>.
    9.93 +</p>
    9.94 +
    9.95 +<form action="log.php" method="get">
    9.96 +<?php
    9.97 +	if ($version == 'stable')
    9.98 +		echo '<input type="hidden" name="stable" value="1" />';
    9.99 +?>	Show cooklog: <input type="text" name="package" />
   9.100 +	<!-- <input type="submit" value="Show" /> -->
   9.101 +</form>
   9.102 +
   9.103 +<h3>Summary</h3>
   9.104 +<pre class="package">
   9.105 +<?php
   9.106 +
   9.107 +// Check curent status (update in real time) and display summary.
   9.108 +
   9.109 +if (file_exists($lockfile)) {
   9.110 +	echo "Status   : Running ";
   9.111 +	include("$db_dir/running");
   9.112 +}
   9.113 +else {
   9.114 +	echo "Status   : Not currently running\n";
   9.115 +}
   9.116 +include("$db_dir/summary");
   9.117 +
   9.118 +?>
   9.119 +</pre>
   9.120 +
   9.121 +<h3>Commit</h3>
   9.122 +<pre class="package">
   9.123 +<?php
   9.124 +include("$db_dir/commit");
   9.125 +?>
   9.126 +</pre>
   9.127 +
   9.128 +<h3>Genpkglist</h3>
   9.129 +<pre class="package">
   9.130 +<?php
   9.131 +include("$db_dir/genpkglist");
   9.132 +?>
   9.133 +</pre>
   9.134 +
   9.135 +<h3>Cooklist</h3>
   9.136 +<pre class="package">
   9.137 +<?php
   9.138 +include("$db_dir/cooklist");
   9.139 +?>
   9.140 +</pre>
   9.141 +
   9.142 +<h3>Broken</h3>
   9.143 +<pre class="package">
   9.144 +<?php
   9.145 +include("$db_dir/broken");
   9.146 +?>
   9.147 +</pre>
   9.148 +
   9.149 +<h3>Blocked</h3>
   9.150 +<pre class="package">
   9.151 +<?php
   9.152 +include("$db_dir/blocked");
   9.153 +?>
   9.154 +</pre>
   9.155 +
   9.156 +<h3>Last cooked packages</h3>
   9.157 +<pre class="package">
   9.158 +<?php
   9.159 +system("cd $packages && ls -1t *.tazpkg | head -20 | \
   9.160 +	while read file; do echo -n \$(stat -c '%y' $packages/\$file | \
   9.161 +	cut -d. -f1); echo '   '\$file; done"); ?>
   9.162 +</pre>
   9.163 +
   9.164 +<h3>Last removed packages</h3>
   9.165 +<pre class="package">
   9.166 +<?php
   9.167 +include("$db_dir/removed");
   9.168 +?>
   9.169 +</pre>
   9.170 +
   9.171 +<h3>Last cooked flavors</h3>
   9.172 +<pre class="package">
   9.173 +<?php
   9.174 +system("cd $packages && ls -1t *.flavor | head -20 | \
   9.175 +	while read file; do echo -n \$(stat -c '%y' $packages/\$file | \
   9.176 +	cut -d. -f1); echo '   '\$file; done"); ?>
   9.177 +</pre>
   9.178 +
   9.179 +<!-- End of content with round corner -->
   9.180 +</div>
   9.181 +
   9.182 +<!-- Start of footer and copy notice -->
   9.183 +<div id="copy">
   9.184 +<p>
   9.185 +Copyright &copy; 2010 <a href="http://www.slitaz.org/">SliTaz</a> -
   9.186 +<a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
   9.187 +</p>
   9.188 +<!-- End of copy -->
   9.189 +</div>
   9.190 +
   9.191 +<!-- Bottom and logo's -->
   9.192 +<div id="bottom">
   9.193 +<p>
   9.194 +<a href="http://validator.w3.org/check?uri=referer"><img
   9.195 +   src="pics/website/xhtml10.png" alt="Valid XHTML 1.0"
   9.196 +   title="Code validé XHTML 1.0"
   9.197 +   style="width: 80px; height: 15px;" /></a>
   9.198 +</p>
   9.199 +</div>
   9.200 +
   9.201 +</body>
   9.202 +</html>
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/web/log.php	Thu Feb 24 01:41:30 2011 +0100
    10.3 @@ -0,0 +1,118 @@
    10.4 +<?php
    10.5 +$version='cooking';
    10.6 +$wok='wok';
    10.7 +if (isset($_GET['stable'])) {
    10.8 +	$version='stable';
    10.9 +	$wok='wok-stable';
   10.10 +}
   10.11 +include("conf.php");
   10.12 +?>
   10.13 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   10.14 +    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   10.15 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   10.16 +<head>
   10.17 +    <title>Tazbb cooklog <?php echo $_GET['package']; ?></title>
   10.18 +    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
   10.19 +    <meta name="description" content="Tazbb web interface cooklog" />
   10.20 +    <meta name="robots" content="index nofollow" />
   10.21 +    <link rel="shortcut icon" href="favicon.ico" />
   10.22 +    <link rel="stylesheet" type="text/css" href="slitaz.css" />
   10.23 +</head>
   10.24 +
   10.25 +<body bgcolor="#ffffff">
   10.26 +<!-- Header -->
   10.27 +<div id="header">
   10.28 +    <a name="top"></a>
   10.29 +    <a href="http://bb.slitaz.org/"><img id="logo"
   10.30 +    src="pics/website/logo.png" title="bb.slitaz.org" alt="bb.slitaz.org"
   10.31 +    style="border: 0px solid ; width: 200px; height: 74px;" /></a>
   10.32 +    <p id="titre">#!/bb/packages<?php if ($version == 'stable') echo '/stable'; ?></p>
   10.33 +</div>
   10.34 +
   10.35 +<!-- Navigation menu -->
   10.36 +<div id="nav">
   10.37 +
   10.38 +<div class="nav_box">
   10.39 +<h4>SliTaz Network</h4>
   10.40 +<ul>
   10.41 +	<li><a href="http://www.slitaz.org/">Main Website</a></li>
   10.42 +	<li><a href="http://doc.slitaz.org/">Documentation</a></li>
   10.43 +	<li><a href="http://forum.slitaz.org/">Community Forum</a></li>
   10.44 +	<li><a href="http://labs.slitaz.org/">SliTaz Labs</a></li>
   10.45 +	<li><a href="http://pkgs.slitaz.org/">Packages Database</a></li>
   10.46 +	<li><a href="http://twitter.com/slitaz">SliTaz on Twitter</a></li>
   10.47 +	<li><a href="http://www.distrowatch.com/slitaz">SliTaz on DistroWatch</a></li>
   10.48 +</ul>
   10.49 +</div>
   10.50 +
   10.51 +<div class="nav_box">
   10.52 +<h4>SliTaz Developers</h4>
   10.53 +<ul>
   10.54 +	<li><a href="http://hg.slitaz.org/">Hg Repositories</a></li>
   10.55 +	<li><a href="http://tank.slitaz.org/">Tank Server</a></li>
   10.56 +	<li><a href="http://people.slitaz.org/">People Stuff</a></li>
   10.57 +	<li><a href="http://labs.slitaz.org/wiki/distro">Distro Wiki</a></li>
   10.58 +</ul>
   10.59 +</div>
   10.60 +
   10.61 +<!-- End navigation menu -->
   10.62 +</div>
   10.63 +
   10.64 +<!-- Content -->
   10.65 +<div id="content">
   10.66 +
   10.67 +<h1><font color="#3E1220">Build Bot</font></h1>
   10.68 +<h2><font color="#DF8F06">Cooklog</font></h2>
   10.69 +
   10.70 +<p>
   10.71 +<form action="log.php" method="get">
   10.72 +	Show cooklog: <input type="text" name="package" />
   10.73 +	<!-- <input type="submit" value="Show" /> -->
   10.74 +<?php
   10.75 +
   10.76 +if ($_GET['package']) {
   10.77 +	$pkg = $_GET["package"];
   10.78 +	if (file_exists("$log_dir/$pkg.log")) {
   10.79 +		echo " Package $pkg: ";
   10.80 +		echo '<a href="' . "log/$pkg.log" . '">Raw log</a> ' . "\n";
   10.81 +		echo '</form></p>';
   10.82 +		echo '<pre class="log">' . "\n";
   10.83 +		echo date ("F d Y H:i:s", filemtime("log/$pkg.log"))."\n";
   10.84 +		include("$log_dir/$pkg.log");
   10.85 +		echo '</pre>';
   10.86 +	}
   10.87 +	else {
   10.88 +		echo " No log file found for: $pkg";
   10.89 +		echo '</form></p>';
   10.90 +	}
   10.91 +}
   10.92 +else {
   10.93 +	echo '</form></p>';
   10.94 +}
   10.95 +
   10.96 +?>
   10.97 +
   10.98 +<!-- End of content with round corner -->
   10.99 +</div>
  10.100 +
  10.101 +<!-- Start of footer and copy notice -->
  10.102 +<div id="copy">
  10.103 +<p>
  10.104 +Copyright &copy; 2010 <a href="http://www.slitaz.org/">SliTaz</a> -
  10.105 +<a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>
  10.106 +</p>
  10.107 +<!-- End of copy -->
  10.108 +</div>
  10.109 +
  10.110 +<!-- Bottom and logo's -->
  10.111 +<div id="bottom">
  10.112 +<p>
  10.113 +<a href="http://validator.w3.org/check?uri=referer"><img
  10.114 +   src="pics/website/xhtml10.png" alt="Valid XHTML 1.0"
  10.115 +   title="Code validé XHTML 1.0"
  10.116 +   style="width: 80px; height: 15px;" /></a>
  10.117 +</p>
  10.118 +</div>
  10.119 +
  10.120 +</body>
  10.121 +</html>
    11.1 Binary file web/pics/website/header.png has changed
    12.1 Binary file web/pics/website/logo.png has changed
    13.1 Binary file web/pics/website/xhtml10.png has changed
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/web/slitaz.css	Thu Feb 24 01:41:30 2011 +0100
    14.3 @@ -0,0 +1,366 @@
    14.4 +/*
    14.5 +	CSS style for SliTaz GNU/Linux website
    14.6 +	www.slitaz.org - (c) 2007 Pankso
    14.7 +*/
    14.8 +
    14.9 +html {
   14.10 +	height:  102%;
   14.11 +}
   14.12 +
   14.13 +body {
   14.14 +	background: #ffffff;
   14.15 +	color: black;
   14.16 +	font: 13px sans-serif, vernada, arial;
   14.17 +	margin: 0;
   14.18 +}
   14.19 +
   14.20 +/* Accessibility */
   14.21 +
   14.22 +#access {
   14.23 +	position: absolute;
   14.24 +	top: 4px;
   14.25 +	right: 4px;
   14.26 +	text-align: right;
   14.27 +	width: 100%;
   14.28 +	margin: 0;
   14.29 +	font-size: 11px;
   14.30 +	font-weight: bold;
   14.31 +}
   14.32 +
   14.33 +#access a {
   14.34 +	background: inherit;
   14.35 +	color: white;
   14.36 +	text-decoration: none;
   14.37 +}
   14.38 +
   14.39 +#access a:hover {
   14.40 +	background: inherit;
   14.41 +	color: #222222;
   14.42 +}
   14.43 +
   14.44 +/* Header and title */
   14.45 +
   14.46 +#header{
   14.47 +	background: #f0ba08 url(pics/website/header.png) repeat-x top;
   14.48 +	color: black;
   14.49 +	width: 100%;
   14.50 +	height: 50px;
   14.51 +	border-top: 1px solid black;
   14.52 +	border-bottom: 1px solid black;
   14.53 +	margin-bottom: 30px;
   14.54 +}
   14.55 +
   14.56 +#titre {
   14.57 +	position: absolute;
   14.58 +	font-size: 16px;
   14.59 +	font-weight: bolder ;
   14.60 +	margin-left: 200px;
   14.61 +	margin-top: 28px;
   14.62 +}
   14.63 +
   14.64 +#logo {
   14.65 +	position: absolute;
   14.66 +	float: left;
   14.67 +	margin-left: 16px;
   14.68 +	margin-top: 0px;
   14.69 +}
   14.70 +
   14.71 +/* Navigation */
   14.72 +
   14.73 +#nav {
   14.74 +	position: absolute;
   14.75 +	top: 76px;
   14.76 +	right: 80px;
   14.77 +	color: #555555;
   14.78 +	float: right;
   14.79 +	width: 250px;
   14.80 +	line-height: 1.5em;
   14.81 +	text-align: left;
   14.82 +	font-size: 12px;
   14.83 +}
   14.84 +
   14.85 +#nav ul {
   14.86 +	-moz-border-radius: 8px;
   14.87 +	-webkit-border-radius: 8px;
   14.88 +	list-style-type: none;
   14.89 +	margin: 10px 0;
   14.90 +	padding: 10px 24px 10px 24px;
   14.91 +	background-color: #eaeaea;
   14.92 +}
   14.93 +
   14.94 +#nav .nav_box ul {
   14.95 +	list-style-type: none;
   14.96 +	margin: 0;
   14.97 +	padding: 10px 24px 10px 0px;
   14.98 +}
   14.99 +
  14.100 +#nav li {
  14.101 +	display: inline;
  14.102 +}
  14.103 +
  14.104 +#nav h4 {
  14.105 +	font-size: 110%;
  14.106 +	color: #666666;
  14.107 +	font-weight: bold;
  14.108 +	margin: 0;
  14.109 +	padding: 0 0 1px 0;
  14.110 +	border-bottom: 1px solid #cecece;
  14.111 +}
  14.112 +
  14.113 +#nav a {
  14.114 +	color: #0F314E;
  14.115 +	background: inherit;
  14.116 +	display: block;
  14.117 +	text-decoration: none;
  14.118 +	font-weight: bold;
  14.119 +}
  14.120 +
  14.121 +#nav a:hover {
  14.122 +	color: #DF8F06;
  14.123 +	text-decoration: none;
  14.124 +	display: block;
  14.125 +}
  14.126 +
  14.127 +#nav hr {
  14.128 +	margin: 2px 0px 1px 0px;
  14.129 +	border: 0px;
  14.130 +	border-top: 1px solid #BDBDBD;
  14.131 +
  14.132 +}
  14.133 +
  14.134 +.nav_box {
  14.135 +	-moz-border-radius: 8px;
  14.136 +	-webkit-border-radius: 8px;
  14.137 +	margin: 10px 0;
  14.138 +	padding: 10px 24px 10px 24px;
  14.139 +	background-color: #eaeaea;
  14.140 +	text-align: justify;
  14.141 +}
  14.142 +
  14.143 +#nav .nav_box p {
  14.144 +	line-height: 1.3em;
  14.145 +}
  14.146 +
  14.147 +#nav .nav_box p a {
  14.148 +	display: inline;
  14.149 +	font-weight: normal;
  14.150 +	text-decoration: underline;
  14.151 +}
  14.152 +
  14.153 +#nav .nav_box p a:hover {
  14.154 +	text-decoration: none;
  14.155 +	color: blue;
  14.156 +	background: inherit;
  14.157 +}
  14.158 +
  14.159 +#nav hr {
  14.160 +	height: 0px;
  14.161 +	border: 0px solid #eaeaea;
  14.162 +}
  14.163 +
  14.164 +/* Page content */
  14.165 +
  14.166 +#content, #content_bottom, #content_top {
  14.167 +	background: white;
  14.168 +	color: black;
  14.169 +	text-align: justify;
  14.170 +}
  14.171 +
  14.172 +#content {
  14.173 +	height: auto;
  14.174 +	margin: 6px 320px 0px 0px;
  14.175 +	padding: 0px 40px 60px 80px;
  14.176 +}
  14.177 +
  14.178 +#content li {
  14.179 +	line-height: 1.5em;
  14.180 +	text-align: left;
  14.181 +}
  14.182 +
  14.183 +/* Legal informations */
  14.184 +
  14.185 +#copy {
  14.186 +	font-size: 11px ;
  14.187 +	text-align: left ;
  14.188 +	background: transparent;
  14.189 +	color: #a8a8a8;
  14.190 +	padding-top: 10px;
  14.191 +	margin: 0 0 0 80px;
  14.192 +}
  14.193 +
  14.194 +#copy a {
  14.195 +	background: inherit;
  14.196 +	color: #a8a8a8;
  14.197 +}
  14.198 +
  14.199 +#copy a:hover {
  14.200 +	background: inherit;
  14.201 +	color: #666666;
  14.202 +}
  14.203 +
  14.204 +/* Footer */
  14.205 +
  14.206 +#bottom {
  14.207 +	float: none;
  14.208 +	background: inherit;
  14.209 +	color: black;
  14.210 +	width: auto;
  14.211 +	clear: both;
  14.212 +	padding: 0;
  14.213 +	margin: 0 0 0 80px;
  14.214 +	text-align: left;
  14.215 +	vertical-align: middle;
  14.216 +}
  14.217 +
  14.218 +#news li {
  14.219 +	list-style-type: square;
  14.220 +	border-bottom: 1px dotted #BEBEBE;
  14.221 +	margin-left: -25px;
  14.222 +	padding: 4px 0px 4px 0px;
  14.223 +}
  14.224 +
  14.225 +#gallery {
  14.226 +	text-align: center;
  14.227 +}
  14.228 +
  14.229 +#gallery table {
  14.230 +	margin: 30px 0px 30px 0px;
  14.231 +}
  14.232 +
  14.233 +/* Clouds */
  14.234 +
  14.235 +#cloud {
  14.236 +	padding: 20px 0px 20px 0px;
  14.237 +	line-height: 3em;
  14.238 +	text-align: center;
  14.239 +}
  14.240 +#cloud a { padding: 4px; color: #956411; }
  14.241 +#cloud a.tag1 { font-size: 0.7em; font-weight: 100; }
  14.242 +#cloud a.tag2 { font-size: 0.8em; font-weight: 200; }
  14.243 +#cloud a.tag3 { font-size: 0.9em; font-weight: 300; }
  14.244 +#cloud a.tag4 { font-size: 1.0em; font-weight: 400; }
  14.245 +#cloud a.tag5 { font-size: 1.2em; font-weight: 500; }
  14.246 +#cloud a.tag6 { font-size: 1.4em; font-weight: 600; }
  14.247 +#cloud a.tag7 { font-size: 1.6em; font-weight: 700; }
  14.248 +#cloud a.tag8 { font-size: 1.8em; font-weight: 800; }
  14.249 +#cloud a.tag9 { font-size: 2.2em; font-weight: 900; }
  14.250 +#cloud a.tag10 { font-size: 2.5em; font-weight: 900; }
  14.251 +
  14.252 +/* CSS class. */
  14.253 +
  14.254 +.infobox {
  14.255 +	margin: 10px;
  14.256 +	padding: 12px;
  14.257 +	background: #f2f2f2;
  14.258 +	border: 1px solid #eaeaea;
  14.259 +	-moz-border-radius: 8px;
  14.260 +	-webkit-border-radius: 8px;
  14.261 +}
  14.262 +
  14.263 +/* HTML styles */
  14.264 +
  14.265 +h1 {
  14.266 +	color: blue;
  14.267 +	background: inherit;
  14.268 +	text-align: left;
  14.269 +	margin: 0px 0px 10px 0px;
  14.270 +	font-size: 140%;
  14.271 +	font-weight: bold;
  14.272 +}
  14.273 +
  14.274 +h2 {
  14.275 +	color: #DF8F06;
  14.276 +	/* border-top: 1px solid #f3f3f3; */
  14.277 +	border-left: 8px solid #f3f3f3;
  14.278 +	padding: 4px 0px 4px 4px;
  14.279 +	margin: 0;
  14.280 +	font-size: 140%;
  14.281 +	font-weight: bold;
  14.282 +}
  14.283 +
  14.284 +h3 {
  14.285 +	font-weight: bold;
  14.286 +	color: #6c0023;
  14.287 +	background: inherit;
  14.288 +}
  14.289 +
  14.290 +a {
  14.291 +	text-decoration: underline;
  14.292 +	color: #0F314E;
  14.293 +	background: inherit;
  14.294 +}
  14.295 +
  14.296 +a:hover {
  14.297 +	text-decoration: none;
  14.298 +	color: blue;
  14.299 +	background: inherit;
  14.300 +}
  14.301 +
  14.302 +code {
  14.303 +	font-size: 12px;
  14.304 +	color: #669900;
  14.305 +	background: inherit;
  14.306 +}
  14.307 +
  14.308 +tt {
  14.309 +	color: #15EE15;
  14.310 +	background: inherit;
  14.311 +}
  14.312 +
  14.313 +img {
  14.314 +	border: 0pt none;
  14.315 +}
  14.316 +
  14.317 +fieldset {
  14.318 +	background: #E2ECf6;
  14.319 +	color: black;
  14.320 +	margin-top: 25px;
  14.321 +	border: 1px solid black;
  14.322 +}
  14.323 +
  14.324 +legend {
  14.325 +	border: 1px solid black;
  14.326 +	color: #6c0023;
  14.327 +	background: #eaeaea;
  14.328 +	font-weight: bold;
  14.329 +}
  14.330 +
  14.331 +pre {
  14.332 +	padding: 5px;
  14.333 +	color: black;
  14.334 +	background: #E1E0B0;
  14.335 +}
  14.336 +
  14.337 +pre.script, pre.log {
  14.338 +	padding: 10px;
  14.339 +	color: black;
  14.340 +	background: #E8E8E8;
  14.341 +	border: 1px inset #606060;
  14.342 +}
  14.343 +
  14.344 +textarea {
  14.345 +	background: #E5E5E5;
  14.346 +	margin-top: 12px;
  14.347 +}
  14.348 +
  14.349 +/* Packages pages */
  14.350 +
  14.351 +.pkg_nav {
  14.352 +	border-top: 1px solid black;
  14.353 +	margin-top: 10px;
  14.354 +	padding-top: 10px;
  14.355 +}
  14.356 +
  14.357 +pre.package {
  14.358 +	padding: 0px;
  14.359 +	color: black;
  14.360 +	background: white;
  14.361 +}
  14.362 +
  14.363 +p.get {
  14.364 +	text-align: center;
  14.365 +	padding: 10px;
  14.366 +	color: black;
  14.367 +	background: #F3F3F3;
  14.368 +	border: 1px solid #DEDEDE;
  14.369 +}