tazwok annotate tazwok @ rev 235

Add functionnality: webserver
author Antoine Bodin <gokhlayeh@slitaz.org>
date Thu Feb 10 15:36:26 2011 +0100 (2011-02-10)
parents a618127f3ce2
children ff1479df1f17
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 #
pankso@7 11
gokhlayeh@186 12 VERSION=3.9.0
gokhlayeh@186 13 . /usr/lib/slitaz/libtaz
gokhlayeh@186 14 source_lib commons
pankso@7 15
gokhlayeh@186 16 # Use text instead of numbers, don't get $2 here if it's an option.
gokhlayeh@186 17 [ "$2" = "${2#--}" ] && PACKAGE=$2 && LIST=$2 && ARG=$2
gokhlayeh@186 18 COMMAND=$1
pankso@7 19
gokhlayeh@186 20 ########################################################################
gokhlayeh@186 21 # TAZWOK USAGE
gokhlayeh@186 22 ########################
gokhlayeh@186 23 # Print the usage (English).
pankso@7 24
pankso@7 25 usage ()
pankso@7 26 {
pankso@7 27 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
pankso@107 28 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
pankso@7 29 \033[1mCommands: \033[0m\n
pankso@7 30 usage Print this short usage.
pankso@7 31 stats Print Tazwok statistics from the config file and the wok.
pankso@133 32 edit Edit a package receipt in the current wok.
paul@121 33 build-depends Generate a list of packages to build a wok.
gokhlayeh@186 34 cmp|compare* Compare the wok and the cooked pkgs (--remove old pkgs).
pankso@7 35 list List all packages in the wok tree or by category.
MikeDSmith25@82 36 info Get information about a package in the wok.
pascal@92 37 check Check every receipt for common errors.
pankso@7 38 check-log Check the process log file of a package.
gokhlayeh@186 39 check-depends* Check every receipt for DEPENDS - doesn't scan ELF files.
erjo@159 40 check-src Check upstream tarball for package in the wok.
pankso@7 41 search Search for a package in the wok by pattern or name.
MikeDSmith25@82 42 compile Configure and build a package using the receipt rules.
pankso@7 43 genpkg Generate a suitable package for Tazpkg with the rules.
pankso@7 44 cook Compile and generate a package directly.
pankso@7 45 cook-list Cook all packages specified in the list by order.
gokhlayeh@186 46 cook-commit Cook all modified receipts.
gokhlayeh@186 47 cook-all Cook all packages excepted toolchain.
gokhlayeh@186 48 cook-toolchain Cook the toolchain packages.
gokhlayeh@186 49 gen-cooklist Generate a sorted cooklist using packages or list (--list) in argument.
gokhlayeh@186 50 sort-cooklist Sort the cooklist given in argument.
gokhlayeh@186 51 get-src Download the tarball of the package given in argument.
pankso@7 52 clean Clean all generated files in the package tree.
pankso@7 53 new-tree Prepare a new package tree and receipt (--interactive).
gokhlayeh@186 54 gen-list (Re-)Generate a packages list for a repository.
gokhlayeh@186 55 gen-wok-db (Re-)Generate wok lists with depends and wanted datas.
pankso@7 56 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
gokhlayeh@186 57 clean-wok Clean entirely the wok.
pankso@107 58 remove Remove a package from the wok.
pankso@108 59 hgup Pull and update a wok under Hg.
pankso@108 60 maintainers List all maintainers in the wok.
gokhlayeh@186 61 maintained-by List packages maintained by a contributor.\n
gokhlayeh@186 62
gokhlayeh@186 63 You can use `basename $0` command --help to list avaible options.
gokhlayeh@186 64 \033[1mImportant - *: \033[0m Commands which need a rewrite."
pankso@7 65 }
pankso@7 66
gokhlayeh@186 67 # This function display an error message without returning any error code.
gokhlayeh@186 68 # It also log the message in source package's warnings.txt; this file can be
gokhlayeh@186 69 # used on an eventual package page on website to display cooking warnings.
gokhlayeh@186 70 tazwok_warning()
pankso@7 71 {
gokhlayeh@186 72 echo -e "tazwok: $1" >&2
gokhlayeh@186 73 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
gokhlayeh@186 74 return
pankso@7 75 }
pankso@7 76
gokhlayeh@186 77 ########################################################################
gokhlayeh@186 78 # TAZWOK VARIABLES & INITIAL CONFIGURATION
gokhlayeh@186 79 ########################
gokhlayeh@186 80
gokhlayeh@186 81 get_tazwok_config()
pankso@7 82 {
gokhlayeh@186 83 # Get configuration file.
gokhlayeh@186 84 get_config
gokhlayeh@186 85
gokhlayeh@186 86 # Define & get options.
gokhlayeh@186 87 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
gokhlayeh@186 88 get_options
gokhlayeh@186 89
gokhlayeh@186 90 if [ "$undigest" ]; then
gokhlayeh@186 91 LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
gokhlayeh@186 92 else
gokhlayeh@186 93 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
pankso@7 94 fi
gokhlayeh@235 95
gokhlayeh@235 96 if ! [ "$save_dir" ]; then
gokhlayeh@235 97 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
gokhlayeh@235 98 save_dir=$LOCAL_REPOSITORY
gokhlayeh@235 99 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
gokhlayeh@235 100 cd $save_dir
gokhlayeh@235 101 get_tazwok_config
gokhlayeh@235 102 unset save_dir
gokhlayeh@235 103 return
gokhlayeh@235 104 fi
gokhlayeh@235 105 fi
gokhlayeh@235 106
gokhlayeh@186 107 # The path to the most important files/dir used by Tazwok.
gokhlayeh@186 108 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
gokhlayeh@186 109 WOK=$LOCAL_REPOSITORY/wok
gokhlayeh@186 110 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
gokhlayeh@186 111 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
gokhlayeh@186 112 set_common_path
gokhlayeh@186 113
gokhlayeh@186 114 # /!\ This part needs some changes.
gokhlayeh@186 115 # Basically, get theses files from the net if they are missing.
gokhlayeh@186 116 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
gokhlayeh@186 117 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
gokhlayeh@215 118 [ -f $dep_db ] || touch $dep_db
gokhlayeh@215 119 [ -f $wan_db ] || touch $wan_db
gokhlayeh@215 120 [ -f $PACKAGES_REPOSITORY/cookorder.txt ] || touch $PACKAGES_REPOSITORY/cookorder.txt
gokhlayeh@186 121
gokhlayeh@186 122 # Check commons directories, create them if user is root.
gokhlayeh@186 123 if test $(id -u) = 0 ; then
gokhlayeh@186 124 check_dir $WOK || chmod 777 $WOK
gokhlayeh@186 125 check_dir $PACKAGES_REPOSITORY
gokhlayeh@186 126 check_dir $SOURCES_REPOSITORY
gokhlayeh@186 127 check_dir $INCOMING_REPOSITORY
gokhlayeh@186 128 check_dir $LOCAL_REPOSITORY/log
gokhlayeh@186 129 fi
gokhlayeh@235 130
gokhlayeh@186 131 # Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
gokhlayeh@186 132 # them if they are missing.
gokhlayeh@204 133 for file in broken blocked commit incoming cooklist; do
gokhlayeh@186 134 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
gokhlayeh@186 135 done
gokhlayeh@186 136
gokhlayeh@186 137 # Limit memory usage.
gokhlayeh@186 138 ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
pankso@7 139 }
pankso@7 140
gokhlayeh@186 141 # Used in several functions.
gokhlayeh@186 142 set_common_path()
gokhlayeh@186 143 {
gokhlayeh@186 144 # The receipt is used to compile the source code and
gokhlayeh@186 145 # generate suitable packages for Tazpkg.
gokhlayeh@186 146 RECEIPT="$WOK/$PACKAGE/receipt"
gokhlayeh@186 147
gokhlayeh@186 148 # The path to the process log file.
gokhlayeh@186 149 LOG="$WOK/$PACKAGE/process.log"
gokhlayeh@186 150 }
gokhlayeh@186 151
gokhlayeh@186 152 ########################################################################
gokhlayeh@186 153 # TAZWOK CHECK FUNCTIONS
gokhlayeh@186 154 ########################
gokhlayeh@186 155
pankso@7 156 # Check for a package name on cmdline.
pankso@7 157 check_for_package_on_cmdline()
pankso@7 158 {
gokhlayeh@186 159 if [ ! "$PACKAGE" ]; then
gokhlayeh@186 160 echo -e "\nYou must specify a package name on the command line." >&2
gokhlayeh@186 161 echo -e "Example : tazwok $COMMAND package\n" >&2
gokhlayeh@186 162 exit 1
pankso@7 163 fi
pankso@7 164 }
pankso@7 165
pankso@7 166 # Check for the receipt of a package used to cook.
pankso@7 167 check_for_receipt()
pankso@7 168 {
pankso@7 169 if [ ! -f "$RECEIPT" ]; then
gokhlayeh@186 170 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
gokhlayeh@186 171 exit 1
pankso@7 172 fi
pankso@7 173 }
pankso@7 174
pankso@7 175 # Check for a specified file list on cmdline.
pankso@7 176 check_for_list()
pankso@7 177 {
gokhlayeh@186 178 if [ ! "$LIST" ]; then
gokhlayeh@186 179 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
gokhlayeh@186 180 exit 1
pankso@7 181 fi
gokhlayeh@186 182
MikeDSmith25@82 183 # Check if the list of packages exists.
pankso@7 184 if [ -f "$LIST" ]; then
pankso@7 185 LIST=`cat $LIST`
pankso@7 186 else
gokhlayeh@186 187 echo -e "\nUnable to find $LIST packages list.\n" >&2
gokhlayeh@186 188 exit 1
pankso@7 189 fi
gokhlayeh@186 190
gokhlayeh@186 191 if [ ! "$LIST" ]; then
gokhlayeh@186 192 echo -e "\nList is empty.\n" >&2
gokhlayeh@186 193 exit 1
gokhlayeh@186 194 fi
gokhlayeh@186 195 }
gokhlayeh@186 196
gokhlayeh@204 197 check_for_pkg_in_wok()
gokhlayeh@204 198 {
gokhlayeh@204 199 [ -f $WOK/$PACKAGE/receipt ] && return
gokhlayeh@204 200 if [ "$undigest" ]; then
gokhlayeh@204 201 [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1
gokhlayeh@204 202 grep -q ^$PACKAGE$ $SLITAZ_VERSION/packages/packages.txt && return 1
gokhlayeh@204 203 fi
gokhlayeh@204 204 echo "Can't find $PACKAGE in wok or mirror" >&2
gokhlayeh@204 205 return 2
gokhlayeh@204 206 }
gokhlayeh@186 207
gokhlayeh@186 208 ########################################################################
gokhlayeh@186 209 # TAZWOK CORE FUNCTIONS
gokhlayeh@186 210 ########################
gokhlayeh@186 211
gokhlayeh@186 212 remove_src()
gokhlayeh@186 213 {
gokhlayeh@204 214 [ "$WANTED" ] && return
gokhlayeh@186 215 look_for_cookopt !remove_src && return
gokhlayeh@215 216 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
gokhlayeh@186 217 check_for_var_modification _pkg src || return
gokhlayeh@215 218 mv "$src/_pkg" $WOK/$PACKAGE/install
gokhlayeh@186 219 fi
gokhlayeh@186 220
gokhlayeh@186 221 # Don't remove sources if a package use src variable in his
gokhlayeh@186 222 # genpkg_rules: it maybe need something inside.
gokhlayeh@186 223 for i in $PACKAGE $(look_for_rwanted); do
gokhlayeh@186 224 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
gokhlayeh@195 225 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
gokhlayeh@186 226 because $i use \$src in his receipt." && return
gokhlayeh@186 227 done
gokhlayeh@186 228
gokhlayeh@186 229 report step "Removing sources directory"
gokhlayeh@186 230 rm -fr "$src"
gokhlayeh@186 231 report end-step
gokhlayeh@186 232 }
gokhlayeh@186 233
gokhlayeh@186 234 # Check $COOK_OPT; usage : get_cookopt particular_opt
gokhlayeh@186 235 # Return error if not founded
gokhlayeh@186 236 # Return args if the opt is in the format opt=arg1:arg2:etc
gokhlayeh@186 237 look_for_cookopt()
gokhlayeh@186 238 {
gokhlayeh@186 239 for arg in $COOK_OPT; do
gokhlayeh@186 240 case $arg in
gokhlayeh@186 241 $1=*)
gokhlayeh@186 242 arg=${arg#$1=}
gokhlayeh@186 243 while [ "$arg" ]; do
gokhlayeh@186 244 echo "${arg%%:*}"
gokhlayeh@186 245 [ "${arg/:}" = "$arg" ] && return
gokhlayeh@186 246 arg=${arg#*:}
gokhlayeh@186 247 done
gokhlayeh@186 248 ;;
gokhlayeh@186 249 $1)
gokhlayeh@186 250 return
gokhlayeh@186 251 ;;
gokhlayeh@186 252 esac
gokhlayeh@186 253 done
gokhlayeh@186 254 return 1
pankso@7 255 }
pankso@7 256
pankso@7 257 # Check for the wanted package if specified in WANTED
paul@166 258 # receipt variable. Set the $src/$_pkg variable to help compile
paul@166 259 # and generate packages.
pankso@7 260 check_for_wanted()
pankso@7 261 {
gokhlayeh@186 262 if [ "$WANTED" ]; then
gokhlayeh@186 263 report "Checking for the wanted package"
pankso@7 264 if [ ! -d "$WOK/$WANTED" ]; then
gokhlayeh@186 265 report exit "\nWanted package is missing in the work directory.\n"
pankso@7 266 fi
gokhlayeh@186 267
erjo@38 268 # Checking for buildtree of Wanted package
pankso@39 269 if [ ! -d "$WOK/$WANTED/taz" ]; then
erjo@38 270 echo -e "\n\nSource files of wanted package is missing in the work directory."
erjo@38 271 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
erjo@38 272 if [ "$anser" == "y" ]; then
erjo@38 273 tazwok cook $WANTED
erjo@38 274 else
gokhlayeh@186 275 report exit "\nWanted package source tree is missing in the work directory.\n"
erjo@38 276 fi
erjo@38 277 fi
gokhlayeh@186 278 report end-step
gokhlayeh@186 279
pankso@7 280 # Set wanted src path.
gokhlayeh@186 281 set_src_path && set_pkg_path
gokhlayeh@186 282
pankso@7 283 fi
pankso@7 284 }
pankso@7 285
pankso@40 286 # Check for build dependencies, notify user and install if specified.
pankso@18 287 check_for_build_depends()
pankso@18 288 {
gokhlayeh@204 289 [ "$WANTED" ] && return
gokhlayeh@213 290 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
gokhlayeh@186 291 report step "Looking for build dependencies"
gokhlayeh@186 292
gokhlayeh@186 293 # Keep the list of previously installed build_depends then compare
gokhlayeh@186 294 # it with new build_depends to know what to install and what to
gokhlayeh@186 295 # what to remove.
gokhlayeh@186 296 plan_remove=" $MISSING_PACKAGE $remove_later "
gokhlayeh@186 297 [ ! "${plan_remove// }" ] && unset plan_remove
gokhlayeh@186 298 unset MISSING_PACKAGE remove_later
gokhlayeh@186 299 rwanted=$(look_for_rwanted)
gokhlayeh@186 300
gokhlayeh@215 301 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
gokhlayeh@204 302 fgrep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e $i"; done))
pankso@18 303 do
gokhlayeh@186 304
gokhlayeh@186 305 # Delay the removing of previous cook depends if they are needed
gokhlayeh@186 306 # for next cook too.
gokhlayeh@186 307 if [ ! -d "$INSTALLED/$pkg" ] ; then
gokhlayeh@186 308 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
gokhlayeh@186 309 fi
gokhlayeh@186 310 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
gokhlayeh@186 311 plan_remove="${plan_remove/ $pkg / }"
gokhlayeh@186 312 remove_later="$remove_later $pkg"
gokhlayeh@186 313 fi
gokhlayeh@186 314 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
gokhlayeh@186 315 broken="$broken$pkg "
pankso@18 316 fi
pankso@18 317 done
gokhlayeh@186 318
gokhlayeh@186 319 # Don't cook if a depend is broken.
gokhlayeh@186 320 if [ "$broken" ]; then
gokhlayeh@186 321 MISSING_PACKAGE=$plan_remove
gokhlayeh@186 322 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
gokhlayeh@186 323 unset plan_remove broken
gokhlayeh@186 324
gokhlayeh@186 325 # Set report step to failed.
gokhlayeh@186 326 report_return_code=1
gokhlayeh@186 327 report end-step
gokhlayeh@186 328 return 1
gokhlayeh@186 329 fi
gokhlayeh@186 330 if [ "$MISSING_PACKAGE" ]; then
gokhlayeh@186 331 install_missing()
gokhlayeh@186 332 {
gokhlayeh@186 333 echo "Installing missing packages : $MISSING_PACKAGE"
gokhlayeh@186 334 for pkg in $MISSING_PACKAGE; do
gokhlayeh@186 335 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
gokhlayeh@186 336 done
gokhlayeh@186 337 }
gokhlayeh@186 338 if [ "$auto_install" = yes ]; then
gokhlayeh@186 339 install_missing
gokhlayeh@186 340 else
gokhlayeh@186 341 echo "================================================================================"
gokhlayeh@186 342 for pkg in $MISSING_PACKAGE
gokhlayeh@186 343 do
pankso@18 344 echo "Missing : $pkg"
gokhlayeh@186 345 done
gokhlayeh@186 346 echo "================================================================================"
gokhlayeh@186 347 echo "You can continue, exit or install missing dependencies."
gokhlayeh@186 348 echo -n "Install, continue or exit (install/y/N) ? "; read answer
gokhlayeh@186 349 case $answer in
gokhlayeh@186 350 install)
gokhlayeh@186 351 install_missing ;;
gokhlayeh@186 352 y|yes)
gokhlayeh@186 353 unset MISSING_PACKAGE;;
gokhlayeh@186 354 *)
gokhlayeh@186 355 report stop
gokhlayeh@186 356 exit 0 ;;
gokhlayeh@186 357 esac
gokhlayeh@186 358 fi
gokhlayeh@186 359 fi
gokhlayeh@186 360 report end-step
gokhlayeh@186 361 remove_build_depends $plan_remove
gokhlayeh@186 362 unset plan_remove
gokhlayeh@186 363 }
gokhlayeh@186 364
gokhlayeh@186 365 remove_build_depends()
gokhlayeh@186 366 {
gokhlayeh@186 367 [ "$1" ] || return
gokhlayeh@186 368 report step "Removing previous build dependencies"
gokhlayeh@186 369 echo "Removing theses packages : $@"
gokhlayeh@186 370 for pkg in $@; do
gokhlayeh@223 371 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
gokhlayeh@186 372 done
gokhlayeh@186 373 report end-step
gokhlayeh@186 374 }
gokhlayeh@186 375
gokhlayeh@186 376 # Check if we can use the new way to handle tarball
gokhlayeh@186 377 # or if we keep the previous method by check for
gokhlayeh@186 378 # _pkg=/src= in receipt and reverse-wanted.
gokhlayeh@186 379 check_for_var_modification()
gokhlayeh@186 380 {
gokhlayeh@186 381 for var in $@; do
gokhlayeh@186 382 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
gokhlayeh@186 383 [ -f $WOK/$pkg/receipt ] || continue
gokhlayeh@195 384 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
pankso@18 385 done
gokhlayeh@186 386 done
gokhlayeh@186 387
gokhlayeh@186 388 # Tweak to make if; then...; fi function working with this one.
gokhlayeh@186 389 echo -n ""
gokhlayeh@186 390 }
gokhlayeh@186 391
gokhlayeh@186 392 set_src_path()
gokhlayeh@186 393 {
gokhlayeh@186 394 if check_for_var_modification src _pkg; then
gokhlayeh@186 395 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
gokhlayeh@186 396 else
gokhlayeh@186 397 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
pankso@18 398 fi
pankso@18 399 }
pascal@76 400
gokhlayeh@186 401 set_pkg_path()
gokhlayeh@186 402 {
gokhlayeh@186 403 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
gokhlayeh@186 404 _pkg=$WOK/${WANTED:-$PACKAGE}/install
gokhlayeh@186 405 else
gokhlayeh@186 406 _pkg=$src/_pkg
gokhlayeh@186 407 fi
gokhlayeh@186 408 }
gokhlayeh@186 409
gokhlayeh@186 410 # Output $VERSION-$EXTRAVERSION using packages.txt
gokhlayeh@186 411 get_pkg_version()
gokhlayeh@186 412 {
gokhlayeh@186 413 [ "$PACKAGE" ] || return
gokhlayeh@204 414 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
gokhlayeh@186 415 }
gokhlayeh@186 416
gokhlayeh@186 417 remove_previous_tarball()
gokhlayeh@186 418 {
gokhlayeh@186 419 [ "$prev_VERSION" ] || return
gokhlayeh@186 420 if [ "$VERSION" != "$prev_VERSION" ]; then
gokhlayeh@186 421 rm -f $SOURCES_REPOSITORY/$PACKAGE-$prev_VERSION.tar.lzma
gokhlayeh@186 422 fi
gokhlayeh@186 423 }
gokhlayeh@186 424
gokhlayeh@186 425 remove_previous_package()
gokhlayeh@186 426 {
gokhlayeh@186 427 [ "$prev_VERSION" ] || return
gokhlayeh@186 428 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
gokhlayeh@186 429 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
gokhlayeh@186 430 fi
gokhlayeh@204 431 return
gokhlayeh@186 432 }
gokhlayeh@186 433
gokhlayeh@186 434 # Check for src tarball and wget if needed.
gokhlayeh@186 435 check_for_tarball()
gokhlayeh@186 436 {
gokhlayeh@186 437 if [ "$WGET_URL" ]; then
gokhlayeh@186 438 report step "Checking for source tarball"
gokhlayeh@186 439
gokhlayeh@186 440 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
gokhlayeh@234 441 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
gokhlayeh@186 442 cd $SOURCES_REPOSITORY
gokhlayeh@186 443 download $WGET_URL
gokhlayeh@186 444
gokhlayeh@186 445 # If source tarball is unreachable, try to find it on SliTaz
gokhlayeh@186 446 # mirror.
gokhlayeh@186 447 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
gokhlayeh@186 448 report step "Download failed, try with mirror copy... "
gokhlayeh@233 449 if [ "$SOURCE" ]; then
gokhlayeh@233 450 download http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma
gokhlayeh@233 451 else
gokhlayeh@233 452 download http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma
gokhlayeh@233 453 fi
gokhlayeh@186 454 fi
gokhlayeh@186 455 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
gokhlayeh@186 456 [ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
gokhlayeh@186 457 report step "Download failed, try with mirror copy (again)... "
gokhlayeh@186 458 file=$(basename $WGET_URL)
gokhlayeh@186 459 download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
gokhlayeh@186 460 fi
gokhlayeh@186 461
gokhlayeh@186 462 # Exit if download failed to avoid errors.
gokhlayeh@186 463 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
gokhlayeh@186 464 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
gokhlayeh@186 465 report end-step
gokhlayeh@186 466 return 1
gokhlayeh@186 467 fi
slaxemulator@232 468 fi
slaxemulator@232 469 fi
slaxemulator@232 470 report end-step
slaxemulator@232 471
gokhlayeh@234 472 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
slaxemulator@232 473 return
slaxemulator@232 474 fi
slaxemulator@232 475
slaxemulator@232 476 # Untaring source if necessary. We don't need to extract source if
slaxemulator@232 477 # the package is built with a wanted source package.
slaxemulator@232 478 if [ "$WANTED" ]; then
slaxemulator@232 479 return
slaxemulator@232 480 fi
slaxemulator@232 481
slaxemulator@232 482 report step "Untaring source tarball"
slaxemulator@232 483 if [ "$target" ]; then
slaxemulator@232 484 src="$target"
slaxemulator@232 485 else
slaxemulator@232 486 set_src_path
slaxemulator@232 487 fi
slaxemulator@232 488
slaxemulator@232 489 # Log process.
slaxemulator@232 490 echo "untaring source tarball" >> $LOG
gokhlayeh@186 491
slaxemulator@232 492 tmp_src=$WOK/$PACKAGE/tmp-src-$$
slaxemulator@232 493 mkdir $tmp_src
gokhlayeh@233 494 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
gokhlayeh@233 495 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
slaxemulator@232 496 tar xf - -C $tmp_src
slaxemulator@232 497 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
slaxemulator@232 498 case "$TARBALL" in
slaxemulator@232 499 *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
slaxemulator@232 500 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
slaxemulator@232 501 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
slaxemulator@232 502 *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
slaxemulator@232 503 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
slaxemulator@232 504 *Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
slaxemulator@232 505 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
slaxemulator@232 506 esac || return 1
slaxemulator@232 507
slaxemulator@232 508 # Check if uncompressed tarball is in a root dir or not.
slaxemulator@232 509 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
slaxemulator@232 510 if check_for_var_modification src _pkg; then
slaxemulator@232 511 mv $tmp_src $tmp_src-1
slaxemulator@232 512 mkdir $tmp_src
gokhlayeh@233 513 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
slaxemulator@232 514 else
slaxemulator@232 515 mv $tmp_src/* $WOK/$PACKAGE
slaxemulator@232 516 repack_src=no
slaxemulator@232 517 rm -r $tmp_src
slaxemulator@232 518 fi
slaxemulator@232 519 fi
slaxemulator@232 520
slaxemulator@232 521 if [ "$repack_src" = yes ]; then
slaxemulator@232 522 report step "Repacking sources in .tar.lzma format"
slaxemulator@232 523 cd $tmp_src
gokhlayeh@233 524 tar -c * | lzma e $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -si
slaxemulator@232 525 rm $SOURCES_REPOSITORY/$TARBALL
slaxemulator@232 526 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
slaxemulator@232 527
slaxemulator@232 528 # Remove previous tarball if it's not used either by
slaxemulator@232 529 # incoming and legacy packages.
slaxemulator@232 530 [ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
slaxemulator@232 531 remove_previous_tarball
slaxemulator@232 532 fi
slaxemulator@232 533 fi
slaxemulator@232 534 if [ "$nounpack" ]; then
slaxemulator@232 535 [ -d "$tmp_src" ] && rm -r $tmp_src
slaxemulator@232 536 return
slaxemulator@232 537 fi
slaxemulator@232 538
slaxemulator@232 539 if [ ! -d "$src" ]; then
slaxemulator@232 540 if [ -d "$tmp_src" ]; then
slaxemulator@232 541 if ! check_for_var_modification src _pkg; then
slaxemulator@232 542 src="${src%/*}/$(ls $tmp_src)"
slaxemulator@232 543 fi
slaxemulator@232 544 mv $(echo $tmp_src/*) "$src"
slaxemulator@232 545 rm -r $tmp_src
slaxemulator@232 546
slaxemulator@232 547 # Permissions settings.
slaxemulator@232 548 chown -R root.root "$src"
gokhlayeh@186 549 fi
gokhlayeh@186 550 report end-step
slaxemulator@232 551 else
slaxemulator@232 552 echo "There's already something at $src. Abord." >&2
gokhlayeh@186 553 fi
gokhlayeh@186 554 }
gokhlayeh@186 555
gokhlayeh@186 556 # Log and execute compile_rules function if it exists, to configure and
gokhlayeh@186 557 # make the package if it exists.
gokhlayeh@186 558 check_for_compile_rules()
gokhlayeh@186 559 {
gokhlayeh@186 560 if grep -q ^compile_rules $RECEIPT; then
gokhlayeh@186 561 echo "executing compile_rules" >> $LOG
gokhlayeh@186 562 report step "Executing compile_rules"
gokhlayeh@186 563 cd $WOK/$PACKAGE
gokhlayeh@186 564 rm -f /tmp/config.site
gokhlayeh@186 565
gokhlayeh@186 566 # Free some RAM by cleaning cache if option is enabled.
slaxemulator@200 567 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
gokhlayeh@186 568
gokhlayeh@186 569 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
gokhlayeh@186 570 # RAM are available.
gokhlayeh@195 571 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
gokhlayeh@195 572 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
gokhlayeh@195 573 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
gokhlayeh@186 574 CFLAGS="${CFLAGS/-pipe}"
gokhlayeh@186 575 CXXFLAGS="${CXXFLAGS/-pipe}"
gokhlayeh@186 576 fi
gokhlayeh@186 577 unset freeram
gokhlayeh@186 578
gokhlayeh@186 579 # Set cook environnement variables.
gokhlayeh@186 580 [ "$src" ] || set_src_path
gokhlayeh@186 581 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
gokhlayeh@186 582 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
gokhlayeh@186 583 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
gokhlayeh@186 584 CONFIG_SITE default_prefix \
gokhlayeh@186 585 default_datarootdir default_datadir default_localedir \
gokhlayeh@186 586 default_infodir default_mandir default_build default_host
gokhlayeh@186 587 local LC_ALL=POSIX LANG=POSIX
gokhlayeh@186 588 compile_rules
gokhlayeh@186 589
gokhlayeh@186 590 # Check if config.site has been used.
gokhlayeh@186 591 # /!\ disabled since it screw the return_code of the step.
gokhlayeh@186 592 #if [ -f /tmp/config.site ]; then
gokhlayeh@186 593 # rm /tmp/config.site
gokhlayeh@186 594 #else
gokhlayeh@186 595 # tazwok_warning "config.site hasn't been used during \
gokhlayeh@186 596 #configuration process."
gokhlayeh@186 597 #fi
gokhlayeh@186 598
gokhlayeh@186 599 report end-step
gokhlayeh@186 600 fi
gokhlayeh@186 601 }
gokhlayeh@186 602
gokhlayeh@186 603 # Check for loop in deps tree. /!\ can be removed
pascal@76 604 check_for_deps_loop()
pascal@76 605 {
pascal@76 606 local list
pascal@76 607 local pkg
pascal@76 608 local deps
pascal@76 609 pkg=$1
pascal@76 610 shift
pascal@76 611 [ -n "$1" ] || return
pascal@76 612 list=""
gokhlayeh@204 613
pascal@76 614 # Filter out already processed deps
pascal@76 615 for i in $@; do
pascal@76 616 case " $ALL_DEPS" in
pascal@76 617 *\ $i\ *);;
pascal@76 618 *) list="$list $i";;
pascal@76 619 esac
pascal@76 620 done
pascal@76 621 ALL_DEPS="$ALL_DEPS$list "
pascal@76 622 for i in $list; do
pascal@76 623 [ -f $i/receipt ] || continue
pascal@76 624 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
pascal@76 625 case " $deps " in
pascal@76 626 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
pascal@76 627 *) check_for_deps_loop $pkg $deps;;
pascal@76 628 esac
pascal@76 629 done
pascal@76 630 }
pascal@76 631
erjo@53 632 download()
erjo@53 633 {
erjo@53 634 for file in $@; do
gokhlayeh@186 635 wget -q $file && break
erjo@53 636 done
erjo@53 637 }
pankso@18 638
gokhlayeh@186 639 # Regenerate every package that wants a PACKAGE compiled
pascal@156 640 refresh_packages_from_compile()
pascal@156 641 {
pascal@156 642 # make tazwok genpkg happy
pascal@156 643 mkdir $WOK/$PACKAGE/taz
gokhlayeh@204 644
gokhlayeh@186 645 # Cook rwanted in default or specied order
gokhlayeh@186 646 genlist=" $(look_for_rwanted | tr '\n' ' ') "
gokhlayeh@186 647 for i in $(look_for_cookopt genpkg | tac); do
gokhlayeh@186 648 [ "${genlist/ $i }" = "$genlist" ] && continue
gokhlayeh@186 649 genlist=" $i${genlist/ $i / }"
pascal@156 650 done
gokhlayeh@215 651 if [ "$genlist" ]; then
gokhlayeh@215 652 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
gokhlayeh@215 653 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
gokhlayeh@215 654 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
gokhlayeh@215 655 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
gokhlayeh@215 656 for PACKAGE in $genlist; do
gokhlayeh@215 657 set_common_path
gokhlayeh@215 658 gen_package
gokhlayeh@215 659 done
gokhlayeh@215 660 fi
pascal@156 661 }
pascal@156 662
MikeDSmith25@82 663 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@22 664 # so some packages need to copy these files with the receipt and genpkg_rules.
pankso@22 665 # This function is executed by gen_package when 'tazwok genpkg'.
pankso@22 666 copy_generic_files()
pankso@22 667 {
MikeDSmith25@82 668 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
pankso@22 669 # using generic variables and $LOCALE from Tazwok config file.
gokhlayeh@186 670 if [ "$LOCALE" ]; then
pankso@22 671 if [ -d "$_pkg/usr/share/locale" ]; then
pankso@22 672 for i in $LOCALE
pankso@22 673 do
pankso@37 674 if [ -d "$_pkg/usr/share/locale/$i" ]; then
pankso@37 675 mkdir -p $fs/usr/share/locale
pankso@37 676 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
pankso@37 677 fi
pankso@22 678 done
pankso@22 679 fi
pankso@22 680 fi
gokhlayeh@186 681
pankso@133 682 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
MikeDSmith25@82 683 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
pankso@31 684 # in pkg receipt.
gokhlayeh@186 685 if [ "$GENERIC_PIXMAPS" != "no" ]; then
pankso@22 686 if [ -d "$_pkg/usr/share/pixmaps" ]; then
pankso@27 687 mkdir -p $fs/usr/share/pixmaps
pankso@31 688 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
pankso@31 689 $fs/usr/share/pixmaps 2>/dev/null
pankso@31 690 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
pankso@22 691 $fs/usr/share/pixmaps 2>/dev/null
pankso@23 692 fi
gokhlayeh@186 693
MikeDSmith25@82 694 # Custom or homemade PNG pixmap can be in stuff.
pankso@23 695 if [ -f "stuff/$PACKAGE.png" ]; then
pankso@27 696 mkdir -p $fs/usr/share/pixmaps
pankso@23 697 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@22 698 fi
pankso@22 699 fi
gokhlayeh@186 700
pankso@22 701 # Desktop entry (.desktop).
pankso@22 702 if [ -d "$_pkg/usr/share/applications" ]; then
pankso@22 703 cp -a $_pkg/usr/share/applications $fs/usr/share
pankso@23 704 fi
gokhlayeh@186 705
MikeDSmith25@82 706 # Homemade desktop file(s) can be in stuff.
pankso@34 707 if [ -d "stuff/applications" ]; then
pankso@42 708 mkdir -p $fs/usr/share
pankso@42 709 cp -a stuff/applications $fs/usr/share
pankso@34 710 fi
pankso@34 711 if [ -f "stuff/$PACKAGE.desktop" ]; then
pankso@42 712 mkdir -p $fs/usr/share/applications
pankso@42 713 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@22 714 fi
pankso@22 715 }
pankso@22 716
pankso@25 717 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
pankso@25 718 strip_package()
pankso@25 719 {
gokhlayeh@186 720 report step "Executing strip on all files"
gokhlayeh@186 721
pankso@25 722 # Binaries.
pankso@25 723 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@25 724 do
pankso@25 725 if [ -d "$dir" ]; then
pankso@25 726 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
pankso@25 727 fi
pankso@25 728 done
gokhlayeh@186 729
pankso@25 730 # Libraries.
pankso@25 731 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
pankso@25 732 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
gokhlayeh@186 733 report end-step
gokhlayeh@186 734 }
gokhlayeh@186 735
gokhlayeh@186 736 # Remove .pyc and .pyo files from packages
gokhlayeh@186 737 py_compiled_files_remove()
gokhlayeh@186 738 {
gokhlayeh@186 739 report step "Removing all .pyc and .pyo files from package ..."
gokhlayeh@186 740 find $fs -type f -name "*.pyc" -delete 2>/dev/null
gokhlayeh@186 741 find $fs -type f -name "*.pyo" -delete 2>/dev/null
gokhlayeh@186 742 report end-step
pankso@25 743 }
pankso@25 744
pankso@135 745 # Check FSH in a slitaz package (Path: /:/usr)
pankso@135 746 check_fsh()
pankso@135 747 {
pankso@135 748 cd $WOK/$PACKAGE/taz/*/fs
pascal@149 749 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
pascal@149 750 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
pascal@149 751 usr/local usr/sbin usr/share usr/src"
pankso@135 752 for i in `ls -d * usr/* 2>/dev/null`
pankso@135 753 do
gokhlayeh@195 754 if ! echo $FSH | fgrep -q $i; then
gokhlayeh@186 755 echo "Wrong path: /$i" >&2
pankso@135 756 error=1
pankso@135 757 fi
pankso@135 758 done
pankso@135 759 if [ "$error" = "1" ]; then
pankso@135 760 cat << _EOT_
pankso@135 761
paul@155 762 Package will install files in a non standard directory and won't be generated.
paul@154 763 You may have a wrong copy path in genpkg_rules or need to add some options to
pankso@135 764 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
pankso@135 765
pankso@135 766 --prefix=/usr
pankso@135 767 --sysconfdir=/etc
pankso@135 768 --libexecdir=/usr/lib/(pkgname)
pankso@135 769 --localstatedir=/var
pankso@135 770 --mandir=/usr/share/man
pankso@135 771 --infodir=/usr/share/info
pankso@135 772
paul@152 773 For more information please read SliTaz docs and run: ./configure --help
pankso@135 774 ================================================================================
pankso@135 775 $PACKAGE package generation aborted.
pankso@135 776
pankso@135 777 _EOT_
gokhlayeh@186 778
pankso@135 779 # Dont generate a corrupted package.
pankso@137 780 cd $WOK/$PACKAGE && rm -rf taz
gokhlayeh@186 781 report exit
pankso@135 782 fi
gokhlayeh@186 783 }
gokhlayeh@186 784
gokhlayeh@186 785 gen_cookmd5()
gokhlayeh@186 786 {
gokhlayeh@186 787 # md5sum of cooking stuff make tazwok able to check for changes
gokhlayeh@186 788 # without hg.
gokhlayeh@186 789 cd $WOK/$PACKAGE
gokhlayeh@186 790 md5sum receipt > md5
gokhlayeh@186 791 [ -f description.txt ] && md5sum description.txt >> md5
gokhlayeh@186 792 if [ -d stuff ]; then
gokhlayeh@186 793 find stuff | while read file; do
gokhlayeh@186 794 md5sum $file >> md5
gokhlayeh@186 795 done
gokhlayeh@186 796 fi
pankso@135 797 }
pankso@135 798
MikeDSmith25@82 799 # Create a package tree and build the gziped cpio archive
pankso@7 800 # to make a SliTaz (.tazpkg) package.
pankso@7 801 gen_package()
pankso@7 802 {
pankso@7 803 check_root
pankso@7 804 check_for_package_on_cmdline
pankso@7 805 check_for_receipt
pascal@74 806 EXTRAVERSION=""
pankso@7 807 . $RECEIPT
gokhlayeh@186 808
pascal@86 809 # May compute VERSION
pascal@86 810 if grep -q ^get_version $RECEIPT; then
pascal@86 811 get_version
pascal@86 812 fi
pankso@7 813 check_for_wanted
pankso@7 814 cd $WOK/$PACKAGE
gokhlayeh@186 815
pankso@7 816 # Remove old Tazwok package files.
gokhlayeh@186 817 [ -d "taz" ] && rm -rf taz
gokhlayeh@186 818
MikeDSmith25@82 819 # Create the package tree and set useful variables.
pankso@7 820 mkdir -p taz/$PACKAGE-$VERSION/fs
pankso@7 821 fs=taz/$PACKAGE-$VERSION/fs
gokhlayeh@186 822
MikeDSmith25@82 823 # Set $src for standard package and $_pkg variables.
gokhlayeh@186 824 set_src_path && set_pkg_path
gokhlayeh@186 825
pankso@135 826 # Execute genpkg_rules, check package and copy generic files to build
pankso@135 827 # the package.
gokhlayeh@186 828 report step "Building $PACKAGE with the receipt"
gokhlayeh@186 829 report open-bloc
pankso@28 830 if grep -q ^genpkg_rules $RECEIPT; then
gokhlayeh@186 831
pankso@7 832 # Log process.
pankso@7 833 echo "executing genpkg_rules" >> $LOG
gokhlayeh@186 834 report step "Executing genpkg_rules"
pascal@126 835 genpkg_rules
gokhlayeh@186 836 report end-step
pankso@135 837 check_fsh
pankso@25 838 cd $WOK/$PACKAGE
gokhlayeh@186 839
pankso@133 840 # Skip generic files for packages with a WANTED variable
pankso@24 841 # (dev and splited pkgs).
gokhlayeh@186 842 if [ ! "$WANTED" ]; then
pankso@24 843 copy_generic_files
pankso@24 844 fi
gokhlayeh@204 845 look_for_cookopt !strip || strip_package
gokhlayeh@186 846 py_compiled_files_remove
pankso@7 847 else
gokhlayeh@186 848 echo "No package rules to gen $PACKAGE..." >&2
gokhlayeh@186 849 report exit
pankso@7 850 fi
gokhlayeh@186 851
paul@154 852 # Copy the receipt and description (if exists) into the binary package tree.
pankso@7 853 cd $WOK/$PACKAGE
gokhlayeh@186 854 report step "Copying the receipt"
pankso@7 855 cp receipt taz/$PACKAGE-$VERSION
gokhlayeh@186 856 report end-step
pascal@89 857 if grep -q ^get_version $RECEIPT; then
gokhlayeh@186 858 report step "Updating version in receipt"
pascal@89 859 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
pascal@89 860 taz/$PACKAGE-$VERSION/receipt
gokhlayeh@186 861 report end-step
pascal@89 862 fi
pankso@7 863 if [ -f "description.txt" ]; then
gokhlayeh@186 864 report step "Copying the description file"
pankso@7 865 cp description.txt taz/$PACKAGE-$VERSION
gokhlayeh@186 866 report end-step
pankso@7 867 fi
gokhlayeh@186 868
gokhlayeh@186 869 # Generate md5 of cooking stuff to look for commit later.
gokhlayeh@186 870 gen_cookmd5
gokhlayeh@186 871 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
gokhlayeh@186 872 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
gokhlayeh@186 873
MikeDSmith25@82 874 # Create the files.list by redirecting find output.
gokhlayeh@186 875 report step "Creating the list of files"
pascal@15 876 cd taz/$PACKAGE-$VERSION
pascal@13 877 LAST_FILE=""
gokhlayeh@195 878 { find fs -print; echo; } | while read file; do
gokhlayeh@186 879 if [ "$LAST_FILE" ]; then
pascal@15 880 case "$file" in
pascal@13 881 $LAST_FILE/*)
pankso@133 882 case "$(ls -ld "$LAST_FILE")" in
pascal@15 883 drwxr-xr-x\ *\ root\ *\ root\ *);;
pascal@15 884 *) echo ${LAST_FILE#fs};;
pascal@13 885 esac;;
pascal@15 886 *) echo ${LAST_FILE#fs};;
pascal@13 887 esac
pascal@13 888 fi
pascal@15 889 LAST_FILE="$file"
pascal@15 890 done > files.list
gokhlayeh@186 891
gokhlayeh@186 892 # Next, check if something has changed in lib files.
gokhlayeh@215 893 if fgrep -q '.so' files.list; then
gokhlayeh@215 894 report step "Look for major/minor update in libraries"
gokhlayeh@215 895 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
gokhlayeh@215 896 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
gokhlayeh@215 897 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
gokhlayeh@215 898 prev_VERSION=$(get_pkg_version $rep)
gokhlayeh@215 899 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
gokhlayeh@215 900 done
gokhlayeh@215 901 if [ "$pkg_file" ]; then
gokhlayeh@215 902 get_pkg_files $pkg_file
gokhlayeh@215 903 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
gokhlayeh@215 904 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
gokhlayeh@215 905 while read lib; do
gokhlayeh@215 906 fgrep -q "$lib" $pkg_files_dir/files.list && continue
gokhlayeh@215 907 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
gokhlayeh@215 908 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
gokhlayeh@215 909 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
gokhlayeh@215 910 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
gokhlayeh@215 911 $PACKAGES_REPOSITORY/cooklist && continue
gokhlayeh@215 912 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
gokhlayeh@215 913 done
gokhlayeh@215 914 regen_cooklist=yes
gokhlayeh@215 915 break
gokhlayeh@215 916 done
gokhlayeh@215 917 rm -r $pkg_files_dir
gokhlayeh@186 918 fi
gokhlayeh@186 919 report end-step
gokhlayeh@186 920 fi
gokhlayeh@186 921 if [ ! "$EXTRAVERSION" ]; then
pascal@84 922 case "$PACKAGE" in
pascal@84 923 linux*);;
pascal@85 924 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
pascal@84 925 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
pascal@84 926 esac
pascal@84 927 fi
gokhlayeh@186 928 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
gokhlayeh@186 929 report step "Creating md5sum of files"
pascal@70 930 while read file; do
pascal@71 931 [ -L "fs$file" ] && continue
pascal@71 932 [ -f "fs$file" ] || continue
pascal@71 933 md5sum "fs$file" | sed 's/ fs/ /'
pascal@70 934 done < files.list > md5sum
gokhlayeh@204 935 report end-step
pascal@84 936 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
pascal@84 937 2> /dev/null | awk '{ sz=$1 } END { print sz }')
gokhlayeh@186 938
pankso@7 939 # Build cpio archives. Find, cpio and gzip the fs, finish by
pankso@7 940 # removing the fs tree.
gokhlayeh@186 941 # Don't log this because compression always output error messages.
pascal@150 942 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
pascal@150 943 tazpkg-lzma) gzip > fs.cpio.gz;;
pascal@150 944 *-lzma) lzma e fs.cpio.lzma -si;;
pascal@150 945 *) gzip > fs.cpio.gz;;
pascal@150 946 esac && rm -rf fs
pascal@150 947 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
pascal@84 948 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
gokhlayeh@186 949 report step "Updating receipt sizes"
pascal@138 950 sed -i '/^PACKED_SIZE/d' receipt
pascal@138 951 sed -i '/^UNPACKED_SIZE/d' receipt
pascal@59 952 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@86 953 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
gokhlayeh@212 954 report end-step
gokhlayeh@212 955 if [ "$EXTRAVERSION" ]; then
gokhlayeh@186 956 report step "Updating receipt EXTRAVERSION"
pascal@72 957 sed -i s/^EXTRAVERSION.*$// receipt
pascal@72 958 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
pascal@72 959 fi
gokhlayeh@186 960 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
gokhlayeh@186 961 remove_previous_package $INCOMING_REPOSITORY
gokhlayeh@186 962 report step "Creating full cpio archive"
gokhlayeh@186 963 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
gokhlayeh@186 964
paul@154 965 # Restore package tree in case we want to browse it.
gokhlayeh@186 966 report step "Restoring original package tree"
gokhlayeh@195 967 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
pascal@150 968 rm fs.cpio.* && cd ..
gokhlayeh@186 969
pankso@7 970 # Log process.
pascal@69 971 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
gokhlayeh@186 972 report close-bloc
pascal@68 973 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
gokhlayeh@186 974 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
pankso@7 975 echo ""
gokhlayeh@186 976
gokhlayeh@204 977 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
gokhlayeh@204 978 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
gokhlayeh@204 979 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
pankso@7 980 }
pankso@7 981
gokhlayeh@186 982 ########################################################################
gokhlayeh@186 983 # This section contains functions used by several other functions
gokhlayeh@186 984 # bellow.
gokhlayeh@186 985 ########################
gokhlayeh@186 986
gokhlayeh@186 987 # Look for receipt/files.list in wok. If they can't be found, get them
gokhlayeh@186 988 # from package. Accept one argument : absolute path to package.
gokhlayeh@186 989 get_pkg_files()
pankso@28 990 {
gokhlayeh@186 991 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
gokhlayeh@186 992 mkdir -p $pkg_files_dir && \
gokhlayeh@186 993 cd $pkg_files_dir && \
gokhlayeh@186 994 cpio --quiet -idm receipt < $1 && \
gokhlayeh@186 995 cpio --quiet -idm files.list < $1
gokhlayeh@186 996 }
gokhlayeh@170 997
gokhlayeh@186 998 ########################################################################
gokhlayeh@204 999 # This section contains functions to generate packages databases.
gokhlayeh@186 1000 ########################
gokhlayeh@186 1001
gokhlayeh@186 1002
gokhlayeh@186 1003 gen_packages_db()
gokhlayeh@186 1004 {
gokhlayeh@186 1005 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
gokhlayeh@204 1006 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
gokhlayeh@186 1007 cd $pkg_repository
gokhlayeh@204 1008 report step "Generating packages lists: $pkg_repository"
gokhlayeh@204 1009 report open-bloc
gokhlayeh@204 1010 report step "Removing old files"
gokhlayeh@204 1011 for file in files.list.lzma packages.list packages.txt \
gokhlayeh@204 1012 packages.desc packages.equiv packages.md5; do
gokhlayeh@204 1013 [ -f $file ] && rm $file
gokhlayeh@204 1014 done
gokhlayeh@204 1015 touch files.list
gokhlayeh@204 1016
gokhlayeh@186 1017 packages_db_start
gokhlayeh@186 1018 unset RECEIPT
gokhlayeh@186 1019 report step "Reading datas from all packages"
gokhlayeh@195 1020 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
gokhlayeh@186 1021 get_packages_info
gokhlayeh@186 1022 done
gokhlayeh@186 1023 report end-step
gokhlayeh@186 1024 packages_db_end
gokhlayeh@204 1025 report close-bloc
gokhlayeh@186 1026 }
gokhlayeh@186 1027
gokhlayeh@186 1028 update_packages_db()
gokhlayeh@186 1029 {
gokhlayeh@204 1030 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
gokhlayeh@186 1031 cd $pkg_repository
gokhlayeh@204 1032 for file in packages.list packages.equiv packages.md5 packages.desc \
gokhlayeh@204 1033 packages.txt; do
gokhlayeh@186 1034 if [ ! -f "$file" ]; then
gokhlayeh@204 1035 gen_packages_db
gokhlayeh@186 1036 return
gokhlayeh@186 1037 fi
gokhlayeh@186 1038 done
gokhlayeh@186 1039 if [ -f files.list.lzma ]; then
gokhlayeh@186 1040 lzma d files.list.lzma files.list
gokhlayeh@186 1041 else
gokhlayeh@204 1042 gen_packages_db
gokhlayeh@186 1043 fi
gokhlayeh@204 1044 report step "Updating packages lists: $pkg_repository"
gokhlayeh@186 1045 packages_db_start
gokhlayeh@186 1046
gokhlayeh@186 1047 # Look for removed/update packages.
gokhlayeh@186 1048 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
gokhlayeh@202 1049 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
gokhlayeh@195 1050 if ! [ -f "$pkg" ]; then
gokhlayeh@186 1051 erase_package_info
gokhlayeh@186 1052 else
gokhlayeh@186 1053 if [ "$pkg" -nt "packages.list" ]; then
gokhlayeh@215 1054 updated_pkg="$updated_pkg
gokhlayeh@215 1055 $PACKAGE $pkg"
gokhlayeh@186 1056 fi
gokhlayeh@170 1057 fi
gokhlayeh@170 1058 done
gokhlayeh@215 1059 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
gokhlayeh@202 1060 erase_package_info
gokhlayeh@202 1061 get_packages_info
gokhlayeh@202 1062 done
gokhlayeh@204 1063 unset updated_pkg
gokhlayeh@202 1064
gokhlayeh@186 1065 # Look for new packages.
gokhlayeh@195 1066 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
gokhlayeh@199 1067 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
gokhlayeh@186 1068 get_packages_info
gokhlayeh@186 1069 fi
gokhlayeh@186 1070 done
gokhlayeh@186 1071 report end-step
gokhlayeh@186 1072 packages_db_end
gokhlayeh@186 1073 }
gokhlayeh@186 1074
gokhlayeh@186 1075 packages_db_start()
gokhlayeh@186 1076 {
gokhlayeh@186 1077 if [ ! -s packages.txt ]; then
gokhlayeh@186 1078 echo "# SliTaz GNU/Linux - Packages list
gokhlayeh@186 1079 #
gokhlayeh@186 1080 # Packages : unknow
gokhlayeh@186 1081 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
gokhlayeh@215 1082 #
gokhlayeh@215 1083 " > packages.txt
pascal@62 1084 else
gokhlayeh@186 1085 sed -e 's/^# Packages :.*/# Packages : unknow/' \
gokhlayeh@186 1086 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
gokhlayeh@186 1087 -i packages.txt
pascal@60 1088 fi
gokhlayeh@186 1089
gokhlayeh@186 1090 # Needed in some case as tazwok define RECEIPT at configuration time
gokhlayeh@186 1091 # in this particular case it can broke the script.
gokhlayeh@186 1092 unset RECEIPT
gokhlayeh@186 1093 }
gokhlayeh@186 1094
gokhlayeh@186 1095 erase_package_info()
gokhlayeh@186 1096 {
gokhlayeh@186 1097 cd $pkg_repository
gokhlayeh@186 1098 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
gokhlayeh@186 1099 sed "/^$PACKAGE /d" -i packages.desc
gokhlayeh@186 1100 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
gokhlayeh@186 1101 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
gokhlayeh@186 1102 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
gokhlayeh@186 1103 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
gokhlayeh@186 1104 -i packages.equiv
gokhlayeh@186 1105 sed "/^$PACKAGE:/d" -i files.list
gokhlayeh@186 1106 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
gokhlayeh@186 1107 sed "/ $(basename $pkg)$/d" -i packages.md5
gokhlayeh@186 1108 }
gokhlayeh@186 1109
gokhlayeh@186 1110 get_packages_info()
gokhlayeh@186 1111 {
gokhlayeh@186 1112 # If there's no taz folder in the wok, extract infos from the
gokhlayeh@186 1113 # package.
gokhlayeh@186 1114 get_pkg_files $pkg
gokhlayeh@186 1115 source_receipt
gokhlayeh@186 1116 echo "Getting datas from $PACKAGE"
gokhlayeh@186 1117
gokhlayeh@186 1118 cat >> $pkg_repository/packages.txt << _EOT_
pankso@28 1119 $PACKAGE
gokhlayeh@186 1120 $VERSION$EXTRAVERSION
pankso@28 1121 $SHORT_DESC
pankso@28 1122 _EOT_
gokhlayeh@215 1123 if [ "$PACKED_SIZE" ]; then
gokhlayeh@215 1124 cat >> $pkg_repository/packages.txt << _EOT_
pankso@133 1125 $PACKED_SIZE ($UNPACKED_SIZE installed)
gokhlayeh@215 1126
pascal@60 1127 _EOT_
gokhlayeh@215 1128 else
gokhlayeh@215 1129 echo "" >> $pkg_repository/packages.txt
gokhlayeh@215 1130 fi
gokhlayeh@186 1131
paul@121 1132 # Packages.desc is used by Tazpkgbox <tree>.
gokhlayeh@186 1133 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
gokhlayeh@186 1134
paul@121 1135 # Packages.equiv is used by tazpkg install to check depends
pascal@99 1136 for i in $PROVIDE; do
pascal@99 1137 DEST=""
gokhlayeh@195 1138 echo $i | fgrep -q : && DEST="${i#*:}:"
gokhlayeh@186 1139 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
gokhlayeh@186 1140 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
pascal@99 1141 else
gokhlayeh@186 1142 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
gokhlayeh@186 1143 fi
gokhlayeh@186 1144 done
gokhlayeh@186 1145
gokhlayeh@186 1146 if [ -f files.list ]; then
gokhlayeh@186 1147 { echo "$PACKAGE"; cat files.list; } | awk '
gokhlayeh@186 1148 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
gokhlayeh@186 1149 fi
gokhlayeh@186 1150
gokhlayeh@186 1151 cd .. && rm -r "$pkg_files_dir"
gokhlayeh@186 1152
gokhlayeh@186 1153 cd $pkg_repository
gokhlayeh@186 1154 echo $(basename ${pkg%.tazpkg}) >> packages.list
gokhlayeh@186 1155 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
gokhlayeh@186 1156 echo "$package_md5" >> packages.md5
gokhlayeh@186 1157 unset package_md5
gokhlayeh@186 1158 }
gokhlayeh@186 1159
gokhlayeh@186 1160 source_receipt()
gokhlayeh@186 1161 {
gokhlayeh@186 1162 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
gokhlayeh@186 1163 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
gokhlayeh@186 1164 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
gokhlayeh@233 1165 src _pkg DESTDIR CONFIG_SITE
gokhlayeh@186 1166 . ${RECEIPT:-$PWD/receipt}
gokhlayeh@186 1167 }
gokhlayeh@186 1168
gokhlayeh@186 1169 packages_db_end()
gokhlayeh@186 1170 {
gokhlayeh@186 1171 cd $pkg_repository
gokhlayeh@186 1172 pkgs=$(wc -l packages.list | sed 's/ .*//')
gokhlayeh@186 1173 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
gokhlayeh@186 1174
gokhlayeh@186 1175 # If lists was updated it's generally needed to sort them well.
gokhlayeh@186 1176 if ! sort -c packages.list 2> /dev/null; then
gokhlayeh@186 1177 report step "Sorting packages lists"
gokhlayeh@186 1178 for file in packages.list packages.desc packages.equiv; do
gokhlayeh@186 1179 [ -f $file ] || continue
gokhlayeh@186 1180 sort -o $file $file
gokhlayeh@186 1181 done
gokhlayeh@186 1182 report end-step
gokhlayeh@186 1183 fi
gokhlayeh@186 1184
gokhlayeh@186 1185 # Dont log this because lzma always output error.
gokhlayeh@186 1186 lzma e files.list files.list.lzma
gokhlayeh@204 1187 rm -f files.list
gokhlayeh@204 1188 [ -f packages.equiv ] || touch packages.equiv
gokhlayeh@186 1189 }
gokhlayeh@186 1190
gokhlayeh@186 1191 ########################################################################
gokhlayeh@186 1192 # This section contains functions to generate wok database.
gokhlayeh@186 1193 ########################
gokhlayeh@186 1194
gokhlayeh@186 1195 gen_wok_db()
gokhlayeh@186 1196 {
gokhlayeh@204 1197 report step "Generating wok database"
gokhlayeh@186 1198 report open-bloc
gokhlayeh@204 1199 report step "Removing old files"
gokhlayeh@204 1200 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
gokhlayeh@204 1201 [ -f $file ] && rm $file
gokhlayeh@204 1202 done
gokhlayeh@186 1203 report step "Generating wok-wanted.txt"
gokhlayeh@204 1204 gen_wan_db
gokhlayeh@186 1205 report step "Generating wok-depends.txt"
gokhlayeh@204 1206 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
gokhlayeh@204 1207 $INCOMING_REPOSITORY/packages.desc | sort -u); do
gokhlayeh@186 1208 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@186 1209 if [ -s $RECEIPT ]; then
gokhlayeh@186 1210 source_receipt
gokhlayeh@186 1211 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
pankso@133 1212 fi
pascal@99 1213 done
gokhlayeh@215 1214 sort_db
gokhlayeh@204 1215 report close-bloc
gokhlayeh@204 1216 }
gokhlayeh@204 1217
gokhlayeh@204 1218 gen_wan_db()
gokhlayeh@204 1219 {
gokhlayeh@204 1220 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
gokhlayeh@204 1221 WANTED=
gokhlayeh@204 1222 source $RECEIPT
gokhlayeh@204 1223 [ "$WANTED" ] || continue
gokhlayeh@204 1224 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
gokhlayeh@204 1225 done
gokhlayeh@215 1226 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
gokhlayeh@204 1227 mv -f $tmp/wan_db $wan_db
gokhlayeh@204 1228 plan_regen_cookorder=yes
gokhlayeh@204 1229 else
gokhlayeh@204 1230 rm $tmp/wan_db
gokhlayeh@204 1231 fi
gokhlayeh@204 1232 }
gokhlayeh@204 1233
gokhlayeh@215 1234 update_wan_db()
gokhlayeh@215 1235 {
gokhlayeh@215 1236 local PACKAGE
gokhlayeh@215 1237 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
gokhlayeh@215 1238 fgrep $PACKAGE | cut -f1 -d ':'); do
gokhlayeh@215 1239 WANTED=
gokhlayeh@215 1240 source $RECEIPT
gokhlayeh@215 1241 [ "$WANTED" ] || continue
gokhlayeh@219 1242 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
gokhlayeh@215 1243 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
gokhlayeh@215 1244 sed "/^$PACKAGE\t/d" -i $wan_db
gokhlayeh@220 1245 echo "$wan_info" >> $wan_db
gokhlayeh@215 1246 plan_regen_cookorder=yes
gokhlayeh@215 1247 plan_sort_wandb=yes
gokhlayeh@215 1248 done
gokhlayeh@215 1249 }
gokhlayeh@215 1250
gokhlayeh@204 1251 update_dep_db()
gokhlayeh@204 1252 {
gokhlayeh@204 1253 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
gokhlayeh@215 1254 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
gokhlayeh@204 1255 sed "/^$PACKAGE\t/d" -i $dep_db
gokhlayeh@204 1256 echo "$dep_info" >> $dep_db
gokhlayeh@204 1257 plan_regen_cookorder=yes
gokhlayeh@204 1258 plan_sort_depdb=yes
pankso@28 1259 }
pankso@28 1260
gokhlayeh@186 1261 sort_db()
pascal@91 1262 {
gokhlayeh@186 1263 report step "Generating cookorder.txt"
gokhlayeh@186 1264 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
gokhlayeh@186 1265 grep -q ^$PACKAGE$'\t' $wan_db && continue
gokhlayeh@186 1266
gokhlayeh@186 1267 # Replace each BUILD_DEPENDS with a WANTED package by it's
gokhlayeh@186 1268 # WANTED package.
gokhlayeh@186 1269 replace_by_wanted()
gokhlayeh@186 1270 {
gokhlayeh@186 1271 for p in $BUILD_DEPENDS; do
gokhlayeh@186 1272 if grep -q ^$p$'\t' $wan_db; then
gokhlayeh@186 1273 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
gokhlayeh@186 1274 else
gokhlayeh@186 1275 echo -n $p' '
gokhlayeh@186 1276 fi
gokhlayeh@186 1277 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
gokhlayeh@186 1278 }
gokhlayeh@186 1279 echo -e $PACKAGE"\t $(replace_by_wanted) "
gokhlayeh@186 1280 done > $tmp/db
gokhlayeh@186 1281 while [ -s "$tmp/db" ]; do
gokhlayeh@186 1282 status=start
gokhlayeh@186 1283 for pkg in $(cut -f 1 $tmp/db); do
gokhlayeh@195 1284 if ! fgrep -q ' '$pkg' ' $tmp/db; then
gokhlayeh@186 1285 echo $pkg >> $tmp/cookorder
gokhlayeh@186 1286 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
gokhlayeh@186 1287 status=proceed
gokhlayeh@186 1288 fi
gokhlayeh@186 1289 done
gokhlayeh@186 1290 if [ "$status" = start ]; then
gokhlayeh@186 1291 cp -f $tmp/db /tmp/remain-depends.txt
gokhlayeh@186 1292 echo "Can't go further because there's depency(ies) loop(s). The remaining packages will be commentend in the cookorder and will be unbuild in case of major update until the problem is solved." >&2
gokhlayeh@186 1293 for blocked in $(cut -f 1 $tmp/db); do
gokhlayeh@186 1294 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
gokhlayeh@186 1295 done
gokhlayeh@186 1296 break
gokhlayeh@186 1297 fi
gokhlayeh@186 1298 done
gokhlayeh@186 1299 [ -s $tmp/cookorder ] || touch $tmp/cookorder
gokhlayeh@186 1300
gokhlayeh@186 1301 # The toolchain packages are moved in first position.
gokhlayeh@186 1302 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 1303 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
gokhlayeh@186 1304 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
gokhlayeh@186 1305 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
gokhlayeh@186 1306 sed "/^$pkg$/d" -i $tmp/cookorder
gokhlayeh@186 1307 done
gokhlayeh@186 1308
gokhlayeh@186 1309 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
gokhlayeh@204 1310 unset plan_regen_cookorder
gokhlayeh@186 1311 report end-step
pascal@91 1312 }
pascal@91 1313
gokhlayeh@186 1314 ########################################################################
gokhlayeh@186 1315 # SCAN CORE
gokhlayeh@186 1316 ########################
gokhlayeh@186 1317 # Include various scan core-functions. It's not intended to be used
gokhlayeh@186 1318 # directly : prefer scan wrappers in next section.
gokhlayeh@186 1319
gokhlayeh@186 1320 look_for_dep()
gokhlayeh@186 1321 {
gokhlayeh@186 1322 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@186 1323 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
gokhlayeh@186 1324 | cut -f 2
gokhlayeh@186 1325 else
gokhlayeh@186 1326 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
gokhlayeh@186 1327 cut -f 2
gokhlayeh@186 1328 fi
gokhlayeh@186 1329 }
gokhlayeh@186 1330
gokhlayeh@186 1331 look_for_bdep()
gokhlayeh@186 1332 {
gokhlayeh@186 1333 look_for_all
gokhlayeh@186 1334 }
gokhlayeh@186 1335
gokhlayeh@186 1336 look_for_all()
gokhlayeh@186 1337 {
gokhlayeh@186 1338 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@186 1339 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
gokhlayeh@186 1340 | cut -f 2,3 | sed 's/ / /'
gokhlayeh@186 1341 else
gokhlayeh@186 1342 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
gokhlayeh@186 1343 cut -f 2,3 | sed 's/ / /'
gokhlayeh@186 1344 fi
gokhlayeh@186 1345 }
gokhlayeh@186 1346
gokhlayeh@186 1347 look_for_rdep()
gokhlayeh@186 1348 {
gokhlayeh@195 1349 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
gokhlayeh@186 1350 if [ "$undigest" ]; then
gokhlayeh@195 1351 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
gokhlayeh@186 1352 if [ ! -f "WOK$/$rdep/receipt" ]; then
gokhlayeh@186 1353 echo "$rdep"
gokhlayeh@186 1354 fi
gokhlayeh@186 1355 done
gokhlayeh@186 1356 fi
gokhlayeh@186 1357 }
gokhlayeh@186 1358
gokhlayeh@186 1359 look_for_rbdep()
gokhlayeh@186 1360 {
gokhlayeh@195 1361 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
gokhlayeh@195 1362 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
gokhlayeh@186 1363 if [ "$undigest" ]; then
gokhlayeh@195 1364 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
gokhlayeh@195 1365 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
gokhlayeh@186 1366 if [ ! -f "WOK$/$rdep/receipt" ]; then
gokhlayeh@186 1367 echo "$rdep"
gokhlayeh@186 1368 fi
gokhlayeh@186 1369 done
gokhlayeh@186 1370 fi
gokhlayeh@186 1371 }
gokhlayeh@186 1372
gokhlayeh@186 1373 # Return WANTED if it exists.
gokhlayeh@186 1374 look_for_wanted()
gokhlayeh@186 1375 {
gokhlayeh@186 1376 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@186 1377 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
gokhlayeh@186 1378 else
gokhlayeh@186 1379 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
gokhlayeh@186 1380 fi
gokhlayeh@186 1381 }
gokhlayeh@186 1382
gokhlayeh@186 1383 # Return packages which wants PACKAGE.
gokhlayeh@186 1384 look_for_rwanted()
gokhlayeh@186 1385 {
gokhlayeh@186 1386 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
gokhlayeh@186 1387 if [ "$undigest" ]; then
gokhlayeh@186 1388 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
gokhlayeh@186 1389 if [ ! -f "$WOK/$rwanted/receipt" ]; then
gokhlayeh@186 1390 echo "$rwanted"
gokhlayeh@186 1391 fi
gokhlayeh@186 1392 done
gokhlayeh@186 1393 fi
gokhlayeh@186 1394 }
gokhlayeh@186 1395
gokhlayeh@186 1396 look_for_dev()
gokhlayeh@186 1397 {
gokhlayeh@223 1398 WANTED=$(look_for_wanted)
gokhlayeh@223 1399 if [ "$WANTED" ]; then
gokhlayeh@223 1400 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
gokhlayeh@223 1401 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
gokhlayeh@223 1402 else
gokhlayeh@223 1403 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
gokhlayeh@223 1404 fi
gokhlayeh@223 1405 fi
gokhlayeh@223 1406 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@223 1407 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
gokhlayeh@223 1408 else
gokhlayeh@223 1409 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
gokhlayeh@223 1410 fi
gokhlayeh@186 1411 }
gokhlayeh@186 1412
gokhlayeh@215 1413 with_dev()
gokhlayeh@215 1414 {
gokhlayeh@215 1415 for PACKAGE in $(cat); do
gokhlayeh@215 1416 echo $PACKAGE
gokhlayeh@215 1417 look_for_dev
gokhlayeh@215 1418 done
gokhlayeh@215 1419 }
gokhlayeh@215 1420
gokhlayeh@215 1421 with_wanted()
gokhlayeh@215 1422 {
gokhlayeh@215 1423 for PACKAGE in $(cat); do
gokhlayeh@215 1424 echo $PACKAGE
gokhlayeh@215 1425 look_for_wanted
gokhlayeh@215 1426 done
gokhlayeh@215 1427 }
gokhlayeh@215 1428
gokhlayeh@215 1429 use_wanted()
gokhlayeh@215 1430 {
gokhlayeh@215 1431 for input in $(cat); do
gokhlayeh@215 1432 { grep ^$input$'\t' $wan_db || echo $input
gokhlayeh@215 1433 } | sed 's/.*\t//'
gokhlayeh@215 1434 done
gokhlayeh@215 1435 }
gokhlayeh@215 1436
gokhlayeh@186 1437 ########################################################################
gokhlayeh@186 1438 # SCAN
gokhlayeh@186 1439 ########################
gokhlayeh@186 1440 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
gokhlayeh@186 1441 # Option in command line (must be first arg) :
gokhlayeh@186 1442 # --look_for=bdep/rbdep - Look for depends or reverse depends.
gokhlayeh@186 1443 # --with_dev - Add development packages (*-dev) in the result.
gokhlayeh@186 1444 # --with_wanted - Add package+reverse wanted in the result.
gokhlayeh@186 1445 # --with_args - Include packages in argument in the result.
gokhlayeh@186 1446
gokhlayeh@186 1447 scan()
gokhlayeh@186 1448 {
gokhlayeh@186 1449 # Get packages in argument.
gokhlayeh@223 1450 local PACKAGE WANTED pkg_list=
gokhlayeh@186 1451 for arg in $@; do
gokhlayeh@186 1452 [ "$arg" = "${arg#--}" ] || continue
gokhlayeh@186 1453 pkg_list="$pkg_list $arg"
gokhlayeh@186 1454 done
gokhlayeh@204 1455
gokhlayeh@186 1456 # Get options.
gokhlayeh@186 1457 [ "$pkg_list" ] || return
gokhlayeh@186 1458 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
gokhlayeh@215 1459 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
gokhlayeh@186 1460 get_options
gokhlayeh@186 1461
gokhlayeh@186 1462 # Cooklist is a special case where we need to modify a little
gokhlayeh@186 1463 # scan behavior
gokhlayeh@186 1464 if [ "$cooklist" ]; then
gokhlayeh@204 1465 gen_wan_db
gokhlayeh@204 1466 look_for=all && with_args=yes && with_dev= && with_wanted=
gokhlayeh@204 1467 filter=use_wanted
gokhlayeh@204 1468 append_to_dep()
gokhlayeh@204 1469 {
gokhlayeh@204 1470 check_for_commit && echo $PACKAGE >> $tmp/dep
gokhlayeh@204 1471 }
gokhlayeh@204 1472 else
gokhlayeh@204 1473 append_to_dep()
gokhlayeh@204 1474 {
gokhlayeh@204 1475 echo $PACKAGE >> $tmp/dep
gokhlayeh@204 1476 }
gokhlayeh@186 1477 fi
gokhlayeh@215 1478
gokhlayeh@204 1479 [ "$with_dev" ] && filter=with_dev
gokhlayeh@204 1480 [ "$with_wanted" ] && filter=with_wanted
gokhlayeh@204 1481 if [ "$filter" ]; then
gokhlayeh@204 1482 pkg_list=$(echo $pkg_list | $filter)
gokhlayeh@204 1483 scan_pkg()
gokhlayeh@204 1484 {
gokhlayeh@204 1485 look_for_$look_for | $filter
gokhlayeh@204 1486 }
gokhlayeh@204 1487 else
gokhlayeh@204 1488 scan_pkg()
gokhlayeh@204 1489 {
gokhlayeh@204 1490 look_for_$look_for
gokhlayeh@204 1491 }
gokhlayeh@204 1492 fi
gokhlayeh@215 1493 touch $tmp/dep
gokhlayeh@204 1494 for PACKAGE in $pkg_list; do
gokhlayeh@204 1495 [ "$with_args" ] && append_to_dep
gokhlayeh@204 1496 scan_pkg
gokhlayeh@186 1497 done | tr ' ' '\n' | sort -u > $tmp/list
gokhlayeh@186 1498 [ "$look_for" = bdep ] && look_for=dep
gokhlayeh@186 1499 while [ -s $tmp/list ]; do
gokhlayeh@186 1500 PACKAGE=$(sed 1!d $tmp/list)
gokhlayeh@186 1501 sed 1d -i $tmp/list
gokhlayeh@204 1502 append_to_dep
gokhlayeh@204 1503 for pkg in $(scan_pkg); do
gokhlayeh@204 1504 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
gokhlayeh@204 1505 echo $pkg >> $tmp/list
gokhlayeh@186 1506 fi
gokhlayeh@186 1507 done
gokhlayeh@186 1508 done
gokhlayeh@204 1509 if [ "$cooklist" ]; then
gokhlayeh@204 1510 mv $tmp/dep $tmp/cooklist
gokhlayeh@215 1511 else
gokhlayeh@204 1512 cat $tmp/dep | sort -u
gokhlayeh@186 1513 fi
gokhlayeh@204 1514 rm -f $tmp/dep $tmp/list
gokhlayeh@186 1515 }
gokhlayeh@186 1516
gokhlayeh@186 1517 ########################################################################
gokhlayeh@186 1518 # This section contains functions to check package repository and
gokhlayeh@186 1519 # find which packages to cook.
gokhlayeh@186 1520 ########################
gokhlayeh@186 1521
gokhlayeh@186 1522 check_for_commit()
gokhlayeh@186 1523 {
gokhlayeh@204 1524 if ! check_for_pkg_in_wok; then
gokhlayeh@204 1525 [ "$?" = 2 ] && return 1
gokhlayeh@204 1526 return
gokhlayeh@204 1527 fi
gokhlayeh@204 1528 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@204 1529 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@186 1530 source_receipt
gokhlayeh@204 1531
gokhlayeh@186 1532 # We use md5 of cooking stuff in the packaged receipt to check
gokhlayeh@186 1533 # commit. We look consecutively in 3 different locations :
gokhlayeh@204 1534 # - in the wok/PACKAGE/taz/* folder
gokhlayeh@186 1535 # - in the receipt in the package in incoming repository
gokhlayeh@186 1536 # - in the receipt in the package in packages repository
gokhlayeh@186 1537 # If md5sum match, there's no commit.
gokhlayeh@186 1538 check_for_commit_using_md5sum()
gokhlayeh@186 1539 {
gokhlayeh@186 1540 if [ ! -f $WOK/$PACKAGE/md5 ]; then
gokhlayeh@186 1541 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
gokhlayeh@186 1542 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
gokhlayeh@186 1543 cd $WOK/$PACKAGE
gokhlayeh@186 1544 fi
gokhlayeh@204 1545
gokhlayeh@186 1546 if [ -s md5 ]; then
gokhlayeh@186 1547 if md5sum -cs md5; then
gokhlayeh@204 1548
gokhlayeh@204 1549 # If md5sum check if ok, check for new/missing files in
gokhlayeh@204 1550 # cooking stuff.
gokhlayeh@204 1551 for file in $([ -f receipt ] && echo receipt; \
gokhlayeh@204 1552 [ -f description.txt ] && echo description.txt; \
gokhlayeh@204 1553 [ -d stuff ] && find stuff); do
gokhlayeh@204 1554 if ! fgrep -q " $file" md5; then
gokhlayeh@186 1555 set_commited
gokhlayeh@186 1556 fi
gokhlayeh@186 1557 done
gokhlayeh@186 1558 else
gokhlayeh@186 1559 set_commited
gokhlayeh@186 1560 fi
gokhlayeh@186 1561 else
gokhlayeh@204 1562 set_commited
gokhlayeh@186 1563 fi
gokhlayeh@186 1564 }
gokhlayeh@186 1565 set_commited()
gokhlayeh@186 1566 {
gokhlayeh@204 1567 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
gokhlayeh@204 1568 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
gokhlayeh@186 1569 gen_cookmd5
gokhlayeh@204 1570 update_dep_db
gokhlayeh@186 1571 }
gokhlayeh@195 1572 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
gokhlayeh@186 1573 if [ -f $WOK/$PACKAGE/md5 ]; then
gokhlayeh@186 1574 cd $WOK/$PACKAGE
gokhlayeh@186 1575 check_for_commit_using_md5sum
gokhlayeh@186 1576 elif [ "$taz_dir" ]; then
gokhlayeh@186 1577 cd $taz_dir
gokhlayeh@186 1578 check_for_commit_using_md5sum
gokhlayeh@186 1579 else
gokhlayeh@195 1580 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
gokhlayeh@195 1581 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
gokhlayeh@186 1582 if [ "$pkg" ]; then
gokhlayeh@186 1583 get_pkg_files $pkg
gokhlayeh@186 1584 check_for_commit_using_md5sum
gokhlayeh@186 1585 rm -r $pkg_files_dir
gokhlayeh@204 1586 else
gokhlayeh@204 1587 set_commited
gokhlayeh@186 1588 fi
gokhlayeh@186 1589 fi
gokhlayeh@204 1590 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
gokhlayeh@186 1591 done
gokhlayeh@204 1592 return
gokhlayeh@186 1593 }
gokhlayeh@186 1594
gokhlayeh@186 1595 gen_cook_list()
gokhlayeh@186 1596 {
gokhlayeh@204 1597 report step "Scanning wok"
gokhlayeh@204 1598 if [ "$pkg" ]; then
gokhlayeh@204 1599 scan $pkg --cooklist
gokhlayeh@204 1600 else
gokhlayeh@204 1601 scan `cat $cooklist` --cooklist
gokhlayeh@204 1602 fi
gokhlayeh@204 1603 report end-step
gokhlayeh@209 1604
gokhlayeh@209 1605 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
gokhlayeh@215 1606 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
gokhlayeh@215 1607 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
gokhlayeh@215 1608 plan_regen_cookorder=yes
gokhlayeh@215 1609 fi
gokhlayeh@209 1610
gokhlayeh@209 1611 # Core toolchain should not be cooked unless cook-toolchain is used.
gokhlayeh@209 1612 if ! [ -f /etc/config.site.tmptoolchain ] ; then
gokhlayeh@209 1613 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
gokhlayeh@209 1614 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
gokhlayeh@209 1615 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
gokhlayeh@209 1616 done
gokhlayeh@209 1617 fi
gokhlayeh@209 1618
gokhlayeh@186 1619 if [ -s $PACKAGES_REPOSITORY/commit ]; then
gokhlayeh@186 1620 cd $PACKAGES_REPOSITORY
gokhlayeh@186 1621 for PACKAGE in $(cat commit); do
gokhlayeh@186 1622 WANTED="$(look_for_wanted)"
gokhlayeh@186 1623 if [ "$WANTED" ]; then
gokhlayeh@204 1624 grep -q ^$WANTED$ broken cooklist blocked commit && continue
gokhlayeh@186 1625 fi
gokhlayeh@204 1626 grep -q ^$PACKAGE$ blocked cooklist && continue
gokhlayeh@204 1627 echo $PACKAGE >> cooklist
gokhlayeh@186 1628 done
gokhlayeh@186 1629 fi
gokhlayeh@204 1630 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@204 1631 [ "$plan_regen_cookorder" ] && sort_db
gokhlayeh@186 1632 sort_cooklist
gokhlayeh@186 1633 }
gokhlayeh@186 1634
gokhlayeh@186 1635 sort_cooklist()
gokhlayeh@186 1636 {
gokhlayeh@215 1637 report step "Sorting cooklist"
gokhlayeh@204 1638 if [ -f "$tmp/checked" ]; then
gokhlayeh@204 1639 rm -f $tmp/cooklist
gokhlayeh@204 1640 cat $tmp/checked | while read PACKAGE; do
gokhlayeh@204 1641 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
gokhlayeh@204 1642 echo $PACKAGE >> $tmp/cooklist
gokhlayeh@204 1643 done
gokhlayeh@209 1644 elif ! [ "$COMMAND" = gen-cooklist ]; then
gokhlayeh@209 1645 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
gokhlayeh@209 1646 sed "/^$PACKAGE/d" -i $tmp/cooklist
gokhlayeh@209 1647 done
gokhlayeh@204 1648 fi
gokhlayeh@215 1649
gokhlayeh@204 1650 for PACKAGE in $(cat $tmp/cooklist); do
gokhlayeh@204 1651 WANTED="$(look_for_wanted)"
gokhlayeh@204 1652 [ "$WANTED" ] || continue
gokhlayeh@215 1653 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
gokhlayeh@186 1654 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 1655 elif [ ! -d $WOK/$WANTED/install ]; then
gokhlayeh@204 1656 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 1657 echo $WANTED >> $tmp/cooklist
gokhlayeh@186 1658 fi
gokhlayeh@186 1659 done
gokhlayeh@186 1660
gokhlayeh@204 1661 # Use cookorder.txt to sort cooklist.
gokhlayeh@204 1662 if [ -s $tmp/cooklist ]; then
gokhlayeh@204 1663 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
gokhlayeh@204 1664 if grep -q ^$PACKAGE$ $tmp/cooklist; then
gokhlayeh@204 1665 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 1666 echo $PACKAGE >> $tmp/cooklist.tmp
gokhlayeh@204 1667 fi
gokhlayeh@204 1668 done
gokhlayeh@204 1669
gokhlayeh@204 1670 # Remaining packages in cooklist are thoses without compile_rules.
gokhlayeh@204 1671 # They can be cooked first in any order.
gokhlayeh@204 1672 if [ -f $tmp/cooklist.tmp ]; then
gokhlayeh@204 1673 cat $tmp/cooklist.tmp >> $tmp/cooklist
gokhlayeh@204 1674 rm $tmp/cooklist.tmp
gokhlayeh@204 1675 fi
gokhlayeh@204 1676
gokhlayeh@204 1677 cat $tmp/cooklist
gokhlayeh@204 1678 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
gokhlayeh@204 1679 cat $tmp/cooklist > $cooklist
gokhlayeh@204 1680 fi
gokhlayeh@204 1681
gokhlayeh@186 1682 report end-step
gokhlayeh@186 1683 }
gokhlayeh@186 1684
gokhlayeh@186 1685 check_for_incoming()
gokhlayeh@186 1686 {
gokhlayeh@204 1687 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
gokhlayeh@204 1688 echo "No packages in $INCOMING_REPOSITORY."
gokhlayeh@204 1689 return; }
gokhlayeh@204 1690 if [ -s $PACKAGES_REPOSITORY/broken ]; then
gokhlayeh@204 1691 echo "Don't move incoming packages to main repository because theses ones are broken:
gokhlayeh@204 1692 $(cat $PACKAGES_REPOSITORY/broken)" >&2
gokhlayeh@204 1693 return
gokhlayeh@186 1694 fi
gokhlayeh@204 1695 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
gokhlayeh@204 1696 echo "Don't move incoming packages to main repository because some of them need to be cooked:
gokhlayeh@204 1697 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
gokhlayeh@204 1698 return
gokhlayeh@204 1699 fi
gokhlayeh@215 1700 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
gokhlayeh@214 1701 if ! [ "$forced" ]; then
gokhlayeh@214 1702 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@214 1703 gen_cook_list
gokhlayeh@214 1704 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
gokhlayeh@214 1705 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
gokhlayeh@214 1706 return
gokhlayeh@214 1707 fi
gokhlayeh@204 1708 fi
gokhlayeh@204 1709 report step "Moving incoming packages to main repository"
gokhlayeh@204 1710 unset EXTRAVERSION
gokhlayeh@215 1711 for PACKAGE in $pkg; do
gokhlayeh@186 1712 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
gokhlayeh@204 1713 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
gokhlayeh@186 1714 remove_previous_package $PACKAGES_REPOSITORY
gokhlayeh@186 1715 remove_previous_tarball
gokhlayeh@204 1716 echo "Moving $PACKAGE..."
gokhlayeh@204 1717 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
gokhlayeh@204 1718 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
gokhlayeh@204 1719 done
gokhlayeh@204 1720 report end-step
gokhlayeh@204 1721 for file in packages.list packages.equiv packages.md5 packages.desc \
gokhlayeh@204 1722 packages.txt; do
gokhlayeh@204 1723 echo -n "" > $INCOMING_REPOSITORY/$file
gokhlayeh@204 1724 done
gokhlayeh@204 1725 rm -r $INCOMING_REPOSITORY/files.list.lzma
gokhlayeh@186 1726 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
gokhlayeh@186 1727 }
gokhlayeh@186 1728
gokhlayeh@186 1729 ########################################################################
gokhlayeh@186 1730 # TAZWOK MAIN FUNCTIONS
gokhlayeh@186 1731 ########################
gokhlayeh@186 1732
gokhlayeh@186 1733 clean()
gokhlayeh@186 1734 {
gokhlayeh@186 1735 cd $WOK/$PACKAGE
gokhlayeh@186 1736 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
gokhlayeh@186 1737 -e ^stuff$ || return
gokhlayeh@186 1738
gokhlayeh@186 1739 report step "Cleaning $PACKAGE"
gokhlayeh@186 1740 # Check for clean_wok function.
gokhlayeh@186 1741 if grep -q ^clean_wok $RECEIPT; then
gokhlayeh@186 1742 clean_wok
gokhlayeh@186 1743 fi
gokhlayeh@186 1744 # Clean should only have a receipt, stuff and optional desc.
gokhlayeh@186 1745 for f in `ls .`
gokhlayeh@186 1746 do
gokhlayeh@186 1747 case $f in
gokhlayeh@186 1748 receipt|stuff|description.txt)
gokhlayeh@186 1749 continue ;;
gokhlayeh@186 1750 *)
gokhlayeh@186 1751 echo "Removing: $f"
gokhlayeh@186 1752 rm -rf $f
gokhlayeh@186 1753 esac
gokhlayeh@186 1754 done
gokhlayeh@186 1755 report end-step
gokhlayeh@186 1756 }
gokhlayeh@186 1757
gokhlayeh@186 1758 # Configure and make a package with the receipt.
gokhlayeh@186 1759 compile_package()
gokhlayeh@186 1760 {
gokhlayeh@186 1761 check_for_package_on_cmdline
gokhlayeh@186 1762
gokhlayeh@186 1763 # Include the receipt to get all needed variables and functions
gokhlayeh@186 1764 # and cd into the work directory to start the work.
gokhlayeh@186 1765 check_for_receipt
gokhlayeh@186 1766 source_receipt
gokhlayeh@186 1767
gokhlayeh@186 1768 # Log the package name and date.
gokhlayeh@186 1769 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
gokhlayeh@186 1770 echo "package $PACKAGE (compile)" >> $LOG
gokhlayeh@186 1771
gokhlayeh@186 1772 # Set wanted $src variable to help compiling.
gokhlayeh@186 1773 [ ! "$src" ] && set_src_path
gokhlayeh@186 1774 check_for_build_depends || return 1
gokhlayeh@186 1775 check_for_wanted
gokhlayeh@186 1776 unset target
gokhlayeh@186 1777 check_for_tarball && check_for_compile_rules
gokhlayeh@186 1778 }
gokhlayeh@186 1779
gokhlayeh@186 1780 # Cook command also include all features to manage lists which keep
gokhlayeh@186 1781 # track of wok/packages state.
gokhlayeh@186 1782 cook()
gokhlayeh@186 1783 {
gokhlayeh@186 1784 cook_code=
gokhlayeh@186 1785 set_common_path
gokhlayeh@186 1786 check_for_receipt
gokhlayeh@186 1787 source_receipt
gokhlayeh@186 1788
gokhlayeh@186 1789 # Define log path and start report.
gokhlayeh@186 1790 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
gokhlayeh@186 1791 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
gokhlayeh@186 1792 report step "Cooking $PACKAGE"
gokhlayeh@186 1793 report open-bloc
gokhlayeh@186 1794
gokhlayeh@186 1795 clean $PACKAGE
gokhlayeh@186 1796 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@186 1797
gokhlayeh@186 1798 if compile_package; then
gokhlayeh@215 1799 remove_src
gokhlayeh@186 1800 refresh_packages_from_compile
gokhlayeh@186 1801 gen_package
gokhlayeh@186 1802
gokhlayeh@186 1803 # Update packages-incoming repository.
gokhlayeh@186 1804 store_pkgname=$PACKAGE
gokhlayeh@186 1805 pkg_repository=$INCOMING_REPOSITORY
gokhlayeh@186 1806 update_packages_db
gokhlayeh@186 1807
gokhlayeh@186 1808 PACKAGE=$store_pkgname
gokhlayeh@186 1809 unset store_pkgname
gokhlayeh@186 1810
gokhlayeh@186 1811 # Upgrade to cooked packages if it was previously installed.
gokhlayeh@186 1812 report step "Look for package(s) to upgrade"
gokhlayeh@186 1813 for pkg in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@186 1814 if [ -d $INSTALLED/$pkg ]; then
gokhlayeh@186 1815 tazpkg get-install $pkg --forced
gokhlayeh@186 1816 fi
gokhlayeh@186 1817 done
gokhlayeh@186 1818 report end-step
gokhlayeh@186 1819 else
gokhlayeh@186 1820
gokhlayeh@186 1821 # Set package as broken.
gokhlayeh@186 1822 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
gokhlayeh@186 1823 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
gokhlayeh@186 1824 fi
gokhlayeh@186 1825 gen_cookmd5
gokhlayeh@186 1826 cook_code=1
gokhlayeh@186 1827 fi
gokhlayeh@186 1828
gokhlayeh@186 1829 # Remove build_depends in cook mode (if in cooklist, it's done when
gokhlayeh@186 1830 # checking build_depends of next package and we remove only unneeded
gokhlayeh@186 1831 # packages to keep chroot minimal and gain some time).
gokhlayeh@210 1832 if [ "$COMMAND" = cook ]; then
gokhlayeh@210 1833 remove_build_depends $MISSING_PACKAGE
gokhlayeh@210 1834 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@210 1835 fi
gokhlayeh@210 1836
gokhlayeh@186 1837 # Regen the cooklist if it was planned and command is not cook.
gokhlayeh@186 1838 [ "$regen_cooklist" ] && unset regen_cooklist && \
gokhlayeh@186 1839 [ "$COMMAND" != cook ] && sort_cooklist
gokhlayeh@186 1840
gokhlayeh@186 1841 # Some hacks to set the bloc & function status as failed if cook was
gokhlayeh@186 1842 # failed.
gokhlayeh@186 1843 report_return_code=$cook_code
gokhlayeh@186 1844 report close-bloc
gokhlayeh@186 1845 report end-sublog
gokhlayeh@186 1846 return $cook_code
gokhlayeh@186 1847 }
gokhlayeh@186 1848
gokhlayeh@186 1849 cook_list()
gokhlayeh@186 1850 {
gokhlayeh@204 1851 if [ -s $tmp/cooklist ]; then
gokhlayeh@204 1852 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@204 1853 # Note : options -main variables- are automatically keeped by
gokhlayeh@204 1854 # the sub-applications tazchroot/tazwok; as well as report data.
gokhlayeh@204 1855 cd $LOCAL_REPOSITORY
gokhlayeh@204 1856 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@204 1857 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
gokhlayeh@204 1858 return
gokhlayeh@204 1859 fi
gokhlayeh@204 1860 while [ -s $tmp/cooklist ]; do
gokhlayeh@204 1861 PACKAGE=$(sed 1!d $tmp/cooklist)
gokhlayeh@204 1862 cook
gokhlayeh@204 1863 done
gokhlayeh@204 1864 remove_build_depends $MISSING_PACKAGE $remove_later
gokhlayeh@210 1865 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@204 1866 else
gokhlayeh@186 1867 echo "Nothing to cook."
gokhlayeh@186 1868 return
gokhlayeh@186 1869 fi
gokhlayeh@186 1870 }
gokhlayeh@186 1871
gokhlayeh@186 1872 configure_tazchroot()
gokhlayeh@186 1873 {
gokhlayeh@190 1874 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
gokhlayeh@186 1875 # Tazchroot configuration file - created by tazwok.
gokhlayeh@186 1876
gokhlayeh@186 1877 # Default chroot path
gokhlayeh@186 1878 SLITAZ_DIR=$SLITAZ_DIR
gokhlayeh@186 1879 SLITAZ_VERSION=$SLITAZ_VERSION
gokhlayeh@186 1880 $( [ "$undigest" ] && echo "undigest=$undigest" )
gokhlayeh@186 1881 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
gokhlayeh@186 1882 chroot_dir=\$LOCAL_REPOSITORY/chroot
gokhlayeh@186 1883
gokhlayeh@186 1884 # Default scripts path (theses scripts are added in the
gokhlayeh@186 1885 # $chroot_dir/usr/bin and can be called with tazchroot script)
gokhlayeh@186 1886 script_dir=/var/lib/tazchroot
gokhlayeh@186 1887
gokhlayeh@186 1888 # List of directories to mount.
gokhlayeh@192 1889 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
gokhlayeh@186 1890 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
gokhlayeh@186 1891
gokhlayeh@186 1892 create_chroot()
gokhlayeh@186 1893 {
gokhlayeh@186 1894 mkdir -p \$chroot_dir
gokhlayeh@186 1895 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
gokhlayeh@186 1896 tazpkg get-install \$pkg --root="\$chroot_dir"
gokhlayeh@186 1897 done
gokhlayeh@186 1898
gokhlayeh@186 1899 # Store list of installed packages needed by cleanchroot.
gokhlayeh@194 1900 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
gokhlayeh@186 1901
gokhlayeh@186 1902 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
gokhlayeh@186 1903 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
gokhlayeh@186 1904 -i \$chroot_dir/etc/slitaz/slitaz.conf
gokhlayeh@186 1905 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
gokhlayeh@186 1906 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
gokhlayeh@186 1907 }
gokhlayeh@186 1908
gokhlayeh@186 1909 mount_chroot()
gokhlayeh@186 1910 {
gokhlayeh@186 1911 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
gokhlayeh@194 1912 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
gokhlayeh@194 1913 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
gokhlayeh@194 1914 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
gokhlayeh@194 1915 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
gokhlayeh@194 1916 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
gokhlayeh@194 1917 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
gokhlayeh@186 1918 mount -t proc proc \$chroot_dir/proc
gokhlayeh@186 1919 mount -t sysfs sysfs \$chroot_dir/sys
gokhlayeh@186 1920 mount -t devpts devpts \$chroot_dir/dev/pts
gokhlayeh@186 1921 mount -t tmpfs shm \$chroot_dir/dev/shm
gokhlayeh@186 1922 for dir in \$list_dir; do
gokhlayeh@186 1923 mkdir -p \$dir \$chroot_dir\$dir
gokhlayeh@186 1924 mount \$dir \$chroot_dir\$dir
gokhlayeh@186 1925 done
gokhlayeh@186 1926 }
gokhlayeh@186 1927
gokhlayeh@186 1928 umount_chroot()
gokhlayeh@186 1929 {
gokhlayeh@186 1930 for dir in \$list_dir; do
gokhlayeh@186 1931 umount \$chroot_dir\$dir
gokhlayeh@186 1932 done
gokhlayeh@186 1933 umount \$chroot_dir/dev/shm
gokhlayeh@186 1934 umount \$chroot_dir/dev/pts
gokhlayeh@186 1935 umount \$chroot_dir/sys
gokhlayeh@186 1936 umount \$chroot_dir/proc
gokhlayeh@186 1937 }
gokhlayeh@186 1938 EOF
gokhlayeh@186 1939 }
gokhlayeh@186 1940
gokhlayeh@186 1941 ########################################################################
gokhlayeh@186 1942 ######################### END OF NEW FUNCTIONS #########################
gokhlayeh@186 1943 ########################################################################
gokhlayeh@186 1944
pascal@111 1945 # List packages providing a virtual package
pascal@111 1946 whoprovide()
pascal@111 1947 {
pascal@111 1948 local i;
gokhlayeh@195 1949 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
pascal@111 1950 . $i
pascal@111 1951 case " $PROVIDE " in
pascal@111 1952 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
pascal@111 1953 esac
pascal@111 1954 done
pascal@111 1955 }
pascal@111 1956
gokhlayeh@186 1957 ########################################################################
gokhlayeh@186 1958 # TAZWOK COMMANDS
gokhlayeh@186 1959 ########################
pankso@7 1960
pankso@7 1961 case "$COMMAND" in
pankso@7 1962 stats)
paul@166 1963 # Tazwok general statistics from the wok config file.
pankso@7 1964 #
gokhlayeh@186 1965 get_tazwok_config
gokhlayeh@186 1966 echo -e "\n\033[1mTazwok configuration statistics\033[0m
pankso@7 1967 ================================================================================
pankso@7 1968 Wok directory : $WOK
pankso@7 1969 Packages repository : $PACKAGES_REPOSITORY
gokhlayeh@186 1970 Incoming repository : $INCOMING_REPOSITORY
pankso@7 1971 Sources repository : $SOURCES_REPOSITORY
gokhlayeh@186 1972 Log directory : $LOCAL_REPOSITORY/log
pankso@7 1973 Packages in the wok : `ls -1 $WOK | wc -l`
pankso@16 1974 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
gokhlayeh@186 1975 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
gokhlayeh@186 1976 ================================================================================\n"
gokhlayeh@186 1977 ;;
pankso@133 1978 edit)
gokhlayeh@186 1979 get_tazwok_config
pankso@133 1980 check_for_package_on_cmdline
pankso@133 1981 check_for_receipt
gokhlayeh@186 1982 $EDITOR $WOK/$PACKAGE/receipt
gokhlayeh@186 1983 ;;
pascal@98 1984 build-depends)
gokhlayeh@186 1985 # List dependencies to rebuild wok, or only a package
gokhlayeh@186 1986 get_tazwok_config
gokhlayeh@215 1987 report(){ : ; }
gokhlayeh@186 1988 if [ "$PACKAGE" = toolchain-cooklist ]; then
gokhlayeh@186 1989 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 1990 --cooklist
gokhlayeh@186 1991 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
gokhlayeh@186 1992 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 1993 --look_for=dep --with_dev --with_args
gokhlayeh@186 1994 else
gokhlayeh@186 1995 check_for_package_on_cmdline
gokhlayeh@186 1996 scan $PACKAGE --look_for=bdep --with_dev
gokhlayeh@186 1997 fi
gokhlayeh@186 1998 ;;
gokhlayeh@186 1999 gen-cooklist)
gokhlayeh@215 2000 check_root
gokhlayeh@204 2001 get_options_list="pkg"
gokhlayeh@186 2002 get_tazwok_config
gokhlayeh@215 2003 report(){ : ; }
gokhlayeh@204 2004 if ! [ "$pkg" ]; then
gokhlayeh@204 2005 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
gokhlayeh@186 2006 fi
gokhlayeh@204 2007 forced=yes
gokhlayeh@204 2008 gen_cook_list
gokhlayeh@186 2009 ;;
pascal@119 2010 check-depends)
gokhlayeh@186 2011 # Check package depends /!\
gokhlayeh@186 2012 get_tazwok_config
pascal@119 2013 echo ""
paul@121 2014 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
pascal@119 2015 ================================================================================"
pascal@119 2016 TMPDIR=/tmp/tazwok$$
pascal@119 2017 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
pascal@119 2018
pascal@119 2019 # Build ALL_DEPENDS variable
pascal@119 2020 scan_dep()
pascal@119 2021 {
pascal@119 2022 local i
pascal@119 2023 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
pascal@128 2024 for i in $DEPENDS $SUGGESTED ; do
pascal@119 2025 case " $ALL_DEPENDS " in
pascal@119 2026 *\ $i\ *) continue;;
pascal@119 2027 esac
pascal@120 2028 [ -d $WOK/$i ] || {
pascal@120 2029 ALL_DEPENDS="$ALL_DEPENDS$i "
pascal@120 2030 continue
pascal@120 2031 }
pascal@128 2032 DEPENDS=""
pascal@128 2033 SUGGESTED=""
pascal@119 2034 . $WOK/$i/receipt
pascal@119 2035 scan_dep
pascal@119 2036 done
pascal@119 2037 }
pankso@133 2038
pascal@119 2039 # Check for ELF file
pascal@119 2040 is_elf()
pascal@119 2041 {
pascal@119 2042 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
pascal@119 2043 = "ELF" ]
pascal@119 2044 }
pascal@119 2045
pascal@119 2046 # Print shared library dependencies
pascal@119 2047 ldd()
pascal@119 2048 {
pascal@130 2049 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
pascal@119 2050 }
pascal@119 2051
pascal@119 2052 mkdir $TMPDIR
pascal@119 2053 cd $TMPDIR
pascal@140 2054 for i in $LOCALSTATE/files.list.lzma \
pascal@140 2055 $LOCALSTATE/undigest/*/files.list.lzma ; do
pascal@119 2056 [ -f $i ] && lzma d $i -so >> files.list
pascal@119 2057 done
pascal@119 2058 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
pascal@119 2059 tazpkg extract $pkg > /dev/null 2>&1
pascal@119 2060 . */receipt
pascal@119 2061 ALL_DEPENDS="$DEFAULT_DEPENDS "
pascal@119 2062 scan_dep
pascal@119 2063 find */fs -type f | while read file ; do
pascal@119 2064 is_elf $file || continue
pascal@119 2065 case "$file" in
pascal@119 2066 *.o|*.ko|*.ko.gz) continue;;
pascal@119 2067 esac
pascal@119 2068 ldd $file | while read lib rem; do
pascal@119 2069 case "$lib" in
pascal@128 2070 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
pascal@119 2071 continue;;
pascal@119 2072 esac
gokhlayeh@195 2073 for dep in $(fgrep $lib files.list | cut -d: -f1); do
pascal@119 2074 case " $ALL_DEPENDS " in
pascal@119 2075 *\ $dep\ *) continue 2;;
pascal@119 2076 esac
gokhlayeh@195 2077 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
pascal@128 2078 case " $ALL_DEPENDS " in
pascal@129 2079 *\ $vdep\ *) continue 3;;
pascal@128 2080 esac
pascal@128 2081 done
pascal@119 2082 done
pascal@128 2083 [ -n "$dep" ] || dep="UNKNOWN"
pascal@119 2084 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
pascal@119 2085 done
pascal@119 2086 done
pascal@119 2087 rm -rf */
pascal@119 2088 done
pascal@119 2089 cd /tmp
pascal@119 2090 rm -rf $TMPDIR
gokhlayeh@186 2091 ;;
pascal@76 2092 check)
paul@154 2093 # Check wok consistency
gokhlayeh@186 2094 get_tazwok_config
pascal@76 2095 echo ""
pascal@76 2096 echo -e "\033[1mWok and packages checking\033[0m
pascal@76 2097 ================================================================================"
pascal@77 2098 cd $WOK
pascal@77 2099 for pkg in $(ls)
pascal@76 2100 do
pascal@76 2101 [ -f $pkg/receipt ] || continue
gokhlayeh@186 2102 RECEIPT= $pkg/receipt
gokhlayeh@186 2103 source_receipt
gokhlayeh@186 2104 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
gokhlayeh@186 2105 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
gokhlayeh@186 2106 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
gokhlayeh@186 2107 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
gokhlayeh@186 2108 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
pascal@97 2109 if [ -n "$WANTED" ]; then
pascal@97 2110 if [ ! -f $WANTED/receipt ]; then
gokhlayeh@186 2111 echo "Package $PACKAGE wants unknown $WANTED package" >&2
pascal@97 2112 else
pascal@97 2113 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
pascal@103 2114 if [ "$VERSION" = "$WANTED" ]; then
pascal@103 2115 # BASEVERSION is computed in receipt
gokhlayeh@195 2116 fgrep -q '_pkg=' $pkg/receipt &&
pascal@103 2117 BASEVERSION=$VERSION
pascal@103 2118 fi
pascal@97 2119 if [ "$VERSION" != "$BASEVERSION" ]; then
gokhlayeh@186 2120 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
pascal@97 2121 fi
pascal@97 2122 fi
pascal@97 2123 fi
pascal@97 2124
pascal@94 2125 if [ -n "$CATEGORY" ]; then
pascal@94 2126 case " $(echo $CATEGORIES) " in
pascal@94 2127 *\ $CATEGORY\ *);;
gokhlayeh@186 2128 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
pascal@94 2129 esac
pascal@94 2130 else
gokhlayeh@186 2131 echo"Package $PACKAGE has no CATEGORY" >&2
pascal@94 2132 fi
gokhlayeh@186 2133 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
gokhlayeh@186 2134 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
pascal@122 2135 case "$WGET_URL" in
pascal@178 2136 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
gokhlayeh@186 2137 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
pascal@122 2138 '') ;;
gokhlayeh@186 2139 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
pascal@122 2140 esac
pascal@112 2141 case "$WEB_SITE" in
pascal@125 2142 ftp*|http*);;
gokhlayeh@186 2143 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
gokhlayeh@186 2144 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
pascal@112 2145 esac
pascal@78 2146 case "$MAINTAINER" in
gokhlayeh@186 2147 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
pascal@78 2148 esac
pascal@78 2149 case "$MAINTAINER" in
pascal@78 2150 *@*);;
gokhlayeh@186 2151 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
pascal@78 2152 esac
gokhlayeh@186 2153 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
pascal@76 2154 for i in $DEPENDS; do
pascal@76 2155 [ -d $i ] && continue
pascal@111 2156 [ -n "$(whoprovide $i)" ] && continue
pascal@76 2157 echo -e "$MSG $i"
pascal@76 2158 MSG=""
pascal@76 2159 done
gokhlayeh@186 2160 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
pascal@92 2161 for i in $BUILD_DEPENDS; do
pascal@92 2162 [ -d $i ] && continue
pascal@111 2163 [ -n "$(whoprovide $i)" ] && continue
pascal@92 2164 echo -e "$MSG $i"
pascal@92 2165 MSG=""
pascal@92 2166 done
pascal@76 2167 MSG="Dependencies loop between $PACKAGE and :\n"
pascal@76 2168 ALL_DEPS=""
pascal@76 2169 check_for_deps_loop $PACKAGE $DEPENDS
pascal@140 2170 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
pascal@141 2171 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
paul@154 2172 echo "$pkg should be rebuilt after $i installation"
pascal@140 2173 done
pascal@76 2174 done
gokhlayeh@186 2175 ;;
pankso@7 2176 list)
paul@166 2177 # List packages in wok directory. User can specify a category.
pankso@7 2178 #
gokhlayeh@186 2179 get_tazwok_config
pankso@7 2180 if [ "$2" = "category" ]; then
pankso@7 2181 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
pankso@7 2182 exit 0
pankso@7 2183 fi
pankso@7 2184 # Check for an asked category.
pankso@7 2185 if [ -n "$2" ]; then
pankso@7 2186 ASKED_CATEGORY=$2
pankso@7 2187 echo ""
pankso@7 2188 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
pankso@7 2189 echo "================================================================================"
pankso@7 2190 for pkg in $WOK/*
pankso@7 2191 do
erjo@168 2192 [ ! -f $pkg/receipt ] && continue
pankso@7 2193 . $pkg/receipt
pankso@7 2194 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@7 2195 echo -n "$PACKAGE"
pankso@28 2196 echo -e "\033[28G $VERSION"
pankso@7 2197 packages=$(($packages+1))
pankso@7 2198 fi
pankso@7 2199 done
pankso@7 2200 echo "================================================================================"
gokhlayeh@186 2201 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
pankso@7 2202 else
pankso@7 2203 # By default list all packages and version.
pankso@7 2204 echo ""
pankso@7 2205 echo -e "\033[1mList of packages in the wok\033[0m"
pankso@7 2206 echo "================================================================================"
pankso@7 2207 for pkg in $WOK/*
pankso@7 2208 do
erjo@168 2209 [ ! -f $pkg/receipt ] && continue
pankso@7 2210 . $pkg/receipt
pankso@7 2211 echo -n "$PACKAGE"
pankso@28 2212 echo -en "\033[28G $VERSION"
pankso@7 2213 echo -e "\033[42G $CATEGORY"
pankso@7 2214 packages=$(($packages+1))
pankso@7 2215 done
pankso@7 2216 echo "================================================================================"
gokhlayeh@186 2217 echo -e "$PACKAGEs packages available in the wok.\n"
pankso@7 2218 fi
pankso@7 2219 ;;
pankso@7 2220 info)
MikeDSmith25@82 2221 # Information about a package.
pankso@7 2222 #
gokhlayeh@186 2223 get_tazwok_config
pankso@7 2224 check_for_package_on_cmdline
pankso@7 2225 check_for_receipt
pankso@7 2226 . $WOK/$PACKAGE/receipt
pankso@7 2227 echo ""
MikeDSmith25@82 2228 echo -e "\033[1mTazwok package information\033[0m
pankso@7 2229 ================================================================================
pankso@7 2230 Package : $PACKAGE
pankso@7 2231 Version : $VERSION
pankso@7 2232 Category : $CATEGORY
pankso@7 2233 Short desc : $SHORT_DESC
pankso@7 2234 Maintainer : $MAINTAINER"
pankso@7 2235 if [ ! "$WEB_SITE" = "" ]; then
pankso@7 2236 echo "Web site : $WEB_SITE"
pankso@7 2237 fi
pankso@7 2238 if [ ! "$DEPENDS" = "" ]; then
pankso@7 2239 echo "Depends : $DEPENDS"
pankso@7 2240 fi
pankso@7 2241 if [ ! "$WANTED" = "" ]; then
pankso@7 2242 echo "Wanted src : $WANTED"
pankso@7 2243 fi
pankso@7 2244 echo "================================================================================"
pankso@7 2245 echo ""
gokhlayeh@186 2246 ;;
pankso@7 2247 check-log)
pankso@7 2248 # We just cat the file log to view process info.
pankso@7 2249 #
gokhlayeh@186 2250 get_tazwok_config
pankso@7 2251 if [ ! -f "$LOG" ]; then
gokhlayeh@186 2252 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
gokhlayeh@186 2253 exit 1
pankso@7 2254 else
pankso@7 2255 echo ""
pankso@7 2256 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
pankso@7 2257 echo "================================================================================"
pankso@7 2258 cat $LOG
pankso@7 2259 echo "================================================================================"
pankso@7 2260 echo ""
pankso@7 2261 fi
gokhlayeh@186 2262 ;;
pankso@7 2263 search)
pankso@7 2264 # Search for a package by pattern or name.
pankso@7 2265 #
gokhlayeh@186 2266 get_tazwok_config
pankso@7 2267 if [ -z "$2" ]; then
gokhlayeh@186 2268 echo -e "\nPlease specify a pattern or a package name to search." >&2
gokhlayeh@186 2269 echo -e "Example : 'tazwok search gcc'.\n" >&2
gokhlayeh@186 2270 exit 1
pankso@7 2271 fi
pankso@7 2272 echo ""
pankso@7 2273 echo -e "\033[1mSearch result for :\033[0m $2"
pankso@7 2274 echo "================================================================================"
gokhlayeh@195 2275 list=`ls -1 $WOK | fgrep $2`
pankso@7 2276 for pkg in $list
pankso@7 2277 do
pankso@7 2278 . $WOK/$pkg/receipt
pankso@7 2279 echo -n "$PACKAGE "
pankso@7 2280 echo -en "\033[24G $VERSION"
pankso@7 2281 echo -e "\033[42G $CATEGORY"
gokhlayeh@186 2282 packages=$(($PACKAGEs+1))
pankso@7 2283 done
pankso@7 2284 echo "================================================================================"
gokhlayeh@186 2285 echo "$PACKAGEs packages found for : $2"
pankso@7 2286 echo ""
gokhlayeh@186 2287 ;;
pankso@7 2288 compile)
pankso@7 2289 # Configure and make a package with the receipt.
pankso@7 2290 #
gokhlayeh@186 2291 get_tazwok_config
gokhlayeh@186 2292 source_lib report
gokhlayeh@186 2293 report start
pankso@7 2294 compile_package
gokhlayeh@186 2295 ;;
pankso@7 2296 genpkg)
paul@121 2297 # Generate a package.
pankso@7 2298 #
gokhlayeh@186 2299 get_tazwok_config
gokhlayeh@186 2300 source_lib report
gokhlayeh@186 2301 report start
pankso@7 2302 gen_package
gokhlayeh@186 2303 ;;
pankso@7 2304 cook)
pankso@7 2305 # Compile and generate a package. Just execute tazwok with
pankso@7 2306 # the good commands.
pankso@7 2307 #
pankso@7 2308 check_root
gokhlayeh@186 2309 get_tazwok_config
gokhlayeh@186 2310 source_lib report
gokhlayeh@186 2311 report start
gokhlayeh@215 2312 update_wan_db
gokhlayeh@215 2313 check_for_commit
gokhlayeh@215 2314 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@215 2315 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
gokhlayeh@215 2316 if [ "$plan_regen_cookorder" ]; then
gokhlayeh@215 2317 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
gokhlayeh@215 2318 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
gokhlayeh@215 2319 fi
gokhlayeh@186 2320 cook
gokhlayeh@186 2321 ;;
gokhlayeh@186 2322 sort-cooklist)
gokhlayeh@186 2323 if [ ! "$LIST" ]; then
gokhlayeh@186 2324 echo "Usage : tazwok sort-cooklist cooklist" >&2\
gokhlayeh@186 2325 exit 1
gokhlayeh@186 2326 fi
gokhlayeh@186 2327 get_tazwok_config
gokhlayeh@186 2328 source_lib report
gokhlayeh@186 2329 report start
gokhlayeh@186 2330 cooklist=$LIST
gokhlayeh@186 2331 sort_cooklist
gokhlayeh@186 2332 cp -af $tmp/cooklist $cooklist
gokhlayeh@186 2333 ;;
pankso@7 2334 cook-list)
gokhlayeh@204 2335 # Cook all packages listed in a file or in default cooklist.
gokhlayeh@186 2336 check_root
gokhlayeh@204 2337 get_options_list="pkg forced"
gokhlayeh@186 2338 get_tazwok_config
gokhlayeh@186 2339 source_lib report
gokhlayeh@186 2340 report start
gokhlayeh@204 2341 if ! [ "$pkg" ]; then
gokhlayeh@204 2342 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
gokhlayeh@186 2343 fi
gokhlayeh@204 2344 gen_cook_list
gokhlayeh@186 2345 cook_list
gokhlayeh@186 2346 ;;
gokhlayeh@186 2347 clean)
gokhlayeh@186 2348 # Clean up a package work directory + thoses which want it.
pankso@7 2349 #
gokhlayeh@186 2350 get_tazwok_config
pankso@7 2351 check_for_package_on_cmdline
pankso@7 2352 check_for_receipt
gokhlayeh@186 2353 source_lib report
gokhlayeh@186 2354 report start
pankso@7 2355 . $RECEIPT
gokhlayeh@186 2356 clean
gokhlayeh@186 2357 ;;
pankso@7 2358 gen-clean-wok)
paul@121 2359 # Generate a clean wok from the current wok by copying all receipts
pankso@7 2360 # and stuff directory.
pankso@7 2361 #
gokhlayeh@186 2362 get_tazwok_config
gokhlayeh@186 2363 source_lib report
gokhlayeh@186 2364 report start
gokhlayeh@186 2365 if [ -z "$ARG" ]; then
gokhlayeh@186 2366 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
gokhlayeh@186 2367 exit 1
pankso@7 2368 else
gokhlayeh@186 2369 dest=$ARG
pankso@7 2370 mkdir -p $dest
pankso@7 2371 fi
gokhlayeh@186 2372 report step "Creating clean wok in : $dest"
pankso@7 2373 for pkg in `ls -1 $WOK`
pankso@7 2374 do
pankso@7 2375 mkdir -p $dest/$pkg
pankso@7 2376 cp -a $WOK/$pkg/receipt $dest/$pkg
gokhlayeh@186 2377 [ -f $WOK/$pkg/description.txt ] && \
gokhlayeh@186 2378 cp -a $WOK/$pkg/description.txt $dest/$pkg
pankso@7 2379 if [ -d "$WOK/$pkg/stuff" ]; then
pankso@7 2380 cp -a $WOK/$pkg/stuff $dest/$pkg
pankso@7 2381 fi
pankso@7 2382 done
gokhlayeh@186 2383 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
gokhlayeh@186 2384 report end-step
pankso@7 2385 echo "Packages cleaned : `ls -1 $dest | wc -l`"
pankso@7 2386 echo ""
gokhlayeh@186 2387 ;;
pankso@7 2388 clean-wok)
pankso@7 2389 # Clean all packages in the work directory
pankso@7 2390 #
gokhlayeh@186 2391 get_tazwok_config
gokhlayeh@186 2392 source_lib report
gokhlayeh@186 2393 report start
gokhlayeh@186 2394 report step "Cleaning wok"
gokhlayeh@186 2395 report open-bloc
gokhlayeh@186 2396 for PACKAGE in `ls -1 $WOK`
pankso@7 2397 do
gokhlayeh@186 2398 set_common_path
gokhlayeh@186 2399 source_receipt
gokhlayeh@186 2400 clean
pankso@7 2401 done
gokhlayeh@186 2402 report close-bloc
pankso@7 2403 echo "`ls -1 $WOK | wc -l` packages cleaned."
gokhlayeh@186 2404 ;;
pankso@7 2405 gen-list)
gokhlayeh@186 2406 get_tazwok_config
gokhlayeh@204 2407 if [ "$2" ]; then
gokhlayeh@204 2408 if [ -d "$2" ]; then
gokhlayeh@204 2409 pkg_repository=$2
gokhlayeh@204 2410 else
gokhlayeh@204 2411 echo -e "\nUnable to find directory : $2\n" >&2
gokhlayeh@204 2412 exit 1
gokhlayeh@204 2413 fi
gokhlayeh@204 2414 fi
gokhlayeh@204 2415
gokhlayeh@186 2416 source_lib report
gokhlayeh@186 2417 report start
gokhlayeh@204 2418 if [ "$pkg_repository" ]; then
gokhlayeh@204 2419 gen_packages_db
gokhlayeh@204 2420 else
gokhlayeh@204 2421 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
gokhlayeh@204 2422 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
gokhlayeh@204 2423 fi
gokhlayeh@186 2424 ;;
gokhlayeh@186 2425 check-list)
gokhlayeh@186 2426 # The directory to move into by default is the repository,
gokhlayeh@186 2427 # if $2 is not empty cd into $2.
pankso@7 2428 #
gokhlayeh@186 2429 get_tazwok_config
gokhlayeh@204 2430 if [ "$2" ]; then
pankso@7 2431 if [ -d "$2" ]; then
gokhlayeh@204 2432 pkg_repository=$2
pankso@7 2433 else
gokhlayeh@186 2434 echo -e "\nUnable to find directory : $2\n" >&2
gokhlayeh@186 2435 exit 1
pankso@7 2436 fi
pankso@7 2437 fi
gokhlayeh@186 2438
gokhlayeh@186 2439 source_lib report
gokhlayeh@204 2440 report start
gokhlayeh@204 2441 if [ "$pkg_repository" ]; then
gokhlayeh@204 2442 update_packages_db
gokhlayeh@204 2443 else
gokhlayeh@204 2444 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
gokhlayeh@204 2445 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
gokhlayeh@204 2446 fi
gokhlayeh@186 2447 ;;
pankso@7 2448 new-tree)
MikeDSmith25@82 2449 # Just create a few directories and generate an empty receipt to prepare
pankso@7 2450 # the creation of a new package.
pankso@7 2451 #
gokhlayeh@186 2452 get_tazwok_config
pankso@7 2453 check_for_package_on_cmdline
pankso@7 2454 if [ -d $WOK/$PACKAGE ]; then
gokhlayeh@186 2455 echo -e "\n$PACKAGE package tree already exists.\n" >&2
gokhlayeh@186 2456 exit 1
pankso@7 2457 fi
pankso@7 2458 echo "Creating : $WOK/$PACKAGE"
pankso@7 2459 mkdir $WOK/$PACKAGE
pankso@7 2460 cd $WOK/$PACKAGE
pankso@7 2461 echo -n "Preparing the receipt..."
pankso@7 2462 #
pankso@7 2463 # Default receipt begin.
pankso@7 2464 #
pankso@7 2465 echo "# SliTaz package receipt." > receipt
pankso@7 2466 echo "" >> receipt
pankso@7 2467 echo "PACKAGE=\"$PACKAGE\"" >> receipt
pankso@7 2468 # Finish the empty receipt.
pankso@7 2469 cat >> receipt << "EOF"
pankso@7 2470 VERSION=""
pankso@7 2471 CATEGORY=""
pankso@7 2472 SHORT_DESC=""
pankso@7 2473 MAINTAINER=""
pankso@7 2474 DEPENDS=""
pankso@7 2475 TARBALL="$PACKAGE-$VERSION.tar.gz"
pankso@7 2476 WEB_SITE=""
pankso@7 2477 WGET_URL=""
pankso@7 2478
pankso@7 2479 # Rules to configure and make the package.
pankso@7 2480 compile_rules()
pankso@7 2481 {
pankso@7 2482 cd $src
gokhlayeh@204 2483 ./configure && make && make install
pankso@7 2484 }
pankso@7 2485
pankso@7 2486 # Rules to gen a SliTaz package suitable for Tazpkg.
pankso@7 2487 genpkg_rules()
pankso@7 2488 {
pankso@7 2489 mkdir -p $fs/usr
pankso@7 2490 cp -a $_pkg/usr/bin $fs/usr
pankso@7 2491 }
pankso@7 2492
pankso@7 2493 EOF
pankso@7 2494 #
pankso@7 2495 # Default receipt end.
pankso@7 2496 #
pankso@7 2497 status
pankso@7 2498 # Interactive mode, asking and seding.
pankso@7 2499 if [ "$3" = "--interactive" ]; then
paul@154 2500 echo "Entering into interactive mode..."
pankso@7 2501 echo "================================================================================"
pankso@7 2502 echo "Package : $PACKAGE"
pankso@7 2503 # Version.
pankso@7 2504 echo -n "Version : " ; read anser
pankso@7 2505 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
pankso@7 2506 # Category.
pankso@7 2507 echo -n "Category : " ; read anser
pankso@7 2508 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
pankso@7 2509 # Short description.
pankso@7 2510 echo -n "Short desc : " ; read anser
pankso@7 2511 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
pankso@7 2512 # Maintainer.
pankso@7 2513 echo -n "Maintainer : " ; read anser
pankso@7 2514 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
pankso@7 2515 # Web site.
pankso@7 2516 echo -n "Web site : " ; read anser
pankso@133 2517 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
pankso@7 2518 echo ""
pankso@7 2519 # Wget URL.
pankso@7 2520 echo "Wget URL to download source tarball."
pankso@7 2521 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
pankso@7 2522 echo -n "Wget url : " ; read anser
pankso@7 2523 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
pankso@7 2524 # Ask for a stuff dir.
pankso@7 2525 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
pankso@7 2526 if [ "$anser" = "y" ]; then
pankso@7 2527 echo -n "Creating the stuff directory..."
pankso@7 2528 mkdir stuff && status
pankso@7 2529 fi
pankso@7 2530 # Ask for a description file.
pankso@7 2531 echo -n "Are you going to write a description ? (y/N) : " ; read anser
pankso@7 2532 if [ "$anser" = "y" ]; then
pankso@7 2533 echo -n "Creating the description.txt file..."
pankso@7 2534 echo "" > description.txt && status
pankso@7 2535 fi
pankso@7 2536 echo "================================================================================"
pankso@7 2537 echo ""
pankso@7 2538 fi
gokhlayeh@186 2539 ;;
pankso@7 2540 remove)
pankso@7 2541 # Remove a package from the wok.
pankso@7 2542 #
gokhlayeh@186 2543 get_tazwok_config
pankso@7 2544 check_for_package_on_cmdline
pankso@7 2545 echo ""
pascal@83 2546 echo -n "Please confirm deletion (y/N) : "; read anser
pascal@83 2547 if [ "$anser" = "y" ]; then
pascal@83 2548 echo -n "Removing $PACKAGE..."
pascal@83 2549 rm -rf $WOK/$PACKAGE && status
pascal@83 2550 echo ""
pascal@83 2551 fi
gokhlayeh@186 2552 ;;
pankso@106 2553 hgup)
paul@166 2554 # Pull and update a Hg wok.
gokhlayeh@186 2555 get_tazwok_config
gokhlayeh@195 2556 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
pankso@106 2557 check_root
pankso@106 2558 fi
pankso@106 2559 cd $WOK
gokhlayeh@186 2560 hg pull && hg update
gokhlayeh@186 2561 ;;
pankso@108 2562 maintainers)
gokhlayeh@186 2563 get_tazwok_config
pankso@108 2564 echo ""
pankso@108 2565 echo "List of maintainers for: $WOK"
pankso@108 2566 echo "================================================================================"
pankso@108 2567 touch /tmp/slitaz-maintainers
pankso@108 2568 for pkg in $WOK/*
pankso@108 2569 do
pankso@108 2570 . $pkg/receipt
gokhlayeh@195 2571 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
pankso@108 2572 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
pankso@108 2573 echo "$MAINTAINER"
pankso@108 2574 fi
pankso@108 2575 done
pankso@108 2576 echo "================================================================================"
pankso@108 2577 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
pankso@108 2578 echo ""
pankso@108 2579 # Remove tmp files
gokhlayeh@186 2580 rm -f /tmp/slitaz-maintainers
gokhlayeh@186 2581 ;;
pankso@107 2582 maintained-by)
paul@166 2583 # Search for packages maintained by a contributor.
gokhlayeh@186 2584 get_tazwok_config
pankso@107 2585 if [ ! -n "$2" ]; then
gokhlayeh@186 2586 echo "Specify a name or email of a maintainer." >&2
gokhlayeh@186 2587 exit 1
pankso@107 2588 fi
pankso@107 2589 echo "Maintainer packages"
pankso@107 2590 echo "================================================================================"
pankso@107 2591 for pkg in $WOK/*
pankso@107 2592 do
pankso@107 2593 . $pkg/receipt
gokhlayeh@195 2594 if echo "$MAINTAINER" | fgrep -q "$2"; then
pankso@107 2595 echo "$PACKAGE"
gokhlayeh@186 2596 packages=$(($PACKAGEs+1))
pankso@107 2597 fi
pankso@107 2598 done
pankso@107 2599 echo "================================================================================"
gokhlayeh@186 2600 echo "Packages maintained by $2: $PACKAGEs"
gokhlayeh@186 2601 echo ""
gokhlayeh@186 2602 ;;
erjo@159 2603 check-src)
erjo@159 2604 # Verify if upstream package is still available
erjo@159 2605 #
gokhlayeh@186 2606 get_tazwok_config
erjo@159 2607 check_for_package_on_cmdline
erjo@159 2608 check_for_receipt
gokhlayeh@186 2609 source_receipt
erjo@159 2610 check_src()
erjo@159 2611 {
erjo@159 2612 for url in $@; do
pascal@178 2613 busybox wget -s $url 2>/dev/null && break
erjo@159 2614 done
erjo@159 2615 }
gokhlayeh@186 2616 if [ "$WGET_URL" ];then
erjo@159 2617 echo -n "$PACKAGE : "
erjo@159 2618 check_src $WGET_URL
erjo@159 2619 status
erjo@159 2620 else
erjo@159 2621 echo "No tarball to check for $PACKAGE"
erjo@159 2622 fi
gokhlayeh@186 2623 ;;
gokhlayeh@186 2624 get-src)
gokhlayeh@186 2625 check_root
gokhlayeh@225 2626 get_options_list="target nounpack"
gokhlayeh@186 2627 get_tazwok_config
gokhlayeh@186 2628 check_for_package_on_cmdline
gokhlayeh@186 2629 check_for_receipt
gokhlayeh@186 2630 source_receipt
gokhlayeh@186 2631 if [ "$WGET_URL" ];then
gokhlayeh@186 2632 source_lib report
gokhlayeh@186 2633 report start
gokhlayeh@225 2634 check_for_tarball
gokhlayeh@186 2635 else
gokhlayeh@186 2636 echo "No tarball to download for $PACKAGE"
gokhlayeh@186 2637 fi
gokhlayeh@186 2638 ;;
gokhlayeh@204 2639 check-commit)
gokhlayeh@186 2640 check_root
gokhlayeh@204 2641 get_options_list="missing forced"
gokhlayeh@186 2642 get_tazwok_config
gokhlayeh@186 2643 source_lib report
gokhlayeh@186 2644 report start
gokhlayeh@204 2645 if [ "$forced" ]; then
gokhlayeh@204 2646 rm -f $WOK/*/md5
gokhlayeh@204 2647 unset forced
gokhlayeh@204 2648 fi
gokhlayeh@204 2649 if [ "$missing" ]; then
gokhlayeh@204 2650 pkg=$(ls -1 $WOK)
gokhlayeh@204 2651 else
gokhlayeh@204 2652 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 2653 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 2654 } | sort -u)"
gokhlayeh@204 2655 fi
gokhlayeh@204 2656 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@186 2657 gen_cook_list
gokhlayeh@186 2658 ;;
gokhlayeh@186 2659 cook-commit)
gokhlayeh@186 2660 check_root
gokhlayeh@204 2661 get_options_list="missing forced"
gokhlayeh@186 2662 get_tazwok_config
gokhlayeh@186 2663 source_lib report
gokhlayeh@186 2664 report start
gokhlayeh@204 2665 if [ "$forced" ]; then
gokhlayeh@204 2666 rm -f $WOK/*/md5
gokhlayeh@204 2667 unset forced
gokhlayeh@204 2668 fi
gokhlayeh@204 2669 if [ "$missing" ]; then
gokhlayeh@204 2670 pkg=$(ls -1 $WOK)
gokhlayeh@204 2671 else
gokhlayeh@204 2672 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 2673 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 2674 } | sort -u)"
gokhlayeh@204 2675 fi
gokhlayeh@204 2676 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@186 2677 gen_cook_list
gokhlayeh@186 2678 cook_list
gokhlayeh@186 2679 ;;
gokhlayeh@186 2680 cook-all)
gokhlayeh@186 2681 check_root
gokhlayeh@204 2682 get_options_list="forced missing"
gokhlayeh@186 2683 get_tazwok_config
gokhlayeh@186 2684 source_lib report
gokhlayeh@186 2685 report start
gokhlayeh@204 2686 if [ "$missing" ]; then
gokhlayeh@204 2687 pkg=$(ls -1 $WOK)
gokhlayeh@204 2688 else
gokhlayeh@204 2689 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 2690 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 2691 } | sort -u)"
gokhlayeh@204 2692 fi
gokhlayeh@204 2693 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@204 2694 gen_cook_list
gokhlayeh@186 2695 cook_list
gokhlayeh@186 2696 ;;
gokhlayeh@186 2697 gen-wok-db)
gokhlayeh@186 2698 check_root
gokhlayeh@186 2699 get_tazwok_config
gokhlayeh@186 2700 source_lib report
gokhlayeh@186 2701 report start
gokhlayeh@204 2702 gen_wok_db
gokhlayeh@186 2703 ;;
gokhlayeh@186 2704 report)
gokhlayeh@186 2705 check_root
gokhlayeh@186 2706 get_tazwok_config
gokhlayeh@186 2707 cd $PACKAGES_REPOSITORY
gokhlayeh@204 2708 for i in commit cooklist incoming broken blocked; do
gokhlayeh@186 2709 if [ -s $i ]; then
gokhlayeh@186 2710 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
gokhlayeh@186 2711 fi
gokhlayeh@186 2712 done
gokhlayeh@186 2713 ;;
gokhlayeh@186 2714 check-incoming)
gokhlayeh@186 2715 check_root
gokhlayeh@214 2716 get_options_list="forced"
gokhlayeh@186 2717 get_tazwok_config
gokhlayeh@186 2718 source_lib report
gokhlayeh@186 2719 report start
gokhlayeh@186 2720 check_for_incoming
gokhlayeh@186 2721 ;;
gokhlayeh@190 2722 configure-chroot)
gokhlayeh@190 2723 check_root
gokhlayeh@190 2724 get_tazwok_config
gokhlayeh@190 2725 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@190 2726 cd $LOCAL_REPOSITORY
gokhlayeh@190 2727 configure_tazchroot
gokhlayeh@190 2728 else
gokhlayeh@190 2729 echo "The packages tazchroot need to be installed" >&2
gokhlayeh@190 2730 exit 1
gokhlayeh@190 2731 fi
gokhlayeh@190 2732 ;;
gokhlayeh@186 2733 chroot)
gokhlayeh@186 2734 check_root
gokhlayeh@186 2735 get_tazwok_config
gokhlayeh@186 2736 # Merge this and the other chroot function ?.
gokhlayeh@186 2737 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@186 2738 cd $LOCAL_REPOSITORY
gokhlayeh@186 2739 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@186 2740 tazchroot
gokhlayeh@186 2741 else
gokhlayeh@186 2742 echo "The packages tazchroot need to be installed" >&2
gokhlayeh@186 2743 exit 1
gokhlayeh@186 2744 fi
gokhlayeh@186 2745 ;;
gokhlayeh@186 2746 cook-toolchain)
gokhlayeh@186 2747 check_root
gokhlayeh@186 2748 get_tazwok_config
gokhlayeh@186 2749 echo -n "" > $PACKAGES_REPOSITORY/broken
gokhlayeh@186 2750 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@186 2751 cd $LOCAL_REPOSITORY
gokhlayeh@186 2752 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@186 2753 tazchroot cook-toolchain
gokhlayeh@186 2754 # Buggy : chroot can be elsewhere.
gokhlayeh@186 2755 rm -r $LOCAL_REPOSITORY/chroot
gokhlayeh@186 2756 # /!\ to be writed :
gokhlayeh@186 2757 # next rm chroot and plan cook-all by pushing all packages
gokhlayeh@186 2758 # in cooklist.
gokhlayeh@186 2759 else
gokhlayeh@186 2760 echo "The packages tazchroot need to be installed" >&2
gokhlayeh@186 2761 exit 1
gokhlayeh@186 2762 fi
gokhlayeh@186 2763 ;;
gokhlayeh@235 2764 webserver)
gokhlayeh@235 2765 check_root
gokhlayeh@235 2766 get_tazwok_config
gokhlayeh@235 2767 if [ "$ARG" = on ]; then
gokhlayeh@235 2768 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
gokhlayeh@235 2769 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
gokhlayeh@235 2770 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
gokhlayeh@235 2771 exit 1
gokhlayeh@235 2772 fi
gokhlayeh@235 2773 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
gokhlayeh@235 2774 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
gokhlayeh@235 2775 fi
gokhlayeh@235 2776 for pkg in php lighttpd; do
gokhlayeh@235 2777 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
gokhlayeh@235 2778 done
gokhlayeh@235 2779 if [ "$missing" ]; then
gokhlayeh@235 2780 echo "You need to install those packages to start webserver: $missing." >&2
gokhlayeh@235 2781 exit 1
gokhlayeh@235 2782 fi
gokhlayeh@235 2783 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
gokhlayeh@235 2784 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
gokhlayeh@235 2785 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
gokhlayeh@235 2786 fi
gokhlayeh@235 2787 if ! [ "$WEBSERVER" ]; then
gokhlayeh@235 2788 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
gokhlayeh@235 2789 read WEBSERVER
gokhlayeh@235 2790 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
gokhlayeh@235 2791 fi
gokhlayeh@235 2792 if [ -f "$WEBSERVER/repositories.list" ] && \
gokhlayeh@235 2793 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
gokhlayeh@235 2794 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
gokhlayeh@235 2795 exit 1
gokhlayeh@235 2796 fi
gokhlayeh@235 2797 mkdir -p $WEBSERVER
gokhlayeh@235 2798 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
gokhlayeh@235 2799 for file in index.php log.php; do
gokhlayeh@235 2800 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
gokhlayeh@235 2801 done
gokhlayeh@235 2802 source $LOCAL_REPOSITORY/tazchroot.conf
gokhlayeh@235 2803 echo "<?php
gokhlayeh@235 2804
gokhlayeh@235 2805 // Web interface configuration
gokhlayeh@235 2806
gokhlayeh@235 2807 \$version=\"${undigest:-$SLITAZ_VERSION}\";
gokhlayeh@235 2808 \$chroot=\"$chroot_dir\";
gokhlayeh@235 2809 \$lockfile=\"\$chroot/proc/1\";
gokhlayeh@235 2810 \$db_dir=\"$PACKAGES_REPOSITORY\";
gokhlayeh@235 2811 \$log_dir=\"$LOCAL_REPOSITORY/log\";
gokhlayeh@235 2812 \$packages=\"$PACKAGES_REPOSITORY\";
gokhlayeh@235 2813 \$incoming=\"$INCOMING_REPOSITORY\";
gokhlayeh@235 2814
gokhlayeh@235 2815 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
gokhlayeh@235 2816 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
gokhlayeh@235 2817 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
gokhlayeh@235 2818 if [ -L "$WEBSERVER/conf.php" ]; then
gokhlayeh@235 2819 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
gokhlayeh@235 2820 read answer
gokhlayeh@235 2821 if [ "$answer" = y ]; then
gokhlayeh@235 2822 rm $WEBSERVER/conf.php
gokhlayeh@235 2823 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
gokhlayeh@235 2824 fi
gokhlayeh@235 2825 else
gokhlayeh@235 2826 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
gokhlayeh@235 2827 fi
gokhlayeh@235 2828 elif [ "$ARG" = off ]; then
gokhlayeh@235 2829 if ! [ "$WEBSERVER" ]; then
gokhlayeh@235 2830 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
gokhlayeh@235 2831 exit 1
gokhlayeh@235 2832 fi
gokhlayeh@235 2833 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
gokhlayeh@235 2834 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
gokhlayeh@235 2835 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
gokhlayeh@235 2836 if ! [ -s "$WEBSERVER/repositories.list" ]; then
gokhlayeh@235 2837 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If it's not the case, you can remove it using: rm -r $WEBSERVER"
gokhlayeh@235 2838 rm $WEBSERVER/conf.php
gokhlayeh@235 2839 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
gokhlayeh@235 2840 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
gokhlayeh@235 2841 rm $WEBSERVER/conf.php
gokhlayeh@235 2842 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
gokhlayeh@235 2843 fi
gokhlayeh@235 2844 else
gokhlayeh@235 2845 echo "Usage: tazwok webserver on/off" >&2
gokhlayeh@235 2846 exit 1
gokhlayeh@235 2847 fi
gokhlayeh@235 2848 ;;
pankso@7 2849 usage|*)
MikeDSmith25@82 2850 # Print usage also for all unknown commands.
pankso@7 2851 #
pankso@7 2852 usage
gokhlayeh@186 2853 ;;
pankso@7 2854 esac
pankso@7 2855
gokhlayeh@186 2856 report stop 2>/dev/null || exit 0