--- /usr/lib/portage/bin/etc-update.old 2005-08-04 18:44:36.000000000 +0200 +++ /usr/lib/portage/bin/etc-update 2005-08-04 18:44:42.000000000 +0200 @@ -9,6 +9,10 @@ # Jochem Kossen # Leo Lipelis # Karl Trygve Kalleberg +# +# Watch list support by: +# Alessandro Di Marco +# Paolo Gianrossi export PORTAGE_CALLER="etc-update" @@ -97,19 +101,55 @@ function sel_file() { local -i isfirst=0 + local -i i=0 + local watch="" + + if [ -f "/etc/etc-update.watch" ] ; then + local esc="\\\\\/" + + for kw in `cat /etc/etc-update.watch | sort` ; do + watch="${watch}s/`echo ${kw} | sed \"s/\//${esc}/g\"`//g ; " + done + fi + until [ -f ${TMP}/files/${input} ] || [ ${input} == -1 ] || [ ${input} == -3 ]; do for file in `ls ${TMP}/files|sort -n`; do + local content="`cat ${TMP}/files/${file}`" + if (( ${isfirst} == 0 )); then isfirst=${file} fi + + if [ "${watch}" != "" ] ; then + if [ "`echo ${content} | sed \"${watch}\"`" != "`echo ${content}`" ] ; then + skip[i++]=${file} + echo -en "\33[0;37;41m" + fi + fi + echo -n "${file}${PAR} " + if (( ${mode} == 0 )); then - for word in `cat ${TMP}/files/${file}`; do - echo ${word} + local space + i=0 + for word in ${content}; do + if (( i == 0 )); then + echo -n "${word} <-- " + space="`echo -n ${word} | sed s/./\ /g`" + elif (( i == 1 )); then + echo "${word}" + else + echo " ${space} ${word}" + fi + i=${i}+1 done else head -n1 ${TMP}/files/${file} fi + + if (( ${i} > 0 )) ; then + echo -en "\33[0;37;39m" + fi done > ${TMP}/menuitems if [ "${OVERWRITE_ALL}" == "yes" ]; then @@ -125,9 +165,12 @@ if (( ${mode} == 0 )); then cat ${TMP}/menuitems echo "Please select a file to edit by entering the corresponding number." - echo " (don't use -3 or -5 if you're unsure what to do)" - echo " (-1 to exit) (-3 to auto merge all remaining files)" - echo -n " (-5 to auto-merge AND not use 'mv -i'): " + echo " (don't use -3, -5, -7 or -9 if you're unsure what to do)" + echo " (-3 to auto merge remaining unwatched files)" + echo " (-5 same as -3 AND not use 'mv -i')" + echo " (-7 to auto merge all remaining files)" + echo " (-9 same as -7 AND not use 'mv -i')" + echo -n " (-1 to exit): " read input else dialog --title "${title}" --menu "${my_title}" \ @@ -135,13 +178,21 @@ 2> ${TMP}/input input=`cat ${TMP}/input` fi + if (( ${input} == -9 )); then + input=-5 + export DONT_MESS="yes" + fi + if (( ${input} == -7 )); then + input=-3 + export DONT_MESS="yes" + fi if (( ${input} == -5 )); then input=-3 export mv_opts="" fi if (( ${input} == -3 )); then - input=0 - export OVERWRITE_ALL="yes" + input=0 + export OVERWRITE_ALL="yes" fi fi # -3 automerge if (( ${input} == 0 )); then @@ -151,10 +202,14 @@ } function do_file() { - echo + if (( ${noecho} == 0 )) ; then + echo + fi local -i my_input local -i fcount=0 until (( `cat ${TMP}/files/${input}|wc -l` < 2 )); do + local -i i + my_input=0 if (( `cat ${TMP}/files/${input}|wc -l` == 2 )); then my_input=1 @@ -209,7 +264,23 @@ file=`cat ${TMP}/files/${input} | sed -e "${fcount}p;d"` ofile=`head -n1 ${TMP}/files/${input}` - do_cfg "${file}" "${ofile}" + for (( i=0; i<${#skip[@]}; i++ )) ; do + if [ "${skip[${i}]}" == "${input}" ] ; then + break; + fi + done + + if (( ${i} >= ${#skip[@]} )) ; then + noecho=0 + do_cfg "${file}" "${ofile}" + else + if [ "${OVERWRITE_ALL}" != "yes" ] || [ "${DONT_MESS}" == "yes" ]; then + noecho=0 + do_cfg "${file}" "${ofile}" + else + noecho=1 + fi + fi cat ${TMP}/files/${input}|sed -e "${fcount}!p;d" > ${TMP}/files/sed mv ${TMP}/files/sed ${TMP}/files/${input} @@ -218,7 +289,9 @@ break fi done - echo + if (( ${noecho} == 0 )) ; then + echo + fi rm ${TMP}/files/${input} count=${count}-1 } @@ -279,6 +352,8 @@ ;; 4) continue ;; + 5) break + ;; *) continue ;; esac @@ -393,6 +468,8 @@ scan +noecho=0 + until (( ${input} == -1 )); do if (( ${count} == 0 )); then die "Nothing left to do; exiting. :)" 0