]>
Commit | Line | Data |
---|---|---|
453b82a3 | 1 | #include <config.h> |
b9179170 | 2 | |
453b82a3 | 3 | #include <apt-pkg/cmndline.h> |
b9179170 | 4 | #include <apt-pkg/configuration.h> |
e7e10e47 | 5 | #include <apt-pkg/fileutl.h> |
453b82a3 DK |
6 | |
7 | #include <apt-private/private-main.h> | |
8 | ||
9 | #include <iostream> | |
8b79c94a DK |
10 | #include <locale> |
11 | ||
453b82a3 DK |
12 | #include <string.h> |
13 | #include <unistd.h> | |
3163087b | 14 | #include <signal.h> |
b9179170 MV |
15 | |
16 | #include <apti18n.h> | |
17 | ||
3163087b | 18 | |
570ec96d | 19 | void InitLocale(APT_CMD const binary) /*{{{*/ |
e7e10e47 | 20 | { |
62600666 DK |
21 | try { |
22 | std::locale::global(std::locale("")); | |
23 | } catch (...) { | |
24 | setlocale(LC_ALL, ""); | |
25 | } | |
570ec96d DK |
26 | switch(binary) |
27 | { | |
28 | case APT_CMD::APT: | |
29 | case APT_CMD::APT_CACHE: | |
30 | case APT_CMD::APT_CDROM: | |
31 | case APT_CMD::APT_CONFIG: | |
ab07af70 | 32 | case APT_CMD::APT_DUMP_SOLVER: |
570ec96d DK |
33 | case APT_CMD::APT_HELPER: |
34 | case APT_CMD::APT_GET: | |
35 | case APT_CMD::APT_MARK: | |
36 | textdomain("apt"); | |
37 | break; | |
38 | case APT_CMD::APT_EXTRACTTEMPLATES: | |
39 | case APT_CMD::APT_FTPARCHIVE: | |
40 | case APT_CMD::APT_INTERNAL_SOLVER: | |
41 | case APT_CMD::APT_SORTPKG: | |
42 | textdomain("apt-utils"); | |
43 | break; | |
44 | } | |
e7e10e47 | 45 | } |
570ec96d | 46 | void InitLocale() {} |
e7e10e47 DK |
47 | /*}}}*/ |
48 | void InitSignals() /*{{{*/ | |
3163087b | 49 | { |
3163087b MV |
50 | signal(SIGPIPE,SIG_IGN); |
51 | } | |
e7e10e47 DK |
52 | /*}}}*/ |
53 | void CheckIfSimulateMode(CommandLine &CmdL) /*{{{*/ | |
b9179170 | 54 | { |
0d5b9da9 DK |
55 | // disable locking in simulation, but show the message only for users |
56 | // as root hasn't the same problems like unreadable files which can heavily | |
57 | // distort the simulation. | |
58 | if (_config->FindB("APT::Get::Simulate") == true && | |
b9179170 MV |
59 | (CmdL.FileSize() == 0 || |
60 | (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 && | |
61 | strcmp(CmdL.FileList[0], "changelog") != 0))) | |
62 | { | |
0d5b9da9 | 63 | if (getuid() != 0 && _config->FindB("APT::Get::Show-User-Simulation-Note",true) == true) |
b9179170 MV |
64 | std::cout << _("NOTE: This is only a simulation!\n" |
65 | " apt-get needs root privileges for real execution.\n" | |
66 | " Keep also in mind that locking is deactivated,\n" | |
67 | " so don't depend on the relevance to the real current situation!" | |
68 | ) << std::endl; | |
69 | _config->Set("Debug::NoLocking",true); | |
70 | } | |
71 | } | |
e7e10e47 DK |
72 | /*}}}*/ |
73 | void CheckIfCalledByScript(int argc, const char *argv[]) /*{{{*/ | |
74 | { | |
75 | if (unlikely(argc < 1)) return; | |
76 | ||
77 | if(!isatty(STDOUT_FILENO) && | |
78 | _config->FindB("Apt::Cmd::Disable-Script-Warning", false) == false) | |
79 | { | |
80 | std::cerr << std::endl | |
81 | << "WARNING: " << flNotDir(argv[0]) << " " | |
82 | << "does not have a stable CLI interface. " | |
83 | << "Use with caution in scripts." | |
84 | << std::endl | |
85 | << std::endl; | |
86 | } | |
87 | } | |
88 | /*}}}*/ |