summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2005-07-27 08:08:05 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2005-07-27 08:08:05 +0000
commitf4f246d4a12ce137e1e73b8c0d590da3d9337b5f (patch)
tree87fe6a5fff61ba70a489710837010150c7d203b6 /perl-install
parent4cb36e102e377ddfd1cdd52d8edce3141518183e (diff)
downloaddrakx-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar
drakx-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar.gz
drakx-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar.bz2
drakx-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.tar.xz
drakx-f4f246d4a12ce137e1e73b8c0d590da3d9337b5f.zip
- Started implementation of configurable, partially interactive print
queue auto setup.
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer/detect.pm6
-rw-r--r--perl-install/printer/printerdrake.pm24
-rwxr-xr-xperl-install/standalone/autosetupprintqueues53
-rwxr-xr-xperl-install/standalone/printerdrake12
4 files changed, 71 insertions, 24 deletions
diff --git a/perl-install/printer/detect.pm b/perl-install/printer/detect.pm
index 065ac23e1..e114e00b5 100644
--- a/perl-install/printer/detect.pm
+++ b/perl-install/printer/detect.pm
@@ -8,9 +8,9 @@ use printer::data;
sub local_detect() {
modules::any_conf->read->get_probeall("usb-interface") and eval { modules::load($usbprintermodule) };
- # Reload parallel port modules only when we were not called from the
- # hotplug script, to avoid the hotplug script running recursively
- if (!$::noX) {
+ # Reload parallel port modules only when we were not called by
+ # automatic setup of print queues, to avoid recursive calls
+ if (!$::autoqueue) {
eval { modules::unload(qw(lp parport_pc parport)) }; #- on kernel 2.4 parport has to be unloaded to probe again
eval { modules::load(qw(parport_pc lp)) }; #- take care as not available on 2.4 kernel (silent error).
}
diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm
index 33bb7dbb4..ab1cc4510 100644
--- a/perl-install/printer/printerdrake.pm
+++ b/perl-install/printer/printerdrake.pm
@@ -678,6 +678,10 @@ sub first_time_dialog {
return 1 if printer::default::get_spooler() || $::isInstall;
my $w = $in->wait_message(N("Printerdrake"), N("Checking your system..."));
+ # Now, where the first-time dialog will be displayed, all subsequent
+ # wait messages should be displayed, also if we are in GUI auto queue
+ # setup mode
+ undef $::autoqueue;
# Auto-detect local printers
my @autodetected = printer::detect::local_detect();
@@ -763,13 +767,11 @@ sub configure_new_printers {
# there is already a queue for them. If there is no queue for an
# auto-detected printer, a queue gets set up non-interactively.
- # Experts can have weird things as self-made CUPS backends, so do not
- # automatically pollute the system with unwished queues in expert
- # mode
- return 1 if $printer->{expert};
+ # Stop here if auto queue setup is not selected
+ return 1 if !($printer->{autoqueuesetuponstart} || $::autoqueue);
# Wait message
- my $w = $::noX ||
+ my $w = $::noX || $::autoqueue ||
$in->wait_message(N("Printerdrake"),
N("Searching for new printers..."));
@@ -780,7 +782,7 @@ sub configure_new_printers {
# kernel modules and causes a new hotplug signal which leads to
# recursive calls of the hotplug script.
require services;
- services::stop("hpoj") if !$::noX;
+ services::stop("hpoj") if !$::noX && !$::autoqueue;
# Auto-detect local printers
my @autodetected = printer::detect::local_detect();
@@ -788,7 +790,7 @@ sub configure_new_printers {
# We are ready with auto-detection, so we restart HPOJ here. If it
# is not installed or not configured, this command has no effect.
- services::start("hpoj") if !$::noX;
+ services::start("hpoj") if !$::noX && !$::autoqueue;
# No printer found? So no need of new queues.
return 1 if !@autodetected;
@@ -4293,7 +4295,7 @@ sub install_spooler {
return 0 unless security_check($spooler, $security, $o_in);
# should not happen
return 0 if $spooler !~ /^(rcups|cups|lpd|lprng|pqd)$/;
- my $w = $o_in && $o_in->wait_message(N("Printerdrake"), N("Checking installed software..."));
+ my $w = $::noX || $::autoqueue || ($o_in && $o_in->wait_message(N("Printerdrake"), N("Checking installed software...")));
# "lpr" conflicts with "LPRng", remove either "LPRng" or remove "lpr"
my $packages = $spoolers{$spooler}{packages2rm};
@@ -4429,7 +4431,7 @@ sub assure_default_printer_is_set {
my ($printer, $in) = @_;
if (defined($printer->{SPOOLER}) && $printer->{SPOOLER} &&
(!defined($printer->{DEFAULT}) || !$printer->{DEFAULT})) {
- my $_w = $::noX ||
+ my $_w = $::noX || $::autoqueue ||
$in->wait_message(N("Printerdrake"),
N("Setting Default Printer..."));
$printer->{DEFAULT} = printer::default::get_printer($printer);
@@ -4686,7 +4688,7 @@ sub init {
# installation of print it should not be asked for the spooler,
# as this feature is only supported for CUPS.
$printer->{SPOOLER} ||= 'cups'
- if (!$printer->{expert} || $::noX) && !$::isInstall;
+ if (!$printer->{expert} || $::noX || $::autoqueue) && !$::isInstall;
# If we have chosen a spooler, install it and mark it as default
# spooler. Spooler installation is ommitted on background queue
@@ -4695,7 +4697,7 @@ sub init {
return 0 unless ($::noX ||
install_spooler($printer, $security, $in->do_pkgs, $in, $upNetwork));
assure_remote_server_is_set($printer, $in)
- if ($printer->{SPOOLER} eq "rcups") && !$::noX;
+ if ($printer->{SPOOLER} eq "rcups") && !$::noX && !$::autoqueue;
printer::main::read_configured_queues($printer)
if (($printer->{SPOOLER} ne "rcups") &&
(keys(%{$printer->{configured}}) == 0));
diff --git a/perl-install/standalone/autosetupprintqueues b/perl-install/standalone/autosetupprintqueues
index 3b72980f7..c8c3d54fd 100755
--- a/perl-install/standalone/autosetupprintqueues
+++ b/perl-install/standalone/autosetupprintqueues
@@ -24,25 +24,62 @@ use standalone;
use printer::printerdrake;
use printer::main;
+# Read mode in which we will run
+my $commandline = join('', @ARGV);
+$commandline =~ /-(auto|nogui|gui|waitforgui)\b/;
+my $gui = $1;
+$gui ||= "auto";
+
+if ($gui ne "nogui") {
+ # Auto-detect whether we go in non-X mode or not
+ my $desktopuser = `cat /var/run/console.lock`;
+ if (!$desktopuser) {
+ if ($gui eq "auto") {
+ # Non-X mode
+ $gui = "nogui";
+ } elsif ($gui eq "waitforgui") {
+ # Wait until a user logs in on the system's X console
+ while (!($desktopuser = `cat /var/run/console.lock`)) {
+ sleep(5);
+ }
+ # Wait for the window manager to start
+ sleep(10);
+ $gui = "gui";
+ } else {
+ # "gui" was requested but no user logged in
+ die "Cannot start in '--gui' mode, no user logged in!\n";
+ }
+ } else {
+ # X mode (a user is logged in)
+ $gui = "gui";
+ }
+
+ if ($gui eq "gui") {
+ # Allow root's windows to be opened on the user's display and
+ # start printerdrake then, in a mode to do nothing else than
+ # automatically setting up print queues.
+ system "export DISPLAY=\"localhost:0.0\"; USER=$desktopuser; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost +localhost > /tmp/pderror 2>&1\"; /usr/sbin/printerdrake --onlyautoqueue >> /tmp/pderror 2>&1; /bin/su $desktopuser -c \"/usr/X11R6/bin/xhost -localhost >> /tmp/pderror 2>&1\"";
+ exit 0;
+ }
+}
+
# Data structure for printer data
my $printer;
-# Dummy variable needed to call the subroutines of the printerdrak.pm module
-# The real data structure is not needed for non-interactive mode
+# Dummy variable needed to call the subroutines of the printerdrake.pm
+# module. The real data structure is not needed for non-interactive
+# non-X mode
my $in;
# Run the subroutines of printerdrake.pm in non-interactive non-X mode
$::noX = 1;
+# Subroutines of printerdrake.pm used for automatic setup of print queues
+$::autoqueue = 1;
+
# Do not let printerdrake ask for the spooler
$printer->{SPOOLER} ||= 'cups';
-# Were we in expert mode last time?
-$printer->{expert} = printer::main::get_usermode();
-
-# Do not auto-install queues in expert mode
-exit 0 if $printer->{expert};
-
# Get info about already installed print queues
eval { $printer = printer::main::getinfo('') };
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index be0716c79..2c4cc8eb2 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -57,6 +57,10 @@ my $in = 'interactive'->vnew('su', if_(!$::isEmbedded, 'printer-mdk'));
my $commandline = $_;
+# Suppress some wait messages to avoid windows popping up if no new print
+# queue has to be set up
+$commandline =~ /-onlyautoqueue/ and $::autoqueue = 1;
+
# Data structure for GTK2 main window
my $us = {};
$us->{VERSION} = '10.2';
@@ -64,8 +68,9 @@ $us->{VERSION} = '10.2';
# Check whether Foomatic is installed and install it if necessary
#printer::printerdrake::install_foomatic($in);
-my $w = $in->wait_message(N("Printerdrake"),
- N("Reading data of installed printers..."));
+my $w = $::autoqueue ||
+ $in->wait_message(N("Printerdrake"),
+ N("Reading data of installed printers..."));
# Get what was installed before
eval { $printer = printer::main::getinfo('') };
@@ -107,6 +112,9 @@ $printer->{SPOOLER} ||= 'cups';
# Initialization
printer::printerdrake::init($printer, $security, $in, undef);
+# Stop here when we are supposed to only automatically set up print queues
+$commandline =~ /-onlyautoqueue/ and exit 0;
+
# GTK2 main window
my $stringsearch = '';