From c9a6421119d44ca994770d81c35174794334e574 Mon Sep 17 00:00:00 2001
From: Mathieu Parent <mathieu.parent@nantesmetropole.fr>
Date: Thu, 16 May 2013 15:24:51 +0200
Subject: [PATCH 1/6] Initial phppear check

Check for package.xml and package2.xml
---
 checks/phppear               |   44 ++++++++++++++++++++++++++++++++++++++++++
 checks/phppear.desc          |   17 ++++++++++++++++
 profiles/debian/main.profile |    2 +-
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 checks/phppear
 create mode 100644 checks/phppear.desc

diff --git a/checks/phppear b/checks/phppear
new file mode 100644
index 0000000..88c3edb
--- /dev/null
+++ b/checks/phppear
@@ -0,0 +1,44 @@
+# phppear -- lintian check script -*- perl -*-
+
+# Copyright (C) 2013 Mathieu Parent <math.parent@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::phppear;
+
+use strict;
+use warnings;
+
+use Lintian::Tags qw(tag);
+use Lintian::Relation;
+
+sub run {
+  my ($pkg, $type, $info) = @_;
+
+
+  my $package_xml = $info->index('package.xml');
+  my $package2_xml = $info->index('package2.xml');
+  if (defined($package_xml) || defined($package2_xml)) {
+    # Checking source builddep
+    my $bdepends = $info->relation('build-depends');
+    if (!$bdepends->implies('pkg-php-tools')) {
+      tag 'pear-package-without-pkg-php-tools-builddep';
+    }
+  }
+}
+
+1;
diff --git a/checks/phppear.desc b/checks/phppear.desc
new file mode 100644
index 0000000..db27cac
--- /dev/null
+++ b/checks/phppear.desc
@@ -0,0 +1,17 @@
+Check-Script: phppear
+Author: Mathieu Parent <sathieu@debian.org>
+Abbrev: phppear
+Type: source
+Needs-Info: index
+Info: This script checks if the packages comply with various aspects of the
+ debian PHP policy.
+
+Tag: pear-package-without-pkg-php-tools-builddep
+Severity: normal
+Certainty: possible
+Info: The package contains an package.xml or package2.xml file but doesn't
+ build-depend on pkg-php-tools.
+ .
+ pkg-php-tools is the recommended tool for building PEAR and PECL packages. For
+ more information, install it and read the included README.Debian.
+
diff --git a/profiles/debian/main.profile b/profiles/debian/main.profile
index 5b6d67f..3862888 100644
--- a/profiles/debian/main.profile
+++ b/profiles/debian/main.profile
@@ -6,7 +6,7 @@ Enable-Tags-From-Check: binaries, changelog-file, changes-file, conffiles, contr
  debian-readme, debian-source-dir, description, duplicate-files, fields,
  filename-length, files, group-checks, huge-usr-share, infofiles, init.d, java,
  lintian, manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems,
- po-debconf, rules, scripts, shared-libs, source-copyright, standards-version,
+ phppear, po-debconf, rules, scripts, shared-libs, source-copyright, standards-version,
  symlinks, testsuite, version-substvars, watch-file
 Disable-Tags: hardening-no-stackprotector
 
-- 
1.7.10.4

