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