tazwok annotate tazwok @ rev 98

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