]>
Commit | Line | Data |
---|---|---|
9e6b13f3 MV |
1 | |
2 | #include <apt-pkg/hashes.h> | |
3 | #include <apti18n.h> | |
4 | ||
5 | #include "private-output.h" | |
6 | #include "private-sources.h" | |
7 | #include "private-utils.h" | |
8 | ||
a8f671c1 MV |
9 | /* Interface discussion with donkult (for the future): |
10 | apt [add-{archive,release,component}|edit|change-release|disable]-sources | |
11 | and be clever and work out stuff from the Release file | |
12 | */ | |
13 | ||
9e6b13f3 MV |
14 | // EditSource - EditSourcesList /*{{{*/ |
15 | // --------------------------------------------------------------------- | |
16 | bool EditSources(CommandLine &CmdL) | |
17 | { | |
18 | bool res; | |
19 | pkgSourceList sl; | |
20 | std::string outs; | |
21 | ||
a8f671c1 MV |
22 | std::string sourceslist; |
23 | if (CmdL.FileList[1] != NULL) | |
cf993341 MV |
24 | { |
25 | sourceslist = _config->FindDir("Dir::Etc::sourceparts") + CmdL.FileList[1]; | |
26 | if (!APT::String::Endswith(sourceslist, ".list")) | |
27 | sourceslist += ".list"; | |
28 | } else { | |
a8f671c1 | 29 | sourceslist = _config->FindFile("Dir::Etc::sourcelist"); |
cf993341 | 30 | } |
9e6b13f3 | 31 | HashString before; |
a8f671c1 MV |
32 | if (FileExists(sourceslist)) |
33 | before.FromFile(sourceslist); | |
9e6b13f3 MV |
34 | |
35 | do { | |
36 | EditFileInSensibleEditor(sourceslist); | |
37 | _error->PushToStack(); | |
38 | res = sl.Read(sourceslist); | |
39 | if (!res) { | |
a8f671c1 | 40 | _error->DumpErrors(); |
9e6b13f3 MV |
41 | strprintf(outs, _("Failed to parse %s. Edit again? "), |
42 | sourceslist.c_str()); | |
43 | std::cout << outs; | |
cf993341 | 44 | // FIXME: should we add a "restore previous" option here? |
9e6b13f3 MV |
45 | res = !YnPrompt(true); |
46 | } | |
47 | _error->RevertToStack(); | |
48 | } while (res == false); | |
49 | ||
a8f671c1 | 50 | if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) { |
9e6b13f3 MV |
51 | strprintf( |
52 | outs, _("Your '%s' file changed, please run 'apt-get update'."), | |
53 | sourceslist.c_str()); | |
54 | std::cout << outs << std::endl; | |
55 | } | |
56 | ||
57 | return true; | |
58 | } | |
59 | /*}}}*/ |