From 0f881eacc9dd3d36486097322c189d0737b56154 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 18 Nov 2002 08:05:41 +0000 Subject: - standalone.pm : o make it be 'use strict' aware o factorize options managment in one place - standalone tools : o they all now support -h|--help -v|--version, ... o they can add their own options to %standalone::usages - harddrake : use std --testing/$::testing rather than its own --test option --- perl-install/harddrake/ui.pm | 19 +------- perl-install/standalone.pm | 89 +++++++++++++++++++++++++++++++---- perl-install/standalone/XFdrake | 13 +---- perl-install/standalone/adduserdrake | 7 --- perl-install/standalone/diskdrake | 24 +++++----- perl-install/standalone/drakautoinst | 2 - perl-install/standalone/drakboot | 7 --- perl-install/standalone/drakconnect | 5 +- perl-install/standalone/drakfloppy | 3 -- perl-install/standalone/drakgw | 2 - perl-install/standalone/draksound | 2 - perl-install/standalone/drakxservices | 5 -- perl-install/standalone/drakxtv | 3 -- perl-install/standalone/keyboarddrake | 6 --- perl-install/standalone/livedrake | 6 --- perl-install/standalone/mousedrake | 7 --- perl-install/standalone/printerdrake | 13 +---- 17 files changed, 96 insertions(+), 117 deletions(-) diff --git a/perl-install/harddrake/ui.pm b/perl-install/harddrake/ui.pm index ea3cf7239..741d9d19e 100644 --- a/perl-install/harddrake/ui.pm +++ b/perl-install/harddrake/ui.pm @@ -58,23 +58,6 @@ my %fields = ); -our $license = 'Copyright (C) 1999-2002 MandrakeSoft by tvignaud@mandrakesoft.com - -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. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -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. -'; - my ($in, %IDs, $pid, $w); my %options; @@ -121,7 +104,7 @@ sub detect { foreach (@harddrake::data::tree) { my ($Ident, $title, $icon, $configurator, $detector) = @$_; next if ref($detector) ne "CODE"; #skip class witouth detector - next if $Ident =~ /(MODEM|PRINTER)/ && "@ARGV" =~ /test/; + next if $Ident =~ /(MODEM|PRINTER)/ && $::testing; next if $Ident =~ /MODEM/ && !$options{MODEMS_DETECTION}; next if $Ident =~ /PRINTER/ && !$options{PRINTERS_DETECTION}; # print N("Probing %s class\n", $Ident); diff --git a/perl-install/standalone.pm b/perl-install/standalone.pm index b758184ed..ca869f6a1 100644 --- a/perl-install/standalone.pm +++ b/perl-install/standalone.pm @@ -1,6 +1,8 @@ package standalone; # $Id$ use c; +use strict; +use common; use Config; #- for sanity (if a use standalone is made during install, MANY problems will happen) @@ -17,12 +19,81 @@ $ENV{SHARE_PATH} ||= "/usr/share"; c::setlocale(); c::bindtextdomain('libDrakX', "/usr/share/locale"); -my $i; -foreach (@ARGV) { +$::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. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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. +"); + +my $progname = basename $0; +print "Running $progname\n"; + +my %usages = ( + 'draksec' => N(" [OPTIONS]... + --debug print debugging information"), + 'drakxtv' => "[--no-guess]", + 'drakupdate_fstab' => " [--add | --del] \n", + 'keyboardrake' => N("[keyboard]"), + '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 + --changelog-first display changelog before filelist in the description window + --merge-all-rpmnew propose to merge all .rpmnew/.rpmsave files found"), + 'XFdrake' => N(" [everything] + XFdrake [--noauto] monitor + XFdrake resolution"), + ); + +$usages{$_} = $usages{rpmdrake} foreach (qw(rpmdrake-remove MandrakeUpdate)); +$usages{Xdrakres} = $usages{XFdrake}; + + +my ($i, @new_ARGV); +foreach my $opt (@ARGV) { $i++; - $_ eq '--embedded' or next; - (undef, $::XID, $::CCPID) = splice @ARGV, ($i-1), 3; - $::isEmbedded = 1; + if ($opt eq '--help' || $opt eq '-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: "), $::usage, "\n" if $::usage; + exit(0); + } elsif ($opt eq '--version' || $opt eq '-v') { + version(); + exit(0); + } elsif ($opt eq '--embedded') { + (undef, $::XID, $::CCPID) = splice @ARGV, ($i-1), 3; + $::isEmbedded = 1; + } elsif ($opt eq '--expert') { + $::expert = 1; + } elsif ($opt eq '--noauto') { + $::noauto = /-noauto/; + } elsif ($opt eq '--auto') { + $::auto = 1; + } elsif ($opt eq '--testing') { + $::testing = 1; + } elsif ($opt eq '--beginner') { + $::expert = 0; + } else { + push @new_ARGV, $opt; + } +} + +@ARGV = @new_ARGV; + + +sub version { + print STDERR "Drakxtools version 9.1.0 +Copyright (C) 1999-2002 MandrakeSoft by +", $::license, "\n"; } ################################################################################ @@ -118,11 +189,11 @@ package standalone; my $standalone_name; sub explanations { c::syslog(c::LOG_INFO()|c::LOG_LOCAL1(), "@_") } -@common_functs = qw(renamef linkf symlinkf output substInFile mkdir_p rm_rf cp_af touch setVarsInSh setExportedVarsInSh setExportedVarsInCsh update_gnomekderc); -@builtin_functs = qw(chmod chown unlink link symlink rename system); -@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 modparm 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); +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 modparm 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 { ($progname = $0) =~ s|.*/||; exec("drakbug --incident $progname") }; +$SIG{SEGV} = sub { my $progname = $0; $progname =~ s|.*/||; exec("drakbug --incident $progname") }; sub import { ($standalone_name = $0) =~ s|.*/||; diff --git a/perl-install/standalone/XFdrake b/perl-install/standalone/XFdrake index 1c803ccd5..5c8311d3d 100755 --- a/perl-install/standalone/XFdrake +++ b/perl-install/standalone/XFdrake @@ -35,17 +35,6 @@ local $_ = join '', @ARGV; my ($configure_this) = grep { !/^-/ } @ARGV; $configure_this ||= 'everything'; -/-h/ || $configure_this !~ /^(resolution|monitor|everything|auto_install)/ and die <<'EOF'; -usage: XFdrake [--expert] [--noauto] [--auto] [everything] - XFdrake [--noauto] monitor - XFdrake resolution -EOF - -my $auto = /-auto/; -$::expert = /-expert/; -$::noauto = /-noauto/; -$::testing = /-testing/; - begin: { my $in = 'interactive'->vnew('su', 'X'); @@ -68,7 +57,7 @@ begin: if ($has_conf) { Xconfig::main::configure_chooser($in, $raw_X, $in->do_pkgs, $options); } else { - Xconfig::main::configure_everything($in, $raw_X, $in->do_pkgs, $auto, $options); + Xconfig::main::configure_everything($in, $raw_X, $in->do_pkgs, $::auto, $options); } } elsif ($configure_this eq 'auto_install') { Xconfig::main::configure_everything_auto_install(Xconfig::default::configure(), $in->do_pkgs, {}, $options); diff --git a/perl-install/standalone/adduserdrake b/perl-install/standalone/adduserdrake index 98a2e3dd0..20268d9ff 100755 --- a/perl-install/standalone/adduserdrake +++ b/perl-install/standalone/adduserdrake @@ -8,13 +8,6 @@ use common; use interactive; use any; -local $_ = join '', @ARGV; - -/-h/ and die "usage: adduserdrake [--beginner] [--expert] []\n"; - -$::beginner = /-beginner/; -$::expert = /-expert/; - my @etc_pass_fields = qw(name pw uid gid realname home shell); my @shells = grep { -x $_ } map { "/bin/$_" } qw(bash tcsh zsh ash ksh); my $isMD5 = cat_("/etc/pam.d/system-auth") =~ /md5/; diff --git a/perl-install/standalone/diskdrake b/perl-install/standalone/diskdrake index 1aa72a3df..a0b8cd158 100755 --- a/perl-install/standalone/diskdrake +++ b/perl-install/standalone/diskdrake @@ -36,18 +36,18 @@ use log; use c; -my %options; -my @l = @ARGV; -while (my $e = shift @l) { - my ($option) = $e =~ /--?(.*)/ or next; - if ($option =~ /(.*?)=(.*)/) { - $options{$1} = $2; - } else { - $options{$option} = ''; - } -} -$::expert = defined(delete $options{expert}); -$::testing = defined(delete $options{testing}); +#my %options; +#my @l = @ARGV; +#while (my $e = shift @l) { +" my ($option) = $e =~ /--?(.*)/ or next; +# if ($option =~ /(.*?)=(.*)/) { +# $options{$1} = $2; +# } else { +# $options{$option} = ''; +# } +"} +#$::expert = defined(delete $options{expert}); +#$::testing = defined(delete $options{testing}); my @types = qw(hd nfs smb dav removable fileshare); my ($type, $para) = ('hd', ''); diff --git a/perl-install/standalone/drakautoinst b/perl-install/standalone/drakautoinst index 478850eeb..de6e2c8d0 100755 --- a/perl-install/standalone/drakautoinst +++ b/perl-install/standalone/drakautoinst @@ -29,8 +29,6 @@ use Data::Dumper; local $_ = join '', @ARGV; -/-h/ and die "usage: drakautoinst [--version]\n"; -/-version/ and die 'version: $Id$ '."\n"; $::direct = /-direct/; $::direct = 1; #DEBUG diff --git a/perl-install/standalone/drakboot b/perl-install/standalone/drakboot index 1aa1855e7..7054ed5db 100755 --- a/perl-install/standalone/drakboot +++ b/perl-install/standalone/drakboot @@ -13,13 +13,6 @@ use fsedit; use fs; use c; -local $_ = join '', @ARGV; - -/-h/ and die "usage: drakboot [--expert] [--testing]\n"; - -$::expert = /-expert/; -$::testing = /-testing/; - my $in = 'interactive'->vnew('su', 'bootloader'); $::lilo_choice = \&lilo_choice; diff --git a/perl-install/standalone/drakconnect b/perl-install/standalone/drakconnect index a4930e616..5a9e897d8 100755 --- a/perl-install/standalone/drakconnect +++ b/perl-install/standalone/drakconnect @@ -36,11 +36,8 @@ use network::adsl; use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file $disconnect_file); my $xpm_path = "/usr/share/libDrakX/pixmaps"; -$::isWizard = "@ARGV" =~ /--wizard/; -$::expert = "@ARGV" =~ /--expert/; local $_ = join '', @ARGV; - -#/-h/ and die "usage: drakconnect[--xf3] [--beginner] [--expert] [--auto] [--noauto] [--skiptest] [--testing]\n"; +$::isWizard = /--wizard/; my $netcnx = {}; my $netc = {}; diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy index a19e7889e..b173a9334 100755 --- a/perl-install/standalone/drakfloppy +++ b/perl-install/standalone/drakfloppy @@ -37,9 +37,6 @@ init Gtk; Gtk->set_locale; $in = 'interactive'->vnew('su', 'default'); -local $_ = join '', @ARGV; - -/-h/ and die N("usage: drakfloppy\n"); $expert_mode = 0; # we have put here the list in order to do $list->clear() when we have to do diff --git a/perl-install/standalone/drakgw b/perl-install/standalone/drakgw index 357dfb2a2..488df9495 100755 --- a/perl-install/standalone/drakgw +++ b/perl-install/standalone/drakgw @@ -37,8 +37,6 @@ $::isInstall and die "Not supported during install.\n"; local $_ = join '', @ARGV; -/-h/ and die "usage: drakgw [--version]\n"; -/-version/ and die 'version: $Id$ '."\n"; $::Wizard_pix_up = "wiz_drakgw.png"; $::Wizard_title = N("Internet Connection Sharing"); $::direct = /-direct/; diff --git a/perl-install/standalone/draksound b/perl-install/standalone/draksound index b8b5c519c..32acca45c 100755 --- a/perl-install/standalone/draksound +++ b/perl-install/standalone/draksound @@ -26,8 +26,6 @@ use common; use harddrake::sound; use modules; -("@ARGV" =~ /--help|-h/) and die "usage: draksound [-h] [--help]\n"; - my $in = 'interactive'->vnew(); modules::mergein_conf('/etc/modules.conf'); diff --git a/perl-install/standalone/drakxservices b/perl-install/standalone/drakxservices index a57b430bb..92fd34fe0 100755 --- a/perl-install/standalone/drakxservices +++ b/perl-install/standalone/drakxservices @@ -9,11 +9,6 @@ use interactive; use services; use log; -local $_ = join '', @ARGV; - -/-h/ and die "usage: drakxservices\n"; - - my $in = 'interactive'->vnew('su', 'services'); begin: my $l = services::ask($in); diff --git a/perl-install/standalone/drakxtv b/perl-install/standalone/drakxtv index 859a066d5..c0d76ea3d 100755 --- a/perl-install/standalone/drakxtv +++ b/perl-install/standalone/drakxtv @@ -29,9 +29,6 @@ use lang; use log; use common; -("@ARGV" =~ /--help|-h/) and die "usage: drakxtv [-h] [--help] [--no-guess]\n"; - - my $in = 'interactive'->vnew(); sub scan4channels { diff --git a/perl-install/standalone/keyboarddrake b/perl-install/standalone/keyboarddrake index fd4559853..7e594f17b 100755 --- a/perl-install/standalone/keyboarddrake +++ b/perl-install/standalone/keyboarddrake @@ -11,12 +11,6 @@ use common; use any; use c; -local $_ = join '', @ARGV; - -/-h/ and die N("usage: keyboarddrake [--expert] [keyboard]\n"); - -$::expert = /-expert/; - my $in; my $keyboard = keyboard::read(); if (my ($kb) = grep { !/^-/ } @ARGV) { diff --git a/perl-install/standalone/livedrake b/perl-install/standalone/livedrake index be4f9894a..03868c03b 100755 --- a/perl-install/standalone/livedrake +++ b/perl-install/standalone/livedrake @@ -9,12 +9,6 @@ use interactive; use run_program; use c; -local $_ = join '', @ARGV; - -/-h/ and die "usage: livedrake [--testing]\n"; - -$::testing = /-testing/; - my $in = 'interactive'->vnew('su', 'default'); my $cd_mntpoint = "/mnt/cdrom"; diff --git a/perl-install/standalone/mousedrake b/perl-install/standalone/mousedrake index bf493e774..4ac16adcb 100755 --- a/perl-install/standalone/mousedrake +++ b/perl-install/standalone/mousedrake @@ -11,13 +11,6 @@ use mouse; use c; -local $_ = join '', @ARGV; - -/-h/ and die "usage: mousedrake [--auto] [--testing]\n"; - -$::auto = /-auto/; -$::testing = /-testing/; - my $in = 'interactive'->vnew('su', 'mouse'); modules::mergein_conf('/etc/modules.conf') if -r '/etc/modules.conf'; diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake index 0369cd661..4f05e1ec2 100755 --- a/perl-install/standalone/printerdrake +++ b/perl-install/standalone/printerdrake @@ -30,18 +30,7 @@ use c; local $_ = join '', @ARGV; -/-h/ and die "usage: printerdrake [--beginner] [--expert] [--auto] [--noauto] [--skiptest] [--testing] [--cups] [--lprng] [--lpd] [--pdq]\n"; - -$::expert = 0; -if (/-expert/) { - $::expert = 1; -} elsif (/-beginner/) { - $::expert = 0; -} else { - printer::main::get_usermode (); -} -$::noauto = /-noauto/; -$::testing = /-testing/; +printer::main::get_usermode (); my $printer; -- cgit v1.2.1