]> git.saurik.com Git - apt.git/blob - apt-private/private-main.cc
0a9f4713fcd8c9b1fafd845440a13eef0e46259c
[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() /*{{{*/
20 {
21 std::locale::global(std::locale(""));
22 textdomain(PACKAGE);
23 }
24 /*}}}*/
25 void InitSignals() /*{{{*/
26 {
27 signal(SIGPIPE,SIG_IGN);
28 }
29 /*}}}*/
30 void CheckIfSimulateMode(CommandLine &CmdL) /*{{{*/
31 {
32 // disable locking in simulation, but show the message only for users
33 // as root hasn't the same problems like unreadable files which can heavily
34 // distort the simulation.
35 if (_config->FindB("APT::Get::Simulate") == true &&
36 (CmdL.FileSize() == 0 ||
37 (strcmp(CmdL.FileList[0], "source") != 0 && strcmp(CmdL.FileList[0], "download") != 0 &&
38 strcmp(CmdL.FileList[0], "changelog") != 0)))
39 {
40 if (getuid() != 0 && _config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
41 std::cout << _("NOTE: This is only a simulation!\n"
42 " apt-get needs root privileges for real execution.\n"
43 " Keep also in mind that locking is deactivated,\n"
44 " so don't depend on the relevance to the real current situation!"
45 ) << std::endl;
46 _config->Set("Debug::NoLocking",true);
47 }
48 }
49 /*}}}*/
50 void CheckIfCalledByScript(int argc, const char *argv[]) /*{{{*/
51 {
52 if (unlikely(argc < 1)) return;
53
54 if(!isatty(STDOUT_FILENO) &&
55 _config->FindB("Apt::Cmd::Disable-Script-Warning", false) == false)
56 {
57 std::cerr << std::endl
58 << "WARNING: " << flNotDir(argv[0]) << " "
59 << "does not have a stable CLI interface. "
60 << "Use with caution in scripts."
61 << std::endl
62 << std::endl;
63 }
64 }
65 /*}}}*/