delete in post-destroot is ineffective, how to make it effective?

Rainer Müller raimue at macports.org
Mon Jul 12 18:29:08 UTC 2021


On 12/07/2021 11.49, Jim DeLaHunt wrote:
> I am breaking a single upstream codebase into subports. I want each
> subport to contribute some of the overall complement of files. But the
> "make install" of the codebase installs more files than I want. Thus I
> think the right thing to do is to declare a post-destroot which delete
> the excess files from each subport.

Sounds reasonable, but be aware that subports in MacPorts do not work
like splitting a package with .rpm or .deb. These other systems compile
once and then sort the files into different binary packages.

But with MacPorts, each subport will be built separately. With the same
build command, each subport will take the same time to compile from
source, even if you later only need a few files in destroot. Therefore
it would still be a good idea to only build what you need for each subport.

> My Portfile has an entry like this:
> 
>     post-destroot {
>         set sharedir ${prefix}/share
>         delete ${prefix}/lib/libfreeciv.a
>         delete ${sharedir}/doc ${sharedir}/man ${sharedir}/locale
>     }

At this point, the files are still not installed on the system, but
reside in the staging directory named ${destroot}, which is at
work/destroot/ as you already found out below.

You need to use absolute paths ${destroot}${prefix}/... here. ${prefix}
is always an absolute path, that's why it can be combined without an
explicit separator. For example, it should look like this:

  delete ${destroot}${prefix}/lib/libfreeciv.a

> But, when I run "sudo port destroot freeciv-server", then look at what I
> believe is the destroot:
> 
> ls $(port work freeciv-server)/destroot/opt/local/share
> 
> the directories which I wanted to delete are still present.
> 
> I look in the main.log for this subport. I don't see any diagnostics
> from those delete directives.

This was an attempt to delete files directly from the prefix, which is
/opt/local by default. But trying to delete non-existing files will not
result in an error. Therefore it silently passed doing nothing.

Rainer


More information about the macports-dev mailing list