diff options
| author | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-02-24 18:16:52 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-02-24 18:16:52 +0100 |
| commit | 52c686391e543bbc1084ec15f40abe8e58b1d514 (patch) | |
| tree | c662ba4d1acf5f2d7f68e917145aa20ce6df9c81 | |
| parent | 8cfca4a5ed2b0fd1ef52b645eedbce3c64e03c6b (diff) | |
| download | python-apt-52c686391e543bbc1084ec15f40abe8e58b1d514.tar.gz | |
* Remove all obsolete backup files before backup
| -rw-r--r-- | SoftwareProperties/SoftwareProperties.py | 1 | ||||
| -rw-r--r-- | SoftwareProperties/aptsources.py | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index f6977275..250e2c1d 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -377,6 +377,7 @@ class SoftwareProperties(SimpleGladeApp): def save_sourceslist(self): #location = "/etc/apt/sources.list" #shutil.copy(location, location + ".save") + self.sourceslist.clearBackup(".save") self.sourceslist.backup(".save") self.sourceslist.save() diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py index 604af097..397ebb38 100644 --- a/SoftwareProperties/aptsources.py +++ b/SoftwareProperties/aptsources.py @@ -314,6 +314,18 @@ class SourcesList: def remove(self, source_entry): self.list.remove(source_entry) + def clearBackup(self, backup_ext): + " remove backuped 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): + os.remove(dir+file+backup_ext) + # 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): + os.remove(file+backup_ext) + def restoreBackup(self, backup_ext): " restore sources.list files based on the backup extension " dir = apt_pkg.Config.FindDir("Dir::Etc") |
