summaryrefslogtreecommitdiff
path: root/pkgtools/R2pkg
diff options
context:
space:
mode:
authorbrook <brook@pkgsrc.org>2019-06-24 13:46:04 +0000
committerbrook <brook@pkgsrc.org>2019-06-24 13:46:04 +0000
commit27d1f15dd70ca1861a4bce84bccdbbe2395c6ffe (patch)
tree2e18032244b4a92e6a5721102bbb63f004996085 /pkgtools/R2pkg
parent0e3b617709df3fee2b22807307a401634b7dfe12 (diff)
downloadpkgsrc-27d1f15dd70ca1861a4bce84bccdbbe2395c6ffe.tar.gz
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 (limited to 'pkgtools/R2pkg')
-rw-r--r--pkgtools/R2pkg/Makefile4
-rw-r--r--pkgtools/R2pkg/files/R2pkg.823
-rwxr-xr-xpkgtools/R2pkg/files/R2pkg.sh139
-rw-r--r--pkgtools/R2pkg/files/RELEASE30
4 files changed, 147 insertions, 49 deletions
diff --git a/pkgtools/R2pkg/Makefile b/pkgtools/R2pkg/Makefile
index 8919c40a3fa..c4d229036d7 100644
--- a/pkgtools/R2pkg/Makefile
+++ b/pkgtools/R2pkg/Makefile
@@ -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 --git a/pkgtools/R2pkg/files/R2pkg.8 b/pkgtools/R2pkg/files/R2pkg.8
index 19b9d06d4a0..c882a5e5c15 100644
--- a/pkgtools/R2pkg/files/R2pkg.8
+++ b/pkgtools/R2pkg/files/R2pkg.8
@@ -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 @@ instead of the user's default editor.
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 @@ package for the R package
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 --git a/pkgtools/R2pkg/files/R2pkg.sh b/pkgtools/R2pkg/files/R2pkg.sh
index 1dd7512a037..ab3fa404067 100755
--- a/pkgtools/R2pkg/files/R2pkg.sh
+++ b/pkgtools/R2pkg/files/R2pkg.sh
@@ -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 @@ USAGE="${NAME} [-DVehqrv] [-E editor] [-R dependency_file] [package] -- create a
# Substituted by pkgsrc at pre-configure time.
MAKE=@MAKE@
EDIT=1
+MAINTAINER_EMAIL=pkgsrc-users@NetBSD.org
QUIET=0
RECURSIVE=0
TOP_LEVEL=1
@@ -51,18 +53,19 @@ VERBOSE=0
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 @@ check_for_R ()
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 @@ package <- function(s) field('R_PKGNAME',one.line(s))
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 @@ make.dependency <- function(s)
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 @@ depends <- function(s1,s2)
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 @@ use.languages <- function(s1,s2)
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
-}
-
copy.description <- function(connection)
{
description <- readLines(connection)
@@ -327,20 +374,21 @@ if (error)
quit(status=error)
metadata <- read.dcf(file='DESCRIPTION', fields=c('Package','Version','Title','Description','License','Imports','Depends'))
-
+
CVS <- '# \$NetBSD\$'
CATEGORIES <- categories()
MASTER.SITES <- 'MASTER_SITES= \${MASTER_SITE_R_CRAN:=contrib/}'
-MAINTAINER <- 'MAINTAINER= pkgsrc-users@NetBSD.org'
+MAINTAINER <- maintainer('${MAINTAINER_EMAIL}')
HOMEPAGE <- 'HOMEPAGE= \${R_HOMEPAGE_BASE}/${RPKG}/'
COMMENT <- comment(metadata[3])
LICENSE <- license(metadata[5])
R_PKGNAME <- package(metadata[1])
R_PKGVER <- version(metadata[2])
USE_LANGUAGES <- use.languages(metadata[6],metadata[7])
-DEPENDS <- depends(metadata[6],metadata[7])
+DEPENDENCIES <- depends(metadata[6],metadata[7])
+DEPENDS <- DEPENDENCIES[1]
+BUILDLINK3.MK <- DEPENDENCIES[2]
INCLUDE.R <- '.include "../../math/R/Makefile.extension"'
-INCLUDE.BUILDLINK <- buildlink(metadata[6],metadata[7])
INCLUDE.PKG <- '.include "../../mk/bsd.pkg.mk"'
DESCR <- description(metadata[4])
@@ -362,7 +410,7 @@ Makefile <- append(Makefile,'')
Makefile <- append(Makefile,USE_LANGUAGES)
Makefile <- append(Makefile,DEPENDS)
Makefile <- append(Makefile,INCLUDE.R)
-Makefile <- append(Makefile,INCLUDE.BUILDLINK)
+Makefile <- append(Makefile,BUILDLINK3.MK)
Makefile <- append(Makefile,INCLUDE.PKG)
Makefile <- paste(unlist(Makefile),collapse='\n')
@@ -419,6 +467,7 @@ cleanup ()
mv distinfo.orig distinfo
fi
rm -f ${R_FILE}
+ rm -f MAINTAINER
}
messages ()
@@ -437,7 +486,7 @@ EOF
if [ ${RECURSIVE} -ne 0 ]; then
cat << EOF
-Recursive packages may have been created in ../../R; please do the following:
+Recursive packages may have been created in ../../wip; please do the following:
- edit each Makefile as follows (in addition to following the notes above):
o move recursively created packages to the appropriate category.
o fix the category in Makefile.
diff --git a/pkgtools/R2pkg/files/RELEASE b/pkgtools/R2pkg/files/RELEASE
new file mode 100644
index 00000000000..366472af4d8
--- /dev/null
+++ b/pkgtools/R2pkg/files/RELEASE
@@ -0,0 +1,30 @@
+$NetBSD: RELEASE,v 1.1 2019/06/24 13:46:04 brook Exp $
+
+RELEASE
+=======
+
+R2pkg v.0.2 (2015-04-25)
+------------------------
+
+* Initial public release
+
+R2pkg v.0.3 (2017-07-18)
+------------------------
+
+* Add to packages conflicting with the base R package.
+
+* Add recursion (-r).
+
+* Add support for updating packages (-u).
+
+R2pkg v.0.4 (2019-06-24)
+------------------------
+
+* Fix recursion.
+
+* Add both c and c++ to USE_LANGUAGES.
+
+* Add maintainer email handling (-M).
+
+* Use buildlink3.mk files for dependencies when available.
+