Date: Sat, 1 Sep 2007 14:37:35 +0200 From: "Alexander Leidinger" <netchild@FreeBSD.org> To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org> Cc: portmgr@FreeBSD.org Subject: ports/115994: remove the use of basename and dirname calls in bsd.port.mk Message-ID: <1188650255.92324@deskjail.leidinger.net> Resent-Message-ID: <200709011240.l81Ce1cJ002469@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 115994 >Category: ports >Synopsis: remove the use of basename and dirname calls in bsd.port.mk >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Sep 01 12:40:00 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Alexander Leidinger >Release: FreeBSD 7.0-CURRENT i386 >Organization: FreeBSD >Environment: System: FreeBSD 7.0-CURRENT #251: Wed Aug 15 21:58:34 CEST 2007 root@Magellan.Leidinger.net:/usr/src/sys/i386/compile/WORK >Description: There are some uses of basename and dirname in bsd.port.mk. They can be replaced by makefile logic instead of exec()ing basename or dirname. I haven't tested the performance impact/improvement. Included are also 3 style fixes (whitespace). >How-To-Repeat: >Fix: --- remove_basename_call.diff begins here --- Index: bsd.port.mk =================================================================== RCS file: /import/FreeBSD-CVS/ports/Mk/bsd.port.mk,v retrieving revision 1.580 diff -u -r1.580 bsd.port.mk --- bsd.port.mk 8 Aug 2007 03:46:04 -0000 1.580 +++ bsd.port.mk 1 Sep 2007 12:24:18 -0000 @@ -3376,15 +3437,15 @@ ${_MASTER_SITES_ENV} ; \ for _file in ${DISTFILES}; do \ file=$${_file%%:*}; \ - if [ $$_file = $$file ]; then \ + if [ $$_file = $$file ]; then \ select=''; \ else \ select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ; \ fi; \ force_fetch=false; \ - filebasename=`${BASENAME} $$file`; \ + filebasename=$${file##*/}; \ for afile in ${FORCE_FETCH}; do \ - afile=`${BASENAME} $$afile`; \ + afile=$${afile##*/}; \ if [ "x$$afile" = "x$$filebasename" ]; then \ force_fetch=true; \ fi; \ @@ -3447,15 +3508,15 @@ file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \ select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \ force_fetch=false; \ - filebasename=`${BASENAME} $$file`; \ + filebasename=$${file##*/}; \ for afile in ${FORCE_FETCH}; do \ - afile=`${BASENAME} $$afile`; \ + afile=$${afile##*/}; \ if [ "x$$afile" = "x$$filebasename" ]; then \ force_fetch=true; \ fi; \ done; \ if [ ! -f $$file -a ! -f $$filebasename -o "$$force_fetch" = "true" ]; then \ - if [ -L $$file -o -L `${BASENAME} $$file` ]; then \ + if [ -L $$file -o -L $${file##*/} ]; then \ ${ECHO_MSG} "=> ${_DISTDIR}/$$file is a broken symlink."; \ ${ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"; \ ${ECHO_MSG} "=> Please correct this problem and try again."; \ @@ -4436,7 +4504,7 @@ for _file in ${DISTFILES}; do \ file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \ select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \ - if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \ + if [ ! -f $$file -a ! -f $${file##*/} ]; then \ if [ ! -z "$$select" ] ; then \ __MASTER_SITES_TMP= ; \ for group in $$select; do \ @@ -4473,7 +4541,7 @@ for _file in ${PATCHFILES}; do \ file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \ select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \ - if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \ + if [ ! -f $$file -a ! -f $${file##*/} ]; then \ if [ ! -z "$$select" ] ; then \ __PATCH_SITES_TMP= ; \ for group in $$select; do \ @@ -5025,7 +5093,7 @@ for child in $$children; do \ case $$state in \ 0) \ - if [ -d $$child ]; then \ + if [ -d $$child ]; then \ ${ECHO_CMD} $$d; \ fi; \ state=1;; \ @@ -5064,7 +5132,7 @@ for child in $$children; do \ case $$state in \ 0) \ - if [ ! -d $$child ]; then \ + if [ ! -d $$child ]; then \ break; \ fi; \ state=1; \ @@ -5804,13 +5878,15 @@ @exit 1 .endif .if ${UID} != 0 && !defined(INSTALL_AS_USER) - @${ECHO_MSG} "===> Switching to root credentials to create `${DIRNAME} ${_OPTIONSFILE}`" - @(${SU_CMD} "${SH} -c \"${MKDIR} `${DIRNAME} ${_OPTIONSFILE}` 2> /dev/null\"") || \ - (${ECHO_MSG} "===> Cannot create `${DIRNAME} ${_OPTIONSFILE}`, check permissions"; exit 1) - @${ECHO_MSG} "===> Returning to user credentials" -.else - @(${MKDIR} `${DIRNAME} ${_OPTIONSFILE}` 2> /dev/null) || \ - (${ECHO_MSG} "===> Cannot create `${DIRNAME} ${_OPTIONSFILE}`, check permissions"; exit 1) + @optionsdir=${_OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \ + ${ECHO_MSG} "===> Switching to root credentials to create $${optionsdir}"; \ + (${SU_CMD} "${SH} -c \"${MKDIR} $${optionsdir} 2> /dev/null\"") || \ + (${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1); \ + ${ECHO_MSG} "===> Returning to user credentials" +.else + @(optionsdir=${_OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \ + ${MKDIR} $${optionsdir} 2> /dev/null) || \ + (${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1) .endif -@if [ -e ${_OPTIONSFILE} ]; then \ . ${_OPTIONSFILE}; \ @@ -5946,14 +6022,15 @@ rmconfig: .if defined(OPTIONS) && exists(${_OPTIONSFILE}) -@${ECHO_MSG} "===> Removing user-configured options for ${PKGNAME}"; \ + optionsdir=${_OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \ if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \ - ${ECHO_MSG} "===> Switching to root credentials to remove ${_OPTIONSFILE} and `${DIRNAME} ${_OPTIONSFILE}`"; \ + ${ECHO_MSG} "===> Switching to root credentials to remove ${_OPTIONSFILE} and $${optionsdir}"; \ ${SU_CMD} "${RM} -f ${_OPTIONSFILE} ; \ - ${RMDIR} `${DIRNAME} ${_OPTIONSFILE}`"; \ + ${RMDIR} $${optionsdir}"; \ ${ECHO_MSG} "===> Returning to user credentials"; \ else \ ${RM} -f ${_OPTIONSFILE}; \ - ${RMDIR} `${DIRNAME} ${_OPTIONSFILE}`; \ + ${RMDIR} $${optionsdir}; \ fi .else @${ECHO_MSG} "===> No user-specified options configured for ${PKGNAME}" --- remove_basename_call.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1188650255.92324>