]>
git.saurik.com Git - apt.git/blob - apt-private/private-sources.cc
2 #include <apt-pkg/hashes.h>
5 #include "private-output.h"
6 #include "private-sources.h"
7 #include "private-utils.h"
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
14 // EditSource - EditSourcesList /*{{{*/
15 // ---------------------------------------------------------------------
16 bool EditSources(CommandLine
&CmdL
)
22 std::string sourceslist
;
23 if (CmdL
.FileList
[1] != NULL
)
25 sourceslist
= _config
->FindDir("Dir::Etc::sourceparts") + CmdL
.FileList
[1];
26 if (!APT::String::Endswith(sourceslist
, ".list"))
27 sourceslist
+= ".list";
29 sourceslist
= _config
->FindFile("Dir::Etc::sourcelist");
32 if (FileExists(sourceslist
))
33 before
.FromFile(sourceslist
);
35 int lockfd
= GetLock(sourceslist
);
40 EditFileInSensibleEditor(sourceslist
);
41 _error
->PushToStack();
42 res
= sl
.Read(sourceslist
);
45 strprintf(outs
, _("Failed to parse %s. Edit again? "),
48 // FIXME: should we add a "restore previous" option here?
49 res
= !YnPrompt(true);
51 _error
->RevertToStack();
52 } while (res
== false);
55 if (FileExists(sourceslist
) && !before
.VerifyFile(sourceslist
)) {
57 outs
, _("Your '%s' file changed, please run 'apt-get update'."),
59 std::cout
<< outs
<< std::endl
;