tazwok rev 398 4.3
Add checks for packages availability & if they are up-to-date; also add check for reference datas existence when undigest option is used. (4.3)
author | Antoine Bodin <gokhlayeh@slitaz.org> |
---|---|
date | Thu Mar 03 22:32:19 2011 +0100 (2011-03-03) |
parents | 3cdf810ec810 |
children | 248bcbd6490b |
files | tazwok |
line diff
1.1 --- a/tazwok Thu Mar 03 21:50:40 2011 +0100 1.2 +++ b/tazwok Thu Mar 03 22:32:19 2011 +0100 1.3 @@ -84,6 +84,39 @@ 1.4 # TAZWOK VARIABLES & INITIAL CONFIGURATION 1.5 ######################## 1.6 1.7 +# Check if all packages are up to date into build environnement 1.8 +check_env_status() 1.9 +{ 1.10 + { [ "${COMMAND#cook}" = "$COMMAND" ] || \ 1.11 + [ "$COMMAND" = cook-toolchain ] ; } && return 1.12 + MIRROR_path=$(grep -l "^$1$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror) 1.13 + 1.14 + if [ ! "$MIRROR_path" ]; then 1.15 + echo "You are trying to cook something but you don't use $1 repository, which is \ 1.16 + needed for this operation." | fold -s >&2 1.17 + exit 1 1.18 + fi 1.19 + 1.20 + LOCALSTATE_path=${MIRROR_path%/mirror} 1.21 + 1.22 + # Check is possible only if repository use ID. 1.23 + if [ "${MIRROR_path:0:1}" = '/' ]; then 1.24 + [ -f "$MIRROR_path/ID" ] || return 1.25 + else 1.26 + wget -a -s $MIRROR_path/ID 2>/dev/null || return 1.27 + fi 1.28 + 1.29 + [ -f $LOCALSTATE_path/ID ] && ID=$(cat $LOCALSATE_path/ID) 1.30 + 1.31 + if [ "$LOCALSTATE_path" = "$LOCALSTATE" ]; then 1.32 + tazpkg recharge main 1.33 + else 1.34 + tazpkg recharge ${LOCALSTATE_path##*/} 1.35 + fi 1.36 + 1.37 + [ "$(cat $LOCALSTATE_path/ID)" = "$ID" ] || env_status=1 1.38 +} 1.39 + 1.40 get_tazwok_config() 1.41 { 1.42 # Get configuration file. 1.43 @@ -112,13 +145,69 @@ 1.44 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming 1.45 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src 1.46 set_common_path 1.47 - 1.48 - # /!\ This part needs some changes. 1.49 - # Basically, get theses files from the net if they are missing. 1.50 dep_db=$INCOMING_REPOSITORY/wok-depends.txt 1.51 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt 1.52 cookorder=$INCOMING_REPOSITORY/cookorder.txt 1.53 1.54 + 1.55 + # Check that packages are up to date if user intend to cook. 1.56 + check_env_status ${USE_ONLINE_PKG:-$PACKAGES_REPOSITORY} 1.57 + check_env_status $INCOMING_REPOSITORY 1.58 + 1.59 + # In case undigest is used, we need to upgrade system. 1.60 + if [ "$undigest" ]; then 1.61 + ref_PACKAGES_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION/packages 1.62 + if [ -f $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf ] && \ 1.63 + grep -q ^USE_ONLINE_PKG $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf; then 1.64 + ref_USE_ONLINE_PKG=$(source $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf && \ 1.65 + echo $USE_ONLINE_PKG) 1.66 + fi 1.67 + 1.68 + check_env_status ${ref_USE_ONLINE_PKG:-$ref_PACKAGES_REPOSITORY} 1.69 + cd $ref_PACKAGES_REPOSITORY 1.70 + if [ "$ref_USE_ONLINE_PKG" ]; then 1.71 + ref_dep_db=$LOCALSTATE_path/wok-depends.txt 1.72 + ref_wan_db=$LOCALSTATE_path/wok-wanted.txt 1.73 + else 1.74 + ref_dep_db=$ref_PACKAGES_REPOSITORY/wok-depends.txt 1.75 + ref_wan_db=$ref_PACKAGES_REPOSITORY/wok-wanted.txt 1.76 + fi 1.77 + 1.78 + for file in $ref_dep_db $ref_wan_db; do 1.79 + [ -f "$file" ] && continue 1.80 + missing_file=t 1.81 + echo "$file is missing." >&2 1.82 + done 1.83 + if [ "$missing_file" ]; then 1.84 + echo " 1.85 +Theses files are needed to get datas about packages from the reference repository $SLITAZ_VERSION. \ 1.86 +If you don't intend to build this reference repository yourself, you should set USE_ONLINE_PKG variable \ 1.87 +into tazwok.conf of this reference repository. How-to:" | fold -s >&2 1.88 + echo "echo 'USE_ONLINE_PKG=\"packages_repository_url\"' >> $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf" 1.89 + echo "" 1.90 + exit 1 1.91 + fi 1.92 + fi 1.93 + 1.94 + # If $env_status exists, it means an upgrade may be needed. 1.95 + if [ "$env_status" ]; then 1.96 + if [ -x /usr/bin/clean-chroot ]; then 1.97 + echo y | tazpkg upgrade 1.98 + else 1.99 + echo "\e[0;31mWarning: \e[m" 1.100 + echo "You're environnement may need a package upgrade." 1.101 + echo "Upgrading is highly recommanded to ensure repository consistency." 1.102 + echo "You can (E)xit, (U)pgrade, or (C)ontinue." 1.103 + echo -n "What do you want to do ?" 1.104 + read answer 1.105 + case $answer in 1.106 + [Cc]*) ;; 1.107 + [Uu]*) echo y | tazpkg upgrade ;; 1.108 + *) exit 1.109 + esac 1.110 + fi 1.111 + fi 1.112 + 1.113 # Check commons directories, create them if user is root. 1.114 if test $(id -u) = 0 ; then 1.115 check_dir $WOK || chmod 777 $WOK