diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/printer/main.pm | 54 | ||||
-rw-r--r-- | perl-install/printer/office.pm | 31 |
2 files changed, 34 insertions, 51 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index d66b41385..757cf35f9 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -1542,24 +1542,19 @@ sub config_sane { sub config_photocard { # Add definitions for the drives p:. q:, r:, and s: to /etc/mtools.conf - my $mtoolsconf = join("", cat_("$::prefix/etc/mtools.conf")); - return if $mtoolsconf =~ m/^\s*drive\s+p:/m; - my $mtoolsconf_append = " + cat_("$::prefix/etc/mtools.conf") !~ m/^\s*drive\s+p:/m or return; + + append_to_file("$::prefix/etc/mtools.conf", <<'EOF'); # Drive definitions added for the photo card readers in HP multi-function # devices driven by HPOJ -drive p: file=\":0\" remote -drive q: file=\":1\" remote -drive r: file=\":2\" remote -drive s: file=\":3\" remote +drive p: file=":0" remote +drive q: file=":1" remote +drive r: file=":2" remote +drive s: file=":3" remote # This turns off some file system integrity checks of mtools, it is needed # for some photo cards. mtools_skip_check=1 -"; - local *F; - open F, ">> $::prefix/etc/mtools.conf" or - die "can't write mtools config in /etc/mtools.conf: $!"; - print F $mtoolsconf_append; - close F; +EOF # Generate a config file for the graphical mtools frontend MToolsFM or # modify the existing one @@ -1574,22 +1569,23 @@ mtools_skip_check=1 $mtoolsfmconf =~ s/^\s*DRIVES\s*=\s*\"[A-Za-z ]*\"/DRIVES=\"$alloweddrives\"/m; $mtoolsfmconf =~ s/^\s*LEFTDRIVE\s*=\s*\"[^\"]*\"/LEFTDRIVE=\"p\"/m; } else { - $mtoolsfmconf = "\# MToolsFM config file. comments start with a hash sign. -\# -\# This variable sets the allowed driveletters (all lowercase). Example: -\# DRIVES=\"ab\" -DRIVES=\"apqrs\" -\# -\# This variable sets the driveletter upon startup in the left window. -\# An empty string or space is for the hardisk. Example: -\# LEFTDRIVE=\"a\" -LEFTDRIVE=\"p\" -\# -\# This variable sets the driveletter upon startup in the right window. -\# An empty string or space is for the hardisk. Example: -\# RIGHTDRIVE=\"a\" -RIGHTDRIVE=\" \" -"; + $mtoolsfmconf = <<'EOF'; +# MToolsFM config file. comments start with a hash sign. +# +# This variable sets the allowed driveletters (all lowercase). Example: +# DRIVES="ab" +DRIVES="apqrs" +# +# This variable sets the driveletter upon startup in the left window. +# An empty string or space is for the hardisk. Example: +# LEFTDRIVE="a" +LEFTDRIVE="p" +# +# This variable sets the driveletter upon startup in the right window. +# An empty string or space is for the hardisk. Example: +# RIGHTDRIVE="a" +RIGHTDRIVE=" " +EOF } output("$::prefix/etc/mtoolsfm.conf", $mtoolsfmconf); } diff --git a/perl-install/printer/office.pm b/perl-install/printer/office.pm index 459ae4d8e..48bfe52f5 100644 --- a/perl-install/printer/office.pm +++ b/perl-install/printer/office.pm @@ -45,7 +45,7 @@ sub configureoffice { $configfilename =~ m!$suites{$suite}{file_name}!; my $configprefix = $1; # Load Star Office printer config file - my $configfilecontent = readsofficeconfigfile($configfilename); + my $configfilecontent = cat_("$::prefix$configfilename"); # Update remote CUPS queues if (0 && $printer->{SPOOLER} eq "cups" && (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { @@ -100,7 +100,7 @@ sub configureoffice { $configfilecontent = removeentry(@parameters, $configfilecontent); $configfilecontent = addentry($parameters[0], $parameters[1] . $suites{$suite}{perl} . $spoolers{$printer->{SPOOLER}{print_command}}, $configfilecontent); # Write back Star Office configuration file - return writesofficeconfigfile($configfilename, $configfilecontent); + return eval { output("$::prefix$configfilename", $configfilecontent) }; } sub add_cups_remote_to_office { @@ -111,7 +111,7 @@ sub add_cups_remote_to_office { $configfilename =~ m!$suites{$suite}{file_name}!; my $configprefix = $1; # Load Star Office printer config file - my $configfilecontent = readsofficeconfigfile($configfilename); + my $configfilecontent = cat_("$::prefix$configfilename"); # Update remote CUPS queues if ($printer->{SPOOLER} eq "cups" && (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { @@ -149,7 +149,7 @@ sub add_cups_remote_to_office { } } # Write back Star Office configuration file - return writesofficeconfigfile($configfilename, $configfilecontent); + return eval { output("$::prefix$configfilename", $configfilecontent) }; } sub remove_printer_from_office { @@ -160,13 +160,13 @@ sub remove_printer_from_office { $configfilename =~ m!$suites{$suite}{file_name}!; my $configprefix = $1; # Load Star Office printer config file - my $configfilecontent = readsofficeconfigfile($configfilename); + my $configfilecontent = cat_("$::prefix$configfilename"); # Remove the printer entry $configfilecontent = removestarofficeprinterentry($printer, $queue, $configprefix, $configfilecontent); # Write back Star Office configuration file - return writesofficeconfigfile($configfilename, $configfilecontent); + return eval { output("$::prefix$configfilename", $configfilecontent) }; } sub remove_local_printers_from_office { @@ -177,14 +177,14 @@ sub remove_local_printers_from_office { $configfilename =~ m!$suites{$suite}{file_name}!; my $configprefix = $1; # Load Star Office printer config file - my $configfilecontent = readsofficeconfigfile($configfilename); + my $configfilecontent = cat_("$::prefix$configfilename"); # Remove the printer entries foreach my $queue (keys(%{$printer->{configured}})) { $configfilecontent = removestarofficeprinterentry($printer, $queue, $configprefix, $configfilecontent); } # Write back Star Office configuration file - return writesofficeconfigfile($configfilename, $configfilecontent); + return eval { output("$::prefix$configfilename", $configfilecontent) }; } @@ -361,21 +361,8 @@ sub find_config_file { return ""; } -sub readsofficeconfigfile { - my ($file) = @_; - local *F; - open F, "< $::prefix$file" or return ""; - my $filecontent = join("", <F>); - close F; - return $filecontent; -} - sub writesofficeconfigfile { my ($file, $filecontent) = @_; - local *F; - open F, "> $::prefix$file" or return 0; - print F $filecontent; - close F; - return 1; + eval { output("$::prefix$file", $filecontent) }; } |