pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/R2pkg/files pkgtools/R2pkg: clean up shell pr...
details: https://anonhg.NetBSD.org/pkgsrc/rev/e1ee71cdda19
branches: trunk
changeset: 403019:e1ee71cdda19
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat Oct 19 16:18:55 2019 +0000
description:
pkgtools/R2pkg: clean up shell program
diffstat:
pkgtools/R2pkg/files/R2pkg.sh | 107 +++++++++++++++++++----------------------
1 files changed, 50 insertions(+), 57 deletions(-)
diffs (270 lines):
diff -r 5a404de68a9f -r e1ee71cdda19 pkgtools/R2pkg/files/R2pkg.sh
--- a/pkgtools/R2pkg/files/R2pkg.sh Sat Oct 19 15:47:19 2019 +0000
+++ b/pkgtools/R2pkg/files/R2pkg.sh Sat Oct 19 16:18:55 2019 +0000
@@ -1,5 +1,5 @@
#!/bin/sh
-# $NetBSD: R2pkg.sh,v 1.9 2019/10/13 15:35:48 rillig Exp $
+# $NetBSD: R2pkg.sh,v 1.10 2019/10/19 16:18:55 rillig Exp $
#
# Copyright (c) 2014,2015,2016,2017,2018,2019
# Brook Milligan. All rights reserved.
@@ -57,39 +57,38 @@
VERBOSE=0
DESCRIPTION=no
-DESCRIPTION_CONNECTION=connection
-ARGS=""
-while getopts cDehqruVvE:M:L:P: f
+args=""
+while getopts cDehqruVvE:M:L:P: arg
do
- case ${f} in
+ case ${arg} in
# options without arguments
- c) UPDATE=false; ARGS="${ARGS} -c";;
- D) DESCRIPTION=yes; DESCRIPTION_CONNECTION="'DESCRIPTION'"; ARGS="${ARGS} -D";;
- e) EDIT=0; ARGS="${ARGS} -e";;
+ c) args="${args} ${arg}"; UPDATE=false;;
+ D) args="${args} ${arg}"; DESCRIPTION=yes;;
+ e) args="${args} ${arg}"; EDIT=0;;
h) echo "${USAGE}"; exit 0;;
- q) QUIET=true; ARGS="${ARGS} -q";;
- r) RECURSIVE=true; ARGS="${ARGS} -r";;
- u) UPDATE=true; ARGS="${ARGS} -u";;
+ q) args="${args} ${arg}"; QUIET=true;;
+ r) args="${args} ${arg}"; RECURSIVE=true;;
+ u) args="${args} ${arg}"; UPDATE=true;;
V) echo "${NAME} v${VERS}"; exit 0;;
- v) VERBOSE=$((${VERBOSE}+1)); ARGS="${ARGS} -v";;
+ v) args="${args} ${arg}"; VERBOSE=$((VERBOSE + 1));;
# options taking arguments
- E) PKGEDITOR=${OPTARG}; ARGS="${ARGS} -E ${PKGEDITOR}";;
- M) MAINTAINER_EMAIL=${OPTARG}; ARGS="${ARGS} -M ${MAINTAINER_EMAIL}";;
+ E) args="${args} ${arg} ${OPTARG}"; PKGEDITOR=${OPTARG};;
+ M) args="${args} ${arg} ${OPTARG}"; MAINTAINER_EMAIL=${OPTARG};;
# options for recursion; only for internal use
L) LEVEL=${OPTARG};;
P) PID=${OPTARG};;
# unknown options
- \?) echo "${USAGE}" 1>&2; exit 1;;
+ \?) echo "${USAGE}" 1>&2; exit 1;;
esac
done
-shift `expr ${OPTIND} - 1`
+shift $((OPTIND - 1))
-# Update ${ARGS} for recursive call
-ARGS="${ARGS} -L $((${LEVEL}+1)) -P ${PID}"
+# Update ${args} for recursive call
+args="${args} -L $((LEVEL + 1)) -P ${PID}"
if [ ${#} -eq 0 ]; then
- RPKG=$(basename $(pwd) | sed -e 's/^R-//')
+ RPKG=$(basename "$(pwd)" | sed -e 's/^R-//')
elif [ ${#} -eq 1 ]; then
RPKG=${1}
else
@@ -100,7 +99,7 @@
R_FILE=${TMPDIR}/R2pkg.$$.R
-if [ ${UPDATE} = true -a -r Makefile ]; then
+if [ ${UPDATE} = true ] && [ -r Makefile ]; then
BANNER_MSG="[ ${LEVEL} ] ===> Updating R package R-${RPKG} in $(pwd)"
else
BANNER_MSG="[ ${LEVEL} ] ===> Creating R package R-${RPKG} in $(pwd)"
@@ -117,9 +116,6 @@
ECHO_DONE=":"
ECHO_FETCH=":"
ECHO_EXTRACT=":"
- if [ ${LEVEL} -ne 0 ]; then
- ECHO=":"
- fi
elif [ ${VERBOSE} -eq 0 ]; then
STDOUT_MAKESUM=">/dev/null"
STDOUT_EXTRACT=">/dev/null"
@@ -149,22 +145,25 @@
CRAN_PACKAGES=pub/R/web/packages
RPKG_DESCRIPTION_URL=${CRAN_URL}/${CRAN_PACKAGES}/${RPKG}/DESCRIPTION
+exists ()
+{
+ case "$#,$*" in (1,*\**) return 1;; esac
+ return 0
+}
+
check_for_R ()
{
- R_CMD="Rscript --no-save /dev/null"
- eval ${R_CMD}
- if [ ${?} -ne 0 ]; then
- echo "ERROR: math/R package is not installed." 1>&2
- exit 1
- fi
+ Rscript --no-save /dev/null && return
+ echo "ERROR: math/R package is not installed." 1>&2
+ exit 1
}
check_for_no_recursion ()
{
- touch ${PACKAGES_LIST}
- grep -E -q -e "${RPKG}" ${PACKAGES_LIST} \
+ touch "${PACKAGES_LIST}"
+ grep -E -q -e "${RPKG}" "${PACKAGES_LIST}" \
&& echo "ERROR: circular dependency" 1>&2
- echo "${RPKG}" >> ${PACKAGES_LIST}
+ echo "${RPKG}" >> "${PACKAGES_LIST}"
}
preserve_original_content ()
@@ -187,7 +186,7 @@
make_package ()
{
env LEVEL="${LEVEL}" RPKG="${RPKG}" PACKAGES_LIST="${PACKAGES_LIST}" \
- R2PKG="${R2PKG}" ARGS="${ARGS}" RECURSIVE="${RECURSIVE}" \
+ R2PKG="${R2PKG}" ARGS="${args}" RECURSIVE="${RECURSIVE}" \
UPDATE="${UPDATE}" DEPENDENCY_LIST="${DEPENDENCY_LIST}" \
MAINTAINER_EMAIL="${MAINTAINER_EMAIL}" \
RPKG_DESCRIPTION_URL="${RPKG_DESCRIPTION_URL}" \
@@ -203,14 +202,14 @@
edit_Makefile ()
{
- if [ ${EDIT} -ne 0 -a -s Makefile ]; then
+ if [ ${EDIT} -ne 0 ] && [ -s Makefile ]; then
${PKGEDITOR} Makefile
fi
}
edit_DESCR ()
{
- if [ ${EDIT} -ne 0 -a -s DESCR ]; then
+ if [ ${EDIT} -ne 0 ] && [ -s DESCR ]; then
${PKGEDITOR} DESCR
fi
}
@@ -219,11 +218,11 @@
{
${ECHO_FETCH} "==> Fetching R-${RPKG} ..."
MAKE_CMD="${MAKE} makesum ${STDOUT_MAKESUM}"
- eval ${MAKE_CMD}
+ eval "${MAKE_CMD}"
error=${?}
if [ ${error} -eq 0 ]; then
MAKE_CMD="${MAKE} makepatchsum ${STDOUT_MAKESUM}"
- eval ${MAKE_CMD}
+ eval "${MAKE_CMD}"
error=${?}
fi
return ${error}
@@ -242,14 +241,14 @@
{
${ECHO_EXTRACT} "[ ${LEVEL} ] Extracting R-${RPKG} ..."
MAKE_CMD="env SKIP_DEPENDS=yes ${MAKE} clean extract ${STDOUT_EXTRACT}"
- eval ${MAKE_CMD}
+ eval "${MAKE_CMD}"
}
check_license ()
{
rm -f LICENSE
# echo '===> LICENSE files:'
- if [ -f work/*/LICENSE ]; then
+ if exists work/*/LICENSE; then
grep -v "^YEAR: " work/*/LICENSE \
| grep -v "^COPYRIGHT HOLDER: " \
| grep -v "^ORGANIZATION: " \
@@ -257,7 +256,7 @@
if [ -s LICENSE ]; then
# ninka -d LICENSE
cp work/*/LICENSE .
- /bin/echo -n "[ ${LEVEL} ] Current license: "
+ printf '%s' "[ ${LEVEL} ] Current license: "
grep LICENSE Makefile
echo "[ ${LEVEL} ] Please check it against the following:"
cat LICENSE
@@ -272,17 +271,13 @@
check_copying ()
{
- if [ -f work/*/COPYING ]; then
- cp work/*/COPYING .
- fi
- if [ -f work/*/COPYING.lib ]; then
- cp work/*/COPYING.lib .
- fi
+ exists work/*/COPYING && cp work/*/COPYING .
+ exists work/*/COPYING.lib && cp work/*/COPYING.lib .
}
cleanup_DESCR ()
{
- if [ -f DESCR -a -f DESCR.orig ]; then
+ if [ -f DESCR ] && [ -f DESCR.orig ]; then
if diff --ignore-case --ignore-all-space --ignore-blank-lines DESCR.orig DESCR > /dev/null; then
mv DESCR.orig DESCR
else
@@ -296,19 +291,17 @@
cleanup_Makefile ()
{
- if [ -f Makefile -a -f Makefile.orig ]; then
+ if [ -f Makefile ] && [ -f Makefile.orig ]; then
diff --ignore-case --ignore-all-space --ignore-blank-lines Makefile.orig Makefile > /dev/null \
&& mv Makefile.orig Makefile
elif [ -f Makefile.orig ]; then
mv Makefile.orig Makefile
- else
- echo "[ ${LEVEL} ] $(pwd): neither Makefile nor Makefile.orig"
fi
}
cleanup_buildlink3 ()
{
- if [ buildlink3.mk -a -f buildlink3.mk.orig ]; then
+ if [ -f buildlink3.mk ] && [ -f buildlink3.mk.orig ]; then
diff --ignore-case --ignore-all-space --ignore-blank-lines buildlink3.mk.orig buildlink3.mk > /dev/null \
&& mv buildlink3.mk.orig buildlink3.mk
elif [ -f buildlink3.mk.orig ]; then
@@ -318,7 +311,7 @@
cleanup_distinfo ()
{
- if [ -f distinfo -a -f distinfo.orig ]; then
+ if [ -f distinfo ] && [ -f distinfo.orig ]; then
tail +2 distinfo.orig > ${TMPDIR}/distinfo.orig.${PID}
tail +2 distinfo > ${TMPDIR}/distinfo.${PID}
cmp -s ${TMPDIR}/distinfo.orig.${PID} ${TMPDIR}/distinfo.${PID} \
@@ -340,8 +333,8 @@
rm -f USE_TOOLS
rm -f DEPENDS
rm -f BUILDLINK3.MK
- [ ${LEVEL} -eq 0 ] && rm -f ${PACKAGES_LIST}
- [ ${LEVEL} -eq 0 ] && rm -f ${DEPENDENCY_LIST}
+ [ ${LEVEL} -eq 0 ] && rm -f "${PACKAGES_LIST}"
+ [ ${LEVEL} -eq 0 ] && rm -f "${DEPENDENCY_LIST}"
}
cleanup ()
@@ -355,7 +348,7 @@
messages ()
{
- if [ ${QUIET} = false -a ${LEVEL} -eq 0 ]; then
+ if [ ${QUIET} = false ] && [ ${LEVEL} -eq 0 ]; then
cat << EOF
Please do not forget the following:
@@ -378,8 +371,8 @@
o fix the category of any dependencies.
o remove any extraneous dependencies.
EOF
- if [ -s ${DEPENDENCY_LIST} ]; then
- tsort ${DEPENDENCY_LIST} > depends
+ if [ -s "${DEPENDENCY_LIST}" ]; then
+ tsort "${DEPENDENCY_LIST}" > depends
echo "- It may be useful to test these packages in the following order:"
awk 'BEGIN{printf(" ")} {printf(" R-%s",$0)}' depends && echo
fi
Home |
Main Index |
Thread Index |
Old Index