tazwok annotate tazwok @ rev 450

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