Hello developers,

this has annoyed me for a long time.

restore_config() dies when it cannot find a saved config file, while
later on in any ebuild that uses savedconfig.eclass, it will save the
config file anyhow. That means it will not use an edited saved config
file during the first emerge, which is to be expected and should not be
fatal.

The current forces you to emerge the same ebuild twice using _different_
USE flags to achieve anything:

1. USE="-savedconfig" emerge cat/foo
2. $EDITOR /etc/portage/savedconfig/cat/foo
3. USE="savedconfig" emerge cat/foo

This is quite illogical.

With the patch applied it should be enough to set USE=savedconfig
globally, run `emerge foo', edit the saved config file(s) and run
`emerge foo' again, without having to change the USE flag:

0. euse -E savedconfig # Set USE=savedconfig globally
1. emerge cat/foo
2. $EDITOR /etc/portage/savedconfig/cat/foo
3. emerge cat/foo
4. Profit!

The attached patch actually accomplishes two things:

1) It removes some old code[1] in an elif that apparently never gets
executed (or we would have seen bash syntax bugs filed loooong ago).
2) It makes restore_config non-fatal on the first emerge with
USE=savedconfig.

If no one objects, I will look forward to committing the patch in a
week or two.


Regards,
     jer


[1] Already present in the first commit.
Index: savedconfig.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/savedconfig.eclass,v
retrieving revision 1.12
diff -u -B -r1.12 savedconfig.eclass
--- savedconfig.eclass	30 Oct 2009 16:46:41 -0000	1.12
+++ savedconfig.eclass	24 Feb 2010 16:52:07 -0000
@@ -111,16 +111,14 @@
 		pushd "${found}" > /dev/null
 		treecopy . "${dest}" || die "Failed to restore ${found} to $1"
 		popd > /dev/null
-	elif [[ -a {found} ]]; then
-		die "do not know how to handle non-file/directory ${found}"
 	else
 		# maybe the user is screwing around with perms they shouldnt #289168
 		if [[ ! -r ${base} ]] ; then
 			eerror "Unable to read ${base} -- perms are screwed ?"
 			die "fix your system"
 		fi
-		eerror "No saved config to restore - please remove USE=savedconfig or"
-		eerror "provide a configuration file in ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN}"
-		die "config file needed when USE=savedconfig is specified"
+		ewarn "No saved config to restore - please remove USE=savedconfig or"
+		ewarn "provide a configuration file in ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/${CATEGORY}/${PN}"
+		ewarn "Your config file(s) will not be used this time"
 	fi
 }

Reply via email to