]>
git.saurik.com Git - apt.git/blob - apt-private/private-main.cc
3 #include <apt-pkg/cmndline.h>
4 #include <apt-pkg/configuration.h>
5 #include <apt-pkg/fileutl.h>
6 #include <apt-pkg/strutl.h>
8 #include <apt-private/private-main.h>
20 void InitLocale(APT_CMD
const binary
) /*{{{*/
23 std::locale::global(std::locale(""));
25 setlocale(LC_ALL
, "");
30 case APT_CMD::APT_CACHE
:
31 case APT_CMD::APT_CDROM
:
32 case APT_CMD::APT_CONFIG
:
33 case APT_CMD::APT_DUMP_SOLVER
:
34 case APT_CMD::APT_HELPER
:
35 case APT_CMD::APT_GET
:
36 case APT_CMD::APT_MARK
:
39 case APT_CMD::APT_EXTRACTTEMPLATES
:
40 case APT_CMD::APT_FTPARCHIVE
:
41 case APT_CMD::APT_INTERNAL_PLANNER
:
42 case APT_CMD::APT_INTERNAL_SOLVER
:
43 case APT_CMD::APT_SORTPKG
:
44 textdomain("apt-utils");
50 void InitSignals() /*{{{*/
52 signal(SIGPIPE
,SIG_IGN
);
55 void CheckIfSimulateMode(CommandLine
&CmdL
) /*{{{*/
57 // disable locking in simulation, but show the message only for users
58 // as root hasn't the same problems like unreadable files which can heavily
59 // distort the simulation.
60 if (_config
->FindB("APT::Get::Simulate") == true &&
61 (CmdL
.FileSize() == 0 ||
62 (strcmp(CmdL
.FileList
[0], "source") != 0 && strcmp(CmdL
.FileList
[0], "download") != 0 &&
63 strcmp(CmdL
.FileList
[0], "changelog") != 0)))
65 if (getuid() != 0 && _config
->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
66 // TRANSLATORS: placeholder is a binary name like apt or apt-get
67 ioprintf(std::cout
, _("NOTE: This is only a simulation!\n"
68 " %s needs root privileges for real execution.\n"
69 " Keep also in mind that locking is deactivated,\n"
70 " so don't depend on the relevance to the real current situation!\n"),
71 _config
->Find("Binary").c_str());
72 _config
->Set("Debug::NoLocking",true);
76 void CheckIfCalledByScript(int argc
, const char *argv
[]) /*{{{*/
78 if (unlikely(argc
< 1)) return;
80 if(!isatty(STDOUT_FILENO
) &&
81 _config
->FindB("Apt::Cmd::Disable-Script-Warning", false) == false)
83 std::cerr
<< std::endl
84 << "WARNING: " << flNotDir(argv
[0]) << " "
85 << "does not have a stable CLI interface. "
86 << "Use with caution in scripts."