Sat Oct 19 16:18:55 2019 UTC ()
pkgtools/R2pkg: clean up shell program


(rillig)
diff -r1.9 -r1.10 pkgsrc/pkgtools/R2pkg/files/R2pkg.sh

cvs diff -r1.9 -r1.10 pkgsrc/pkgtools/R2pkg/files/R2pkg.sh (expand / switch to unified diff)

--- pkgsrc/pkgtools/R2pkg/files/R2pkg.sh 2019/10/13 15:35:48 1.9
+++ pkgsrc/pkgtools/R2pkg/files/R2pkg.sh 2019/10/19 16:18:55 1.10
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#!/bin/sh 1#!/bin/sh
2# $NetBSD: R2pkg.sh,v 1.9 2019/10/13 15:35:48 rillig Exp $ 2# $NetBSD: R2pkg.sh,v 1.10 2019/10/19 16:18:55 rillig Exp $
3# 3#
4# Copyright (c) 2014,2015,2016,2017,2018,2019 4# Copyright (c) 2014,2015,2016,2017,2018,2019
5# Brook Milligan. All rights reserved. 5# Brook Milligan. All rights reserved.
6# 6#
7# Redistribution and use in source and binary forms, with or without 7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions 8# modification, are permitted provided that the following conditions
9# are met: 9# are met:
10# 1. Redistributions of source code must retain the above copyright 10# 1. Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer. 11# notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright 12# 2. Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the 13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution. 14# documentation and/or other materials provided with the distribution.
15# 3. Neither the name of the author nor the names of any contributors 15# 3. Neither the name of the author nor the names of any contributors
@@ -47,89 +47,85 @@ USAGE="${NAME} [-cDehqruVv] [-E editor]  @@ -47,89 +47,85 @@ USAGE="${NAME} [-cDehqruVv] [-E editor]
47 47
48# Substituted by pkgsrc at pre-configure time. 48# Substituted by pkgsrc at pre-configure time.
49MAKE=@MAKE@ 49MAKE=@MAKE@
50EDIT=1 50EDIT=1
51LEVEL=0 51LEVEL=0
52MAINTAINER_EMAIL=pkgsrc-users@NetBSD.org 52MAINTAINER_EMAIL=pkgsrc-users@NetBSD.org
53PID=$$ 53PID=$$
54QUIET=false 54QUIET=false
55RECURSIVE=false 55RECURSIVE=false
56UPDATE=false 56UPDATE=false
57VERBOSE=0 57VERBOSE=0
58 58
59DESCRIPTION=no 59DESCRIPTION=no
60DESCRIPTION_CONNECTION=connection 
61 60
62ARGS="" 61args=""
63while getopts cDehqruVvE:M:L:P: f 62while getopts cDehqruVvE:M:L:P: arg
64do 63do
65 case ${f} in 64 case ${arg} in
66 # options without arguments 65 # options without arguments
67 c) UPDATE=false; ARGS="${ARGS} -c";; 66 c) args="${args} ${arg}"; UPDATE=false;;
68 D) DESCRIPTION=yes; DESCRIPTION_CONNECTION="'DESCRIPTION'"; ARGS="${ARGS} -D";; 67 D) args="${args} ${arg}"; DESCRIPTION=yes;;
69 e) EDIT=0; ARGS="${ARGS} -e";; 68 e) args="${args} ${arg}"; EDIT=0;;
70 h) echo "${USAGE}"; exit 0;; 69 h) echo "${USAGE}"; exit 0;;
71 q) QUIET=true; ARGS="${ARGS} -q";; 70 q) args="${args} ${arg}"; QUIET=true;;
72 r) RECURSIVE=true; ARGS="${ARGS} -r";; 71 r) args="${args} ${arg}"; RECURSIVE=true;;
73 u) UPDATE=true; ARGS="${ARGS} -u";; 72 u) args="${args} ${arg}"; UPDATE=true;;
74 V) echo "${NAME} v${VERS}"; exit 0;; 73 V) echo "${NAME} v${VERS}"; exit 0;;
75 v) VERBOSE=$((${VERBOSE}+1)); ARGS="${ARGS} -v";; 74 v) args="${args} ${arg}"; VERBOSE=$((VERBOSE + 1));;
76 # options taking arguments 75 # options taking arguments
77 E) PKGEDITOR=${OPTARG}; ARGS="${ARGS} -E ${PKGEDITOR}";; 76 E) args="${args} ${arg} ${OPTARG}"; PKGEDITOR=${OPTARG};;
78 M) MAINTAINER_EMAIL=${OPTARG}; ARGS="${ARGS} -M ${MAINTAINER_EMAIL}";; 77 M) args="${args} ${arg} ${OPTARG}"; MAINTAINER_EMAIL=${OPTARG};;
79 # options for recursion; only for internal use 78 # options for recursion; only for internal use
80 L) LEVEL=${OPTARG};; 79 L) LEVEL=${OPTARG};;
81 P) PID=${OPTARG};; 80 P) PID=${OPTARG};;
82 # unknown options 81 # unknown options
83 \?) echo "${USAGE}" 1>&2; exit 1;; 82 \?) echo "${USAGE}" 1>&2; exit 1;;
84 esac 83 esac
85done 84done
86shift `expr ${OPTIND} - 1` 85shift $((OPTIND - 1))
87 86
88# Update ${ARGS} for recursive call 87# Update ${args} for recursive call
89ARGS="${ARGS} -L $((${LEVEL}+1)) -P ${PID}" 88args="${args} -L $((LEVEL + 1)) -P ${PID}"
90 89
91if [ ${#} -eq 0 ]; then 90if [ ${#} -eq 0 ]; then
92 RPKG=$(basename $(pwd) | sed -e 's/^R-//') 91 RPKG=$(basename "$(pwd)" | sed -e 's/^R-//')
93elif [ ${#} -eq 1 ]; then 92elif [ ${#} -eq 1 ]; then
94 RPKG=${1} 93 RPKG=${1}
95else 94else
96 echo "Error: multiple package names given." 1>&2 95 echo "Error: multiple package names given." 1>&2
97 echo "${USAGE}" 1>&2 96 echo "${USAGE}" 1>&2
98 exit 1 97 exit 1
99fi 98fi
100 99
101R_FILE=${TMPDIR}/R2pkg.$$.R 100R_FILE=${TMPDIR}/R2pkg.$$.R
102 101
103if [ ${UPDATE} = true -a -r Makefile ]; then 102if [ ${UPDATE} = true ] && [ -r Makefile ]; then
104 BANNER_MSG="[ ${LEVEL} ] ===> Updating R package R-${RPKG} in $(pwd)" 103 BANNER_MSG="[ ${LEVEL} ] ===> Updating R package R-${RPKG} in $(pwd)"
105else 104else
106 BANNER_MSG="[ ${LEVEL} ] ===> Creating R package R-${RPKG} in $(pwd)" 105 BANNER_MSG="[ ${LEVEL} ] ===> Creating R package R-${RPKG} in $(pwd)"
107fi 106fi
108 107
109PACKAGES_LIST=${TMPDIR}/R2pkg.packages.${PID} 108PACKAGES_LIST=${TMPDIR}/R2pkg.packages.${PID}
110DEPENDENCY_LIST=${TMPDIR}/R2pkg.depends.${PID} 109DEPENDENCY_LIST=${TMPDIR}/R2pkg.depends.${PID}
111 110
112if [ ${QUIET} = true ]; then 111if [ ${QUIET} = true ]; then
113 STDOUT_MAKESUM=">/dev/null" 112 STDOUT_MAKESUM=">/dev/null"
114 STDOUT_EXTRACT=">/dev/null" 113 STDOUT_EXTRACT=">/dev/null"
115 QUIET_CURL="TRUE" 114 QUIET_CURL="TRUE"
116 ECHO_BANNER=":" 115 ECHO_BANNER=":"
117 ECHO_DONE=":" 116 ECHO_DONE=":"
118 ECHO_FETCH=":" 117 ECHO_FETCH=":"
119 ECHO_EXTRACT=":" 118 ECHO_EXTRACT=":"
120 if [ ${LEVEL} -ne 0 ]; then 
121 ECHO=":" 
122 fi 
123elif [ ${VERBOSE} -eq 0 ]; then 119elif [ ${VERBOSE} -eq 0 ]; then
124 STDOUT_MAKESUM=">/dev/null" 120 STDOUT_MAKESUM=">/dev/null"
125 STDOUT_EXTRACT=">/dev/null" 121 STDOUT_EXTRACT=">/dev/null"
126 QUIET_CURL="TRUE" 122 QUIET_CURL="TRUE"
127 ECHO_BANNER="echo" 123 ECHO_BANNER="echo"
128 ECHO_DONE=":" 124 ECHO_DONE=":"
129 ECHO_FETCH=":" 125 ECHO_FETCH=":"
130 ECHO_EXTRACT="echo" 126 ECHO_EXTRACT="echo"
131elif [ ${VERBOSE} -eq 1 ]; then 127elif [ ${VERBOSE} -eq 1 ]; then
132 STDOUT_MAKESUM=">/dev/null" 128 STDOUT_MAKESUM=">/dev/null"
133 STDOUT_EXTRACT=">/dev/null" 129 STDOUT_EXTRACT=">/dev/null"
134 QUIET_CURL="TRUE" 130 QUIET_CURL="TRUE"
135 ECHO_BANNER="echo" 131 ECHO_BANNER="echo"
@@ -139,257 +135,254 @@ elif [ ${VERBOSE} -eq 1 ]; then @@ -139,257 +135,254 @@ elif [ ${VERBOSE} -eq 1 ]; then
139else 135else
140 STDOUT_MAKESUM="" 136 STDOUT_MAKESUM=""
141 STDOUT_EXTRACT="" 137 STDOUT_EXTRACT=""
142 QUIET_CURL="FALSE" 138 QUIET_CURL="FALSE"
143 ECHO_BANNER="echo" 139 ECHO_BANNER="echo"
144 ECHO_DONE="echo" 140 ECHO_DONE="echo"
145 ECHO_FETCH="echo" 141 ECHO_FETCH="echo"
146 ECHO_EXTRACT="echo" 142 ECHO_EXTRACT="echo"
147fi 143fi
148 144
149CRAN_PACKAGES=pub/R/web/packages 145CRAN_PACKAGES=pub/R/web/packages
150RPKG_DESCRIPTION_URL=${CRAN_URL}/${CRAN_PACKAGES}/${RPKG}/DESCRIPTION 146RPKG_DESCRIPTION_URL=${CRAN_URL}/${CRAN_PACKAGES}/${RPKG}/DESCRIPTION
151 147
 148exists ()
 149{
 150 case "$#,$*" in (1,*\**) return 1;; esac
 151 return 0
 152}
 153
152check_for_R () 154check_for_R ()
153{ 155{
154 R_CMD="Rscript --no-save /dev/null" 156 Rscript --no-save /dev/null && return
155 eval ${R_CMD} 157 echo "ERROR: math/R package is not installed." 1>&2
156 if [ ${?} -ne 0 ]; then 158 exit 1
157 echo "ERROR: math/R package is not installed." 1>&2 
158 exit 1 
159 fi 
160} 159}
161 160
162check_for_no_recursion () 161check_for_no_recursion ()
163{ 162{
164 touch ${PACKAGES_LIST} 163 touch "${PACKAGES_LIST}"
165 grep -E -q -e "${RPKG}" ${PACKAGES_LIST} \ 164 grep -E -q -e "${RPKG}" "${PACKAGES_LIST}" \
166 && echo "ERROR: circular dependency" 1>&2 165 && echo "ERROR: circular dependency" 1>&2
167 echo "${RPKG}" >> ${PACKAGES_LIST} 166 echo "${RPKG}" >> "${PACKAGES_LIST}"
168} 167}
169 168
170preserve_original_content () 169preserve_original_content ()
171{ 170{
172 [ -f Makefile ] && grep -e "CATEGORIES=" Makefile > CATEGORIES 171 [ -f Makefile ] && grep -e "CATEGORIES=" Makefile > CATEGORIES
173 [ -f Makefile ] && grep -e "COMMENT=" Makefile > COMMENT 172 [ -f Makefile ] && grep -e "COMMENT=" Makefile > COMMENT
174 [ -f Makefile ] && grep -e "LICENSE=" Makefile > LICENSE 173 [ -f Makefile ] && grep -e "LICENSE=" Makefile > LICENSE
175 [ -f Makefile ] && grep -e "MAINTAINER=" Makefile > MAINTAINER 174 [ -f Makefile ] && grep -e "MAINTAINER=" Makefile > MAINTAINER
176 [ -f Makefile ] && grep -e "USE_LANGUAGES" Makefile > USE_LANGUAGES 175 [ -f Makefile ] && grep -e "USE_LANGUAGES" Makefile > USE_LANGUAGES
177 [ -f Makefile ] && grep -e "USE_TOOLS" Makefile > USE_TOOLS 176 [ -f Makefile ] && grep -e "USE_TOOLS" Makefile > USE_TOOLS
178 [ -f Makefile ] && grep -e "DEPENDS" Makefile > DEPENDS 177 [ -f Makefile ] && grep -e "DEPENDS" Makefile > DEPENDS
179 [ -f Makefile ] && grep -e "buildlink3.mk" Makefile > BUILDLINK3.MK 178 [ -f Makefile ] && grep -e "buildlink3.mk" Makefile > BUILDLINK3.MK
180 179
181 [ -f DESCR ] && mv DESCR DESCR.orig 180 [ -f DESCR ] && mv DESCR DESCR.orig
182 [ -f Makefile ] && mv Makefile Makefile.orig 181 [ -f Makefile ] && mv Makefile Makefile.orig
183 [ -f buildlink3.mk ] && mv buildlink3.mk buildlink3.mk.orig 182 [ -f buildlink3.mk ] && mv buildlink3.mk buildlink3.mk.orig
184 [ -f distinfo ] && mv distinfo distinfo.orig 183 [ -f distinfo ] && mv distinfo distinfo.orig
185} 184}
186 185
187make_package () 186make_package ()
188{ 187{
189 env LEVEL="${LEVEL}" RPKG="${RPKG}" PACKAGES_LIST="${PACKAGES_LIST}" \ 188 env LEVEL="${LEVEL}" RPKG="${RPKG}" PACKAGES_LIST="${PACKAGES_LIST}" \
190 R2PKG="${R2PKG}" ARGS="${ARGS}" RECURSIVE="${RECURSIVE}" \ 189 R2PKG="${R2PKG}" ARGS="${args}" RECURSIVE="${RECURSIVE}" \
191 UPDATE="${UPDATE}" DEPENDENCY_LIST="${DEPENDENCY_LIST}" \ 190 UPDATE="${UPDATE}" DEPENDENCY_LIST="${DEPENDENCY_LIST}" \
192 MAINTAINER_EMAIL="${MAINTAINER_EMAIL}" \ 191 MAINTAINER_EMAIL="${MAINTAINER_EMAIL}" \
193 RPKG_DESCRIPTION_URL="${RPKG_DESCRIPTION_URL}" \ 192 RPKG_DESCRIPTION_URL="${RPKG_DESCRIPTION_URL}" \
194 QUIET_CURL="${QUIET_CURL}" \ 193 QUIET_CURL="${QUIET_CURL}" \
195 LC_ALL="C" \ 194 LC_ALL="C" \
196 Rscript --no-save -e "source('@LIBDIR@/R2pkg.R'); main()" 195 Rscript --no-save -e "source('@LIBDIR@/R2pkg.R'); main()"
197 retval=${?} 196 retval=${?}
198 if [ ${retval} -ne 0 ]; then 197 if [ ${retval} -ne 0 ]; then
199 echo "ERROR: making ${RPKG} package failed." 1>&2 198 echo "ERROR: making ${RPKG} package failed." 1>&2
200 fi 199 fi
201 return ${retval} 200 return ${retval}
202} 201}
203 202
204edit_Makefile () 203edit_Makefile ()
205{ 204{
206 if [ ${EDIT} -ne 0 -a -s Makefile ]; then 205 if [ ${EDIT} -ne 0 ] && [ -s Makefile ]; then
207 ${PKGEDITOR} Makefile 206 ${PKGEDITOR} Makefile
208 fi 207 fi
209} 208}
210 209
211edit_DESCR () 210edit_DESCR ()
212{ 211{
213 if [ ${EDIT} -ne 0 -a -s DESCR ]; then 212 if [ ${EDIT} -ne 0 ] && [ -s DESCR ]; then
214 ${PKGEDITOR} DESCR 213 ${PKGEDITOR} DESCR
215 fi 214 fi
216} 215}
217 216
218create_distinfo () 217create_distinfo ()
219{ 218{
220 ${ECHO_FETCH} "==> Fetching R-${RPKG} ..." 219 ${ECHO_FETCH} "==> Fetching R-${RPKG} ..."
221 MAKE_CMD="${MAKE} makesum ${STDOUT_MAKESUM}" 220 MAKE_CMD="${MAKE} makesum ${STDOUT_MAKESUM}"
222 eval ${MAKE_CMD} 221 eval "${MAKE_CMD}"
223 error=${?} 222 error=${?}
224 if [ ${error} -eq 0 ]; then 223 if [ ${error} -eq 0 ]; then
225 MAKE_CMD="${MAKE} makepatchsum ${STDOUT_MAKESUM}" 224 MAKE_CMD="${MAKE} makepatchsum ${STDOUT_MAKESUM}"
226 eval ${MAKE_CMD} 225 eval "${MAKE_CMD}"
227 error=${?} 226 error=${?}
228 fi 227 fi
229 return ${error} 228 return ${error}
230} 229}
231 230
232create_buildlink3_mk () 231create_buildlink3_mk ()
233{ 232{
234 if [ -f buildlink3.mk.orig ]; then 233 if [ -f buildlink3.mk.orig ]; then
235 PKGVERSION=$(${MAKE} show-var VARNAME=PKGVERSION) 234 PKGVERSION=$(${MAKE} show-var VARNAME=PKGVERSION)
236 sed -E -e "/BUILDLINK_API_DEPENDS\./s/[[:digit:].]+$/${PKGVERSION}/" \ 235 sed -E -e "/BUILDLINK_API_DEPENDS\./s/[[:digit:].]+$/${PKGVERSION}/" \
237 buildlink3.mk.orig > buildlink3.mk 236 buildlink3.mk.orig > buildlink3.mk
238 fi 237 fi
239} 238}
240 239
241extract () 240extract ()
242{ 241{
243 ${ECHO_EXTRACT} "[ ${LEVEL} ] Extracting R-${RPKG} ..." 242 ${ECHO_EXTRACT} "[ ${LEVEL} ] Extracting R-${RPKG} ..."
244 MAKE_CMD="env SKIP_DEPENDS=yes ${MAKE} clean extract ${STDOUT_EXTRACT}" 243 MAKE_CMD="env SKIP_DEPENDS=yes ${MAKE} clean extract ${STDOUT_EXTRACT}"
245 eval ${MAKE_CMD} 244 eval "${MAKE_CMD}"
246} 245}
247 246
248check_license () 247check_license ()
249{ 248{
250 rm -f LICENSE 249 rm -f LICENSE
251 # echo '===> LICENSE files:' 250 # echo '===> LICENSE files:'
252 if [ -f work/*/LICENSE ]; then 251 if exists work/*/LICENSE; then
253 grep -v "^YEAR: " work/*/LICENSE \ 252 grep -v "^YEAR: " work/*/LICENSE \
254 | grep -v "^COPYRIGHT HOLDER: " \ 253 | grep -v "^COPYRIGHT HOLDER: " \
255 | grep -v "^ORGANIZATION: " \ 254 | grep -v "^ORGANIZATION: " \
256 > LICENSE 255 > LICENSE
257 if [ -s LICENSE ]; then 256 if [ -s LICENSE ]; then
258 # ninka -d LICENSE 257 # ninka -d LICENSE
259 cp work/*/LICENSE . 258 cp work/*/LICENSE .
260 /bin/echo -n "[ ${LEVEL} ] Current license: " 259 printf '%s' "[ ${LEVEL} ] Current license: "
261 grep LICENSE Makefile 260 grep LICENSE Makefile
262 echo "[ ${LEVEL} ] Please check it against the following:" 261 echo "[ ${LEVEL} ] Please check it against the following:"
263 cat LICENSE 262 cat LICENSE
264 else 263 else
265 rm LICENSE 264 rm LICENSE
266 sed -E -e 's/[[:blank:]]+#[[:blank:]]+\+ file LICENSE[[:blank:]]+.*$//' Makefile > Makefile.$$ \ 265 sed -E -e 's/[[:blank:]]+#[[:blank:]]+\+ file LICENSE[[:blank:]]+.*$//' Makefile > Makefile.$$ \
267 && mv Makefile.$$ Makefile 266 && mv Makefile.$$ Makefile
268 grep -q "file LICENSE" Makefile && echo "[ ${LEVEL} ] 'file LICENSE' in Makefile but no relevant license information" 267 grep -q "file LICENSE" Makefile && echo "[ ${LEVEL} ] 'file LICENSE' in Makefile but no relevant license information"
269 fi 268 fi
270 fi 269 fi
271} 270}
272 271
273check_copying () 272check_copying ()
274{ 273{
275 if [ -f work/*/COPYING ]; then 274 exists work/*/COPYING && cp work/*/COPYING .
276 cp work/*/COPYING . 275 exists work/*/COPYING.lib && cp work/*/COPYING.lib .
277 fi 
278 if [ -f work/*/COPYING.lib ]; then 
279 cp work/*/COPYING.lib . 
280 fi 
281} 276}
282 277
283cleanup_DESCR () 278cleanup_DESCR ()
284{ 279{
285 if [ -f DESCR -a -f DESCR.orig ]; then 280 if [ -f DESCR ] && [ -f DESCR.orig ]; then
286 if diff --ignore-case --ignore-all-space --ignore-blank-lines DESCR.orig DESCR > /dev/null; then 281 if diff --ignore-case --ignore-all-space --ignore-blank-lines DESCR.orig DESCR > /dev/null; then
287 mv DESCR.orig DESCR 282 mv DESCR.orig DESCR
288 else 283 else
289 mv DESCR DESCR.new 284 mv DESCR DESCR.new
290 mv DESCR.orig DESCR 285 mv DESCR.orig DESCR
291 fi 286 fi
292 elif [ -f DESCR.orig ]; then 287 elif [ -f DESCR.orig ]; then
293 mv DESCR.orig DESCR 288 mv DESCR.orig DESCR
294 fi 289 fi
295} 290}
296 291
297cleanup_Makefile () 292cleanup_Makefile ()
298{ 293{
299 if [ -f Makefile -a -f Makefile.orig ]; then 294 if [ -f Makefile ] && [ -f Makefile.orig ]; then
300 diff --ignore-case --ignore-all-space --ignore-blank-lines Makefile.orig Makefile > /dev/null \ 295 diff --ignore-case --ignore-all-space --ignore-blank-lines Makefile.orig Makefile > /dev/null \
301 && mv Makefile.orig Makefile 296 && mv Makefile.orig Makefile
302 elif [ -f Makefile.orig ]; then 297 elif [ -f Makefile.orig ]; then
303 mv Makefile.orig Makefile 298 mv Makefile.orig Makefile
304 else 
305 echo "[ ${LEVEL} ] $(pwd): neither Makefile nor Makefile.orig" 
306 fi 299 fi
307} 300}
308 301
309cleanup_buildlink3 () 302cleanup_buildlink3 ()
310{ 303{
311 if [ buildlink3.mk -a -f buildlink3.mk.orig ]; then 304 if [ -f buildlink3.mk ] && [ -f buildlink3.mk.orig ]; then
312 diff --ignore-case --ignore-all-space --ignore-blank-lines buildlink3.mk.orig buildlink3.mk > /dev/null \ 305 diff --ignore-case --ignore-all-space --ignore-blank-lines buildlink3.mk.orig buildlink3.mk > /dev/null \
313 && mv buildlink3.mk.orig buildlink3.mk 306 && mv buildlink3.mk.orig buildlink3.mk
314 elif [ -f buildlink3.mk.orig ]; then 307 elif [ -f buildlink3.mk.orig ]; then
315 mv buildlink3.mk.orig buildlink3.mk 308 mv buildlink3.mk.orig buildlink3.mk
316 fi 309 fi
317} 310}
318 311
319cleanup_distinfo () 312cleanup_distinfo ()
320{ 313{
321 if [ -f distinfo -a -f distinfo.orig ]; then 314 if [ -f distinfo ] && [ -f distinfo.orig ]; then
322 tail +2 distinfo.orig > ${TMPDIR}/distinfo.orig.${PID} 315 tail +2 distinfo.orig > ${TMPDIR}/distinfo.orig.${PID}
323 tail +2 distinfo > ${TMPDIR}/distinfo.${PID} 316 tail +2 distinfo > ${TMPDIR}/distinfo.${PID}
324 cmp -s ${TMPDIR}/distinfo.orig.${PID} ${TMPDIR}/distinfo.${PID} \ 317 cmp -s ${TMPDIR}/distinfo.orig.${PID} ${TMPDIR}/distinfo.${PID} \
325 && mv distinfo.orig distinfo 318 && mv distinfo.orig distinfo
326 rm -f ${TMPDIR}/distinfo.orig.${PID} ${TMPDIR}/distinfo.${PID} 319 rm -f ${TMPDIR}/distinfo.orig.${PID} ${TMPDIR}/distinfo.${PID}
327 elif [ -f distinfo.orig ]; then 320 elif [ -f distinfo.orig ]; then
328 mv distinfo.orig distinfo 321 mv distinfo.orig distinfo
329 fi 322 fi
330} 323}
331 324
332cleanup_misc_files () 325cleanup_misc_files ()
333{ 326{
334 [ "${DESCRIPTION}" = "yes" ] || rm -f DESCRIPTION 327 [ "${DESCRIPTION}" = "yes" ] || rm -f DESCRIPTION
335 rm -f ${R_FILE} 328 rm -f ${R_FILE}
336 rm -f CATEGORIES 329 rm -f CATEGORIES
337 rm -f COMMENT 330 rm -f COMMENT
338 rm -f MAINTAINER 331 rm -f MAINTAINER
339 rm -f USE_LANGUAGES 332 rm -f USE_LANGUAGES
340 rm -f USE_TOOLS 333 rm -f USE_TOOLS
341 rm -f DEPENDS 334 rm -f DEPENDS
342 rm -f BUILDLINK3.MK 335 rm -f BUILDLINK3.MK
343 [ ${LEVEL} -eq 0 ] && rm -f ${PACKAGES_LIST} 336 [ ${LEVEL} -eq 0 ] && rm -f "${PACKAGES_LIST}"
344 [ ${LEVEL} -eq 0 ] && rm -f ${DEPENDENCY_LIST} 337 [ ${LEVEL} -eq 0 ] && rm -f "${DEPENDENCY_LIST}"
345} 338}
346 339
347cleanup () 340cleanup ()
348{ 341{
349 cleanup_DESCR 342 cleanup_DESCR
350 cleanup_Makefile 343 cleanup_Makefile
351 cleanup_buildlink3 344 cleanup_buildlink3
352 cleanup_distinfo 345 cleanup_distinfo
353 cleanup_misc_files 346 cleanup_misc_files
354} 347}
355 348
356messages () 349messages ()
357{ 350{
358 if [ ${QUIET} = false -a ${LEVEL} -eq 0 ]; then 351 if [ ${QUIET} = false ] && [ ${LEVEL} -eq 0 ]; then
359 cat << EOF 352 cat << EOF
360 353
361Please do not forget the following: 354Please do not forget the following:
362- check DESCR and edit as necessary. 355- check DESCR and edit as necessary.
363- check Makefile: 356- check Makefile:
364 o verify the COMMENT. 357 o verify the COMMENT.
365 o verify the LICENSE. 358 o verify the LICENSE.
366 o verify the DEPENDS, especially the categories. 359 o verify the DEPENDS, especially the categories.
367EOF 360EOF
368 [ -f buildlink3.mk ] && echo "- check buildlink3.mk" 361 [ -f buildlink3.mk ] && echo "- check buildlink3.mk"
369 362
370 [ "${DESCRIPTION}" = "yes" ] && echo "- remove DESCRIPTION." 363 [ "${DESCRIPTION}" = "yes" ] && echo "- remove DESCRIPTION."
371 if [ ${RECURSIVE} = true ]; then 364 if [ ${RECURSIVE} = true ]; then
372 cat << EOF 365 cat << EOF
373 366
374Recursive packages may have been created in ../../wip; please do the following: 367Recursive packages may have been created in ../../wip; please do the following:
375- edit each Makefile as follows (in addition to following the notes above): 368- edit each Makefile as follows (in addition to following the notes above):
376 o move recursively created packages to the appropriate category. 369 o move recursively created packages to the appropriate category.
377 o fix the category in Makefile. 370 o fix the category in Makefile.
378 o fix the category of any dependencies. 371 o fix the category of any dependencies.
379 o remove any extraneous dependencies. 372 o remove any extraneous dependencies.
380EOF 373EOF
381 if [ -s ${DEPENDENCY_LIST} ]; then 374 if [ -s "${DEPENDENCY_LIST}" ]; then
382 tsort ${DEPENDENCY_LIST} > depends 375 tsort "${DEPENDENCY_LIST}" > depends
383 echo "- It may be useful to test these packages in the following order:" 376 echo "- It may be useful to test these packages in the following order:"
384 awk 'BEGIN{printf(" ")} {printf(" R-%s",$0)}' depends && echo 377 awk 'BEGIN{printf(" ")} {printf(" R-%s",$0)}' depends && echo
385 fi 378 fi
386 fi 379 fi
387 fi 380 fi
388} 381}
389 382
390${ECHO_BANNER} "${BANNER_MSG} ..." 383${ECHO_BANNER} "${BANNER_MSG} ..."
391check_for_R 384check_for_R
392check_for_no_recursion 385check_for_no_recursion
393preserve_original_content 386preserve_original_content
394make_package 387make_package
395error=${?} 388error=${?}