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

Bug#605012: lintian: Add check for missing build-arch and build-indep targets in debian/rules



Updated patch attached.  Error text updated to use correct target
name and indent code correctly.

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
From ff35018a03699ba88d0b0ab5439551ed8de74b7e Mon Sep 17 00:00:00 2001
From: Roger Leigh <rleigh@debian.org>
Date: Fri, 26 Nov 2010 09:54:28 +0000
Subject: [PATCH] Add check for missing build-arch and build-indep targets in debian/rules

Add new check (tag debian-rules-missing-recommended-target)
Update testsuite

Signed-off-by: Roger Leigh <rleigh@debian.org>
---
 checks/rules                                       |   13 ++++++++++++
 checks/rules.desc                                  |   21 ++++++++++++++++++++
 t/tests/debhelper-deprecated/debian/debian/rules   |    6 +++-
 .../debian/debian/rules                            |    6 +++-
 .../debhelper-dh-clean-k-ok/debian/debian/rules    |    6 +++-
 t/tests/debhelper-dh-depends/debian/debian/rules   |    5 +++-
 .../debian/debian/rules                            |    6 +++-
 t/tests/fields-quilt-debhelper/debian/debian/rules |   10 +++++---
 t/tests/generic-empty/desc                         |    1 +
 t/tests/generic-empty/tags                         |    2 +
 testset/binary/debian/rules                        |    6 +++-
 testset/debconf/debian/rules                       |   11 ++++++++-
 testset/debug/debian/rules                         |    9 ++++++-
 testset/etcfiles/debian/rules                      |    3 ++
 testset/fields/debian/rules                        |    8 +++++-
 testset/filenames/debian/rules                     |    9 ++++++-
 testset/foo++/debian/rules                         |    8 +++++-
 testset/libbaz/debian/rules                        |   10 ++++++--
 testset/maintainer-scripts/debian/rules            |    8 +++++-
 testset/relations/debian/rules                     |    8 +++++-
 testset/scripts/debian/rules                       |    9 ++++++-
 testset/tags.binary                                |    1 +
 testset/tags.etcfiles                              |    1 +
 23 files changed, 133 insertions(+), 34 deletions(-)

diff --git a/checks/rules b/checks/rules
index 358db41..126c8e2 100644
--- a/checks/rules
+++ b/checks/rules
@@ -88,6 +88,10 @@ my @RULE_CLEAN_DEPENDS =
 my %required = map { $_ => 1 }
     qw(build binary binary-arch binary-indep clean);
 
+# The following targets are recommended per Policy.
+my %recommended = map { $_ => 1 }
+    qw(build-arch build-indep);
+
 # Rules about required debhelper command ordering.  Each command is put into a
 # class and the tag is issued if they're called in the wrong order for the
 # classes.  Unknown commands won't trigger this flag.
@@ -208,6 +212,7 @@ while (<RULES>) {
         my @targets = split (' ', $1);
         for (@targets) {
             $seen{$_}++ if $required{$_};
+            $seen{$_}++ if $recommended{$_};
         }
     }
 
@@ -225,8 +230,12 @@ while (<RULES>) {
                 for my $required (keys %required) {
                     $seen{$required}++ if $required =~ m/$pattern/;
                 }
+                for my $recommended (keys %recommended) {
+                    $seen{$recommended}++ if $recommended =~ m/$pattern/;
+                }
             } else {
                 $seen{$target}++ if $required{$target};
+                $seen{$target}++ if $recommended{$target};
             }
             if (grep { $target =~ /$_/ } @arch_rules) {
                 push (@arch_rules, @depends);
@@ -292,6 +301,10 @@ unless ($includes) {
         tag "debian-rules-missing-required-target", $target
             unless $seen{$target};
     }
+    for my $target (sort keys %recommended) {
+        tag "debian-rules-missing-recommended-target", $target
+            unless $seen{$target};
+    }
 }
 
 # Make sure we have no content for binary-arch if we are arch-indep:
diff --git a/checks/rules.desc b/checks/rules.desc
index 7dd263f..55dbd98 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -35,6 +35,27 @@ Info: The <tt>debian/rules</tt> file for this package does not provide one
  binary-indep, and clean must be provided, even if they don't do anything
  for this package.
 
+Tag: debian-rules-missing-recommended-target
+Severity: normal
+Certainty: certain
+Ref: policy 4.9
+Info: The <tt>debian/rules</tt> file for this package does not provide
+ one of the recommended targets.  All of build-arch and build-indep
+ should be provided, even if they don't do anything for this package.
+ If this package does not currently split building of architecture
+ dependent and independent packages, the following rules may be added
+ to fall back to the build target:
+ .
+   build-arch: build
+   build-indep: build
+ .
+ Note that the following form is recommended however:
+ .
+   build: build-arch build-indep
+ .
+ These targets will be required by policy in the future, so should be
+ added to prevent future breakage.
+
 Tag: debian-rules-uses-pwd
 Severity: normal
 Certainty: certain
diff --git a/t/tests/debhelper-deprecated/debian/debian/rules b/t/tests/debhelper-deprecated/debian/debian/rules
index 7ec4692..f75cfb6 100755
--- a/t/tests/debhelper-deprecated/debian/debian/rules
+++ b/t/tests/debhelper-deprecated/debian/debian/rules
@@ -2,7 +2,9 @@
 
 pkg = $(shell dh_listpackages)
 
-build:
+build: build-indep build-arch
+build-arch:
+build-indep:
 
 clean:
 	dh_testdir
@@ -37,4 +39,4 @@ endif
 	dh_md5sums
 	dh_builddeb
 
-.PHONY: binary binary-arch binary-indep build clean
+.PHONY: build-arch build-indep build binary binary-arch binary-indep clean
diff --git a/t/tests/debhelper-dh-clean-k-deprecated/debian/debian/rules b/t/tests/debhelper-dh-clean-k-deprecated/debian/debian/rules
index 488e728..bd004e3 100755
--- a/t/tests/debhelper-dh-clean-k-deprecated/debian/debian/rules
+++ b/t/tests/debhelper-dh-clean-k-deprecated/debian/debian/rules
@@ -6,7 +6,9 @@
 
 pkg = $(shell dh_listpackages)
 
-build:
+build: build-arch build-indep
+build-arch:
+build-indep:
 
 clean:
 	dh_testdir
@@ -32,4 +34,4 @@ binary-indep:
 	dh_md5sums
 	dh_builddeb
 
-.PHONY: binary binary-arch binary-indep build clean
+.PHONY: build-arch build-indep build binary binary-arch binary-indep clean
diff --git a/t/tests/debhelper-dh-clean-k-ok/debian/debian/rules b/t/tests/debhelper-dh-clean-k-ok/debian/debian/rules
index 488e728..243e5c2 100755
--- a/t/tests/debhelper-dh-clean-k-ok/debian/debian/rules
+++ b/t/tests/debhelper-dh-clean-k-ok/debian/debian/rules
@@ -6,7 +6,9 @@
 
 pkg = $(shell dh_listpackages)
 
-build:
+build: build-indep build-arch
+build-arch:
+build-indep:
 
 clean:
 	dh_testdir
@@ -32,4 +34,4 @@ binary-indep:
 	dh_md5sums
 	dh_builddeb
 
-.PHONY: binary binary-arch binary-indep build clean
+.PHONY: build-arch build-indep build binary binary-arch binary-indep clean
diff --git a/t/tests/debhelper-dh-depends/debian/debian/rules b/t/tests/debhelper-dh-depends/debian/debian/rules
index 1c04f36..803501b 100755
--- a/t/tests/debhelper-dh-depends/debian/debian/rules
+++ b/t/tests/debhelper-dh-depends/debian/debian/rules
@@ -1,6 +1,9 @@
 #!/usr/bin/make -f
 
-build: build-stamp
+build: build-arch build-indep
+build-arch:
+build-indep: build-stamp
+
 build-stamp:
 	dh_testdir
 	dh_auto_configure
diff --git a/t/tests/debhelper-script-token-unneeded/debian/debian/rules b/t/tests/debhelper-script-token-unneeded/debian/debian/rules
index bbd9fb3..ee51749 100755
--- a/t/tests/debhelper-script-token-unneeded/debian/debian/rules
+++ b/t/tests/debhelper-script-token-unneeded/debian/debian/rules
@@ -6,7 +6,9 @@
 
 pkg = $(shell dh_listpackages)
 
-build:
+build: build-indep build-arch
+build-indep:
+build-arch:
 
 clean:
 	dh_testdir
@@ -31,4 +33,4 @@ binary-indep:
 	dh_md5sums
 	dh_builddeb
 
-.PHONY: binary binary-arch binary-indep build clean
+.PHONY: build-arch build-indep build binary binary-arch binary-indep clean
diff --git a/t/tests/fields-quilt-debhelper/debian/debian/rules b/t/tests/fields-quilt-debhelper/debian/debian/rules
index d893de8..da794bd 100755
--- a/t/tests/fields-quilt-debhelper/debian/debian/rules
+++ b/t/tests/fields-quilt-debhelper/debian/debian/rules
@@ -1,6 +1,8 @@
 #!/usr/bin/make -f
 
-build:
+build: build-arch build-indep
+build-arch:
+build-indep:
 	dh_quilt_patch
 
 clean:
@@ -17,8 +19,8 @@ install: build
 	dh_install
 
 binary: binary-indep binary-arch
-binary-arch: build install
-binary-indep: build install
+binary-arch: build-arch install
+binary-indep: build-indep install
 	dh_testdir
 	dh_testroot
 	dh_installchangelogs
@@ -31,4 +33,4 @@ binary-indep: build install
 	dh_md5sums
 	dh_builddeb
 
-.PHONY: build clean binary-indep binary-arch binary install
+.PHONY: build-arch build-indep build clean binary-indep binary-arch binary install
diff --git a/t/tests/generic-empty/desc b/t/tests/generic-empty/desc
index a994997..9d4aef9 100644
--- a/t/tests/generic-empty/desc
+++ b/t/tests/generic-empty/desc
@@ -8,6 +8,7 @@ Test-For:
  changed-by-address-missing
  changelog-should-mention-nmu
  debian-rules-missing-required-target
+ debian-rules-missing-recommended-target
  maintainer-address-missing
  maintainer-not-full-name
  no-copyright-file
diff --git a/t/tests/generic-empty/tags b/t/tests/generic-empty/tags
index d6742e1..2acd3a2 100644
--- a/t/tests/generic-empty/tags
+++ b/t/tests/generic-empty/tags
@@ -9,6 +9,8 @@ E: generic-empty_1.0_arch changes: bad-urgency-in-changes-file unknown
 E: generic-empty_1.0_arch changes: changed-by-address-malformed a <>
 E: generic-empty_1.0_arch changes: changed-by-address-missing a <>
 W: generic-empty source: changelog-should-mention-nmu
+W: generic-empty source: debian-rules-missing-recommended-target build-arch
+W: generic-empty source: debian-rules-missing-recommended-target build-indep
 W: generic-empty source: maintainer-not-full-name a
 W: generic-empty source: no-section-field-for-source
 W: generic-empty source: source-nmu-has-incorrect-version-number 1.0
diff --git a/testset/binary/debian/rules b/testset/binary/debian/rules
index be68ea0..08dd671 100755
--- a/testset/binary/debian/rules
+++ b/testset/binary/debian/rules
@@ -4,10 +4,12 @@ tmp=debian/tmp
 
 # This reference to $(PWD) should not cause an error but the one below
 # should.
-build:
+build-arch:
 	make
 	echo $(PWD)
 
+build: build-arch
+
 clean:
 	make -i clean
 	rm -f debian/files debian/substvars
@@ -88,4 +90,4 @@ binary-arch: build
 
 binary: binary-arch
 
-.PHONY: build binary-arch binary clean
+.PHONY: build-arch build binary-arch binary clean
diff --git a/testset/debconf/debian/rules b/testset/debconf/debian/rules
index 4cedfcd..65d283b 100755
--- a/testset/debconf/debian/rules
+++ b/testset/debconf/debian/rules
@@ -6,10 +6,17 @@ deb_dir		=	debian/debconf
 udeb_dir	=	debian/debconf-udeb
 build_dirs	=	$(deb_dir) $(udeb_dir)
 
-build:
+build-indep:
+# There are no architecture-independent files to be built
+# by this package.  If there were any they would be made
+# here.
+
+build-arch:
 	dh_testdir
 	touch build
 
+build: build-indep build-arch
+
 clean:
 	dh_testdir
 	dh_testroot
@@ -56,4 +63,4 @@ binary-arch:	build
 
 binary:		binary-indep binary-arch
 
-.PHONY: binary binary-arch binary-indep clean checkroot
+.PHONY: build-arch build-indep build binary binary-arch binary-indep clean checkroot
diff --git a/testset/debug/debian/rules b/testset/debug/debian/rules
index 26e777e..b4e68e2 100755
--- a/testset/debug/debian/rules
+++ b/testset/debug/debian/rules
@@ -4,7 +4,10 @@
 
 export DH_COMPAT := 5
 
-build: build-stamp
+build-indep:
+
+build-arch: build-stamp
+
 build-stamp:
 	dh_testdir
 	gcc -D_REENTRANT -fPIC -c libhello.c
@@ -13,6 +16,8 @@ build-stamp:
 	gcc -o hello hello.c -L. -lhello
 	touch build-stamp
 
+build: build-arch build-indep
+
 clean:
 	dh_testdir
 	dh_testroot
@@ -86,4 +91,4 @@ binary-arch: build-stamp install
 
 binary-indep:
 binary: binary-indep binary-arch
-.PHONY: binary binary-indep binary-arch build clean install
+.PHONY: build-arch build-indep build binary binary-indep binary-arch clean install
diff --git a/testset/etcfiles/debian/rules b/testset/etcfiles/debian/rules
index 60eb147..4434415 100755
--- a/testset/etcfiles/debian/rules
+++ b/testset/etcfiles/debian/rules
@@ -9,6 +9,9 @@ clean:
 	rm -rf debian/only-etcfiles
 
 build:
+build-arch:
+build-indep:
+build-indep:
 binary-indep:
 	install -d $(tmp)/etc
 	install -m 644 proper $(tmp)/etc
diff --git a/testset/fields/debian/rules b/testset/fields/debian/rules
index eb139f3..2d74d8b 100755
--- a/testset/fields/debian/rules
+++ b/testset/fields/debian/rules
@@ -2,7 +2,11 @@
 
 tmp=debian/tmp
 
-build:
+build-arch:
+
+build-indep:
+
+build: build-arch build-indep
 
 binary-arch:
 
@@ -26,4 +30,4 @@ binary: binary-arch binary-indep
 clean:
 	rm -rf debian/files $(tmp) debian/substvars
 
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-arch build-indep build binary-arch binary-indep binary clean
diff --git a/testset/filenames/debian/rules b/testset/filenames/debian/rules
index f77a857..3dacf6d 100755
--- a/testset/filenames/debian/rules
+++ b/testset/filenames/debian/rules
@@ -27,7 +27,12 @@ clean:
 	touch "files/'\\ "
 	touch filenames.c~
 
-build:
+build-arch:
+
+build-indep:
+
+build: build-arch build-indep
+
 
 binary-arch:
 
@@ -232,4 +237,4 @@ binary-indep:
 
 binary: binary-arch binary-indep
 
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-indep build-arch build binary-arch binary-indep binary clean
diff --git a/testset/foo++/debian/rules b/testset/foo++/debian/rules
index d769f80..b04bd36 100755
--- a/testset/foo++/debian/rules
+++ b/testset/foo++/debian/rules
@@ -3,7 +3,11 @@
 foo=foo++
 helper=foo++-helper
 
-build:
+build-arch:
+
+build-indep:
+
+build: build-arch build-indep
 
 binary-arch:
 
@@ -29,4 +33,4 @@ binary: binary-arch binary-indep
 
 clean:
 
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-arch build-indep build binary-arch binary-indep binary clean
diff --git a/testset/libbaz/debian/rules b/testset/libbaz/debian/rules
index 8ed2bb0..65cec1b 100755
--- a/testset/libbaz/debian/rules
+++ b/testset/libbaz/debian/rules
@@ -6,9 +6,13 @@ dev_tmp=debian/tmp-dev
 LIB=libbaz1
 DEV=libbaz1-dev
 
-build:
+build-arch:
 	$(MAKE)
 
+build-indep:
+
+build: build-arch build-indep
+
 clean:
 	$(MAKE) clean
 	dh_clean -plibbaz2 -plibbaz2-dev
@@ -57,7 +61,7 @@ binary-correct:
 	dh_builddeb -plibbaz2 -plibbaz2-dev -plibbaz2-dbg -pia32-libbaz2
 
 # and the incorrect one
-binary-arch: build binary-correct
+binary-arch: build-arch binary-correct
 	# first, the lib package
 	install -d $(lib_tmp)/usr/lib
 	# resp. no soname (check), wrong soname (check), and no-pic (check)
@@ -120,4 +124,4 @@ binary: binary-arch
 
 # The mention of binary-indep here should be sufficient to suppress the
 # warning that it's not present.
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-arch build-indep build binary-arch binary-indep binary clean
diff --git a/testset/maintainer-scripts/debian/rules b/testset/maintainer-scripts/debian/rules
index 98240ed..f1f4075 100755
--- a/testset/maintainer-scripts/debian/rules
+++ b/testset/maintainer-scripts/debian/rules
@@ -1,6 +1,10 @@
 #!/usr/bin/make -f
 
-build:
+build-arch:
+
+build-indep:
+
+build: build-arch build-indep
 
 binary-arch:
 
@@ -29,4 +33,4 @@ clean2:
 	dh_clean
 clean3:
 
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-arch build-indep build binary-arch binary-indep binary clean
diff --git a/testset/relations/debian/rules b/testset/relations/debian/rules
index 722be9b..76ef605 100755
--- a/testset/relations/debian/rules
+++ b/testset/relations/debian/rules
@@ -18,7 +18,11 @@
 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
-build:
+build-arch:
+
+build-indep:
+
+build: build-arch build-indep
 
 binary-arch:
 
@@ -45,4 +49,4 @@ clean::
 # Test requiring perl Build-Depends for manual perl invocations.
 	[ ! -f Build ] || $(PERL) Build distclean
 
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-arch build-indep build binary-arch binary-indep binary clean
diff --git a/testset/scripts/debian/rules b/testset/scripts/debian/rules
index 3a4ab8c..e90d227 100755
--- a/testset/scripts/debian/rules
+++ b/testset/scripts/debian/rules
@@ -2,7 +2,12 @@
 
 tmp=debian/tmp
 
-build:
+build-arch:
+	echo "Hi, in an arch: all package, I am a bug!"
+
+build-indep:
+
+build: build-arch build-indep
 
 binary-arch:
 	echo "Hi, in an arch: all package, I am a bug!"
@@ -99,4 +104,4 @@ binary: binary-arch binary-indep
 clean:
 	rm -rf debian/files $(tmp) debian/substvars
 
-.PHONY: build binary-arch binary-indep binary clean
+.PHONY: build-arch build-indep build binary-arch binary-indep binary clean
diff --git a/testset/tags.binary b/testset/tags.binary
index c206f69..41a9ff3 100644
--- a/testset/tags.binary
+++ b/testset/tags.binary
@@ -58,6 +58,7 @@ I: binary: capitalization-error-in-description debian Debian
 I: binary: desktop-entry-contains-encoding-key /usr/share/applications/goodbye.desktop:11 Encoding
 I: binary: desktop-entry-contains-encoding-key /usr/share/applications/hello.desktop:13 Encoding
 I: binary: no-md5sums-control-file
+W: binary source: debian-rules-missing-recommended-target build-indep
 W: binary source: ancient-standards-version 3.2.1 (current is 3.9.1)
 W: binary source: debian-rules-ignores-make-clean-error line 12
 W: binary source: debian-rules-uses-pwd line 9
diff --git a/testset/tags.etcfiles b/testset/tags.etcfiles
index 7875f92..49bfb0f 100644
--- a/testset/tags.etcfiles
+++ b/testset/tags.etcfiles
@@ -10,6 +10,7 @@ E: etcfiles: no-copyright-file
 E: etcfiles: non-etc-file-marked-as-conffile /var/lib/foo
 E: only-etcfiles: extended-description-is-empty
 I: etcfiles source: missing-debian-source-format
+W: etcfiles source: debian-rules-missing-recommended-target build-arch
 W: etcfiles source: ancient-standards-version 3.5.0 (current is 3.9.1)
 W: etcfiles: file-missing-in-md5sums etc/improper-link
 W: etcfiles: file-missing-in-md5sums usr/share/doc/etcfiles/changelog
-- 
1.7.2.3

Attachment: signature.asc
Description: Digital signature


Reply to: