3 # Because the getopt() program is so horribly broken, I wrote my own argument
4 # processer that uses the find Getopt::Long module. This is used by all
7 # Joey Hess, GPL copyright 1998.
9 # Returns a list of packages in the control file.
10 # Must pass "arch" or "indep" to specify arch-dependant or -independant
12 sub GetPackages { $type=shift;
16 open (CONTROL,"<debian/control") ||
17 ( $parse_error="cannot read debian/control: $!\n" );
21 if (/^Package:\s+(.*)/) {
24 if (/^Architecture:\s+(.*)/) {
27 if (!$_ or eof) { # end of stanza.
29 (($type eq 'indep' && $arch eq 'all') ||
30 ($type eq 'arch' && $arch ne 'all'))) {
32 undef $package, $arch;
41 # Passed an option name and an option value, adds packages to the list
42 # of packages. We need this so the list will be built up in the right
44 sub AddPackage { my($option,$value)=@_;
45 if ($option eq 'i' or $option eq 'indep') {
46 push @packages, GetPackages('indep');
49 elsif ($option eq 'a' or $option eq 'arch') {
50 push @packages, GetPackages('arch');
53 elsif ($option eq 'p' or $option eq 'package') {
54 push @packages, $value;
57 $parse_error="bad option $option - should never happen!\n";
63 # Enable bundling of short command line options.
64 Getopt::Long::config("bundling");
69 "verbose" => \$verbose,
72 "indep" => \&AddPackage,
75 "arch" => \&AddPackage,
77 "p=s" => \&AddPackage,
78 "package=s" => \&AddPackage,
81 "noscripts" => \$noscripts,
83 "x" => \$include, # is -x for some unknown historical reason..
84 "include-conffiles" => \$include,
87 "remove-d" => \$d_flag,
90 "no-restart-on-upgrade" => \$r_flag,
96 "tmpdir=s" => \$tmpdir,
99 "update-rcd-params=s", => \$u_params,
100 "dpkg-shlibdeps-params=s", => \$u_params,
103 "major=s" => \$major,
105 "V:s", => \$version_info,
106 "version-info:s" => \$version_info,
112 # Check to see if -V was specified. If so, but no parameters were passed,
113 # the variable will be defined but empty.
114 if (defined($version_info)) {
118 # Now output everything, in a format suitable for a shell to eval it.
119 # Note the last line sets $@ in the shell to whatever arguements remain.
121 DH_VERBOSE='$verbose'
122 DH_DOPACKAGES='@packages'
125 DH_NOSCRIPTS='$noscripts'
126 DH_EXCLUDE='$include'
131 DH_U_PARAMS='$u_params'
133 DH_V_FLAG='$version_info'
134 DH_V_FLAG_SET='$version_info_set'
136 DH_PARSE_ERROR='$parse_error'