diff options
| -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") |
