tazwok annotate tazwok @ rev 399

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