ruipacheco
ruipacheco

Reputation: 16442

How can I force macports to fetch a port source from a specific url?

I'm editing and testing a package that I'd like to build via macports. Is there a way that I can force macports to fetch and build the package from my repository? I've edited my Portfile to point to a single repository but it seems to be ignoring it.

Upvotes: 1

Views: 1631

Answers (1)

neverpanic
neverpanic

Reputation: 2998

MacPorts uses curl internally to download files, which gives you a couple of options to switch where stuff is downloaded from:

  • You can use file:// URLs in the master_sites property of the Portfile to point to a local directory. Note that the fetch runs as the macports user, so make sure that user is allowed to read files from that directory.
  • For file downloads, you can replace the cached file. MacPorts will use your replacement the next time it extracts the source code of a port. Run port distfiles $portname to find the local path where a file may be cached.
  • You can switch to git for fetching by setting fetch.type git, git.url to whatever git clone will accept to clone your repository (which can be local) and optionally git.branch to a commitish you want to check out. See https://guide.macports.org/#reference.phases.fetch.git for details. Again, make sure that the macports user can read the local files if you use a local git repository.
  • Any other version control system supported by MacPorts; see the guide for details.

Note that MacPorts caches file downloads by default (no caching is applied for version control systems at the moment), so if you did not modify the filename, you will have to run sudo port clean --dist $portname to delete the cache.

When building modified versions of ports, you'll also have to look out for a number of other points:

  • MacPorts will download a precompiled binary if one is available. Since that precompiled binary will not match your modified Portfile or source code, pass the -s flag to port to force building from source.
  • MacPorts will not compile a port if you run 'port install' and it is already installed (either activated or deactivated).

Probably the easiest solution to work around these two potential pitfalls is running sudo port destroot $portname instead of sudo port install. This will run all steps up to (and including) make install, but will not actually put the files into /opt/local. If you can debug what you need to debug from the build directory at port work $portname, this will simplify things.

Upvotes: 1

Related Questions