tazwok annotate tazwok @ rev 407

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