Portfile clarifications
Bryan Blackburn
blb at macports.org
Mon Sep 7 01:24:45 PDT 2009
On Mon, Sep 07, 2009 at 12:55:00AM -0700, Jim Busser said:
> Hi all
>
> I am new to MacPorts but have it installed (on Leopard), and have
> further installed some ports both from the command line and using the
> GUI Porticus.
>
> I am working on a first portfile for client software GNUmed-client
> which connects to a database. What the Portfile needs to mediate is
>
> - user downloads the archive
> - checksums applied and directory and contents extracted
> - check and take care of dependencies
> - there is no build (compilation) needed, because what is being
> downloaded is just a directory containing subdirectories and python
> source, which does not need compilation
> - copy the extracted directory to a suitable machine directory (owned
> by root) but also to the logged-in user's home directory
Note that (with a couple of important exceptions), installing files outside
of ${prefix} (/opt/local by default) is very much frowned upon.
> - also create some hard links but this bit I am not (at this time)
> worried about :-)
>
> I have read the following
>
> http://guide.macports.org/
> http://trac.macports.org/wiki/PortfileRecipes
> http://trac.macports.org/wiki/BuildPhases
>
> but still have a few questions:
>
> 1. Am I right to surmise that the phases
> fetch
> checksum
> extract
> execute by default (without having to be declared), so long as
> distfiles and checksums had been specified?
Yes, all phases are run unless you either set something which causes them to
be skipped (like clearing distfiles skips fetch, checksum, and extract) or
by overriding the phase completely.
>
> Does extraction rely on the value of "extract.suffix" or is the
> latter used only for the fetch phase?
extract.suffix is used for fetch, checksum, and extract since it is usually
append to distname to build the full file name.
>
> 2. As our distfile is actually a directory which needs no
> compilation, do I need to explicitly eliminate the following phases,
> using:
> configure {}
> build {}
> destroot {}
>
> or (in the case of configure) do I instead declare a keyword
> use_configure no
>
> or if configure {} is the same as use_configure no
> then it doesn't matter? either gives identical results ??
"use_configure no" is preferred (in fact, port lint will complain if you use
"configure {}" instead); to override build, yes "build {}" is the right way.
>
> 3. If I would eliminate destroot, then there will exist no destrooted
> files on which the install phase can act. So do I need to do
>
> install{} ?
Actually you want to setup your own destroot phase, and install the files in
that step, to ${destroot}${prefix}/... so that port sees what files are
considered to be part of the final install. See the mediawiki port for one
example, which simply copies everything in destroot:
<http://trac.macports.org/browser/trunk/dports/www/mediawiki/Portfile>
>
> 4. On Debian, in order to keep a copy of our client (owned by root)
> available to supply machine-wide defaults, our project installs a
> copy of the client in
> /etc/
>
> In MacPorts, I take it this should instead reside in:
>
> /opt/local/var/macports/software/
>
> as (for example)
>
> /opt/local/var/macports/software/GNUmed-client-0.5.0
The stuff installed into var/macports/software is what's called an image,
which is the full (from destroot) set of the port's files. When a port is
activated, the stuff in var/macports/software is then hardlinked into just
${prefix} (and removed when deactivated). Hence, if you properly do the
destroot, installing the port will populate var/macports/software.
>
> but we will also want creation of
>
> ~/GNUmed-client-0.5.0
Depending on what's actually needed in someone's homedir, you may be able to
either use ui_msg to tell the user what to do, or perhaps install a script
with the port which does any necessary setup. Note that whatever that
script would do would obviously not be part of the port itself. I do
something similar to this (though into /usr instead of ~) with the cups-pdf
port, which installs ${prefix}/libexec/cups-pdf_links.sh:
<http://trac.macports.org/browser/trunk/dports/print/cups-pdf/Portfile>
Bryan
>
> So for this, would I declare a post-destroot phase, and how do I
> achieve the two copying tasks above, since I am not sure whether the
> source would be
>
> ${worksrcpath}
>
> =
>
> ${prefix}/var/macports/build/${name}/work/${worksrcdir}
>
> or would it instead be
>
> ${prefix}/var/macports/build/${name}/work/${name}
>
> and if xinstall even copies recursively? I was guessing maybe
>
> post-destroot { /
> xinstall -m 755 -W ${worksrcpath} ${prefix}/var/macports/software/
> xinstall -m 700 -d ~/{name}
> xinstall -m 700 -W ${worksrcpath} ~/{name}
> }
>
> but would appreciate the guidance. As I figure this out, I am
> identifying some possible improvements to the guide that I will like
> to suggest for consideration.
More information about the macports-users
mailing list