[debhelper-devel] [debhelper] 01/01: Dh_Lib: Provide deprecated_functionality helper
Niels Thykier
nthykier at moszumanska.debian.org
Sun Feb 19 08:26:40 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 e691259fa1c32a342dc82efdbd0518f0c6f5003f
Author: Niels Thykier <niels at thykier.net>
Date: Sun Feb 19 08:25:43 2017 +0000
Dh_Lib: Provide deprecated_functionality helper
Signed-off-by: Niels Thykier <niels at thykier.net>
---
Debian/Debhelper/Dh_Getopt.pm | 6 +-----
Debian/Debhelper/Dh_Lib.pm | 16 +++++++++++++++-
debhelper.pod | 2 +-
dh_clean | 8 +++-----
doc/PROGRAMMING | 8 ++++++++
5 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm
index 22ef536..a2110b7 100644
--- a/Debian/Debhelper/Dh_Getopt.pm
+++ b/Debian/Debhelper/Dh_Getopt.pm
@@ -34,11 +34,7 @@ sub AddPackage { my($option,$value)=@_;
push @{$dh{DOPACKAGES}}, getpackages('arch');
$dh{DOARCH}=1;
if ($option eq 's' or $option eq 'same-arch') {
- if (compat(10)) {
- warning('-s/--same-arch is deprecated; please use -a/--arch instead');
- } else {
- error('-s/--same-arch is removed in compat 11; please use -a/--arch instead');
- }
+ deprecated_functionality('-s/--same-arch is deprecated; please use -a/--arch instead', 11);
}
}
elsif ($option eq 'p' or $option eq 'package') {
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 13406cb..f4b9ca2 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -49,7 +49,7 @@ use vars qw(@EXPORT %dh);
&get_source_date_epoch &is_cross_compiling
&generated_file &autotrigger &package_section
&restore_file_on_clean &restore_all_files
- &open_gz &reset_perm_and_owner
+ &open_gz &reset_perm_and_owner &deprecated_functionality
);
# The Makefile changes this if debhelper is installed in a PREFIX.
@@ -1441,6 +1441,20 @@ sub open_gz {
return $fd;
}
+sub deprecated_functionality {
+ my ($warning_msg, $compat_removal, $removal_msg) = @_;
+ if (defined($compat_removal) and not compat($compat_removal - 1)) {
+ my $msg = $removal_msg // $warning_msg;
+ warning($msg);
+ error("This feature was removed in compat ${compat_removal}.");
+ } else {
+ warning($warning_msg);
+ warning("This feature will be removed in compat ${compat_removal}.")
+ if defined($compat_removal);
+ }
+ return 1;
+}
+
1
# Local Variables:
diff --git a/debhelper.pod b/debhelper.pod
index 4cac38c..e2e0e6e 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -592,7 +592,7 @@ B<dh_systemd_start> instead.
=item -
-The B<-s> (B<--same-arch>) option is removed.
+The B<-s> (B<--same-arch>) option is removed. Please use B<-a> (B<--arch>) instead.
=item -
diff --git a/dh_clean b/dh_clean
index 590ef3a..7da59ac 100755
--- a/dh_clean
+++ b/dh_clean
@@ -80,11 +80,9 @@ init(options => {
inhibit_log();
if ($dh{K_FLAG}) {
- # dh_prep will be emulated (mostly) by the code below.
- if (not compat(10)) {
- error("The -k option is not supported in compat 11; use dh_prep instead");
- }
- warning("dh_clean -k is deprecated; use dh_prep instead");
+ deprecated_functionality('dh_clean -k is deprecated; use dh_prep instead',
+ 11,
+ 'The -k option is not supported in compat 11; use dh_prep instead');
}
# Remove the debhelper stamp file
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index eb06372..f0482ae 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -340,6 +340,14 @@ open_gz($file)
Depending on runtime features, it might be a pipe from an
external process (which will die with a "SIGPIPE" if you
do not consume all the input)
+deprecated_functionality($warn_msg[, $rm_compat[, $rm_msg]])
+ Emit $warn_msg as a deprecation warning, or error out if $rm_compat
+ is provided and equal to (or greater than) the active compat level.
+ The $rm_msg parameter can be used to provide a custom error message
+ in the latter case (if omitted, $warn_msg will be used in both cases).
+ The function will provide a separate diagnotic about which compat
+ level that will remove/removed the functionality if $rm_compat is
+ given.
Sequence Addons:
---------------
--
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