pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc R2pkg: update to 0.4.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/63c68ee9cf35
branches:  trunk
changeset: 335629:63c68ee9cf35
user:      brook <brook%pkgsrc.org@localhost>
date:      Mon Jun 24 13:46:04 2019 +0000

description:
R2pkg: update to 0.4.

Changes since 0.3:
* Fix recursion.
* Add both c and c++ to USE_LANGUAGES.
* Add maintainer email handling (-M).
* Use buildlink3.mk files for dependencies when available.

diffstat:

 doc/CHANGES-2019              |    3 +-
 pkgtools/R2pkg/Makefile       |    4 +-
 pkgtools/R2pkg/files/R2pkg.8  |   23 ++++++-
 pkgtools/R2pkg/files/R2pkg.sh |  139 ++++++++++++++++++++++++++++-------------
 pkgtools/R2pkg/files/RELEASE  |   30 +++++++++
 5 files changed, 149 insertions(+), 50 deletions(-)

diffs (truncated from 389 to 300 lines):

diff -r 9ce163a0a65c -r 63c68ee9cf35 doc/CHANGES-2019
--- a/doc/CHANGES-2019  Mon Jun 24 12:05:36 2019 +0000
+++ b/doc/CHANGES-2019  Mon Jun 24 13:46:04 2019 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES-2019,v 1.2670 2019/06/24 11:35:45 jperkin Exp $
+$NetBSD: CHANGES-2019,v 1.2671 2019/06/24 13:46:04 brook Exp $
 
 Changes to the packages collection and infrastructure in 2019:
 
@@ -4434,3 +4434,4 @@
        Added games/oshu version 2.0.0 [nia 2019-06-23]
        Updated emulators/mame to 0.210 [wiz 2019-06-23]
        mk/bsd.pkg.mk: started freeze for pkgsrc-2019Q2 branch [jperkin 2019-06-24]
+       Updated pkgtools/R2pkg to 0.4 [brook 2019-06-24]
diff -r 9ce163a0a65c -r 63c68ee9cf35 pkgtools/R2pkg/Makefile
--- a/pkgtools/R2pkg/Makefile   Mon Jun 24 12:05:36 2019 +0000
+++ b/pkgtools/R2pkg/Makefile   Mon Jun 24 13:46:04 2019 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.2 2017/07/18 17:24:31 brook Exp $
+# $NetBSD: Makefile,v 1.3 2019/06/24 13:46:04 brook Exp $
 #
 
-VERS=          0.3
+VERS=          0.4
 PKGNAME=       R2pkg-${VERS}
 CATEGORIES=    pkgtools
 
diff -r 9ce163a0a65c -r 63c68ee9cf35 pkgtools/R2pkg/files/R2pkg.8
--- a/pkgtools/R2pkg/files/R2pkg.8      Mon Jun 24 12:05:36 2019 +0000
+++ b/pkgtools/R2pkg/files/R2pkg.8      Mon Jun 24 13:46:04 2019 +0000
@@ -1,6 +1,6 @@
-.\"    $NetBSD: R2pkg.8,v 1.4 2017/07/18 18:44:06 wiz Exp $
+.\"    $NetBSD: R2pkg.8,v 1.5 2019/06/24 13:46:04 brook Exp $
 .\"
-.\" Copyright (c) 2014,2015,2016,2017
+.\" Copyright (c) 2014,2015,2016,2017,2018,2019
 .\"    Brook Milligan.  All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@
 .Nm
 .Op Fl DehqruVv
 .Op Fl E Ar editor
+.Op Fl M Ar maintainer_email
 .Op Fl R Ar dependency_file
 .Op Ar package
 .Sh DESCRIPTION
@@ -105,6 +106,8 @@
 Do not edit Makefile and DESCR.
 .It Fl h
 Produce a short help message.
+.It Fl M Ar maintainer_email
+Set the maintainer email address for any newly created packages.
 .It Fl q
 Do not produce status messages along the way.
 .It Fl R Ar dependency_file
@@ -182,6 +185,22 @@
 Remember to test the resulting package and remove any extra files
 created by
 .Nm .
+Adding
+.Fl r
+to the command line will also recursively create all necessary
+dependencies in the
+.Pa wip
+directory.
+.Pp
+Use the following commands to update a
+.Xr pkgsrc 7
+package (and dependencies) for the R package
+.Ar foo :
+.Dl cd pkgsrc/math/R-foo
+.Dl R2pkg -r -u
+Packages built for any new dependencies will be added to the
+.Pa wip
+directory.
 .Sh SEE ALSO
 .Xr pkgsrc 7
 .Sh AUTHORS
diff -r 9ce163a0a65c -r 63c68ee9cf35 pkgtools/R2pkg/files/R2pkg.sh
--- a/pkgtools/R2pkg/files/R2pkg.sh     Mon Jun 24 12:05:36 2019 +0000
+++ b/pkgtools/R2pkg/files/R2pkg.sh     Mon Jun 24 13:46:04 2019 +0000
@@ -1,8 +1,7 @@
 #!/bin/sh
-# $NetBSD: R2pkg.sh,v 1.3 2018/01/13 09:10:33 jperkin Exp $
-# R2pkg
+# $NetBSD: R2pkg.sh,v 1.4 2019/06/24 13:46:04 brook Exp $
 #
-# Copyright (c) 2014,2015,2016,2017
+# Copyright (c) 2014,2015,2016,2017,2018,2019
 #      Brook Milligan.  All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -35,7 +34,9 @@
 NAME="R2pkg"
 VERS="@VERS@"
 
-USAGE="${NAME} [-DVehqrv] [-E editor] [-R dependency_file] [package] -- create an R package for pkgsrc"
+R2PKG=${0}
+
+USAGE="${NAME} [-DVehqrv] [-E editor] [-M maintainer] [-R dependency_file] [package] -- create an R package for pkgsrc"
 
 : ${CRAN_URL:=ftp://cran.r-project.org}
 : ${PKGEDITOR:=${EDITOR:=vi}}
@@ -43,6 +44,7 @@
 # Substituted by pkgsrc at pre-configure time.
 MAKE=@MAKE@
 EDIT=1
+MAINTAINER_EMAIL=pkgsrc-users%NetBSD.org@localhost
 QUIET=0
 RECURSIVE=0
 TOP_LEVEL=1
@@ -51,18 +53,19 @@
 
 DESCRIPTION_CONNECTION=connection
 
-while getopts DE:R:Vehqruv f
+while getopts DE:M:R:Vehqruv f
 do
     case $f in
        D) DESCRIPTION=yes; DESCRIPTION_CONNECTION="'DESCRIPTION'"; ARGS="${ARGS} -D";;
        E) PKGEDITOR=${OPTARG}; ARGS="${ARGS} -E ${PKGEDITOR}";;
+       M) MAINTAINER_EMAIL=${OPTARG}; ARGS="${ARGS} -M ${MAINTAINER_EMAIL}";;
        R) DEPENDENCY_LIST=${OPTARG}; RECURSIVE=1; TOP_LEVEL=0; ARGS="${ARGS} -R ${DEPENDENCY_LIST}";;
        V) echo "${NAME} v${VERS}"; exit 0;;
        e) EDIT=0; ARGS="${ARGS} -e";;
        h) echo ${USAGE}; exit 0;;
        q) QUIET=1; ARGS="${ARGS} -q";;
        r) RECURSIVE=1; RECURSIVE_MESSAGE=1; ARGS="${ARGS} -r";;
-       u) UPDATE=1;;
+       u) UPDATE=1; ARGS="${ARGS} -u";;
        v) VERBOSE=$((${VERBOSE}+1)); ARGS="${ARGS} -v";;
         \?) echo ${USAGE}; exit 1;;
     esac
@@ -149,6 +152,7 @@
 preserve_original_files ()
 {
     [ -f DESCR ]    && mv DESCR DESCR.orig
+    [ -f Makefile ] && grep -e "MAINTAINER=" Makefile > MAINTAINER
     [ -f Makefile ] && mv Makefile Makefile.orig
     [ -f distinfo ] && mv distinfo distinfo.orig
 }
@@ -209,6 +213,19 @@
 version <- function(s) field('R_PKGVER',one.line(s))
 comment <- function(s) field('COMMENT',one.line(s))
 license <- function(s) field(todo.license(s),pkgsrc.license(s))
+maintainer <- function(email)
+  {
+     if (file.exists('MAINTAINER'))
+       {
+         x <- scan('MAINTAINER','character',quiet=TRUE)
+         if (length(x) == 2)
+           email = x[2]
+         else
+           message('WARNING: previous MAINTAINER is ignored')
+       }
+     email <- paste0('MAINTAINER=      ',email)
+     email
+   }
 
 categories <- function() paste('CATEGORIES=',paste(basename(dirname(getwd())),'R'),sep='       ')
 description <- function(s) strwrap(s,width=71)
@@ -244,7 +261,8 @@
 depends <- function(s1,s2)
 {
   imports <- make.imports(s1,s2)
-  DEPENDS <- list()
+  DEPENDS <- data.frame()
+  BUILDLINK3.MK <- data.frame()
   if (length(imports) > 0)
     {
       for (i in 1:length(imports))
@@ -252,46 +270,85 @@
           dependency <- make.dependency(imports[i])
           depends <- dependency[1]
           depends.pkg <- Sys.glob(paste('../../*/R-',depends,sep=''))
-          if (length(depends.pkg) != 1) # a unique dependency cannot be found
+          if (length(depends.pkg) == 0) # a dependency cannot be found
             {
+             message('WARNING: creating the dependency',depends)
               if (${RECURSIVE})
                 {
-                  dependency.dir <- paste('../../R/R-',depends,sep='')
+                  dependency.dir <- paste('../../wip/R-',depends,sep='')
                   dir.create(path=dependency.dir,recursive=TRUE)
-                  error <- system(paste('(cd',dependency.dir,'&& R2pkg.sh ${ARGS}',depends,')'))
+                  error <- system(paste('(cd',dependency.dir,'&& ${R2PKG} ${ARGS}',depends,')'))
                   if (error != 0)
                     file.remove(dependency.dir)
                 }
             }
           depends.pkg <- Sys.glob(paste('../../*/R-',depends,sep=''))
-          if (length(depends.pkg) == 1) # a unique dependency found
+         if (length(depends.pkg) == 0) # no dependency was created
+           message('WARNING: the dependency',depends,'does not exist')
+          else if (length(depends.pkg) == 1) # a unique dependency found
             {
-              depends.pkg.fullname <- system(paste('cd',depends.pkg,'&& bmake show-var VARNAME=PKGNAME'),intern=TRUE)
-              depends.pkg.name <- sub('^(.*)-([^-]*)$','\\\\1',depends.pkg.fullname)
-              depends.pkg.vers <- sub('^(.*)-([^-]*)$','\\\\2',depends.pkg.fullname)
-              if (length(dependency) == 2)
-                depends.vers <- dependency[2]
-              else
-                depends.vers <- paste('>=',depends.pkg.vers,sep='')
-              depends.line <- paste('DEPENDS+=\tR-',depends,depends.vers,':',depends.pkg,sep='')
-              if (length(dependency) == 2)
-                depends.line <- paste(depends.line,'   # XXX - found ',depends.pkg.fullname,' (',depends.pkg,')',sep='')
+             fields <- strsplit(depends.pkg,'/',fixed=TRUE)
+             depends.dir <- fields[[1]][3]
+             buildlink3.mk <- paste(depends.pkg,'/buildlink3.mk',sep='')
+             if (file.exists(buildlink3.mk))
+                {
+                  buildlink3.line <- paste('.include "',buildlink3.mk,'"',sep='')
+                  BUILDLINK3.MK <- rbind(BUILDLINK3.MK,data.frame(key=depends.dir,value=buildlink3.line))
+                }
+             else
+               {
+                  depends.pkg.fullname <- system(paste('cd',depends.pkg,'&& bmake show-var VARNAME=PKGNAME'),intern=TRUE)
+                  depends.pkg.name <- sub('^(.*)-([^-]*)$','\\\\1',depends.pkg.fullname)
+                  depends.pkg.vers <- sub('^(.*)-([^-]*)$','\\\\2',depends.pkg.fullname)
+                  if (length(dependency) == 2)
+                    depends.vers <- dependency[2]
+                  else
+                    depends.vers <- paste('>=',depends.pkg.vers,sep='')
+                  depends.line <- paste('DEPENDS+=\tR-',depends,depends.vers,':',depends.pkg,sep='')
+                  depends.line <- paste(depends.line,' # XXX - found ',depends.pkg.fullname,' (',depends.pkg,')',sep='')
+                  DEPENDS <- rbind(DEPENDS,data.frame(key=depends.dir,value=depends.line))
+                }
             }
-          else
+          else                 # more than 1 dependency found
             {
+             msg <- paste('WARNING: too many dependencies found for ',depends,':',sep='')
+             for (pkg in depends.pkg)
+               msg <- paste(msg,' ',pkg,sep='')
+             message(msg)
               depends.vers <- ifelse(length(dependency) == 2, dependency[2], '>=???')
               depends.vers <- trim.space(depends.vers)
-              depends.line <- paste('DEPENDS+=\tR-',depends,depends.vers,':../../R/R-',depends,sep='')
+              depends.line <- paste('DEPENDS+=\tR-',depends,depends.vers,':../../???/R-',depends,sep='')
+             depends.line <- paste(depends.line,'      # XXX - found',sep='')
+             for (pkg in depends.pkg)
+               depends.line <- paste(depends.line,' ',pkg,sep='')
+              DEPENDS <- rbind(DEPENDS,data.frame(key='???',value=depends.line))
             }
-          DEPENDS <- list(DEPENDS,depends.line)
-          new.depends.pkg <- Sys.glob(paste('../../R/R-',depends,sep=''))
+          new.depends.pkg <- Sys.glob(paste('../../wip/R-',depends,sep=''))
           if (length(new.depends.pkg) > 0)
             system(paste('echo',depends,'${RPKG} >> ${DEPENDENCY_LIST}'))
         }
     }
-  if (length(DEPENDS) > 0)
-    DEPENDS <- append(DEPENDS,'')
-  DEPENDS
+  if (nrow(DEPENDS) > 0)
+    {
+      key <- as.vector(DEPENDS[,1])
+      value <- as.vector(DEPENDS[,2])
+      key <- order(key,value)
+      DEPENDS <- as.list(value[key])
+      if (length(DEPENDS) > 0)
+        DEPENDS <- append(DEPENDS,'')
+    }
+  else
+    DEPENDS = list()
+  if (nrow(BUILDLINK3.MK) > 0)
+    {
+      key <- as.vector(BUILDLINK3.MK[,1])
+      value <- as.vector(BUILDLINK3.MK[,2])
+      key <- order(key,value)
+      BUILDLINK3.MK <- as.list(value[key])
+    }
+  else
+    BUILDLINK3.MK <- list()
+  list(DEPENDS,BUILDLINK3.MK)
 }
 
 use.languages <- function(s1,s2)
@@ -300,22 +357,12 @@
   s <- paste(s1,s2)
   Rcpp <- grepl('Rcpp',s)
   if (Rcpp)
-    USE_LANGUAGES <- append(USE_LANGUAGES,list('USE_LANGUAGES+=        c++'))
+    USE_LANGUAGES <- append(USE_LANGUAGES,list('USE_LANGUAGES+=        c c++'))
   if (length(USE_LANGUAGES) > 0)
     USE_LANGUAGES <- append(USE_LANGUAGES,'')
   USE_LANGUAGES
 }
 
-buildlink <- function(s1,s2)
-{
-  BUILDLINK <- list()
-  s <- paste(s1,s2)
-  Rcpp <- grepl('Rcpp',s)
-  if (Rcpp)
-    BUILDLINK <- append(BUILDLINK,'.include "../../devel/R-Rcpp/buildlink3.mk"')
-  BUILDLINK
-}
-



Home | Main Index | Thread Index | Old Index