summaryrefslogtreecommitdiff
path: root/dh_testversion
blob: b915dd1482300695ef1b962474c3c746029d4434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl -w

=head1 NAME

dh_testversion - ensure that the correct version of debhelper is installed

=cut

use Debian::Debhelper::Dh_Lib;
use Debian::Debhelper::Dh_Version; # contains the version number of debhelper.

=head1 SYNOPSIS

B<dh_testversion> [S<I<debhelper options>>] [I<operator>] [I<version>]

=head1 DESCRIPTION

Note: This program is deprecated. You should use build dependencies
instead.

dh_testversion compares the version of debhelper against the version you
specify, and if the condition is not met, exits with an error message.

You can use this in your debian/rules files if a new debhelper feature is
introduced, and your package requires that feature to build correctly. Use
debhelper's changelog to figure out the version you need.

Be sure not to overuse dh_testversion. If debhelper version 9.5
introduces a new dh_autofixbugs command, and your package uses it, then if
someone tries to build it with debhelper 1.0, the build will fail anyway when
dh_autofixbugs cannot be found, so there is no need for you to use
dh_testversion.

=head1 OPTIONS

=over 4

=item I<operator>

Optional comparison operator used in comparing the versions. If not 
specified, ">=" is used. For descriptions of the comparison operators, see 
dpkg --help.

=item I<version>

Version number to compare against the current version of debhelper. If not
specified, dh_testversion does nothing.

=back

=cut

init();

my($compare, $ver);

if ($#ARGV > 0) {
	$compare=shift;
	$ver=shift;
}
elsif ($#ARGV eq 0) {
	$compare=">=";
	$ver=shift;
}

if (defined $compare and defined $ver) {
	system('dpkg','--compare-versions',$Debian::Debhelper::Dh_Version::version,$compare,$ver) == 0 ||
		error("debhelper version $Debian::Debhelper::Dh_Version::version is installed, but a version $compare $ver is needed to build this package.");
}

=head1 SEE ALSO

L<debhelper(1)>

This program is a part of debhelper.

=head1 AUTHOR

Joey Hess <joeyh@debian.org>

=cut