Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 33698 - etc-update should backup configurationg files, not overwrite them
Summary: etc-update should backup configurationg files, not overwrite them
Status: RESOLVED INVALID
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
: 95244 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-17 12:04 UTC by Aaron Bennett
Modified: 2011-10-30 22:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Bennett 2003-11-17 12:04:46 UTC
Do a quick search on forums.gentoo.org.  You'll see a ton of people with borked
systems because they fat-fingered during an etc-update session.  (this usually
happens in conjunction with emerge -e world, which generates a zillion 'new'
configuration files that aren't really new).

It's inexcusable that etc-update overwrites files without preserving a backup copy.

Reproducible: Always
Steps to Reproduce:
1. emerge -e world
2. etc-update
3. hit the wrong keys a few times because there's 17 configuration files to go
through
4.  curse your fate

Actual Results:  
you get blown up!

Expected Results:  
make a backup copy, ideally with a date stamp or version number.

here's a trivial hack to etc-update that implements this:

bash-2.05b$ diff -u /usr/sbin/etc-update etc-update
--- /usr/sbin/etc-update        2003-10-22 09:04:51.000000000 -0400
+++ etc-update  2003-11-17 15:01:53.000000000 -0500
@@ -8,7 +8,7 @@
 # Leo Lipelis <aeoo@gentoo.org>
 # Karl Trygve Kalleberg <karltk@gentoo.org>
 #
-# $Header: /home/cvsroot/gentoo-src/portage/bin/etc-update,v 1.13 2003/08/04
15:21:15 aether Exp $
+# $Header: /usr/local/cvsroot/gentoo/etc-update,v 1.1 2003/11/17 16:07:47
abennett Exp $

 export PORTAGE_CALLER="etc-update"

@@ -255,15 +255,18 @@

                case ${my_input} in
                        1) echo "Replacing ${ofile} with ${file}"
+                          backup_file "$ofile"
                           mv ${mv_opts} ${file} ${ofile}
                           continue
                           ;;
                        2) echo "Deleting ${file}"
+                           backup_file "$ofile"
                           rm ${rm_opts} ${file}
                           continue
                           ;;
                        3) do_merge "${file}" "${ofile}"
-                          my_input=${?}
+                           backup_file "$ofile"
+                           my_input=${?}
 #                         [ ${my_input} == 255 ] && my_input=-1
                           continue
                           ;;
@@ -275,6 +278,12 @@
        done
 }

+function backup_file() {
+    local ofile="${1}"
+    local backup=.backup-${ofile}-$(date +%F+%R)
+    cp ${ofile} ${backup}
+}
+
 function do_merge() {

        local file="${1}"
Comment 1 SpanKY gentoo-dev 2003-11-17 12:22:55 UTC
theres a backup option already in /etc/dispatch-conf.conf
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2005-06-06 10:21:55 UTC
*** Bug 95244 has been marked as a duplicate of this bug. ***