From 57cd028e69472a1d2ade68a474a45641c65ff7bb Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 3 Mar 2000 03:44:42 +0000 Subject: r340: * Patch from Jorgen `forcer' Schaefer (much modified)to make dh_installwm use new window manager registration method, update-alternatives. Closes: #52156, #34684 (latter bug is obsolete) * Fixed $dh{flavor} to be upper-case. * Deprecated dh_installemavcsen --number; use --priority instead. Also, the option parser requires the parameter be a number now. And, dh_installwm now accepts --priority, and window manager packages should start using it. * dh_installwm now behaves like a proper debhelper command, and reads debian/.wm too. This is a small behavior change; filenames specified on the command line no longer apply to all packages it acts on. I can't belive this program existed for 2 years with such a glaring problem; I guess most people don't need ot register 5 wm's in 3 sub-packages. Anyway, it can handle such things now. :-) * Moved Dh_*.pm to /usr/lib/perl5/Debian/Debhelper. *big* change. --- Debian/Debhelper/Dh_Getopt.pm | 193 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 Debian/Debhelper/Dh_Getopt.pm (limited to 'Debian/Debhelper/Dh_Getopt.pm') diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm new file mode 100644 index 00000000..1e52109e --- /dev/null +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -0,0 +1,193 @@ +#!/usr/bin/perl -w +# +# Debhelper option processing library. +# +# Joey Hess GPL copyright 1998. + +package Debian::Debhelper::Dh_Getopt; +use strict; + +use Debian::Debhelper::Dh_Lib; +use Getopt::Long; +use Exporter; +#use vars qw{@ISA @EXPORT}; +#@ISA=qw(Exporter); +#@EXPORT=qw(&aparseopts); # FIXME: for some reason, this doesn't work. + +my (%options, %exclude_package); + +# Passed an option name and an option value, adds packages to the list +# of packages. We need this so the list will be built up in the right +# order. +sub AddPackage { my($option,$value)=@_; + if ($option eq 'i' or $option eq 'indep') { + push @{$options{DOPACKAGES}}, GetPackages('indep'); + $options{DOINDEP}=1; + } + elsif ($option eq 'a' or $option eq 'arch') { + push @{$options{DOPACKAGES}}, GetPackages('arch'); + $options{DOARCH}=1; + } + elsif ($option eq 'p' or $option eq 'package') { + push @{$options{DOPACKAGES}}, $value; + } + elsif ($option eq 's' or $option eq 'same-arch') { + push @{$options{DOPACKAGES}}, GetPackages('same'); + $options{DOSAME}=1; + } + else { + error("bad option $option - should never happen!\n"); + } +} + +# Add a package to a list of packages that should not be acted on. +sub ExcludePackage { my($option,$value)=@_; + $exclude_package{$value}=1; +} + +# Add another item to the exclude list. +sub AddExclude { my($option,$value)=@_; + push @{$options{EXCLUDE}},$value; +} + +# This collects non-options values. +sub NonOption { + push @{$options{ARGV}}, @_; +} + +# Parse options and return a hash of the values. +sub parseopts { + undef %options; + + my $ret=GetOptions( + "v" => \$options{VERBOSE}, + "verbose" => \$options{VERBOSE}, + + "i" => \&AddPackage, + "indep" => \&AddPackage, + + "a" => \&AddPackage, + "arch" => \&AddPackage, + + "p=s" => \&AddPackage, + "package=s" => \&AddPackage, + + "s" => \&AddPackage, + "same-arch" => \&AddPackage, + + "N=s" => \&ExcludePackage, + "no-package=s" => \&ExcludePackage, + + "n" => \$options{NOSCRIPTS}, + "noscripts" => \$options{NOSCRIPTS}, + + "x" => \$options{INCLUDE_CONFFILES}, # is -x for some unknown historical reason.. + "include-conffiles" => \$options{INCLUDE_CONFFILES}, + + "X=s" => \&AddExclude, + "exclude=s" => \&AddExclude, + + "d" => \$options{D_FLAG}, + "remove-d" => \$options{D_FLAG}, + "dirs-only" => \$options{D_FLAG}, + + "r" => \$options{R_FLAG}, + "no-restart-on-upgrade" => \$options{R_FLAG}, + + "k" => \$options{K_FLAG}, + "keep" => \$options{K_FLAG}, + + "P=s" => \$options{TMPDIR}, + "tmpdir=s" => \$options{TMPDIR}, + + "u=s", => \$options{U_PARAMS}, + "update-rcd-params=s", => \$options{U_PARAMS}, + "dpkg-shlibdeps-params=s", => \$options{U_PARAMS}, + "dpkg-gencontrol-params=s", => \$options{U_PARAMS}, + + "l=s", => \$options{L_PARAMS}, + + "m=s", => \$options{M_PARAMS}, + "major=s" => \$options{M_PARAMS}, + + "V:s", => \$options{V_FLAG}, + "version-info:s" => \$options{V_FLAG}, + + "A" => \$options{PARAMS_ALL}, + "all" => \$options{PARAMS_ALL}, + + "no-act" => \$options{NO_ACT}, + + "init-script=s" => \$options{INIT_SCRIPT}, + + "sourcedir=s" => \$options{SOURCEDIR}, + + "destdir=s" => \$options{DESTDIR}, + + "number=i" => \$options{PRIORITY}, # deprecated + "priority=i" => \$options{PRIORITY}, + + "flavor=s" => \$options{FLAVOR}, + + "<>" => \&NonOption, + ); + + if (!$ret) { + error("unknown option; aborting"); + } + + # Check to see if -V was specified. If so, but no parameters were + # passed, the variable will be defined but empty. + if (defined($options{V_FLAG})) { + $options{V_FLAG_SET}=1; + } + + # If we have not been given any packages to act on, assume they + # want us to act on them all. Note we have to do this before excluding + # packages out, below. + if (! defined $options{DOPACKAGES} || ! @{$options{DOPACKAGES}}) { + if ($options{DOINDEP} || $options{DOARCH} || $options{DOSAME}) { + # User specified that all arch (in)dep package be + # built, and there are none of that type. + error("I have no package to build"); + } + push @{$options{DOPACKAGES}},GetPackages(); + } + + # Remove excluded packages from the list of packages to act on. + my @package_list; + my $package; + foreach $package (@{$options{DOPACKAGES}}) { + if (! $exclude_package{$package}) { + push @package_list, $package; + } + } + @{$options{DOPACKAGES}}=@package_list; + + # Generate EXCLUDE_FIND. + $options{EXCLUDE_FIND}=''; + foreach (@{$options{EXCLUDE}}) { + $options{EXCLUDE_FIND}.="-regex .*".quotemeta($_).".* -or "; + } + $options{EXCLUDE_FIND}=~s/ -or $//; + + # If there are no packages to act on now, it's an error. + if (! defined $options{DOPACKAGES} || ! @{$options{DOPACKAGES}}) { + error("I have no package to build"); + } + + # Anything left in @ARGV is options that appeared after a -- + # These options are added to U_PARAMS, while the non-option + # values we collected replace them in @ARGV; + $options{U_PARAMS}.=join(' ', @ARGV); + @ARGV=@{$options{ARGV}} if exists $options{ARGV}; + + return %options; +} + +sub import { + # Enable bundling of short command line options. + Getopt::Long::config("bundling"); +} + +1 -- cgit v1.2.3