[dh-r] 28/43: Factor out repository guessing, not needed at build time

Gordon Ball chronitis-guest at moszumanska.debian.org
Thu Sep 15 13:45:36 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 255e50e0c45901caa2ccbb896182375ce92021e3
Author: Gordon Ball <gordon at chronitis.net>
Date:   Wed Sep 7 21:25:58 2016 +0200

    Factor out repository guessing, not needed at build time
---
 dh/R.pm | 49 +++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/dh/R.pm b/dh/R.pm
index 6ad9def..1e2d7cd 100644
--- a/dh/R.pm
+++ b/dh/R.pm
@@ -37,6 +37,28 @@ sub parse_description {
     return $desc;
 }
 
+sub get_repo {
+    my $desc = shift;
+    my $repo = "CRAN";
+    if (defined $ENV{RREPOSITORY}) {
+        $repo = $ENV{RREPOSITORY};
+        say "I: Using repo=$repo from env RREPOSITORY";
+    } elsif (length $desc->{Repo}) {
+        # this appears to be set ("CRAN") for packages originating from CRAN,
+        # but is not set for bioconductor, nor for packages direct from upstream
+        $repo = $desc->{Repo};
+        say "I: Using repo=$repo from DESCRIPTION::Repository";
+    } elsif (length $desc->{biocViews}) {
+        # however, biocViews is (presumably) only going to be set for bioconductor
+        # packages, so nonzero should identify
+        $repo = "BIOC";
+        say "I: Using repo=$repo due to existence of DESCRIPTION::biocViews";
+    } else {
+        say "I: Using repo=$repo by default";
+    }
+    return $repo;
+}
+
 sub parse_depends {
     # try and convert R package dependencies in DESCRIPTION into a
     # list of debian package dependencies
@@ -93,35 +115,15 @@ sub install {
         say "I: R package with Priority: $desc->{Priority}, installing in $libdir";
     }
 
-    my $repo = "CRAN";
-    if (defined $ENV{RRepository}) {
-        $repo = $ENV{RRepository};
-        say "I: Using repo=$repo from env RRepository";
-    } elsif (length $desc->{Repo}) {
-        # this appears to be set ("CRAN") for packages originating from CRAN,
-        # but is not set for bioconductor, nor for packages direct from upstream
-        $repo = $desc->{Repo};
-        say "I: Using repo=$repo from DESCRIPTION::Repository";
-    } elsif (length $desc->{biocViews}) {
-        # however, biocViews is (presumably) only going to be set for bioconductor
-        # packages, so nonzero should identify
-        $repo = "BIOC";
-        say "I: Using repo=$repo due to existence of DESCRIPTION::biocViews";
-    } elsif ($sourcepackage =~ /^r-cran/) {
-        $repo = "CRAN";
-        say "I: Using repo=$repo based on source package name";
-    } elsif ($sourcepackage =~ /^r-bioc/) {
-        $repo = "BIOC";
-        say "I: Using repo=$repo based on source package name";
-    } else {
-        say "I: Using repo=$repo by default";
-    }
+    my $repo = get_repo($desc);
 
 
     # 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($desc->{Package});
     say "I: Using debian package name: $debname";
+    # we don't actually need to know this here since we're already supplied
+    # with the correct destination dir
 
     chomp(my $rbase_version = qx/dpkg-query -W -f='\${Version}' r-base-dev/);
     say "I: Building using R version $rbase_version";
@@ -132,7 +134,6 @@ sub install {
     my $changelog_time = Dpkg::Changelog::Parse::changelog_parse()->{Date};
     say "I: Using built-time from d/changelog: $changelog_time";
 
-
     $this->doit_in_sourcedir("mkdir", "-p", "$destdir/$libdir");
 
     my @instargs;

-- 
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