[dh-r] 01/43: Initial commit

Gordon Ball chronitis-guest at moszumanska.debian.org
Thu Sep 15 13:45:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

chronitis-guest pushed a commit to branch master
in repository dh-r.

commit 023f5eb3f778446b896648a60836aae170564713
Author: Gordon Ball <gordon at chronitis.net>
Date:   Thu Sep 1 16:28:08 2016 +0200

    Initial commit
---
 debian/changelog     |   5 ++
 debian/compat        |   1 +
 debian/control       |  12 ++++
 debian/copyright     |  12 ++++
 debian/dh-r.install  |   1 +
 debian/rules         |   4 ++
 debian/source/format |   1 +
 dh/R.pm              | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 206 insertions(+)

diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..273db3c
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+dh-r (20160901) unstable; urgency=medium
+
+  * Initial release.
+
+ -- Gordon Ball <gordon at chronitis.net>  Thu, 01 Sep 2016 16:27:35 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..38be5df
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,12 @@
+Source: dh-r
+Section: science
+Priority: optional
+Maintainer: Gordon Ball <gordon at chronitis.net>
+Build-Depends: debhelper (>= 9), libdpkg-perl
+Standards-Version: 3.9.8
+
+Package: dh-r
+Architecture: all
+Depends: ${misc:Depends}, r-base-dev
+Description: Debian helper tools for packaging Julia libraries
+ Provides the julia buildsystem for debhelper.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..a1f3a6e
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,12 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+
+Files: *
+Copyright: 2016 Gordon Ball <gordon at chronitis.net>
+License: MIT
+
+License: MIT
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
diff --git a/debian/dh-r.install b/debian/dh-r.install
new file mode 100644
index 0000000..4ccd903
--- /dev/null
+++ b/debian/dh-r.install
@@ -0,0 +1 @@
+dh/R.pm usr/share/perl5/Debian/Debhelper/Buildsystem
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..a5e0d78
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,4 @@
+#! /usr/bin/make -f
+
+%:
+	dh $@
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/dh/R.pm b/dh/R.pm
new file mode 100644
index 0000000..936523a
--- /dev/null
+++ b/dh/R.pm
@@ -0,0 +1,170 @@
+# A debhelper build system for R
+
+package Debian::Debhelper::Buildsystem::R;
+
+use feature say;
+use strict;
+use Cwd;
+use Dpkg::Control::Info;
+use Dpkg::Changelog::Debian;
+use Debian::Debhelper::Dh_Lib;
+use base 'Debian::Debhelper::Buildsystem';
+
+sub DESCRIPTION {
+    "R buildsystem"
+}
+
+sub new {
+    my $class=shift;
+    my $this=$class->SUPER::new(@_);
+    $this->enforce_in_source_building();
+    return $this;
+}
+
+sub check_auto_buildable {
+    # R packages are auto-buildable if they contain ./DESCRIPTION in the
+    # source package
+
+    my $this=shift;
+    return -e $this->get_sourcepath("DESCRIPTION") ? 1 : 0;
+}
+
+sub parse_depends {
+    # try and convert R package dependencies in DESCRIPTION into a
+    # list of debian package dependencies
+
+    my $field = shift;
+    my @text = split(/,/, qx/grep-dctrl -s $field -n . DESCRIPTION/);
+    my @deps;
+    foreach my $dep (@text) {
+        chomp $dep;
+        # rely on the R version format being equivalent
+        $dep =~ /^(\w+)\s*(\(.*\))?$/;
+        my $pkg = lc $1;
+        my $vers = $2;
+        if ($pkg eq "r") {
+            # TODO: check if the available version of R satisfies this
+            # for now, discard it, since we generate R (>= curver)
+            say "W: Ignoring specified R dependency: $dep";
+            next;
+        }
+
+        if (system("dpkg-query", "-W", "r-cran-$pkg") == 0) {
+            say "I: Using r-cran-$pkg for $field:$dep";
+            push (@deps, "r-cran-$pkg $vers");
+        } elsif (system("dpkg-query", "-W", "r-bioc-$pkg") == 0) {
+            say "I: Using r-bioc-$pkg for $field:$dep";
+            push (@deps, "r-bioc-$pkg $vers");
+        } else {
+            say "W: Cannot find a debian package for $field:$dep";
+        }
+    }
+    return @deps;
+}
+
+sub install {
+    my $this = shift;
+    my $destdir = shift;
+
+    # it would be nice to use Dpkg::Control::Info here since the
+    # format is the same, but we can't because it checks the first
+    # block contains Source: and errors when it doesn't
+    my $rpackage = qx/grep-dctrl -s Package -n . DESCRIPTION/;
+    my $rversion = qx/grep-dctrl -s Version -n . DESCRIPTION/;
+
+    say "I: R Package: $rpackage Version: $rversion";
+
+    # Priority: Recommended should go in /library instead of /site-library
+    my $rpriority = qx/grep-dctrl -s Priority -n . DESCRIPTION/;
+
+    my $libdir = "usr/lib/R/site-library";
+    if ($rpriority eq "Recommended") {
+        $libdir = "usr/lib/R/library";
+        say "I: R package with Priority: $rpriority, installing in $libdir";
+    }
+
+    # this appears to be set ("CRAN") for packages originating from CRAN,
+    # but is not set for bioconductor, nor for packages direct from upstream
+    my $rrepo = qx/grep-dctrl -s Repository -n . DESCRIPTION/;
+
+    # however, biocViews is (presumably) only going to be set for bioconductor
+    # packages, so nonzero should identify
+    my $rbiocviews = qx/grep-dctrl -s biocViews -n . DESCRIPTION/;
+
+    my $srcctrl = Dpkg::Control::Info->new()->get_source();
+
+    my $repo = "CRAN";
+    if (defined $ENV{RRepository}) {
+        $repo = $ENV{RRepository};
+        say "I: Using repo=$repo from env RRepository";
+    } elsif (length $rrepo) {
+        $repo = $rrepo;
+        say "I: Using repo=$repo from DESCRIPTION::Repository";
+    } elsif (length $rbiocviews) {
+        $repo = "BIOC";
+        say "I: Using repo=$repo due to existence of DESCRIPTION::biocViews";
+    } elsif ($this->sourcepackage() =~ /^r-cran/) {
+        $repo = "CRAN";
+        say "I: Using repo=$repo based on source package name";
+    } elsif ($this->sourcepackage() =~ /^r-bioc/) {
+        $repo = "BIOC";
+        say "I: Using repo=$repo based on source package name";
+    } else {
+        say "I: Using repo=$repo by default";
+    }
+
+
+    # this is used to determine the install directory during build
+    # TODO: check this actually matches the binary name in d/control?
+    my $debname = "r-" . lc($repo) . "-" . lc($rpackage);
+    say "I: Using debian package name: $debname";
+
+    my $rpkgversion = qx/dpkg-query -W -f='\${Version}' r-base-dev/;
+    say "I: Building using R version $rpkgversion";
+
+    my $rapiversion = qx/dpkg-query -W -f='\${Provides}' r-base-core | grep -o 'r-api[^, ]*'/;
+    say "I: R API version: $rapiversion";
+
+    my $builttime = qx/dpkg-parsechangelog | grep-dctrl -s Date -n ./;
+    say "I: Using built-time from d/changelog: $builttime";
+
+
+
+    $this->doit_in_sourcedir("mkdir", "-p", "$destdir/$libdir");
+
+    my @instargs;
+    if (defined $ENV{RMakeFlags}) {
+        say "I: Using MAKEFLAGS=" . $ENV{RMakeFlags};
+        push (@instargs, "MAKEFLAGS=" . $ENV{RMakeFlags});
+    }
+
+    push (@instargs, "R", "CMD", "INSTALL", "-l", "$destdir/$libdir", "--clean");
+    if (defined $ENV{RExtraInstallFlags}) {
+        say "I: Using extra install flags: $ENV{RExtraInstallFlags}";
+        push (@instargs, $ENV{RExtraInstallFlags});
+    }
+    push (@instargs, "--built-timestamp='$builttime'");
+
+    $this->doit_in_sourcedir(@instargs);
+
+    my @toremove = ("R.css", "COPYING*", "LICENSE*");
+    foreach my $rmf (@toremove) {
+        $this->doit_in_sourcedir("rm", "-vf", "$destdir/$libdir/$rpackage/$rmf");
+    }
+
+    my $sourcepackage = $this->sourcepackage();
+    my $rdepends = join(",", parse_depends("Depends"));
+    my $rrecommends = join(",", parse_depends("Recommends"));
+    my $rsuggests = join(",", parse_depends("Suggests"));
+    my $rimports = join(",", parse_depends("Imports"));
+
+    open(my $svs, ">>", "debian/$sourcepackage.substvars");
+    say $svs "R:Depends=r-base-core (>= $rversion), $rapiversion";
+    say $svs "R:PkgDepends=$rdepends, $rimports";
+    say $svs "R:Recommends=$rrecommends";
+    say $svs "R:Suggests=$rsuggests";
+    close $svs;
+
+}
+
+1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/dh-r.git



More information about the debian-science-commits mailing list