tazwok annotate tazwok @ rev 460

tazwok: various fixes about packages_db() generation
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Mar 25 17:58:40 2011 +0100 (2011-03-25)
parents 95e4c4e04cdd
children ae0a39ba004a
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@396 12 VERSION=4.3
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
gokhlayeh@237 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.
pankso@7 34 list List all packages in the wok tree or by category.
MikeDSmith25@82 35 info Get information about a package in the wok.
gokhlayeh@283 36 report Display commit/cooklist/broken/blocked.
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.
paul@430 47 cook-all Cook all packages except toolchain.
gokhlayeh@186 48 cook-toolchain Cook the toolchain packages.
gokhlayeh@240 49 gen-cooklist Generate a sorted cooklist using packages or list.
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@240 55 check-list Update packages lists for a repository.
paul@430 56 gen-wok-db (Re-)Generate wok lists with depends and wanted data.
gokhlayeh@240 57 gen-clean-wok Generate a clean wok in a dir.
gokhlayeh@186 58 clean-wok Clean entirely the wok.
paul@430 59 clean-src Remove old/unrelated-to-wok sources.
pankso@107 60 remove Remove a package from the wok.
gokhlayeh@240 61 webserver Enable/disable webserver on localhost.
gokhlayeh@304 62 update-wok Update the wok.
pankso@108 63 maintainers List all maintainers in the wok.
gokhlayeh@281 64 maintained-by List packages maintained by a contributor.
pankso@355 65 tags List all tags used in wok receipts.
pankso@355 66 block Add package from the blocked list to prevent cooking it.
pankso@355 67 unblock Remove package from the blocked list.\n
gokhlayeh@186 68
paul@430 69 You can use `basename $0` command --help to list available options.
gokhlayeh@186 70 \033[1mImportant - *: \033[0m Commands which need a rewrite."
pankso@7 71 }
pankso@7 72
paul@430 73 # This function displays an error message without returning any error code.
paul@430 74 # It also logs the message in source package's warnings.txt; this file can be
gokhlayeh@186 75 # used on an eventual package page on website to display cooking warnings.
gokhlayeh@186 76 tazwok_warning()
pankso@7 77 {
gokhlayeh@186 78 echo -e "tazwok: $1" >&2
gokhlayeh@186 79 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
gokhlayeh@186 80 return
pankso@7 81 }
pankso@7 82
gokhlayeh@186 83 ########################################################################
gokhlayeh@186 84 # TAZWOK VARIABLES & INITIAL CONFIGURATION
gokhlayeh@186 85 ########################
gokhlayeh@186 86
gokhlayeh@398 87 # Check if all packages are up to date into build environnement
gokhlayeh@398 88 check_env_status()
gokhlayeh@398 89 {
gokhlayeh@453 90 { [ "${COMMAND#cook}" = "$COMMAND" ] ||
gokhlayeh@453 91 [ "$COMMAND" = cook-toolchain ] ||
gokhlayeh@453 92 [ -f /etc/config.site.tmptoolchain ]; } && return
gokhlayeh@398 93 MIRROR_path=$(grep -l "^$1$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror)
gokhlayeh@398 94
gokhlayeh@398 95 if [ ! "$MIRROR_path" ]; then
gokhlayeh@398 96 echo "You are trying to cook something but you don't use $1 repository, which is \
gokhlayeh@398 97 needed for this operation." | fold -s >&2
gokhlayeh@398 98 exit 1
gokhlayeh@398 99 fi
gokhlayeh@398 100
gokhlayeh@398 101 LOCALSTATE_path=${MIRROR_path%/mirror}
gokhlayeh@398 102
gokhlayeh@398 103 # Check is possible only if repository use ID.
gokhlayeh@398 104 if [ "${MIRROR_path:0:1}" = '/' ]; then
gokhlayeh@398 105 [ -f "$MIRROR_path/ID" ] || return
gokhlayeh@398 106 else
gokhlayeh@398 107 wget -a -s $MIRROR_path/ID 2>/dev/null || return
gokhlayeh@398 108 fi
gokhlayeh@398 109
gokhlayeh@398 110 [ -f $LOCALSTATE_path/ID ] && ID=$(cat $LOCALSATE_path/ID)
gokhlayeh@398 111
gokhlayeh@398 112 if [ "$LOCALSTATE_path" = "$LOCALSTATE" ]; then
gokhlayeh@398 113 tazpkg recharge main
gokhlayeh@398 114 else
gokhlayeh@398 115 tazpkg recharge ${LOCALSTATE_path##*/}
gokhlayeh@398 116 fi
gokhlayeh@398 117
gokhlayeh@398 118 [ "$(cat $LOCALSTATE_path/ID)" = "$ID" ] || env_status=1
gokhlayeh@398 119 }
gokhlayeh@398 120
gokhlayeh@186 121 get_tazwok_config()
pankso@7 122 {
gokhlayeh@186 123 # Get configuration file.
gokhlayeh@186 124 get_config
gokhlayeh@186 125
gokhlayeh@186 126 # Define & get options.
gokhlayeh@444 127 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
gokhlayeh@186 128 get_options
gokhlayeh@186 129
gokhlayeh@364 130 LOCAL_REPOSITORY=$SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}
gokhlayeh@235 131
gokhlayeh@235 132 if ! [ "$save_dir" ]; then
gokhlayeh@235 133 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
gokhlayeh@235 134 save_dir=$LOCAL_REPOSITORY
gokhlayeh@235 135 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
gokhlayeh@235 136 cd $save_dir
gokhlayeh@235 137 get_tazwok_config
gokhlayeh@235 138 unset save_dir
gokhlayeh@235 139 return
gokhlayeh@235 140 fi
gokhlayeh@235 141 fi
gokhlayeh@405 142
gokhlayeh@186 143 set_common_path
gokhlayeh@186 144
gokhlayeh@398 145 # Check that packages are up to date if user intend to cook.
gokhlayeh@398 146 check_env_status ${USE_ONLINE_PKG:-$PACKAGES_REPOSITORY}
gokhlayeh@398 147 check_env_status $INCOMING_REPOSITORY
gokhlayeh@398 148
gokhlayeh@398 149 # In case undigest is used, we need to upgrade system.
gokhlayeh@398 150 if [ "$undigest" ]; then
gokhlayeh@410 151 use_undigest_scan_core
gokhlayeh@398 152 ref_PACKAGES_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION/packages
gokhlayeh@398 153 if [ -f $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf ] && \
gokhlayeh@398 154 grep -q ^USE_ONLINE_PKG $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf; then
gokhlayeh@398 155 ref_USE_ONLINE_PKG=$(source $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf && \
gokhlayeh@398 156 echo $USE_ONLINE_PKG)
gokhlayeh@398 157 fi
gokhlayeh@398 158
gokhlayeh@398 159 check_env_status ${ref_USE_ONLINE_PKG:-$ref_PACKAGES_REPOSITORY}
gokhlayeh@398 160 cd $ref_PACKAGES_REPOSITORY
gokhlayeh@398 161 if [ "$ref_USE_ONLINE_PKG" ]; then
gokhlayeh@398 162 ref_dep_db=$LOCALSTATE_path/wok-depends.txt
gokhlayeh@398 163 ref_wan_db=$LOCALSTATE_path/wok-wanted.txt
gokhlayeh@450 164 ref_lib_db=$LOCALSTATE_path/libraries.txt
gokhlayeh@398 165 else
gokhlayeh@398 166 ref_dep_db=$ref_PACKAGES_REPOSITORY/wok-depends.txt
gokhlayeh@398 167 ref_wan_db=$ref_PACKAGES_REPOSITORY/wok-wanted.txt
gokhlayeh@450 168 ref_lib_db=$ref_PACKAGES_REPOSITORY/libraries.txt
gokhlayeh@398 169 fi
gokhlayeh@398 170
gokhlayeh@450 171 for file in $ref_dep_db $ref_wan_db $ref_lib_db; do
gokhlayeh@398 172 [ -f "$file" ] && continue
gokhlayeh@398 173 missing_file=t
gokhlayeh@398 174 echo "$file is missing." >&2
gokhlayeh@398 175 done
gokhlayeh@398 176 if [ "$missing_file" ]; then
gokhlayeh@398 177 echo "
gokhlayeh@398 178 Theses files are needed to get datas about packages from the reference repository $SLITAZ_VERSION. \
gokhlayeh@398 179 If you don't intend to build this reference repository yourself, you should set USE_ONLINE_PKG variable \
gokhlayeh@398 180 into tazwok.conf of this reference repository. How-to:" | fold -s >&2
gokhlayeh@398 181 echo "echo 'USE_ONLINE_PKG=\"packages_repository_url\"' >> $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf"
gokhlayeh@398 182 echo ""
gokhlayeh@398 183 exit 1
gokhlayeh@398 184 fi
gokhlayeh@398 185 fi
gokhlayeh@398 186
gokhlayeh@398 187 # If $env_status exists, it means an upgrade may be needed.
gokhlayeh@398 188 if [ "$env_status" ]; then
gokhlayeh@398 189 if [ -x /usr/bin/clean-chroot ]; then
gokhlayeh@398 190 echo y | tazpkg upgrade
gokhlayeh@398 191 else
gokhlayeh@398 192 echo "\e[0;31mWarning: \e[m"
gokhlayeh@398 193 echo "You're environnement may need a package upgrade."
gokhlayeh@398 194 echo "Upgrading is highly recommanded to ensure repository consistency."
gokhlayeh@398 195 echo "You can (E)xit, (U)pgrade, or (C)ontinue."
gokhlayeh@398 196 echo -n "What do you want to do ?"
gokhlayeh@398 197 read answer
gokhlayeh@398 198 case $answer in
gokhlayeh@398 199 [Cc]*) ;;
gokhlayeh@398 200 [Uu]*) echo y | tazpkg upgrade ;;
gokhlayeh@398 201 *) exit
gokhlayeh@398 202 esac
gokhlayeh@398 203 fi
gokhlayeh@398 204 fi
gokhlayeh@186 205
gokhlayeh@186 206 # Check commons directories, create them if user is root.
gokhlayeh@186 207 if test $(id -u) = 0 ; then
gokhlayeh@186 208 check_dir $WOK || chmod 777 $WOK
gokhlayeh@304 209 check_dir $LOCAL_REPOSITORY/clean-wok || chmod 777 $LOCAL_REPOSITORY/clean-wok
gokhlayeh@186 210 check_dir $PACKAGES_REPOSITORY
gokhlayeh@186 211 check_dir $SOURCES_REPOSITORY
gokhlayeh@186 212 check_dir $INCOMING_REPOSITORY
gokhlayeh@186 213 check_dir $LOCAL_REPOSITORY/log
gokhlayeh@405 214 for file in $dep_db $wan_db $cookorder $commit $cooklist \
gokhlayeh@450 215 $broken $blocked $SOURCES_REPOSITORY/sources.list $lib_db
gokhlayeh@405 216 do
gokhlayeh@405 217 [ -f $file ] || touch $file
gokhlayeh@293 218 done
gokhlayeh@186 219 fi
gokhlayeh@235 220
gokhlayeh@186 221 # Limit memory usage.
pascal@386 222 ulimit -v $(awk '/MemTotal|SwapTotal/ { n+=$2 } END { print int((n*80)/100) }' < /proc/meminfo)
gokhlayeh@405 223 }
gokhlayeh@405 224
gokhlayeh@405 225 # The path to the most important files/dir used by Tazwok.
gokhlayeh@405 226 set_common_path()
gokhlayeh@405 227 {
gokhlayeh@405 228 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
gokhlayeh@405 229 WOK=$LOCAL_REPOSITORY/wok
gokhlayeh@405 230 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
gokhlayeh@405 231 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
gokhlayeh@405 232 RECEIPT="$WOK/$PACKAGE/receipt"
gokhlayeh@405 233 LOG="$WOK/$PACKAGE/process.log"
gokhlayeh@405 234 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
gokhlayeh@405 235 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
gokhlayeh@450 236 lib_db=$INCOMING_REPOSITORY/libraries.txt
gokhlayeh@405 237 cookorder=$PACKAGES_REPOSITORY/cookorder.txt
gokhlayeh@405 238 commit=$PACKAGES_REPOSITORY/commit
gokhlayeh@405 239 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@405 240 broken=$PACKAGES_REPOSITORY/broken
gokhlayeh@405 241 blocked=$PACKAGES_REPOSITORY/blocked
gokhlayeh@352 242
gokhlayeh@352 243 # log steps for webserver.
gokhlayeh@352 244 log_step="$LOCAL_REPOSITORY/log/step"
gokhlayeh@352 245 run_on_exit="$run_on_exit
gokhlayeh@352 246 rm -f $LOCAL_REPOSITORY/log/step
gokhlayeh@352 247 rm -f $LOCAL_REPOSITORY/log/package"
pankso@7 248 }
pankso@7 249
gokhlayeh@186 250 ########################################################################
gokhlayeh@186 251 # TAZWOK CHECK FUNCTIONS
gokhlayeh@186 252 ########################
gokhlayeh@186 253
pankso@7 254 # Check for a package name on cmdline.
pankso@7 255 check_for_package_on_cmdline()
pankso@7 256 {
gokhlayeh@186 257 if [ ! "$PACKAGE" ]; then
gokhlayeh@186 258 echo -e "\nYou must specify a package name on the command line." >&2
gokhlayeh@186 259 echo -e "Example : tazwok $COMMAND package\n" >&2
gokhlayeh@186 260 exit 1
pankso@7 261 fi
pankso@7 262 }
pankso@7 263
pankso@7 264 # Check for the receipt of a package used to cook.
pankso@7 265 check_for_receipt()
pankso@7 266 {
pankso@7 267 if [ ! -f "$RECEIPT" ]; then
gokhlayeh@186 268 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
gokhlayeh@186 269 exit 1
pankso@7 270 fi
pankso@7 271 }
pankso@7 272
pankso@7 273 # Check for a specified file list on cmdline.
pankso@7 274 check_for_list()
pankso@7 275 {
gokhlayeh@186 276 if [ ! "$LIST" ]; then
gokhlayeh@186 277 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
gokhlayeh@186 278 exit 1
gokhlayeh@405 279 elif ! [ -f "$LIST" ]; then
gokhlayeh@186 280 echo -e "\nUnable to find $LIST packages list.\n" >&2
gokhlayeh@186 281 exit 1
gokhlayeh@405 282 elif ! [ -s "$LIST" ]; then
gokhlayeh@186 283 echo -e "\nList is empty.\n" >&2
gokhlayeh@186 284 exit 1
gokhlayeh@186 285 fi
gokhlayeh@186 286 }
gokhlayeh@186 287
gokhlayeh@186 288 ########################################################################
gokhlayeh@186 289 # TAZWOK CORE FUNCTIONS
gokhlayeh@186 290 ########################
gokhlayeh@186 291
gokhlayeh@186 292 remove_src()
gokhlayeh@186 293 {
gokhlayeh@204 294 [ "$WANTED" ] && return
gokhlayeh@186 295 look_for_cookopt !remove_src && return
gokhlayeh@215 296 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
gokhlayeh@186 297 check_for_var_modification _pkg src || return
gokhlayeh@215 298 mv "$src/_pkg" $WOK/$PACKAGE/install
gokhlayeh@186 299 fi
gokhlayeh@186 300
paul@430 301 # Don't remove sources if a package uses src variable in its
paul@431 302 # genpkg_rules: it maybe needs something inside.
gokhlayeh@186 303 for i in $PACKAGE $(look_for_rwanted); do
gokhlayeh@186 304 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
gokhlayeh@195 305 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
paul@431 306 because $i uses \$src in its receipt." && return
gokhlayeh@186 307 done
gokhlayeh@186 308
gokhlayeh@186 309 report step "Removing sources directory"
gokhlayeh@186 310 rm -fr "$src"
gokhlayeh@186 311 report end-step
gokhlayeh@186 312 }
gokhlayeh@186 313
gokhlayeh@186 314 # Check $COOK_OPT; usage : get_cookopt particular_opt
paul@430 315 # Return error if not found
gokhlayeh@186 316 # Return args if the opt is in the format opt=arg1:arg2:etc
gokhlayeh@186 317 look_for_cookopt()
gokhlayeh@186 318 {
gokhlayeh@186 319 for arg in $COOK_OPT; do
gokhlayeh@186 320 case $arg in
gokhlayeh@186 321 $1=*)
gokhlayeh@186 322 arg=${arg#$1=}
gokhlayeh@186 323 while [ "$arg" ]; do
gokhlayeh@186 324 echo "${arg%%:*}"
gokhlayeh@186 325 [ "${arg/:}" = "$arg" ] && return
gokhlayeh@186 326 arg=${arg#*:}
gokhlayeh@186 327 done
gokhlayeh@186 328 ;;
gokhlayeh@186 329 $1)
gokhlayeh@186 330 return
gokhlayeh@186 331 ;;
gokhlayeh@186 332 esac
gokhlayeh@186 333 done
gokhlayeh@186 334 return 1
pankso@7 335 }
pankso@7 336
pankso@7 337 # Check for the wanted package if specified in WANTED
paul@166 338 # receipt variable. Set the $src/$_pkg variable to help compile
paul@166 339 # and generate packages.
pankso@7 340 check_for_wanted()
pankso@7 341 {
gokhlayeh@186 342 if [ "$WANTED" ]; then
gokhlayeh@186 343 report "Checking for the wanted package"
pankso@7 344 if [ ! -d "$WOK/$WANTED" ]; then
gokhlayeh@186 345 report exit "\nWanted package is missing in the work directory.\n"
pankso@7 346 fi
gokhlayeh@186 347
erjo@38 348 # Checking for buildtree of Wanted package
pankso@39 349 if [ ! -d "$WOK/$WANTED/taz" ]; then
erjo@38 350 echo -e "\n\nSource files of wanted package is missing in the work directory."
erjo@38 351 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
erjo@38 352 if [ "$anser" == "y" ]; then
erjo@38 353 tazwok cook $WANTED
erjo@38 354 else
gokhlayeh@186 355 report exit "\nWanted package source tree is missing in the work directory.\n"
erjo@38 356 fi
erjo@38 357 fi
gokhlayeh@186 358 report end-step
gokhlayeh@186 359
pankso@7 360 # Set wanted src path.
gokhlayeh@186 361 set_src_path && set_pkg_path
gokhlayeh@186 362
pascal@178 363 fi
pascal@178 364 }
pascal@178 365
pascal@178 366 # Check for build dependencies, notify user and install if specified.
pascal@178 367 check_for_build_depends()
pascal@178 368 {
gokhlayeh@204 369 [ "$WANTED" ] && return
gokhlayeh@213 370 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
gokhlayeh@272 371 [ ! "$BUILD_DEPENDS" ] && ! fgrep -q compile_rules $RECEIPT && return
gokhlayeh@186 372 report step "Looking for build dependencies"
gokhlayeh@186 373
gokhlayeh@186 374 # Keep the list of previously installed build_depends then compare
gokhlayeh@186 375 # it with new build_depends to know what to install and what to
gokhlayeh@186 376 # what to remove.
gokhlayeh@186 377 plan_remove=" $MISSING_PACKAGE $remove_later "
gokhlayeh@186 378 [ ! "${plan_remove// }" ] && unset plan_remove
gokhlayeh@186 379 unset MISSING_PACKAGE remove_later
gokhlayeh@186 380 rwanted=$(look_for_rwanted)
gokhlayeh@186 381
gokhlayeh@215 382 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
gokhlayeh@394 383 grep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e ^$i$"; done))
pascal@178 384 do
gokhlayeh@186 385
gokhlayeh@186 386 # Delay the removing of previous cook depends if they are needed
gokhlayeh@186 387 # for next cook too.
gokhlayeh@186 388 if [ ! -d "$INSTALLED/$pkg" ] ; then
gokhlayeh@186 389 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
gokhlayeh@186 390 fi
gokhlayeh@186 391 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
gokhlayeh@186 392 plan_remove="${plan_remove/ $pkg / }"
gokhlayeh@186 393 remove_later="$remove_later $pkg"
gokhlayeh@186 394 fi
gokhlayeh@405 395 grep -q ^$pkg$ $broken && broken_pkg="$broken_pkg$pkg "
pascal@178 396 done
gokhlayeh@186 397
gokhlayeh@186 398 # Don't cook if a depend is broken.
gokhlayeh@405 399 if [ "$broken_pkg" ]; then
gokhlayeh@186 400 MISSING_PACKAGE=$plan_remove
paul@430 401 echo "Can't cook $PACKAGE because of broken depend(s) : $broken" >&2
gokhlayeh@186 402 unset plan_remove broken
gokhlayeh@186 403
gokhlayeh@186 404 # Set report step to failed.
gokhlayeh@186 405 report_return_code=1
gokhlayeh@186 406 report end-step
gokhlayeh@186 407 return 1
gokhlayeh@186 408 fi
gokhlayeh@186 409 if [ "$MISSING_PACKAGE" ]; then
gokhlayeh@186 410 install_missing()
gokhlayeh@186 411 {
gokhlayeh@186 412 echo "Installing missing packages : $MISSING_PACKAGE"
gokhlayeh@186 413 for pkg in $MISSING_PACKAGE; do
gokhlayeh@186 414 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
gokhlayeh@186 415 done
gokhlayeh@186 416 }
gokhlayeh@186 417 if [ "$auto_install" = yes ]; then
gokhlayeh@186 418 install_missing
gokhlayeh@186 419 else
gokhlayeh@186 420 echo "================================================================================"
gokhlayeh@186 421 for pkg in $MISSING_PACKAGE
gokhlayeh@186 422 do
pascal@178 423 echo "Missing : $pkg"
gokhlayeh@186 424 done
gokhlayeh@186 425 echo "================================================================================"
gokhlayeh@186 426 echo "You can continue, exit or install missing dependencies."
gokhlayeh@186 427 echo -n "Install, continue or exit (install/y/N) ? "; read answer
gokhlayeh@186 428 case $answer in
gokhlayeh@186 429 install)
gokhlayeh@186 430 install_missing ;;
gokhlayeh@186 431 y|yes)
gokhlayeh@186 432 unset MISSING_PACKAGE;;
gokhlayeh@186 433 *)
gokhlayeh@186 434 report stop
gokhlayeh@186 435 exit 0 ;;
gokhlayeh@186 436 esac
gokhlayeh@186 437 fi
gokhlayeh@186 438 fi
gokhlayeh@186 439 report end-step
gokhlayeh@186 440 remove_build_depends $plan_remove
gokhlayeh@186 441 unset plan_remove
gokhlayeh@186 442 }
gokhlayeh@186 443
gokhlayeh@186 444 remove_build_depends()
gokhlayeh@186 445 {
gokhlayeh@186 446 [ "$1" ] || return
gokhlayeh@186 447 report step "Removing previous build dependencies"
paul@430 448 echo "Removing these packages : $@"
gokhlayeh@186 449 for pkg in $@; do
gokhlayeh@382 450 [ -f "$INSTALLED/$pkg/receipt" ] && tazpkg remove $pkg --auto
gokhlayeh@186 451 done
gokhlayeh@382 452 cd $PWD
gokhlayeh@186 453 report end-step
gokhlayeh@186 454 }
gokhlayeh@186 455
gokhlayeh@186 456 # Check if we can use the new way to handle tarball
paul@430 457 # or if we keep the previous method by checking for
gokhlayeh@186 458 # _pkg=/src= in receipt and reverse-wanted.
gokhlayeh@186 459 check_for_var_modification()
gokhlayeh@186 460 {
gokhlayeh@186 461 for var in $@; do
gokhlayeh@186 462 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
gokhlayeh@186 463 [ -f $WOK/$pkg/receipt ] || continue
gokhlayeh@195 464 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
pascal@178 465 done
gokhlayeh@186 466 done
gokhlayeh@186 467
gokhlayeh@186 468 # Tweak to make if; then...; fi function working with this one.
gokhlayeh@186 469 echo -n ""
gokhlayeh@186 470 }
gokhlayeh@186 471
gokhlayeh@186 472 set_src_path()
gokhlayeh@186 473 {
gokhlayeh@186 474 if check_for_var_modification src _pkg; then
gokhlayeh@186 475 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
gokhlayeh@186 476 else
paul@430 477 tazwok_warning "Use original name or tarball root directory because src/_pkg is defined in the receipt (this is no longer needed!)."
gokhlayeh@186 478 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
pascal@178 479 fi
gokhlayeh@298 480 stuff=$WOK/$PACKAGE/stuff
gokhlayeh@298 481 [ "$WANTED" ] && wanted_stuff=$WOK/$WANTED/stuff
pascal@178 482 }
pascal@178 483
gokhlayeh@186 484 set_pkg_path()
gokhlayeh@186 485 {
slaxemulator@269 486 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
gokhlayeh@186 487 _pkg=$WOK/${WANTED:-$PACKAGE}/install
gokhlayeh@186 488 else
pankso@7 489 _pkg=$src/_pkg
pankso@7 490 fi
pankso@7 491 }
pankso@7 492
gokhlayeh@186 493 # Output $VERSION-$EXTRAVERSION using packages.txt
gokhlayeh@186 494 get_pkg_version()
gokhlayeh@186 495 {
gokhlayeh@186 496 [ "$PACKAGE" ] || return
gokhlayeh@204 497 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
gokhlayeh@186 498 }
erjo@38 499
gokhlayeh@186 500 remove_previous_package()
pankso@18 501 {
gokhlayeh@186 502 [ "$prev_VERSION" ] || return
gokhlayeh@186 503 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
gokhlayeh@186 504 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
gokhlayeh@186 505 fi
gokhlayeh@382 506 return 0
gokhlayeh@186 507 }
gokhlayeh@186 508
gokhlayeh@186 509 # Check for src tarball and wget if needed.
gokhlayeh@186 510 check_for_tarball()
gokhlayeh@186 511 {
gokhlayeh@258 512 [ "$WGET_URL" ] || return 0
gokhlayeh@364 513 look_for_cookopt !unpack && nounpack=yes
gokhlayeh@290 514 report step "Checking for source tarball: $PACKAGE"
slaxemulator@326 515 local repack_src=$repack_src TARBALL=$TARBALL
gokhlayeh@266 516 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
gokhlayeh@266 517 repack_src=no
gokhlayeh@266 518 fi
gokhlayeh@266 519 if [ "$target" ]; then
gokhlayeh@266 520 src="$target"
gokhlayeh@266 521 else
gokhlayeh@266 522 set_src_path
gokhlayeh@266 523 fi
gokhlayeh@266 524 tmp_src=$tmp/tarball-$$
gokhlayeh@253 525 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
gokhlayeh@253 526 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
gokhlayeh@253 527 cd $SOURCES_REPOSITORY
gokhlayeh@266 528 if [ "$SOURCE" ]; then
gokhlayeh@266 529 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
gokhlayeh@266 530 else
gokhlayeh@266 531 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
pankso@18 532 fi
gokhlayeh@420 533 download $WGET_URL $alt_url http://mirror.slitaz.org/sources/packages/${TARBALL:0:1}/$TARBALL
gokhlayeh@266 534 unset alt_url
gokhlayeh@253 535 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
gokhlayeh@266 536 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
gokhlayeh@266 537 [ ! -d $tmp_src ]; then
gokhlayeh@253 538 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
gokhlayeh@253 539 report end-step
gokhlayeh@253 540 return 1
gokhlayeh@253 541 fi
slaxemulator@232 542 fi
gokhlayeh@253 543 report end-step
gokhlayeh@364 544 if { [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ] ; } || \
gokhlayeh@364 545 { [ -f "$SOURCES_REPOSITORY/$TARBALL" ] && [ "$repack_src" != yes ] && [ "$nounpack" ] ; }; then
gokhlayeh@266 546 [ -d "$tmp_src" ] && rm -r $tmp_src
gokhlayeh@364 547 return 0
slaxemulator@232 548 fi
slaxemulator@232 549
slaxemulator@232 550 # Untaring source if necessary. We don't need to extract source if
slaxemulator@232 551 # the package is built with a wanted source package.
slaxemulator@232 552 if [ "$WANTED" ]; then
gokhlayeh@266 553 [ -d "$tmp_src" ] && rm -r $tmp_src
slaxemulator@232 554 return
slaxemulator@232 555 fi
slaxemulator@232 556
slaxemulator@232 557 report step "Untaring source tarball"
slaxemulator@232 558
slaxemulator@232 559 # Log process.
slaxemulator@232 560 echo "untaring source tarball" >> $LOG
gokhlayeh@266 561
paul@430 562 # If $tmp_src exists, there's already a unpacked tarball in it.
gokhlayeh@266 563 if ! [ -d $tmp_src ]; then
gokhlayeh@266 564 mkdir $tmp_src
gokhlayeh@266 565 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
gokhlayeh@266 566 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
gokhlayeh@266 567 tar xf - -C $tmp_src
gokhlayeh@266 568 repack_src=no
gokhlayeh@266 569 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
gokhlayeh@266 570 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
gokhlayeh@266 571 case "$TARBALL" in
gokhlayeh@266 572 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
gokhlayeh@266 573 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
gokhlayeh@266 574 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
gokhlayeh@266 575 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
gokhlayeh@266 576 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
gokhlayeh@266 577 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
gokhlayeh@266 578 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
gokhlayeh@266 579 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
gokhlayeh@266 580
gokhlayeh@266 581 # It's a plain file or something receipt unpack itself.
gokhlayeh@266 582 *)
gokhlayeh@266 583 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
gokhlayeh@266 584 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
gokhlayeh@266 585 ;;
gokhlayeh@266 586
gokhlayeh@271 587 esac || { report end-step
gokhlayeh@271 588 rm -f $SOURCES_REPOSITORY/$TARBALL
gokhlayeh@271 589 rm -r $tmp_src
gokhlayeh@271 590 return 1
gokhlayeh@271 591 }
gokhlayeh@266 592 fi
gokhlayeh@266 593
slaxemulator@232 594 # Check if uncompressed tarball is in a root dir or not.
gokhlayeh@266 595 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
slaxemulator@232 596 if check_for_var_modification src _pkg; then
slaxemulator@232 597 mv $tmp_src $tmp_src-1
slaxemulator@232 598 mkdir $tmp_src
gokhlayeh@233 599 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
slaxemulator@232 600 else
slaxemulator@232 601 mv $tmp_src/* $WOK/$PACKAGE
slaxemulator@232 602 repack_src=no
slaxemulator@232 603 rm -r $tmp_src
paul@430 604 tazwok_warning "Putting all files in $WOK/$PACKAGE; not sure about how to handle this tarball (no root dir)... Please try to remove src/_pkg definition from the receipt if you encounter any problems."
pankso@18 605 fi
slaxemulator@232 606 fi
gokhlayeh@266 607 fi
gokhlayeh@266 608
gokhlayeh@266 609 if [ "$repack_src" = yes ]; then
slaxemulator@232 610 report step "Repacking sources in .tar.lzma format"
gokhlayeh@266 611 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
gokhlayeh@266 612 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
slaxemulator@232 613 cd $tmp_src
gokhlayeh@266 614 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
gokhlayeh@266 615 fi
slaxemulator@232 616
gokhlayeh@266 617 # Remove previous tarball if no other package needs it. We take care to
paul@430 618 # keep tarball if the same package uses it in the main repository.
gokhlayeh@266 619 if [ "$TARBALL" ]; then
gokhlayeh@266 620 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
gokhlayeh@266 621 if [ "$previous_tarball" ]; then
gokhlayeh@266 622 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
gokhlayeh@266 623 -i $SOURCES_REPOSITORY/sources.list
gokhlayeh@266 624 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
gokhlayeh@266 625 rm -f $SOURCES_REPOSITORY/$previous_tarball
gokhlayeh@266 626 else
gokhlayeh@266 627 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
slaxemulator@232 628 fi
slaxemulator@232 629 fi
gokhlayeh@266 630
slaxemulator@232 631 if [ "$nounpack" ]; then
slaxemulator@232 632 [ -d "$tmp_src" ] && rm -r $tmp_src
gokhlayeh@285 633 report end-step
slaxemulator@232 634 return
slaxemulator@232 635 fi
gokhlayeh@285 636 if [ ! -d "$src" ]|| [ "$target" ]; then
gokhlayeh@285 637 # Permissions settings.
gokhlayeh@285 638 chown -R root.root "$tmp_src"
gokhlayeh@285 639 if [ -d "$src" ]; then
gokhlayeh@285 640 mkdir -p $src
gokhlayeh@285 641 for f in $tmp_src/*/*; do
gokhlayeh@285 642 cp -a $f $src || { report end-step; rm -r $tmp_src; return 1; }
gokhlayeh@285 643 done
gokhlayeh@285 644 else
gokhlayeh@285 645 if ! check_for_var_modification src _pkg && ! [ "$target" ]; then
gokhlayeh@285 646 src="${src%/*}/$(ls $tmp_src)"
gokhlayeh@285 647 fi
gokhlayeh@285 648 mv $(echo $tmp_src/*) "$src" || { report end-step; rm -r $tmp_src; return 1; }
gokhlayeh@186 649 fi
gokhlayeh@266 650 rm -r $tmp_src
gokhlayeh@266 651 else
gokhlayeh@266 652 [ -d "$tmp_src" ] && rm -r $tmp_src
gokhlayeh@266 653 echo "There's already something at $src. Abort." >&2
gokhlayeh@186 654 fi
gokhlayeh@285 655 report end-step
gokhlayeh@186 656 }
gokhlayeh@186 657
gokhlayeh@186 658 # Log and execute compile_rules function if it exists, to configure and
gokhlayeh@186 659 # make the package if it exists.
gokhlayeh@186 660 check_for_compile_rules()
gokhlayeh@186 661 {
gokhlayeh@186 662 if grep -q ^compile_rules $RECEIPT; then
gokhlayeh@186 663 echo "executing compile_rules" >> $LOG
gokhlayeh@186 664 report step "Executing compile_rules"
gokhlayeh@186 665 cd $WOK/$PACKAGE
gokhlayeh@186 666 rm -f /tmp/config.site
pascal@385 667 ulimit -d unlimited
pascal@385 668 ulimit -m unlimited
gokhlayeh@186 669
gokhlayeh@186 670 # Free some RAM by cleaning cache if option is enabled.
slaxemulator@200 671 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
gokhlayeh@186 672
gokhlayeh@186 673 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
gokhlayeh@186 674 # RAM are available.
gokhlayeh@195 675 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
gokhlayeh@195 676 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
paul@430 677 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM is available."
gokhlayeh@186 678 CFLAGS="${CFLAGS/-pipe}"
gokhlayeh@186 679 CXXFLAGS="${CXXFLAGS/-pipe}"
gokhlayeh@186 680 fi
gokhlayeh@186 681 unset freeram
gokhlayeh@186 682
paul@430 683 # Set cook environement variables.
gokhlayeh@186 684 [ "$src" ] || set_src_path
gokhlayeh@186 685 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
gokhlayeh@186 686 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
gokhlayeh@186 687 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
gokhlayeh@186 688 CONFIG_SITE default_prefix \
gokhlayeh@186 689 default_datarootdir default_datadir default_localedir \
gokhlayeh@186 690 default_infodir default_mandir default_build default_host
gokhlayeh@186 691 local LC_ALL=POSIX LANG=POSIX
gokhlayeh@186 692 compile_rules
gokhlayeh@186 693
gokhlayeh@186 694 # Check if config.site has been used.
paul@430 695 # /!\ disabled since it screws the return_code of the step.
gokhlayeh@186 696 #if [ -f /tmp/config.site ]; then
gokhlayeh@186 697 # rm /tmp/config.site
gokhlayeh@186 698 #else
gokhlayeh@186 699 # tazwok_warning "config.site hasn't been used during \
paul@430 700 #the configuration process."
gokhlayeh@186 701 #fi
gokhlayeh@186 702 report end-step
pankso@18 703 fi
pankso@18 704 }
pascal@76 705
paul@430 706 # Check for loop in deps tree. /!\ can be removed.
pascal@76 707 check_for_deps_loop()
pascal@76 708 {
pascal@76 709 local list
pascal@76 710 local pkg
pascal@76 711 local deps
pascal@76 712 pkg=$1
pascal@76 713 shift
pascal@76 714 [ -n "$1" ] || return
pascal@76 715 list=""
gokhlayeh@204 716
paul@430 717 # Filter out already processed deps.
pascal@76 718 for i in $@; do
pascal@76 719 case " $ALL_DEPS" in
pascal@76 720 *\ $i\ *);;
pascal@76 721 *) list="$list $i";;
pascal@76 722 esac
pascal@76 723 done
pascal@76 724 ALL_DEPS="$ALL_DEPS$list "
pascal@76 725 for i in $list; do
pascal@76 726 [ -f $i/receipt ] || continue
pascal@76 727 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
pascal@76 728 case " $deps " in
pascal@76 729 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
pascal@76 730 *) check_for_deps_loop $pkg $deps;;
pascal@76 731 esac
pascal@76 732 done
pascal@76 733 }
pascal@76 734
gokhlayeh@266 735 # Function used by download().
gokhlayeh@266 736 revert_vcs_failure()
gokhlayeh@266 737 {
gokhlayeh@266 738 cd $SOURCES_REPOSITORY
gokhlayeh@266 739 rm -r $tmp_src
gokhlayeh@266 740 }
gokhlayeh@266 741
erjo@53 742 download()
erjo@53 743 {
gokhlayeh@278 744 if [ "$COMMAND" = get-src ]; then
gokhlayeh@278 745 if [ "${DEPENDS/tar}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/tar}" != "$BUILD_DEPENDS" ]; then
slaxemulator@287 746 [ -f $INSTALLED/tar/receipt ] || tazpkg get-install tar --forced
pankso@7 747 fi
pankso@7 748 fi
pascal@178 749 for file in $@; do
gokhlayeh@266 750 echo "Downloading from ${file#*|}..."
gokhlayeh@255 751 case "$file" in
gokhlayeh@266 752 git\|*)
gokhlayeh@266 753 file=${file#git|}
gokhlayeh@278 754 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/git/receipt ] && tazpkg get-install git --forced
slaxemulator@274 755 if [ -f $INSTALLED/git/receipt ]; then
gokhlayeh@266 756 mkdir $tmp_src
gokhlayeh@266 757 cd $tmp_src
gokhlayeh@266 758 if [ "$BRANCH" ]; then
slaxemulator@426 759 git clone $file ${src##*/} && cd ${src##*/} && \
gokhlayeh@266 760 git checkout $BRANCH && rm -rf .git* && break
gokhlayeh@266 761 else
gokhlayeh@266 762 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
gokhlayeh@266 763 fi
gokhlayeh@266 764 revert_vcs_failure
gokhlayeh@266 765 else
paul@430 766 tazwok_warning "Needs git to download the source tarball from $file, please add it as a build-depend."
gokhlayeh@266 767 continue
gokhlayeh@266 768 fi
gokhlayeh@266 769 ;;
slaxemulator@426 770 bazaar\|*)
slaxemulator@426 771 file=${file#bazaar|}
slaxemulator@426 772 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/bazaar/receipt ] && tazpkg get-install bazaar --forced
slaxemulator@426 773 if [ -f $INSTALLED/bazaar/receipt ]; then
slaxemulator@426 774 mkdir $tmp_src
slaxemulator@426 775 cd $tmp_src
slaxemulator@426 776 if [ "$BRANCH" ]; then
slaxemulator@426 777 bzr co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.bzr* && break
slaxemulator@426 778 else
slaxemulator@426 779 bzr co $file ${src##*/} && rm -rf ${src##*/}/.bzr* && break
slaxemulator@426 780 fi
slaxemulator@426 781 revert_vcs_failure
slaxemulator@426 782 else
paul@430 783 tazwok_warning "Needs bazaar to download the source tarball from $file, please add it as a build-depend."
slaxemulator@426 784 continue
slaxemulator@426 785 fi
slaxemulator@426 786 ;;
gokhlayeh@266 787 subversion\|*)
gokhlayeh@266 788 file=${file#subversion|}
gokhlayeh@278 789 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
slaxemulator@274 790 if [ -f $INSTALLED/subversion/receipt ]; then
gokhlayeh@266 791 mkdir $tmp_src
gokhlayeh@266 792 cd $tmp_src
gokhlayeh@266 793 if [ "$BRANCH" ]; then
gokhlayeh@266 794 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
gokhlayeh@266 795 else
gokhlayeh@266 796 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
gokhlayeh@266 797 fi
gokhlayeh@266 798 revert_vcs_failure
gokhlayeh@266 799 else
paul@430 800 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as a build-depend."
gokhlayeh@266 801 continue
gokhlayeh@266 802 fi
gokhlayeh@266 803 ;;
gokhlayeh@266 804 mercurial\|*)
gokhlayeh@266 805 file=${file#mercurial|}
gokhlayeh@278 806 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
slaxemulator@274 807 if [ -f $INSTALLED/mercurial/receipt ]; then
gokhlayeh@266 808 mkdir $tmp_src
gokhlayeh@266 809 cd $tmp_src
gokhlayeh@266 810 if [ "$BRANCH" ]; then
gokhlayeh@266 811 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
gokhlayeh@266 812 else
gokhlayeh@266 813 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
gokhlayeh@266 814 fi
gokhlayeh@266 815 revert_vcs_failure
gokhlayeh@266 816 else
paul@430 817 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as a build-depend."
gokhlayeh@266 818 continue
gokhlayeh@266 819 fi
gokhlayeh@266 820 ;;
gokhlayeh@266 821 https*)
gokhlayeh@278 822 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
gokhlayeh@255 823 if [ -d $INSTALLED/wget ]; then
gokhlayeh@266 824 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
gokhlayeh@266 825 wget -q --no-check-certificate -O $TARBALL $file && break
gokhlayeh@266 826 else
gokhlayeh@290 827 wget -q --no-check-certificate $file && break
gokhlayeh@266 828 fi
gokhlayeh@255 829 else
paul@430 830 tazwok_warning "Needs wget to download the source tarball from $file, please add it as a build-depend."
gokhlayeh@266 831 continue
gokhlayeh@255 832 fi
gokhlayeh@266 833 ;;
gokhlayeh@266 834 http*|ftp*)
gokhlayeh@266 835 # Handle crappy URL.
gokhlayeh@278 836 if [ "$COMMAND" = get-src ]; then
gokhlayeh@278 837 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
gokhlayeh@278 838 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
gokhlayeh@278 839 fi
gokhlayeh@278 840 fi
gokhlayeh@266 841 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
gokhlayeh@266 842 wget -q -O $TARBALL $file && break
gokhlayeh@266 843 else
gokhlayeh@266 844 wget -q $file && break
gokhlayeh@266 845 fi
gokhlayeh@266 846 ;;
gokhlayeh@255 847 esac
pascal@178 848 done
pankso@7 849 }
pankso@7 850
paul@430 851 # Regenerate every package that wants a PACKAGE compiled.
pascal@156 852 refresh_packages_from_compile()
pascal@156 853 {
paul@430 854 # make tazwok genpkg happy.
pascal@156 855 mkdir $WOK/$PACKAGE/taz
gokhlayeh@204 856
paul@430 857 # Cook rwanted in default or specied order.
gokhlayeh@186 858 genlist=" $(look_for_rwanted | tr '\n' ' ') "
gokhlayeh@186 859 for i in $(look_for_cookopt genpkg | tac); do
gokhlayeh@186 860 [ "${genlist/ $i }" = "$genlist" ] && continue
gokhlayeh@186 861 genlist=" $i${genlist/ $i / }"
pascal@156 862 done
gokhlayeh@215 863 if [ "$genlist" ]; then
gokhlayeh@215 864 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
gokhlayeh@215 865 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
gokhlayeh@215 866 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
gokhlayeh@298 867 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG stuff wanted_stuff
gokhlayeh@215 868 for PACKAGE in $genlist; do
gokhlayeh@215 869 set_common_path
gokhlayeh@215 870 gen_package
gokhlayeh@215 871 done
gokhlayeh@215 872 fi
pascal@156 873 }
pascal@156 874
MikeDSmith25@82 875 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
pankso@22 876 # so some packages need to copy these files with the receipt and genpkg_rules.
pankso@22 877 # This function is executed by gen_package when 'tazwok genpkg'.
pankso@22 878 copy_generic_files()
pankso@22 879 {
MikeDSmith25@82 880 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
pankso@22 881 # using generic variables and $LOCALE from Tazwok config file.
gokhlayeh@186 882 if [ "$LOCALE" ]; then
pankso@22 883 if [ -d "$_pkg/usr/share/locale" ]; then
pankso@22 884 for i in $LOCALE
pankso@22 885 do
pankso@37 886 if [ -d "$_pkg/usr/share/locale/$i" ]; then
pankso@37 887 mkdir -p $fs/usr/share/locale
pankso@37 888 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
pankso@37 889 fi
pankso@22 890 done
pankso@22 891 fi
pankso@22 892 fi
gokhlayeh@186 893
pankso@133 894 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
MikeDSmith25@82 895 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
pankso@31 896 # in pkg receipt.
gokhlayeh@186 897 if [ "$GENERIC_PIXMAPS" != "no" ]; then
pankso@22 898 if [ -d "$_pkg/usr/share/pixmaps" ]; then
pankso@27 899 mkdir -p $fs/usr/share/pixmaps
pankso@31 900 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
pankso@31 901 $fs/usr/share/pixmaps 2>/dev/null
pankso@31 902 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
pankso@22 903 $fs/usr/share/pixmaps 2>/dev/null
pankso@23 904 fi
gokhlayeh@186 905
MikeDSmith25@82 906 # Custom or homemade PNG pixmap can be in stuff.
pankso@23 907 if [ -f "stuff/$PACKAGE.png" ]; then
pankso@27 908 mkdir -p $fs/usr/share/pixmaps
pankso@23 909 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
pankso@22 910 fi
pankso@22 911 fi
gokhlayeh@186 912
pankso@22 913 # Desktop entry (.desktop).
pankso@22 914 if [ -d "$_pkg/usr/share/applications" ]; then
pankso@22 915 cp -a $_pkg/usr/share/applications $fs/usr/share
pankso@23 916 fi
gokhlayeh@186 917
MikeDSmith25@82 918 # Homemade desktop file(s) can be in stuff.
pankso@34 919 if [ -d "stuff/applications" ]; then
pankso@42 920 mkdir -p $fs/usr/share
pankso@42 921 cp -a stuff/applications $fs/usr/share
pankso@34 922 fi
pankso@34 923 if [ -f "stuff/$PACKAGE.desktop" ]; then
pankso@42 924 mkdir -p $fs/usr/share/applications
pankso@42 925 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
pankso@22 926 fi
pankso@22 927 }
pankso@22 928
pankso@25 929 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
pankso@25 930 strip_package()
pankso@25 931 {
gokhlayeh@186 932 report step "Executing strip on all files"
gokhlayeh@186 933
pankso@25 934 # Binaries.
pankso@25 935 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
pankso@25 936 do
pankso@25 937 if [ -d "$dir" ]; then
pankso@25 938 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
pankso@25 939 fi
pankso@25 940 done
gokhlayeh@186 941
pankso@25 942 # Libraries.
pankso@25 943 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
pankso@25 944 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
gokhlayeh@186 945 report end-step
pankso@25 946 }
pankso@25 947
paul@430 948 # Remove .pyc and .pyo files from packages.
slaxemulator@183 949 py_compiled_files_remove()
slaxemulator@183 950 {
paul@438 951 report step "Removing all .pyc and .pyo files from package"
slaxemulator@183 952 find $fs -type f -name "*.pyc" -delete 2>/dev/null
slaxemulator@183 953 find $fs -type f -name "*.pyo" -delete 2>/dev/null
gokhlayeh@186 954 report end-step
slaxemulator@183 955 }
slaxemulator@183 956
pankso@135 957 # Check FSH in a slitaz package (Path: /:/usr)
pankso@135 958 check_fsh()
pankso@135 959 {
pankso@135 960 cd $WOK/$PACKAGE/taz/*/fs
pascal@428 961 if [ -z "$(find * ! -type d)" ] && [ "$CATEGORY" != meta ]; then
gokhlayeh@381 962 echo "$PACKAGE fs is empty." >&2
gokhlayeh@381 963 cd $WOK/$PACKAGE && rm -rf taz
gokhlayeh@381 964 return 1
gokhlayeh@381 965 fi
pascal@149 966 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
pascal@149 967 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
pascal@149 968 usr/local usr/sbin usr/share usr/src"
pankso@135 969 for i in `ls -d * usr/* 2>/dev/null`
pankso@135 970 do
gokhlayeh@195 971 if ! echo $FSH | fgrep -q $i; then
gokhlayeh@186 972 echo "Wrong path: /$i" >&2
pankso@135 973 error=1
pankso@135 974 fi
pankso@135 975 done
pankso@135 976 if [ "$error" = "1" ]; then
pankso@135 977 cat << _EOT_
pankso@135 978
paul@155 979 Package will install files in a non standard directory and won't be generated.
paul@154 980 You may have a wrong copy path in genpkg_rules or need to add some options to
pankso@135 981 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
pankso@135 982
pankso@135 983 --prefix=/usr
pankso@135 984 --sysconfdir=/etc
pankso@135 985 --libexecdir=/usr/lib/(pkgname)
pankso@135 986 --localstatedir=/var
pankso@135 987 --mandir=/usr/share/man
pankso@135 988 --infodir=/usr/share/info
pankso@135 989
paul@152 990 For more information please read SliTaz docs and run: ./configure --help
pankso@135 991 ================================================================================
pankso@135 992 $PACKAGE package generation aborted.
pankso@135 993
pankso@135 994 _EOT_
gokhlayeh@186 995
pankso@135 996 # Dont generate a corrupted package.
pankso@137 997 cd $WOK/$PACKAGE && rm -rf taz
gokhlayeh@381 998 return 1
pankso@135 999 fi
gokhlayeh@381 1000 return 0
gokhlayeh@186 1001 }
gokhlayeh@186 1002
gokhlayeh@186 1003 gen_cookmd5()
gokhlayeh@186 1004 {
gokhlayeh@186 1005 # md5sum of cooking stuff make tazwok able to check for changes
gokhlayeh@186 1006 # without hg.
gokhlayeh@186 1007 cd $WOK/$PACKAGE
gokhlayeh@186 1008 md5sum receipt > md5
gokhlayeh@186 1009 [ -f description.txt ] && md5sum description.txt >> md5
gokhlayeh@186 1010 if [ -d stuff ]; then
gokhlayeh@186 1011 find stuff | while read file; do
gokhlayeh@186 1012 md5sum $file >> md5
gokhlayeh@186 1013 done
gokhlayeh@186 1014 fi
pankso@135 1015 }
pankso@135 1016
gokhlayeh@381 1017 set_pkg_broken()
gokhlayeh@381 1018 {
gokhlayeh@405 1019 grep -q ^$PACKAGE$ $broken || echo $PACKAGE >> $broken
gokhlayeh@381 1020
paul@430 1021 # Remove pkg from cooklist to avoid re-cook it if no changes happen
gokhlayeh@381 1022 # in the cook stuff.
gokhlayeh@405 1023 sed "/^$PACKAGE$/d" -i $cooklist $commit
gokhlayeh@381 1024
gokhlayeh@381 1025 gen_cookmd5
gokhlayeh@381 1026
paul@430 1027 # Return 1 to make report know that its mother-function failed.
gokhlayeh@381 1028 return 1
gokhlayeh@381 1029 }
gokhlayeh@381 1030
MikeDSmith25@82 1031 # Create a package tree and build the gziped cpio archive
pankso@7 1032 # to make a SliTaz (.tazpkg) package.
pankso@7 1033 gen_package()
pankso@7 1034 {
pankso@7 1035 check_root
pankso@7 1036 check_for_package_on_cmdline
pankso@7 1037 check_for_receipt
gokhlayeh@381 1038 source_receipt
gokhlayeh@186 1039
pascal@86 1040 # May compute VERSION
pascal@86 1041 if grep -q ^get_version $RECEIPT; then
pascal@86 1042 get_version
pascal@86 1043 fi
pankso@7 1044 check_for_wanted
pankso@7 1045 cd $WOK/$PACKAGE
gokhlayeh@186 1046
pankso@7 1047 # Remove old Tazwok package files.
gokhlayeh@186 1048 [ -d "taz" ] && rm -rf taz
gokhlayeh@186 1049
MikeDSmith25@82 1050 # Create the package tree and set useful variables.
gokhlayeh@266 1051 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
gokhlayeh@381 1052 mkdir -p $fs
gokhlayeh@186 1053
MikeDSmith25@82 1054 # Set $src for standard package and $_pkg variables.
gokhlayeh@302 1055 set_src_path
gokhlayeh@302 1056 set_pkg_path
gokhlayeh@186 1057
pankso@135 1058 # Execute genpkg_rules, check package and copy generic files to build
pankso@135 1059 # the package.
gokhlayeh@186 1060 report step "Building $PACKAGE with the receipt"
gokhlayeh@186 1061 report open-bloc
gokhlayeh@381 1062 if look_for_cookopt !fs; then
gokhlayeh@381 1063 :
gokhlayeh@381 1064 elif grep -q ^genpkg_rules $RECEIPT; then
gokhlayeh@186 1065
pankso@7 1066 # Log process.
pankso@7 1067 echo "executing genpkg_rules" >> $LOG
gokhlayeh@186 1068 report step "Executing genpkg_rules"
gokhlayeh@381 1069 ( set -e; genpkg_rules ) || { set_pkg_broken; report close-bloc; return 1; }
gokhlayeh@381 1070 check_fsh || { set_pkg_broken; report close-bloc; return 1; }
gokhlayeh@381 1071 cd $WOK/$PACKAGE
gokhlayeh@186 1072 report end-step
gokhlayeh@381 1073
pankso@133 1074 # Skip generic files for packages with a WANTED variable
paul@430 1075 # (dev and split pkgs).
gokhlayeh@186 1076 if [ ! "$WANTED" ]; then
pankso@24 1077 copy_generic_files
pankso@24 1078 fi
gokhlayeh@204 1079 look_for_cookopt !strip || strip_package
slaxemulator@183 1080 py_compiled_files_remove
pankso@7 1081 else
gokhlayeh@186 1082 echo "No package rules to gen $PACKAGE..." >&2
gokhlayeh@381 1083 set_pkg_broken
gokhlayeh@381 1084 report close-bloc
gokhlayeh@381 1085 return 1
pankso@7 1086 fi
gokhlayeh@186 1087
paul@154 1088 # Copy the receipt and description (if exists) into the binary package tree.
pankso@7 1089 cd $WOK/$PACKAGE
gokhlayeh@186 1090 report step "Copying the receipt"
pankso@7 1091 cp receipt taz/$PACKAGE-$VERSION
gokhlayeh@186 1092 report end-step
pascal@89 1093 if grep -q ^get_version $RECEIPT; then
gokhlayeh@186 1094 report step "Updating version in receipt"
pascal@89 1095 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
pascal@89 1096 taz/$PACKAGE-$VERSION/receipt
gokhlayeh@186 1097 report end-step
pascal@89 1098 fi
pankso@7 1099 if [ -f "description.txt" ]; then
gokhlayeh@186 1100 report step "Copying the description file"
pankso@7 1101 cp description.txt taz/$PACKAGE-$VERSION
gokhlayeh@186 1102 report end-step
pankso@7 1103 fi
gokhlayeh@186 1104
gokhlayeh@186 1105 # Generate md5 of cooking stuff to look for commit later.
gokhlayeh@186 1106 gen_cookmd5
gokhlayeh@186 1107 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
gokhlayeh@186 1108 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
gokhlayeh@186 1109
MikeDSmith25@82 1110 # Create the files.list by redirecting find output.
gokhlayeh@186 1111 report step "Creating the list of files"
pascal@15 1112 cd taz/$PACKAGE-$VERSION
pascal@13 1113 LAST_FILE=""
gokhlayeh@195 1114 { find fs -print; echo; } | while read file; do
gokhlayeh@186 1115 if [ "$LAST_FILE" ]; then
pascal@15 1116 case "$file" in
pascal@13 1117 $LAST_FILE/*)
pankso@133 1118 case "$(ls -ld "$LAST_FILE")" in
pascal@15 1119 drwxr-xr-x\ *\ root\ *\ root\ *);;
pascal@15 1120 *) echo ${LAST_FILE#fs};;
pascal@13 1121 esac;;
pascal@15 1122 *) echo ${LAST_FILE#fs};;
pascal@13 1123 esac
pascal@13 1124 fi
pascal@15 1125 LAST_FILE="$file"
pascal@15 1126 done > files.list
gokhlayeh@186 1127
gokhlayeh@186 1128 # Next, check if something has changed in lib files.
gokhlayeh@450 1129 # Plan to recook each packages which depends on libs
gokhlayeh@450 1130 # which doesn't exists anymore.
gokhlayeh@450 1131 libs=$(for file in $(find * -type f); do
gokhlayeh@450 1132 [ "$(dd if=$file bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] || continue
gokhlayeh@450 1133 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $PWD/$file
gokhlayeh@450 1134 done | { cut -f 1 -d ' ' | tr -d '\t' | sort -u | \
gokhlayeh@450 1135 sed -e 's/^linux-gate.so.*$/SLIB/' -e 's~^/lib/ld-.*$~SLIB~' \
gokhlayeh@450 1136 -e '/^statically$/d' | tr '\n' ' '; })
gokhlayeh@459 1137 [ "$libs" ] && libs=$(echo " $libs" | sed -r 's/( SLIB)+ / /g')
gokhlayeh@450 1138 old_libs=$(grep -m1 ^$PACKAGE$'\t' $lib_db | cut -f 2)
gokhlayeh@450 1139 if [ "$old_libs" ]; then
gokhlayeh@450 1140 report step "Looking if reverse depends needs to be refreshed"
gokhlayeh@450 1141 for i in $old_libs; do
gokhlayeh@450 1142 [ "${libs/ $i }" = "$libs" ] || continue
gokhlayeh@450 1143 fgrep " $i " $lib_db | cut -f 1
gokhlayeh@450 1144 done | sort -u | while read rdep; do
gokhlayeh@450 1145 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
gokhlayeh@450 1146 grep -q ^$rdep$ $blocked $cooklist && continue
gokhlayeh@450 1147 echo "Plan to recook $rdep"
gokhlayeh@450 1148 echo $rdep >> $cooklist
gokhlayeh@215 1149 done
gokhlayeh@450 1150 sed "/^$PACKAGE\t/d" -i $lib_db
gokhlayeh@450 1151 report end-step
gokhlayeh@450 1152 fi
gokhlayeh@450 1153 if [ "$libs" ]; then
gokhlayeh@450 1154 echo -e "$PACKAGE\t$libs" >> $lib_db
gokhlayeh@450 1155 sort -o $lib_db $lib_db
gokhlayeh@450 1156 fi
gokhlayeh@450 1157
gokhlayeh@186 1158 if [ ! "$EXTRAVERSION" ]; then
pascal@84 1159 case "$PACKAGE" in
pascal@84 1160 linux*);;
pascal@85 1161 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
pascal@84 1162 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
pascal@84 1163 esac
pascal@84 1164 fi
gokhlayeh@186 1165 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
gokhlayeh@186 1166 report step "Creating md5sum of files"
pascal@70 1167 while read file; do
pascal@71 1168 [ -L "fs$file" ] && continue
pascal@71 1169 [ -f "fs$file" ] || continue
pascal@71 1170 md5sum "fs$file" | sed 's/ fs/ /'
pascal@70 1171 done < files.list > md5sum
gokhlayeh@204 1172 report end-step
pascal@84 1173 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
pascal@84 1174 2> /dev/null | awk '{ sz=$1 } END { print sz }')
gokhlayeh@186 1175
pankso@7 1176 # Build cpio archives. Find, cpio and gzip the fs, finish by
pankso@7 1177 # removing the fs tree.
paul@430 1178 # Don't log this because compression always outputs error messages.
pascal@150 1179 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
pascal@150 1180 tazpkg-lzma) gzip > fs.cpio.gz;;
pascal@150 1181 *-lzma) lzma e fs.cpio.lzma -si;;
pascal@150 1182 *) gzip > fs.cpio.gz;;
pascal@150 1183 esac && rm -rf fs
pascal@150 1184 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
pascal@84 1185 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
gokhlayeh@186 1186 report step "Updating receipt sizes"
pascal@138 1187 sed -i '/^PACKED_SIZE/d' receipt
pascal@138 1188 sed -i '/^UNPACKED_SIZE/d' receipt
pascal@59 1189 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
pascal@86 1190 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
gokhlayeh@212 1191 report end-step
gokhlayeh@212 1192 if [ "$EXTRAVERSION" ]; then
gokhlayeh@186 1193 report step "Updating receipt EXTRAVERSION"
pascal@72 1194 sed -i s/^EXTRAVERSION.*$// receipt
pascal@72 1195 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
pascal@72 1196 fi
gokhlayeh@186 1197 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
gokhlayeh@186 1198 remove_previous_package $INCOMING_REPOSITORY
gokhlayeh@186 1199 report step "Creating full cpio archive"
gokhlayeh@186 1200 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
gokhlayeh@186 1201
paul@154 1202 # Restore package tree in case we want to browse it.
gokhlayeh@186 1203 report step "Restoring original package tree"
gokhlayeh@195 1204 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
pascal@150 1205 rm fs.cpio.* && cd ..
gokhlayeh@383 1206
gokhlayeh@449 1207 # Save receipts if save_wok is enabled.
gokhlayeh@449 1208 [ "$save_wok" ] && copy_cooking_stuff $WOK $PACKAGE $INCOMING_REPOSITORY/wok
gokhlayeh@449 1209
gokhlayeh@383 1210 # Recook of reverse-depends if package was broken.
gokhlayeh@405 1211 if grep -q "^$PACKAGE$" $broken; then
paul@430 1212 report step "Planning a re-try cook of reverse depends"
gokhlayeh@405 1213 sed "/^$PACKAGE$/d" -i $broken
gokhlayeh@383 1214 for rdep in $(look_for_rdep); do
gokhlayeh@405 1215 grep -q "^$rdep$" $broken || continue
gokhlayeh@405 1216 grep -q "^$rdep$" $cooklist && continue
gokhlayeh@383 1217 echo "Adding $rdep to the cooklist"
gokhlayeh@405 1218 echo $rdep >> $cooklist
gokhlayeh@383 1219 regen_cooklist=t
gokhlayeh@383 1220 done
gokhlayeh@383 1221 report end-step
gokhlayeh@383 1222 fi
gokhlayeh@405 1223 sed "/^$PACKAGE$/d" -i $commit $cooklist
gokhlayeh@186 1224
pankso@7 1225 # Log process.
pascal@69 1226 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
gokhlayeh@186 1227 report close-bloc
pascal@68 1228 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
gokhlayeh@186 1229 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
pankso@7 1230 echo ""
pankso@7 1231 }
pankso@7 1232
gokhlayeh@186 1233 ########################################################################
gokhlayeh@186 1234 # This section contains functions used by several other functions
paul@430 1235 # below.
gokhlayeh@186 1236 ########################
gokhlayeh@186 1237
gokhlayeh@186 1238 # Look for receipt/files.list in wok. If they can't be found, get them
gokhlayeh@186 1239 # from package. Accept one argument : absolute path to package.
gokhlayeh@186 1240 get_pkg_files()
pankso@28 1241 {
gokhlayeh@186 1242 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
gokhlayeh@186 1243 mkdir -p $pkg_files_dir && \
gokhlayeh@186 1244 cd $pkg_files_dir && \
gokhlayeh@186 1245 cpio --quiet -idm receipt < $1 && \
gokhlayeh@186 1246 cpio --quiet -idm files.list < $1
gokhlayeh@186 1247 }
gokhlayeh@170 1248
gokhlayeh@186 1249 ########################################################################
gokhlayeh@204 1250 # This section contains functions to generate packages databases.
gokhlayeh@186 1251 ########################
gokhlayeh@186 1252
gokhlayeh@186 1253
gokhlayeh@186 1254 gen_packages_db()
gokhlayeh@186 1255 {
gokhlayeh@186 1256 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
gokhlayeh@204 1257 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
gokhlayeh@186 1258 cd $pkg_repository
gokhlayeh@204 1259 report step "Generating packages lists: $pkg_repository"
gokhlayeh@204 1260 report open-bloc
gokhlayeh@204 1261 report step "Removing old files"
gokhlayeh@204 1262 for file in files.list.lzma packages.list packages.txt \
gokhlayeh@204 1263 packages.desc packages.equiv packages.md5; do
gokhlayeh@415 1264 rm -rf $file
gokhlayeh@204 1265 done
gokhlayeh@204 1266 touch files.list
gokhlayeh@204 1267
gokhlayeh@186 1268 packages_db_start
gokhlayeh@186 1269 unset RECEIPT
paul@430 1270 report step "Reading data from all packages"
gokhlayeh@195 1271 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
gokhlayeh@186 1272 get_packages_info
gokhlayeh@186 1273 done
gokhlayeh@186 1274 report end-step
gokhlayeh@186 1275 packages_db_end
gokhlayeh@204 1276 report close-bloc
gokhlayeh@186 1277 }
gokhlayeh@186 1278
gokhlayeh@186 1279 update_packages_db()
gokhlayeh@186 1280 {
gokhlayeh@204 1281 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
gokhlayeh@186 1282 cd $pkg_repository
gokhlayeh@204 1283 for file in packages.list packages.equiv packages.md5 packages.desc \
gokhlayeh@204 1284 packages.txt; do
gokhlayeh@186 1285 if [ ! -f "$file" ]; then
gokhlayeh@204 1286 gen_packages_db
gokhlayeh@186 1287 return
gokhlayeh@170 1288 fi
gokhlayeh@170 1289 done
gokhlayeh@186 1290 if [ -f files.list.lzma ]; then
gokhlayeh@186 1291 lzma d files.list.lzma files.list
gokhlayeh@186 1292 else
gokhlayeh@204 1293 gen_packages_db
gokhlayeh@414 1294 return
gokhlayeh@186 1295 fi
gokhlayeh@204 1296 report step "Updating packages lists: $pkg_repository"
gokhlayeh@186 1297 packages_db_start
gokhlayeh@412 1298
gokhlayeh@186 1299 # Look for removed/update packages.
gokhlayeh@412 1300 touch stamp -r packages.list
gokhlayeh@186 1301 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
gokhlayeh@202 1302 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
gokhlayeh@195 1303 if ! [ -f "$pkg" ]; then
gokhlayeh@186 1304 erase_package_info
gokhlayeh@186 1305 else
gokhlayeh@412 1306 if [ "$pkg" -nt "stamp" ]; then
gokhlayeh@215 1307 updated_pkg="$updated_pkg
gokhlayeh@215 1308 $PACKAGE $pkg"
gokhlayeh@266 1309 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
gokhlayeh@266 1310 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
gokhlayeh@266 1311 erase_package_info
gokhlayeh@415 1312 echo "Removing $PACKAGE from $pkg_repository."
gokhlayeh@266 1313 rm $pkg
gokhlayeh@449 1314 [ "$save_wok" ] && rm -rf $pkg_repository/wok/$PACKAGE
gokhlayeh@449 1315 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
gokhlayeh@449 1316 rm -rf $WOK/$PACKAGE
gokhlayeh@449 1317 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db $cookorder
gokhlayeh@449 1318 sed "/^$PACKAGE$/d" -i $cooklist $commit $blocked $broken
gokhlayeh@449 1319 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html
gokhlayeh@449 1320 if [ "$(sed 1!d $cookorder)" != "#PlanSort" ]; then
gokhlayeh@449 1321 sed 1i"#PlanSort" -i $cookorder
gokhlayeh@449 1322 regen_cooklist=yes
gokhlayeh@449 1323 fi
gokhlayeh@266 1324 else
gokhlayeh@449 1325 echo "$PACKAGE" >> removed
gokhlayeh@415 1326 sed -n '1,10p' -i removed
gokhlayeh@266 1327 fi
gokhlayeh@186 1328 fi
pascal@178 1329 fi
pascal@178 1330 done
gokhlayeh@412 1331 rm stamp
gokhlayeh@215 1332 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
gokhlayeh@202 1333 erase_package_info
gokhlayeh@202 1334 get_packages_info
gokhlayeh@202 1335 done
gokhlayeh@204 1336 unset updated_pkg
gokhlayeh@202 1337
gokhlayeh@186 1338 # Look for new packages.
gokhlayeh@415 1339 for pkg in $pkg_repository/*.tazpkg; do
gokhlayeh@415 1340 fgrep -q " ${pkg##*/}" packages.md5 || get_packages_info
gokhlayeh@186 1341 done
gokhlayeh@186 1342 report end-step
gokhlayeh@186 1343 packages_db_end
gokhlayeh@186 1344 }
gokhlayeh@186 1345
gokhlayeh@186 1346 packages_db_start()
gokhlayeh@186 1347 {
gokhlayeh@415 1348 if [ -s packages.txt ]; then
gokhlayeh@434 1349 sed -e 's/^# Packages :.*/# Packages : unknown/' \
gokhlayeh@415 1350 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
gokhlayeh@415 1351 -i packages.txt
gokhlayeh@415 1352 else
gokhlayeh@186 1353 echo "# SliTaz GNU/Linux - Packages list
gokhlayeh@186 1354 #
paul@430 1355 # Packages : unknown
gokhlayeh@186 1356 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
gokhlayeh@215 1357 #
gokhlayeh@215 1358 " > packages.txt
pascal@60 1359 fi
gokhlayeh@186 1360
paul@430 1361 # Needed in some cases as tazwok defines RECEIPT at configuration time
paul@430 1362 # in this particular case it can break the script.
gokhlayeh@186 1363 unset RECEIPT
gokhlayeh@410 1364
gokhlayeh@410 1365 # If $packages_repository is the main one, configure few functions
gokhlayeh@410 1366 # to act as they should, without having loop on them (speed-up)
gokhlayeh@460 1367 if [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ]; then
gokhlayeh@410 1368 erase_package_info_extracmd="erase_package_info_main"
gokhlayeh@460 1369 get_packages_info_extracmd="get_packages_info_main"
gokhlayeh@439 1370 fi
gokhlayeh@186 1371 }
pankso@28 1372
gokhlayeh@186 1373 erase_package_info()
gokhlayeh@186 1374 {
gokhlayeh@186 1375 cd $pkg_repository
gokhlayeh@186 1376 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
gokhlayeh@186 1377 sed "/^$PACKAGE /d" -i packages.desc
gokhlayeh@186 1378 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
gokhlayeh@186 1379 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
gokhlayeh@186 1380 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
gokhlayeh@186 1381 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
gokhlayeh@186 1382 -i packages.equiv
gokhlayeh@186 1383 sed "/^$PACKAGE:/d" -i files.list
gokhlayeh@186 1384 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
gokhlayeh@186 1385 sed "/ $(basename $pkg)$/d" -i packages.md5
gokhlayeh@410 1386 $erase_package_info_extracmd
gokhlayeh@410 1387 }
gokhlayeh@410 1388
gokhlayeh@410 1389 erase_package_info_main()
gokhlayeh@410 1390 {
gokhlayeh@450 1391 for i in wanted.txt depends.txt libraries.txt; do
gokhlayeh@399 1392 [ -f $i ] || continue
gokhlayeh@399 1393 sed "/^$PACKAGE\t/d" -i $i
gokhlayeh@399 1394 done
gokhlayeh@186 1395 }
gokhlayeh@186 1396
gokhlayeh@186 1397 get_packages_info()
gokhlayeh@186 1398 {
paul@430 1399 # If there's no taz folder in the wok, extract info from the
gokhlayeh@186 1400 # package.
gokhlayeh@186 1401 get_pkg_files $pkg
gokhlayeh@186 1402 source_receipt
paul@430 1403 echo "Getting data from $PACKAGE"
gokhlayeh@186 1404
gokhlayeh@186 1405 cat >> $pkg_repository/packages.txt << _EOT_
pankso@28 1406 $PACKAGE
gokhlayeh@186 1407 $VERSION$EXTRAVERSION
pankso@28 1408 $SHORT_DESC
pankso@28 1409 _EOT_
gokhlayeh@215 1410 if [ "$PACKED_SIZE" ]; then
gokhlayeh@215 1411 cat >> $pkg_repository/packages.txt << _EOT_
pankso@133 1412 $PACKED_SIZE ($UNPACKED_SIZE installed)
gokhlayeh@215 1413
pascal@60 1414 _EOT_
gokhlayeh@215 1415 else
gokhlayeh@215 1416 echo "" >> $pkg_repository/packages.txt
pascal@60 1417 fi
gokhlayeh@186 1418
paul@121 1419 # Packages.desc is used by Tazpkgbox <tree>.
gokhlayeh@186 1420 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
gokhlayeh@186 1421
paul@430 1422 # Packages.equiv is used by tazpkg install to check depends.
pascal@99 1423 for i in $PROVIDE; do
pascal@99 1424 DEST=""
gokhlayeh@195 1425 echo $i | fgrep -q : && DEST="${i#*:}:"
gokhlayeh@186 1426 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
gokhlayeh@186 1427 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
pascal@99 1428 else
gokhlayeh@186 1429 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
gokhlayeh@186 1430 fi
gokhlayeh@186 1431 done
gokhlayeh@186 1432
gokhlayeh@186 1433 if [ -f files.list ]; then
gokhlayeh@186 1434 { echo "$PACKAGE"; cat files.list; } | awk '
gokhlayeh@186 1435 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
gokhlayeh@186 1436 fi
gokhlayeh@186 1437
gokhlayeh@186 1438 cd .. && rm -r "$pkg_files_dir"
gokhlayeh@186 1439
gokhlayeh@186 1440 cd $pkg_repository
gokhlayeh@186 1441 echo $(basename ${pkg%.tazpkg}) >> packages.list
gokhlayeh@410 1442 md5sum $(basename $pkg) >> packages.md5
gokhlayeh@410 1443 $get_packages_info_extracmd
gokhlayeh@410 1444 }
gokhlayeh@399 1445
gokhlayeh@410 1446 get_packages_info_main()
gokhlayeh@410 1447 {
gokhlayeh@410 1448 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
gokhlayeh@410 1449 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> package.txt
gokhlayeh@460 1450 grep -m1 ^$PACKAGE$'\t' $lib_db >> libraries.txt
gokhlayeh@186 1451 }
gokhlayeh@186 1452
gokhlayeh@186 1453 source_receipt()
gokhlayeh@186 1454 {
gokhlayeh@186 1455 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
gokhlayeh@186 1456 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
gokhlayeh@186 1457 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
gokhlayeh@298 1458 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL stuff wanted_stuff
gokhlayeh@186 1459 . ${RECEIPT:-$PWD/receipt}
gokhlayeh@186 1460 }
gokhlayeh@186 1461
gokhlayeh@186 1462 packages_db_end()
gokhlayeh@186 1463 {
gokhlayeh@186 1464 cd $pkg_repository
gokhlayeh@186 1465 pkgs=$(wc -l packages.list | sed 's/ .*//')
gokhlayeh@186 1466 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
gokhlayeh@186 1467
paul@430 1468 # If lists were updated it's generally needed to sort them well.
gokhlayeh@186 1469 if ! sort -c packages.list 2> /dev/null; then
gokhlayeh@186 1470 report step "Sorting packages lists"
gokhlayeh@399 1471 files_list="packages.list packages.desc packages.equiv"
gokhlayeh@415 1472 [ "${pkg_repository##*/}" = packages ] && \
gokhlayeh@450 1473 files_list="$files_list wanted.txt depends.txt libraries.txt"
gokhlayeh@399 1474 for file in $files_list; do
gokhlayeh@186 1475 [ -f $file ] || continue
gokhlayeh@186 1476 sort -o $file $file
gokhlayeh@186 1477 done
gokhlayeh@186 1478 report end-step
gokhlayeh@186 1479 fi
gokhlayeh@460 1480
gokhlayeh@460 1481 md5sum packages.md5 | cut -f1 -d' ' > ID
gokhlayeh@460 1482 [ -s ID ] || echo null > ID
gokhlayeh@186 1483
paul@430 1484 # Dont log this because lzma always output errors.
gokhlayeh@186 1485 lzma e files.list files.list.lzma
gokhlayeh@204 1486 rm -f files.list
gokhlayeh@204 1487 [ -f packages.equiv ] || touch packages.equiv
gokhlayeh@186 1488 }
gokhlayeh@186 1489
gokhlayeh@186 1490 ########################################################################
gokhlayeh@186 1491 # This section contains functions to generate wok database.
gokhlayeh@186 1492 ########################
gokhlayeh@186 1493
gokhlayeh@186 1494 gen_wok_db()
gokhlayeh@186 1495 {
gokhlayeh@204 1496 report step "Generating wok database"
gokhlayeh@186 1497 report open-bloc
gokhlayeh@204 1498 report step "Removing old files"
gokhlayeh@397 1499 for file in $wan_db $dep_db $cookorder; do
gokhlayeh@204 1500 [ -f $file ] && rm $file
gokhlayeh@204 1501 done
gokhlayeh@186 1502 report step "Generating wok-wanted.txt"
gokhlayeh@204 1503 gen_wan_db
gokhlayeh@186 1504 report step "Generating wok-depends.txt"
gokhlayeh@204 1505 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
gokhlayeh@204 1506 $INCOMING_REPOSITORY/packages.desc | sort -u); do
gokhlayeh@186 1507 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@186 1508 if [ -s $RECEIPT ]; then
gokhlayeh@186 1509 source_receipt
gokhlayeh@186 1510 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
pankso@133 1511 fi
pascal@99 1512 done
gokhlayeh@215 1513 sort_db
gokhlayeh@204 1514 report close-bloc
pankso@28 1515 }
pankso@28 1516
gokhlayeh@204 1517 gen_wan_db()
pascal@91 1518 {
gokhlayeh@204 1519 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
gokhlayeh@204 1520 WANTED=
gokhlayeh@204 1521 source $RECEIPT
gokhlayeh@204 1522 [ "$WANTED" ] || continue
gokhlayeh@204 1523 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
gokhlayeh@204 1524 done
gokhlayeh@215 1525 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
gokhlayeh@204 1526 mv -f $tmp/wan_db $wan_db
gokhlayeh@204 1527 plan_regen_cookorder=yes
gokhlayeh@204 1528 else
gokhlayeh@204 1529 rm $tmp/wan_db
gokhlayeh@204 1530 fi
pascal@91 1531 }
pascal@91 1532
gokhlayeh@215 1533 update_wan_db()
gokhlayeh@215 1534 {
slaxemulator@326 1535 local PACKAGE=$PACKAGE
gokhlayeh@423 1536 wanted_list=$(fgrep WANTED=\"$PACKAGE\" $WOK/*/receipt | cut -f1 -d ':')
gokhlayeh@423 1537 grep $'\t'$PACKAGE $wan_db | cut -f 1 | while read wan; do
gokhlayeh@423 1538 echo "$wanted_list" | fgrep -q /$wan/receipt && continue
gokhlayeh@423 1539 sed "/^$wan\t/d" -i $wan_db
gokhlayeh@423 1540 plan_regen_cookorder=yes
gokhlayeh@423 1541 done
gokhlayeh@423 1542 for RECEIPT in $wanted_list; do
gokhlayeh@215 1543 WANTED=
gokhlayeh@215 1544 source $RECEIPT
gokhlayeh@215 1545 [ "$WANTED" ] || continue
gokhlayeh@219 1546 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
gokhlayeh@411 1547 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && continue
gokhlayeh@215 1548 sed "/^$PACKAGE\t/d" -i $wan_db
gokhlayeh@220 1549 echo "$wan_info" >> $wan_db
gokhlayeh@215 1550 plan_regen_cookorder=yes
gokhlayeh@215 1551 plan_sort_wandb=yes
gokhlayeh@215 1552 done
gokhlayeh@423 1553 unset wanted_list
gokhlayeh@215 1554 }
gokhlayeh@215 1555
gokhlayeh@204 1556 update_dep_db()
gokhlayeh@204 1557 {
gokhlayeh@204 1558 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
gokhlayeh@215 1559 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
gokhlayeh@204 1560 sed "/^$PACKAGE\t/d" -i $dep_db
gokhlayeh@204 1561 echo "$dep_info" >> $dep_db
gokhlayeh@204 1562 plan_regen_cookorder=yes
gokhlayeh@204 1563 plan_sort_depdb=yes
pascal@178 1564 }
pascal@178 1565
gokhlayeh@186 1566 sort_db()
pascal@178 1567 {
gokhlayeh@186 1568 report step "Generating cookorder.txt"
gokhlayeh@415 1569 sed 's/ \t / /' $dep_db | while read PACKAGE BUILD_DEPENDS; do
gokhlayeh@186 1570 grep -q ^$PACKAGE$'\t' $wan_db && continue
gokhlayeh@186 1571
gokhlayeh@186 1572 # Replace each BUILD_DEPENDS with a WANTED package by it's
gokhlayeh@186 1573 # WANTED package.
gokhlayeh@415 1574 echo -e $PACKAGE"\t $(echo $BUILD_DEPENDS | use_wanted | \
gokhlayeh@415 1575 sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' ') "
gokhlayeh@186 1576 done > $tmp/db
gokhlayeh@186 1577 while [ -s "$tmp/db" ]; do
gokhlayeh@186 1578 status=start
gokhlayeh@186 1579 for pkg in $(cut -f 1 $tmp/db); do
gokhlayeh@195 1580 if ! fgrep -q ' '$pkg' ' $tmp/db; then
gokhlayeh@186 1581 echo $pkg >> $tmp/cookorder
gokhlayeh@186 1582 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
gokhlayeh@186 1583 status=proceed
gokhlayeh@186 1584 fi
gokhlayeh@186 1585 done
gokhlayeh@186 1586 if [ "$status" = start ]; then
gokhlayeh@186 1587 cp -f $tmp/db /tmp/remain-depends.txt
paul@430 1588 echo "Can't go further because of dependency loop(s). The remaining packages will be commented in the cookorder and will be unbuilt in case of major updates until the problem is solved." >&2
gokhlayeh@415 1589 for remaining in $(cut -f 1 $tmp/db); do
gokhlayeh@415 1590 echo "$remaining" >> $blocked
gokhlayeh@186 1591 done
gokhlayeh@186 1592 break
gokhlayeh@186 1593 fi
gokhlayeh@186 1594 done
gokhlayeh@186 1595 [ -s $tmp/cookorder ] || touch $tmp/cookorder
gokhlayeh@186 1596
gokhlayeh@186 1597 # The toolchain packages are moved in first position.
gokhlayeh@186 1598 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 1599 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
gokhlayeh@397 1600 $tmp/cookorder | tac > $cookorder
gokhlayeh@397 1601 for pkg in $(cat $cookorder); do
gokhlayeh@186 1602 sed "/^$pkg$/d" -i $tmp/cookorder
gokhlayeh@186 1603 done
gokhlayeh@186 1604
gokhlayeh@397 1605 tac $tmp/cookorder >> $cookorder
gokhlayeh@204 1606 unset plan_regen_cookorder
gokhlayeh@186 1607 report end-step
pascal@178 1608 }
pascal@178 1609
gokhlayeh@186 1610 ########################################################################
gokhlayeh@186 1611 # SCAN CORE
gokhlayeh@186 1612 ########################
paul@430 1613 # Includes various scan core-functions. It's not intended to be used
gokhlayeh@186 1614 # directly : prefer scan wrappers in next section.
gokhlayeh@186 1615
gokhlayeh@186 1616 look_for_dep()
gokhlayeh@186 1617 {
gokhlayeh@410 1618 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
gokhlayeh@186 1619 }
gokhlayeh@186 1620
gokhlayeh@186 1621 look_for_bdep()
gokhlayeh@186 1622 {
gokhlayeh@186 1623 look_for_all
gokhlayeh@186 1624 }
gokhlayeh@186 1625
gokhlayeh@186 1626 look_for_all()
gokhlayeh@186 1627 {
gokhlayeh@410 1628 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
gokhlayeh@186 1629 }
gokhlayeh@186 1630
gokhlayeh@186 1631 look_for_rdep()
gokhlayeh@186 1632 {
gokhlayeh@399 1633 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
gokhlayeh@186 1634 }
gokhlayeh@186 1635
gokhlayeh@186 1636 look_for_rbdep()
gokhlayeh@186 1637 {
gokhlayeh@399 1638 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
gokhlayeh@186 1639 }
gokhlayeh@186 1640
gokhlayeh@186 1641 # Return WANTED if it exists.
gokhlayeh@186 1642 look_for_wanted()
gokhlayeh@186 1643 {
gokhlayeh@410 1644 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
gokhlayeh@186 1645 }
gokhlayeh@186 1646
gokhlayeh@186 1647 # Return packages which wants PACKAGE.
gokhlayeh@186 1648 look_for_rwanted()
gokhlayeh@186 1649 {
gokhlayeh@399 1650 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
gokhlayeh@186 1651 }
gokhlayeh@186 1652
gokhlayeh@186 1653 look_for_dev()
gokhlayeh@186 1654 {
gokhlayeh@223 1655 WANTED=$(look_for_wanted)
gokhlayeh@223 1656 if [ "$WANTED" ]; then
gokhlayeh@410 1657 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
gokhlayeh@223 1658 fi
gokhlayeh@410 1659 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
gokhlayeh@186 1660 }
gokhlayeh@186 1661
gokhlayeh@215 1662 with_dev()
gokhlayeh@215 1663 {
gokhlayeh@215 1664 for PACKAGE in $(cat); do
gokhlayeh@215 1665 echo $PACKAGE
gokhlayeh@215 1666 look_for_dev
gokhlayeh@215 1667 done
gokhlayeh@215 1668 }
gokhlayeh@215 1669
gokhlayeh@215 1670 with_wanted()
gokhlayeh@215 1671 {
gokhlayeh@215 1672 for PACKAGE in $(cat); do
gokhlayeh@215 1673 echo $PACKAGE
gokhlayeh@215 1674 look_for_wanted
gokhlayeh@215 1675 done
gokhlayeh@215 1676 }
gokhlayeh@215 1677
gokhlayeh@215 1678 use_wanted()
gokhlayeh@215 1679 {
gokhlayeh@410 1680 for input in $(cat); do
gokhlayeh@410 1681 { grep ^$input$'\t' $wan_db || echo $input
gokhlayeh@415 1682 }
gokhlayeh@415 1683 done | sed 's/.*\t//'
gokhlayeh@415 1684 }
gokhlayeh@415 1685
gokhlayeh@415 1686 check_for_pkg_in_wok()
gokhlayeh@415 1687 {
gokhlayeh@415 1688 [ -f $WOK/$PACKAGE/receipt ] && return
gokhlayeh@415 1689 echo "Can't find $PACKAGE in wok or mirror" >&2
gokhlayeh@415 1690 return 2
gokhlayeh@410 1691 }
gokhlayeh@410 1692
gokhlayeh@410 1693 # Define how theses functions should act when using --undigest.
gokhlayeh@410 1694 use_undigest_scan_core()
gokhlayeh@410 1695 {
gokhlayeh@410 1696 look_for_dep()
gokhlayeh@410 1697 {
gokhlayeh@410 1698 if [ -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@410 1699 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
gokhlayeh@410 1700 else
gokhlayeh@410 1701 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
gokhlayeh@410 1702 fi
gokhlayeh@410 1703 }
gokhlayeh@410 1704
gokhlayeh@410 1705 look_for_all()
gokhlayeh@410 1706 {
gokhlayeh@410 1707 if [ -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@410 1708 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
gokhlayeh@410 1709 else
gokhlayeh@410 1710 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ / /'
gokhlayeh@410 1711 fi
gokhlayeh@410 1712 }
gokhlayeh@410 1713
gokhlayeh@410 1714 look_for_rdep()
gokhlayeh@410 1715 {
gokhlayeh@410 1716 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
gokhlayeh@410 1717 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
gokhlayeh@410 1718 [ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
gokhlayeh@410 1719 done
gokhlayeh@410 1720 }
gokhlayeh@410 1721
gokhlayeh@410 1722 look_for_rbdep()
gokhlayeh@410 1723 {
gokhlayeh@410 1724 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
gokhlayeh@410 1725 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
gokhlayeh@410 1726 [ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
gokhlayeh@410 1727 done
gokhlayeh@410 1728 }
gokhlayeh@410 1729
gokhlayeh@410 1730 look_for_wanted()
gokhlayeh@410 1731 {
gokhlayeh@410 1732 if [ -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@410 1733 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
gokhlayeh@410 1734 else
gokhlayeh@410 1735 grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
gokhlayeh@410 1736 fi
gokhlayeh@410 1737 }
gokhlayeh@410 1738
gokhlayeh@410 1739 look_for_rwanted()
gokhlayeh@410 1740 {
gokhlayeh@410 1741 if [ -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@410 1742 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
gokhlayeh@410 1743 else
gokhlayeh@410 1744 grep $'\t'$PACKAGE$ $ref_wan_db | cut -f 1
gokhlayeh@410 1745 fi
gokhlayeh@410 1746 }
gokhlayeh@410 1747
gokhlayeh@410 1748 look_for_dev()
gokhlayeh@410 1749 {
gokhlayeh@410 1750 WANTED=$(look_for_wanted)
gokhlayeh@410 1751 if [ "$WANTED" ]; then
gokhlayeh@410 1752 if [ -f "$WOK/$WANTED/receipt" ]; then
gokhlayeh@410 1753 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
gokhlayeh@410 1754 else
gokhlayeh@410 1755 grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
gokhlayeh@410 1756 fi
gokhlayeh@410 1757 fi
gokhlayeh@410 1758 if [ -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@410 1759 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
gokhlayeh@410 1760 else
gokhlayeh@410 1761 grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
gokhlayeh@410 1762 fi
gokhlayeh@410 1763 }
gokhlayeh@415 1764
gokhlayeh@415 1765 check_for_pkg_in_wok()
gokhlayeh@415 1766 {
gokhlayeh@415 1767 [ -f $WOK/$PACKAGE/receipt ] && return
gokhlayeh@415 1768 grep -q ^$PACKAGE'$\t' $ref_dep_db && return 1
gokhlayeh@415 1769 echo "Can't find $PACKAGE in wok or mirror" >&2
gokhlayeh@415 1770 return 2
gokhlayeh@415 1771 }
gokhlayeh@215 1772 }
gokhlayeh@215 1773
gokhlayeh@186 1774 ########################################################################
gokhlayeh@186 1775 # SCAN
gokhlayeh@186 1776 ########################
gokhlayeh@186 1777 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
gokhlayeh@186 1778 # Option in command line (must be first arg) :
gokhlayeh@186 1779 # --look_for=bdep/rbdep - Look for depends or reverse depends.
gokhlayeh@186 1780 # --with_dev - Add development packages (*-dev) in the result.
gokhlayeh@186 1781 # --with_wanted - Add package+reverse wanted in the result.
gokhlayeh@186 1782 # --with_args - Include packages in argument in the result.
gokhlayeh@186 1783
gokhlayeh@186 1784 scan()
gokhlayeh@186 1785 {
gokhlayeh@186 1786 # Get packages in argument.
slaxemulator@326 1787 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
gokhlayeh@186 1788 for arg in $@; do
gokhlayeh@186 1789 [ "$arg" = "${arg#--}" ] || continue
gokhlayeh@186 1790 pkg_list="$pkg_list $arg"
gokhlayeh@186 1791 done
gokhlayeh@204 1792
gokhlayeh@186 1793 # Get options.
gokhlayeh@186 1794 [ "$pkg_list" ] || return
gokhlayeh@186 1795 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
gokhlayeh@215 1796 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
gokhlayeh@186 1797 get_options
gokhlayeh@186 1798
gokhlayeh@186 1799 # Cooklist is a special case where we need to modify a little
gokhlayeh@186 1800 # scan behavior
gokhlayeh@186 1801 if [ "$cooklist" ]; then
gokhlayeh@204 1802 gen_wan_db
gokhlayeh@204 1803 look_for=all && with_args=yes && with_dev= && with_wanted=
gokhlayeh@204 1804 filter=use_wanted
gokhlayeh@241 1805 if [ "$COMMAND" = gen-cooklist ]; then
gokhlayeh@241 1806 for PACKAGE in $pkg_list; do
gokhlayeh@241 1807 grep -q ^$PACKAGE$'\t' $dep_db && continue
gokhlayeh@241 1808 [ -d "$WOK/$p" ] || continue
gokhlayeh@241 1809 check_for_missing
gokhlayeh@241 1810 done
gokhlayeh@241 1811 append_to_dep()
gokhlayeh@241 1812 {
gokhlayeh@415 1813 if grep -q ^$PACKAGE$'\t' $dep_db; then
gokhlayeh@415 1814 echo $PACKAGE >> $tmp/dep
gokhlayeh@415 1815 else
gokhlayeh@241 1816 check_for_missing && echo $PACKAGE >> $tmp/dep
gokhlayeh@241 1817 fi
gokhlayeh@241 1818 }
gokhlayeh@241 1819 else
gokhlayeh@241 1820 append_to_dep()
gokhlayeh@241 1821 {
gokhlayeh@241 1822 check_for_commit && echo $PACKAGE >> $tmp/dep
gokhlayeh@241 1823 }
gokhlayeh@241 1824 fi
gokhlayeh@204 1825 else
gokhlayeh@204 1826 append_to_dep()
gokhlayeh@204 1827 {
gokhlayeh@204 1828 echo $PACKAGE >> $tmp/dep
gokhlayeh@204 1829 }
gokhlayeh@240 1830 # If requested packages are not in dep_db, partial generation of this db is needed.
gokhlayeh@241 1831 for PACKAGE in $pkg_list; do
gokhlayeh@241 1832 grep -q ^$PACKAGE$'\t' $dep_db && continue
gokhlayeh@240 1833 [ -d "$WOK/$p" ] || continue
gokhlayeh@240 1834 plan_check_for_missing=yes
gokhlayeh@240 1835 check_for_missing
gokhlayeh@240 1836 done
gokhlayeh@240 1837 if [ "$plan_check_for_missing" ]; then
gokhlayeh@240 1838 append_to_dep()
gokhlayeh@240 1839 {
gokhlayeh@415 1840 if grep -q ^$PACKAGE$'\t' $dep_db; then
gokhlayeh@415 1841 echo $PACKAGE >> $tmp/dep
gokhlayeh@415 1842 else
gokhlayeh@240 1843 check_for_missing && echo $PACKAGE >> $tmp/dep
gokhlayeh@240 1844 fi
gokhlayeh@240 1845 }
gokhlayeh@240 1846 check_db_status=yes
gokhlayeh@240 1847 unset plan_check_for_missing
gokhlayeh@240 1848 fi
gokhlayeh@186 1849 fi
gokhlayeh@215 1850
gokhlayeh@204 1851 [ "$with_dev" ] && filter=with_dev
gokhlayeh@204 1852 [ "$with_wanted" ] && filter=with_wanted
gokhlayeh@204 1853 if [ "$filter" ]; then
gokhlayeh@291 1854 pkg_list=$(echo $pkg_list | $filter | sort -u)
gokhlayeh@204 1855 scan_pkg()
gokhlayeh@204 1856 {
gokhlayeh@204 1857 look_for_$look_for | $filter
gokhlayeh@204 1858 }
gokhlayeh@204 1859 else
gokhlayeh@204 1860 scan_pkg()
gokhlayeh@204 1861 {
gokhlayeh@204 1862 look_for_$look_for
gokhlayeh@204 1863 }
gokhlayeh@204 1864 fi
gokhlayeh@215 1865 touch $tmp/dep
gokhlayeh@204 1866 for PACKAGE in $pkg_list; do
gokhlayeh@204 1867 [ "$with_args" ] && append_to_dep
gokhlayeh@204 1868 scan_pkg
gokhlayeh@186 1869 done | tr ' ' '\n' | sort -u > $tmp/list
gokhlayeh@186 1870 [ "$look_for" = bdep ] && look_for=dep
gokhlayeh@186 1871 while [ -s $tmp/list ]; do
gokhlayeh@186 1872 PACKAGE=$(sed 1!d $tmp/list)
gokhlayeh@186 1873 sed 1d -i $tmp/list
gokhlayeh@204 1874 append_to_dep
gokhlayeh@204 1875 for pkg in $(scan_pkg); do
gokhlayeh@415 1876 grep -q ^$pkg$ $tmp/list $tmp/dep || echo $pkg >> $tmp/list
gokhlayeh@186 1877 done
gokhlayeh@186 1878 done
gokhlayeh@204 1879 if [ "$cooklist" ]; then
gokhlayeh@204 1880 mv $tmp/dep $tmp/cooklist
gokhlayeh@215 1881 else
gokhlayeh@204 1882 cat $tmp/dep | sort -u
gokhlayeh@186 1883 fi
gokhlayeh@204 1884 rm -f $tmp/dep $tmp/list
gokhlayeh@240 1885 if [ "$check_db_status" ]; then
gokhlayeh@240 1886 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@240 1887 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
gokhlayeh@352 1888 if [ "$plan_regen_cookorder" ] && \
gokhlayeh@397 1889 [ "$(sed 1!d $cookorder)" != "#PlanSort" ]; then
gokhlayeh@397 1890 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
gokhlayeh@240 1891 fi
gokhlayeh@240 1892 fi
gokhlayeh@186 1893 }
gokhlayeh@186 1894
gokhlayeh@186 1895 ########################################################################
paul@430 1896 # This section contains functions to check the package repository and
gokhlayeh@186 1897 # find which packages to cook.
gokhlayeh@186 1898 ########################
gokhlayeh@186 1899
gokhlayeh@240 1900 check_for_missing()
gokhlayeh@240 1901 {
slaxemulator@326 1902 local PACKAGE=$PACKAGE
gokhlayeh@240 1903 if ! check_for_pkg_in_wok; then
gokhlayeh@240 1904 [ "$?" = 2 ] && return 1
gokhlayeh@240 1905 return
gokhlayeh@240 1906 fi
gokhlayeh@241 1907 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@240 1908 source_receipt
gokhlayeh@240 1909 PACKAGE=${WANTED:-$PACKAGE}
gokhlayeh@240 1910 update_wan_db
gokhlayeh@240 1911 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@240 1912 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@240 1913 source_receipt
gokhlayeh@240 1914 update_dep_db
gokhlayeh@240 1915 done
gokhlayeh@240 1916 }
gokhlayeh@240 1917
gokhlayeh@186 1918 check_for_commit()
gokhlayeh@186 1919 {
gokhlayeh@204 1920 if ! check_for_pkg_in_wok; then
gokhlayeh@204 1921 [ "$?" = 2 ] && return 1
gokhlayeh@204 1922 return
gokhlayeh@204 1923 fi
gokhlayeh@204 1924 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@204 1925 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@186 1926 source_receipt
gokhlayeh@204 1927
gokhlayeh@186 1928 # We use md5 of cooking stuff in the packaged receipt to check
gokhlayeh@186 1929 # commit. We look consecutively in 3 different locations :
gokhlayeh@204 1930 # - in the wok/PACKAGE/taz/* folder
gokhlayeh@186 1931 # - in the receipt in the package in incoming repository
gokhlayeh@186 1932 # - in the receipt in the package in packages repository
paul@430 1933 # If md5sums match, there's no commit.
gokhlayeh@186 1934 check_for_commit_using_md5sum()
gokhlayeh@186 1935 {
gokhlayeh@186 1936 if [ ! -f $WOK/$PACKAGE/md5 ]; then
gokhlayeh@186 1937 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
gokhlayeh@186 1938 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
gokhlayeh@186 1939 cd $WOK/$PACKAGE
gokhlayeh@186 1940 fi
gokhlayeh@204 1941
gokhlayeh@186 1942 if [ -s md5 ]; then
gokhlayeh@186 1943 if md5sum -cs md5; then
gokhlayeh@204 1944
gokhlayeh@204 1945 # If md5sum check if ok, check for new/missing files in
gokhlayeh@204 1946 # cooking stuff.
gokhlayeh@204 1947 for file in $([ -f receipt ] && echo receipt; \
gokhlayeh@204 1948 [ -f description.txt ] && echo description.txt; \
gokhlayeh@204 1949 [ -d stuff ] && find stuff); do
gokhlayeh@204 1950 if ! fgrep -q " $file" md5; then
gokhlayeh@186 1951 set_commited
gokhlayeh@186 1952 fi
gokhlayeh@186 1953 done
gokhlayeh@186 1954 else
gokhlayeh@186 1955 set_commited
gokhlayeh@186 1956 fi
gokhlayeh@186 1957 else
gokhlayeh@204 1958 set_commited
gokhlayeh@186 1959 fi
gokhlayeh@186 1960 }
gokhlayeh@186 1961 set_commited()
gokhlayeh@186 1962 {
gokhlayeh@405 1963 grep -q ^$PACKAGE$ $commit || echo $PACKAGE >> $commit
gokhlayeh@186 1964 gen_cookmd5
gokhlayeh@204 1965 update_dep_db
gokhlayeh@186 1966 }
gokhlayeh@195 1967 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
gokhlayeh@186 1968 if [ -f $WOK/$PACKAGE/md5 ]; then
gokhlayeh@186 1969 cd $WOK/$PACKAGE
gokhlayeh@186 1970 check_for_commit_using_md5sum
gokhlayeh@186 1971 elif [ "$taz_dir" ]; then
gokhlayeh@186 1972 cd $taz_dir
gokhlayeh@186 1973 check_for_commit_using_md5sum
gokhlayeh@186 1974 else
gokhlayeh@195 1975 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
gokhlayeh@195 1976 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
gokhlayeh@186 1977 if [ "$pkg" ]; then
gokhlayeh@186 1978 get_pkg_files $pkg
gokhlayeh@186 1979 check_for_commit_using_md5sum
gokhlayeh@186 1980 rm -r $pkg_files_dir
gokhlayeh@204 1981 else
gokhlayeh@204 1982 set_commited
gokhlayeh@186 1983 fi
gokhlayeh@186 1984 fi
gokhlayeh@204 1985 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
gokhlayeh@186 1986 done
gokhlayeh@204 1987 return
gokhlayeh@186 1988 }
gokhlayeh@186 1989
gokhlayeh@186 1990 gen_cook_list()
gokhlayeh@186 1991 {
gokhlayeh@204 1992 report step "Scanning wok"
gokhlayeh@204 1993 if [ "$pkg" ]; then
gokhlayeh@204 1994 scan $pkg --cooklist
gokhlayeh@405 1995 elif [ "$LIST" ]; then
gokhlayeh@405 1996 scan `cat $LIST` --cooklist
gokhlayeh@204 1997 else
gokhlayeh@204 1998 scan `cat $cooklist` --cooklist
gokhlayeh@204 1999 fi
gokhlayeh@204 2000 report end-step
gokhlayeh@209 2001
gokhlayeh@209 2002 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
gokhlayeh@209 2003
gokhlayeh@209 2004 # Core toolchain should not be cooked unless cook-toolchain is used.
gokhlayeh@209 2005 if ! [ -f /etc/config.site.tmptoolchain ] ; then
gokhlayeh@209 2006 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
gokhlayeh@405 2007 grep -q ^$PACKAGE$ $blocked || echo $PACKAGE >> $blocked
gokhlayeh@209 2008 done
gokhlayeh@209 2009 fi
gokhlayeh@313 2010
gokhlayeh@405 2011 if [ -s $commit ] && [ "$COMMAND" != gen-cooklist ]; then
gokhlayeh@405 2012 for PACKAGE in $(cat $commit); do
gokhlayeh@186 2013 WANTED="$(look_for_wanted)"
gokhlayeh@186 2014 if [ "$WANTED" ]; then
gokhlayeh@405 2015 grep -q ^$WANTED$ $broken $cooklist $blocked $commit && continue
gokhlayeh@186 2016 fi
gokhlayeh@405 2017 grep -q ^$PACKAGE$ $blocked $cooklist && continue
gokhlayeh@405 2018 echo $PACKAGE >> $cooklist
gokhlayeh@186 2019 done
gokhlayeh@186 2020 fi
gokhlayeh@186 2021 sort_cooklist
gokhlayeh@186 2022 }
gokhlayeh@186 2023
gokhlayeh@186 2024 sort_cooklist()
gokhlayeh@186 2025 {
gokhlayeh@397 2026 if [ "$(sed 1!d $cookorder)" = "#PlanSort" ]; then
gokhlayeh@397 2027 sed 1d -i $cookorder
gokhlayeh@266 2028 plan_regen_cookorder=yes
gokhlayeh@266 2029 fi
gokhlayeh@266 2030 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@266 2031 [ "$plan_regen_cookorder" ] && sort_db
gokhlayeh@313 2032 report step "Generating cooklist"
gokhlayeh@204 2033 if [ -f "$tmp/checked" ]; then
gokhlayeh@204 2034 rm -f $tmp/cooklist
gokhlayeh@204 2035 cat $tmp/checked | while read PACKAGE; do
gokhlayeh@405 2036 grep -q ^$PACKAGE$ $cooklist && echo $PACKAGE >> $tmp/cooklist
gokhlayeh@204 2037 done
gokhlayeh@209 2038 elif ! [ "$COMMAND" = gen-cooklist ]; then
gokhlayeh@405 2039 cat $blocked | while read PACKAGE; do
gokhlayeh@209 2040 sed "/^$PACKAGE/d" -i $tmp/cooklist
gokhlayeh@209 2041 done
gokhlayeh@204 2042 fi
gokhlayeh@313 2043 report end-step
gokhlayeh@313 2044 [ -s $tmp/cooklist ] || return
gokhlayeh@215 2045
gokhlayeh@313 2046 report step "Sorting cooklist"
gokhlayeh@204 2047 for PACKAGE in $(cat $tmp/cooklist); do
gokhlayeh@204 2048 WANTED="$(look_for_wanted)"
gokhlayeh@204 2049 [ "$WANTED" ] || continue
gokhlayeh@405 2050 if grep -q ^$WANTED$ $broken $tmp/cooklist; then
gokhlayeh@186 2051 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 2052 elif [ ! -d $WOK/$WANTED/install ]; then
gokhlayeh@204 2053 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 2054 echo $WANTED >> $tmp/cooklist
gokhlayeh@186 2055 fi
gokhlayeh@186 2056 done
gokhlayeh@186 2057
gokhlayeh@204 2058 # Use cookorder.txt to sort cooklist.
gokhlayeh@204 2059 if [ -s $tmp/cooklist ]; then
gokhlayeh@397 2060 cat $cookorder | while read PACKAGE; do
gokhlayeh@204 2061 if grep -q ^$PACKAGE$ $tmp/cooklist; then
gokhlayeh@204 2062 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 2063 echo $PACKAGE >> $tmp/cooklist.tmp
gokhlayeh@204 2064 fi
gokhlayeh@204 2065 done
gokhlayeh@204 2066
paul@430 2067 # Remaining packages in cooklist are those without compile_rules.
gokhlayeh@204 2068 # They can be cooked first in any order.
gokhlayeh@204 2069 if [ -f $tmp/cooklist.tmp ]; then
gokhlayeh@204 2070 cat $tmp/cooklist.tmp >> $tmp/cooklist
gokhlayeh@204 2071 rm $tmp/cooklist.tmp
gokhlayeh@204 2072 fi
gokhlayeh@204 2073
gokhlayeh@204 2074 cat $tmp/cooklist
gokhlayeh@405 2075 [ "$LIST" ] || cat $tmp/cooklist > $cooklist
gokhlayeh@204 2076 fi
gokhlayeh@204 2077
gokhlayeh@186 2078 report end-step
gokhlayeh@186 2079 }
gokhlayeh@186 2080
gokhlayeh@284 2081 look_for_missing_pkg()
gokhlayeh@284 2082 {
gokhlayeh@284 2083 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
gokhlayeh@284 2084 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
gokhlayeh@284 2085 $PACKAGES_REPOSITORY/packages.txt || \
gokhlayeh@284 2086 continue
gokhlayeh@284 2087 echo $pkg
gokhlayeh@284 2088 done
gokhlayeh@284 2089 }
gokhlayeh@284 2090
gokhlayeh@186 2091 check_for_incoming()
gokhlayeh@186 2092 {
paul@430 2093 report step "Checking that all packages were cooked OK"
gokhlayeh@204 2094 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
gokhlayeh@204 2095 echo "No packages in $INCOMING_REPOSITORY."
gokhlayeh@307 2096 report end-step; return; }
gokhlayeh@405 2097 if [ -s $broken ]; then
gokhlayeh@290 2098 missingpkg=$(look_for_missing_pkg broken)
gokhlayeh@290 2099 if [ "$missingpkg" ]; then
paul@430 2100 echo "Don't move incoming packages to main repository because these ones are broken:" >&2
gokhlayeh@290 2101 echo "$missingpkg"
gokhlayeh@307 2102 report end-step
gokhlayeh@307 2103 return 1
gokhlayeh@290 2104 fi
gokhlayeh@186 2105 fi
gokhlayeh@405 2106 if [ -s $cooklist ]; then
gokhlayeh@290 2107 missingpkg=$(look_for_missing_pkg cooklist)
gokhlayeh@290 2108 if [ "$missingpkg" ]; then
paul@430 2109 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
gokhlayeh@290 2110 echo "$missingpkg"
gokhlayeh@307 2111 report end-step
gokhlayeh@307 2112 return 1
gokhlayeh@290 2113 fi
gokhlayeh@204 2114 fi
gokhlayeh@306 2115 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
gokhlayeh@214 2116 if ! [ "$forced" ]; then
gokhlayeh@214 2117 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@313 2118 pkg="$incoming_pkgs"
gokhlayeh@214 2119 gen_cook_list
gokhlayeh@405 2120 if [ -s $cooklist ]; then
gokhlayeh@290 2121 missingpkg=$(look_for_missing_pkg cooklist)
gokhlayeh@290 2122 if [ "$missingpkg" ]; then
paul@430 2123 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
gokhlayeh@290 2124 echo "$missingpkg"
gokhlayeh@307 2125 report end-step
gokhlayeh@307 2126 return 1
gokhlayeh@290 2127 fi
gokhlayeh@214 2128 fi
gokhlayeh@204 2129 fi
gokhlayeh@313 2130
gokhlayeh@204 2131 report step "Moving incoming packages to main repository"
gokhlayeh@449 2132 [ "save_wok" ] && mkdir -p $PACKAGES_REPOSITORY/wok
gokhlayeh@204 2133 unset EXTRAVERSION
gokhlayeh@306 2134 for PACKAGE in $incoming_pkgs; do
gokhlayeh@186 2135 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
gokhlayeh@204 2136 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
gokhlayeh@186 2137 remove_previous_package $PACKAGES_REPOSITORY
gokhlayeh@204 2138 echo "Moving $PACKAGE..."
gokhlayeh@204 2139 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
gokhlayeh@204 2140 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
gokhlayeh@415 2141 previous_tarball=$(grep -m1 ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
gokhlayeh@266 2142 sed -e "/^$PACKAGE:main/d" \
slaxemulator@275 2143 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
gokhlayeh@266 2144 -i $SOURCES_REPOSITORY/sources.list
gokhlayeh@266 2145 if [ "$previous_tarball" ]; then
gokhlayeh@266 2146 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
gokhlayeh@266 2147 rm -f $SOURCES_REPOSITORY/$previous_tarball
gokhlayeh@266 2148 fi
gokhlayeh@449 2149 [ "$save_wok" ] &&
gokhlayeh@449 2150 copy_cooking_stuff $INCOMING_REPOSITORY/wok $PACKAGE $PACKAGES_REPOSITORY/wok
gokhlayeh@204 2151 done
gokhlayeh@401 2152
gokhlayeh@449 2153 if [ "$save_wok" = tarball ]; then
gokhlayeh@415 2154 rm -f $PACKAGES_REPOSITORY/wok.tar.lzma
gokhlayeh@401 2155 cd $PACKAGES_REPOSITORY/wok
gokhlayeh@401 2156 report step "Generating safe-wok tarball"
gokhlayeh@401 2157 tar -c * | lzma e $PACKAGES_REPOSITORY/wok.tar.lzma
gokhlayeh@401 2158 report end-step
gokhlayeh@401 2159 fi
gokhlayeh@401 2160
gokhlayeh@204 2161 for file in packages.list packages.equiv packages.md5 packages.desc \
gokhlayeh@204 2162 packages.txt; do
gokhlayeh@204 2163 echo -n "" > $INCOMING_REPOSITORY/$file
gokhlayeh@204 2164 done
gokhlayeh@204 2165 rm -r $INCOMING_REPOSITORY/files.list.lzma
gokhlayeh@186 2166 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
gokhlayeh@313 2167
gokhlayeh@313 2168 report step "Updating flavors"
gokhlayeh@313 2169 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
gokhlayeh@313 2170 if ! [ -x /usr/bin/tazlito ]; then
gokhlayeh@313 2171 tazpkg get-install tazlito
gokhlayeh@313 2172 fi
gokhlayeh@313 2173
gokhlayeh@313 2174 # Handle cases where tazwok is used into main system;
gokhlayeh@313 2175 # Handle cases where SLITAZ_DIR is not /home/slitaz.
gokhlayeh@313 2176 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
gokhlayeh@313 2177 mkdir -p /home/slitaz
gokhlayeh@313 2178 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
gokhlayeh@313 2179
gokhlayeh@313 2180 cd $LOCAL_REPOSITORY/packages
gokhlayeh@313 2181 for i in $LOCAL_REPOSITORY/flavors/*; do
gokhlayeh@331 2182 [ -d "$i" ] || continue
gokhlayeh@313 2183 tazlito pack-flavor ${i##*/}
gokhlayeh@313 2184 done
gokhlayeh@313 2185
gokhlayeh@313 2186 noheader=""
gokhlayeh@313 2187 for i in *.flavor; do
gokhlayeh@313 2188 tazlito show-flavor $i --brief $noheader
gokhlayeh@313 2189 noheader="--noheader"
gokhlayeh@313 2190 done > flavors.list
gokhlayeh@313 2191 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@313 2192 else
paul@430 2193 echo "Can't create up-to-date flavors because the tazlito package is missing." >&2
gokhlayeh@313 2194 fi
gokhlayeh@313 2195 report end-step
gokhlayeh@186 2196 }
gokhlayeh@186 2197
gokhlayeh@449 2198 # Usage: move_cooking_stuff source receipt destination
gokhlayeh@449 2199 # Make the argument check before calling it!
gokhlayeh@449 2200 copy_cooking_stuff()
gokhlayeh@449 2201 {
gokhlayeh@449 2202 rm -rf $3/$2
gokhlayeh@449 2203 mkdir -p $3/$2
gokhlayeh@449 2204 cp -a $1/$2/receipt $3/$2
gokhlayeh@449 2205 [ -f $1/$2/description.txt ] && \
gokhlayeh@449 2206 cp -a $1/$2/description.txt $3/$2
gokhlayeh@449 2207 if [ -d "$1/$2/stuff" ]; then
gokhlayeh@449 2208 cp -a $1/$2/stuff $3/$2
gokhlayeh@449 2209 fi
gokhlayeh@449 2210 }
gokhlayeh@449 2211
gokhlayeh@186 2212 ########################################################################
gokhlayeh@186 2213 # TAZWOK MAIN FUNCTIONS
gokhlayeh@186 2214 ########################
gokhlayeh@186 2215
gokhlayeh@186 2216 clean()
gokhlayeh@186 2217 {
gokhlayeh@186 2218 cd $WOK/$PACKAGE
gokhlayeh@186 2219 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
gokhlayeh@186 2220 -e ^stuff$ || return
gokhlayeh@186 2221
gokhlayeh@249 2222 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
gokhlayeh@186 2223 # Check for clean_wok function.
gokhlayeh@186 2224 if grep -q ^clean_wok $RECEIPT; then
gokhlayeh@186 2225 clean_wok
gokhlayeh@186 2226 fi
gokhlayeh@415 2227 # Clean should only have a receipt, stuff and optionals desc/md5.
gokhlayeh@186 2228 for f in `ls .`
gokhlayeh@186 2229 do
gokhlayeh@186 2230 case $f in
gokhlayeh@250 2231 receipt|stuff|description.txt|md5)
gokhlayeh@186 2232 continue ;;
gokhlayeh@186 2233 *)
gokhlayeh@263 2234 rm -rf $f ;;
gokhlayeh@186 2235 esac
gokhlayeh@186 2236 done
gokhlayeh@262 2237 [ "$COMMAND" != clean-wok ] && report end-step
gokhlayeh@186 2238 }
gokhlayeh@186 2239
gokhlayeh@186 2240 # Configure and make a package with the receipt.
gokhlayeh@186 2241 compile_package()
gokhlayeh@186 2242 {
gokhlayeh@186 2243 check_for_package_on_cmdline
gokhlayeh@186 2244
gokhlayeh@186 2245 # Include the receipt to get all needed variables and functions
gokhlayeh@186 2246 # and cd into the work directory to start the work.
gokhlayeh@186 2247 check_for_receipt
gokhlayeh@186 2248 source_receipt
gokhlayeh@186 2249
gokhlayeh@186 2250 # Log the package name and date.
gokhlayeh@186 2251 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
gokhlayeh@186 2252 echo "package $PACKAGE (compile)" >> $LOG
gokhlayeh@186 2253
gokhlayeh@186 2254 # Set wanted $src variable to help compiling.
gokhlayeh@186 2255 [ ! "$src" ] && set_src_path
gokhlayeh@186 2256 check_for_build_depends || return 1
gokhlayeh@186 2257 check_for_wanted
gokhlayeh@186 2258 unset target
gokhlayeh@186 2259 check_for_tarball && check_for_compile_rules
gokhlayeh@186 2260 }
gokhlayeh@186 2261
gokhlayeh@186 2262 # Cook command also include all features to manage lists which keep
gokhlayeh@186 2263 # track of wok/packages state.
gokhlayeh@186 2264 cook()
gokhlayeh@186 2265 {
gokhlayeh@186 2266 cook_code=
gokhlayeh@186 2267 set_common_path
gokhlayeh@186 2268 check_for_receipt
gokhlayeh@186 2269 source_receipt
gokhlayeh@186 2270
gokhlayeh@186 2271 # Define log path and start report.
gokhlayeh@415 2272 for i in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@415 2273 rm -f $LOCAL_REPOSITORY/log/$i.html
gokhlayeh@415 2274 done
gokhlayeh@186 2275 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
pascal@349 2276 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
gokhlayeh@186 2277 report step "Cooking $PACKAGE"
gokhlayeh@186 2278 report open-bloc
gokhlayeh@186 2279
gokhlayeh@186 2280 clean $PACKAGE
gokhlayeh@186 2281 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@381 2282
gokhlayeh@186 2283 if compile_package; then
gokhlayeh@215 2284 remove_src
gokhlayeh@186 2285 refresh_packages_from_compile
gokhlayeh@186 2286 gen_package
gokhlayeh@186 2287
gokhlayeh@186 2288 # Update packages-incoming repository.
gokhlayeh@186 2289 store_pkgname=$PACKAGE
gokhlayeh@186 2290 pkg_repository=$INCOMING_REPOSITORY
gokhlayeh@186 2291 update_packages_db
gokhlayeh@186 2292
gokhlayeh@186 2293 PACKAGE=$store_pkgname
gokhlayeh@186 2294 unset store_pkgname
gokhlayeh@186 2295
gokhlayeh@186 2296 # Upgrade to cooked packages if it was previously installed.
paul@430 2297 report step "Looking for package(s) to upgrade"
gokhlayeh@186 2298 for pkg in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@415 2299 if [ -f $INSTALLED/$pkg/receipt ]; then
gokhlayeh@186 2300 tazpkg get-install $pkg --forced
gokhlayeh@186 2301 fi
gokhlayeh@186 2302 done
gokhlayeh@186 2303 report end-step
gokhlayeh@186 2304 else
gokhlayeh@381 2305 set_pkg_broken
gokhlayeh@186 2306 cook_code=1
gokhlayeh@186 2307 fi
gokhlayeh@186 2308
gokhlayeh@186 2309 # Remove build_depends in cook mode (if in cooklist, it's done when
gokhlayeh@186 2310 # checking build_depends of next package and we remove only unneeded
gokhlayeh@186 2311 # packages to keep chroot minimal and gain some time).
gokhlayeh@210 2312 if [ "$COMMAND" = cook ]; then
gokhlayeh@210 2313 remove_build_depends $MISSING_PACKAGE
gokhlayeh@210 2314 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@210 2315 fi
gokhlayeh@210 2316
gokhlayeh@186 2317 # Regen the cooklist if it was planned and command is not cook.
gokhlayeh@405 2318 [ "$regen_cooklist" ] && unset regen_cooklist &&
gokhlayeh@405 2319 [ "$COMMAND" != cook ] && sort_cooklist
gokhlayeh@186 2320
paul@430 2321 # Some hacks to set the bloc & function status as failed if cook has
gokhlayeh@186 2322 # failed.
gokhlayeh@186 2323 report_return_code=$cook_code
gokhlayeh@186 2324 report close-bloc
gokhlayeh@186 2325 report end-sublog
pascal@351 2326 rm -f $LOCAL_REPOSITORY/log/package
gokhlayeh@186 2327 return $cook_code
gokhlayeh@186 2328 }
gokhlayeh@186 2329
gokhlayeh@186 2330 cook_list()
gokhlayeh@186 2331 {
gokhlayeh@204 2332 if [ -s $tmp/cooklist ]; then
gokhlayeh@204 2333 if [ -f /usr/bin/tazchroot ]; then
paul@430 2334 # Note : options -main variables- are automatically kept by
gokhlayeh@204 2335 # the sub-applications tazchroot/tazwok; as well as report data.
gokhlayeh@204 2336 cd $LOCAL_REPOSITORY
gokhlayeh@204 2337 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@204 2338 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
gokhlayeh@204 2339 return
gokhlayeh@204 2340 fi
gokhlayeh@204 2341 while [ -s $tmp/cooklist ]; do
gokhlayeh@204 2342 PACKAGE=$(sed 1!d $tmp/cooklist)
gokhlayeh@204 2343 cook
gokhlayeh@204 2344 done
gokhlayeh@204 2345 remove_build_depends $MISSING_PACKAGE $remove_later
gokhlayeh@210 2346 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@204 2347 else
gokhlayeh@186 2348 echo "Nothing to cook."
gokhlayeh@186 2349 return
gokhlayeh@186 2350 fi
gokhlayeh@186 2351 }
gokhlayeh@186 2352
gokhlayeh@186 2353 configure_tazchroot()
gokhlayeh@186 2354 {
gokhlayeh@190 2355 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
gokhlayeh@186 2356 # Tazchroot configuration file - created by tazwok.
gokhlayeh@186 2357
gokhlayeh@407 2358 # Local repository definition.
gokhlayeh@186 2359 SLITAZ_DIR=$SLITAZ_DIR
gokhlayeh@186 2360 SLITAZ_VERSION=$SLITAZ_VERSION
gokhlayeh@407 2361 LOCAL_REPOSITORY=$SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}
gokhlayeh@407 2362 ${USE_ONLINE_PKG:+USE_ONLINE_PKG=$USE_ONLINE_PKG}
gokhlayeh@407 2363 ${undigest:+undigest=$undigest}
gokhlayeh@407 2364 ${ref_USE_ONLINE_PKG:+ref_USE_ONLINE_PKG=$ref_USE_ONLINE_PKG}
gokhlayeh@407 2365
gokhlayeh@407 2366 # Chroot path.
gokhlayeh@407 2367 # You can use a chroot into /tmp if it's mounted in RAM
gokhlayeh@407 2368 # to speed-up the process, be sure you have a free GB.
gokhlayeh@407 2369 # (minimal chroot is like 150~200MB, can be a lot more during cook)
gokhlayeh@407 2370 # chroot_dir=/tmp/chroot-${undigest:-$SLITAZ_VERSION}
gokhlayeh@186 2371 chroot_dir=\$LOCAL_REPOSITORY/chroot
gokhlayeh@186 2372
paul@430 2373 # Default scripts path (these scripts are added to the
paul@430 2374 # $chroot_dir/usr/bin and can be called with tazchroot script).
gokhlayeh@314 2375 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
gokhlayeh@186 2376
gokhlayeh@186 2377 # List of directories to mount.
gokhlayeh@407 2378 list_dir="$LOCAL_REPOSITORY
gokhlayeh@186 2379 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
gokhlayeh@186 2380
gokhlayeh@186 2381 create_chroot()
gokhlayeh@186 2382 {
gokhlayeh@186 2383 mkdir -p \$chroot_dir
gokhlayeh@186 2384 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
gokhlayeh@186 2385 tazpkg get-install \$pkg --root="\$chroot_dir"
gokhlayeh@186 2386 done
gokhlayeh@186 2387
gokhlayeh@186 2388 # Store list of installed packages needed by cleanchroot.
gokhlayeh@194 2389 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
gokhlayeh@186 2390
gokhlayeh@186 2391 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
gokhlayeh@186 2392 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
gokhlayeh@186 2393 -i \$chroot_dir/etc/slitaz/slitaz.conf
gokhlayeh@443 2394 echo \$SLITAZ_VERSION > \$chroot_dir/etc/slitaz-release
gokhlayeh@186 2395 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
gokhlayeh@186 2396 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
gokhlayeh@407 2397
paul@430 2398 # The build bot may run in a sandbox: link sandbox lockfile.
pascal@368 2399 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
gokhlayeh@186 2400 }
gokhlayeh@186 2401
gokhlayeh@186 2402 mount_chroot()
gokhlayeh@186 2403 {
gokhlayeh@186 2404 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
gokhlayeh@407 2405 $( if [ "$USE_ONLINE_PKG" ]; then
gokhlayeh@407 2406 echo ' echo "$USE_ONLINE_PKG" > $chroot_dir$LOCALSTATE/mirror'
gokhlayeh@407 2407 else
gokhlayeh@452 2408 echo ' echo "$LOCAL_REPOSITORY/packages" > $chroot_dir$LOCALSTATE/mirror'
gokhlayeh@407 2409 fi
gokhlayeh@407 2410 )
gokhlayeh@194 2411 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
gokhlayeh@194 2412 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
gokhlayeh@448 2413 $( if [ "$undigest" ]; then
gokhlayeh@448 2414 echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION'
gokhlayeh@448 2415 if [ "$ref_USE_ONLINE_PKG" ]; then
gokhlayeh@448 2416 echo ' echo "$ref_USE_ONLINE_PKG" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror'
gokhlayeh@448 2417 else
gokhlayeh@448 2418 echo ' echo "$ref_LOCAL_REPOSITORY/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror'
gokhlayeh@448 2419 fi
gokhlayeh@448 2420 fi )
gokhlayeh@194 2421 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
gokhlayeh@440 2422 mount -o bind /proc \$chroot_dir/proc
gokhlayeh@440 2423 mount -o bind /sys \$chroot_dir/sys
gokhlayeh@433 2424 mount -o bind /dev/pts \$chroot_dir/dev/pts
gokhlayeh@433 2425 mount -o bind /dev/shm \$chroot_dir/dev/shm
gokhlayeh@186 2426 for dir in \$list_dir; do
gokhlayeh@186 2427 mkdir -p \$dir \$chroot_dir\$dir
gokhlayeh@186 2428 mount \$dir \$chroot_dir\$dir
gokhlayeh@186 2429 done
gokhlayeh@186 2430 }
gokhlayeh@186 2431
gokhlayeh@186 2432 umount_chroot()
gokhlayeh@186 2433 {
gokhlayeh@186 2434 for dir in \$list_dir; do
gokhlayeh@186 2435 umount \$chroot_dir\$dir
gokhlayeh@186 2436 done
gokhlayeh@186 2437 umount \$chroot_dir/dev/shm
gokhlayeh@186 2438 umount \$chroot_dir/dev/pts
gokhlayeh@186 2439 umount \$chroot_dir/sys
gokhlayeh@186 2440 umount \$chroot_dir/proc
gokhlayeh@186 2441 }
gokhlayeh@186 2442 EOF
gokhlayeh@186 2443 }
gokhlayeh@186 2444
gokhlayeh@186 2445 ########################################################################
gokhlayeh@186 2446 ######################### END OF NEW FUNCTIONS #########################
gokhlayeh@186 2447 ########################################################################
gokhlayeh@186 2448
paul@430 2449 # List packages providing a virtual package.
pascal@111 2450 whoprovide()
pascal@111 2451 {
pascal@111 2452 local i;
gokhlayeh@195 2453 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
pascal@111 2454 . $i
pascal@111 2455 case " $PROVIDE " in
pascal@111 2456 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
pascal@111 2457 esac
pascal@111 2458 done
pascal@111 2459 }
pascal@111 2460
gokhlayeh@186 2461 ########################################################################
gokhlayeh@186 2462 # TAZWOK COMMANDS
gokhlayeh@186 2463 ########################
pankso@7 2464
pankso@7 2465 case "$COMMAND" in
pankso@7 2466 stats)
paul@166 2467 # Tazwok general statistics from the wok config file.
pankso@7 2468 #
gokhlayeh@186 2469 get_tazwok_config
gokhlayeh@186 2470 echo -e "\n\033[1mTazwok configuration statistics\033[0m
pankso@7 2471 ================================================================================
pankso@7 2472 Wok directory : $WOK
pankso@7 2473 Packages repository : $PACKAGES_REPOSITORY
gokhlayeh@186 2474 Incoming repository : $INCOMING_REPOSITORY
pankso@7 2475 Sources repository : $SOURCES_REPOSITORY
gokhlayeh@186 2476 Log directory : $LOCAL_REPOSITORY/log
pankso@7 2477 Packages in the wok : `ls -1 $WOK | wc -l`
pankso@16 2478 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
gokhlayeh@186 2479 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
gokhlayeh@186 2480 ================================================================================\n"
gokhlayeh@186 2481 ;;
pankso@133 2482 edit)
gokhlayeh@186 2483 get_tazwok_config
pankso@133 2484 check_for_package_on_cmdline
pankso@133 2485 check_for_receipt
gokhlayeh@186 2486 $EDITOR $WOK/$PACKAGE/receipt
gokhlayeh@186 2487 ;;
pascal@98 2488 build-depends)
paul@430 2489 # List dependencies to rebuild wok, or only a package.
gokhlayeh@186 2490 get_tazwok_config
gokhlayeh@215 2491 report(){ : ; }
gokhlayeh@242 2492 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
gokhlayeh@186 2493 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 2494 --look_for=dep --with_dev --with_args
gokhlayeh@186 2495 else
gokhlayeh@186 2496 check_for_package_on_cmdline
gokhlayeh@186 2497 scan $PACKAGE --look_for=bdep --with_dev
gokhlayeh@186 2498 fi
gokhlayeh@186 2499 ;;
gokhlayeh@186 2500 gen-cooklist)
gokhlayeh@215 2501 check_root
gokhlayeh@204 2502 get_options_list="pkg"
gokhlayeh@186 2503 get_tazwok_config
gokhlayeh@215 2504 report(){ : ; }
gokhlayeh@204 2505 if ! [ "$pkg" ]; then
gokhlayeh@242 2506 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
gokhlayeh@242 2507 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
gokhlayeh@242 2508 else
gokhlayeh@405 2509 check_for_list
gokhlayeh@242 2510 fi
gokhlayeh@186 2511 fi
gokhlayeh@204 2512 gen_cook_list
gokhlayeh@186 2513 ;;
pascal@119 2514 check-depends)
paul@430 2515 # Check package depends /!\.
gokhlayeh@186 2516 get_tazwok_config
pascal@119 2517 echo ""
paul@121 2518 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
pascal@119 2519 ================================================================================"
pascal@119 2520 TMPDIR=/tmp/tazwok$$
pascal@119 2521 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
pascal@119 2522
paul@430 2523 # Build ALL_DEPENDS variable.
pascal@119 2524 scan_dep()
pascal@119 2525 {
pascal@119 2526 local i
pascal@119 2527 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
pascal@128 2528 for i in $DEPENDS $SUGGESTED ; do
pascal@119 2529 case " $ALL_DEPENDS " in
pascal@119 2530 *\ $i\ *) continue;;
pascal@119 2531 esac
pascal@120 2532 [ -d $WOK/$i ] || {
pascal@120 2533 ALL_DEPENDS="$ALL_DEPENDS$i "
pascal@120 2534 continue
pascal@120 2535 }
pascal@128 2536 DEPENDS=""
pascal@128 2537 SUGGESTED=""
pascal@119 2538 . $WOK/$i/receipt
pascal@119 2539 scan_dep
pascal@119 2540 done
pascal@119 2541 }
pankso@133 2542
paul@430 2543 # Check for ELF file.
pascal@119 2544 is_elf()
pascal@119 2545 {
slaxemulator@323 2546 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
pascal@119 2547 }
pascal@119 2548
paul@430 2549 # Print shared library dependencies.
pascal@119 2550 ldd()
pascal@119 2551 {
pascal@130 2552 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
pascal@119 2553 }
pascal@119 2554
pascal@119 2555 mkdir $TMPDIR
pascal@119 2556 cd $TMPDIR
pascal@140 2557 for i in $LOCALSTATE/files.list.lzma \
pascal@140 2558 $LOCALSTATE/undigest/*/files.list.lzma ; do
pascal@119 2559 [ -f $i ] && lzma d $i -so >> files.list
pascal@119 2560 done
pascal@119 2561 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
pascal@119 2562 tazpkg extract $pkg > /dev/null 2>&1
pascal@119 2563 . */receipt
pascal@119 2564 ALL_DEPENDS="$DEFAULT_DEPENDS "
pascal@119 2565 scan_dep
pascal@119 2566 find */fs -type f | while read file ; do
pascal@119 2567 is_elf $file || continue
pascal@119 2568 case "$file" in
pascal@119 2569 *.o|*.ko|*.ko.gz) continue;;
pascal@119 2570 esac
pascal@119 2571 ldd $file | while read lib rem; do
pascal@119 2572 case "$lib" in
pascal@128 2573 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
pascal@119 2574 continue;;
pascal@119 2575 esac
gokhlayeh@195 2576 for dep in $(fgrep $lib files.list | cut -d: -f1); do
pascal@119 2577 case " $ALL_DEPENDS " in
pascal@119 2578 *\ $dep\ *) continue 2;;
pascal@119 2579 esac
gokhlayeh@195 2580 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
pascal@128 2581 case " $ALL_DEPENDS " in
pascal@129 2582 *\ $vdep\ *) continue 3;;
pascal@128 2583 esac
pascal@128 2584 done
pascal@119 2585 done
pascal@128 2586 [ -n "$dep" ] || dep="UNKNOWN"
pascal@119 2587 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
pascal@119 2588 done
pascal@119 2589 done
pascal@119 2590 rm -rf */
pascal@119 2591 done
pascal@119 2592 cd /tmp
pascal@119 2593 rm -rf $TMPDIR
gokhlayeh@186 2594 ;;
pascal@76 2595 check)
paul@430 2596 # Check wok consistency.
gokhlayeh@186 2597 get_tazwok_config
pascal@76 2598 echo ""
pascal@76 2599 echo -e "\033[1mWok and packages checking\033[0m
pascal@76 2600 ================================================================================"
pascal@77 2601 cd $WOK
pascal@77 2602 for pkg in $(ls)
pascal@76 2603 do
pascal@76 2604 [ -f $pkg/receipt ] || continue
gokhlayeh@186 2605 RECEIPT= $pkg/receipt
gokhlayeh@186 2606 source_receipt
gokhlayeh@186 2607 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
gokhlayeh@186 2608 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
gokhlayeh@186 2609 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
gokhlayeh@186 2610 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
gokhlayeh@186 2611 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
pascal@97 2612 if [ -n "$WANTED" ]; then
pascal@97 2613 if [ ! -f $WANTED/receipt ]; then
gokhlayeh@186 2614 echo "Package $PACKAGE wants unknown $WANTED package" >&2
pascal@97 2615 else
pascal@97 2616 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
pascal@103 2617 if [ "$VERSION" = "$WANTED" ]; then
pascal@103 2618 # BASEVERSION is computed in receipt
gokhlayeh@195 2619 fgrep -q '_pkg=' $pkg/receipt &&
pascal@103 2620 BASEVERSION=$VERSION
pascal@103 2621 fi
pascal@97 2622 if [ "$VERSION" != "$BASEVERSION" ]; then
gokhlayeh@186 2623 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
pascal@97 2624 fi
pascal@97 2625 fi
pascal@97 2626 fi
pascal@97 2627
pascal@94 2628 if [ -n "$CATEGORY" ]; then
pascal@94 2629 case " $(echo $CATEGORIES) " in
pascal@94 2630 *\ $CATEGORY\ *);;
gokhlayeh@186 2631 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
pascal@94 2632 esac
pascal@94 2633 else
gokhlayeh@186 2634 echo"Package $PACKAGE has no CATEGORY" >&2
pascal@94 2635 fi
gokhlayeh@186 2636 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
gokhlayeh@186 2637 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
pascal@122 2638 case "$WGET_URL" in
pascal@178 2639 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
gokhlayeh@186 2640 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
pascal@122 2641 '') ;;
gokhlayeh@186 2642 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
pascal@122 2643 esac
pascal@112 2644 case "$WEB_SITE" in
pascal@125 2645 ftp*|http*);;
gokhlayeh@186 2646 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
gokhlayeh@186 2647 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
pascal@112 2648 esac
pascal@78 2649 case "$MAINTAINER" in
gokhlayeh@186 2650 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
pascal@78 2651 esac
pascal@78 2652 case "$MAINTAINER" in
pascal@78 2653 *@*);;
gokhlayeh@186 2654 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
pascal@78 2655 esac
gokhlayeh@186 2656 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
pascal@76 2657 for i in $DEPENDS; do
pascal@76 2658 [ -d $i ] && continue
pascal@111 2659 [ -n "$(whoprovide $i)" ] && continue
pascal@76 2660 echo -e "$MSG $i"
pascal@76 2661 MSG=""
pascal@76 2662 done
gokhlayeh@186 2663 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
pascal@92 2664 for i in $BUILD_DEPENDS; do
pascal@92 2665 [ -d $i ] && continue
pascal@111 2666 [ -n "$(whoprovide $i)" ] && continue
pascal@92 2667 echo -e "$MSG $i"
pascal@92 2668 MSG=""
pascal@92 2669 done
paul@430 2670 MSG="Dependency loop between $PACKAGE and :\n"
pascal@76 2671 ALL_DEPS=""
pascal@76 2672 check_for_deps_loop $PACKAGE $DEPENDS
pascal@140 2673 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
pascal@141 2674 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
paul@154 2675 echo "$pkg should be rebuilt after $i installation"
pascal@140 2676 done
pascal@76 2677 done
gokhlayeh@186 2678 ;;
pankso@7 2679 list)
paul@166 2680 # List packages in wok directory. User can specify a category.
pankso@7 2681 #
gokhlayeh@186 2682 get_tazwok_config
pankso@7 2683 if [ "$2" = "category" ]; then
pankso@7 2684 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
pankso@7 2685 exit 0
pankso@7 2686 fi
pankso@7 2687 # Check for an asked category.
pankso@7 2688 if [ -n "$2" ]; then
pankso@7 2689 ASKED_CATEGORY=$2
pankso@7 2690 echo ""
pankso@7 2691 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
pankso@7 2692 echo "================================================================================"
pankso@7 2693 for pkg in $WOK/*
pankso@7 2694 do
erjo@168 2695 [ ! -f $pkg/receipt ] && continue
pankso@7 2696 . $pkg/receipt
pankso@7 2697 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@7 2698 echo -n "$PACKAGE"
pankso@28 2699 echo -e "\033[28G $VERSION"
pankso@7 2700 packages=$(($packages+1))
pankso@7 2701 fi
pankso@7 2702 done
pankso@7 2703 echo "================================================================================"
pankso@7 2704 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
pankso@7 2705 else
pankso@7 2706 # By default list all packages and version.
pankso@7 2707 echo ""
pankso@7 2708 echo -e "\033[1mList of packages in the wok\033[0m"
pankso@7 2709 echo "================================================================================"
pankso@7 2710 for pkg in $WOK/*
pankso@7 2711 do
erjo@168 2712 [ ! -f $pkg/receipt ] && continue
pankso@7 2713 . $pkg/receipt
pankso@7 2714 echo -n "$PACKAGE"
pankso@28 2715 echo -en "\033[28G $VERSION"
pankso@7 2716 echo -e "\033[42G $CATEGORY"
pankso@7 2717 packages=$(($packages+1))
pankso@7 2718 done
pankso@7 2719 echo "================================================================================"
MikeDSmith25@82 2720 echo -e "$packages packages available in the wok.\n"
pankso@7 2721 fi
pankso@7 2722 ;;
pankso@7 2723 info)
MikeDSmith25@82 2724 # Information about a package.
pankso@7 2725 #
gokhlayeh@186 2726 get_tazwok_config
pankso@7 2727 check_for_package_on_cmdline
pankso@7 2728 check_for_receipt
pankso@7 2729 . $WOK/$PACKAGE/receipt
pankso@7 2730 echo ""
MikeDSmith25@82 2731 echo -e "\033[1mTazwok package information\033[0m
pankso@7 2732 ================================================================================
pankso@7 2733 Package : $PACKAGE
pankso@7 2734 Version : $VERSION
pankso@7 2735 Category : $CATEGORY
pankso@7 2736 Short desc : $SHORT_DESC
pankso@7 2737 Maintainer : $MAINTAINER"
pankso@7 2738 if [ ! "$WEB_SITE" = "" ]; then
pankso@7 2739 echo "Web site : $WEB_SITE"
pankso@7 2740 fi
pankso@7 2741 if [ ! "$DEPENDS" = "" ]; then
pankso@7 2742 echo "Depends : $DEPENDS"
pankso@7 2743 fi
pankso@7 2744 if [ ! "$WANTED" = "" ]; then
pankso@7 2745 echo "Wanted src : $WANTED"
pankso@7 2746 fi
pankso@7 2747 echo "================================================================================"
pankso@7 2748 echo ""
gokhlayeh@186 2749 ;;
pankso@7 2750 check-log)
pankso@7 2751 # We just cat the file log to view process info.
pankso@7 2752 #
gokhlayeh@186 2753 get_tazwok_config
pankso@7 2754 if [ ! -f "$LOG" ]; then
gokhlayeh@186 2755 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
gokhlayeh@186 2756 exit 1
pankso@7 2757 else
pankso@7 2758 echo ""
pankso@7 2759 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
pankso@7 2760 echo "================================================================================"
pankso@7 2761 cat $LOG
pankso@7 2762 echo "================================================================================"
pankso@7 2763 echo ""
gokhlayeh@237 2764 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
gokhlayeh@237 2765 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
gokhlayeh@237 2766 echo "================================================================================"
gokhlayeh@237 2767 cat "$WOK/$PACKAGE/warning.txt"
gokhlayeh@237 2768 echo "================================================================================"
gokhlayeh@237 2769 echo ""
gokhlayeh@237 2770 fi
pankso@7 2771 fi
gokhlayeh@186 2772 ;;
pankso@7 2773 search)
pankso@7 2774 # Search for a package by pattern or name.
pankso@7 2775 #
gokhlayeh@186 2776 get_tazwok_config
pankso@7 2777 if [ -z "$2" ]; then
gokhlayeh@186 2778 echo -e "\nPlease specify a pattern or a package name to search." >&2
gokhlayeh@186 2779 echo -e "Example : 'tazwok search gcc'.\n" >&2
gokhlayeh@186 2780 exit 1
pankso@7 2781 fi
pankso@7 2782 echo ""
pankso@7 2783 echo -e "\033[1mSearch result for :\033[0m $2"
pankso@7 2784 echo "================================================================================"
gokhlayeh@195 2785 list=`ls -1 $WOK | fgrep $2`
pankso@7 2786 for pkg in $list
pankso@7 2787 do
pankso@7 2788 . $WOK/$pkg/receipt
pankso@7 2789 echo -n "$PACKAGE "
pankso@7 2790 echo -en "\033[24G $VERSION"
pankso@7 2791 echo -e "\033[42G $CATEGORY"
gokhlayeh@186 2792 packages=$(($PACKAGEs+1))
pankso@7 2793 done
pankso@7 2794 echo "================================================================================"
pankso@7 2795 echo "$packages packages found for : $2"
pankso@7 2796 echo ""
gokhlayeh@186 2797 ;;
pankso@7 2798 compile)
pankso@7 2799 # Configure and make a package with the receipt.
pankso@7 2800 #
gokhlayeh@186 2801 get_tazwok_config
gokhlayeh@186 2802 source_lib report
gokhlayeh@186 2803 report start
pankso@7 2804 compile_package
gokhlayeh@186 2805 ;;
pankso@7 2806 genpkg)
paul@121 2807 # Generate a package.
pankso@7 2808 #
gokhlayeh@186 2809 get_tazwok_config
gokhlayeh@186 2810 source_lib report
gokhlayeh@186 2811 report start
pankso@7 2812 gen_package
gokhlayeh@186 2813 ;;
pankso@7 2814 cook)
pankso@7 2815 # Compile and generate a package. Just execute tazwok with
pankso@7 2816 # the good commands.
pankso@7 2817 #
pankso@7 2818 check_root
gokhlayeh@186 2819 get_tazwok_config
gokhlayeh@186 2820 source_lib report
gokhlayeh@186 2821 report start
gokhlayeh@215 2822 update_wan_db
gokhlayeh@215 2823 check_for_commit
gokhlayeh@215 2824 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@215 2825 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
gokhlayeh@215 2826 if [ "$plan_regen_cookorder" ]; then
gokhlayeh@397 2827 [ "$(sed 1!d $cookorder)" = "#PlanSort" ] || \
gokhlayeh@397 2828 sed 1i"#PlanSort" -i $cookorder
gokhlayeh@215 2829 fi
gokhlayeh@186 2830 cook
gokhlayeh@186 2831 ;;
gokhlayeh@186 2832 sort-cooklist)
gokhlayeh@297 2833 check_root
gokhlayeh@186 2834 get_tazwok_config
gokhlayeh@405 2835 check_for_list
gokhlayeh@297 2836 report(){ : ; }
gokhlayeh@297 2837 # When using sort-cooklist, the script should behave as for gen-cooklist
paul@430 2838 # The only difference between these two is where the output is sent.
gokhlayeh@297 2839 COMMAND=gen-cooklist
gokhlayeh@297 2840 gen_cook_list
gokhlayeh@405 2841 cp -af $tmp/cooklist $LIST
gokhlayeh@186 2842 ;;
pankso@7 2843 cook-list)
gokhlayeh@204 2844 # Cook all packages listed in a file or in default cooklist.
gokhlayeh@186 2845 check_root
gokhlayeh@204 2846 get_options_list="pkg forced"
gokhlayeh@186 2847 get_tazwok_config
gokhlayeh@186 2848 source_lib report
gokhlayeh@186 2849 report start
gokhlayeh@204 2850 if ! [ "$pkg" ]; then
gokhlayeh@405 2851 [ "$LIST" ] && check_for_list
gokhlayeh@186 2852 fi
gokhlayeh@204 2853 gen_cook_list
gokhlayeh@186 2854 cook_list
gokhlayeh@186 2855 ;;
gokhlayeh@186 2856 clean)
paul@430 2857 # Clean up a package work directory + those which want it.
pankso@7 2858 #
gokhlayeh@186 2859 get_tazwok_config
pankso@7 2860 check_for_package_on_cmdline
pankso@7 2861 check_for_receipt
gokhlayeh@186 2862 source_lib report
gokhlayeh@186 2863 report start
pankso@7 2864 . $RECEIPT
gokhlayeh@186 2865 clean
gokhlayeh@186 2866 ;;
pankso@7 2867 gen-clean-wok)
paul@121 2868 # Generate a clean wok from the current wok by copying all receipts
pankso@7 2869 # and stuff directory.
pankso@7 2870 #
gokhlayeh@186 2871 get_tazwok_config
gokhlayeh@186 2872 source_lib report
gokhlayeh@186 2873 report start
gokhlayeh@186 2874 if [ -z "$ARG" ]; then
gokhlayeh@186 2875 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
gokhlayeh@186 2876 exit 1
pankso@7 2877 else
gokhlayeh@186 2878 dest=$ARG
pankso@7 2879 mkdir -p $dest
pankso@7 2880 fi
gokhlayeh@186 2881 report step "Creating clean wok in : $dest"
pankso@7 2882 for pkg in `ls -1 $WOK`
pankso@7 2883 do
gokhlayeh@449 2884 copy_cooking_stuff $WOK $pkg $dest
pankso@7 2885 done
gokhlayeh@186 2886 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
gokhlayeh@186 2887 report end-step
pankso@7 2888 echo "Packages cleaned : `ls -1 $dest | wc -l`"
pankso@7 2889 echo ""
gokhlayeh@186 2890 ;;
pankso@7 2891 clean-wok)
paul@430 2892 # Clean all packages in the work directory.
pankso@7 2893 #
gokhlayeh@186 2894 get_tazwok_config
gokhlayeh@186 2895 source_lib report
gokhlayeh@186 2896 report start
gokhlayeh@186 2897 report step "Cleaning wok"
gokhlayeh@186 2898 for PACKAGE in `ls -1 $WOK`
pankso@7 2899 do
gokhlayeh@186 2900 set_common_path
gokhlayeh@186 2901 source_receipt
gokhlayeh@186 2902 clean
pankso@7 2903 done
pankso@7 2904 echo "`ls -1 $WOK | wc -l` packages cleaned."
gokhlayeh@186 2905 ;;
gokhlayeh@266 2906 clean-src)
gokhlayeh@266 2907 # Remove tarball unrelated to wok receipts from src repo.
gokhlayeh@266 2908 check_root
gokhlayeh@266 2909 get_options_list="forced"
gokhlayeh@266 2910 get_tazwok_config
gokhlayeh@266 2911 cd $SOURCES_REPOSITORY
gokhlayeh@266 2912 echo -n "Checking $SOURCES_REPOSITORY..."
gokhlayeh@266 2913 for TARBALL in *; do
gokhlayeh@266 2914 [ "$TARBALL" = sources.list ] && continue
gokhlayeh@266 2915 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
gokhlayeh@266 2916 echo $TARBALL >> $tmp/obsolete
gokhlayeh@266 2917 done
gokhlayeh@266 2918 status
slaxemulator@273 2919 if ! [ -f $tmp/obsolete ]; then
slaxemulator@273 2920 echo "No sources need to be removed."
slaxemulator@273 2921 exit 1
slaxemulator@273 2922 fi
gokhlayeh@266 2923 echo ""
paul@430 2924 echo -e "\033[1mObsolete/unrelated-to-wok sources :\033[0m"
gokhlayeh@266 2925 horizontal_line
gokhlayeh@266 2926 cat $tmp/obsolete
gokhlayeh@266 2927 horizontal_line
gokhlayeh@266 2928 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
pankso@7 2929 echo ""
paul@430 2930 echo -n "Please confirm before removing (type uppercase YES): "
gokhlayeh@266 2931 read answer
gokhlayeh@266 2932 if [ "$answer" = YES ]; then
gokhlayeh@266 2933 echo -n "Removing old sources..."
gokhlayeh@266 2934 cat $tmp/obsolete | while read i; do
gokhlayeh@266 2935 rm -f $SOURCES_REPOSITORY/$i
gokhlayeh@266 2936 done
gokhlayeh@266 2937 status
gokhlayeh@266 2938 fi
gokhlayeh@266 2939 ;;
pankso@7 2940 gen-list)
gokhlayeh@186 2941 get_tazwok_config
gokhlayeh@204 2942 if [ "$2" ]; then
pankso@7 2943 if [ -d "$2" ]; then
gokhlayeh@204 2944 pkg_repository=$2
pankso@7 2945 else
gokhlayeh@204 2946 echo -e "\nUnable to find directory : $2\n" >&2
gokhlayeh@204 2947 exit 1
pankso@7 2948 fi
pankso@7 2949 fi
gokhlayeh@204 2950
gokhlayeh@186 2951 source_lib report
gokhlayeh@186 2952 report start
gokhlayeh@204 2953 if [ "$pkg_repository" ]; then
gokhlayeh@204 2954 gen_packages_db
gokhlayeh@204 2955 else
gokhlayeh@204 2956 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
gokhlayeh@204 2957 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
pankso@28 2958 fi
gokhlayeh@186 2959 ;;
gokhlayeh@186 2960 check-list)
gokhlayeh@186 2961 # The directory to move into by default is the repository,
gokhlayeh@186 2962 # if $2 is not empty cd into $2.
pascal@178 2963 #
gokhlayeh@186 2964 get_tazwok_config
gokhlayeh@204 2965 if [ "$2" ]; then
pascal@178 2966 if [ -d "$2" ]; then
gokhlayeh@204 2967 pkg_repository=$2
pascal@178 2968 else
gokhlayeh@186 2969 echo -e "\nUnable to find directory : $2\n" >&2
gokhlayeh@186 2970 exit 1
pascal@178 2971 fi
pascal@178 2972 fi
gokhlayeh@186 2973
gokhlayeh@186 2974 source_lib report
gokhlayeh@204 2975 report start
gokhlayeh@204 2976 if [ "$pkg_repository" ]; then
gokhlayeh@204 2977 update_packages_db
gokhlayeh@204 2978 else
gokhlayeh@204 2979 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
gokhlayeh@204 2980 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
gokhlayeh@204 2981 fi
gokhlayeh@186 2982 ;;
pankso@7 2983 new-tree)
MikeDSmith25@82 2984 # Just create a few directories and generate an empty receipt to prepare
pankso@7 2985 # the creation of a new package.
pankso@7 2986 #
gokhlayeh@186 2987 get_tazwok_config
pankso@7 2988 check_for_package_on_cmdline
slaxemulator@362 2989 clean_wok=$LOCAL_REPOSITORY/clean-wok
slaxemulator@362 2990 if [ -d $clean_wok/$PACKAGE ]; then
gokhlayeh@186 2991 echo -e "\n$PACKAGE package tree already exists.\n" >&2
gokhlayeh@186 2992 exit 1
pankso@7 2993 fi
gokhlayeh@442 2994 echo "Creating : $clean_wok/$PACKAGE"
slaxemulator@362 2995 mkdir $clean_wok/$PACKAGE
slaxemulator@362 2996 cd $clean_wok/$PACKAGE
pankso@7 2997 echo -n "Preparing the receipt..."
pankso@7 2998 #
pankso@7 2999 # Default receipt begin.
pankso@7 3000 #
pankso@7 3001 echo "# SliTaz package receipt." > receipt
pankso@7 3002 echo "" >> receipt
pankso@7 3003 echo "PACKAGE=\"$PACKAGE\"" >> receipt
pankso@7 3004 # Finish the empty receipt.
pankso@7 3005 cat >> receipt << "EOF"
pankso@7 3006 VERSION=""
pankso@7 3007 CATEGORY=""
pankso@7 3008 SHORT_DESC=""
pankso@7 3009 MAINTAINER=""
pankso@7 3010 DEPENDS=""
pankso@7 3011 TARBALL="$PACKAGE-$VERSION.tar.gz"
pankso@7 3012 WEB_SITE=""
pankso@7 3013 WGET_URL=""
pankso@7 3014
pankso@7 3015 # Rules to configure and make the package.
pankso@7 3016 compile_rules()
pankso@7 3017 {
pankso@7 3018 cd $src
gokhlayeh@204 3019 ./configure && make && make install
pankso@7 3020 }
pankso@7 3021
pankso@7 3022 # Rules to gen a SliTaz package suitable for Tazpkg.
pankso@7 3023 genpkg_rules()
pankso@7 3024 {
pankso@7 3025 mkdir -p $fs/usr
pankso@7 3026 cp -a $_pkg/usr/bin $fs/usr
pankso@7 3027 }
pankso@7 3028
pankso@7 3029 EOF
pankso@7 3030 #
pankso@7 3031 # Default receipt end.
pankso@7 3032 #
pankso@7 3033 status
pankso@7 3034 # Interactive mode, asking and seding.
pankso@7 3035 if [ "$3" = "--interactive" ]; then
paul@430 3036 echo "Entering interactive mode..."
pankso@7 3037 echo "================================================================================"
pankso@7 3038 echo "Package : $PACKAGE"
pankso@7 3039 # Version.
pankso@7 3040 echo -n "Version : " ; read anser
pankso@7 3041 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
pankso@7 3042 # Category.
pankso@7 3043 echo -n "Category : " ; read anser
pankso@7 3044 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
pankso@7 3045 # Short description.
pankso@7 3046 echo -n "Short desc : " ; read anser
pankso@7 3047 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
pankso@7 3048 # Maintainer.
pankso@7 3049 echo -n "Maintainer : " ; read anser
pankso@7 3050 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
pankso@7 3051 # Web site.
pankso@7 3052 echo -n "Web site : " ; read anser
pankso@133 3053 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
pankso@7 3054 echo ""
pankso@7 3055 # Wget URL.
pankso@7 3056 echo "Wget URL to download source tarball."
pankso@7 3057 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
pankso@7 3058 echo -n "Wget url : " ; read anser
pankso@7 3059 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
pankso@7 3060 # Ask for a stuff dir.
pankso@7 3061 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
pankso@7 3062 if [ "$anser" = "y" ]; then
pankso@7 3063 echo -n "Creating the stuff directory..."
pankso@7 3064 mkdir stuff && status
pankso@7 3065 fi
pankso@7 3066 # Ask for a description file.
pankso@7 3067 echo -n "Are you going to write a description ? (y/N) : " ; read anser
pankso@7 3068 if [ "$anser" = "y" ]; then
pankso@7 3069 echo -n "Creating the description.txt file..."
pankso@7 3070 echo "" > description.txt && status
pankso@7 3071 fi
pankso@7 3072 echo "================================================================================"
pankso@7 3073 echo ""
pankso@7 3074 fi
gokhlayeh@186 3075 ;;
pankso@7 3076 remove)
pankso@7 3077 # Remove a package from the wok.
pankso@7 3078 #
gokhlayeh@186 3079 get_tazwok_config
pankso@7 3080 check_for_package_on_cmdline
pankso@7 3081 echo ""
pascal@83 3082 echo -n "Please confirm deletion (y/N) : "; read anser
pascal@83 3083 if [ "$anser" = "y" ]; then
pascal@83 3084 echo -n "Removing $PACKAGE..."
pascal@83 3085 rm -rf $WOK/$PACKAGE && status
pascal@83 3086 echo ""
pascal@83 3087 fi
gokhlayeh@186 3088 ;;
gokhlayeh@304 3089 update-wok)
paul@166 3090 # Pull and update a Hg wok.
gokhlayeh@304 3091 get_options_list="local"
gokhlayeh@186 3092 get_tazwok_config
gokhlayeh@309 3093 source_lib report
gokhlayeh@310 3094 report start
gokhlayeh@304 3095 clean_wok=$LOCAL_REPOSITORY/clean-wok
gokhlayeh@304 3096 cd $clean_wok
gokhlayeh@304 3097 if ! [ "$local" ]; then
gokhlayeh@304 3098 if [ "$WOK_UPDATE_METHOD" = hg ]; then
gokhlayeh@304 3099 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
gokhlayeh@304 3100
gokhlayeh@304 3101 # Auto-install only if we are in a cook chroot.
gokhlayeh@304 3102 if [ -x /usr/bin/clean-chroot ]; then
gokhlayeh@392 3103 tazpkg get-install mercurial
gokhlayeh@392 3104 else
gokhlayeh@304 3105 echo "" >&2
paul@430 3106 echo "You need to install mercurial to get wok from hg (recommended). Otherwise, you can switch wok get method to \"tarball\" into $LOCAL_REPOSITORY/tazwok.conf (per-repository configuration, if it doesn't exist) or /etc/slitaz/tazwok.conf (global configuration)." | fold -s >&2
gokhlayeh@304 3107 echo "">&2
gokhlayeh@330 3108 exit 1
gokhlayeh@304 3109 fi
gokhlayeh@330 3110 fi
gokhlayeh@304 3111
gokhlayeh@330 3112 report step "Getting wok changes using hg"
gokhlayeh@330 3113 if [ -d .hg ]; then
gokhlayeh@330 3114 hg pull -u || exit 1
gokhlayeh@304 3115 else
gokhlayeh@330 3116 hg clone $HG_WOK . || exit 1
gokhlayeh@304 3117 fi
gokhlayeh@309 3118 report end-step
gokhlayeh@304 3119 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@304 3120 else
gokhlayeh@309 3121 report step "Getting wok changes using tarball"
gokhlayeh@304 3122 { mkdir .tmp && cd .tmp
gokhlayeh@304 3123 wget "$TARBALL_WOK" &&
gokhlayeh@304 3124 case $TARBALL_WOK in
gokhlayeh@304 3125 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
gokhlayeh@304 3126 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
gokhlayeh@304 3127 *gz) tar xzf *.gz -C wok; rm*.gz ;;
gokhlayeh@304 3128 esac &&
gokhlayeh@304 3129 rm -r $(ls -d $clean_wok/*) &&
gokhlayeh@304 3130 cp -a wok/* $clean_wok &&
gokhlayeh@304 3131 cd .. &&
gokhlayeh@304 3132 rm -r .tmp
gokhlayeh@304 3133 } || { echo "That's not cool: it fails!" >&2
gokhlayeh@309 3134 report end-step
gokhlayeh@304 3135 exit 1; }
gokhlayeh@309 3136 report end-step
gokhlayeh@304 3137 fi
pankso@106 3138 fi
gokhlayeh@309 3139 report step "Appending changes to wok"
gokhlayeh@304 3140
gokhlayeh@308 3141 # Handle removed files/dir.
gokhlayeh@308 3142 cd $WOK
gokhlayeh@313 3143 for dir in *; do
slaxemulator@329 3144 [ -d "$clean_wok/$dir" ] || rm -rf $dir
gokhlayeh@308 3145 done
gokhlayeh@308 3146 for file in */receipt */description.txt; do
slaxemulator@329 3147 [ -f "$clean_wok/$file" ] || rm -rf $file
gokhlayeh@308 3148 done
gokhlayeh@330 3149 for i in $(find */stuff 2>/dev/null); do
slaxemulator@329 3150 [ -e "$clean_wok/$i" ] || rm -rf $i
gokhlayeh@304 3151 done
gokhlayeh@304 3152
gokhlayeh@308 3153 cp -a $clean_wok/* $WOK
gokhlayeh@309 3154 report end-step
gokhlayeh@186 3155 ;;
pankso@108 3156 maintainers)
gokhlayeh@186 3157 get_tazwok_config
pankso@108 3158 echo ""
pankso@108 3159 echo "List of maintainers for: $WOK"
pankso@108 3160 echo "================================================================================"
pankso@108 3161 touch /tmp/slitaz-maintainers
pankso@108 3162 for pkg in $WOK/*
pankso@108 3163 do
pankso@108 3164 . $pkg/receipt
gokhlayeh@195 3165 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
pankso@108 3166 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
pankso@108 3167 echo "$MAINTAINER"
pankso@108 3168 fi
pankso@108 3169 done
pankso@108 3170 echo "================================================================================"
pankso@108 3171 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
pankso@108 3172 echo ""
pankso@108 3173 # Remove tmp files
gokhlayeh@186 3174 rm -f /tmp/slitaz-maintainers
gokhlayeh@186 3175 ;;
pankso@107 3176 maintained-by)
paul@166 3177 # Search for packages maintained by a contributor.
gokhlayeh@186 3178 get_tazwok_config
pankso@107 3179 if [ ! -n "$2" ]; then
gokhlayeh@186 3180 echo "Specify a name or email of a maintainer." >&2
gokhlayeh@186 3181 exit 1
pankso@107 3182 fi
pankso@107 3183 echo "Maintainer packages"
pankso@107 3184 echo "================================================================================"
pankso@107 3185 for pkg in $WOK/*
pankso@107 3186 do
pankso@107 3187 . $pkg/receipt
gokhlayeh@195 3188 if echo "$MAINTAINER" | fgrep -q "$2"; then
pankso@107 3189 echo "$PACKAGE"
gokhlayeh@186 3190 packages=$(($PACKAGEs+1))
pankso@107 3191 fi
pankso@107 3192 done
pankso@107 3193 echo "================================================================================"
gokhlayeh@186 3194 echo "Packages maintained by $2: $PACKAGEs"
gokhlayeh@186 3195 echo ""
gokhlayeh@186 3196 ;;
gokhlayeh@268 3197 tags)
gokhlayeh@268 3198 get_tazwok_config
gokhlayeh@268 3199 echo -e "\n\033[1mTags list :\033[0m"
gokhlayeh@268 3200 horizontal_line
gokhlayeh@268 3201 cd $WOK
gokhlayeh@268 3202 for i in */receipt; do
gokhlayeh@268 3203 unset TAGS
gokhlayeh@268 3204 source $i
gokhlayeh@268 3205 for t in $TAGS; do
gokhlayeh@268 3206 grep -q ^$t$ $tmp/tags && continue
gokhlayeh@268 3207 echo $t | tee -a $tmp/tags
gokhlayeh@268 3208 done
gokhlayeh@268 3209 done
gokhlayeh@268 3210 horizontal_line
gokhlayeh@268 3211 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
gokhlayeh@268 3212 ;;
erjo@159 3213 check-src)
paul@430 3214 # Verify if upstream package is still available.
erjo@159 3215 #
gokhlayeh@186 3216 get_tazwok_config
erjo@159 3217 check_for_package_on_cmdline
erjo@159 3218 check_for_receipt
gokhlayeh@186 3219 source_receipt
erjo@159 3220 check_src()
erjo@159 3221 {
erjo@159 3222 for url in $@; do
pascal@178 3223 busybox wget -s $url 2>/dev/null && break
erjo@159 3224 done
erjo@159 3225 }
gokhlayeh@186 3226 if [ "$WGET_URL" ];then
erjo@159 3227 echo -n "$PACKAGE : "
erjo@159 3228 check_src $WGET_URL
erjo@159 3229 status
erjo@159 3230 else
erjo@159 3231 echo "No tarball to check for $PACKAGE"
erjo@159 3232 fi
gokhlayeh@186 3233 ;;
gokhlayeh@186 3234 get-src)
gokhlayeh@186 3235 check_root
gokhlayeh@225 3236 get_options_list="target nounpack"
gokhlayeh@186 3237 get_tazwok_config
gokhlayeh@186 3238 check_for_package_on_cmdline
gokhlayeh@186 3239 check_for_receipt
gokhlayeh@186 3240 source_receipt
gokhlayeh@186 3241 if [ "$WGET_URL" ];then
gokhlayeh@186 3242 source_lib report
gokhlayeh@186 3243 report start
gokhlayeh@225 3244 check_for_tarball
gokhlayeh@186 3245 else
gokhlayeh@186 3246 echo "No tarball to download for $PACKAGE"
gokhlayeh@186 3247 fi
gokhlayeh@186 3248 ;;
gokhlayeh@204 3249 check-commit)
gokhlayeh@186 3250 check_root
gokhlayeh@204 3251 get_options_list="missing forced"
gokhlayeh@186 3252 get_tazwok_config
gokhlayeh@186 3253 source_lib report
gokhlayeh@186 3254 report start
gokhlayeh@204 3255 if [ "$forced" ]; then
gokhlayeh@204 3256 rm -f $WOK/*/md5
gokhlayeh@204 3257 unset forced
gokhlayeh@204 3258 fi
gokhlayeh@204 3259 if [ "$missing" ]; then
gokhlayeh@204 3260 pkg=$(ls -1 $WOK)
gokhlayeh@204 3261 else
gokhlayeh@204 3262 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 3263 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 3264 } | sort -u)"
gokhlayeh@204 3265 fi
gokhlayeh@186 3266 gen_cook_list
gokhlayeh@186 3267 ;;
gokhlayeh@186 3268 cook-commit)
gokhlayeh@186 3269 check_root
gokhlayeh@204 3270 get_options_list="missing forced"
gokhlayeh@186 3271 get_tazwok_config
gokhlayeh@186 3272 source_lib report
gokhlayeh@186 3273 report start
gokhlayeh@204 3274 if [ "$forced" ]; then
gokhlayeh@204 3275 rm -f $WOK/*/md5
gokhlayeh@204 3276 unset forced
gokhlayeh@204 3277 fi
gokhlayeh@204 3278 if [ "$missing" ]; then
gokhlayeh@204 3279 pkg=$(ls -1 $WOK)
gokhlayeh@204 3280 else
gokhlayeh@204 3281 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 3282 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 3283 } | sort -u)"
gokhlayeh@204 3284 fi
gokhlayeh@186 3285 gen_cook_list
gokhlayeh@186 3286 cook_list
gokhlayeh@186 3287 ;;
gokhlayeh@186 3288 cook-all)
gokhlayeh@186 3289 check_root
gokhlayeh@204 3290 get_options_list="forced missing"
gokhlayeh@186 3291 get_tazwok_config
gokhlayeh@186 3292 source_lib report
gokhlayeh@186 3293 report start
gokhlayeh@204 3294 if [ "$missing" ]; then
gokhlayeh@204 3295 pkg=$(ls -1 $WOK)
gokhlayeh@204 3296 else
gokhlayeh@204 3297 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 3298 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 3299 } | sort -u)"
gokhlayeh@204 3300 fi
gokhlayeh@204 3301 gen_cook_list
gokhlayeh@186 3302 cook_list
gokhlayeh@186 3303 ;;
gokhlayeh@186 3304 gen-wok-db)
gokhlayeh@186 3305 check_root
gokhlayeh@186 3306 get_tazwok_config
gokhlayeh@186 3307 source_lib report
gokhlayeh@186 3308 report start
gokhlayeh@204 3309 gen_wok_db
gokhlayeh@186 3310 ;;
gokhlayeh@186 3311 report)
gokhlayeh@186 3312 get_tazwok_config
gokhlayeh@186 3313 cd $PACKAGES_REPOSITORY
gokhlayeh@239 3314 if [ "$2" ]; then
gokhlayeh@239 3315 case $2 in
gokhlayeh@239 3316 commit|cooklist|incoming|broken|blocked)
gokhlayeh@239 3317 show="$2"
gokhlayeh@239 3318 ;;
gokhlayeh@239 3319 *)
gokhlayeh@239 3320 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
gokhlayeh@239 3321 exit 1
gokhlayeh@239 3322 ;;
gokhlayeh@239 3323 esac
gokhlayeh@239 3324 else
gokhlayeh@239 3325 show="commit cooklist incoming broken blocked"
gokhlayeh@239 3326 fi
gokhlayeh@239 3327 for i in $show; do
gokhlayeh@186 3328 if [ -s $i ]; then
gokhlayeh@239 3329 echo ""
gokhlayeh@239 3330 echo -e "\033[1m$i\033[0m"
gokhlayeh@239 3331 echo "================================================================================"
gokhlayeh@239 3332 cat $i
gokhlayeh@239 3333 echo "================================================================================"
gokhlayeh@239 3334 echo ""
gokhlayeh@186 3335 fi
gokhlayeh@186 3336 done
gokhlayeh@186 3337 ;;
gokhlayeh@186 3338 check-incoming)
gokhlayeh@186 3339 check_root
gokhlayeh@214 3340 get_options_list="forced"
gokhlayeh@186 3341 get_tazwok_config
gokhlayeh@186 3342 source_lib report
gokhlayeh@186 3343 report start
gokhlayeh@307 3344 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
gokhlayeh@307 3345 report step "Checking $INCOMING_REPOSITORY"
gokhlayeh@307 3346 report open-bloc
gokhlayeh@313 3347 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
gokhlayeh@307 3348 report sublog $LOCAL_REPOSITORY/log/incoming.html
gokhlayeh@352 3349 echo "incoming" > $LOCAL_REPOSITORY/log/package
gokhlayeh@186 3350 check_for_incoming
gokhlayeh@307 3351 report end-sublog
gokhlayeh@307 3352 report close-bloc
gokhlayeh@186 3353 ;;
gokhlayeh@190 3354 configure-chroot)
gokhlayeh@190 3355 check_root
gokhlayeh@190 3356 get_tazwok_config
gokhlayeh@190 3357 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@190 3358 cd $LOCAL_REPOSITORY
gokhlayeh@190 3359 configure_tazchroot
gokhlayeh@190 3360 else
paul@430 3361 echo "The package tazchroot needs to be installed" >&2
gokhlayeh@190 3362 exit 1
gokhlayeh@190 3363 fi
gokhlayeh@190 3364 ;;
gokhlayeh@186 3365 chroot)
gokhlayeh@186 3366 check_root
gokhlayeh@186 3367 get_tazwok_config
gokhlayeh@186 3368 # Merge this and the other chroot function ?.
gokhlayeh@186 3369 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@186 3370 cd $LOCAL_REPOSITORY
gokhlayeh@186 3371 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@186 3372 tazchroot
gokhlayeh@186 3373 else
paul@430 3374 echo "The package tazchroot needs to be installed" >&2
gokhlayeh@186 3375 exit 1
gokhlayeh@186 3376 fi
gokhlayeh@186 3377 ;;
gokhlayeh@186 3378 cook-toolchain)
gokhlayeh@186 3379 check_root
gokhlayeh@186 3380 get_tazwok_config
gokhlayeh@186 3381 echo -n "" > $PACKAGES_REPOSITORY/broken
gokhlayeh@186 3382 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@186 3383 cd $LOCAL_REPOSITORY
gokhlayeh@406 3384 [ -f tazchroot.conf ] || configure_tazchroot
gokhlayeh@406 3385
gokhlayeh@406 3386 # Plan to recook all packages.
gokhlayeh@406 3387 if tazchroot cook-toolchain; then
gokhlayeh@406 3388 source_lib report
gokhlayeh@406 3389 report start
gokhlayeh@406 3390 pkg="$(grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt \
gokhlayeh@406 3391 $INCOMING_REPOSITORY/packages.txt | sort -u)"
gokhlayeh@406 3392 forced=yes
gokhlayeh@406 3393 gen_cook_list
gokhlayeh@406 3394 fi
gokhlayeh@406 3395
gokhlayeh@406 3396 # Remove chroot where toolchain has been cooked.
gokhlayeh@406 3397 source $LOCAL_REPOSITORY/tazchroot.conf
gokhlayeh@186 3398 rm -r $LOCAL_REPOSITORY/chroot
gokhlayeh@406 3399
gokhlayeh@186 3400 else
gokhlayeh@434 3401 echo -e "\nThe package tazchroot needs to be installed.\n" >&2
gokhlayeh@186 3402 exit 1
gokhlayeh@186 3403 fi
gokhlayeh@186 3404 ;;
gokhlayeh@235 3405 webserver)
gokhlayeh@235 3406 check_root
gokhlayeh@235 3407 get_tazwok_config
gokhlayeh@235 3408 if [ "$ARG" = on ]; then
gokhlayeh@235 3409 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
gokhlayeh@235 3410 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
gokhlayeh@235 3411 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
gokhlayeh@235 3412 exit 1
gokhlayeh@235 3413 fi
gokhlayeh@235 3414 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
gokhlayeh@235 3415 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
gokhlayeh@235 3416 fi
gokhlayeh@235 3417 for pkg in php lighttpd; do
gokhlayeh@235 3418 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
gokhlayeh@235 3419 done
gokhlayeh@235 3420 if [ "$missing" ]; then
paul@430 3421 echo "You need to install these packages to start webserver: $missing." >&2
gokhlayeh@235 3422 exit 1
gokhlayeh@235 3423 fi
gokhlayeh@235 3424 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
gokhlayeh@235 3425 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
gokhlayeh@235 3426 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
gokhlayeh@235 3427 fi
gokhlayeh@235 3428 if ! [ "$WEBSERVER" ]; then
gokhlayeh@235 3429 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
gokhlayeh@235 3430 read WEBSERVER
gokhlayeh@235 3431 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
gokhlayeh@235 3432 fi
gokhlayeh@235 3433 if [ -f "$WEBSERVER/repositories.list" ] && \
gokhlayeh@235 3434 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
gokhlayeh@235 3435 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
gokhlayeh@235 3436 exit 1
gokhlayeh@235 3437 fi
gokhlayeh@235 3438 mkdir -p $WEBSERVER
gokhlayeh@235 3439 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
gokhlayeh@267 3440 for file in index.php log.php download.php; do
gokhlayeh@235 3441 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
gokhlayeh@235 3442 done
gokhlayeh@267 3443 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
gokhlayeh@267 3444 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
gokhlayeh@267 3445 done
gokhlayeh@235 3446 source $LOCAL_REPOSITORY/tazchroot.conf
gokhlayeh@235 3447 echo "<?php
gokhlayeh@235 3448
gokhlayeh@235 3449 // Web interface configuration
gokhlayeh@235 3450
gokhlayeh@235 3451 \$version=\"${undigest:-$SLITAZ_VERSION}\";
gokhlayeh@235 3452 \$chroot=\"$chroot_dir\";
pascal@360 3453 \$lockfile=\"\$chroot/proc/1/status\";
gokhlayeh@235 3454 \$db_dir=\"$PACKAGES_REPOSITORY\";
gokhlayeh@235 3455 \$log_dir=\"$LOCAL_REPOSITORY/log\";
gokhlayeh@235 3456 \$packages=\"$PACKAGES_REPOSITORY\";
gokhlayeh@235 3457 \$incoming=\"$INCOMING_REPOSITORY\";
gokhlayeh@251 3458 \$wok=\"$WOK\";
gokhlayeh@235 3459
gokhlayeh@235 3460 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
gokhlayeh@235 3461 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
gokhlayeh@235 3462 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
gokhlayeh@235 3463 if [ -L "$WEBSERVER/conf.php" ]; then
paul@430 3464 echo "Do you want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
gokhlayeh@235 3465 read answer
gokhlayeh@235 3466 if [ "$answer" = y ]; then
gokhlayeh@235 3467 rm $WEBSERVER/conf.php
gokhlayeh@235 3468 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
gokhlayeh@235 3469 fi
gokhlayeh@235 3470 else
gokhlayeh@235 3471 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
gokhlayeh@235 3472 fi
gokhlayeh@235 3473 elif [ "$ARG" = off ]; then
gokhlayeh@235 3474 if ! [ "$WEBSERVER" ]; then
gokhlayeh@235 3475 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
gokhlayeh@235 3476 exit 1
gokhlayeh@235 3477 fi
gokhlayeh@235 3478 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
gokhlayeh@235 3479 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
gokhlayeh@235 3480 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
gokhlayeh@267 3481 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
gokhlayeh@267 3482 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
gokhlayeh@267 3483 done
gokhlayeh@235 3484 if ! [ -s "$WEBSERVER/repositories.list" ]; then
paul@430 3485 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If that's not the case, you can remove it using: rm -r $WEBSERVER"
gokhlayeh@235 3486 rm $WEBSERVER/conf.php
gokhlayeh@235 3487 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
gokhlayeh@235 3488 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
gokhlayeh@235 3489 rm $WEBSERVER/conf.php
gokhlayeh@235 3490 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
gokhlayeh@235 3491 fi
gokhlayeh@235 3492 else
gokhlayeh@235 3493 echo "Usage: tazwok webserver on/off" >&2
gokhlayeh@235 3494 exit 1
gokhlayeh@235 3495 fi
gokhlayeh@235 3496 ;;
pankso@354 3497 block)
pankso@354 3498 # Add a pkg name to the list of blocked packages.
gokhlayeh@367 3499 get_tazwok_config
gokhlayeh@367 3500 check_root
gokhlayeh@367 3501 check_for_package_on_cmdline
gokhlayeh@367 3502 if ! [ -f $WOK/$PACKAGE/receipt ]; then
paul@430 3503 echo "Can't find $PACKAGE in wok." >&2
gokhlayeh@367 3504 echo ""
gokhlayeh@367 3505 exit 1
gokhlayeh@367 3506 fi
pankso@354 3507 echo ""
gokhlayeh@405 3508 if grep -qs "^$PACKAGE$" $blocked; then
gokhlayeh@367 3509 echo "$PACKAGE is already in the blocked packages list." >&2
gokhlayeh@367 3510 echo ""
gokhlayeh@367 3511 exit 1
pankso@354 3512 else
gokhlayeh@405 3513 echo -n "Adding $PACKAGE to : $blocked... "
gokhlayeh@405 3514 echo "$PACKAGE" >> $blocked
gokhlayeh@367 3515 status
gokhlayeh@405 3516 if grep -q "^$PACKAGE$" $cooklist; then
gokhlayeh@405 3517 echo -n "Removing $PACKAGE from : $cooklist... "
gokhlayeh@405 3518 sed -i /"^$PACKAGE$"/d $cooklist
gokhlayeh@367 3519 status
pankso@354 3520 fi
pankso@354 3521 fi
pankso@354 3522 echo "" ;;
pankso@354 3523 unblock)
pankso@354 3524 # Remove a pkg name from the list of blocked packages.
gokhlayeh@367 3525 get_tazwok_config
gokhlayeh@367 3526 check_root
gokhlayeh@367 3527 check_for_package_on_cmdline
gokhlayeh@367 3528 if ! [ -f $WOK/$PACKAGE/receipt ]; then
paul@430 3529 echo "Can't find $PACKAGE in wok." >&2
gokhlayeh@367 3530 echo ""
gokhlayeh@367 3531 exit 1
gokhlayeh@367 3532 fi
pankso@354 3533 echo ""
gokhlayeh@405 3534 if grep -qs "^$PACKAGE$" $blocked; then
gokhlayeh@405 3535 echo -n "Removing $PACKAGE from : $blocked... "
gokhlayeh@405 3536 sed -i /"^$PACKAGE$"/d $blocked
gokhlayeh@405 3537 sed -i '/^$/d' $blocked
gokhlayeh@367 3538 status
pankso@354 3539 else
gokhlayeh@367 3540 echo "$PACKAGE is not in the blocked packages list." >&2
gokhlayeh@367 3541 echo ""
gokhlayeh@367 3542 exit 1
pankso@354 3543 fi
pankso@354 3544 echo "" ;;
pankso@7 3545 usage|*)
MikeDSmith25@82 3546 # Print usage also for all unknown commands.
pankso@7 3547 #
pankso@7 3548 usage
gokhlayeh@186 3549 ;;
pankso@7 3550 esac
pankso@7 3551
gokhlayeh@451 3552 # If a cook command has been used, refresh ID of the repository to avoid
gokhlayeh@451 3553 # useless upgrade at next cook command.
gokhlayeh@451 3554 case $COMMAND in
gokhlayeh@451 3555 cook*)
gokhlayeh@451 3556 for repo in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY \
gokhlayeh@451 3557 $( [ "$undigest" -a ! "$ref_USE_ONLINE_PKG" ] && echo $ref_PACKAGES_REPOSITORY ); do
gokhlayeh@451 3558 [ -f $repo/ID ] || continue
gokhlayeh@451 3559 MIRROR_path=$(grep -l "^$repo$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror)
gokhlayeh@451 3560 LOCALSTATE_path=${MIRROR_path%/mirror}
gokhlayeh@451 3561 cp -a $repo/ID $LOCALSTATE_path
gokhlayeh@451 3562 done
gokhlayeh@451 3563 ;;
gokhlayeh@451 3564 esac
gokhlayeh@451 3565
gokhlayeh@313 3566 report stop 2>/dev/null
pankso@7 3567 exit 0