tazwok annotate tazwok @ rev 398

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