tazwok annotate tazwok @ rev 449

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