Subject: Re: pkg/14684: make clean in pkgsrc is waaay too slow
To: None <tech-pkg@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-pkg
Date: 11/22/2001 22:21:54
[ On Friday, November 23, 2001 at 02:26:59 (+0100), Hubert Feyrer wrote: ]
> Subject: Re: pkg/14684: make clean in pkgsrc is waaay too slow
>
> On Thu, 22 Nov 2001 franklin@elfie.org wrote:
> > +fastclean:
> > +       rm -rf distfiles/*
> > +       rm -rf */*/work
> 
> Nice idea. Two points:
> 
>  * "make clean" doesn't nuke distfile, so should fastclean. If anything,
>    make a "fastdistclean|

I agree -- distfiles should never be nuked automatically by any "*clean"
target (and I don't see any advantage of having a target to clean all
distfiles since that's trivial to do manually, though a "make distclean"
per module is of course very useful).

"fastclean" should be more explicit to -- eg. maybe "allclean" and maybe
it should only work if invoked from the top of ${PKGSRCDIR} too?

>  * I'm have OBJMACHINE set, as such I don't have */*/work but
>    */*/work.sparc (etc.), this needs to be takein into account.
> 
> It should be discussed on tech-pkg if we want this feature.

I'm not sure how it might relate, but I'd like to point out that I've
got the following set in my /etc/mk.conf (well actually I put them
directly in my local mk/bsd.pkg.defaults.mk since they're static in my
environment where I share my /usr/pkgsrc amongst several architectures
and release levels):

	# to build on a (fast(er)) local disk...
	#
	# Note you do not want OBJMACHINE set -- just make sure this
	# directory is unique per build environment.
	#
	# This can be a symlink.
	#
	WRKOBJDIR=	/var/package-obj

and I've made a small change to mk/bsd.pkg.mk so that "make clean" in
any pkgsrc module will _not_ remove the "work" symlink if WRKOBJDIR is
set (though I suppose it should only avoid the rmdir if WRKOBJDIR begins
with a '/').  This is done because with a shared pkgsrc it's rather
disruptive to do "make clean" on one machine while trying to build the
same package on another machine.  Given the static nature of the link
there's no need to ever change it anyway (unless of course WRKOBJDIR is
changed, but of course that won't happen as easily if it's set only in
bsd.pkg.defaults.mk :-).  I'm not even sure the rmdir is needed at all,
but I've not had any problem with keeping it.

***************
  		fi;							\
  	fi
  .  ifdef WRKOBJDIR
! 	-${_PKG_SILENT}${_PKG_DEBUG}					\
! 	${RMDIR} ${BUILD_DIR} 2>/dev/null;				\
! 	${RM} -f ${WRKDIR_BASENAME}
  .  endif
  .endif
  
--- 2402,2408 ----
  		fi;							\
  	fi
  .  ifdef WRKOBJDIR
! 	-${_PKG_SILENT}${_PKG_DEBUG}${RMDIR} -p ${BUILD_DIR} 2>/dev/null;
  .  endif
  .endif
  

I haven't bothered inventing the equivalent of "make obj" for pkgsrc
though -- it's just really not necessary until/unless it were to be put
on read-only media in this form (and of course pre-existing WRKOBJDIR
symlinks would be the only way pkgsrc could be used from read-only
media!).


For me "make allclean" could have just the following even faster
implementation:

allclean:
	${RM} -rf ${WRKOBJDIR}/*



Just FYI, I also do this:

	# Store generated packages on a per-architecture base
	# Possible: any path you like, eg ${PKGSRC_BASE}/packages/${MACHINE_ARCH}
	#
	# Default: /usr/pkgsrc/packages
	#
	# This can be a symlink.
	#
	PACKAGES=       /var/packages

and I've changed my DISTDIR setting in mk/bsd.pkg.mk to always be just
/var/package-distfiles, and since that location can also be a symlink I
just point it on my build machines to a shared NFS directory when and
where that's possible.

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>     <woods@robohack.ca>
Planix, Inc. <woods@planix.com>;   Secrets of the Weird <woods@weird.com>