]>
git.saurik.com Git - apt.git/blob - apt-private/private-sources.cc
3 #include <apt-pkg/hashes.h>
4 #include <apt-pkg/strutl.h>
5 #include <apt-pkg/configuration.h>
6 #include <apt-pkg/sourcelist.h>
7 #include <apt-pkg/cmndline.h>
8 #include <apt-pkg/error.h>
9 #include <apt-pkg/fileutl.h>
11 #include <apt-private/private-output.h>
12 #include <apt-private/private-sources.h>
13 #include <apt-private/private-utils.h>
22 /* Interface discussion with donkult (for the future):
23 apt [add-{archive,release,component}|edit|change-release|disable]-sources
24 and be clever and work out stuff from the Release file
27 // EditSource - EditSourcesList /*{{{*/
28 // ---------------------------------------------------------------------
29 bool EditSources(CommandLine
&CmdL
)
34 std::string sourceslist
;
35 if (CmdL
.FileList
[1] != NULL
)
37 sourceslist
= _config
->FindDir("Dir::Etc::sourceparts") + CmdL
.FileList
[1];
38 if (!APT::String::Endswith(sourceslist
, ".list"))
39 sourceslist
+= ".list";
41 sourceslist
= _config
->FindFile("Dir::Etc::sourcelist");
44 if (FileExists(sourceslist
))
45 before
.FromFile(sourceslist
);
47 int lockfd
= GetLock(sourceslist
);
52 EditFileInSensibleEditor(sourceslist
);
53 _error
->PushToStack();
54 res
= sl
.Read(sourceslist
);
57 strprintf(outs
, _("Failed to parse %s. Edit again? "), sourceslist
.c_str());
58 // FIXME: should we add a "restore previous" option here?
59 res
= !YnPrompt(outs
.c_str(), true);
61 _error
->RevertToStack();
62 } while (res
== false);
65 if (FileExists(sourceslist
) && !before
.VerifyFile(sourceslist
)) {
67 std::cout
, _("Your '%s' file changed, please run 'apt-get update'."),