]>
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
)
35 std::string sourceslist
;
36 if (CmdL
.FileList
[1] != NULL
)
38 sourceslist
= _config
->FindDir("Dir::Etc::sourceparts") + CmdL
.FileList
[1];
39 if (!APT::String::Endswith(sourceslist
, ".list"))
40 sourceslist
+= ".list";
42 sourceslist
= _config
->FindFile("Dir::Etc::sourcelist");
45 if (FileExists(sourceslist
))
46 before
.FromFile(sourceslist
);
48 int lockfd
= GetLock(sourceslist
);
53 EditFileInSensibleEditor(sourceslist
);
54 _error
->PushToStack();
55 res
= sl
.Read(sourceslist
);
58 strprintf(outs
, _("Failed to parse %s. Edit again? "),
61 // FIXME: should we add a "restore previous" option here?
62 res
= !YnPrompt(true);
64 _error
->RevertToStack();
65 } while (res
== false);
68 if (FileExists(sourceslist
) && !before
.VerifyFile(sourceslist
)) {
70 outs
, _("Your '%s' file changed, please run 'apt-get update'."),
72 std::cout
<< outs
<< std::endl
;