diff options
Diffstat (limited to 'perl-install/standalone.pm')
| -rw-r--r-- | perl-install/standalone.pm | 247 |
1 files changed, 97 insertions, 150 deletions
diff --git a/perl-install/standalone.pm b/perl-install/standalone.pm index 9f14e971f..806ebf7cd 100644 --- a/perl-install/standalone.pm +++ b/perl-install/standalone.pm @@ -1,25 +1,30 @@ -package standalone; # $Id$ +package standalone; use c; use strict; -use common; +use subs qw(exit); +use common qw(N N_ if_ backtrace); use Config; +use drakbug; + +BEGIN { unshift @::textdomains, 'libDrakX-standalone' } +require 'log.pm'; #- "require log" causes some pb, perl thinking that "log" is the log() function #- for sanity (if a use standalone is made during install, MANY problems will happen) if ($::isInstall) { - require 'log.pm'; log::l('ERROR: use standalone made during install :-('); - require common; - log::l('backtrace: ' . common::backtrace()); + log::l('backtrace: ' . backtrace()); } $::isStandalone = 1; $ENV{SHARE_PATH} ||= "/usr/share"; -c::setlocale(); -c::bindtextdomain('libDrakX', "/usr/share/locale"); +eval { #- allow standalone.pm to be used in drakxtools-backend without perl-Locale-gettext + c::init_setlocale(); + Locale::gettext::bindtextdomain('libDrakX', "/usr/share/locale"); +}; -$::license = N("This program is free software; you can redistribute it and/or modify +$::license = N_("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. @@ -31,14 +36,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. "); -my $progname = basename $0; +my $progname = common::basename($0); my %usages = ( 'diskdrake' => "[--{" . join(",", qw(hd nfs smb dav removable fileshare)) . "}]", - 'drakbackup' => N("[--config-info] [--daemon] [--debug] [--default] [--show-conf] + 'drakbackup' => N_("[--config-info] [--daemon] [--debug] [--default] [--show-conf] Backup and Restore application --default : save default directories. @@ -47,29 +52,42 @@ Backup and Restore application --config-info : explain configuration file options (for non-X users). --daemon : use daemon configuration. --help : show this message. ---version : show version name. +--version : show version number. "), - 'drakbug' => N("[OPTIONS] [PROGRAM_NAME] + + 'drakboot' => N_("[--boot] +OPTIONS: + --boot - enable to configure boot loader +default mode: offer to configure autologin feature"), + 'drakbug' => N_("[OPTIONS] [PROGRAM_NAME] OPTIONS: --help - print this help message. - --report - program should be one of mandrake tools - --incident - program should be one of mandrake tools"), - 'drakfont' => N("Font Importation and monitoring application + --report - program should be one of %s tools + --incident - program should be one of %s tools"), + 'drakconnect' => N_("[--add] + --add - \"add a network interface\" wizard + --del - \"delete a network interface\" wizard + --skip-wizard - manage connections + --internet - configure internet + --wizard - like --add"), + 'drakfont' => N_(" +Font Importation and monitoring application + +OPTIONS: --windows_import : import from all available windows partitions. --xls_fonts : show all fonts that already exist from xls ---strong : strong verification of font. ---install : accept any font file and any directry. +--install : accept any font file and any directory. --uninstall : uninstall any font or any directory of font. --replace : replace all font if already exist --application : 0 none application. : 1 all application available supported. : name_of_application like so for staroffice : and gs for ghostscript for only this one."), - 'draksec' => N("[OPTIONS]... - --debug print debugging information"), - 'drakTermServ' => N("[OPTIONS]... -Mandrake Terminal Server Configurator + 'draksec' => "[--debug] +--debug: print debugging information", + 'drakTermServ' => N_("[OPTIONS]... +%s Terminal Server Configurator --enable : enable MTS --disable : disable MTS --start : start MTS @@ -80,9 +98,9 @@ Mandrake Terminal Server Configurator --delclient : delete a client machine from MTS (requires MAC address, IP, nbi image name)"), 'drakxtv' => "[--no-guess]", 'drakupdate_fstab' => " [--add | --del] <device>\n", - 'keyboardrake' => N("[keyboard]"), - 'logdrake' => N("[--file=myfyle] [--word=myword] [--explain=regexp] [--alert]"), - 'net_monitor' => N("[OPTIONS] + 'keyboardrake' => N_("[keyboard]"), + 'logdrake' => N_("[--file=myfile] [--word=myword] [--explain=regexp] [--alert]"), + 'net_monitor' => N_("[OPTIONS] Network & Internet connection and monitoring application --defaultintf interface : show this interface by default @@ -90,40 +108,64 @@ Network & Internet connection and monitoring application --disconnect : disconnect to internet if already connected --force : used with (dis)connect : force (dis)connection. --status : returns 1 if connected 0 otherwise, then exit. ---quiet : don't be interactive. To be used with (dis)connect."), - 'printerdrake' => N(" [--skiptest] [--cups] [--lprng] [--lpd] [--pdq]"), - 'rpmdrake' => N("[OPTION]... - --no-confirmation don't ask first confirmation question in MandrakeUpdate mode - --no-verify-rpm don't verify packages signatures +--quiet : do not be interactive. To be used with (dis)connect."), + 'printerdrake' => " [--skiptest] [--cups] [--lprng] [--lpd] [--pdq]", + 'rpmdrake' => N_("[OPTION]... + --no-confirmation do not ask first confirmation question in %s Update mode + --no-verify-rpm do not verify packages signatures --changelog-first display changelog before filelist in the description window --merge-all-rpmnew propose to merge all .rpmnew/.rpmsave files found"), - 'scannerdrake' => N("[--manual] [--device=dev] [--update-sane=sane_desc_dir] [--update-usbtable] [--dynamic=dev]"), - 'XFdrake' => N(" [everything] + 'scannerdrake' => N_("[--manual] [--device=dev] [--update-sane=sane_source_dir] [--update-usbtable] [--dynamic=dev]"), + 'XFdrake' => N_(" [everything] XFdrake [--noauto] monitor XFdrake resolution"), ); -$usages{$_} = $usages{rpmdrake} foreach qw(rpmdrake-remove MandrakeUpdate); +$usages{$_} = $usages{rpmdrake} foreach qw(rpmdrake-remove MageiaUpdate); $usages{Xdrakres} = $usages{XFdrake}; +sub exit { + explanations('### Program is exiting ###'); + CORE::exit(@_); +} + +sub __exit { + explanations('### Program is exiting ###'); + c::_exit(@_); +} + + +sub real_version() { + return "VER"; # version automatically set from Makefile +} + +sub version() { + print 'Drakxtools version ' . real_version() . ' +Copyright (C) 1999-2008 Mandriva by <install@mandriva.com> +Copyright (C) 2010-2014 Mageia +', $::license, "\n"; +} + +if (!$::no_global_argv_parsing) { my ($i, @new_ARGV); foreach (@ARGV) { $i++; if (/^-(-help|h)$/) { version(); - print STDERR N("\nUsage: %s [--auto] [--beginner] [--expert] [-h|--help] [--noauto] [--testing] [-v|--version] ", $progname), if_($usages{$progname}, $usages{$progname}), "\n"; + print N("\nUsage: %s [--auto] [--beginner] [--expert] [-h|--help] [--noauto] [--testing] [-v|--version] ", $progname), + if_($usages{$progname}, common::translate($usages{$progname})), "\n"; # print N("\nUsage: "), $::usage, "\n" if $::usage; - exit(0); + CORE::exit(0); } elsif (/^-(-version|v)$/) { version(); - exit(0); + CORE::exit(0); } elsif (/^--embedded$/) { - (undef, $::XID, $::CCPID) = splice @ARGV, ($i-1), 3; + $::XID = splice @ARGV, $i, 1; $::isEmbedded = 1; } elsif (/^--expert$/) { $::expert = 1; - } elsif (/--noauto$/) { + } elsif (/^--noauto$/) { $::noauto = /-noauto/; } elsif (/^--auto$/) { $::auto = 1; @@ -137,123 +179,28 @@ foreach (@ARGV) { } @ARGV = @new_ARGV; - - -sub version { - print STDERR "Drakxtools version 9.1.0 -Copyright (C) 1999-2002 MandrakeSoft by <install\@mandrakesoft.com> -", $::license, "\n"; -} - -################################################################################ -package pkgs_interactive; - -use run_program; -use common; - - -sub interactive::do_pkgs { - my ($in) = @_; - bless { in => $in }, 'pkgs_interactive'; -} - -sub install { - my ($o, @l) = @_; - - return 1 if is_installed($o, @l); - - my $wait; - if ($o->{in}->isa('interactive::newt')) { - $o->{in}->suspend; - } else { - $wait = $o->{in}->wait_message('', N("Installing packages...")); - } - standalone::explanations("installed packages @l"); - my $ret = system('urpmi', '--allow-medium-change', '--auto', '--best-output', @l) == 0; - - if ($o->{in}->isa('interactive::newt')) { - $o->{in}->resume; - } else { - undef $wait; - } - $ret; } -sub ensure_is_installed { - my ($o, $pkg, $file, $auto) = @_; - - if (! -e $file) { - $o->{in}->ask_okcancel('', N("The package %s needs to be installed. Do you want to install it?", $pkg), 1) - or return if !$auto; - $o->{in}->do_pkgs->install($pkg); - } - if (! -e $file) { - $o->{in}->ask_warn('', N("Mandatory package %s is missing", $pkg)); - return; - } - 1; -} - -sub what_provides { - my ($o, $name) = @_; - my ($what) = split '\n', `urpmq '$name' 2>/dev/null`; - split '\|', $what; -} - -sub is_installed { - my ($o, @l) = @_; - run_program::run('rpm', '>', '/dev/null', '-q', @l); -} - -sub are_installed { - my ($o, @l) = @_; - my @l2; - run_program::run('rpm', '>', \@l2, '-q', '--qf', "%{name}\n", @l); - intersection(\@l, [ map { chomp_($_) } @l2 ]); -} - -sub remove { - my ($o, @l) = @_; - $o->{in}->suspend; - standalone::explanations("removed packages @l"); - my $ret = system('rpm', '-e', @l) == 0; - $o->{in}->resume; - $ret; -} - -sub remove_nodeps { - my ($o, @l) = @_; - $o->{in}->suspend; - standalone::explanations("removed (with --nodeps) packages @l"); - my $ret = system('rpm', '-e', '--nodeps', @l) == 0; - $o->{in}->resume; - $ret; -} ################################################################################ - -package standalone; - #- stuff will go to special /var/log/explanations file my $standalone_name; -sub explanations { c::syslog(c::LOG_INFO()|c::LOG_LOCAL1(), "@_") } +sub explanations { log::explanations("@_") } our @common_functs = qw(renamef linkf symlinkf output substInFile mkdir_p rm_rf cp_af touch setVarsInSh setExportedVarsInSh setExportedVarsInCsh update_gnomekderc); -our @builtin_functs = qw(chmod chown unlink link symlink rename system); -our @drakx_modules = qw(Xconfig::card Xconfig::default Xconfig::main Xconfig::monitor Xconfig::parse Xconfig::proprietary Xconfig::resolution_and_depth Xconfig::screen Xconfig::test Xconfig::various Xconfig::xfree Xconfig::xfree3 Xconfig::xfree4 Xconfig::xfreeX any bootloader bootlook c class_discard commands crypto detect_devices devices diskdrake diskdrake::hd_gtk diskdrake::interactive diskdrake::removable diskdrake::removable_gtk diskdrake::smbnfs_gtk fs fsedit http keyboard lang log loopback lvm modules::parameters modules mouse my_gtk network network::adsl network::ethernet network::isdn_consts network::isdn network::modem network::netconnect network::network network::nfs network::smb network::tools partition_table partition_table_bsd partition_table::dos partition_table::empty partition_table::gpt partition_table::mac partition_table::raw partition_table::sun printer printerdrake proxy raid run_program scanner services steps swap timezone network::drakfirewall network::shorewall); - -$SIG{SEGV} = sub { my $progname = $0; $progname =~ s|.*/||; exec("drakbug --incident $progname") }; +our @builtin_functs = qw(chmod chown __exit exit unlink link symlink rename system); +our @drakx_modules = qw(Xconfig::card Xconfig::default Xconfig::main Xconfig::monitor Xconfig::parse Xconfig::proprietary Xconfig::resolution_and_depth Xconfig::screen Xconfig::test Xconfig::various Xconfig::xfree any bootloader bootlook c commands crypto detect_devices devices diskdrake diskdrake::hd_gtk diskdrake::interactive diskdrake::removable diskdrake::removable_gtk diskdrake::smbnfs_gtk fs fsedit http keyboard lang log loopback lvm modules::parameters modules mouse my_gtk network network::adsl network::ethernet network::connection network::isdn_consts network::isdn network::modem network::netconnect network::network fs::remote::nfs fs::remote::smb network::tools partition_table partition_table_bsd partition_table::dos partition_table::empty partition_table::gpt partition_table::mac partition_table::raw partition_table::sun printer printerdrake proxy raid run_program scanner services steps swap timezone network::drakfirewall network::shorewall); -sub import { +sub import() { ($standalone_name = $0) =~ s|.*/||; - c::openlog("$standalone_name"."[$$]"); + c::openlog($standalone_name . "[$$]"); explanations('### Program is starting ###'); - eval "*MDK::Common::$_ = *$_" foreach @common_functs; + eval "*common::$_ = *$_" foreach @common_functs; foreach my $f (@builtin_functs) { - eval "*$_"."::$f = *$f" foreach @drakx_modules; - eval "*".caller()."::$f = *$f"; + eval "*$_" . "::$f = *$f" foreach @drakx_modules; + eval "*" . caller() . "::$f = *$f"; } } @@ -294,7 +241,7 @@ sub rm_rf { } sub cp_af { - my $retval = MDK::Common::File::cp_af @_; + my $retval = MDK::Common::File::cp_af(@_); my $dest = pop @_; explanations "copied recursively @_ to $dest"; return $retval; @@ -327,14 +274,14 @@ sub update_gnomekderc { sub chmod { - my $retval = CORE::chmod @_; + my $retval = CORE::chmod(@_); my $mode = shift @_; explanations sprintf("changed mode of %s to %o", $_, $mode) foreach @_; return $retval; } sub chown { - my $retval = CORE::chown @_; + my $retval = CORE::chown(@_); my $uid = shift @_; my $gid = shift @_; explanations sprintf("changed owner of $_ to $uid.$gid") foreach @_; @@ -343,27 +290,27 @@ sub chown { sub unlink { explanations "removed files/directories @_"; - CORE::unlink @_; + CORE::unlink(@_); } sub link { explanations "hard linked file $_[0] to $_[1]"; - CORE::link $_[0], $_[1]; + CORE::link($_[0], $_[1]); } sub symlink { explanations "symlinked file $_[0] to $_[1]"; - CORE::symlink $_[0], $_[1]; + CORE::symlink($_[0], $_[1]); } sub rename { - explanations "renamed file $_[0] to $_[1]"; - CORE::rename $_[0], $_[1]; + explanations "renamed file $_[0] to $_[1]" if -r $_[0]; + CORE::rename($_[0], $_[1]); } sub system { explanations "launched command: @_"; - CORE::system @_; + CORE::system(@_); } 1; |
