summaryrefslogtreecommitdiff
path: root/SoftwareProperties
diff options
context:
space:
mode:
authorMichael Vogt <egon@top>2005-12-05 16:14:53 +0100
committerMichael Vogt <egon@top>2005-12-05 16:14:53 +0100
commit66ba55b25018996af69e2a50d0623fd6893b7a61 (patch)
tree54921477011015f10fd157d9616a6d103ae5c5c4 /SoftwareProperties
parenta0ee71f0b7268127ec6da4ca22f002775aba64c0 (diff)
downloadpython-apt-66ba55b25018996af69e2a50d0623fd6893b7a61.tar.gz
* sources.list does a proper backup now
Diffstat (limited to 'SoftwareProperties')
-rw-r--r--SoftwareProperties/aptsources.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index e23a0007..540bb801 100644
--- a/SoftwareProperties/aptsources.py
+++ b/SoftwareProperties/aptsources.py
@@ -28,6 +28,7 @@ import apt_pkg
import glob
import shutil
import time
+import os.path
from UpdateManager.Common.DistInfo import DistInfo
@@ -223,6 +224,18 @@ class SourcesList:
def remove(self, source_entry):
self.list.remove(source_entry)
+ def restoreBackup(self, backup_ext):
+ " restore sources.list files based on the backup extension "
+ dir = apt_pkg.Config.FindDir("Dir::Etc")
+ file = apt_pkg.Config.Find("Dir::Etc::sourcelist")
+ if os.path.exists(dir+file+backup_ext):
+ shutil.copy(dir+file+backup_ext,dir+file)
+ # now sources.list.d
+ partsdir = apt_pkg.Config.FindDir("Dir::Etc::sourceparts")
+ for file in glob.glob("%s/*.list" % partsdir):
+ if os.path.exists(file+backup_ext):
+ shutil.copy(file+backup_ext,file)
+
def backup(self, backup_ext=None):
""" make a backup of the current source files, if no backup extension
is given, the current date/time is used (and returned) """
@@ -231,7 +244,7 @@ class SourcesList:
backup_ext = time.strftime("%y%m%d.%H%M")
for source in self.list:
if not source.file in already_backuped:
- shutil.copy(source.file,"%s.%s" % (source.file,backup_ext))
+ shutil.copy(source.file,"%s%s" % (source.file,backup_ext))
return backup_ext
def load(self,file):