[debhelper-devel] [debhelper] 02/02: dh_install{docs, examples}: Validate --doc-main-package argument
Niels Thykier
nthykier at moszumanska.debian.org
Tue Oct 3 21:11:14 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit 144df263929b258d424975b682fa571392720e0d
Author: Niels Thykier <niels at thykier.net>
Date: Tue Oct 3 21:08:42 2017 +0000
dh_install{docs,examples}: Validate --doc-main-package argument
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debian/changelog | 3 +++
dh_installdocs | 4 ++++
dh_installexamples | 3 +++
lib/Debian/Debhelper/Dh_Getopt.pm | 12 +++---------
lib/Debian/Debhelper/Dh_Lib.pm | 14 ++++++++++++++
5 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index cc2f29a..602f6fe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,9 @@ debhelper (10.9.1) UNRELEASED; urgency=medium
* debhelper.7: Document how package selections interact with
Build-Profiles. Thanks to Helmut Grohne for the report.
(Closes: #872745)
+ * dh_installdocs: Validate that the package passed to
+ --doc-main-package are listed in debian/control.
+ * dh_installexamples: Ditto.
[ Dmitry Shachnev ]
* qmake.pm: Add basic cross-building support. (Closes: #877357)
diff --git a/dh_installdocs b/dh_installdocs
index 70fd2b0..a7343ac 100755
--- a/dh_installdocs
+++ b/dh_installdocs
@@ -224,6 +224,10 @@ if (@{$dh{DOPACKAGES}} > 1 and $dh{DOC_MAIN_PACKAGE}) {
error('--doc-main-package should be used with -p<doc-pkg>');
}
+if ($dh{DOC_MAIN_PACKAGE}) {
+ assert_opt_is_known_package($dh{DOC_MAIN_PACKAGE}, '--doc-main-package');
+}
+
foreach my $package (getpackages()) {
next if is_udeb($package);
diff --git a/dh_installexamples b/dh_installexamples
index 7547f87..01c4820 100755
--- a/dh_installexamples
+++ b/dh_installexamples
@@ -107,6 +107,9 @@ $default_error_handler = \&glob_expand_error_handler_silently_ignore if $nodocs;
if (@{$dh{DOPACKAGES}} > 1 and $dh{DOC_MAIN_PACKAGE}) {
error('--doc-main-package should be used with -p<doc-pkg>');
}
+if ($dh{DOC_MAIN_PACKAGE}) {
+ assert_opt_is_known_package($dh{DOC_MAIN_PACKAGE}, '--doc-main-package');
+}
foreach my $package (getpackages()) {
next if is_udeb($package);
diff --git a/lib/Debian/Debhelper/Dh_Getopt.pm b/lib/Debian/Debhelper/Dh_Getopt.pm
index 1f39dfe..8b978d9 100644
--- a/lib/Debian/Debhelper/Dh_Getopt.pm
+++ b/lib/Debian/Debhelper/Dh_Getopt.pm
@@ -11,7 +11,7 @@ use warnings;
use Debian::Debhelper::Dh_Lib;
use Getopt::Long;
-my (%exclude_package, %known_packages, %profile_enabled_packages, $profile_excluded_pkg);
+my (%exclude_package, %profile_enabled_packages, $profile_excluded_pkg);
sub showhelp {
my $prog=basename($0);
@@ -41,10 +41,7 @@ sub AddPackage { my($option,$value)=@_;
}
}
elsif ($option eq 'p' or $option eq 'package') {
- %known_packages = map { $_ => 1 } getpackages() if not %known_packages;
- if (not exists($known_packages{$value})) {
- error("Requested unknown package ${value} via -p/--package, expected one of: " . join(' ', getpackages()));
- }
+ assert_opt_is_known_package($value, '-p/--package');
%profile_enabled_packages = map { $_ => 1 } getpackages('both') if not %profile_enabled_packages;
# Silently ignore packages that are not enabled by the
# profile.
@@ -69,10 +66,7 @@ sub SetDebugPackage { my($option,$value)=@_;
# Add a package to a list of packages that should not be acted on.
sub ExcludePackage {
my($option, $value)=@_;
- %known_packages = map { $_ => 1 } getpackages() if not %known_packages;
- if (not exists($known_packages{$value})) {
- error("Unknown package ${value} given via -N/--no-package, expected one of: " . join(' ', getpackages()));
- }
+ assert_opt_is_known_package($value, '-N/--no-package');
$exclude_package{$value}=1;
}
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm
index 2dcacec..93c5206 100644
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -65,6 +65,7 @@ our (@EXPORT, %dh);
&glob_expand_error_handler_silently_ignore DH_BUILTIN_VERSION
&print_and_complex_doit &default_sourcedir &qx_cmd
&compute_doc_main_package &is_so_or_exec_elf_file
+ &assert_opt_is_known_package
);
# The Makefile changes this if debhelper is installed in a PREFIX.
@@ -2067,4 +2068,17 @@ sub compute_doc_main_package {
return;
}
+
+{
+ my %known_packages;
+ sub assert_opt_is_known_package {
+ my ($package, $method) = @_;
+ %known_packages = map { $_ => 1 } getpackages() if not %known_packages;
+ if (not exists($known_packages{$package})) {
+ error("Requested unknown package $package via $method, expected one of: " . join(' ', getpackages()));
+ }
+ return 1;
+ }
+}
+
1
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git
More information about the debhelper-devel
mailing list