Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Nov 2009 14:09:26 +0000
From:      "b. f." <bf1783@googlemail.com>
To:        freebsd-ports@FreeBSD.org
Cc:        Sandra Kachelmann <s.kachelmann@googlemail.com>
Subject:   Re: remove BUILD_DEPENDS automatically after install
Message-ID:  <d873d5be0911160609y11433721w9a087c0b2f64b4cf@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
>> On Sun, Nov 15, 2009 at 11:44:04PM +0100, Sandra Kachelmann wrote:
>>> Is there a reason why BUILD_DEPENDS aren't being removed after a port
>>> has been installed and if no other installed port depends on it?
>>
>> How do you know that the user does not want that port installed?
>> And what if the user will install 20 other ports afterwards - all of whi=
ch
>> is that same port as a BUILD_DEPENDS - should that port be
>> installed/deinstalled each and every time?
>
>It would be nice if this was configurable. Maybe it could be even
>integrated into portupgrade or portmaster. If such a port is installed
>directly it could get a package entry DIRECT_INSTALLED=3Dyes in
>/var/db/pkg/.. or something (there is probably a better way to do
>this).

How are you going to account for those ports that, while installed as
dependencies, the user nevertheless wants to keep for their own sake?
Or those that are installed individually by a user, perhaps to fix a
problem, but are not really wanted after all builds are done?  I think
that this kind of bookkeeping should be done by users and
administrators, and should not be cluttering up the ports and package
infrastructure.  If you really want it there, you can make your own
local modifications.

>
>> (Personally I would be *very* annoyed if, for example, libtool or
>> automake/autoconf would be reinstalled every time I installed a port whi=
ch
>> had one of them as a build-time dependency. =A0There are *lots* of ports=
 which
>> have one of them in BUILD_DEPENDS, but few if any that has them as
>> RUN_DEPENDS.)
>
>Even nicer if execptions would be configurable. There are loads of
>ports that install BUILD_DEPENDS that are never used again. cvsup for
>instance pulls in a gigantic tree of esoteric ports I can't even
>pronounce. Sure I could install the package, take cvsup-without-gui or
>even use portsnap but this is not the point here.

I'm not sure what you mean by "exceptions" -- but if you are not
willing to consider dependencies and configure ports, then you really
ought to be using packages, and that is relevant to this discussion.

There are some ports that can help you manage this kind of cleanup --
for example, you could  run "portmaster -s", and then run "portmaster
-l", and remove those ports listed as leaf or root ports that you no
longer want. Or you could add entries to AFTERINSTALL in pkgtools.conf
to remove build dependencies when using portupgrade.  But it is
difficult to completely automate a removal, in a generic way that
would satisfy all administrators and users, so some interaction or at
least an initial configuration will be required.

Here is a shell script that will emit a list of installed ports that
are needed to build other installed ports, but are not needed by any
other ports at runtime, according to a ports tree.  You could run it
and then either pipe it's output directly to:

| xargs -I % make -C ${PORTSDIR:-/usr/ports}% deinstall

, or first filter the output to remove any ports that you want to keep:


#!/bin/sh
#findbuildonlydeps.sh

_portsdir=3D${PORTSDIR:-/usr/ports}
_scriptname=3D`basename $0`
_listbuildreqs=3D`mktemp -t ${_scriptname}` || \
	echo "cannot create ${_listbuildreqs}"
_listrunreqs=3D`mktemp -t ${_scriptname}` || \
	echo "cannot create ${_listrunreqs}"

for _pkgorigin in `pkg_info -qoa` ; do

	for _buildreq in `make -C ${_portsdir}/${_pkgorigin} \
	-V FETCH_DEPENDS -V EXTRACT_DEPENDS \
	-V PATCH_DEPENDS -V BUILD_DEPENDS` ; do
		echo ${_buildreq##*${_portsdir}} >> ${_listbuildreqs}
	done

	for _runreq in `make -C ${_portsdir}/${_pkgorigin} \
	-V RUN_DEPENDS -V LIB_DEPENDS` ; do
		echo ${_runreq##*${_portsdir}} >> ${_listrunreqs}
	done
=09
done

sort -u ${_listbuildreqs} > ${_listbuildreqs}_sorted
sort -u ${_listrunreqs} > ${_listrunreqs}_sorted
comm -23  ${_listbuildreqs}_sorted ${_listrunreqs}_sorted
rm ${_listbuildreqs} ${_listbuildreqs}_sorted \
${_listrunreqs} ${_listrunreqs}_sorted



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d873d5be0911160609y11433721w9a087c0b2f64b4cf>