tazwok annotate tazwok @ rev 108

Add command 'maintainers' to list all packagers for a wok
author Christophe Lincoln <pankso@slitaz.org>
date Sun Jan 18 00:02:51 2009 +0100 (2009-01-18)
parents 5c096869a0bb
children 2a0e22536a34
rev   line source
pankso@7 1 #!/bin/sh
pankso@7 2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
pankso@7 3 #
MikeDSmith25@82 4 # Tazwok can compile source packages and create binary packages suitable for
MikeDSmith25@82 5 # Tazpkg (Tiny Autonomous zone package manager). You can build individual
MikeDSmith25@82 6 # packages or a list of packages with one command, rebuild the full distro,
pankso@7 7 # generate a packages repository and also list and get info about packages.
pankso@7 8 #
pankso@106 9 # (C) 2007-2009 SliTaz - GNU General Public License.
pankso@7 10 #
pascal@100 11 VERSION=2.1
pankso@7 12
pankso@7 13 ####################
pankso@7 14 # Tazwok variables #
pankso@7 15 ####################
pankso@7 16
pankso@7 17 # Packages categories.
pankso@25 18 CATEGORIES="
pankso@25 19 base-system
pascal@94 20 x-window
pankso@25 21 utilities
pankso@25 22 network
pankso@25 23 graphics
pankso@25 24 multimedia
pankso@25 25 office
pankso@25 26 development
pankso@25 27 system-tools
pankso@25 28 security
pankso@26 29 games
pankso@26 30 misc
pankso@43 31 meta
pankso@43 32 non-free"
pankso@7 33
MikeDSmith25@82 34 # Use words rather than numbers in the code.
pankso@7 35 COMMAND=$1
pankso@7 36 PACKAGE=$2
pankso@7 37 LIST=$2
pankso@7 38
MikeDSmith25@82 39 # Include config file or exit if no file found.
erjo@38 40 if [ -f "./tazwok.conf" ]; then
erjo@38 41 . ./tazwok.conf
erjo@38 42 elif [ -f "/etc/tazwok.conf" ]; then
pankso@7 43 . /etc/tazwok.conf
pankso@7 44 else
pankso@7 45 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
pankso@7 46 echo -e "Please read the Tazwok documentation.\n"
pankso@7 47 exit 0
pankso@7 48 fi
pankso@7 49
MikeDSmith25@82 50 # Create Taz wok needed directories if user is root.
pankso@7 51 if test $(id -u) = 0 ; then
pankso@7 52 # Check for the wok directory.
pankso@7 53 if [ ! -d "$WOK" ]; then
pankso@7 54 echo "Creating the wok directory..."
pankso@7 55 mkdir -p $WOK
pankso@7 56 chmod 777 $WOK
pankso@7 57 fi
pankso@7 58 # Check for the packages repository.
pankso@7 59 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
pankso@7 60 echo "Creating the packages repository..."
pankso@7 61 mkdir -p $PACKAGES_REPOSITORY
pankso@7 62 fi
pankso@7 63 # Check for the sources repository.
pankso@7 64 if [ ! -d "$SOURCES_REPOSITORY" ]; then
pankso@7 65 echo "Creating the sources repository..."
pankso@17 66 mkdir -p $SOURCES_REPOSITORY
pankso@7 67 fi
pankso@7 68 fi
pankso@7 69
pankso@7 70 # The path to the most important file used by Tazwok.
pankso@7 71 # The receipt is used to compile the source code and
MikeDSmith25@82 72 # generate suitable packages for Tazpkg.
pankso@7 73 RECEIPT="$WOK/$PACKAGE/receipt"
pankso@7 74
pankso@7 75 # The path to the process log file.
pankso@7 76 LOG="$WOK/$PACKAGE/process.log"
pankso@7 77
pankso@7 78 ####################
pankso@7 79 # Tazwok functions #
pankso@7 80 ####################
pankso@7 81
pankso@7 82 # Print the usage (English).
pankso@7 83 usage ()
pankso@7 84 {
pankso@7 85 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
pankso@107 86 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
pankso@7 87 \033[1mCommands: \033[0m\n
pankso@7 88 usage Print this short usage.
pankso@7 89 stats Print Tazwok statistics from the config file and the wok.
pascal@98 90 build-depends Generate a list of package to build wok.
pankso@66 91 cmp|compare Compare the wok and the cooked pkgs (--remove old pkgs).
pankso@7 92 list List all packages in the wok tree or by category.
MikeDSmith25@82 93 info Get information about a package in the wok.
pascal@92 94 check Check every receipt for common errors.
pankso@7 95 check-log Check the process log file of a package.
pankso@7 96 search Search for a package in the wok by pattern or name.
MikeDSmith25@82 97 compile Configure and build a package using the receipt rules.
pankso@7 98 genpkg Generate a suitable package for Tazpkg with the rules.
pankso@7 99 cook Compile and generate a package directly.
pankso@7 100 cook-list Cook all packages specified in the list by order.
pankso@7 101 clean Clean all generated files in the package tree.
pankso@7 102 new-tree Prepare a new package tree and receipt (--interactive).
MikeDSmith25@82 103 gen-list Generate a packages list for a repository (--text).
pankso@7 104 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
pankso@107 105 remove Remove a package from the wok.
pankso@108 106 hgup Pull and update a wok under Hg.
pankso@108 107 maintainers List all maintainers in the wok.
pankso@107 108 maintained-by List packages maintained by a contributor\n"
pankso@7 109 }
pankso@7 110
pankso@7 111 # Status function.
pankso@7 112 status()
pankso@7 113 {
pankso@7 114 local CHECK=$?
pankso@7 115 echo -en "\\033[70G[ "
pankso@7 116 if [ $CHECK = 0 ]; then
pankso@7 117 echo -en "\\033[1;33mOK"
pankso@7 118 else
pankso@7 119 echo -en "\\033[1;31mFailed"
pankso@7 120 fi
pankso@7 121 echo -e "\\033[0;39m ]"
pankso@7 122 }
pankso@7 123
pankso@7 124 # Check if user is root.
pankso@7 125 check_root()
pankso@7 126 {
pankso@7 127 if test $(id -u) != 0 ; then
pankso@7 128 echo -e "\nYou must be root to run `basename $0` with this option."
pankso@7 129 echo -e "Please type 'su' and root password to become super-user.\n"
pankso@7 130 exit 0
pankso@7 131 fi
pankso@7 132 }
pankso@7 133
pankso@7 134 # Check for a package name on cmdline.
pankso@7 135 check_for_package_on_cmdline()
pankso@7 136 {
pankso@7 137 if [ -z "$PACKAGE" ]; then
pankso@7 138 echo -e "\nYou must specify a package name on the command line."
pankso@7 139 echo -e "Example : tazwok $COMMAND package\n"
pankso@7 140 exit 0
pankso@7 141 fi
pankso@7 142 }
pankso@7 143
pankso@7 144 # Check for the receipt of a package used to cook.
pankso@7 145 check_for_receipt()
pankso@7 146 {
pankso@7 147 if [ ! -f "$RECEIPT" ]; then
pankso@7 148 echo -e "\nUnable to find the receipt : $RECEIPT\n"
pankso@7 149 exit 0
pankso@7 150 fi
pankso@7 151 }
pankso@7 152
pankso@7 153 # Check for a specified file list on cmdline.
pankso@7 154 check_for_list()
pankso@7 155 {
pankso@7 156 if [ -z "$LIST" ]; then
pankso@7 157 echo -e "\nPlease specify the path to the list of packages to cook.\n"
pankso@7 158 exit 0
pankso@7 159 fi
MikeDSmith25@82 160 # Check if the list of packages exists.
pankso@7 161 if [ -f "$LIST" ]; then
pankso@7 162 LIST=`cat $LIST`
pankso@7 163 else
pankso@7 164 echo -e "\nUnable to find $LIST packages list.\n"
pankso@7 165 exit 0
pankso@7 166 fi
pankso@7 167 }
pankso@7 168
pankso@7 169 # Check for the wanted package if specified in WANTED
pankso@7 170 # receipt variable. Set the $src/$_pkg variable to help compiling
pankso@7 171 # and generating packages.
pankso@7 172 check_for_wanted()
pankso@7 173 {
pankso@7 174 if [ ! "$WANTED" = "" ]; then
pankso@7 175 echo -n "Checking for the wanted package..."
pankso@7 176 if [ ! -d "$WOK/$WANTED" ]; then
pankso@7 177 echo -e "\nWanted package is missing in the work directory.\n"
pankso@7 178 exit 0
pankso@7 179 fi
erjo@38 180 # Checking for buildtree of Wanted package
pankso@39 181 if [ ! -d "$WOK/$WANTED/taz" ]; then
erjo@38 182 echo -e "\n\nSource files of wanted package is missing in the work directory."
erjo@38 183 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
erjo@38 184 if [ "$anser" == "y" ]; then
erjo@38 185 tazwok cook $WANTED
erjo@38 186 else
erjo@38 187 echo -e "\nWanted package source tree is missing in the work directory.\n"
erjo@38 188 exit 0
erjo@38 189 fi
erjo@38 190 fi
pankso@7 191 status
pankso@7 192 # Set wanted src path.
pankso@7 193 src=$WOK/$WANTED/$WANTED-$VERSION
pankso@7 194 _pkg=$src/_pkg
pankso@7 195 fi
pankso@7 196 }
pankso@7 197
erjo@38 198
pankso@40 199 # Check for build dependencies, notify user and install if specified.
pankso@18 200 check_for_build_depends()
pankso@18 201 {
pankso@18 202 echo "Checking for build dependencies..."
pankso@18 203 for pkg in $BUILD_DEPENDS
pankso@18 204 do
pankso@18 205 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@18 206 MISSING_PACKAGE=$pkg
pankso@18 207 fi
pankso@18 208 done
pankso@18 209 if [ ! "$MISSING_PACKAGE" = "" ]; then
pankso@18 210 echo "================================================================================"
pankso@18 211 for pkg in $BUILD_DEPENDS
pankso@18 212 do
pankso@18 213 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@18 214 MISSING_PACKAGE=$pkg
pankso@18 215 echo "Missing : $pkg"
pankso@18 216 fi
pankso@18 217 done
pankso@18 218 echo "================================================================================"
pankso@40 219 echo "You can continue, exit or install missing dependencies."
pankso@40 220 echo -n "Install, continue or exit (install/y/N) ? "; read anser
pankso@40 221 case $anser in
pankso@40 222 install)
pankso@40 223 for pkg in $BUILD_DEPENDS
pankso@40 224 do
pankso@40 225 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
pankso@40 226 tazpkg get-install $pkg
pankso@40 227 fi
pankso@40 228 done ;;
pankso@40 229 y|yes)
pankso@40 230 continue ;;
pankso@40 231 *)
pankso@40 232 exit 0 ;;
pankso@40 233 esac
pankso@18 234 fi
pankso@18 235 }
pascal@76 236
pascal@76 237 # Check for loop in deps tree.
pascal@76 238 check_for_deps_loop()
pascal@76 239 {
pascal@76 240 local list
pascal@76 241 local pkg
pascal@76 242 local deps
pascal@76 243 pkg=$1
pascal@76 244 shift
pascal@76 245 [ -n "$1" ] || return
pascal@76 246 list=""
pascal@76 247 # Filter out already processed deps
pascal@76 248 for i in $@; do
pascal@76 249 case " $ALL_DEPS" in
pascal@76 250 *\ $i\ *);;
pascal@76 251 *) list="$list $i";;
pascal@76 252 esac
pascal@76 253 done
pascal@76 254 ALL_DEPS="$ALL_DEPS$list "
pascal@76 255 for i in $list; do
pascal@76 256 [ -f $i/receipt ] || continue
pascal@76 257 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
pascal@76 258 case " $deps " in
pascal@76 259 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
pascal@76 260 *) check_for_deps_loop $pkg $deps;;
pascal@76 261 esac
pascal@76 262 done
pascal@76 263 }
pascal@76 264
erjo@53 265 download()
erjo@53 266 {
erjo@53 267 for file in $@; do
erjo@53 268 wget $file && break
erjo@53 269 done
erjo@53 270 }
pankso@18 271
pankso@7 272 # Configure and make a package with the receipt.
pankso@7 273 compile_package()
pankso@7 274 {
pankso@7 275 check_for_package_on_cmdline
pankso@7 276 # Include the receipt to get all needed variables and functions
pankso@7 277 # and cd into the work directory to start the work.
pankso@7 278 check_for_receipt
pankso@7 279 . $RECEIPT
pankso@7 280 # Log the package name and date.
pankso@7 281 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
pankso@7 282 echo "package $PACKAGE (compile)" >> $LOG
pankso@7 283 # Set wanted $src variable to help compiling.
pankso@7 284 if [ ! "$SOURCE" = "" ]; then
pankso@7 285 src=$WOK/$PACKAGE/$SOURCE-$VERSION
pankso@7 286 else
pankso@7 287 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
pankso@7 288 fi
pankso@18 289 check_for_build_depends
pankso@7 290 check_for_wanted
pankso@7 291 echo ""
pankso@7 292 echo "Starting to cook $PACKAGE..."
pankso@7 293 echo "================================================================================"
pankso@7 294 # Check for src tarball and wget if needed.
pankso@28 295 if [ ! "$WGET_URL" = "" ]; then
pankso@7 296 echo "Checking for source tarball... "
pankso@7 297 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
pankso@7 298 cd $SOURCES_REPOSITORY
erjo@53 299 download $WGET_URL
erjo@53 300 #wget $WGET_URL
pankso@7 301 # Exit if download failed to avoid errors.
pankso@7 302 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
pankso@7 303 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
pankso@7 304 exit 1
pankso@7 305 fi
pankso@7 306 else
pankso@7 307 echo -n "Source tarball exit... "
pankso@7 308 status
pankso@7 309 fi
MikeDSmith25@82 310 # Untaring source if necessary. We don't need to extract source if
MikeDSmith25@82 311 # the package is built with a wanted source package.
pankso@7 312 if [ "$WANTED" = "" ]; then
pankso@7 313 if [ ! -d $src ]; then
pankso@7 314 # Log process.
pankso@7 315 echo "untaring $TARBALL" >> $LOG
pankso@7 316 echo -n "Untaring $TARBALL... "
pascal@48 317 case "$TARBALL" in
pascal@97 318 *zip) ( cd $WOK/$PACKAGE; unzip -o $SOURCES_REPOSITORY/$TARBALL );;
pascal@48 319 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
pascal@48 320 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
pascal@88 321 *Z) tar xZf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
pascal@48 322 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
pascal@48 323 esac
pankso@7 324 status
pankso@52 325 # Permissions settings
pankso@52 326 chown -R root.root $WOK/$PACKAGE/$PACKAGE-* 2>/dev/null
pankso@52 327 chown -R root.root $WOK/$PACKAGE/$SOURCE-* 2>/dev/null
pankso@7 328 else
pankso@7 329 echo -n "Source direcory exit... " && status
pankso@7 330 fi
pankso@7 331 fi
pankso@7 332 fi
pankso@7 333 cd $WOK/$PACKAGE
MikeDSmith25@82 334 # Log and execute compile_rules function if it exists, to configure and
MikeDSmith25@82 335 # make the package if it exists.
pankso@28 336 if grep -q ^compile_rules $RECEIPT; then
pankso@7 337 echo "executing compile_rules" >> $LOG
pankso@7 338 compile_rules
pankso@7 339 # Exit if compilation failed so the binary package
pankso@7 340 # is not generated when using the cook comand.
pankso@7 341 local CHECK=$?
pankso@7 342 if [ $CHECK = 0 ]; then
pankso@7 343 echo "================================================================================"
pankso@7 344 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
pankso@7 345 echo ""
pankso@7 346 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
pankso@7 347 else
pankso@7 348 echo "================================================================================"
pankso@7 349 echo "Compilation failed. Please read the compilator output."
pankso@7 350 echo "" && exit 1
pankso@7 351 fi
pankso@7 352 else
pankso@7 353 echo "no compile_rules" >> $LOG
pankso@7 354 echo -e "No compile rules for $PACKAGE...\n"
pankso@7 355 fi
pankso@7 356 }
pankso@7 357
MikeDSmith25@82 358 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@22 359 # so some packages need to copy these files with the receipt and genpkg_rules.
pankso@22 360 # This function is executed by gen_package when 'tazwok genpkg'.
pankso@22 361 copy_generic_files()
pankso@22 362 {
MikeDSmith25@82 363 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
pankso@22 364 # using generic variables and $LOCALE from Tazwok config file.
pankso@22 365 if [ ! "$LOCALE" = "" ]; then
pankso@22 366 if [ -d "$_pkg/usr/share/locale" ]; then
pankso@22 367 for i in $LOCALE
pankso@22 368 do
pankso@37 369 if [ -d "$_pkg/usr/share/locale/$i" ]; then
pankso@37 370 mkdir -p $fs/usr/share/locale
pankso@37 371 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
pankso@37 372 fi
pankso@22 373 done
pankso@22 374 fi
pankso@22 375 fi
MikeDSmith25@82 376 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
MikeDSmith25@82 377 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
pankso@31 378 # in pkg receipt.
pankso@22 379 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
pankso@22 380 if [ -d "$_pkg/usr/share/pixmaps" ]; then
pankso@27 381 mkdir -p $fs/usr/share/pixmaps
pankso@31 382 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
pankso@31 383 $fs/usr/share/pixmaps 2>/dev/null
pankso@31 384 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
pankso@22 385 $fs/usr/share/pixmaps 2>/dev/null
pankso@23 386 fi
MikeDSmith25@82 387 # Custom or homemade PNG pixmap can be in stuff.
pankso@23 388 if [ -f "stuff/$PACKAGE.png" ]; then
pankso@27 389 mkdir -p $fs/usr/share/pixmaps
pankso@23 390 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@22 391 fi
pankso@22 392 fi
pankso@22 393 # Desktop entry (.desktop).
pankso@22 394 if [ -d "$_pkg/usr/share/applications" ]; then
pankso@22 395 cp -a $_pkg/usr/share/applications $fs/usr/share
pankso@23 396 fi
MikeDSmith25@82 397 # Homemade desktop file(s) can be in stuff.
pankso@34 398 if [ -d "stuff/applications" ]; then
pankso@42 399 mkdir -p $fs/usr/share
pankso@42 400 cp -a stuff/applications $fs/usr/share
pankso@34 401 fi
pankso@34 402 if [ -f "stuff/$PACKAGE.desktop" ]; then
pankso@42 403 mkdir -p $fs/usr/share/applications
pankso@42 404 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@22 405 fi
pankso@22 406 }
pankso@22 407
pankso@25 408 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
pankso@25 409 strip_package()
pankso@25 410 {
pankso@25 411 echo -n "Executing strip on all files..."
pankso@25 412 # Binaries.
pankso@25 413 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@25 414 do
pankso@25 415 if [ -d "$dir" ]; then
pankso@25 416 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
pankso@25 417 fi
pankso@25 418 done
pankso@25 419 # Libraries.
pankso@25 420 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
pankso@25 421 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
pankso@25 422 status
pankso@25 423 }
pankso@25 424
MikeDSmith25@82 425 # Create a package tree and build the gziped cpio archive
pankso@7 426 # to make a SliTaz (.tazpkg) package.
pankso@7 427 gen_package()
pankso@7 428 {
pankso@7 429 check_root
pankso@7 430 check_for_package_on_cmdline
pankso@7 431 check_for_receipt
pascal@74 432 EXTRAVERSION=""
pankso@7 433 . $RECEIPT
pascal@86 434 # May compute VERSION
pascal@86 435 if grep -q ^get_version $RECEIPT; then
pascal@86 436 get_version
pascal@86 437 fi
pankso@7 438 check_for_wanted
pankso@7 439 cd $WOK/$PACKAGE
pankso@7 440 # Remove old Tazwok package files.
pankso@7 441 if [ -d "taz" ]; then
pankso@7 442 rm -rf taz
pankso@7 443 fi
MikeDSmith25@82 444 # Create the package tree and set useful variables.
pankso@7 445 mkdir -p taz/$PACKAGE-$VERSION/fs
pankso@7 446 fs=taz/$PACKAGE-$VERSION/fs
MikeDSmith25@82 447 # Set $src for standard package and $_pkg variables.
pankso@7 448 if [ "$WANTED" = "" ]; then
pankso@7 449 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
pankso@7 450 _pkg=$src/_pkg
pankso@7 451 fi
pankso@7 452 if [ ! "$SOURCE" = "" ]; then
pankso@7 453 src=$WOK/$PACKAGE/$SOURCE-$VERSION
pankso@7 454 _pkg=$src/_pkg
pankso@7 455 fi
pankso@7 456 cd $WOK/$PACKAGE
pankso@22 457 # Execute genpkg_rules and copy generic files to build the package.
pankso@7 458 echo ""
pascal@87 459 echo "Building $PACKAGE with the receipt..."
pankso@7 460 echo "================================================================================"
pankso@28 461 if grep -q ^genpkg_rules $RECEIPT; then
pankso@7 462 # Log process.
pankso@7 463 echo "executing genpkg_rules" >> $LOG
pankso@7 464 genpkg_rules
pankso@25 465 cd $WOK/$PACKAGE
pankso@24 466 # Skip generic files for packages with a WANTED variable
pankso@24 467 # (dev and splited pkgs).
pankso@24 468 if [ ! "$WANTED" = "" ]; then
pankso@24 469 continue
pankso@24 470 else
pankso@24 471 copy_generic_files
pankso@24 472 fi
pankso@25 473 strip_package
pankso@7 474 else
pankso@7 475 echo "No package rules to gen $PACKAGE..."
pankso@22 476 exit 1
pankso@7 477 fi
MikeDSmith25@82 478 # Copy the receipt and description (if exists) in the binary package tree.
pankso@7 479 cd $WOK/$PACKAGE
pankso@7 480 echo -n "Copying the receipt..."
pankso@7 481 cp receipt taz/$PACKAGE-$VERSION
pankso@7 482 status
pascal@89 483 if grep -q ^get_version $RECEIPT; then
pascal@89 484 echo -n "Update version in receipt..."
pascal@89 485 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
pascal@89 486 taz/$PACKAGE-$VERSION/receipt
pascal@89 487 status
pascal@89 488 fi
pankso@7 489 if [ -f "description.txt" ]; then
pankso@7 490 echo -n "Copying the description file..."
pankso@7 491 cp description.txt taz/$PACKAGE-$VERSION
pankso@7 492 status
pankso@7 493 fi
MikeDSmith25@82 494 # Create the files.list by redirecting find output.
pankso@7 495 echo -n "Creating the list of files..."
pascal@15 496 cd taz/$PACKAGE-$VERSION
pascal@13 497 LAST_FILE=""
pascal@15 498 ( find fs -print; echo ) | while read file; do
pascal@13 499 if [ "$LAST_FILE" != "" ]; then
pascal@15 500 case "$file" in
pascal@13 501 $LAST_FILE/*)
pascal@15 502 case "$(ls -ld "$LAST_FILE")" in
pascal@15 503 drwxr-xr-x\ *\ root\ *\ root\ *);;
pascal@15 504 *) echo ${LAST_FILE#fs};;
pascal@13 505 esac;;
pascal@15 506 *) echo ${LAST_FILE#fs};;
pascal@13 507 esac
pascal@13 508 fi
pascal@15 509 LAST_FILE="$file"
pascal@15 510 done > files.list
pankso@7 511 status
pascal@84 512 if [ -z "$EXTRAVERSION" ]; then
pascal@84 513 case "$PACKAGE" in
pascal@84 514 linux*);;
pascal@85 515 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
pascal@84 516 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
pascal@84 517 esac
pascal@84 518 fi
pascal@87 519 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
pascal@70 520 echo -n "Creating md5sum of files..."
pascal@70 521 while read file; do
pascal@71 522 [ -L "fs$file" ] && continue
pascal@71 523 [ -f "fs$file" ] || continue
pascal@71 524 md5sum "fs$file" | sed 's/ fs/ /'
pascal@70 525 done < files.list > md5sum
pascal@97 526 #[ -s md5sum ] || rm -f md5sum
pascal@70 527 status
pascal@84 528 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
pascal@84 529 2> /dev/null | awk '{ sz=$1 } END { print sz }')
pankso@7 530 # Build cpio archives. Find, cpio and gzip the fs, finish by
pankso@7 531 # removing the fs tree.
pankso@7 532 echo -n "Compressing the fs... "
pankso@56 533 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
pascal@84 534 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list md5sum \
pascal@84 535 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
pascal@59 536 echo -n "Undating receipt sizes..."
pascal@59 537 sed -i s/^PACKED_SIZE.*$// receipt
pascal@59 538 sed -i s/^UNPACKED_SIZE.*$// receipt
pascal@59 539 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@86 540 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
pascal@59 541 status
pascal@72 542 if [ -n "$EXTRAVERSION" ]; then
pascal@72 543 echo -n "Undating receipt EXTRAVERSION..."
pascal@72 544 sed -i s/^EXTRAVERSION.*$// receipt
pascal@72 545 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
pascal@72 546 status
pascal@72 547 fi
pankso@7 548 echo -n "Creating full cpio archive... "
pascal@68 549 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
MikeDSmith25@82 550 # Restore package tree incase we want to browse it.
pankso@7 551 echo -n "Restoring original package tree... "
pascal@14 552 zcat fs.cpio.gz | cpio -id
pascal@14 553 rm fs.cpio.gz && cd ..
pankso@7 554 # Log process.
pascal@69 555 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
pankso@7 556 echo "================================================================================"
pascal@68 557 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
pascal@68 558 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
pankso@7 559 echo ""
pankso@7 560 }
pankso@7 561
pankso@28 562 # Optional text packages list for gen-list.
pankso@28 563 gen_textlist()
pankso@28 564 {
pascal@99 565 rm -f packages.desc packages.equiv
pankso@28 566 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
pankso@28 567 echo -n "Creating the text packages list... "
pankso@28 568 cat >> packages.txt << _EOT_
pankso@28 569 # SliTaz GNU/Linux - Packages list
pankso@28 570 #
pankso@28 571 # Packages : _packages_
pankso@28 572 # Date : $DATE
pankso@28 573 #
pankso@28 574 _EOT_
pankso@28 575 for pkg in $WOK/*
pankso@28 576 do
pascal@99 577 PROVIDE=""
pankso@58 578 PACKAGE=""
pascal@60 579 PACKED_SIZE=""
pascal@60 580 if [ -f $pkg/taz/*/receipt ]; then
pascal@62 581 . $pkg/taz/*/receipt
pascal@62 582 else
pascal@60 583 . $pkg/receipt
pascal@60 584 fi
pankso@28 585 cat >> packages.txt << _EOT_
pankso@28 586
pankso@28 587 $PACKAGE
pankso@28 588 $VERSION
pankso@28 589 $SHORT_DESC
pankso@28 590 _EOT_
pascal@60 591 if [ -n "$PACKED_SIZE" ]; then
pascal@60 592 cat >> packages.txt << _EOT_
pascal@64 593 $PACKED_SIZE ($UNPACKED_SIZE installed)
pascal@60 594 _EOT_
pascal@60 595 fi
MikeDSmith25@82 596 # packages.desc is used by Tazpkgbox <tree>.
pankso@58 597 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
pascal@99 598 # packages.equiv is used by tazpkg install to check depends
pascal@104 599 touch packages.equiv
pascal@99 600 for i in $PROVIDE; do
pascal@99 601 DEST=""
pascal@99 602 echo $i | grep -q : && DEST="${i#*:}:"
pascal@99 603 if grep -qs ^${i%:*}= packages.equiv; then
pascal@99 604 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" packages.equiv
pascal@99 605 else
pascal@99 606 echo "${i%:*}=$DEST$PACKAGE" >> packages.equiv
pascal@99 607 fi
pascal@99 608 done
pankso@28 609 packages=$(($packages+1))
pankso@28 610 done && status
pascal@61 611 echo -n "Creating the text files list... "
pascal@61 612 for pkg in $WOK/*
pascal@61 613 do
pascal@63 614 if [ -f $pkg/taz/*/files.list ]; then
pascal@61 615 . $pkg/taz/*/receipt
pascal@61 616 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
pascal@61 617 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
pascal@61 618 else
pascal@61 619 echo "No files_list in $pkg" 1>&2
pascal@61 620 fi
pascal@61 621 done | lzma e files.list.lzma -si && status
pankso@28 622 sed -i s/"_packages_"/"$packages"/ packages.txt
pankso@28 623 }
pankso@28 624
pascal@91 625 # Return the date of the last commit in seconds since Jan 1 1970
pascal@91 626 hgdate()
pascal@91 627 {
pascal@91 628 local pkg
pascal@91 629 local date
pascal@91 630 local mon
pascal@91 631 # Default date is Jan 1 1970
pascal@97 632 [ -d $WOK/.hg -a -x /usr/bin/hg ] || { echo "010100001970"; return; }
pascal@91 633 pkg=$(basename $1)
pascal@91 634 # Get date for last commit
pascal@91 635 date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
pascal@91 636 2> /dev/null) | grep date: | head -1 | cut -c 6-)"
pascal@97 637 [ -n "$date" ] || { echo "010100001970"; return; }
pascal@91 638 case "$(echo $date | awk '{ print $2 }')" in
pascal@91 639 Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
pascal@91 640 May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
pascal@91 641 Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
pascal@91 642 esac
pascal@91 643 # Reformat, don't mind about TZ: we look for days or months delta
pascal@91 644 echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
pascal@91 645 }
pascal@91 646
pankso@7 647 ###################
pankso@7 648 # Tazwok commands #
pankso@7 649 ###################
pankso@7 650
pankso@7 651 case "$COMMAND" in
pankso@7 652 stats)
pankso@7 653 # Tazwok general statistics from the config file the wok.
pankso@7 654 #
pankso@7 655 echo ""
pankso@7 656 echo -e "\033[1mTazwok configuration statistics\033[0m
pankso@7 657 ================================================================================
pankso@7 658 Wok directory : $WOK
pankso@7 659 Packages repository : $PACKAGES_REPOSITORY
pankso@7 660 Sources repository : $SOURCES_REPOSITORY
pankso@7 661 Packages in the wok : `ls -1 $WOK | wc -l`
pankso@16 662 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
pankso@7 663 ================================================================================"
pankso@7 664 echo ""
pankso@7 665 ;;
pascal@98 666 build-depends)
pascal@98 667 # List dependancies to rebuild wok
pascal@98 668 cd $WOK
pascal@98 669 ALL_DEPS="slitaz-toolchain"
pascal@98 670 echo $ALL_DEPS
pascal@98 671 for pkg in $(ls $2)
pascal@98 672 do
pascal@98 673 [ -f $pkg/receipt ] || continue
pascal@98 674 BUILD_DEPENDS=""
pascal@98 675 . $pkg/receipt
pascal@98 676 for i in $BUILD_DEPENDS; do
pascal@98 677 case " $ALL_DEPS " in
pascal@98 678 *\ $i\ *);;
pascal@98 679 *) ALL_DEPS="$ALL_DEPS $i"
pascal@98 680 echo $i;;
pascal@98 681 esac
pascal@98 682 done
pascal@98 683 done
pascal@98 684 ;;
pascal@76 685 check)
pascal@76 686 # Check wok consistancy
pascal@76 687 echo ""
pascal@76 688 echo -e "\033[1mWok and packages checking\033[0m
pascal@76 689 ================================================================================"
pascal@77 690 cd $WOK
pascal@77 691 for pkg in $(ls)
pascal@76 692 do
pascal@76 693 [ -f $pkg/receipt ] || continue
pascal@76 694 PACKAGE=""
pascal@76 695 VERSION=""
pascal@76 696 CATEGORY=""
pascal@76 697 SHORT_DESC=""
pascal@76 698 MAINTAINER=""
pascal@76 699 WEB_SITE=""
pascal@79 700 DEPENDS=""
pascal@93 701 BUILD_DEPENDS=""
pascal@97 702 WANTED=""
pascal@76 703 . $pkg/receipt
pascal@76 704 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
pascal@76 705 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
pascal@97 706 if [ -n "$WANTED" ]; then
pascal@97 707 if [ ! -f $WANTED/receipt ]; then
pascal@97 708 echo "Package $PACKAGE want unknown $WANTED package"
pascal@97 709 else
pascal@97 710 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
pascal@103 711 if [ "$VERSION" = "$WANTED" ]; then
pascal@103 712 # BASEVERSION is computed in receipt
pascal@103 713 grep -q '_pkg=' $pkg/receipt &&
pascal@103 714 BASEVERSION=$VERSION
pascal@103 715 fi
pascal@97 716 if [ "$VERSION" != "$BASEVERSION" ]; then
pascal@97 717 echo "Package $PACKAGE ($VERSION) want $WANTED ($BASEVERSION)"
pascal@97 718 fi
pascal@97 719 fi
pascal@97 720 fi
pascal@97 721
pascal@94 722 if [ -n "$CATEGORY" ]; then
pascal@94 723 case " $(echo $CATEGORIES) " in
pascal@94 724 *\ $CATEGORY\ *);;
taziden@105 725 *) echo "Package $PACKAGE has an invalid CATEGORY";;
pascal@94 726 esac
pascal@94 727 else
pascal@94 728 echo"Package $PACKAGE has no CATEGORY"
pascal@94 729 fi
pascal@76 730 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
pascal@76 731 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
pascal@76 732 [ -n "$WEB_SITE" ] || echo "Package $PACKAGE has no WEB_SITE"
pascal@78 733 case "$MAINTAINER" in
pascal@78 734 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
pascal@78 735 esac
pascal@78 736 case "$MAINTAINER" in
pascal@78 737 *@*);;
pascal@78 738 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
pascal@78 739 esac
pascal@76 740 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
pascal@76 741 for i in $DEPENDS; do
pascal@76 742 [ -d $i ] && continue
pascal@76 743 echo -e "$MSG $i"
pascal@76 744 MSG=""
pascal@76 745 done
pascal@92 746 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
pascal@92 747 for i in $BUILD_DEPENDS; do
pascal@92 748 [ -d $i ] && continue
pascal@92 749 echo -e "$MSG $i"
pascal@92 750 MSG=""
pascal@92 751 done
pascal@76 752 MSG="Dependencies loop between $PACKAGE and :\n"
pascal@76 753 ALL_DEPS=""
pascal@76 754 check_for_deps_loop $PACKAGE $DEPENDS
pascal@76 755 done
pascal@76 756 ;;
pankso@66 757 cmp|compare)
MikeDSmith25@82 758 # Compare the wok and packages repository to help with maintaining
pankso@66 759 # a mirror.
pankso@65 760 echo ""
MikeDSmith25@82 761 echo -e "\033[1mWok and packages comparison\033[0m
pankso@65 762 ================================================================================"
pankso@65 763 for pkg in $WOK/*
pankso@65 764 do
pascal@98 765 WANTED=""
pankso@65 766 . $pkg/receipt
pascal@95 767 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
pascal@102 768 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
pascal@91 769 if [ -z "$tpkg" ]; then
pascal@74 770 echo "Missing package: $PACKAGE ($VERSION)"
pascal@95 771 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
pascal@91 772 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
pascal@91 773 echo "Obsolete package: $PACKAGE ($VERSION)"
pascal@95 774 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
pascal@97 775 elif [ $pkg/receipt -nt $tpkg ]; then
pascal@97 776 echo "Refresh package: $PACKAGE ($VERSION)"
pascal@97 777 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
pascal@91 778 else
pascal@91 779 srcdate=$(hgdate $pkg)
pascal@91 780 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
pascal@91 781 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
pascal@91 782 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
pascal@95 783 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
pascal@95 784 else
pascal@95 785 continue
pascal@91 786 fi
pankso@65 787 fi
pascal@95 788 if [ "$2" = "--cook" ]; then
pascal@98 789 if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
pascal@98 790 yes '' | tazwok cook $WANTED
pascal@98 791 fi
pascal@96 792 yes '' | tazwok cook $PACKAGE
pascal@95 793 fi
pankso@65 794 done
pankso@66 795 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
pankso@66 796 do
pascal@95 797 # grep $pkg in /tmp/wok.list.$$
pascal@90 798 # may include EXTRAVERSION or computed VERSION
pascal@95 799 for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
pascal@74 800 case "$pkg" in
pascal@75 801 ${i%.tazpkg}*.tazpkg) continue 2;;
pascal@74 802 esac
pascal@74 803 done
MikeDSmith25@82 804 # Not found
pascal@95 805 echo $pkg >> /tmp/pkgs.old.$$
pascal@74 806 if [ "$2" = "--remove" ]; then
pascal@74 807 echo "Removing package: $pkg"
pascal@74 808 rm $PACKAGES_REPOSITORY/$pkg
pascal@74 809 else
pascal@74 810 echo "Old package: $pkg"
pascal@74 811 fi
pankso@66 812 done
pankso@66 813 cd /tmp
pankso@65 814 echo "================================================================================"
pascal@95 815 echo "Wok: `cat wok.list.$$ | wc -l` - \
pankso@66 816 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
pascal@95 817 Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
pascal@95 818 Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
pankso@65 819 echo ""
pascal@95 820 rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
pankso@65 821 ;;
pankso@7 822 list)
pankso@7 823 # List packages in wok directory. User can specifiy a category
pankso@7 824 #
pankso@7 825 if [ "$2" = "category" ]; then
pankso@7 826 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
pankso@7 827 exit 0
pankso@7 828 fi
pankso@7 829 # Check for an asked category.
pankso@7 830 if [ -n "$2" ]; then
pankso@7 831 ASKED_CATEGORY=$2
pankso@7 832 echo ""
pankso@7 833 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
pankso@7 834 echo "================================================================================"
pankso@7 835 for pkg in $WOK/*
pankso@7 836 do
pankso@7 837 . $pkg/receipt
pankso@7 838 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@7 839 echo -n "$PACKAGE"
pankso@28 840 echo -e "\033[28G $VERSION"
pankso@7 841 packages=$(($packages+1))
pankso@7 842 fi
pankso@7 843 done
pankso@7 844 echo "================================================================================"
pankso@7 845 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
pankso@7 846 else
pankso@7 847 # By default list all packages and version.
pankso@7 848 echo ""
pankso@7 849 echo -e "\033[1mList of packages in the wok\033[0m"
pankso@7 850 echo "================================================================================"
pankso@7 851 for pkg in $WOK/*
pankso@7 852 do
pankso@7 853 . $pkg/receipt
pankso@7 854 echo -n "$PACKAGE"
pankso@28 855 echo -en "\033[28G $VERSION"
pankso@7 856 echo -e "\033[42G $CATEGORY"
pankso@7 857 packages=$(($packages+1))
pankso@7 858 done
pankso@7 859 echo "================================================================================"
MikeDSmith25@82 860 echo -e "$packages packages available in the wok.\n"
pankso@7 861 fi
pankso@7 862 ;;
pankso@7 863 info)
MikeDSmith25@82 864 # Information about a package.
pankso@7 865 #
pankso@7 866 check_for_package_on_cmdline
pankso@7 867 check_for_receipt
pankso@7 868 . $WOK/$PACKAGE/receipt
pankso@7 869 echo ""
MikeDSmith25@82 870 echo -e "\033[1mTazwok package information\033[0m
pankso@7 871 ================================================================================
pankso@7 872 Package : $PACKAGE
pankso@7 873 Version : $VERSION
pankso@7 874 Category : $CATEGORY
pankso@7 875 Short desc : $SHORT_DESC
pankso@7 876 Maintainer : $MAINTAINER"
pankso@7 877 if [ ! "$WEB_SITE" = "" ]; then
pankso@7 878 echo "Web site : $WEB_SITE"
pankso@7 879 fi
pankso@7 880 if [ ! "$DEPENDS" = "" ]; then
pankso@7 881 echo "Depends : $DEPENDS"
pankso@7 882 fi
pankso@7 883 if [ ! "$WANTED" = "" ]; then
pankso@7 884 echo "Wanted src : $WANTED"
pankso@7 885 fi
pankso@7 886 echo "================================================================================"
pankso@7 887 echo ""
pankso@7 888
pankso@7 889 ;;
pankso@7 890 check-log)
pankso@7 891 # We just cat the file log to view process info.
pankso@7 892 #
pankso@7 893 if [ ! -f "$LOG" ]; then
MikeDSmith25@82 894 echo -e "\nNo process log found. The package is probably not cooked.\n"
pankso@7 895 exit 0
pankso@7 896 else
pankso@7 897 echo ""
pankso@7 898 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
pankso@7 899 echo "================================================================================"
pankso@7 900 cat $LOG
pankso@7 901 echo "================================================================================"
pankso@7 902 echo ""
pankso@7 903 fi
pankso@7 904 ;;
pankso@7 905 search)
pankso@7 906 # Search for a package by pattern or name.
pankso@7 907 #
pankso@7 908 if [ -z "$2" ]; then
pankso@7 909 echo -e "\nPlease specify a pattern or a package name to search."
pankso@7 910 echo -e "Example : 'tazwok search gcc'.\n"
pankso@7 911 exit 0
pankso@7 912 fi
pankso@7 913 echo ""
pankso@7 914 echo -e "\033[1mSearch result for :\033[0m $2"
pankso@7 915 echo "================================================================================"
pankso@7 916 list=`ls -1 $WOK | grep $2`
pankso@7 917 for pkg in $list
pankso@7 918 do
pankso@7 919 . $WOK/$pkg/receipt
pankso@7 920 echo -n "$PACKAGE "
pankso@7 921 echo -en "\033[24G $VERSION"
pankso@7 922 echo -e "\033[42G $CATEGORY"
pankso@7 923 packages=$(($packages+1))
pankso@7 924 done
pankso@7 925 echo "================================================================================"
pankso@7 926 echo "$packages packages found for : $2"
pankso@7 927 echo ""
pankso@7 928 ;;
pankso@7 929 compile)
pankso@7 930 # Configure and make a package with the receipt.
pankso@7 931 #
pankso@7 932 compile_package
pankso@7 933 ;;
pankso@7 934 genpkg)
pankso@7 935 # Generate a package
pankso@7 936 #
pankso@7 937 gen_package
pankso@7 938 ;;
pankso@7 939 cook)
pankso@7 940 # Compile and generate a package. Just execute tazwok with
pankso@7 941 # the good commands.
pankso@7 942 #
pankso@7 943 check_root
pankso@7 944 compile_package
pankso@7 945 gen_package
pankso@7 946 ;;
pankso@7 947 cook-list)
pankso@7 948 # Cook all packages listed in a file. The path to the cooklist must
pankso@7 949 # be specified on the cmdline.
pankso@7 950 #
pankso@7 951 check_root
pankso@7 952 check_for_list
pankso@7 953 for pkg in $LIST
pankso@7 954 do
pankso@7 955 tazwok compile $pkg
pankso@7 956 tazwok genpkg $pkg
pankso@7 957 done
pankso@7 958 ;;
pankso@7 959 clean)
pankso@7 960 # Clean up a package work directory.
pankso@7 961 #
pankso@7 962 check_for_package_on_cmdline
pankso@7 963 check_for_receipt
pankso@7 964 . $RECEIPT
pankso@7 965 cd $WOK/$PACKAGE
pankso@7 966 echo ""
pankso@7 967 echo "Cleaning $PACKAGE..."
pankso@7 968 echo "================================================================================"
pankso@28 969 # Check for clean_wok function.
pankso@28 970 if grep -q ^clean_wok $RECEIPT; then
pankso@28 971 clean_wok
pankso@28 972 fi
MikeDSmith25@82 973 # Remove taz/ and source tree if exists.
pankso@7 974 if [ -d "taz" ]; then
pankso@7 975 echo -n "Removing taz files..."
pascal@95 976 rm -rf taz
pascal@95 977 status
pankso@7 978 fi
pascal@95 979 for i in $PACKAGE-$VERSION $SOURCE-$VERSION ; do
pascal@95 980 [ -e "$i" ] || continue
pankso@7 981 echo -n "Removing source files..."
pascal@95 982 if [ -L $i ]; then
pascal@95 983 target=$(readlink $i)
pascal@95 984 [ -d "$target" ] && case "$target" in
pascal@95 985 /*|.|./*|..|../*);;
pascal@95 986 *) rm -rf $target;;
pascal@95 987 esac
pascal@95 988 fi
pascal@95 989 rm -rf $i
pascal@95 990 status
pascal@95 991 done
pankso@7 992 # Remove an envental $PACKAGE-build directory.
pankso@7 993 if [ -d "$PACKAGE-build" ]; then
pankso@7 994 echo -n "Removing build tree..."
pankso@7 995 rm -rf $PACKAGE-build && status
pankso@7 996 fi
pankso@7 997 # Remove process log file.
pankso@7 998 if [ -f "process.log" ]; then
pankso@7 999 echo -n "Removing process log file..."
pankso@7 1000 rm process.log && status
pankso@28 1001 echo "================================================================================"
pankso@7 1002 fi
pankso@7 1003 echo "$PACKAGE is clean. You can cook it again..."
pankso@7 1004 echo ""
pankso@7 1005 ;;
pankso@7 1006 gen-clean-wok)
pankso@7 1007 # Generate a clean wok from the current wok by copying all receipt
pankso@7 1008 # and stuff directory.
pankso@7 1009 #
pankso@7 1010 if [ -z "$2" ]; then
pankso@7 1011 echo -e "\nPlease specify the destination for the new clean wok.\n"
pankso@7 1012 exit 0
pankso@7 1013 else
pankso@7 1014 dest=$2
pankso@7 1015 mkdir -p $dest
pankso@7 1016 fi
pankso@7 1017 echo "New wok is going to : $dest"
pankso@7 1018 for pkg in `ls -1 $WOK`
pankso@7 1019 do
pankso@7 1020 echo "----"
pankso@7 1021 echo -n "Preparing $pkg..."
pankso@7 1022 mkdir -p $dest/$pkg
pankso@7 1023 status
pankso@7 1024 echo -n "Copying the receipt..."
pankso@7 1025 cp -a $WOK/$pkg/receipt $dest/$pkg
pankso@7 1026 status
pankso@7 1027 if [ -d "$WOK/$pkg/stuff" ]; then
pankso@7 1028 echo -n "Copying all the stuff directory..."
pankso@7 1029 cp -a $WOK/$pkg/stuff $dest/$pkg
pankso@7 1030 status
pankso@7 1031 fi
pankso@7 1032 done
pankso@7 1033 echo "================================================================================"
pankso@7 1034 echo "Clean wok generated in : $dest"
pankso@7 1035 echo "Packages cleaned : `ls -1 $dest | wc -l`"
pankso@7 1036 echo ""
pankso@7 1037 ;;
pankso@7 1038 clean-wok)
pankso@7 1039 # Clean all packages in the work directory
pankso@7 1040 #
pankso@7 1041 for pkg in `ls -1 $WOK`
pankso@7 1042 do
pankso@7 1043 tazwok clean $pkg
pankso@7 1044 done
pankso@7 1045 echo "================================================================================"
pankso@7 1046 echo "`ls -1 $WOK | wc -l` packages cleaned."
pankso@7 1047 echo ""
pankso@7 1048 ;;
pankso@7 1049 gen-list)
pankso@7 1050 # Sed is used to remove all the .tazpkg extensions from the
pankso@7 1051 # packages.list. The directory to move in by default is the repository
pankso@28 1052 # if $2 is not empty cd into $2. A text packages list can also be gen
pankso@28 1053 # with the option --text.
pankso@7 1054 #
pascal@104 1055 fakewok="no"
pankso@28 1056 if [ "$2" == "--text" ]; then
pankso@28 1057 textlist="yes"
pascal@104 1058 if [ "$3" == "--fakewok" ]; then
pascal@104 1059 fakewok="yes"
pascal@104 1060 WOK=/tmp/fakewok-$$
pascal@104 1061 mkdir -p $WOK
pascal@104 1062 PACKAGES_REPOSITORY=$(pwd)
pascal@104 1063 for i in *.tazpkg; do
pascal@104 1064 (cd $WOK; cpio -i receipt files.list) < $i
pascal@104 1065 . $WOK/receipt
pascal@104 1066 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
pascal@104 1067 mv $WOK/receipt $WOK/files.list \
pascal@104 1068 $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
pascal@104 1069 ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
pascal@104 1070 done
pascal@104 1071 fi
pankso@28 1072 elif [ -z "$2" ]; then
pankso@7 1073 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
pankso@7 1074 else
pankso@7 1075 if [ -d "$2" ]; then
pankso@7 1076 PACKAGES_REPOSITORY=$2
pankso@7 1077 else
pankso@7 1078 echo -e "\nUnable to find directory : $2\n"
pankso@7 1079 exit 0
pankso@7 1080 fi
pankso@7 1081 fi
pankso@7 1082 cd $PACKAGES_REPOSITORY
MikeDSmith25@82 1083 # Remove old packages.list and md5sum, they will soon be rebuilt.
pankso@28 1084 rm -f packages.list packages.md5 packages.txt
pankso@7 1085 echo ""
pankso@28 1086 echo -e "\033[1mGenerating packages lists\033[0m"
pankso@28 1087 echo "================================================================================"
pankso@28 1088 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
MikeDSmith25@82 1089 # Generate packages.txt
pankso@28 1090 if [ "$textlist" == "yes" ]; then
pankso@28 1091 gen_textlist
pascal@104 1092 [ "$fakewok" == "yes" ] && rm -rf $WOK
pankso@28 1093 fi
pankso@28 1094 echo -n "Creating the raw packages list... "
pankso@17 1095 ls -1 *.tazpkg > /tmp/packages.list
pankso@7 1096 sed -i s/'.tazpkg'/''/ /tmp/packages.list
pankso@7 1097 status
pankso@7 1098 echo -n "Building the md5sum for all packages... "
pankso@7 1099 md5sum * > packages.md5
pankso@7 1100 status
pankso@7 1101 mv /tmp/packages.list $PACKAGES_REPOSITORY
pankso@7 1102 echo "================================================================================"
pankso@7 1103 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
pankso@7 1104 echo "$pkgs packages in the repository."
pankso@7 1105 echo ""
pankso@7 1106 ;;
pankso@7 1107 new-tree)
MikeDSmith25@82 1108 # Just create a few directories and generate an empty receipt to prepare
pankso@7 1109 # the creation of a new package.
pankso@7 1110 #
pankso@7 1111 check_for_package_on_cmdline
pankso@7 1112 if [ -d $WOK/$PACKAGE ]; then
MikeDSmith25@82 1113 echo -e "\n$PACKAGE package tree already exists.\n"
pankso@7 1114 exit 0
pankso@7 1115 fi
pankso@7 1116 echo "Creating : $WOK/$PACKAGE"
pankso@7 1117 mkdir $WOK/$PACKAGE
pankso@7 1118 cd $WOK/$PACKAGE
pankso@7 1119 echo -n "Preparing the receipt..."
pankso@7 1120 #
pankso@7 1121 # Default receipt begin.
pankso@7 1122 #
pankso@7 1123 echo "# SliTaz package receipt." > receipt
pankso@7 1124 echo "" >> receipt
pankso@7 1125 echo "PACKAGE=\"$PACKAGE\"" >> receipt
pankso@7 1126 # Finish the empty receipt.
pankso@7 1127 cat >> receipt << "EOF"
pankso@7 1128 VERSION=""
pankso@7 1129 CATEGORY=""
pankso@7 1130 SHORT_DESC=""
pankso@7 1131 MAINTAINER=""
pankso@7 1132 DEPENDS=""
pankso@7 1133 TARBALL="$PACKAGE-$VERSION.tar.gz"
pankso@7 1134 WEB_SITE=""
pankso@7 1135 WGET_URL=""
pankso@7 1136
pankso@7 1137 # Rules to configure and make the package.
pankso@7 1138 compile_rules()
pankso@7 1139 {
pankso@7 1140 cd $src
pankso@7 1141 ./configure --prefix=/usr --infodir=/usr/share/info \
pascal@87 1142 --mandir=/usr/share/man $CONFIGURE_ARGS && \
pascal@87 1143 make && make DESTDIR=$PWD/_pkg install
pankso@7 1144 }
pankso@7 1145
pankso@7 1146 # Rules to gen a SliTaz package suitable for Tazpkg.
pankso@7 1147 genpkg_rules()
pankso@7 1148 {
pankso@7 1149 mkdir -p $fs/usr
pankso@7 1150 cp -a $_pkg/usr/bin $fs/usr
pankso@7 1151 }
pankso@7 1152
pankso@7 1153 EOF
pankso@7 1154 #
pankso@7 1155 # Default receipt end.
pankso@7 1156 #
pankso@7 1157 status
pankso@7 1158 # Interactive mode, asking and seding.
pankso@7 1159 if [ "$3" = "--interactive" ]; then
pankso@7 1160 echo "Entering in interactive mode..."
pankso@7 1161 echo "================================================================================"
pankso@7 1162 echo "Package : $PACKAGE"
pankso@7 1163 # Version.
pankso@7 1164 echo -n "Version : " ; read anser
pankso@7 1165 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
pankso@7 1166 # Category.
pankso@7 1167 echo -n "Category : " ; read anser
pankso@7 1168 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
pankso@7 1169 # Short description.
pankso@7 1170 echo -n "Short desc : " ; read anser
pankso@7 1171 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
pankso@7 1172 # Maintainer.
pankso@7 1173 echo -n "Maintainer : " ; read anser
pankso@7 1174 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
pankso@7 1175 # Web site.
pankso@7 1176 echo -n "Web site : " ; read anser
pankso@7 1177 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
pankso@7 1178 echo ""
pankso@7 1179 # Wget URL.
pankso@7 1180 echo "Wget URL to download source tarball."
pankso@7 1181 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
pankso@7 1182 echo -n "Wget url : " ; read anser
pankso@7 1183 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
pankso@7 1184 # Ask for a stuff dir.
pankso@7 1185 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
pankso@7 1186 if [ "$anser" = "y" ]; then
pankso@7 1187 echo -n "Creating the stuff directory..."
pankso@7 1188 mkdir stuff && status
pankso@7 1189 fi
pankso@7 1190 # Ask for a description file.
pankso@7 1191 echo -n "Are you going to write a description ? (y/N) : " ; read anser
pankso@7 1192 if [ "$anser" = "y" ]; then
pankso@7 1193 echo -n "Creating the description.txt file..."
pankso@7 1194 echo "" > description.txt && status
pankso@7 1195 fi
pankso@7 1196 echo "================================================================================"
pankso@7 1197 echo ""
pankso@7 1198 fi
pankso@7 1199 ;;
pankso@7 1200 remove)
pankso@7 1201 # Remove a package from the wok.
pankso@7 1202 #
pankso@7 1203 check_for_package_on_cmdline
pankso@7 1204 echo ""
pascal@83 1205 echo -n "Please confirm deletion (y/N) : "; read anser
pascal@83 1206 if [ "$anser" = "y" ]; then
pascal@83 1207 echo -n "Removing $PACKAGE..."
pascal@83 1208 rm -rf $WOK/$PACKAGE && status
pascal@83 1209 echo ""
pascal@83 1210 fi
pankso@7 1211 ;;
pankso@106 1212 hgup)
pankso@106 1213 # Pull and update an Hg wok.
pankso@106 1214 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
pankso@106 1215 check_root
pankso@106 1216 fi
pankso@106 1217 cd $WOK
pankso@106 1218 hg pull && hg update ;;
pankso@108 1219 maintainers)
pankso@108 1220 echo ""
pankso@108 1221 echo "List of maintainers for: $WOK"
pankso@108 1222 echo "================================================================================"
pankso@108 1223 touch /tmp/slitaz-maintainers
pankso@108 1224 for pkg in $WOK/*
pankso@108 1225 do
pankso@108 1226 . $pkg/receipt
pankso@108 1227 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
pankso@108 1228 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
pankso@108 1229 echo "$MAINTAINER"
pankso@108 1230 fi
pankso@108 1231 done
pankso@108 1232 echo "================================================================================"
pankso@108 1233 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
pankso@108 1234 echo ""
pankso@108 1235 # Remove tmp files
pankso@108 1236 rm -f /tmp/slitaz-maintainers ;;
pankso@107 1237 maintained-by)
pankso@107 1238 # Search for packages maintained by a packagers.
pankso@107 1239 if [ ! -n "$2" ]; then
pankso@107 1240 echo "Specify a name or mail of a maintainer."
pankso@107 1241 exit 0
pankso@107 1242 fi
pankso@107 1243 echo "Maintainer packages"
pankso@107 1244 echo "================================================================================"
pankso@107 1245 for pkg in $WOK/*
pankso@107 1246 do
pankso@107 1247 . $pkg/receipt
pankso@107 1248 if echo "$MAINTAINER" | grep -q "$2"; then
pankso@107 1249 echo "$PACKAGE"
pankso@107 1250 packages=$(($packages+1))
pankso@107 1251 fi
pankso@107 1252 done
pankso@107 1253 echo "================================================================================"
pankso@107 1254 echo "Packages maintained by $1: $packages"
pankso@107 1255 echo "" ;;
pankso@7 1256 usage|*)
MikeDSmith25@82 1257 # Print usage also for all unknown commands.
pankso@7 1258 #
pankso@7 1259 usage
pankso@7 1260 ;;
pankso@7 1261 esac
pankso@7 1262
pankso@7 1263 exit 0