tazwok annotate tazwok @ rev 401

Generate safe wok / optionnally safe-wok tarball (4.3)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Thu Mar 03 22:51:15 2011 +0100 (2011-03-03)
parents 83afa4ea8ba6
children 87a358f04407
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@400 150 cookorder=$PACKAGES_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@399 1384 [ "$pkg_repository" != "$PACKAGES_REPOSITORY" ] && return 0
gokhlayeh@399 1385 for i in wok-wanted.txt wok-depends.txt; do
gokhlayeh@399 1386 [ -f $i ] || continue
gokhlayeh@399 1387 sed "/^$PACKAGE\t/d" -i $i
gokhlayeh@399 1388 done
gokhlayeh@186 1389 }
gokhlayeh@186 1390
gokhlayeh@186 1391 get_packages_info()
gokhlayeh@186 1392 {
gokhlayeh@186 1393 # If there's no taz folder in the wok, extract infos from the
gokhlayeh@186 1394 # package.
gokhlayeh@186 1395 get_pkg_files $pkg
gokhlayeh@186 1396 source_receipt
gokhlayeh@186 1397 echo "Getting datas from $PACKAGE"
gokhlayeh@186 1398
gokhlayeh@186 1399 cat >> $pkg_repository/packages.txt << _EOT_
pankso@28 1400 $PACKAGE
gokhlayeh@186 1401 $VERSION$EXTRAVERSION
pankso@28 1402 $SHORT_DESC
pankso@28 1403 _EOT_
gokhlayeh@215 1404 if [ "$PACKED_SIZE" ]; then
gokhlayeh@215 1405 cat >> $pkg_repository/packages.txt << _EOT_
pankso@133 1406 $PACKED_SIZE ($UNPACKED_SIZE installed)
gokhlayeh@215 1407
pascal@60 1408 _EOT_
gokhlayeh@215 1409 else
gokhlayeh@215 1410 echo "" >> $pkg_repository/packages.txt
pascal@60 1411 fi
gokhlayeh@186 1412
paul@121 1413 # Packages.desc is used by Tazpkgbox <tree>.
gokhlayeh@186 1414 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
gokhlayeh@186 1415
paul@121 1416 # Packages.equiv is used by tazpkg install to check depends
pascal@99 1417 for i in $PROVIDE; do
pascal@99 1418 DEST=""
gokhlayeh@195 1419 echo $i | fgrep -q : && DEST="${i#*:}:"
gokhlayeh@186 1420 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
gokhlayeh@186 1421 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
pascal@99 1422 else
gokhlayeh@186 1423 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
gokhlayeh@186 1424 fi
gokhlayeh@186 1425 done
gokhlayeh@186 1426
gokhlayeh@186 1427 if [ -f files.list ]; then
gokhlayeh@186 1428 { echo "$PACKAGE"; cat files.list; } | awk '
gokhlayeh@186 1429 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
gokhlayeh@186 1430 fi
gokhlayeh@186 1431
gokhlayeh@186 1432 cd .. && rm -r "$pkg_files_dir"
gokhlayeh@186 1433
gokhlayeh@186 1434 cd $pkg_repository
gokhlayeh@186 1435 echo $(basename ${pkg%.tazpkg}) >> packages.list
gokhlayeh@186 1436 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
gokhlayeh@186 1437 echo "$package_md5" >> packages.md5
gokhlayeh@186 1438 unset package_md5
gokhlayeh@399 1439
gokhlayeh@399 1440 if [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ]; then
gokhlayeh@399 1441 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wok-wanted.txt
gokhlayeh@399 1442 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> wok-package.txt
gokhlayeh@399 1443 fi
gokhlayeh@186 1444 }
gokhlayeh@186 1445
gokhlayeh@186 1446 source_receipt()
gokhlayeh@186 1447 {
gokhlayeh@186 1448 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
gokhlayeh@186 1449 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
gokhlayeh@186 1450 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
gokhlayeh@298 1451 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL stuff wanted_stuff
gokhlayeh@186 1452 . ${RECEIPT:-$PWD/receipt}
gokhlayeh@186 1453 }
gokhlayeh@186 1454
gokhlayeh@186 1455 packages_db_end()
gokhlayeh@186 1456 {
gokhlayeh@186 1457 cd $pkg_repository
gokhlayeh@186 1458 pkgs=$(wc -l packages.list | sed 's/ .*//')
gokhlayeh@186 1459 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
gokhlayeh@186 1460
gokhlayeh@186 1461 # If lists was updated it's generally needed to sort them well.
gokhlayeh@186 1462 if ! sort -c packages.list 2> /dev/null; then
gokhlayeh@186 1463 report step "Sorting packages lists"
gokhlayeh@399 1464 files_list="packages.list packages.desc packages.equiv"
gokhlayeh@399 1465 [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ] && \
gokhlayeh@399 1466 files_list="$files_list wok-wanted.txt wok-depends.txt"
gokhlayeh@399 1467 for file in $files_list; do
gokhlayeh@186 1468 [ -f $file ] || continue
gokhlayeh@186 1469 sort -o $file $file
gokhlayeh@186 1470 done
gokhlayeh@399 1471 md5sum packages.md5 | cut -f1 -d' ' > ID
gokhlayeh@186 1472 report end-step
gokhlayeh@186 1473 fi
gokhlayeh@186 1474
gokhlayeh@186 1475 # Dont log this because lzma always output error.
gokhlayeh@186 1476 lzma e files.list files.list.lzma
gokhlayeh@204 1477 rm -f files.list
gokhlayeh@204 1478 [ -f packages.equiv ] || touch packages.equiv
gokhlayeh@186 1479 }
gokhlayeh@186 1480
gokhlayeh@186 1481 ########################################################################
gokhlayeh@186 1482 # This section contains functions to generate wok database.
gokhlayeh@186 1483 ########################
gokhlayeh@186 1484
gokhlayeh@186 1485 gen_wok_db()
gokhlayeh@186 1486 {
gokhlayeh@204 1487 report step "Generating wok database"
gokhlayeh@186 1488 report open-bloc
gokhlayeh@204 1489 report step "Removing old files"
gokhlayeh@397 1490 for file in $wan_db $dep_db $cookorder; do
gokhlayeh@204 1491 [ -f $file ] && rm $file
gokhlayeh@204 1492 done
gokhlayeh@186 1493 report step "Generating wok-wanted.txt"
gokhlayeh@204 1494 gen_wan_db
gokhlayeh@186 1495 report step "Generating wok-depends.txt"
gokhlayeh@204 1496 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
gokhlayeh@204 1497 $INCOMING_REPOSITORY/packages.desc | sort -u); do
gokhlayeh@186 1498 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@186 1499 if [ -s $RECEIPT ]; then
gokhlayeh@186 1500 source_receipt
gokhlayeh@186 1501 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
pankso@133 1502 fi
pascal@99 1503 done
gokhlayeh@215 1504 sort_db
gokhlayeh@204 1505 report close-bloc
pankso@28 1506 }
pankso@28 1507
gokhlayeh@204 1508 gen_wan_db()
pascal@91 1509 {
gokhlayeh@204 1510 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
gokhlayeh@204 1511 WANTED=
gokhlayeh@204 1512 source $RECEIPT
gokhlayeh@204 1513 [ "$WANTED" ] || continue
gokhlayeh@204 1514 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
gokhlayeh@204 1515 done
gokhlayeh@215 1516 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
gokhlayeh@204 1517 mv -f $tmp/wan_db $wan_db
gokhlayeh@204 1518 plan_regen_cookorder=yes
gokhlayeh@204 1519 else
gokhlayeh@204 1520 rm $tmp/wan_db
gokhlayeh@204 1521 fi
pascal@91 1522 }
pascal@91 1523
gokhlayeh@215 1524 update_wan_db()
gokhlayeh@215 1525 {
slaxemulator@326 1526 local PACKAGE=$PACKAGE
gokhlayeh@215 1527 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
gokhlayeh@215 1528 fgrep $PACKAGE | cut -f1 -d ':'); do
gokhlayeh@215 1529 WANTED=
gokhlayeh@215 1530 source $RECEIPT
gokhlayeh@215 1531 [ "$WANTED" ] || continue
gokhlayeh@219 1532 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
gokhlayeh@215 1533 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
gokhlayeh@215 1534 sed "/^$PACKAGE\t/d" -i $wan_db
gokhlayeh@220 1535 echo "$wan_info" >> $wan_db
gokhlayeh@215 1536 plan_regen_cookorder=yes
gokhlayeh@215 1537 plan_sort_wandb=yes
gokhlayeh@215 1538 done
gokhlayeh@215 1539 }
gokhlayeh@215 1540
gokhlayeh@204 1541 update_dep_db()
gokhlayeh@204 1542 {
gokhlayeh@204 1543 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
gokhlayeh@215 1544 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
gokhlayeh@204 1545 sed "/^$PACKAGE\t/d" -i $dep_db
gokhlayeh@204 1546 echo "$dep_info" >> $dep_db
gokhlayeh@204 1547 plan_regen_cookorder=yes
gokhlayeh@204 1548 plan_sort_depdb=yes
pascal@178 1549 }
pascal@178 1550
gokhlayeh@186 1551 sort_db()
pascal@178 1552 {
gokhlayeh@186 1553 report step "Generating cookorder.txt"
gokhlayeh@186 1554 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
gokhlayeh@186 1555 grep -q ^$PACKAGE$'\t' $wan_db && continue
gokhlayeh@186 1556
gokhlayeh@186 1557 # Replace each BUILD_DEPENDS with a WANTED package by it's
gokhlayeh@186 1558 # WANTED package.
gokhlayeh@186 1559 replace_by_wanted()
gokhlayeh@186 1560 {
gokhlayeh@186 1561 for p in $BUILD_DEPENDS; do
gokhlayeh@186 1562 if grep -q ^$p$'\t' $wan_db; then
gokhlayeh@186 1563 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
gokhlayeh@186 1564 else
gokhlayeh@186 1565 echo -n $p' '
gokhlayeh@186 1566 fi
gokhlayeh@186 1567 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
gokhlayeh@186 1568 }
gokhlayeh@186 1569 echo -e $PACKAGE"\t $(replace_by_wanted) "
gokhlayeh@186 1570 done > $tmp/db
gokhlayeh@186 1571 while [ -s "$tmp/db" ]; do
gokhlayeh@186 1572 status=start
gokhlayeh@186 1573 for pkg in $(cut -f 1 $tmp/db); do
gokhlayeh@195 1574 if ! fgrep -q ' '$pkg' ' $tmp/db; then
gokhlayeh@186 1575 echo $pkg >> $tmp/cookorder
gokhlayeh@186 1576 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
gokhlayeh@186 1577 status=proceed
gokhlayeh@186 1578 fi
gokhlayeh@186 1579 done
gokhlayeh@186 1580 if [ "$status" = start ]; then
gokhlayeh@186 1581 cp -f $tmp/db /tmp/remain-depends.txt
gokhlayeh@186 1582 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 1583 for blocked in $(cut -f 1 $tmp/db); do
gokhlayeh@186 1584 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
gokhlayeh@186 1585 done
gokhlayeh@186 1586 break
gokhlayeh@186 1587 fi
gokhlayeh@186 1588 done
gokhlayeh@186 1589 [ -s $tmp/cookorder ] || touch $tmp/cookorder
gokhlayeh@186 1590
gokhlayeh@186 1591 # The toolchain packages are moved in first position.
gokhlayeh@186 1592 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 1593 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
gokhlayeh@397 1594 $tmp/cookorder | tac > $cookorder
gokhlayeh@397 1595 for pkg in $(cat $cookorder); do
gokhlayeh@186 1596 sed "/^$pkg$/d" -i $tmp/cookorder
gokhlayeh@186 1597 done
gokhlayeh@186 1598
gokhlayeh@397 1599 tac $tmp/cookorder >> $cookorder
gokhlayeh@204 1600 unset plan_regen_cookorder
gokhlayeh@186 1601 report end-step
pascal@178 1602 }
pascal@178 1603
gokhlayeh@186 1604 ########################################################################
gokhlayeh@186 1605 # SCAN CORE
gokhlayeh@186 1606 ########################
gokhlayeh@186 1607 # Include various scan core-functions. It's not intended to be used
gokhlayeh@186 1608 # directly : prefer scan wrappers in next section.
gokhlayeh@186 1609
gokhlayeh@186 1610 look_for_dep()
gokhlayeh@186 1611 {
gokhlayeh@186 1612 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@399 1613 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
gokhlayeh@186 1614 else
gokhlayeh@399 1615 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
gokhlayeh@186 1616 fi
gokhlayeh@186 1617 }
gokhlayeh@186 1618
gokhlayeh@186 1619 look_for_bdep()
gokhlayeh@186 1620 {
gokhlayeh@186 1621 look_for_all
gokhlayeh@186 1622 }
gokhlayeh@186 1623
gokhlayeh@186 1624 look_for_all()
gokhlayeh@186 1625 {
gokhlayeh@186 1626 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@399 1627 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ / /'
gokhlayeh@186 1628 else
gokhlayeh@399 1629 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
gokhlayeh@186 1630 fi
gokhlayeh@186 1631 }
gokhlayeh@186 1632
gokhlayeh@186 1633 look_for_rdep()
gokhlayeh@186 1634 {
gokhlayeh@399 1635 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
gokhlayeh@186 1636 if [ "$undigest" ]; then
gokhlayeh@399 1637 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
gokhlayeh@186 1638 if [ ! -f "WOK$/$rdep/receipt" ]; then
gokhlayeh@186 1639 echo "$rdep"
gokhlayeh@186 1640 fi
gokhlayeh@186 1641 done
gokhlayeh@186 1642 fi
gokhlayeh@186 1643 }
gokhlayeh@186 1644
gokhlayeh@186 1645 look_for_rbdep()
gokhlayeh@186 1646 {
gokhlayeh@399 1647 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
gokhlayeh@186 1648 if [ "$undigest" ]; then
gokhlayeh@399 1649 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
gokhlayeh@186 1650 if [ ! -f "WOK$/$rdep/receipt" ]; then
gokhlayeh@186 1651 echo "$rdep"
gokhlayeh@186 1652 fi
gokhlayeh@186 1653 done
gokhlayeh@399 1654 fi
gokhlayeh@186 1655 }
gokhlayeh@186 1656
gokhlayeh@186 1657 # Return WANTED if it exists.
gokhlayeh@186 1658 look_for_wanted()
gokhlayeh@186 1659 {
gokhlayeh@186 1660 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@399 1661 grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
gokhlayeh@186 1662 else
gokhlayeh@399 1663 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
gokhlayeh@186 1664 fi
gokhlayeh@186 1665 }
gokhlayeh@186 1666
gokhlayeh@186 1667 # Return packages which wants PACKAGE.
gokhlayeh@186 1668 look_for_rwanted()
gokhlayeh@186 1669 {
gokhlayeh@399 1670 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
gokhlayeh@186 1671 if [ "$undigest" ]; then
gokhlayeh@399 1672 for rwanted in $(grep $'\t' $ref_wan_db | cut -f 1); do
gokhlayeh@186 1673 if [ ! -f "$WOK/$rwanted/receipt" ]; then
gokhlayeh@186 1674 echo "$rwanted"
gokhlayeh@186 1675 fi
gokhlayeh@186 1676 done
gokhlayeh@186 1677 fi
gokhlayeh@186 1678 }
gokhlayeh@186 1679
gokhlayeh@186 1680 look_for_dev()
gokhlayeh@186 1681 {
gokhlayeh@223 1682 WANTED=$(look_for_wanted)
gokhlayeh@223 1683 if [ "$WANTED" ]; then
gokhlayeh@223 1684 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
gokhlayeh@399 1685 grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
gokhlayeh@223 1686 else
gokhlayeh@223 1687 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
gokhlayeh@223 1688 fi
gokhlayeh@223 1689 fi
gokhlayeh@223 1690 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
gokhlayeh@399 1691 grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
gokhlayeh@223 1692 else
gokhlayeh@223 1693 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
gokhlayeh@223 1694 fi
gokhlayeh@186 1695 }
gokhlayeh@186 1696
gokhlayeh@215 1697 with_dev()
gokhlayeh@215 1698 {
gokhlayeh@215 1699 for PACKAGE in $(cat); do
gokhlayeh@215 1700 echo $PACKAGE
gokhlayeh@215 1701 look_for_dev
gokhlayeh@215 1702 done
gokhlayeh@215 1703 }
gokhlayeh@215 1704
gokhlayeh@215 1705 with_wanted()
gokhlayeh@215 1706 {
gokhlayeh@215 1707 for PACKAGE in $(cat); do
gokhlayeh@215 1708 echo $PACKAGE
gokhlayeh@215 1709 look_for_wanted
gokhlayeh@215 1710 done
gokhlayeh@215 1711 }
gokhlayeh@215 1712
gokhlayeh@215 1713 use_wanted()
gokhlayeh@215 1714 {
gokhlayeh@215 1715 for input in $(cat); do
gokhlayeh@215 1716 { grep ^$input$'\t' $wan_db || echo $input
gokhlayeh@215 1717 } | sed 's/.*\t//'
gokhlayeh@215 1718 done
gokhlayeh@215 1719 }
gokhlayeh@215 1720
gokhlayeh@186 1721 ########################################################################
gokhlayeh@186 1722 # SCAN
gokhlayeh@186 1723 ########################
gokhlayeh@186 1724 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
gokhlayeh@186 1725 # Option in command line (must be first arg) :
gokhlayeh@186 1726 # --look_for=bdep/rbdep - Look for depends or reverse depends.
gokhlayeh@186 1727 # --with_dev - Add development packages (*-dev) in the result.
gokhlayeh@186 1728 # --with_wanted - Add package+reverse wanted in the result.
gokhlayeh@186 1729 # --with_args - Include packages in argument in the result.
gokhlayeh@186 1730
gokhlayeh@186 1731 scan()
gokhlayeh@186 1732 {
gokhlayeh@186 1733 # Get packages in argument.
slaxemulator@326 1734 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
gokhlayeh@186 1735 for arg in $@; do
gokhlayeh@186 1736 [ "$arg" = "${arg#--}" ] || continue
gokhlayeh@186 1737 pkg_list="$pkg_list $arg"
gokhlayeh@186 1738 done
gokhlayeh@204 1739
gokhlayeh@186 1740 # Get options.
gokhlayeh@186 1741 [ "$pkg_list" ] || return
gokhlayeh@186 1742 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
gokhlayeh@215 1743 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
gokhlayeh@186 1744 get_options
gokhlayeh@186 1745
gokhlayeh@186 1746 # Cooklist is a special case where we need to modify a little
gokhlayeh@186 1747 # scan behavior
gokhlayeh@186 1748 if [ "$cooklist" ]; then
gokhlayeh@204 1749 gen_wan_db
gokhlayeh@204 1750 look_for=all && with_args=yes && with_dev= && with_wanted=
gokhlayeh@204 1751 filter=use_wanted
gokhlayeh@241 1752 if [ "$COMMAND" = gen-cooklist ]; then
gokhlayeh@241 1753 for PACKAGE in $pkg_list; do
gokhlayeh@241 1754 grep -q ^$PACKAGE$'\t' $dep_db && continue
gokhlayeh@241 1755 [ -d "$WOK/$p" ] || continue
gokhlayeh@241 1756 check_for_missing
gokhlayeh@241 1757 done
gokhlayeh@241 1758 append_to_dep()
gokhlayeh@241 1759 {
gokhlayeh@241 1760 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
gokhlayeh@241 1761 check_for_missing && echo $PACKAGE >> $tmp/dep
gokhlayeh@241 1762 else
gokhlayeh@241 1763 echo $PACKAGE >> $tmp/dep
gokhlayeh@241 1764 fi
gokhlayeh@241 1765 }
gokhlayeh@241 1766 else
gokhlayeh@241 1767 append_to_dep()
gokhlayeh@241 1768 {
gokhlayeh@241 1769 check_for_commit && echo $PACKAGE >> $tmp/dep
gokhlayeh@241 1770 }
gokhlayeh@241 1771 fi
gokhlayeh@204 1772 else
gokhlayeh@204 1773 append_to_dep()
gokhlayeh@204 1774 {
gokhlayeh@204 1775 echo $PACKAGE >> $tmp/dep
gokhlayeh@204 1776 }
gokhlayeh@240 1777 # If requested packages are not in dep_db, partial generation of this db is needed.
gokhlayeh@241 1778 for PACKAGE in $pkg_list; do
gokhlayeh@241 1779 grep -q ^$PACKAGE$'\t' $dep_db && continue
gokhlayeh@240 1780 [ -d "$WOK/$p" ] || continue
gokhlayeh@240 1781 plan_check_for_missing=yes
gokhlayeh@240 1782 check_for_missing
gokhlayeh@240 1783 done
gokhlayeh@240 1784 if [ "$plan_check_for_missing" ]; then
gokhlayeh@240 1785 append_to_dep()
gokhlayeh@240 1786 {
gokhlayeh@240 1787 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
gokhlayeh@240 1788 check_for_missing && echo $PACKAGE >> $tmp/dep
gokhlayeh@240 1789 else
gokhlayeh@240 1790 echo $PACKAGE >> $tmp/dep
gokhlayeh@240 1791 fi
gokhlayeh@240 1792 }
gokhlayeh@240 1793 check_db_status=yes
gokhlayeh@240 1794 unset plan_check_for_missing
gokhlayeh@240 1795 fi
gokhlayeh@186 1796 fi
gokhlayeh@215 1797
gokhlayeh@204 1798 [ "$with_dev" ] && filter=with_dev
gokhlayeh@204 1799 [ "$with_wanted" ] && filter=with_wanted
gokhlayeh@204 1800 if [ "$filter" ]; then
gokhlayeh@291 1801 pkg_list=$(echo $pkg_list | $filter | sort -u)
gokhlayeh@204 1802 scan_pkg()
gokhlayeh@204 1803 {
gokhlayeh@204 1804 look_for_$look_for | $filter
gokhlayeh@204 1805 }
gokhlayeh@204 1806 else
gokhlayeh@204 1807 scan_pkg()
gokhlayeh@204 1808 {
gokhlayeh@204 1809 look_for_$look_for
gokhlayeh@204 1810 }
gokhlayeh@204 1811 fi
gokhlayeh@215 1812 touch $tmp/dep
gokhlayeh@204 1813 for PACKAGE in $pkg_list; do
gokhlayeh@204 1814 [ "$with_args" ] && append_to_dep
gokhlayeh@204 1815 scan_pkg
gokhlayeh@186 1816 done | tr ' ' '\n' | sort -u > $tmp/list
gokhlayeh@186 1817 [ "$look_for" = bdep ] && look_for=dep
gokhlayeh@186 1818 while [ -s $tmp/list ]; do
gokhlayeh@186 1819 PACKAGE=$(sed 1!d $tmp/list)
gokhlayeh@186 1820 sed 1d -i $tmp/list
gokhlayeh@204 1821 append_to_dep
gokhlayeh@204 1822 for pkg in $(scan_pkg); do
gokhlayeh@204 1823 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
gokhlayeh@204 1824 echo $pkg >> $tmp/list
gokhlayeh@186 1825 fi
gokhlayeh@186 1826 done
gokhlayeh@186 1827 done
gokhlayeh@204 1828 if [ "$cooklist" ]; then
gokhlayeh@204 1829 mv $tmp/dep $tmp/cooklist
gokhlayeh@215 1830 else
gokhlayeh@204 1831 cat $tmp/dep | sort -u
gokhlayeh@186 1832 fi
gokhlayeh@204 1833 rm -f $tmp/dep $tmp/list
gokhlayeh@240 1834 if [ "$check_db_status" ]; then
gokhlayeh@240 1835 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@240 1836 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
gokhlayeh@352 1837 if [ "$plan_regen_cookorder" ] && \
gokhlayeh@397 1838 [ "$(sed 1!d $cookorder)" != "#PlanSort" ]; then
gokhlayeh@397 1839 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
gokhlayeh@240 1840 fi
gokhlayeh@240 1841 fi
gokhlayeh@186 1842 }
gokhlayeh@186 1843
gokhlayeh@186 1844 ########################################################################
gokhlayeh@186 1845 # This section contains functions to check package repository and
gokhlayeh@186 1846 # find which packages to cook.
gokhlayeh@186 1847 ########################
gokhlayeh@186 1848
gokhlayeh@240 1849 check_for_missing()
gokhlayeh@240 1850 {
slaxemulator@326 1851 local PACKAGE=$PACKAGE
gokhlayeh@240 1852 if ! check_for_pkg_in_wok; then
gokhlayeh@240 1853 [ "$?" = 2 ] && return 1
gokhlayeh@240 1854 return
gokhlayeh@240 1855 fi
gokhlayeh@241 1856 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@240 1857 source_receipt
gokhlayeh@240 1858 PACKAGE=${WANTED:-$PACKAGE}
gokhlayeh@240 1859 update_wan_db
gokhlayeh@240 1860 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@240 1861 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@240 1862 source_receipt
gokhlayeh@240 1863 update_dep_db
gokhlayeh@240 1864 done
gokhlayeh@240 1865 }
gokhlayeh@240 1866
gokhlayeh@186 1867 check_for_commit()
gokhlayeh@186 1868 {
gokhlayeh@204 1869 if ! check_for_pkg_in_wok; then
gokhlayeh@204 1870 [ "$?" = 2 ] && return 1
gokhlayeh@204 1871 return
gokhlayeh@204 1872 fi
gokhlayeh@204 1873 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@204 1874 RECEIPT=$WOK/$PACKAGE/receipt
gokhlayeh@186 1875 source_receipt
gokhlayeh@204 1876
gokhlayeh@186 1877 # We use md5 of cooking stuff in the packaged receipt to check
gokhlayeh@186 1878 # commit. We look consecutively in 3 different locations :
gokhlayeh@204 1879 # - in the wok/PACKAGE/taz/* folder
gokhlayeh@186 1880 # - in the receipt in the package in incoming repository
gokhlayeh@186 1881 # - in the receipt in the package in packages repository
gokhlayeh@186 1882 # If md5sum match, there's no commit.
gokhlayeh@186 1883 check_for_commit_using_md5sum()
gokhlayeh@186 1884 {
gokhlayeh@186 1885 if [ ! -f $WOK/$PACKAGE/md5 ]; then
gokhlayeh@186 1886 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
gokhlayeh@186 1887 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
gokhlayeh@186 1888 cd $WOK/$PACKAGE
gokhlayeh@186 1889 fi
gokhlayeh@204 1890
gokhlayeh@186 1891 if [ -s md5 ]; then
gokhlayeh@186 1892 if md5sum -cs md5; then
gokhlayeh@204 1893
gokhlayeh@204 1894 # If md5sum check if ok, check for new/missing files in
gokhlayeh@204 1895 # cooking stuff.
gokhlayeh@204 1896 for file in $([ -f receipt ] && echo receipt; \
gokhlayeh@204 1897 [ -f description.txt ] && echo description.txt; \
gokhlayeh@204 1898 [ -d stuff ] && find stuff); do
gokhlayeh@204 1899 if ! fgrep -q " $file" md5; then
gokhlayeh@186 1900 set_commited
gokhlayeh@186 1901 fi
gokhlayeh@186 1902 done
gokhlayeh@186 1903 else
gokhlayeh@186 1904 set_commited
gokhlayeh@186 1905 fi
gokhlayeh@186 1906 else
gokhlayeh@204 1907 set_commited
gokhlayeh@186 1908 fi
gokhlayeh@186 1909 }
gokhlayeh@186 1910 set_commited()
gokhlayeh@186 1911 {
gokhlayeh@204 1912 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
gokhlayeh@204 1913 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
gokhlayeh@186 1914 gen_cookmd5
gokhlayeh@204 1915 update_dep_db
gokhlayeh@186 1916 }
gokhlayeh@195 1917 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
gokhlayeh@186 1918 if [ -f $WOK/$PACKAGE/md5 ]; then
gokhlayeh@186 1919 cd $WOK/$PACKAGE
gokhlayeh@186 1920 check_for_commit_using_md5sum
gokhlayeh@186 1921 elif [ "$taz_dir" ]; then
gokhlayeh@186 1922 cd $taz_dir
gokhlayeh@186 1923 check_for_commit_using_md5sum
gokhlayeh@186 1924 else
gokhlayeh@195 1925 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
gokhlayeh@195 1926 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
gokhlayeh@186 1927 if [ "$pkg" ]; then
gokhlayeh@186 1928 get_pkg_files $pkg
gokhlayeh@186 1929 check_for_commit_using_md5sum
gokhlayeh@186 1930 rm -r $pkg_files_dir
gokhlayeh@204 1931 else
gokhlayeh@204 1932 set_commited
gokhlayeh@186 1933 fi
gokhlayeh@186 1934 fi
gokhlayeh@204 1935 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
gokhlayeh@186 1936 done
gokhlayeh@204 1937 return
gokhlayeh@186 1938 }
gokhlayeh@186 1939
gokhlayeh@186 1940 gen_cook_list()
gokhlayeh@186 1941 {
gokhlayeh@204 1942 report step "Scanning wok"
gokhlayeh@204 1943 if [ "$pkg" ]; then
gokhlayeh@204 1944 scan $pkg --cooklist
gokhlayeh@204 1945 else
gokhlayeh@204 1946 scan `cat $cooklist` --cooklist
gokhlayeh@204 1947 fi
gokhlayeh@204 1948 report end-step
gokhlayeh@209 1949
gokhlayeh@209 1950 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
gokhlayeh@209 1951
gokhlayeh@209 1952 # Core toolchain should not be cooked unless cook-toolchain is used.
gokhlayeh@209 1953 if ! [ -f /etc/config.site.tmptoolchain ] ; then
gokhlayeh@209 1954 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
gokhlayeh@209 1955 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
gokhlayeh@209 1956 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
gokhlayeh@209 1957 done
gokhlayeh@209 1958 fi
gokhlayeh@313 1959
gokhlayeh@241 1960 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
gokhlayeh@186 1961 cd $PACKAGES_REPOSITORY
gokhlayeh@186 1962 for PACKAGE in $(cat commit); do
gokhlayeh@186 1963 WANTED="$(look_for_wanted)"
gokhlayeh@186 1964 if [ "$WANTED" ]; then
gokhlayeh@204 1965 grep -q ^$WANTED$ broken cooklist blocked commit && continue
gokhlayeh@186 1966 fi
gokhlayeh@204 1967 grep -q ^$PACKAGE$ blocked cooklist && continue
gokhlayeh@204 1968 echo $PACKAGE >> cooklist
gokhlayeh@186 1969 done
gokhlayeh@186 1970 fi
gokhlayeh@186 1971 sort_cooklist
gokhlayeh@186 1972 }
gokhlayeh@186 1973
gokhlayeh@186 1974 sort_cooklist()
gokhlayeh@186 1975 {
gokhlayeh@397 1976 if [ "$(sed 1!d $cookorder)" = "#PlanSort" ]; then
gokhlayeh@397 1977 sed 1d -i $cookorder
gokhlayeh@266 1978 plan_regen_cookorder=yes
gokhlayeh@266 1979 fi
gokhlayeh@266 1980 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@266 1981 [ "$plan_regen_cookorder" ] && sort_db
gokhlayeh@313 1982 report step "Generating cooklist"
gokhlayeh@204 1983 if [ -f "$tmp/checked" ]; then
gokhlayeh@204 1984 rm -f $tmp/cooklist
gokhlayeh@204 1985 cat $tmp/checked | while read PACKAGE; do
gokhlayeh@204 1986 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
gokhlayeh@204 1987 echo $PACKAGE >> $tmp/cooklist
gokhlayeh@204 1988 done
gokhlayeh@209 1989 elif ! [ "$COMMAND" = gen-cooklist ]; then
gokhlayeh@209 1990 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
gokhlayeh@209 1991 sed "/^$PACKAGE/d" -i $tmp/cooklist
gokhlayeh@209 1992 done
gokhlayeh@204 1993 fi
gokhlayeh@313 1994 report end-step
gokhlayeh@313 1995 [ -s $tmp/cooklist ] || return
gokhlayeh@215 1996
gokhlayeh@313 1997 report step "Sorting cooklist"
gokhlayeh@204 1998 for PACKAGE in $(cat $tmp/cooklist); do
gokhlayeh@204 1999 WANTED="$(look_for_wanted)"
gokhlayeh@204 2000 [ "$WANTED" ] || continue
gokhlayeh@297 2001 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
gokhlayeh@186 2002 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 2003 elif [ ! -d $WOK/$WANTED/install ]; then
gokhlayeh@204 2004 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 2005 echo $WANTED >> $tmp/cooklist
gokhlayeh@186 2006 fi
gokhlayeh@186 2007 done
gokhlayeh@186 2008
gokhlayeh@204 2009 # Use cookorder.txt to sort cooklist.
gokhlayeh@204 2010 if [ -s $tmp/cooklist ]; then
gokhlayeh@397 2011 cat $cookorder | while read PACKAGE; do
gokhlayeh@204 2012 if grep -q ^$PACKAGE$ $tmp/cooklist; then
gokhlayeh@204 2013 sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@204 2014 echo $PACKAGE >> $tmp/cooklist.tmp
gokhlayeh@204 2015 fi
gokhlayeh@204 2016 done
gokhlayeh@204 2017
gokhlayeh@204 2018 # Remaining packages in cooklist are thoses without compile_rules.
gokhlayeh@204 2019 # They can be cooked first in any order.
gokhlayeh@204 2020 if [ -f $tmp/cooklist.tmp ]; then
gokhlayeh@204 2021 cat $tmp/cooklist.tmp >> $tmp/cooklist
gokhlayeh@204 2022 rm $tmp/cooklist.tmp
gokhlayeh@204 2023 fi
gokhlayeh@204 2024
gokhlayeh@204 2025 cat $tmp/cooklist
gokhlayeh@204 2026 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
gokhlayeh@204 2027 cat $tmp/cooklist > $cooklist
gokhlayeh@204 2028 fi
gokhlayeh@204 2029
gokhlayeh@186 2030 report end-step
gokhlayeh@186 2031 }
gokhlayeh@186 2032
gokhlayeh@284 2033 look_for_missing_pkg()
gokhlayeh@284 2034 {
gokhlayeh@284 2035 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
gokhlayeh@284 2036 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
gokhlayeh@284 2037 $PACKAGES_REPOSITORY/packages.txt || \
gokhlayeh@284 2038 continue
gokhlayeh@284 2039 echo $pkg
gokhlayeh@284 2040 done
gokhlayeh@284 2041 }
gokhlayeh@284 2042
gokhlayeh@186 2043 check_for_incoming()
gokhlayeh@186 2044 {
gokhlayeh@307 2045 report step "Check that all packages were cooked fine"
gokhlayeh@204 2046 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
gokhlayeh@204 2047 echo "No packages in $INCOMING_REPOSITORY."
gokhlayeh@307 2048 report end-step; return; }
gokhlayeh@204 2049 if [ -s $PACKAGES_REPOSITORY/broken ]; then
gokhlayeh@290 2050 missingpkg=$(look_for_missing_pkg broken)
gokhlayeh@290 2051 if [ "$missingpkg" ]; then
gokhlayeh@290 2052 echo "Don't move incoming packages to main repository because theses ones are broken:" >&2
gokhlayeh@290 2053 echo "$missingpkg"
gokhlayeh@307 2054 report end-step
gokhlayeh@307 2055 return 1
gokhlayeh@290 2056 fi
gokhlayeh@186 2057 fi
gokhlayeh@204 2058 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
gokhlayeh@290 2059 missingpkg=$(look_for_missing_pkg cooklist)
gokhlayeh@290 2060 if [ "$missingpkg" ]; then
gokhlayeh@290 2061 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
gokhlayeh@290 2062 echo "$missingpkg"
gokhlayeh@307 2063 report end-step
gokhlayeh@307 2064 return 1
gokhlayeh@290 2065 fi
gokhlayeh@204 2066 fi
gokhlayeh@306 2067 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
gokhlayeh@214 2068 if ! [ "$forced" ]; then
gokhlayeh@214 2069 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@313 2070 pkg="$incoming_pkgs"
gokhlayeh@214 2071 gen_cook_list
gokhlayeh@214 2072 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
gokhlayeh@290 2073 missingpkg=$(look_for_missing_pkg cooklist)
gokhlayeh@290 2074 if [ "$missingpkg" ]; then
gokhlayeh@290 2075 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
gokhlayeh@290 2076 echo "$missingpkg"
gokhlayeh@307 2077 report end-step
gokhlayeh@307 2078 return 1
gokhlayeh@290 2079 fi
gokhlayeh@214 2080 fi
gokhlayeh@204 2081 fi
gokhlayeh@313 2082
gokhlayeh@204 2083 report step "Moving incoming packages to main repository"
gokhlayeh@401 2084 mkdir -p $PACKAGES_REPOSITORY/wok
gokhlayeh@204 2085 unset EXTRAVERSION
gokhlayeh@306 2086 for PACKAGE in $incoming_pkgs; do
gokhlayeh@186 2087 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
gokhlayeh@204 2088 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
gokhlayeh@186 2089 remove_previous_package $PACKAGES_REPOSITORY
gokhlayeh@204 2090 echo "Moving $PACKAGE..."
gokhlayeh@204 2091 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
gokhlayeh@204 2092 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
gokhlayeh@266 2093 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
gokhlayeh@266 2094 sed -e "/^$PACKAGE:main/d" \
slaxemulator@275 2095 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
gokhlayeh@266 2096 -i $SOURCES_REPOSITORY/sources.list
gokhlayeh@266 2097 if [ "$previous_tarball" ]; then
gokhlayeh@266 2098 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
gokhlayeh@266 2099 rm -f $SOURCES_REPOSITORY/$previous_tarball
gokhlayeh@266 2100 fi
gokhlayeh@401 2101 rm -rf $PACKAGES_REPOSITORY/wok/$PACKAGE
gokhlayeh@401 2102 mkdir -p $PACKAGES_REPOSITORY/wok/$PACKAGE
gokhlayeh@401 2103 for i in $WOK/$PACKAGE/receipt $WOK/$PACKAGE/description.txt \
gokhlayeh@401 2104 $WOK/$PACKAGE/stuff; do
gokhlayeh@401 2105 cp -a $i $PACKAGES_REPOSITORY/wok/$PACKAGE
gokhlayeh@401 2106 done
gokhlayeh@204 2107 done
gokhlayeh@401 2108
gokhlayeh@401 2109 if [ "$GEN_SAFE_WOK_TARBALL" ]; then
gokhlayeh@401 2110 rm -rf $PACKAGES_REPOSITORY/wok.tar.lzma
gokhlayeh@401 2111 cd $PACKAGES_REPOSITORY/wok
gokhlayeh@401 2112 report step "Generating safe-wok tarball"
gokhlayeh@401 2113 tar -c * | lzma e $PACKAGES_REPOSITORY/wok.tar.lzma
gokhlayeh@401 2114 report end-step
gokhlayeh@401 2115 fi
gokhlayeh@401 2116
gokhlayeh@204 2117 for file in packages.list packages.equiv packages.md5 packages.desc \
gokhlayeh@204 2118 packages.txt; do
gokhlayeh@204 2119 echo -n "" > $INCOMING_REPOSITORY/$file
gokhlayeh@204 2120 done
gokhlayeh@204 2121 rm -r $INCOMING_REPOSITORY/files.list.lzma
gokhlayeh@186 2122 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
gokhlayeh@313 2123
gokhlayeh@313 2124 report step "Updating flavors"
gokhlayeh@313 2125 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
gokhlayeh@313 2126 if ! [ -x /usr/bin/tazlito ]; then
gokhlayeh@313 2127 tazpkg get-install tazlito
gokhlayeh@313 2128 fi
gokhlayeh@313 2129
gokhlayeh@313 2130 # Handle cases where tazwok is used into main system;
gokhlayeh@313 2131 # Handle cases where SLITAZ_DIR is not /home/slitaz.
gokhlayeh@313 2132 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
gokhlayeh@313 2133 mkdir -p /home/slitaz
gokhlayeh@313 2134 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
gokhlayeh@313 2135
gokhlayeh@313 2136 cd $LOCAL_REPOSITORY/packages
gokhlayeh@313 2137 for i in $LOCAL_REPOSITORY/flavors/*; do
gokhlayeh@331 2138 [ -d "$i" ] || continue
gokhlayeh@313 2139 tazlito pack-flavor ${i##*/}
gokhlayeh@313 2140 done
gokhlayeh@313 2141
gokhlayeh@313 2142 noheader=""
gokhlayeh@313 2143 for i in *.flavor; do
gokhlayeh@313 2144 tazlito show-flavor $i --brief $noheader
gokhlayeh@313 2145 noheader="--noheader"
gokhlayeh@313 2146 done > flavors.list
gokhlayeh@313 2147 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@313 2148 else
gokhlayeh@313 2149 echo "Can't create up-to-date flavors because tazlito package is missing." >&2
gokhlayeh@313 2150 fi
gokhlayeh@313 2151 report end-step
gokhlayeh@186 2152 }
gokhlayeh@186 2153
gokhlayeh@186 2154 ########################################################################
gokhlayeh@186 2155 # TAZWOK MAIN FUNCTIONS
gokhlayeh@186 2156 ########################
gokhlayeh@186 2157
gokhlayeh@186 2158 clean()
gokhlayeh@186 2159 {
gokhlayeh@186 2160 cd $WOK/$PACKAGE
gokhlayeh@186 2161 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
gokhlayeh@186 2162 -e ^stuff$ || return
gokhlayeh@186 2163
gokhlayeh@249 2164 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
gokhlayeh@186 2165 # Check for clean_wok function.
gokhlayeh@186 2166 if grep -q ^clean_wok $RECEIPT; then
gokhlayeh@186 2167 clean_wok
gokhlayeh@186 2168 fi
gokhlayeh@186 2169 # Clean should only have a receipt, stuff and optional desc.
gokhlayeh@186 2170 for f in `ls .`
gokhlayeh@186 2171 do
gokhlayeh@186 2172 case $f in
gokhlayeh@250 2173 receipt|stuff|description.txt|md5)
gokhlayeh@186 2174 continue ;;
gokhlayeh@186 2175 *)
gokhlayeh@263 2176 rm -rf $f ;;
gokhlayeh@186 2177 esac
gokhlayeh@186 2178 done
gokhlayeh@262 2179 [ "$COMMAND" != clean-wok ] && report end-step
gokhlayeh@186 2180 }
gokhlayeh@186 2181
gokhlayeh@186 2182 # Configure and make a package with the receipt.
gokhlayeh@186 2183 compile_package()
gokhlayeh@186 2184 {
gokhlayeh@186 2185 check_for_package_on_cmdline
gokhlayeh@186 2186
gokhlayeh@186 2187 # Include the receipt to get all needed variables and functions
gokhlayeh@186 2188 # and cd into the work directory to start the work.
gokhlayeh@186 2189 check_for_receipt
gokhlayeh@186 2190 source_receipt
gokhlayeh@186 2191
gokhlayeh@186 2192 # Log the package name and date.
gokhlayeh@186 2193 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
gokhlayeh@186 2194 echo "package $PACKAGE (compile)" >> $LOG
gokhlayeh@186 2195
gokhlayeh@186 2196 # Set wanted $src variable to help compiling.
gokhlayeh@186 2197 [ ! "$src" ] && set_src_path
gokhlayeh@186 2198 check_for_build_depends || return 1
gokhlayeh@186 2199 check_for_wanted
gokhlayeh@186 2200 unset target
gokhlayeh@186 2201 check_for_tarball && check_for_compile_rules
gokhlayeh@186 2202 }
gokhlayeh@186 2203
gokhlayeh@186 2204 # Cook command also include all features to manage lists which keep
gokhlayeh@186 2205 # track of wok/packages state.
gokhlayeh@186 2206 cook()
gokhlayeh@186 2207 {
gokhlayeh@186 2208 cook_code=
gokhlayeh@186 2209 set_common_path
gokhlayeh@186 2210 check_for_receipt
gokhlayeh@186 2211 source_receipt
gokhlayeh@186 2212
gokhlayeh@186 2213 # Define log path and start report.
gokhlayeh@186 2214 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
gokhlayeh@186 2215 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
pascal@349 2216 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
gokhlayeh@186 2217 report step "Cooking $PACKAGE"
gokhlayeh@186 2218 report open-bloc
gokhlayeh@186 2219
gokhlayeh@186 2220 clean $PACKAGE
gokhlayeh@186 2221 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
gokhlayeh@381 2222
gokhlayeh@186 2223 if compile_package; then
gokhlayeh@215 2224 remove_src
gokhlayeh@186 2225 refresh_packages_from_compile
gokhlayeh@186 2226 gen_package
gokhlayeh@186 2227
gokhlayeh@186 2228 # Update packages-incoming repository.
gokhlayeh@186 2229 store_pkgname=$PACKAGE
gokhlayeh@186 2230 pkg_repository=$INCOMING_REPOSITORY
gokhlayeh@186 2231 update_packages_db
gokhlayeh@186 2232
gokhlayeh@186 2233 PACKAGE=$store_pkgname
gokhlayeh@186 2234 unset store_pkgname
gokhlayeh@186 2235
gokhlayeh@186 2236 # Upgrade to cooked packages if it was previously installed.
gokhlayeh@186 2237 report step "Look for package(s) to upgrade"
gokhlayeh@186 2238 for pkg in $(look_for_rwanted) $PACKAGE; do
gokhlayeh@186 2239 if [ -d $INSTALLED/$pkg ]; then
gokhlayeh@186 2240 tazpkg get-install $pkg --forced
gokhlayeh@186 2241 fi
gokhlayeh@186 2242 done
gokhlayeh@186 2243 report end-step
gokhlayeh@186 2244 else
gokhlayeh@381 2245 set_pkg_broken
gokhlayeh@186 2246 cook_code=1
gokhlayeh@186 2247 fi
gokhlayeh@186 2248
gokhlayeh@186 2249 # Remove build_depends in cook mode (if in cooklist, it's done when
gokhlayeh@186 2250 # checking build_depends of next package and we remove only unneeded
gokhlayeh@186 2251 # packages to keep chroot minimal and gain some time).
gokhlayeh@210 2252 if [ "$COMMAND" = cook ]; then
gokhlayeh@210 2253 remove_build_depends $MISSING_PACKAGE
gokhlayeh@210 2254 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@210 2255 fi
gokhlayeh@210 2256
gokhlayeh@186 2257 # Regen the cooklist if it was planned and command is not cook.
gokhlayeh@186 2258 [ "$regen_cooklist" ] && unset regen_cooklist && \
gokhlayeh@186 2259 [ "$COMMAND" != cook ] && sort_cooklist
gokhlayeh@186 2260
gokhlayeh@186 2261 # Some hacks to set the bloc & function status as failed if cook was
gokhlayeh@186 2262 # failed.
gokhlayeh@186 2263 report_return_code=$cook_code
gokhlayeh@186 2264 report close-bloc
gokhlayeh@186 2265 report end-sublog
pascal@351 2266 rm -f $LOCAL_REPOSITORY/log/package
gokhlayeh@186 2267 return $cook_code
gokhlayeh@186 2268 }
gokhlayeh@186 2269
gokhlayeh@186 2270 cook_list()
gokhlayeh@186 2271 {
gokhlayeh@204 2272 if [ -s $tmp/cooklist ]; then
gokhlayeh@204 2273 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@204 2274 # Note : options -main variables- are automatically keeped by
gokhlayeh@204 2275 # the sub-applications tazchroot/tazwok; as well as report data.
gokhlayeh@204 2276 cd $LOCAL_REPOSITORY
gokhlayeh@204 2277 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@204 2278 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
gokhlayeh@204 2279 return
gokhlayeh@204 2280 fi
gokhlayeh@204 2281 while [ -s $tmp/cooklist ]; do
gokhlayeh@204 2282 PACKAGE=$(sed 1!d $tmp/cooklist)
gokhlayeh@204 2283 cook
gokhlayeh@204 2284 done
gokhlayeh@204 2285 remove_build_depends $MISSING_PACKAGE $remove_later
gokhlayeh@210 2286 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@204 2287 else
gokhlayeh@186 2288 echo "Nothing to cook."
gokhlayeh@186 2289 return
gokhlayeh@186 2290 fi
gokhlayeh@186 2291 }
gokhlayeh@186 2292
gokhlayeh@186 2293 configure_tazchroot()
gokhlayeh@186 2294 {
gokhlayeh@190 2295 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
gokhlayeh@186 2296 # Tazchroot configuration file - created by tazwok.
gokhlayeh@186 2297
gokhlayeh@186 2298 # Default chroot path
gokhlayeh@186 2299 SLITAZ_DIR=$SLITAZ_DIR
gokhlayeh@186 2300 SLITAZ_VERSION=$SLITAZ_VERSION
gokhlayeh@186 2301 $( [ "$undigest" ] && echo "undigest=$undigest" )
gokhlayeh@186 2302 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
gokhlayeh@186 2303 chroot_dir=\$LOCAL_REPOSITORY/chroot
gokhlayeh@186 2304
gokhlayeh@186 2305 # Default scripts path (theses scripts are added in the
gokhlayeh@186 2306 # $chroot_dir/usr/bin and can be called with tazchroot script)
gokhlayeh@314 2307 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
gokhlayeh@186 2308
gokhlayeh@186 2309 # List of directories to mount.
gokhlayeh@318 2310 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
gokhlayeh@186 2311 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
gokhlayeh@186 2312
gokhlayeh@186 2313 create_chroot()
gokhlayeh@186 2314 {
gokhlayeh@186 2315 mkdir -p \$chroot_dir
gokhlayeh@186 2316 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
gokhlayeh@186 2317 tazpkg get-install \$pkg --root="\$chroot_dir"
gokhlayeh@186 2318 done
gokhlayeh@186 2319
gokhlayeh@186 2320 # Store list of installed packages needed by cleanchroot.
gokhlayeh@194 2321 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
gokhlayeh@186 2322
gokhlayeh@186 2323 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
gokhlayeh@186 2324 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
gokhlayeh@186 2325 -i \$chroot_dir/etc/slitaz/slitaz.conf
gokhlayeh@186 2326 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
gokhlayeh@186 2327 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
pascal@368 2328 # The build bot may run in a sandbox: link sandbox lockfile
pascal@368 2329 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
gokhlayeh@186 2330 }
gokhlayeh@186 2331
gokhlayeh@186 2332 mount_chroot()
gokhlayeh@186 2333 {
gokhlayeh@186 2334 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
gokhlayeh@194 2335 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
gokhlayeh@194 2336 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
gokhlayeh@194 2337 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
gokhlayeh@194 2338 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
gokhlayeh@194 2339 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
gokhlayeh@194 2340 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
gokhlayeh@186 2341 mount -t proc proc \$chroot_dir/proc
gokhlayeh@186 2342 mount -t sysfs sysfs \$chroot_dir/sys
gokhlayeh@186 2343 mount -t devpts devpts \$chroot_dir/dev/pts
gokhlayeh@186 2344 mount -t tmpfs shm \$chroot_dir/dev/shm
gokhlayeh@186 2345 for dir in \$list_dir; do
gokhlayeh@186 2346 mkdir -p \$dir \$chroot_dir\$dir
gokhlayeh@186 2347 mount \$dir \$chroot_dir\$dir
gokhlayeh@186 2348 done
gokhlayeh@186 2349 }
gokhlayeh@186 2350
gokhlayeh@186 2351 umount_chroot()
gokhlayeh@186 2352 {
gokhlayeh@186 2353 for dir in \$list_dir; do
gokhlayeh@186 2354 umount \$chroot_dir\$dir
gokhlayeh@186 2355 done
gokhlayeh@186 2356 umount \$chroot_dir/dev/shm
gokhlayeh@186 2357 umount \$chroot_dir/dev/pts
gokhlayeh@186 2358 umount \$chroot_dir/sys
gokhlayeh@186 2359 umount \$chroot_dir/proc
gokhlayeh@186 2360 }
gokhlayeh@186 2361 EOF
gokhlayeh@186 2362 }
gokhlayeh@186 2363
gokhlayeh@186 2364 ########################################################################
gokhlayeh@186 2365 ######################### END OF NEW FUNCTIONS #########################
gokhlayeh@186 2366 ########################################################################
gokhlayeh@186 2367
pascal@111 2368 # List packages providing a virtual package
pascal@111 2369 whoprovide()
pascal@111 2370 {
pascal@111 2371 local i;
gokhlayeh@195 2372 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
pascal@111 2373 . $i
pascal@111 2374 case " $PROVIDE " in
pascal@111 2375 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
pascal@111 2376 esac
pascal@111 2377 done
pascal@111 2378 }
pascal@111 2379
gokhlayeh@186 2380 ########################################################################
gokhlayeh@186 2381 # TAZWOK COMMANDS
gokhlayeh@186 2382 ########################
pankso@7 2383
pankso@7 2384 case "$COMMAND" in
pankso@7 2385 stats)
paul@166 2386 # Tazwok general statistics from the wok config file.
pankso@7 2387 #
gokhlayeh@186 2388 get_tazwok_config
gokhlayeh@186 2389 echo -e "\n\033[1mTazwok configuration statistics\033[0m
pankso@7 2390 ================================================================================
pankso@7 2391 Wok directory : $WOK
pankso@7 2392 Packages repository : $PACKAGES_REPOSITORY
gokhlayeh@186 2393 Incoming repository : $INCOMING_REPOSITORY
pankso@7 2394 Sources repository : $SOURCES_REPOSITORY
gokhlayeh@186 2395 Log directory : $LOCAL_REPOSITORY/log
pankso@7 2396 Packages in the wok : `ls -1 $WOK | wc -l`
pankso@16 2397 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
gokhlayeh@186 2398 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
gokhlayeh@186 2399 ================================================================================\n"
gokhlayeh@186 2400 ;;
pankso@133 2401 edit)
gokhlayeh@186 2402 get_tazwok_config
pankso@133 2403 check_for_package_on_cmdline
pankso@133 2404 check_for_receipt
gokhlayeh@186 2405 $EDITOR $WOK/$PACKAGE/receipt
gokhlayeh@186 2406 ;;
pascal@98 2407 build-depends)
gokhlayeh@186 2408 # List dependencies to rebuild wok, or only a package
gokhlayeh@186 2409 get_tazwok_config
gokhlayeh@215 2410 report(){ : ; }
gokhlayeh@242 2411 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
gokhlayeh@186 2412 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
gokhlayeh@186 2413 --look_for=dep --with_dev --with_args
gokhlayeh@186 2414 else
gokhlayeh@186 2415 check_for_package_on_cmdline
gokhlayeh@186 2416 scan $PACKAGE --look_for=bdep --with_dev
gokhlayeh@186 2417 fi
gokhlayeh@186 2418 ;;
gokhlayeh@186 2419 gen-cooklist)
gokhlayeh@215 2420 check_root
gokhlayeh@204 2421 get_options_list="pkg"
gokhlayeh@186 2422 get_tazwok_config
gokhlayeh@215 2423 report(){ : ; }
gokhlayeh@204 2424 if ! [ "$pkg" ]; then
gokhlayeh@242 2425 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
gokhlayeh@242 2426 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
gokhlayeh@242 2427 else
gokhlayeh@242 2428 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
gokhlayeh@242 2429 fi
gokhlayeh@186 2430 fi
gokhlayeh@204 2431 gen_cook_list
gokhlayeh@186 2432 ;;
pascal@119 2433 check-depends)
gokhlayeh@186 2434 # Check package depends /!\
gokhlayeh@186 2435 get_tazwok_config
pascal@119 2436 echo ""
paul@121 2437 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
pascal@119 2438 ================================================================================"
pascal@119 2439 TMPDIR=/tmp/tazwok$$
pascal@119 2440 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
pascal@119 2441
pascal@119 2442 # Build ALL_DEPENDS variable
pascal@119 2443 scan_dep()
pascal@119 2444 {
pascal@119 2445 local i
pascal@119 2446 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
pascal@128 2447 for i in $DEPENDS $SUGGESTED ; do
pascal@119 2448 case " $ALL_DEPENDS " in
pascal@119 2449 *\ $i\ *) continue;;
pascal@119 2450 esac
pascal@120 2451 [ -d $WOK/$i ] || {
pascal@120 2452 ALL_DEPENDS="$ALL_DEPENDS$i "
pascal@120 2453 continue
pascal@120 2454 }
pascal@128 2455 DEPENDS=""
pascal@128 2456 SUGGESTED=""
pascal@119 2457 . $WOK/$i/receipt
pascal@119 2458 scan_dep
pascal@119 2459 done
pascal@119 2460 }
pankso@133 2461
pascal@119 2462 # Check for ELF file
pascal@119 2463 is_elf()
pascal@119 2464 {
slaxemulator@323 2465 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
pascal@119 2466 }
pascal@119 2467
pascal@119 2468 # Print shared library dependencies
pascal@119 2469 ldd()
pascal@119 2470 {
pascal@130 2471 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
pascal@119 2472 }
pascal@119 2473
pascal@119 2474 mkdir $TMPDIR
pascal@119 2475 cd $TMPDIR
pascal@140 2476 for i in $LOCALSTATE/files.list.lzma \
pascal@140 2477 $LOCALSTATE/undigest/*/files.list.lzma ; do
pascal@119 2478 [ -f $i ] && lzma d $i -so >> files.list
pascal@119 2479 done
pascal@119 2480 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
pascal@119 2481 tazpkg extract $pkg > /dev/null 2>&1
pascal@119 2482 . */receipt
pascal@119 2483 ALL_DEPENDS="$DEFAULT_DEPENDS "
pascal@119 2484 scan_dep
pascal@119 2485 find */fs -type f | while read file ; do
pascal@119 2486 is_elf $file || continue
pascal@119 2487 case "$file" in
pascal@119 2488 *.o|*.ko|*.ko.gz) continue;;
pascal@119 2489 esac
pascal@119 2490 ldd $file | while read lib rem; do
pascal@119 2491 case "$lib" in
pascal@128 2492 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
pascal@119 2493 continue;;
pascal@119 2494 esac
gokhlayeh@195 2495 for dep in $(fgrep $lib files.list | cut -d: -f1); do
pascal@119 2496 case " $ALL_DEPENDS " in
pascal@119 2497 *\ $dep\ *) continue 2;;
pascal@119 2498 esac
gokhlayeh@195 2499 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
pascal@128 2500 case " $ALL_DEPENDS " in
pascal@129 2501 *\ $vdep\ *) continue 3;;
pascal@128 2502 esac
pascal@128 2503 done
pascal@119 2504 done
pascal@128 2505 [ -n "$dep" ] || dep="UNKNOWN"
pascal@119 2506 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
pascal@119 2507 done
pascal@119 2508 done
pascal@119 2509 rm -rf */
pascal@119 2510 done
pascal@119 2511 cd /tmp
pascal@119 2512 rm -rf $TMPDIR
gokhlayeh@186 2513 ;;
pascal@76 2514 check)
paul@154 2515 # Check wok consistency
gokhlayeh@186 2516 get_tazwok_config
pascal@76 2517 echo ""
pascal@76 2518 echo -e "\033[1mWok and packages checking\033[0m
pascal@76 2519 ================================================================================"
pascal@77 2520 cd $WOK
pascal@77 2521 for pkg in $(ls)
pascal@76 2522 do
pascal@76 2523 [ -f $pkg/receipt ] || continue
gokhlayeh@186 2524 RECEIPT= $pkg/receipt
gokhlayeh@186 2525 source_receipt
gokhlayeh@186 2526 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
gokhlayeh@186 2527 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
gokhlayeh@186 2528 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
gokhlayeh@186 2529 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
gokhlayeh@186 2530 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
pascal@97 2531 if [ -n "$WANTED" ]; then
pascal@97 2532 if [ ! -f $WANTED/receipt ]; then
gokhlayeh@186 2533 echo "Package $PACKAGE wants unknown $WANTED package" >&2
pascal@97 2534 else
pascal@97 2535 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
pascal@103 2536 if [ "$VERSION" = "$WANTED" ]; then
pascal@103 2537 # BASEVERSION is computed in receipt
gokhlayeh@195 2538 fgrep -q '_pkg=' $pkg/receipt &&
pascal@103 2539 BASEVERSION=$VERSION
pascal@103 2540 fi
pascal@97 2541 if [ "$VERSION" != "$BASEVERSION" ]; then
gokhlayeh@186 2542 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
pascal@97 2543 fi
pascal@97 2544 fi
pascal@97 2545 fi
pascal@97 2546
pascal@94 2547 if [ -n "$CATEGORY" ]; then
pascal@94 2548 case " $(echo $CATEGORIES) " in
pascal@94 2549 *\ $CATEGORY\ *);;
gokhlayeh@186 2550 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
pascal@94 2551 esac
pascal@94 2552 else
gokhlayeh@186 2553 echo"Package $PACKAGE has no CATEGORY" >&2
pascal@94 2554 fi
gokhlayeh@186 2555 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
gokhlayeh@186 2556 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
pascal@122 2557 case "$WGET_URL" in
pascal@178 2558 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
gokhlayeh@186 2559 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
pascal@122 2560 '') ;;
gokhlayeh@186 2561 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
pascal@122 2562 esac
pascal@112 2563 case "$WEB_SITE" in
pascal@125 2564 ftp*|http*);;
gokhlayeh@186 2565 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
gokhlayeh@186 2566 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
pascal@112 2567 esac
pascal@78 2568 case "$MAINTAINER" in
gokhlayeh@186 2569 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
pascal@78 2570 esac
pascal@78 2571 case "$MAINTAINER" in
pascal@78 2572 *@*);;
gokhlayeh@186 2573 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
pascal@78 2574 esac
gokhlayeh@186 2575 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
pascal@76 2576 for i in $DEPENDS; do
pascal@76 2577 [ -d $i ] && continue
pascal@111 2578 [ -n "$(whoprovide $i)" ] && continue
pascal@76 2579 echo -e "$MSG $i"
pascal@76 2580 MSG=""
pascal@76 2581 done
gokhlayeh@186 2582 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
pascal@92 2583 for i in $BUILD_DEPENDS; do
pascal@92 2584 [ -d $i ] && continue
pascal@111 2585 [ -n "$(whoprovide $i)" ] && continue
pascal@92 2586 echo -e "$MSG $i"
pascal@92 2587 MSG=""
pascal@92 2588 done
pascal@76 2589 MSG="Dependencies loop between $PACKAGE and :\n"
pascal@76 2590 ALL_DEPS=""
pascal@76 2591 check_for_deps_loop $PACKAGE $DEPENDS
pascal@140 2592 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
pascal@141 2593 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
paul@154 2594 echo "$pkg should be rebuilt after $i installation"
pascal@140 2595 done
pascal@76 2596 done
gokhlayeh@186 2597 ;;
pankso@7 2598 list)
paul@166 2599 # List packages in wok directory. User can specify a category.
pankso@7 2600 #
gokhlayeh@186 2601 get_tazwok_config
pankso@7 2602 if [ "$2" = "category" ]; then
pankso@7 2603 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
pankso@7 2604 exit 0
pankso@7 2605 fi
pankso@7 2606 # Check for an asked category.
pankso@7 2607 if [ -n "$2" ]; then
pankso@7 2608 ASKED_CATEGORY=$2
pankso@7 2609 echo ""
pankso@7 2610 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
pankso@7 2611 echo "================================================================================"
pankso@7 2612 for pkg in $WOK/*
pankso@7 2613 do
erjo@168 2614 [ ! -f $pkg/receipt ] && continue
pankso@7 2615 . $pkg/receipt
pankso@7 2616 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
pankso@7 2617 echo -n "$PACKAGE"
pankso@28 2618 echo -e "\033[28G $VERSION"
pankso@7 2619 packages=$(($packages+1))
pankso@7 2620 fi
pankso@7 2621 done
pankso@7 2622 echo "================================================================================"
pankso@7 2623 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
pankso@7 2624 else
pankso@7 2625 # By default list all packages and version.
pankso@7 2626 echo ""
pankso@7 2627 echo -e "\033[1mList of packages in the wok\033[0m"
pankso@7 2628 echo "================================================================================"
pankso@7 2629 for pkg in $WOK/*
pankso@7 2630 do
erjo@168 2631 [ ! -f $pkg/receipt ] && continue
pankso@7 2632 . $pkg/receipt
pankso@7 2633 echo -n "$PACKAGE"
pankso@28 2634 echo -en "\033[28G $VERSION"
pankso@7 2635 echo -e "\033[42G $CATEGORY"
pankso@7 2636 packages=$(($packages+1))
pankso@7 2637 done
pankso@7 2638 echo "================================================================================"
MikeDSmith25@82 2639 echo -e "$packages packages available in the wok.\n"
pankso@7 2640 fi
pankso@7 2641 ;;
pankso@7 2642 info)
MikeDSmith25@82 2643 # Information about a package.
pankso@7 2644 #
gokhlayeh@186 2645 get_tazwok_config
pankso@7 2646 check_for_package_on_cmdline
pankso@7 2647 check_for_receipt
pankso@7 2648 . $WOK/$PACKAGE/receipt
pankso@7 2649 echo ""
MikeDSmith25@82 2650 echo -e "\033[1mTazwok package information\033[0m
pankso@7 2651 ================================================================================
pankso@7 2652 Package : $PACKAGE
pankso@7 2653 Version : $VERSION
pankso@7 2654 Category : $CATEGORY
pankso@7 2655 Short desc : $SHORT_DESC
pankso@7 2656 Maintainer : $MAINTAINER"
pankso@7 2657 if [ ! "$WEB_SITE" = "" ]; then
pankso@7 2658 echo "Web site : $WEB_SITE"
pankso@7 2659 fi
pankso@7 2660 if [ ! "$DEPENDS" = "" ]; then
pankso@7 2661 echo "Depends : $DEPENDS"
pankso@7 2662 fi
pankso@7 2663 if [ ! "$WANTED" = "" ]; then
pankso@7 2664 echo "Wanted src : $WANTED"
pankso@7 2665 fi
pankso@7 2666 echo "================================================================================"
pankso@7 2667 echo ""
gokhlayeh@186 2668 ;;
pankso@7 2669 check-log)
pankso@7 2670 # We just cat the file log to view process info.
pankso@7 2671 #
gokhlayeh@186 2672 get_tazwok_config
pankso@7 2673 if [ ! -f "$LOG" ]; then
gokhlayeh@186 2674 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
gokhlayeh@186 2675 exit 1
pankso@7 2676 else
pankso@7 2677 echo ""
pankso@7 2678 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
pankso@7 2679 echo "================================================================================"
pankso@7 2680 cat $LOG
pankso@7 2681 echo "================================================================================"
pankso@7 2682 echo ""
gokhlayeh@237 2683 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
gokhlayeh@237 2684 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
gokhlayeh@237 2685 echo "================================================================================"
gokhlayeh@237 2686 cat "$WOK/$PACKAGE/warning.txt"
gokhlayeh@237 2687 echo "================================================================================"
gokhlayeh@237 2688 echo ""
gokhlayeh@237 2689 fi
pankso@7 2690 fi
gokhlayeh@186 2691 ;;
pankso@7 2692 search)
pankso@7 2693 # Search for a package by pattern or name.
pankso@7 2694 #
gokhlayeh@186 2695 get_tazwok_config
pankso@7 2696 if [ -z "$2" ]; then
gokhlayeh@186 2697 echo -e "\nPlease specify a pattern or a package name to search." >&2
gokhlayeh@186 2698 echo -e "Example : 'tazwok search gcc'.\n" >&2
gokhlayeh@186 2699 exit 1
pankso@7 2700 fi
pankso@7 2701 echo ""
pankso@7 2702 echo -e "\033[1mSearch result for :\033[0m $2"
pankso@7 2703 echo "================================================================================"
gokhlayeh@195 2704 list=`ls -1 $WOK | fgrep $2`
pankso@7 2705 for pkg in $list
pankso@7 2706 do
pankso@7 2707 . $WOK/$pkg/receipt
pankso@7 2708 echo -n "$PACKAGE "
pankso@7 2709 echo -en "\033[24G $VERSION"
pankso@7 2710 echo -e "\033[42G $CATEGORY"
gokhlayeh@186 2711 packages=$(($PACKAGEs+1))
pankso@7 2712 done
pankso@7 2713 echo "================================================================================"
pankso@7 2714 echo "$packages packages found for : $2"
pankso@7 2715 echo ""
gokhlayeh@186 2716 ;;
pankso@7 2717 compile)
pankso@7 2718 # Configure and make a package with the receipt.
pankso@7 2719 #
gokhlayeh@186 2720 get_tazwok_config
gokhlayeh@186 2721 source_lib report
gokhlayeh@186 2722 report start
pankso@7 2723 compile_package
gokhlayeh@186 2724 ;;
pankso@7 2725 genpkg)
paul@121 2726 # Generate a package.
pankso@7 2727 #
gokhlayeh@186 2728 get_tazwok_config
gokhlayeh@186 2729 source_lib report
gokhlayeh@186 2730 report start
pankso@7 2731 gen_package
gokhlayeh@186 2732 ;;
pankso@7 2733 cook)
pankso@7 2734 # Compile and generate a package. Just execute tazwok with
pankso@7 2735 # the good commands.
pankso@7 2736 #
pankso@7 2737 check_root
gokhlayeh@186 2738 get_tazwok_config
gokhlayeh@186 2739 source_lib report
gokhlayeh@186 2740 report start
gokhlayeh@215 2741 update_wan_db
gokhlayeh@215 2742 check_for_commit
gokhlayeh@215 2743 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
gokhlayeh@215 2744 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
gokhlayeh@215 2745 if [ "$plan_regen_cookorder" ]; then
gokhlayeh@397 2746 [ "$(sed 1!d $cookorder)" = "#PlanSort" ] || \
gokhlayeh@397 2747 sed 1i"#PlanSort" -i $cookorder
gokhlayeh@215 2748 fi
gokhlayeh@186 2749 cook
gokhlayeh@186 2750 ;;
gokhlayeh@186 2751 sort-cooklist)
gokhlayeh@297 2752 if [ ! -f "$LIST" ]; then
gokhlayeh@297 2753 echo "Usage : tazwok sort-cooklist cooklist" >&2
gokhlayeh@186 2754 exit 1
gokhlayeh@186 2755 fi
gokhlayeh@297 2756 check_root
gokhlayeh@186 2757 get_tazwok_config
gokhlayeh@297 2758 report(){ : ; }
gokhlayeh@297 2759 # When using sort-cooklist, the script should behave as for gen-cooklist
gokhlayeh@297 2760 # The only difference between theses two is where the output is sended.
gokhlayeh@297 2761 COMMAND=gen-cooklist
gokhlayeh@186 2762 cooklist=$LIST
gokhlayeh@297 2763 gen_cook_list
gokhlayeh@300 2764 cp -af $tmp/cooklist $cooklist
gokhlayeh@186 2765 ;;
pankso@7 2766 cook-list)
gokhlayeh@204 2767 # Cook all packages listed in a file or in default cooklist.
gokhlayeh@186 2768 check_root
gokhlayeh@204 2769 get_options_list="pkg forced"
gokhlayeh@186 2770 get_tazwok_config
gokhlayeh@186 2771 source_lib report
gokhlayeh@186 2772 report start
gokhlayeh@204 2773 if ! [ "$pkg" ]; then
gokhlayeh@204 2774 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
gokhlayeh@186 2775 fi
gokhlayeh@204 2776 gen_cook_list
gokhlayeh@186 2777 cook_list
gokhlayeh@186 2778 ;;
gokhlayeh@186 2779 clean)
gokhlayeh@186 2780 # Clean up a package work directory + thoses which want it.
pankso@7 2781 #
gokhlayeh@186 2782 get_tazwok_config
pankso@7 2783 check_for_package_on_cmdline
pankso@7 2784 check_for_receipt
gokhlayeh@186 2785 source_lib report
gokhlayeh@186 2786 report start
pankso@7 2787 . $RECEIPT
gokhlayeh@186 2788 clean
gokhlayeh@186 2789 ;;
pankso@7 2790 gen-clean-wok)
paul@121 2791 # Generate a clean wok from the current wok by copying all receipts
pankso@7 2792 # and stuff directory.
pankso@7 2793 #
gokhlayeh@186 2794 get_tazwok_config
gokhlayeh@186 2795 source_lib report
gokhlayeh@186 2796 report start
gokhlayeh@186 2797 if [ -z "$ARG" ]; then
gokhlayeh@186 2798 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
gokhlayeh@186 2799 exit 1
pankso@7 2800 else
gokhlayeh@186 2801 dest=$ARG
pankso@7 2802 mkdir -p $dest
pankso@7 2803 fi
gokhlayeh@186 2804 report step "Creating clean wok in : $dest"
pankso@7 2805 for pkg in `ls -1 $WOK`
pankso@7 2806 do
pankso@7 2807 mkdir -p $dest/$pkg
pankso@7 2808 cp -a $WOK/$pkg/receipt $dest/$pkg
gokhlayeh@186 2809 [ -f $WOK/$pkg/description.txt ] && \
gokhlayeh@186 2810 cp -a $WOK/$pkg/description.txt $dest/$pkg
pankso@7 2811 if [ -d "$WOK/$pkg/stuff" ]; then
pankso@7 2812 cp -a $WOK/$pkg/stuff $dest/$pkg
pankso@7 2813 fi
pankso@7 2814 done
gokhlayeh@186 2815 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
gokhlayeh@186 2816 report end-step
pankso@7 2817 echo "Packages cleaned : `ls -1 $dest | wc -l`"
pankso@7 2818 echo ""
gokhlayeh@186 2819 ;;
pankso@7 2820 clean-wok)
pankso@7 2821 # Clean all packages in the work directory
pankso@7 2822 #
gokhlayeh@186 2823 get_tazwok_config
gokhlayeh@186 2824 source_lib report
gokhlayeh@186 2825 report start
gokhlayeh@186 2826 report step "Cleaning wok"
gokhlayeh@186 2827 for PACKAGE in `ls -1 $WOK`
pankso@7 2828 do
gokhlayeh@186 2829 set_common_path
gokhlayeh@186 2830 source_receipt
gokhlayeh@186 2831 clean
pankso@7 2832 done
pankso@7 2833 echo "`ls -1 $WOK | wc -l` packages cleaned."
gokhlayeh@186 2834 ;;
gokhlayeh@266 2835 clean-src)
gokhlayeh@266 2836 # Remove tarball unrelated to wok receipts from src repo.
gokhlayeh@266 2837 check_root
gokhlayeh@266 2838 get_options_list="forced"
gokhlayeh@266 2839 get_tazwok_config
gokhlayeh@266 2840 cd $SOURCES_REPOSITORY
gokhlayeh@266 2841 echo -n "Checking $SOURCES_REPOSITORY..."
gokhlayeh@266 2842 for TARBALL in *; do
gokhlayeh@266 2843 [ "$TARBALL" = sources.list ] && continue
gokhlayeh@266 2844 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
gokhlayeh@266 2845 echo $TARBALL >> $tmp/obsolete
gokhlayeh@266 2846 done
gokhlayeh@266 2847 status
slaxemulator@273 2848 if ! [ -f $tmp/obsolete ]; then
slaxemulator@273 2849 echo "No sources need to be removed."
slaxemulator@273 2850 exit 1
slaxemulator@273 2851 fi
gokhlayeh@266 2852 echo ""
gokhlayeh@266 2853 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
gokhlayeh@266 2854 horizontal_line
gokhlayeh@266 2855 cat $tmp/obsolete
gokhlayeh@266 2856 horizontal_line
gokhlayeh@266 2857 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
pankso@7 2858 echo ""
gokhlayeh@266 2859 echo -n "Please confirm removing (type uppercase YES): "
gokhlayeh@266 2860 read answer
gokhlayeh@266 2861 if [ "$answer" = YES ]; then
gokhlayeh@266 2862 echo -n "Removing old sources..."
gokhlayeh@266 2863 cat $tmp/obsolete | while read i; do
gokhlayeh@266 2864 rm -f $SOURCES_REPOSITORY/$i
gokhlayeh@266 2865 done
gokhlayeh@266 2866 status
gokhlayeh@266 2867 fi
gokhlayeh@266 2868 ;;
pankso@7 2869 gen-list)
gokhlayeh@186 2870 get_tazwok_config
gokhlayeh@204 2871 if [ "$2" ]; then
pankso@7 2872 if [ -d "$2" ]; then
gokhlayeh@204 2873 pkg_repository=$2
pankso@7 2874 else
gokhlayeh@204 2875 echo -e "\nUnable to find directory : $2\n" >&2
gokhlayeh@204 2876 exit 1
pankso@7 2877 fi
pankso@7 2878 fi
gokhlayeh@204 2879
gokhlayeh@186 2880 source_lib report
gokhlayeh@186 2881 report start
gokhlayeh@204 2882 if [ "$pkg_repository" ]; then
gokhlayeh@204 2883 gen_packages_db
gokhlayeh@204 2884 else
gokhlayeh@204 2885 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
gokhlayeh@204 2886 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
pankso@28 2887 fi
gokhlayeh@186 2888 ;;
gokhlayeh@186 2889 check-list)
gokhlayeh@186 2890 # The directory to move into by default is the repository,
gokhlayeh@186 2891 # if $2 is not empty cd into $2.
pascal@178 2892 #
gokhlayeh@186 2893 get_tazwok_config
gokhlayeh@204 2894 if [ "$2" ]; then
pascal@178 2895 if [ -d "$2" ]; then
gokhlayeh@204 2896 pkg_repository=$2
pascal@178 2897 else
gokhlayeh@186 2898 echo -e "\nUnable to find directory : $2\n" >&2
gokhlayeh@186 2899 exit 1
pascal@178 2900 fi
pascal@178 2901 fi
gokhlayeh@186 2902
gokhlayeh@186 2903 source_lib report
gokhlayeh@204 2904 report start
gokhlayeh@204 2905 if [ "$pkg_repository" ]; then
gokhlayeh@204 2906 update_packages_db
gokhlayeh@204 2907 else
gokhlayeh@204 2908 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
gokhlayeh@204 2909 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
gokhlayeh@204 2910 fi
gokhlayeh@186 2911 ;;
pankso@7 2912 new-tree)
MikeDSmith25@82 2913 # Just create a few directories and generate an empty receipt to prepare
pankso@7 2914 # the creation of a new package.
pankso@7 2915 #
gokhlayeh@186 2916 get_tazwok_config
pankso@7 2917 check_for_package_on_cmdline
slaxemulator@362 2918 clean_wok=$LOCAL_REPOSITORY/clean-wok
slaxemulator@362 2919 if [ -d $clean_wok/$PACKAGE ]; then
gokhlayeh@186 2920 echo -e "\n$PACKAGE package tree already exists.\n" >&2
gokhlayeh@186 2921 exit 1
pankso@7 2922 fi
pankso@7 2923 echo "Creating : $WOK/$PACKAGE"
slaxemulator@362 2924 mkdir $clean_wok/$PACKAGE
slaxemulator@362 2925 cd $clean_wok/$PACKAGE
pankso@7 2926 echo -n "Preparing the receipt..."
pankso@7 2927 #
pankso@7 2928 # Default receipt begin.
pankso@7 2929 #
pankso@7 2930 echo "# SliTaz package receipt." > receipt
pankso@7 2931 echo "" >> receipt
pankso@7 2932 echo "PACKAGE=\"$PACKAGE\"" >> receipt
pankso@7 2933 # Finish the empty receipt.
pankso@7 2934 cat >> receipt << "EOF"
pankso@7 2935 VERSION=""
pankso@7 2936 CATEGORY=""
pankso@7 2937 SHORT_DESC=""
pankso@7 2938 MAINTAINER=""
pankso@7 2939 DEPENDS=""
pankso@7 2940 TARBALL="$PACKAGE-$VERSION.tar.gz"
pankso@7 2941 WEB_SITE=""
pankso@7 2942 WGET_URL=""
pankso@7 2943
pankso@7 2944 # Rules to configure and make the package.
pankso@7 2945 compile_rules()
pankso@7 2946 {
pankso@7 2947 cd $src
gokhlayeh@204 2948 ./configure && make && make install
pankso@7 2949 }
pankso@7 2950
pankso@7 2951 # Rules to gen a SliTaz package suitable for Tazpkg.
pankso@7 2952 genpkg_rules()
pankso@7 2953 {
pankso@7 2954 mkdir -p $fs/usr
pankso@7 2955 cp -a $_pkg/usr/bin $fs/usr
pankso@7 2956 }
pankso@7 2957
pankso@7 2958 EOF
pankso@7 2959 #
pankso@7 2960 # Default receipt end.
pankso@7 2961 #
pankso@7 2962 status
pankso@7 2963 # Interactive mode, asking and seding.
pankso@7 2964 if [ "$3" = "--interactive" ]; then
paul@154 2965 echo "Entering into interactive mode..."
pankso@7 2966 echo "================================================================================"
pankso@7 2967 echo "Package : $PACKAGE"
pankso@7 2968 # Version.
pankso@7 2969 echo -n "Version : " ; read anser
pankso@7 2970 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
pankso@7 2971 # Category.
pankso@7 2972 echo -n "Category : " ; read anser
pankso@7 2973 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
pankso@7 2974 # Short description.
pankso@7 2975 echo -n "Short desc : " ; read anser
pankso@7 2976 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
pankso@7 2977 # Maintainer.
pankso@7 2978 echo -n "Maintainer : " ; read anser
pankso@7 2979 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
pankso@7 2980 # Web site.
pankso@7 2981 echo -n "Web site : " ; read anser
pankso@133 2982 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
pankso@7 2983 echo ""
pankso@7 2984 # Wget URL.
pankso@7 2985 echo "Wget URL to download source tarball."
pankso@7 2986 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
pankso@7 2987 echo -n "Wget url : " ; read anser
pankso@7 2988 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
pankso@7 2989 # Ask for a stuff dir.
pankso@7 2990 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
pankso@7 2991 if [ "$anser" = "y" ]; then
pankso@7 2992 echo -n "Creating the stuff directory..."
pankso@7 2993 mkdir stuff && status
pankso@7 2994 fi
pankso@7 2995 # Ask for a description file.
pankso@7 2996 echo -n "Are you going to write a description ? (y/N) : " ; read anser
pankso@7 2997 if [ "$anser" = "y" ]; then
pankso@7 2998 echo -n "Creating the description.txt file..."
pankso@7 2999 echo "" > description.txt && status
pankso@7 3000 fi
pankso@7 3001 echo "================================================================================"
pankso@7 3002 echo ""
pankso@7 3003 fi
gokhlayeh@186 3004 ;;
pankso@7 3005 remove)
pankso@7 3006 # Remove a package from the wok.
pankso@7 3007 #
gokhlayeh@186 3008 get_tazwok_config
pankso@7 3009 check_for_package_on_cmdline
pankso@7 3010 echo ""
pascal@83 3011 echo -n "Please confirm deletion (y/N) : "; read anser
pascal@83 3012 if [ "$anser" = "y" ]; then
pascal@83 3013 echo -n "Removing $PACKAGE..."
pascal@83 3014 rm -rf $WOK/$PACKAGE && status
pascal@83 3015 echo ""
pascal@83 3016 fi
gokhlayeh@186 3017 ;;
gokhlayeh@304 3018 update-wok)
paul@166 3019 # Pull and update a Hg wok.
gokhlayeh@304 3020 get_options_list="local"
gokhlayeh@186 3021 get_tazwok_config
gokhlayeh@309 3022 source_lib report
gokhlayeh@310 3023 report start
gokhlayeh@304 3024 clean_wok=$LOCAL_REPOSITORY/clean-wok
gokhlayeh@304 3025 cd $clean_wok
gokhlayeh@304 3026 if ! [ "$local" ]; then
gokhlayeh@304 3027 if [ "$WOK_UPDATE_METHOD" = hg ]; then
gokhlayeh@304 3028 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
gokhlayeh@304 3029
gokhlayeh@304 3030 # Auto-install only if we are in a cook chroot.
gokhlayeh@304 3031 if [ -x /usr/bin/clean-chroot ]; then
gokhlayeh@304 3032 echo "" >&2
slaxemulator@327 3033 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 3034 echo "">&2
gokhlayeh@330 3035 exit 1
gokhlayeh@304 3036 else
gokhlayeh@304 3037 tazpkg get-install mercurial
gokhlayeh@304 3038 fi
gokhlayeh@330 3039 fi
gokhlayeh@304 3040
gokhlayeh@330 3041 report step "Getting wok changes using hg"
gokhlayeh@330 3042 if [ -d .hg ]; then
gokhlayeh@330 3043 hg pull -u || exit 1
gokhlayeh@304 3044 else
gokhlayeh@330 3045 hg clone $HG_WOK . || exit 1
gokhlayeh@304 3046 fi
gokhlayeh@309 3047 report end-step
gokhlayeh@304 3048 [ -x /usr/bin/clean-chroot ] && clean-chroot
gokhlayeh@304 3049 else
gokhlayeh@309 3050 report step "Getting wok changes using tarball"
gokhlayeh@304 3051 { mkdir .tmp && cd .tmp
gokhlayeh@304 3052 wget "$TARBALL_WOK" &&
gokhlayeh@304 3053 case $TARBALL_WOK in
gokhlayeh@304 3054 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
gokhlayeh@304 3055 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
gokhlayeh@304 3056 *gz) tar xzf *.gz -C wok; rm*.gz ;;
gokhlayeh@304 3057 esac &&
gokhlayeh@304 3058 rm -r $(ls -d $clean_wok/*) &&
gokhlayeh@304 3059 cp -a wok/* $clean_wok &&
gokhlayeh@304 3060 cd .. &&
gokhlayeh@304 3061 rm -r .tmp
gokhlayeh@304 3062 } || { echo "That's not cool: it fails!" >&2
gokhlayeh@309 3063 report end-step
gokhlayeh@304 3064 exit 1; }
gokhlayeh@309 3065 report end-step
gokhlayeh@304 3066 fi
pankso@106 3067 fi
gokhlayeh@309 3068 report step "Appending changes to wok"
gokhlayeh@304 3069
gokhlayeh@308 3070 # Handle removed files/dir.
gokhlayeh@308 3071 cd $WOK
gokhlayeh@313 3072 for dir in *; do
slaxemulator@329 3073 [ -d "$clean_wok/$dir" ] || rm -rf $dir
gokhlayeh@308 3074 done
gokhlayeh@308 3075 for file in */receipt */description.txt; do
slaxemulator@329 3076 [ -f "$clean_wok/$file" ] || rm -rf $file
gokhlayeh@308 3077 done
gokhlayeh@330 3078 for i in $(find */stuff 2>/dev/null); do
slaxemulator@329 3079 [ -e "$clean_wok/$i" ] || rm -rf $i
gokhlayeh@304 3080 done
gokhlayeh@304 3081
gokhlayeh@308 3082 cp -a $clean_wok/* $WOK
gokhlayeh@309 3083 report end-step
gokhlayeh@186 3084 ;;
pankso@108 3085 maintainers)
gokhlayeh@186 3086 get_tazwok_config
pankso@108 3087 echo ""
pankso@108 3088 echo "List of maintainers for: $WOK"
pankso@108 3089 echo "================================================================================"
pankso@108 3090 touch /tmp/slitaz-maintainers
pankso@108 3091 for pkg in $WOK/*
pankso@108 3092 do
pankso@108 3093 . $pkg/receipt
gokhlayeh@195 3094 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
pankso@108 3095 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
pankso@108 3096 echo "$MAINTAINER"
pankso@108 3097 fi
pankso@108 3098 done
pankso@108 3099 echo "================================================================================"
pankso@108 3100 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
pankso@108 3101 echo ""
pankso@108 3102 # Remove tmp files
gokhlayeh@186 3103 rm -f /tmp/slitaz-maintainers
gokhlayeh@186 3104 ;;
pankso@107 3105 maintained-by)
paul@166 3106 # Search for packages maintained by a contributor.
gokhlayeh@186 3107 get_tazwok_config
pankso@107 3108 if [ ! -n "$2" ]; then
gokhlayeh@186 3109 echo "Specify a name or email of a maintainer." >&2
gokhlayeh@186 3110 exit 1
pankso@107 3111 fi
pankso@107 3112 echo "Maintainer packages"
pankso@107 3113 echo "================================================================================"
pankso@107 3114 for pkg in $WOK/*
pankso@107 3115 do
pankso@107 3116 . $pkg/receipt
gokhlayeh@195 3117 if echo "$MAINTAINER" | fgrep -q "$2"; then
pankso@107 3118 echo "$PACKAGE"
gokhlayeh@186 3119 packages=$(($PACKAGEs+1))
pankso@107 3120 fi
pankso@107 3121 done
pankso@107 3122 echo "================================================================================"
gokhlayeh@186 3123 echo "Packages maintained by $2: $PACKAGEs"
gokhlayeh@186 3124 echo ""
gokhlayeh@186 3125 ;;
gokhlayeh@268 3126 tags)
gokhlayeh@268 3127 get_tazwok_config
gokhlayeh@268 3128 echo -e "\n\033[1mTags list :\033[0m"
gokhlayeh@268 3129 horizontal_line
gokhlayeh@268 3130 cd $WOK
gokhlayeh@268 3131 for i in */receipt; do
gokhlayeh@268 3132 unset TAGS
gokhlayeh@268 3133 source $i
gokhlayeh@268 3134 for t in $TAGS; do
gokhlayeh@268 3135 grep -q ^$t$ $tmp/tags && continue
gokhlayeh@268 3136 echo $t | tee -a $tmp/tags
gokhlayeh@268 3137 done
gokhlayeh@268 3138 done
gokhlayeh@268 3139 horizontal_line
gokhlayeh@268 3140 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
gokhlayeh@268 3141 ;;
erjo@159 3142 check-src)
erjo@159 3143 # Verify if upstream package is still available
erjo@159 3144 #
gokhlayeh@186 3145 get_tazwok_config
erjo@159 3146 check_for_package_on_cmdline
erjo@159 3147 check_for_receipt
gokhlayeh@186 3148 source_receipt
erjo@159 3149 check_src()
erjo@159 3150 {
erjo@159 3151 for url in $@; do
pascal@178 3152 busybox wget -s $url 2>/dev/null && break
erjo@159 3153 done
erjo@159 3154 }
gokhlayeh@186 3155 if [ "$WGET_URL" ];then
erjo@159 3156 echo -n "$PACKAGE : "
erjo@159 3157 check_src $WGET_URL
erjo@159 3158 status
erjo@159 3159 else
erjo@159 3160 echo "No tarball to check for $PACKAGE"
erjo@159 3161 fi
gokhlayeh@186 3162 ;;
gokhlayeh@186 3163 get-src)
gokhlayeh@186 3164 check_root
gokhlayeh@225 3165 get_options_list="target nounpack"
gokhlayeh@186 3166 get_tazwok_config
gokhlayeh@186 3167 check_for_package_on_cmdline
gokhlayeh@186 3168 check_for_receipt
gokhlayeh@186 3169 source_receipt
gokhlayeh@186 3170 if [ "$WGET_URL" ];then
gokhlayeh@186 3171 source_lib report
gokhlayeh@186 3172 report start
gokhlayeh@225 3173 check_for_tarball
gokhlayeh@186 3174 else
gokhlayeh@186 3175 echo "No tarball to download for $PACKAGE"
gokhlayeh@186 3176 fi
gokhlayeh@186 3177 ;;
gokhlayeh@204 3178 check-commit)
gokhlayeh@186 3179 check_root
gokhlayeh@204 3180 get_options_list="missing forced"
gokhlayeh@186 3181 get_tazwok_config
gokhlayeh@186 3182 source_lib report
gokhlayeh@186 3183 report start
gokhlayeh@204 3184 if [ "$forced" ]; then
gokhlayeh@204 3185 rm -f $WOK/*/md5
gokhlayeh@204 3186 unset forced
gokhlayeh@204 3187 fi
gokhlayeh@204 3188 if [ "$missing" ]; then
gokhlayeh@204 3189 pkg=$(ls -1 $WOK)
gokhlayeh@204 3190 else
gokhlayeh@204 3191 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 3192 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 3193 } | sort -u)"
gokhlayeh@204 3194 fi
gokhlayeh@204 3195 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@186 3196 gen_cook_list
gokhlayeh@186 3197 ;;
gokhlayeh@186 3198 cook-commit)
gokhlayeh@186 3199 check_root
gokhlayeh@204 3200 get_options_list="missing forced"
gokhlayeh@186 3201 get_tazwok_config
gokhlayeh@186 3202 source_lib report
gokhlayeh@186 3203 report start
gokhlayeh@204 3204 if [ "$forced" ]; then
gokhlayeh@204 3205 rm -f $WOK/*/md5
gokhlayeh@204 3206 unset forced
gokhlayeh@204 3207 fi
gokhlayeh@204 3208 if [ "$missing" ]; then
gokhlayeh@204 3209 pkg=$(ls -1 $WOK)
gokhlayeh@204 3210 else
gokhlayeh@204 3211 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 3212 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 3213 } | sort -u)"
gokhlayeh@204 3214 fi
gokhlayeh@204 3215 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@186 3216 gen_cook_list
gokhlayeh@186 3217 cook_list
gokhlayeh@186 3218 ;;
gokhlayeh@186 3219 cook-all)
gokhlayeh@186 3220 check_root
gokhlayeh@204 3221 get_options_list="forced missing"
gokhlayeh@186 3222 get_tazwok_config
gokhlayeh@186 3223 source_lib report
gokhlayeh@186 3224 report start
gokhlayeh@204 3225 if [ "$missing" ]; then
gokhlayeh@204 3226 pkg=$(ls -1 $WOK)
gokhlayeh@204 3227 else
gokhlayeh@204 3228 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
gokhlayeh@204 3229 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
gokhlayeh@204 3230 } | sort -u)"
gokhlayeh@204 3231 fi
gokhlayeh@204 3232 cooklist=$PACKAGES_REPOSITORY/cooklist
gokhlayeh@204 3233 gen_cook_list
gokhlayeh@186 3234 cook_list
gokhlayeh@186 3235 ;;
gokhlayeh@186 3236 gen-wok-db)
gokhlayeh@186 3237 check_root
gokhlayeh@186 3238 get_tazwok_config
gokhlayeh@186 3239 source_lib report
gokhlayeh@186 3240 report start
gokhlayeh@204 3241 gen_wok_db
gokhlayeh@186 3242 ;;
gokhlayeh@186 3243 report)
gokhlayeh@186 3244 get_tazwok_config
gokhlayeh@186 3245 cd $PACKAGES_REPOSITORY
gokhlayeh@239 3246 if [ "$2" ]; then
gokhlayeh@239 3247 case $2 in
gokhlayeh@239 3248 commit|cooklist|incoming|broken|blocked)
gokhlayeh@239 3249 show="$2"
gokhlayeh@239 3250 ;;
gokhlayeh@239 3251 *)
gokhlayeh@239 3252 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
gokhlayeh@239 3253 exit 1
gokhlayeh@239 3254 ;;
gokhlayeh@239 3255 esac
gokhlayeh@239 3256 else
gokhlayeh@239 3257 show="commit cooklist incoming broken blocked"
gokhlayeh@239 3258 fi
gokhlayeh@239 3259 for i in $show; do
gokhlayeh@186 3260 if [ -s $i ]; then
gokhlayeh@239 3261 echo ""
gokhlayeh@239 3262 echo -e "\033[1m$i\033[0m"
gokhlayeh@239 3263 echo "================================================================================"
gokhlayeh@239 3264 cat $i
gokhlayeh@239 3265 echo "================================================================================"
gokhlayeh@239 3266 echo ""
gokhlayeh@186 3267 fi
gokhlayeh@186 3268 done
gokhlayeh@186 3269 ;;
gokhlayeh@186 3270 check-incoming)
gokhlayeh@186 3271 check_root
gokhlayeh@214 3272 get_options_list="forced"
gokhlayeh@186 3273 get_tazwok_config
gokhlayeh@186 3274 source_lib report
gokhlayeh@186 3275 report start
gokhlayeh@307 3276 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
gokhlayeh@307 3277 report step "Checking $INCOMING_REPOSITORY"
gokhlayeh@307 3278 report open-bloc
gokhlayeh@313 3279 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
gokhlayeh@307 3280 report sublog $LOCAL_REPOSITORY/log/incoming.html
gokhlayeh@352 3281 echo "incoming" > $LOCAL_REPOSITORY/log/package
gokhlayeh@186 3282 check_for_incoming
gokhlayeh@307 3283 report end-sublog
gokhlayeh@307 3284 report close-bloc
gokhlayeh@186 3285 ;;
gokhlayeh@190 3286 configure-chroot)
gokhlayeh@190 3287 check_root
gokhlayeh@190 3288 get_tazwok_config
gokhlayeh@190 3289 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@190 3290 cd $LOCAL_REPOSITORY
gokhlayeh@190 3291 configure_tazchroot
gokhlayeh@190 3292 else
gokhlayeh@190 3293 echo "The packages tazchroot need to be installed" >&2
gokhlayeh@190 3294 exit 1
gokhlayeh@190 3295 fi
gokhlayeh@190 3296 ;;
gokhlayeh@186 3297 chroot)
gokhlayeh@186 3298 check_root
gokhlayeh@186 3299 get_tazwok_config
gokhlayeh@186 3300 # Merge this and the other chroot function ?.
gokhlayeh@186 3301 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@186 3302 cd $LOCAL_REPOSITORY
gokhlayeh@186 3303 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@186 3304 tazchroot
gokhlayeh@186 3305 else
gokhlayeh@186 3306 echo "The packages tazchroot need to be installed" >&2
gokhlayeh@186 3307 exit 1
gokhlayeh@186 3308 fi
gokhlayeh@186 3309 ;;
gokhlayeh@186 3310 cook-toolchain)
gokhlayeh@186 3311 check_root
gokhlayeh@186 3312 get_tazwok_config
gokhlayeh@186 3313 echo -n "" > $PACKAGES_REPOSITORY/broken
gokhlayeh@186 3314 if [ -f /usr/bin/tazchroot ]; then
gokhlayeh@186 3315 cd $LOCAL_REPOSITORY
gokhlayeh@186 3316 [ ! -f tazchroot.conf ] && configure_tazchroot
gokhlayeh@186 3317 tazchroot cook-toolchain
gokhlayeh@186 3318 # Buggy : chroot can be elsewhere.
gokhlayeh@186 3319 rm -r $LOCAL_REPOSITORY/chroot
gokhlayeh@186 3320 # /!\ to be writed :
gokhlayeh@186 3321 # next rm chroot and plan cook-all by pushing all packages
gokhlayeh@186 3322 # in cooklist.
gokhlayeh@186 3323 else
gokhlayeh@186 3324 echo "The packages tazchroot need to be installed" >&2
gokhlayeh@186 3325 exit 1
gokhlayeh@186 3326 fi
gokhlayeh@186 3327 ;;
gokhlayeh@235 3328 webserver)
gokhlayeh@235 3329 check_root
gokhlayeh@235 3330 get_tazwok_config
gokhlayeh@235 3331 if [ "$ARG" = on ]; then
gokhlayeh@235 3332 if [ "$WEBSERVER" ] && [ -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 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
gokhlayeh@235 3338 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
gokhlayeh@235 3339 fi
gokhlayeh@235 3340 for pkg in php lighttpd; do
gokhlayeh@235 3341 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
gokhlayeh@235 3342 done
gokhlayeh@235 3343 if [ "$missing" ]; then
gokhlayeh@235 3344 echo "You need to install those packages to start webserver: $missing." >&2
gokhlayeh@235 3345 exit 1
gokhlayeh@235 3346 fi
gokhlayeh@235 3347 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
gokhlayeh@235 3348 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
gokhlayeh@235 3349 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
gokhlayeh@235 3350 fi
gokhlayeh@235 3351 if ! [ "$WEBSERVER" ]; then
gokhlayeh@235 3352 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
gokhlayeh@235 3353 read WEBSERVER
gokhlayeh@235 3354 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
gokhlayeh@235 3355 fi
gokhlayeh@235 3356 if [ -f "$WEBSERVER/repositories.list" ] && \
gokhlayeh@235 3357 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
gokhlayeh@235 3358 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
gokhlayeh@235 3359 exit 1
gokhlayeh@235 3360 fi
gokhlayeh@235 3361 mkdir -p $WEBSERVER
gokhlayeh@235 3362 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
gokhlayeh@267 3363 for file in index.php log.php download.php; do
gokhlayeh@235 3364 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
gokhlayeh@235 3365 done
gokhlayeh@267 3366 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
gokhlayeh@267 3367 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
gokhlayeh@267 3368 done
gokhlayeh@235 3369 source $LOCAL_REPOSITORY/tazchroot.conf
gokhlayeh@235 3370 echo "<?php
gokhlayeh@235 3371
gokhlayeh@235 3372 // Web interface configuration
gokhlayeh@235 3373
gokhlayeh@235 3374 \$version=\"${undigest:-$SLITAZ_VERSION}\";
gokhlayeh@235 3375 \$chroot=\"$chroot_dir\";
pascal@360 3376 \$lockfile=\"\$chroot/proc/1/status\";
gokhlayeh@235 3377 \$db_dir=\"$PACKAGES_REPOSITORY\";
gokhlayeh@235 3378 \$log_dir=\"$LOCAL_REPOSITORY/log\";
gokhlayeh@235 3379 \$packages=\"$PACKAGES_REPOSITORY\";
gokhlayeh@235 3380 \$incoming=\"$INCOMING_REPOSITORY\";
gokhlayeh@251 3381 \$wok=\"$WOK\";
gokhlayeh@235 3382
gokhlayeh@235 3383 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
gokhlayeh@235 3384 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
gokhlayeh@235 3385 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
gokhlayeh@235 3386 if [ -L "$WEBSERVER/conf.php" ]; then
gokhlayeh@235 3387 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
gokhlayeh@235 3388 read answer
gokhlayeh@235 3389 if [ "$answer" = y ]; then
gokhlayeh@235 3390 rm $WEBSERVER/conf.php
gokhlayeh@235 3391 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
gokhlayeh@235 3392 fi
gokhlayeh@235 3393 else
gokhlayeh@235 3394 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
gokhlayeh@235 3395 fi
gokhlayeh@235 3396 elif [ "$ARG" = off ]; then
gokhlayeh@235 3397 if ! [ "$WEBSERVER" ]; then
gokhlayeh@235 3398 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
gokhlayeh@235 3399 exit 1
gokhlayeh@235 3400 fi
gokhlayeh@235 3401 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
gokhlayeh@235 3402 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
gokhlayeh@235 3403 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
gokhlayeh@267 3404 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
gokhlayeh@267 3405 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
gokhlayeh@267 3406 done
gokhlayeh@235 3407 if ! [ -s "$WEBSERVER/repositories.list" ]; then
gokhlayeh@235 3408 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 3409 rm $WEBSERVER/conf.php
gokhlayeh@235 3410 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
gokhlayeh@235 3411 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
gokhlayeh@235 3412 rm $WEBSERVER/conf.php
gokhlayeh@235 3413 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
gokhlayeh@235 3414 fi
gokhlayeh@235 3415 else
gokhlayeh@235 3416 echo "Usage: tazwok webserver on/off" >&2
gokhlayeh@235 3417 exit 1
gokhlayeh@235 3418 fi
gokhlayeh@235 3419 ;;
pankso@354 3420 block)
pankso@354 3421 # Add a pkg name to the list of blocked packages.
gokhlayeh@367 3422 get_tazwok_config
gokhlayeh@367 3423 check_root
gokhlayeh@367 3424 check_for_package_on_cmdline
gokhlayeh@367 3425 if ! [ -f $WOK/$PACKAGE/receipt ]; then
gokhlayeh@367 3426 echo "Can't find $PACKAGE into wok." >&2
gokhlayeh@367 3427 echo ""
gokhlayeh@367 3428 exit 1
gokhlayeh@367 3429 fi
pankso@354 3430 echo ""
gokhlayeh@367 3431 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
gokhlayeh@367 3432 echo "$PACKAGE is already in the blocked packages list." >&2
gokhlayeh@367 3433 echo ""
gokhlayeh@367 3434 exit 1
pankso@354 3435 else
gokhlayeh@367 3436 echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... "
gokhlayeh@367 3437 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked
gokhlayeh@367 3438 status
gokhlayeh@367 3439 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then
gokhlayeh@367 3440 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... "
gokhlayeh@367 3441 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist
gokhlayeh@367 3442 status
pankso@354 3443 fi
pankso@354 3444 fi
pankso@354 3445 echo "" ;;
pankso@354 3446 unblock)
pankso@354 3447 # Remove a pkg name from the list of blocked packages.
gokhlayeh@367 3448 get_tazwok_config
gokhlayeh@367 3449 check_root
gokhlayeh@367 3450 check_for_package_on_cmdline
gokhlayeh@367 3451 if ! [ -f $WOK/$PACKAGE/receipt ]; then
gokhlayeh@367 3452 echo "Can't find $PACKAGE into wok." >&2
gokhlayeh@367 3453 echo ""
gokhlayeh@367 3454 exit 1
gokhlayeh@367 3455 fi
pankso@354 3456 echo ""
gokhlayeh@367 3457 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
gokhlayeh@367 3458 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... "
gokhlayeh@367 3459 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked
gokhlayeh@367 3460 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked
gokhlayeh@367 3461 status
pankso@354 3462 else
gokhlayeh@367 3463 echo "$PACKAGE is not in the blocked packages list." >&2
gokhlayeh@367 3464 echo ""
gokhlayeh@367 3465 exit 1
pankso@354 3466 fi
pankso@354 3467 echo "" ;;
pankso@7 3468 usage|*)
MikeDSmith25@82 3469 # Print usage also for all unknown commands.
pankso@7 3470 #
pankso@7 3471 usage
gokhlayeh@186 3472 ;;
pankso@7 3473 esac
pankso@7 3474
gokhlayeh@313 3475 report stop 2>/dev/null
pankso@7 3476 exit 0