aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2015-08-09 13:56:22 -0400
committerAnthony G. Basile <blueness@gentoo.org>2015-08-09 13:56:22 -0400
commit38903acaed401c1a5daba418172eacf052cc2435 (patch)
tree182a2ac29ce54eb6b23551148558803f825850c5
parentbin/grsup: fix bugs. (diff)
downloadgrss-38903acaed401c1a5daba418172eacf052cc2435.tar.gz
grss-38903acaed401c1a5daba418172eacf052cc2435.tar.bz2
grss-38903acaed401c1a5daba418172eacf052cc2435.zip
bin/grsup: backup old make.conf if clobbering.
-rwxr-xr-xbin/grsup17
1 files changed, 14 insertions, 3 deletions
diff --git a/bin/grsup b/bin/grsup
index 5e0a70c..d722edb 100755
--- a/bin/grsup
+++ b/bin/grsup
@@ -211,8 +211,10 @@ def main():
# If a raw new make.conf exists, pick it, else pick the highest cycle no.
newmakeconf = os.path.join(libdir, 'core/etc/portage/make.conf')
oldmakeconf = os.path.join(CONST.PORTAGE_CONFIGDIR, 'make.conf')
+
+ do_copy = False
if os.path.isfile(newmakeconf):
- shutil.copy(newmakeconf, oldmakeconf)
+ do_copy = True
else:
cycled_files = {}
for f in glob.glob('%s.*' % newmakeconf):
@@ -222,10 +224,19 @@ def main():
cycled_files[cycle_no] = m.group(0)
try:
max_cycle_no = max(cycled_files)
- shutil.copy(cycled_files[max_cycle_no], oldmakeconf)
- except ValueError:
+ newmakeconf = cycled_files[max_cycle_no]
+ do_copy = True
+ except ValueError: # thrown by max() if cycled_files is empty
pass
+ if do_copy:
+ if os.path.isfile(oldmakeconf):
+ if not filecmp.cmp(newmakeconf, oldmakeconf):
+ print('New make.conf differs from local version. Backing up as make.conf.old')
+ shutil(oldmakeconf, '%s.old' % oldmakeconf)
+ shutil.copy(newmakeconf, oldmakeconf)
+
+ # Check if we left behind a dirty /etc/portage
if os.path.isfile(CONST.PORTAGE_DIRTYFILE):
WorldConf.clean()
open(CONST.PORTAGE_DIRTYFILE, 'a').close()