[PATCH] small speedups in Mk/bsd.port.mk
Roman Neuhauser
neuhauser at chello.cz
Sun May 2 00:03:59 PDT 2004
# petef at absolutbsd.org / 2004-05-02 00:08:06 -0500:
> * Sat, 01 May 2004 17:04:29 CDT - Pete Fritchman:
> | Nope, that seems to be fixed. I'll run with this version and let you
> | know if I run into any trouble.
>
> Found a bug with make checksum:
>
> skull(/usr/ports/devel/libsigc++12) [1410] > cat distinfo
> MD5 (gnome2/libsigc++-1.2.5.tar.gz) = d0d1ffcae0eced97ef4f17ce0ba81352
> SIZE (gnome2/libsigc++-1.2.5.tar.gz) = 408276
> skull(/usr/ports/devel/libsigc++12) [1411] > make -V DISTFILES
> libsigc++-1.2.5.tar.gz
> skull(/usr/ports/devel/libsigc++12) [1412] > make -V DIST_SUBDIR
> gnome2
> skull(/usr/ports/devel/libsigc++12) [1413] > make checksum
> ===> Vulnerability check disabled
> >> No checksum recorded for gnome2/libsigc++-1.2.5.tar.gz.
> *** Error code 1
>
> Stop in /usr/ports/devel/libsigc++12.
> skull(/usr/ports/devel/libsigc++12) [1414] >
Hrmph, right, dot is just one of regexp metacharacters.
This version uses plain string comparisons in DISTINFO_SIZE_AWK and
DISTINFO_CKSUM_AWK.
Thanks again for testing! This would have taken weeks if I submitted
the patch right away.
--
If you cc me or remove the list(s) completely I'll most likely ignore
your message. see http://www.eyrie.org./~eagle/faqs/questions.html
-------------- next part --------------
Index: Mk/bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.488
diff -u -u -r1.488 bsd.port.mk
--- Mk/bsd.port.mk 19 Apr 2004 23:39:52 -0000 1.488
+++ Mk/bsd.port.mk 2 May 2004 06:37:18 -0000
@@ -2173,6 +2173,9 @@
. endif
.endfor
+DISTINFO_SIZE_AWK= 'BEGIN { p = sprintf("SIZE (%s)", distinfo); l = length(p); } { if (substr($$0, 1, l) == p) { print $$4; } }'
+DISTINFO_CKSUM_AWK= 'BEGIN { p = sprintf("MD5 (%s)", distinfo); l = length(p); } { if (substr($$0, 1, l) == p) { print $$4; } }'
+
#
# Hackery to enable simple fetch targets with several dynamic MASTER_SITES
#
@@ -2859,7 +2862,8 @@
for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
DIR=${DIST_SUBDIR}; \
- CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ CKSIZE=`${AWK} -v distinfo="$${DIR:+$$DIR/}$$file" \
+ ${DISTINFO_SIZE_AWK} ${MD5_FILE}`; \
case $${file} in \
*/*) ${MKDIR} $${file%/*}; \
args="-o $${file} $${site}$${file}";; \
@@ -2912,8 +2916,8 @@
for site in `eval $$SORTED_PATCH_SITES_CMD_TMP`; do \
${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
DIR=${DIST_SUBDIR}; \
- pattern="$${DIR:+$$DIR/}`${ECHO_CMD} $$file | ${SED} -e 's/\./\\\\./g'`"; \
- CKSIZE=`${GREP} "^SIZE ($$pattern)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ CKSIZE=`${AWK} -v distinfo="$${DIR:+$$DIR/}$$file" \
+ ${DISTINFO_SIZE_AWK} ${MD5_FILE}`; \
case $${file} in \
*/*) ${MKDIR} $${file%/*}; \
args="-o $${file} $${site}$${file}";; \
@@ -2997,7 +3001,7 @@
if ${PATCH} ${PATCH_ARGS} < $$i ; then \
PATCHES_APPLIED="$$PATCHES_APPLIED $$i" ; \
else \
- ${ECHO_MSG} `${ECHO_CMD} ">> Patch $$i failed to apply cleanly." | ${SED} "s|${PATCHDIR}/||"` ; \
+ ${ECHO_MSG} ">> Patch $${i#${PATCHDIR}} failed to apply cleanly." ; \
if [ x"$$PATCHES_APPLIED" != x"" ]; then \
${ECHO_MSG} `${ECHO_CMD} ">> Patch(es) $$PATCHES_APPLIED applied cleanly." | ${SED} "s|${PATCHDIR}/||g"` ; \
fi; \
@@ -3380,9 +3384,8 @@
/usr/bin/objdump -R ${PREFIX}/$$i > \
${WRKDIR}/.PLIST.objdump 2> /dev/null; \
if [ -s ${WRKDIR}/.PLIST.objdump ] ; then \
- ${EGREP} " $$stupid_functions_regexp" \
- ${WRKDIR}/.PLIST.objdump | ${AWK} '{print " " $$3}' | ${TR} -d '\n' \
- > ${WRKDIR}/.PLIST.stupid; \
+ ${AWK} '/ '"$$stupid_functions_regexp"'/ {printf " %s" $$3}' \
+ ${WRKDIR}/.PLIST.objdump > ${WRKDIR}/.PLIST.stupid; \
if [ -n "`${EGREP} ' (accept|recvfrom)$$' ${WRKDIR}/.PLIST.objdump`" ] ; then \
if [ -s ${WRKDIR}/.PLIST.stupid ]; then \
${ECHO_CMD} -n "${PREFIX}/$$i (USES POSSIBLY INSECURE FUNCTIONS:" >> ${WRKDIR}/.PLIST.network; \
@@ -3803,7 +3806,8 @@
fi ; \
for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
DIR=${DIST_SUBDIR}; \
- CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ CKSIZE=`${AWK} -v distinfo="$${DIR:+$$DIR/}$$file" \
+ ${DISTINFO_SIZE_AWK} ${MD5_FILE}`; \
case $${file} in \
*/*) args="-o $${file} $${site}$${file}";; \
*) args=$${site}$${file};; \
@@ -3835,7 +3839,8 @@
fi ; \
for site in `eval $$SORTED_PATCH_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
DIR=${DIST_SUBDIR}; \
- CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ CKSIZE=`${AWK} -v distinfo="$${DIR:+$$DIR/}$$file" \
+ ${DISTINFO_SIZE_AWK} ${MD5_FILE}`; \
case $${file} in \
*/*) args="-o $${file} $${site}$${file}";; \
*) args=$${site}$${file};; \
@@ -3886,9 +3891,8 @@
@if [ -f ${MD5_FILE} ]; then \
(cd ${DISTDIR}; OK=""; \
for file in ${_CKSUMFILES}; do \
- pattern="`${ECHO_CMD} $$file | ${SED} -e 's/\./\\\\./g'`"; \
CKSUM=`${MD5} < $$file`; \
- CKSUM2=`${GREP} "^MD5 ($$pattern)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
+ CKSUM2=`${AWK} -v distinfo="$$file" ${DISTINFO_CKSUM_AWK} ${MD5_FILE}`; \
if [ -z "$$CKSUM2" ]; then \
${ECHO_MSG} ">> No checksum recorded for $$file."; \
OK="false"; \
@@ -3914,8 +3918,7 @@
fi; \
done; \
for file in ${_IGNOREFILES}; do \
- pattern="`${ECHO_CMD} $$file | ${SED} -e 's/\./\\\\./g'`"; \
- CKSUM2=`${GREP} "($$pattern)" ${MD5_FILE} | ${AWK} '{if(NR<2)print $$4}'`; \
+ CKSUM2=`${AWK} -v distinfo="$$file" ${DISTINFO_CKSUM_AWK} ${MD5_FILE}`; \
if [ "$$CKSUM2" = "" ]; then \
${ECHO_MSG} ">> No checksum recorded for $$file, file is in "'$$'"{IGNOREFILES} list."; \
OK="false"; \
@@ -4004,8 +4007,8 @@
prog=`${ECHO_CMD} $$i | ${SED} -e 's/:.*//'`; \
dir=`${ECHO_CMD} $$i | ${SED} -e 's/[^:]*://'`; \
if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
- target=`${ECHO_CMD} $$dir | ${SED} -e 's/.*://'`; \
- dir=`${ECHO_CMD} $$dir | ${SED} -e 's/:.*//'`; \
+ target=$${dir##*:}; \
+ dir=$${dir%%:*}; \
else \
target="${DEPENDS_TARGET}"; \
depends_args="${DEPENDS_ARGS}"; \
@@ -4129,8 +4132,8 @@
.if !defined(NO_DEPENDS)
@for dir in ${DEPENDS}; do \
if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
- target=`${ECHO_CMD} $$dir | ${SED} -e 's/.*://'`; \
- dir=`${ECHO_CMD} $$dir | ${SED} -e 's/:.*//'`; \
+ target=$${dir##*:}; \
+ dir=$${dir%%:*}; \
else \
target="${DEPENDS_TARGET}"; \
depends_args="${DEPENDS_ARGS}"; \
@@ -4160,7 +4163,7 @@
ALL-DEPENDS-LIST= \
checked="${PARENT_CHECKED}"; \
- for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
+ for dir in $$(${ECHO_CMD} "${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${AWK} -v RS=' ' -v FS=: '{print $$2}') $$(${ECHO_CMD} ${DEPENDS} | ${AWK} -v RS=' ' -v FS=: '{print $$1}'); do \
if [ -d $$dir ]; then \
if (${ECHO_CMD} $$checked | ${GREP} -qwv "$$dir"); then \
child=$$(cd $$dir; ${MAKE} PARENT_CHECKED="$$checked" run-depends-list); \
@@ -4419,7 +4422,7 @@
www-site:
.if exists(${DESCR})
- @${GREP} '^WWW:[ ]' ${DESCR} | ${AWK} '{print $$2}' | ${HEAD} -1
+ @${AWK} '/^WWW:[ ]/ {print $$2; exit;}' ${DESCR}
.else
@${ECHO_CMD}
.endif
@@ -4465,7 +4468,7 @@
defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
defined(LIB_DEPENDS) || defined(DEPENDS)
@${ECHO_CMD} -n 'This port requires package(s) "'
- @${ECHO_CMD} -n `${GREP} '^${PKGNAME}|' ${PORTSDIR}/${INDEXFILE} | ${AWK} -F\| '{print $$8;}'`
+ @${ECHO_CMD} -n `${AWK} -F\| '/^${PKGNAME}|/ {print $$8;}' ${PORTSDIR}/${INDEXFILE}`
@${ECHO_CMD} '" to build.'
.endif
.endif
@@ -4474,7 +4477,7 @@
pretty-print-run-depends-list:
.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
@${ECHO_CMD} -n 'This port requires package(s) "'
- @${ECHO_CMD} -n `${GREP} '^${PKGNAME}|' ${PORTSDIR}/${INDEXFILE} | ${AWK} -F\| '{print $$9;}'`
+ @${ECHO_CMD} -n `${AWK} -F\| '/^${PKGNAME}|/ {print $$9;}' ${PORTSDIR}/${INDEXFILE}`
@${ECHO_CMD} '" to run.'
.endif
.endif
@@ -4487,10 +4490,9 @@
@${ECHO_MSG} "===> Generating temporary packing list"
@${MKDIR} `${DIRNAME} ${TMPPLIST}`
@if [ ! -f ${DESCR} ]; then ${ECHO_CMD} "** Missing pkg-descr for ${PKGNAME}."; exit 1; fi
- @>${TMPPLIST}
@for file in ${PLIST_FILES}; do \
- ${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
- done
+ ${ECHO_CMD} $${file}; \
+ done | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} > ${TMPPLIST}
@for man in ${__MANPAGES}; do \
${ECHO_CMD} $${man} >> ${TMPPLIST}; \
done
@@ -4529,9 +4531,9 @@
@if [ -f ${PLIST} ]; then \
${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
fi
-.for dir in ${PLIST_DIRS}
- @${ECHO_CMD} ${dir} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} | ${SED} -e 's,^, at dirrm ,' >> ${TMPPLIST}
-.endfor
+ @for dir in ${PLIST_DIRS}; do \
+ ${ECHO_CMD} $${dir}; \
+ done | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} | ${SED} -e 's,^, at dirrm ,' >> ${TMPPLIST}
.if !defined(NO_MTREE)
@${ECHO_CMD} "@unexec if [ -f %D/info/dir ]; then if sed -e '1,/Menu:/d' %D/info/dir | grep -q '^[*] '; then true; else rm %D/info/dir; fi; fi" >> ${TMPPLIST}
.endif
@@ -4558,10 +4560,15 @@
.if !target(add-plist-docs)
add-plist-docs:
.if defined(PORTDOCS)
- @if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \
- [ "`${SED} -En -e '/^@cw?d[ ]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \
- ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
- fi
+ @${AWK} -v found=0 -v cwd='' -v prefix='${PREFIX}' \
+ 'match($$0, /^@cw?d[ ]*/) { \
+ found = 1; cwd = substr($$0, RSTART + RLENGTH); \
+ } \
+ END { \
+ if (found && cwd != prefix) { \
+ print "@cwd " prefix >> "${TMPPLIST}"; \
+ } \
+ }' ${TMPPLIST}; \
@${FIND} -P ${PORTDOCS:S/^/${DOCSDIR}\//} ! -type d 2>/dev/null | \
${SED} -ne 's,^${PREFIX}/,,p' >> ${TMPPLIST}
@${FIND} -P -d ${PORTDOCS:S/^/${DOCSDIR}\//} -type d 2>/dev/null | \
@@ -4646,7 +4653,7 @@
if [ -f ${PKGMESSAGE} ]; then \
${CP} ${PKGMESSAGE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
fi; \
- for dep in `${PKG_INFO} -qf ${PKGNAME} | ${GREP} -w ^@pkgdep | ${AWK} '{print $$2}' | sort -u`; do \
+ for dep in `${PKG_INFO} -qf ${PKGNAME} | ${AWK} '/^@pkgdep\>/ {print $$2}' | sort -u`; do \
if [ -d ${PKG_DBDIR}/$$dep -a -z `${ECHO_CMD} $$dep | ${GREP} -E ${PKG_IGNORE_DEPENDS}` ]; then \
if ! ${GREP} ^${PKGNAME}$$ ${PKG_DBDIR}/$$dep/+REQUIRED_BY \
>/dev/null 2>&1; then \
@@ -4750,7 +4757,7 @@
${ECHO_MSG} "===> No user-specified options to save for ${PKGNAME}"; \
exit 0; \
fi; \
- SELOPTIONS=$$(${CAT} $${TMPOPTIONSFILE}); \
+ SELOPTIONS=$$(${SED} -e 's/"//g' $${TMPOPTIONSFILE}); \
${RM} -f $${TMPOPTIONSFILE}; \
TMPOPTIONSFILE=$$(mktemp -t portoptions); \
trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
@@ -4758,14 +4765,23 @@
${ECHO_CMD} "# No user-servicable parts inside!" >> $${TMPOPTIONSFILE}; \
${ECHO_CMD} "# Options for ${PKGNAME}" >> $${TMPOPTIONSFILE}; \
${ECHO_CMD} "_OPTIONS_READ=${PKGNAME}" >> $${TMPOPTIONSFILE}; \
- for i in $${OPTIONSLIST}; do \
- ${ECHO_CMD} $${SELOPTIONS} | ${GREP} -qw $${i}; \
- if [ $$? -eq 0 ]; then \
- ${ECHO_CMD} WITH_$${i}=true >> $${TMPOPTIONSFILE}; \
- else \
- ${ECHO_CMD} WITHOUT_$${i}=true >> $${TMPOPTIONSFILE}; \
- fi; \
- done; \
+ ${ECHO_CMD} $${OPTIONSLIST} | ${AWK} \
+ 'BEGIN { \
+ getline; \
+ sub(/[\r\n]+/, ""); \
+ split($$0, ol); \
+ split("'"$${SELOPTIONS}"'", sl); \
+ for (o in ol) { \
+ found = 0; \
+ for (s in sl) { \
+ if (ol[o] == sl[s]) { \
+ found = 1; \
+ break; \
+ } \
+ } \
+ printf("WITH%s_%s=true\n", found ? "" : "OUT", ol[o]); \
+ } \
+ }' >> $${TMPOPTIONSFILE}; \
if [ `${ID} -u` != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
${ECHO_MSG} "===> Switching to root credentials to write ${_OPTIONSFILE}"; \
${SU_CMD} "${CAT} $${TMPOPTIONSFILE} > ${_OPTIONSFILE}"; \
More information about the freebsd-ports
mailing list