]> git.saurik.com Git - apt.git/blame - apt-private/private-sources.cc
Turkish program translation update
[apt.git] / apt-private / private-sources.cc
CommitLineData
453b82a3 1#include <config.h>
9e6b13f3
MV
2
3#include <apt-pkg/hashes.h>
453b82a3
DK
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>
10
11#include <apt-private/private-output.h>
12#include <apt-private/private-sources.h>
13#include <apt-private/private-utils.h>
9e6b13f3 14
453b82a3
DK
15#include <stddef.h>
16#include <unistd.h>
17#include <iostream>
18#include <string>
19
20#include <apti18n.h>
9e6b13f3 21
a8f671c1
MV
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
25*/
26
9e6b13f3
MV
27// EditSource - EditSourcesList /*{{{*/
28// ---------------------------------------------------------------------
29bool EditSources(CommandLine &CmdL)
30{
31 bool res;
32 pkgSourceList sl;
9e6b13f3 33
a8f671c1
MV
34 std::string sourceslist;
35 if (CmdL.FileList[1] != NULL)
cf993341
MV
36 {
37 sourceslist = _config->FindDir("Dir::Etc::sourceparts") + CmdL.FileList[1];
38 if (!APT::String::Endswith(sourceslist, ".list"))
39 sourceslist += ".list";
40 } else {
a8f671c1 41 sourceslist = _config->FindFile("Dir::Etc::sourcelist");
cf993341 42 }
9e6b13f3 43 HashString before;
a8f671c1
MV
44 if (FileExists(sourceslist))
45 before.FromFile(sourceslist);
9e6b13f3 46
c189f87d
MV
47 int lockfd = GetLock(sourceslist);
48 if (lockfd < 0)
49 return false;
fd789740 50
9e6b13f3
MV
51 do {
52 EditFileInSensibleEditor(sourceslist);
53 _error->PushToStack();
54 res = sl.Read(sourceslist);
55 if (!res) {
fd789740
DK
56 std::string outs;
57 strprintf(outs, _("Failed to parse %s. Edit again? "), sourceslist.c_str());
cf993341 58 // FIXME: should we add a "restore previous" option here?
fd789740 59 res = !YnPrompt(outs.c_str(), true);
9e6b13f3
MV
60 }
61 _error->RevertToStack();
62 } while (res == false);
c189f87d 63 close(lockfd);
9e6b13f3 64
a8f671c1 65 if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
fd789740
DK
66 ioprintf(
67 std::cout, _("Your '%s' file changed, please run 'apt-get update'."),
9e6b13f3 68 sourceslist.c_str());
9e6b13f3
MV
69 }
70
71 return true;
72}
73 /*}}}*/