[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#568748: lintian: check for deprecated Debian-specific Makefile.PL usage



Package: lintian
Version: 2.3.3
Severity: wishlist

As discussed in #545904, about 250 perl library packages use an obsolete
way of overriding the installation directory at build time. Please consider
the attached patch, which adds a check for Makefile.PL based packages using 
 make install PREFIX=something
without setting DESTDIR.

This would allow us to eventually remove a Debian-specific patch to
ExtUtils::MakeMaker as upstream has long ago provided a different way
to get the same behaviour.

There's some room for both false positives and negatives, as lintian
doesn't parse debian/rules very carefully, ignoring at least continuation
lines and end of line comments. I'll try to address that with a separate
patch.

Thanks for your work on lintian,
-- 
Niko Tyni   ntyni@debian.org
>From 9bd8aa0be4e2d1393e6aea27cbbdd52b91724ffa Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Sat, 6 Feb 2010 15:09:20 +0200
Subject: [PATCH] Check for deprecated Debian-specific Makefile.PL usage

As discussed in #545904, about 250 perl library packages use an obsolete
way of overriding the installation directory at build time.
---
 checks/rules                                       |    5 ++
 checks/rules.desc                                  |   17 +++++
 t/tests/rules-perl-makemaker/debian/Foo.pm         |    3 +
 t/tests/rules-perl-makemaker/debian/Makefile.PL    |    6 ++
 t/tests/rules-perl-makemaker/debian/debian/compat  |    1 +
 .../rules-perl-makemaker/debian/debian/control.in  |   14 ++++
 t/tests/rules-perl-makemaker/debian/debian/rules   |   63 ++++++++++++++++++++
 t/tests/rules-perl-makemaker/desc                  |    6 ++
 t/tests/rules-perl-makemaker/tags                  |    1 +
 9 files changed, 116 insertions(+), 0 deletions(-)
 create mode 100644 t/tests/rules-perl-makemaker/debian/Foo.pm
 create mode 100644 t/tests/rules-perl-makemaker/debian/Makefile.PL
 create mode 100644 t/tests/rules-perl-makemaker/debian/debian/compat
 create mode 100644 t/tests/rules-perl-makemaker/debian/debian/control.in
 create mode 100755 t/tests/rules-perl-makemaker/debian/debian/rules
 create mode 100644 t/tests/rules-perl-makemaker/desc
 create mode 100644 t/tests/rules-perl-makemaker/tags

diff --git a/checks/rules b/checks/rules
index 230d52e..db5610c 100644
--- a/checks/rules
+++ b/checks/rules
@@ -143,9 +143,11 @@ my @current_targets;
 my %rules_per_target;
 my %debhelper_group;
 my $maybe_skipping;
+my $uses_makefile_pl = 0;
 while (<RULES>) {
     next if /^\s*\#/;
     $includes = 1 if m/^ *[s-]?include\s+/;
+    $uses_makefile_pl = 1 if m/Makefile\.PL/;
 
     # Check for DH_COMPAT settings outside of any rule, which are now
     # deprecated.  It's a bit easier structurally to do this here than in
@@ -168,6 +170,9 @@ while (<RULES>) {
     if (/^\s*DEB_AUTO_UPDATE_DEBIAN_CONTROL\s*=\s*yes/) {
         tag 'debian-rules-automatically-updates-control', "line $.";
     }
+    if ($uses_makefile_pl && /install.*PREFIX/ && !/DESTDIR/) {
+        tag 'debian-rules-perl-makemaker-prefix-is-deprecated', "line $.";
+    }
 
     # Keep track of whether this portion of debian/rules may be optional
     if (/^ifn?(eq|def)\s/) {
diff --git a/checks/rules.desc b/checks/rules.desc
index 9f3df07..801f291 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -158,3 +158,20 @@ Info: The specified package is required to run the clean target of
  <tt>debian/rules</tt> and therefore must be listed in Build-Depends, not
  Build-Depends-Indep, even if no architecture-dependent packages are
  built.
+
+Tag: debian-rules-perl-makemaker-prefix-is-deprecated
+Severity: normal
+Certainty: possible
+Info: The package appears to use an ExtUtils::MakeMaker (Makefile.PL)
+ build system and sets the temporary installation path by overriding
+ PREFIX when calling `make install'. This only works because of a Debian
+ specific ExtUtils::MakeMaker change that the maintainers of the Debian
+ perl package want to remove once the packages needing it are fixed.
+ .
+ The preferred way to set the installation directory is with DESTDIR.
+ Setting PREFIX should not be necessary at all. For example, the line
+  make install PREFIX=$(TMP)/usr          # WRONG
+ should be replaced with
+  make install DESTDIR=$(TMP)             # RIGHT
+ .
+ See http://bugs.debian.org/545904 for more details.
diff --git a/t/tests/rules-perl-makemaker/debian/Foo.pm b/t/tests/rules-perl-makemaker/debian/Foo.pm
new file mode 100644
index 0000000..533bb3c
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/debian/Foo.pm
@@ -0,0 +1,3 @@
+package Foo;
+our $VERSION = '1.1';
+1;
diff --git a/t/tests/rules-perl-makemaker/debian/Makefile.PL b/t/tests/rules-perl-makemaker/debian/Makefile.PL
new file mode 100644
index 0000000..ccd0d80
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/debian/Makefile.PL
@@ -0,0 +1,6 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME	=> 'Foo',
+    VERSION_FROM => 'Foo.pm',
+);
diff --git a/t/tests/rules-perl-makemaker/debian/debian/compat b/t/tests/rules-perl-makemaker/debian/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/debian/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/t/tests/rules-perl-makemaker/debian/debian/control.in b/t/tests/rules-perl-makemaker/debian/debian/control.in
new file mode 100644
index 0000000..d52ef24
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/debian/debian/control.in
@@ -0,0 +1,14 @@
+Source: {$srcpkg}
+Priority: extra
+Section: {$section}
+Maintainer: {$author}
+Standards-Version: {$standards_version}
+Build-Depends: debhelper (>= 5)
+
+Package: {$srcpkg}
+Architecture: {$architecture}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Description: {$description}
+ This is a test package designed to exercise some feature or tag of
+ Lintian.  It is part of the Lintian test suite and may do very odd
+ things.  It should not be installed like a regular package.
diff --git a/t/tests/rules-perl-makemaker/debian/debian/rules b/t/tests/rules-perl-makemaker/debian/debian/rules
new file mode 100755
index 0000000..4559967
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/debian/debian/rules
@@ -0,0 +1,63 @@
+#!/usr/bin/make -f
+
+#export DH_VERBOSE=1
+
+PERL ?= /usr/bin/perl
+
+PACKAGE = $(shell dh_listpackages)
+TMP     = $(CURDIR)/debian/$(PACKAGE)
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+
+	perl Makefile.PL verbose INSTALLDIRS=vendor
+
+	touch configure-stamp
+
+build: build-stamp
+build-stamp: configure-stamp
+	dh_testdir
+
+	$(MAKE) OPTIMIZE="-O2 -g -Wall"
+	$(MAKE) test
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+
+	[ ! -e Makefile ] || $(MAKE) distclean
+
+	dh_clean configure-stamp build-stamp
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	$(MAKE) install PREFIX=$(TMP)/usr
+
+	# Remove any empty directories
+	find $(TMP)/usr -type d -empty -print0 | xargs --no-run-if-empty --null rmdir -p --ignore-fail-on-non-empty
+
+binary-arch:
+
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installdocs
+	dh_installman
+	dh_installchangelogs
+	dh_compress
+	dh_fixperms
+	dh_installdeb
+	dh_perl
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/t/tests/rules-perl-makemaker/desc b/t/tests/rules-perl-makemaker/desc
new file mode 100644
index 0000000..04e6615
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/desc
@@ -0,0 +1,6 @@
+Testname: rules-perl-makemaker
+Sequence: 6000
+Version: 1.0
+Description: Check detection of PREFIX usage in Makefile.PL based packages
+Test-For: debian-rules-perl-makemaker-prefix-is-deprecated
+References: Debian Bug#545904
diff --git a/t/tests/rules-perl-makemaker/tags b/t/tests/rules-perl-makemaker/tags
new file mode 100644
index 0000000..96918df
--- /dev/null
+++ b/t/tests/rules-perl-makemaker/tags
@@ -0,0 +1 @@
+W: rules-perl-makemaker source: debian-rules-perl-makemaker-prefix-is-deprecated line 41
-- 
1.6.6.1


Reply to: