]> git.saurik.com Git - apt.git/blame - apt-private/private-main.cc
use pkgCache::VS instead of pkgDepCache::VS()
[apt.git] / apt-private / private-main.cc
CommitLineData
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>
10#include <string.h>
11#include <unistd.h>
3163087b 12#include <signal.h>
b9179170
MV
13
14#include <apti18n.h>
15
3163087b 16
e7e10e47
DK
17void InitLocale() /*{{{*/
18{
19 setlocale(LC_ALL,"");
20 textdomain(PACKAGE);
21}
22 /*}}}*/
23void InitSignals() /*{{{*/
3163087b 24{
3163087b
MV
25 signal(SIGPIPE,SIG_IGN);
26}
e7e10e47
DK
27 /*}}}*/
28void CheckIfSimulateMode(CommandLine &CmdL) /*{{{*/
b9179170 29{
0d5b9da9
DK
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 &&
b9179170
MV
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 {
0d5b9da9 38 if (getuid() != 0 && _config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
b9179170
MV
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}
e7e10e47
DK
47 /*}}}*/
48void 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 /*}}}*/