Subject: Re: pkgsrc make clean speedup
To: None <mcmahill@mtl.mit.edu>
From: David Maxwell <david@crlf.net>
List: tech-pkg
Date: 11/07/2003 22:11:30
On Thu, Dec 05, 2002 at 06:39:26AM -0500, mcmahill@mtl.mit.edu wrote:
> Just so I'm sure I understand, it just works by checking for $WRKDIR first
> and only cleaning if it exists right? Therefore eliminating up to 3000
> calls to make :) So my only question is if it does the right thing if you
> have something like
>
> WRKOBJDIR= /u2/disk1/build/pkgsrc
>
> in /etc/mk.conf and possibly a read-only /usr/pkgsrc
>
> In the first case, /usr/pkgsrc/foo/bar/work will be a link to
> /u2/disk1/build/pkgsrc/foo/bar/work and in the second,
> /usr/pkgsrc/foo/bar/work will never even exist, but
> /u2/disk1/build/pkgsrc/foo/bar/work will. As long as those 2 variations
> are dealt with then I think this is a good idea.
Naturally, it did not. Here's a new one.
I did not take the other suggestion, of using rm -r in the WORKOBJDIR
case, since concievably someone might have something else in that
directory as well. Cleaning each dir is slower, but more correct, and
safer.
(Did 'DUDS' go away? - if so, I'll cut that part out - I can no longer
find any uses of it.)
Tack this onto the end of pkgsrc/mk/bsd.pkg.subdir.mk
fastclean:
@REM="***************************************************************************";
@REM="*** Loop over the subdirs of the current directory. ***";
@REM="*** We might have been called from the top level pkgsrc dir, or from a ***";
@REM="*** category directory. ***";
@REM="***************************************************************************";
@for entry in "" ${SUBDIR}; do \
REM="************************************"; \
REM="*** Skip empty entries ***"; \
REM="************************************"; \
if [ "X$$entry" = "X" ]; then continue; fi; \
OK=""; \
REM="************************************"; \
REM="*** Loop over DUDS ***"; \
REM="************************************"; \
for dud in "" ${DUDS}; do \
REM="************************************"; \
REM="*** Skip empty DUD entries ***"; \
REM="************************************"; \
if [ "X$$dud" = "X" ]; then continue; fi; \
REM="***********************************************************"; \
REM="*** If the current entry (pkg or cat) is a dud, set a ***"; \
REM="*** flag, msg that it will ***"; \
REM="*** be skipped, and skip checking the rest. ***"; \
REM="***********************************************************"; \
if [ $${dud} = $${entry} ]; then \
${ECHO_MSG} "===> ${_THISDIR_}$${entry} is a DUD - skipped"; \
continue 2; \
fi; \
done; \
REM="****************************************************************"; \
REM="*** Look for the category, or individual package directory. ***"; \
REM="*** I can't remember why it looks for .${MACHINE} ***"; \
REM="*** Set 'edir' to the directory. ***"; \
REM="****************************************************************"; \
if [ -d ${.CURDIR}/$${entry}.${MACHINE} ]; then \
edir=$${entry}.${MACHINE}; \
elif [ -d ${.CURDIR}/$${entry} ]; then \
edir=$${entry}; \
else \
OK="false"; \
${ECHO_MSG} "===> ${_THISDIR_}$${entry} non-existent"; \
fi; \
if [ "$$OK" = "" ]; then \
REM="*************************************************************"; \
REM="*** Handle being started from the top of the pkgsrc tree ***"; \
REM="*************************************************************"; \
if [ "X${PKGSRCTOP}" = "Xyes" ]; then \
cd ${.CURDIR}/$${edir}; \
${ECHO_MSG} "===> Category - ${_THISDIR_}$${edir}"; \
${ECHO_MSG} "===> Cleaning ===> "; \
CLEANED_SOMETHING=""; \
REM="**************************************"; \
REM="*** Recurse into the category dir ***"; \
REM="**************************************"; \
${MAKE} ${MAKEFLAGS} fastclean ; \
${ECHO_MSG} ""; \
else \
REM="**************************************************"; \
REM="*** Handle being started from a category dir ***"; \
REM="*** Check each pkg subdir for extant workdirs ***"; \
REM="*** and clean it (normally) if there are any ***"; \
REM="***********************************************************************"; \
REM="*** We can't check for workdirs created by old WRKOBJDIR settings ***"; \
REM="*** because they could be anywhere in the filesystem. So, only ***"; \
REM="*** workdirs matching the current mk.conf settings will be cleaned.***"; \
REM="***********************************************************************"; \
if [ "X${WRKOBJDIR}" = "X" ]; then \
CHECKDIR=${.CURDIR}/$${edir}/${WRKDIR_BASENAME}; \
else \
CHECKDIR=${WRKOBJDIR}/${PKGPATH}/$${edir}/${WRKDIR_BASENAME}; \
fi; \
if [ -d $${CHECKDIR} ]; then \
cd ${.CURDIR}/$${edir}; \
${ECHO_MSG} -n " $${edir} "; \
CLEANED_SOMETHING="yes"; \
REM="*****************************************"; \
REM="*** Recurse into the pkg dir (clean) ***"; \
REM="*****************************************"; \
${MAKE} ${MAKEFLAGS} clean ; \
fi; \
fi; \
fi; \
done
--
David Maxwell, david@vex.net|david@maxwell.net -->
Any sufficiently advanced Common Sense will seem like magic...
- me