From: Anthony Basile Date: Sun, 12 Dec 2010 23:30:45 +0000 (-0500) Subject: etc-update: add option to save example config X-Git-Tag: v2.2.0_alpha8~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=99ec8de8e69f71e9a3f04dc318c7c741c5e6563a;p=portage.git etc-update: add option to save example config This will fix bug #348561. --- diff --git a/bin/etc-update b/bin/etc-update index e282a307c..d4ed6e689 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -339,6 +339,7 @@ do_cfg() { 2) Delete update, keeping original as is 3) Interactively merge original with update 4) Show differences again +5) Save update as example config Please select from the menu above (-1 to ignore this update): " my_input=$(read_int) fi @@ -361,6 +362,8 @@ Please select from the menu above (-1 to ignore this update): " ;; 4) continue ;; + 5) do_distconf "${file}" "${ofile}" + ;; *) continue ;; esac @@ -444,6 +447,36 @@ Please select from the menu above (-1 to exit, losing this merge): " return 255 } +do_distconf() { + # search for any previously saved distribution config + # files and number the current one accordingly + + local file="${1}" + local ofile="${2}" + local -i count + local -i size + local -i fill + local -i f + local suffix + local efile + + for count in $(seq 0 9999); do + size=${#count} + let fill=$((4-$size)) + suffix=".dist_" + for f in $(seq 1 $fill); do + suffix+="0" + done + suffix+="${count}" + efile="${ofile}${suffix}" + if [[ ! -f ${efile} ]]; then + echo ${efile} + mv ${mv_opts} ${file} ${efile} + break + fi + done +} + die() { trap SIGTERM trap SIGINT