From 3ee70c61924e65e3c4ef6bf0fa0673d2e866b042 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Mon, 5 Feb 2007 09:19:39 +0100 Subject: * write an empty default sources.list if all sources have been removed --- aptsources/sourceslist.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'aptsources/sourceslist.py') diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 14c2a0ea..e5b8dab9 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -342,6 +342,15 @@ class SourcesList: def save(self): """ save the current sources """ files = {} + # write an empty default config file if there aren't any sources + if len(self.list) == 0: + path = "%s%s" % (apt_pkg.Config.FindDir("Dir::Etc"), + apt_pkg.Config.Find("Dir::Etc::sourcelist")) + header = ("## See sources.list(5) for more information, especialy\n" + "# Remember that you can only use http, ftp or file URIs\n" + "# CDROMs are managed through the apt-cdrom tool.\n") + open(path,"w").write(header) + return for source in self.list: if not files.has_key(source.file): files[source.file]=open(source.file,"w") -- cgit v1.2.3