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