Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 1632 Details for
Bug 3804
etc-update running feature request bug
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
new version of etc-update
etc-update (text/plain), 5.22 KB, created by
Jochem Kossen
on 2002-06-20 03:10:27 UTC
(
hide
)
Description:
new version of etc-update
Filename:
MIME Type:
Creator:
Jochem Kossen
Created:
2002-06-20 03:10:27 UTC
Size:
5.22 KB
patch
obsolete
>#!/bin/bash ># Copyright 2002 Gentoo Technologies, Inc. ># Distributed under the terms of the GNU General Public License, v2 or later ># Author: Jochem Kossen <j.kossen@home.nl>, (c) 2002 ># Author: Leo Lipelis <aeoo@gentoo.org>, (c) 2002 ># Author: Karl Trygve Kalleberg <karltk@gentoo.org>, (c) 2002 > ># ># Functions ># > >get_config() { > item="${1}" > > # First strip off comment lines, then grab the configuration > # item. If there's more than one of the same configuration item, > # then allow the last setting to take precedence. > cut -d'#' -f1-1 /etc/etc-update.conf | \ > sed -ne "s/^\ *${item}\ *=\ *\"\(.*\)\"/\1/p" | tail -1 >} > ># ># Ask which one of the given two files to install ># >rm_extra_file() { > old=$1 > new=$2 > > show_diff $old $new > menu1 > > # read and echo 1 char from stdin > read input > echo > case $input in > 1) > echo "*** upgrading to $new ..." > mv $mv_opts $new $old > ;; > 2) > echo "*** keeping $old ..." > rm $rm_opts $new > ;; > 3) > merge_files $old $new > install_merged_file $old $new > ;; > 4) > rm_extra_file $old $new > ;; > 5) > echo "*** skipping ..." > ;; > *) > echo "!!! Please pick a valid choice next time !!!" > menu1 > ;; > esac >} > ># ># Install merged file ># >install_merged_file() { > old=$1 > merged=$1.merged > new=$2 > > menu2 > # read and echo 1 char from stdin > read input > echo > case $input in > 1) > echo "*** upgrading to $merged ..." > mv $mv_opts $merged $old > rm $rm_opts $new > ;; > 2) > echo "*** keeping old file ..." > rm $rm_opts $merged $new > ;; > 3) > merge_files $old $new > install_merged_file $old $new > ;; > 4) > show_diff $old $merged > install_merged_file $old $new > ;; > 5) > echo "*** skipping ..." > ;; > 6) > echo "*** going back to previous menu ..." > echo > if [ -e $merged ]; then > echo "*** an (old?) merged file exists. It will be removed ..." > rm $rm_opts $merged > fi > rm_extra_file $old $new > ;; > *) > echo "!!! Please pick a valid choice next time !!!" > menu2 > ;; > esac >} > > ># ># Show menu1 ># >menu1() { > echo > echo > echo "1) Apply new file" > echo "2) Keep old file" > echo "3) Merge files" > echo "4) Show difference" > echo " OR" > echo "5) Skip (keep both files)" > echo > echo -n "Type (1, 2, 3, 4 or 5): " >} > ># ># Show menu2 ># >menu2() { > echo > echo > echo "1) Apply merged file" > echo "2) Keep old file" > echo "3) Redo merge" > echo "4) Show difference between old and merged file" > echo "5) Skip (keep all files)" > echo " OR" > echo "6) Back to previous menu" > echo > echo -n "Type (1, 2, 3, 4, 5 or 6): " >} > ># ># Show difference between two files ># >show_diff() { > echo > if [ "`echo ${pager}`" ]; then > (echo "*** showing difference between old and new ${1}" && echo && \ > `echo ${diff_command} | sed \ > -e s@%file1@${1}@g \ > -e s@%file2@${2}@g` ) | $pager > else > echo "*** showing difference between old and new ${1}" && echo > `echo ${diff_command} | sed \ > -e s@%file1@${1}@g \ > -e s@%file2@${2}@g` > fi >} > ># ># Merge two files ># >merge_files() { > old="${1}" > merged="${1}.merged" > new="${2}" > > echo > echo "*** merging ${old} with ${new} ..." > > if [ -e "${merged}" ]; then > echo > echo "*** a (old?) merged file already exists. It will be removed ..." > echo > rm $rm_opts "${merged}" > fi > > # execute the merge command > `echo ${merge_command} |sed \ > -e s@%merged@${merged}@g \ > -e s@%orig@${old}@g \ > -e s@%new@${new}@g` >} > ># ># Run the script ># >scriptname=`basename ${0}` > ># I need the CONFIG_PROTECT value >source /etc/make.globals > ># load etc-config's configuration >rm_opts=`get_config rm_opts` >mv_opts=`get_config mv_opts` >cp_opts=`get_config cp_opts` >pager=`get_config pager` >diff_command=`get_config diff_command` >merge_command=`get_config merge_command` > >#echo "rm_opts: $rm_opts, mv_opts: $mv_opts, cp_opts: $cp_opts" >#echo "pager: $pager, diff_command: $diff_command, merge_command: $merge_command" > ># ># Find all "new" configuration files, sort, so that ._cfg_0000 is presented ># before ._cfg_0001 ># >#set -o xtrace >for cfg_dir in ${CONFIG_PROTECT}; do > if [ -d "${cfg_dir}" ] ; then > cfg_files=`find "${cfg_dir}" -iname '._cfg????_*' | sort` > > if [ -z "${cfg_files}" ] ; then > echo "!!! No config files to update in ${cfg_dir}" > fi > > checklist_old="" # to contain existing files > checklist_new="" # to contain new files (the ._cfg????_* files) > > #TODO: remove older ._cfg????_* files. i.e. remove ._cfg0000_make.conf > # if ._cfg0001_make.conf exists > > for new_full_path in ${cfg_files}; do > file="${new_full_path##*/}" > old_full_path=${new_full_path%/*}/${file:10} > if [ -z "`diff ${old_full_path} ${new_full_path}`" ]; then > # new configfile is exactly the same as old > # configfile. Remove new configfile > echo "same file: ${old_full_path} and ${new_full_path}" > rm $rm_opts "${new_full_path}" > else > checklist_old="${checklist_old} ${old_full_path}" > checklist_new="${checklist_new} ${new_full_path}" > fi > done > > if [ ! -z "${checklist_old}" ]; then > echo "Files which need updating:" > echo "${checklist_old}" |sed -e 's@\ @\n@g' > echo "Press any key to continue ..." > read ANYKEY > fi > > for new_full_path in ${checklist_new}; do > file="${new_full_path##*/}" > old_full_path=${new_full_path%/*}/${file:10} > rm_extra_file ${old_full_path} ${new_full_path} > done > > else > echo "!!! Skipping non-existant directory ${cfg_dir}" > fi >done >echo "*** script finished ..."
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 3804
:
1565
| 1632 |
6790