tazwok rev 405 4.3
Use variables for commit/cooklist/broken/blocked
author | Antoine Bodin <gokhlayeh@slitaz.org> |
---|---|
date | Fri Mar 04 05:35:52 2011 +0100 (2011-03-04) |
parents | 9ca9e6ff253b |
children | 30d672e10274 |
files | TODO tazwok |
line diff
1.1 --- a/TODO Fri Mar 04 03:23:26 2011 +0100 1.2 +++ b/TODO Fri Mar 04 05:35:52 2011 +0100 1.3 @@ -7,6 +7,7 @@ 1.4 [ ] get reverse depends when a recook is needed (don't catch packages from reference repository!) 1.5 [ ] cooklist generation 1.6 [ ] Fix md5um on-the-fly generation when using check-incoming) 1.7 +[ ] Generate cooklist properly after cook-toolchain 1.8 1.9 ==== Code optimizations ==== 1.10 1.11 @@ -16,8 +17,9 @@ 1.12 [ ] Move files related to cooking env from packages to packages-incoming (just before releasing the beta) 1.13 [ ] Use variables for most used files 1.14 [*] cook-order.txt; wok-wanted.txt/wok-depends.txt of reference repository 1.15 - [ ] cooklist, commit, broken, blocked 1.16 + [*] cooklist, commit, broken, blocked 1.17 [ ] Rename wok-wanted.txt/wok-depends.txt to simply depends.txt/wanted.txt 1.18 +[ ] L407: Use fgrep here are variable subsitution are not optimize for big strings. 1.19 1.20 ==== New features ==== 1.21
2.1 --- a/tazwok Fri Mar 04 03:23:26 2011 +0100 2.2 +++ b/tazwok Fri Mar 04 05:35:52 2011 +0100 2.3 @@ -138,17 +138,8 @@ 2.4 return 2.5 fi 2.6 fi 2.7 - 2.8 - # The path to the most important files/dir used by Tazwok. 2.9 - PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages 2.10 - WOK=$LOCAL_REPOSITORY/wok 2.11 - INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming 2.12 - SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src 2.13 + 2.14 set_common_path 2.15 - dep_db=$INCOMING_REPOSITORY/wok-depends.txt 2.16 - wan_db=$INCOMING_REPOSITORY/wok-wanted.txt 2.17 - cookorder=$PACKAGES_REPOSITORY/cookorder.txt 2.18 - 2.19 2.20 # Check that packages are up to date if user intend to cook. 2.21 check_env_status ${USE_ONLINE_PKG:-$PACKAGES_REPOSITORY} 2.22 @@ -219,14 +210,33 @@ 2.23 [ -f $dep_db ] || touch $dep_db 2.24 [ -f $wan_db ] || touch $wan_db 2.25 [ -f $cookorder ] || touch $cookorder 2.26 - for file in broken blocked commit incoming cooklist; do 2.27 - [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file 2.28 + for file in $dep_db $wan_db $cookorder $commit $cooklist \ 2.29 + $broken $blocked $SOURCES_REPOSITORY/sources.list 2.30 + do 2.31 + [ -f $file ] || touch $file 2.32 done 2.33 - touch $SOURCES_REPOSITORY/sources.list 2.34 fi 2.35 2.36 # Limit memory usage. 2.37 ulimit -v $(awk '/MemTotal|SwapTotal/ { n+=$2 } END { print int((n*80)/100) }' < /proc/meminfo) 2.38 +} 2.39 + 2.40 +# The path to the most important files/dir used by Tazwok. 2.41 +set_common_path() 2.42 +{ 2.43 + PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages 2.44 + WOK=$LOCAL_REPOSITORY/wok 2.45 + INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming 2.46 + SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src 2.47 + RECEIPT="$WOK/$PACKAGE/receipt" 2.48 + LOG="$WOK/$PACKAGE/process.log" 2.49 + dep_db=$INCOMING_REPOSITORY/wok-depends.txt 2.50 + wan_db=$INCOMING_REPOSITORY/wok-wanted.txt 2.51 + cookorder=$PACKAGES_REPOSITORY/cookorder.txt 2.52 + commit=$PACKAGES_REPOSITORY/commit 2.53 + cooklist=$PACKAGES_REPOSITORY/cooklist 2.54 + broken=$PACKAGES_REPOSITORY/broken 2.55 + blocked=$PACKAGES_REPOSITORY/blocked 2.56 2.57 # log steps for webserver. 2.58 log_step="$LOCAL_REPOSITORY/log/step" 2.59 @@ -235,17 +245,6 @@ 2.60 rm -f $LOCAL_REPOSITORY/log/package" 2.61 } 2.62 2.63 -# Used in several functions. 2.64 -set_common_path() 2.65 -{ 2.66 - # The receipt is used to compile the source code and 2.67 - # generate suitable packages for Tazpkg. 2.68 - RECEIPT="$WOK/$PACKAGE/receipt" 2.69 - 2.70 - # The path to the process log file. 2.71 - LOG="$WOK/$PACKAGE/process.log" 2.72 -} 2.73 - 2.74 ######################################################################## 2.75 # TAZWOK CHECK FUNCTIONS 2.76 ######################## 2.77 @@ -275,17 +274,10 @@ 2.78 if [ ! "$LIST" ]; then 2.79 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2 2.80 exit 1 2.81 - fi 2.82 - 2.83 - # Check if the list of packages exists. 2.84 - if [ -f "$LIST" ]; then 2.85 - LIST=`cat $LIST` 2.86 - else 2.87 + elif ! [ -f "$LIST" ]; then 2.88 echo -e "\nUnable to find $LIST packages list.\n" >&2 2.89 exit 1 2.90 - fi 2.91 - 2.92 - if [ ! "$LIST" ]; then 2.93 + elif ! [ -s "$LIST" ]; then 2.94 echo -e "\nList is empty.\n" >&2 2.95 exit 1 2.96 fi 2.97 @@ -294,10 +286,7 @@ 2.98 check_for_pkg_in_wok() 2.99 { 2.100 [ -f $WOK/$PACKAGE/receipt ] && return 2.101 - if [ "$undigest" ]; then 2.102 - [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1 2.103 - grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt && return 1 2.104 - fi 2.105 + [ "$undigest" ] grep -q ^$PACKAGE'$\t' $ref_dep_db && return 1 2.106 echo "Can't find $PACKAGE in wok or mirror" >&2 2.107 return 2 2.108 } 2.109 @@ -409,15 +398,13 @@ 2.110 plan_remove="${plan_remove/ $pkg / }" 2.111 remove_later="$remove_later $pkg" 2.112 fi 2.113 - if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then 2.114 - broken="$broken$pkg " 2.115 - fi 2.116 + grep -q ^$pkg$ $broken && broken_pkg="$broken_pkg$pkg " 2.117 done 2.118 2.119 # Don't cook if a depend is broken. 2.120 - if [ "$broken" ]; then 2.121 + if [ "$broken_pkg" ]; then 2.122 MISSING_PACKAGE=$plan_remove 2.123 - echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2 2.124 + echo "Can't cook $PACKAGE because broken depend(s) : $broken_pkg" >&2 2.125 unset plan_remove broken 2.126 2.127 # Set report step to failed. 2.128 @@ -1021,14 +1008,11 @@ 2.129 2.130 set_pkg_broken() 2.131 { 2.132 - if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then 2.133 - echo $PACKAGE >> $PACKAGES_REPOSITORY/broken 2.134 - fi 2.135 + grep -q ^$PACKAGE$ $broken || echo $PACKAGE >> $broken 2.136 2.137 # Remove pkg from cooklist to avoid re-cook it if no changes happens 2.138 # in the cook stuff. 2.139 - sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist 2.140 - sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit 2.141 + sed "/^$PACKAGE$/d" -i $cooklist $commit 2.142 2.143 gen_cookmd5 2.144 2.145 @@ -1151,9 +1135,8 @@ 2.146 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE." 2.147 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do 2.148 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue 2.149 - grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \ 2.150 - $PACKAGES_REPOSITORY/cooklist && continue 2.151 - echo $rdep >> $PACKAGES_REPOSITORY/cooklist 2.152 + grep -q ^$rdep$ $blocked $cooklist && continue 2.153 + echo $rdep >> $cooklist 2.154 done 2.155 regen_cooklist=yes 2.156 break 2.157 @@ -1213,20 +1196,19 @@ 2.158 rm fs.cpio.* && cd .. 2.159 2.160 # Recook of reverse-depends if package was broken. 2.161 - if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/broken; then 2.162 + if grep -q "^$PACKAGE$" $broken; then 2.163 report step "Planning re-try a cook of reverse depends" 2.164 - sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken 2.165 + sed "/^$PACKAGE$/d" -i $broken 2.166 for rdep in $(look_for_rdep); do 2.167 - grep -q "^$rdep$" $PACKAGES_REPOSITORY/broken || continue 2.168 - grep -q "^$rdep$" $PACKAGES_REPOSITORY/cooklist && continue 2.169 + grep -q "^$rdep$" $broken || continue 2.170 + grep -q "^$rdep$" $cooklist && continue 2.171 echo "Adding $rdep to the cooklist" 2.172 - echo $rdep >> $PACKAGES_REPOSITORY/cooklist 2.173 + echo $rdep >> $cooklist 2.174 regen_cooklist=t 2.175 done 2.176 report end-step 2.177 fi 2.178 - sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit 2.179 - sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist 2.180 + sed "/^$PACKAGE$/d" -i $commit $cooklist 2.181 2.182 # Log process. 2.183 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG 2.184 @@ -1317,9 +1299,7 @@ 2.185 rm $pkg 2.186 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE 2.187 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db $cookorder 2.188 - for i in cooklist commit blocked broken; do 2.189 - sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i 2.190 - done 2.191 + sed "/^$PACKAGE$/d" -i $cooklist $commit $blocked $broken 2.192 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html 2.193 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ] && \ 2.194 [ "$(sed 1!d $cookorder)" != "#PlanSort" ] ; then 2.195 @@ -1909,8 +1889,7 @@ 2.196 } 2.197 set_commited() 2.198 { 2.199 - ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit && 2.200 - echo $PACKAGE >> $PACKAGES_REPOSITORY/commit 2.201 + grep -q ^$PACKAGE$ $commit || echo $PACKAGE >> $commit 2.202 gen_cookmd5 2.203 update_dep_db 2.204 } 2.205 @@ -1942,6 +1921,8 @@ 2.206 report step "Scanning wok" 2.207 if [ "$pkg" ]; then 2.208 scan $pkg --cooklist 2.209 + elif [ "$LIST" ]; then 2.210 + scan `cat $LIST` --cooklist 2.211 else 2.212 scan `cat $cooklist` --cooklist 2.213 fi 2.214 @@ -1952,20 +1933,18 @@ 2.215 # Core toolchain should not be cooked unless cook-toolchain is used. 2.216 if ! [ -f /etc/config.site.tmptoolchain ] ; then 2.217 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do 2.218 - grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \ 2.219 - echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked 2.220 + grep -q ^$PACKAGE$ $blocked || echo $PACKAGE >> $blocked 2.221 done 2.222 fi 2.223 2.224 - if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then 2.225 - cd $PACKAGES_REPOSITORY 2.226 - for PACKAGE in $(cat commit); do 2.227 + if [ -s $commit ] && [ "$COMMAND" != gen-cooklist ]; then 2.228 + for PACKAGE in $(cat $commit); do 2.229 WANTED="$(look_for_wanted)" 2.230 if [ "$WANTED" ]; then 2.231 - grep -q ^$WANTED$ broken cooklist blocked commit && continue 2.232 + grep -q ^$WANTED$ $broken $cooklist $blocked $commit && continue 2.233 fi 2.234 - grep -q ^$PACKAGE$ blocked cooklist && continue 2.235 - echo $PACKAGE >> cooklist 2.236 + grep -q ^$PACKAGE$ $blocked $cooklist && continue 2.237 + echo $PACKAGE >> $cooklist 2.238 done 2.239 fi 2.240 sort_cooklist 2.241 @@ -1983,11 +1962,10 @@ 2.242 if [ -f "$tmp/checked" ]; then 2.243 rm -f $tmp/cooklist 2.244 cat $tmp/checked | while read PACKAGE; do 2.245 - grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \ 2.246 - echo $PACKAGE >> $tmp/cooklist 2.247 + grep -q ^$PACKAGE$ $cooklist && echo $PACKAGE >> $tmp/cooklist 2.248 done 2.249 elif ! [ "$COMMAND" = gen-cooklist ]; then 2.250 - cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do 2.251 + cat $blocked | while read PACKAGE; do 2.252 sed "/^$PACKAGE/d" -i $tmp/cooklist 2.253 done 2.254 fi 2.255 @@ -1998,7 +1976,7 @@ 2.256 for PACKAGE in $(cat $tmp/cooklist); do 2.257 WANTED="$(look_for_wanted)" 2.258 [ "$WANTED" ] || continue 2.259 - if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then 2.260 + if grep -q ^$WANTED$ $broken $tmp/cooklist; then 2.261 sed "/^$PACKAGE$/d" -i $tmp/cooklist 2.262 elif [ ! -d $WOK/$WANTED/install ]; then 2.263 sed "/^$PACKAGE$/d" -i $tmp/cooklist 2.264 @@ -2023,8 +2001,7 @@ 2.265 fi 2.266 2.267 cat $tmp/cooklist 2.268 - [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \ 2.269 - cat $tmp/cooklist > $cooklist 2.270 + [ "$LIST" ] || cat $tmp/cooklist > $cooklist 2.271 fi 2.272 2.273 report end-step 2.274 @@ -2046,7 +2023,7 @@ 2.275 [ -s $INCOMING_REPOSITORY/packages.desc ] || { 2.276 echo "No packages in $INCOMING_REPOSITORY." 2.277 report end-step; return; } 2.278 - if [ -s $PACKAGES_REPOSITORY/broken ]; then 2.279 + if [ -s $broken ]; then 2.280 missingpkg=$(look_for_missing_pkg broken) 2.281 if [ "$missingpkg" ]; then 2.282 echo "Don't move incoming packages to main repository because theses ones are broken:" >&2 2.283 @@ -2055,7 +2032,7 @@ 2.284 return 1 2.285 fi 2.286 fi 2.287 - if [ -s $PACKAGES_REPOSITORY/cooklist ]; then 2.288 + if [ -s $cooklist ]; then 2.289 missingpkg=$(look_for_missing_pkg cooklist) 2.290 if [ "$missingpkg" ]; then 2.291 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2 2.292 @@ -2069,7 +2046,7 @@ 2.293 cooklist=$PACKAGES_REPOSITORY/cooklist 2.294 pkg="$incoming_pkgs" 2.295 gen_cook_list 2.296 - if [ -s $PACKAGES_REPOSITORY/cooklist ]; then 2.297 + if [ -s $cooklist ]; then 2.298 missingpkg=$(look_for_missing_pkg cooklist) 2.299 if [ "$missingpkg" ]; then 2.300 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2 2.301 @@ -2255,8 +2232,8 @@ 2.302 fi 2.303 2.304 # Regen the cooklist if it was planned and command is not cook. 2.305 - [ "$regen_cooklist" ] && unset regen_cooklist && \ 2.306 - [ "$COMMAND" != cook ] && sort_cooklist 2.307 + [ "$regen_cooklist" ] && unset regen_cooklist && 2.308 + [ "$COMMAND" != cook ] && sort_cooklist 2.309 2.310 # Some hacks to set the bloc & function status as failed if cook was 2.311 # failed. 2.312 @@ -2425,7 +2402,7 @@ 2.313 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then 2.314 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" 2.315 else 2.316 - cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist} 2.317 + check_for_list 2.318 fi 2.319 fi 2.320 gen_cook_list 2.321 @@ -2749,19 +2726,15 @@ 2.322 cook 2.323 ;; 2.324 sort-cooklist) 2.325 - if [ ! -f "$LIST" ]; then 2.326 - echo "Usage : tazwok sort-cooklist cooklist" >&2 2.327 - exit 1 2.328 - fi 2.329 check_root 2.330 get_tazwok_config 2.331 + check_for_list 2.332 report(){ : ; } 2.333 # When using sort-cooklist, the script should behave as for gen-cooklist 2.334 # The only difference between theses two is where the output is sended. 2.335 COMMAND=gen-cooklist 2.336 - cooklist=$LIST 2.337 gen_cook_list 2.338 - cp -af $tmp/cooklist $cooklist 2.339 + cp -af $tmp/cooklist $LIST 2.340 ;; 2.341 cook-list) 2.342 # Cook all packages listed in a file or in default cooklist. 2.343 @@ -2771,7 +2744,7 @@ 2.344 source_lib report 2.345 report start 2.346 if ! [ "$pkg" ]; then 2.347 - cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist} 2.348 + [ "$LIST" ] && check_for_list 2.349 fi 2.350 gen_cook_list 2.351 cook_list 2.352 @@ -3192,7 +3165,6 @@ 2.353 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt 2.354 } | sort -u)" 2.355 fi 2.356 - cooklist=$PACKAGES_REPOSITORY/cooklist 2.357 gen_cook_list 2.358 ;; 2.359 cook-commit) 2.360 @@ -3212,7 +3184,6 @@ 2.361 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt 2.362 } | sort -u)" 2.363 fi 2.364 - cooklist=$PACKAGES_REPOSITORY/cooklist 2.365 gen_cook_list 2.366 cook_list 2.367 ;; 2.368 @@ -3229,7 +3200,6 @@ 2.369 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt 2.370 } | sort -u)" 2.371 fi 2.372 - cooklist=$PACKAGES_REPOSITORY/cooklist 2.373 gen_cook_list 2.374 cook_list 2.375 ;; 2.376 @@ -3428,17 +3398,17 @@ 2.377 exit 1 2.378 fi 2.379 echo "" 2.380 - if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then 2.381 + if grep -qs "^$PACKAGE$" $blocked; then 2.382 echo "$PACKAGE is already in the blocked packages list." >&2 2.383 echo "" 2.384 exit 1 2.385 else 2.386 - echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... " 2.387 - echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked 2.388 + echo -n "Adding $PACKAGE to : $blocked... " 2.389 + echo "$PACKAGE" >> $blocked 2.390 status 2.391 - if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then 2.392 - echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... " 2.393 - sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist 2.394 + if grep -q "^$PACKAGE$" $cooklist; then 2.395 + echo -n "Removing $PACKAGE from : $cooklist... " 2.396 + sed -i /"^$PACKAGE$"/d $cooklist 2.397 status 2.398 fi 2.399 fi 2.400 @@ -3454,10 +3424,10 @@ 2.401 exit 1 2.402 fi 2.403 echo "" 2.404 - if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then 2.405 - echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... " 2.406 - sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked 2.407 - sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked 2.408 + if grep -qs "^$PACKAGE$" $blocked; then 2.409 + echo -n "Removing $PACKAGE from : $blocked... " 2.410 + sed -i /"^$PACKAGE$"/d $blocked 2.411 + sed -i '/^$/d' $blocked 2.412 status 2.413 else 2.414 echo "$PACKAGE is not in the blocked packages list." >&2