Solved Creating new port - Beginner questions

jbo@

Developer
I'm considering creating a couple of ports. The upstream software of the ports I'd like to create compile out-of-the-box on FreeBSD which should make this fairly simple.

I've read the Porter's Handbook but still have some questions I'd like to clarify before tackling this.

1. Port location
When creating a new port, I take it that the port needs to be located in a specific location on my system, right? Or can I just have my port under ~/ports? Would I need to pull the full ports three on the machine where I want to create the port?

2. Build environment
What are the recommendations regarding the environment when creating a new port? As these are mainly build recipes, I take it that I can just do this on my desktop machine or are there some severe problems afterwards? Should I create/build my port in a jail instead? Or a completely dedicated machine?

3. Tarball
From section 3 of the Porter's Handbook:
First, get the original tarball and put it into DISTDIR, which defaults to /usr/ports/distfiles.
I assume that this is the tarball containing the upstream project source, is that correct? Do ports generally ship with the tarball or would the port itself only contain a reference of where the tarball can be obtained from and it will be pulled in automagically when building the port?

4. Publishing ports
What are the requirements that need to be met for ports to be included in the "offical ports"? How do I become a port maintainer?
Lets assume there is a port I'd like to create of some custom C++ library that is currently not widely used but I use it in several of my other projects/programs. Should I still contribute the port to the official ports or "keep it to myself"?
 
When creating a new port, I take it that the port needs to be located in a specific location on my system, right?
Your port will automatically download it, and it typically gets placed under /usr/ports/distfiles. You don't need to set anything for this, it's done automatically.
Would I need to pull the full ports three on the machine where I want to create the port?
Not really needed unless you port has dependencies on other ports.

What are the recommendations regarding the environment when creating a new port?
A clean system, so you can check if the dependencies are getting pulled in correctly. I also highly recommend setting up ports-mgmt/poudriere and running your port through poudriere-testport(8).
As these are mainly build recipes, I take it that I can just do this on my desktop machine or are there some severe problems afterwards? Should I create/build my port in a jail instead? Or a completely dedicated machine?
A clean system makes it easier to verify it builds correctly and no other versions or dependencies will influence it.

I assume that this is the tarball containing the upstream project source, is that correct?
Correct.
Do ports generally ship with the tarball or would the port itself only contain a reference of where the tarball can be obtained from and it will be pulled in automagically when building the port?
The port has the information where to download the original source from (PACKAGESITE).

What are the requirements that need to be met for ports to be included in the "offical ports"?
It builds cleanly on various architectures and versions. The pkg-plist has to be in order, portlint(1) doesn't complain. And again, using poudriere-testport(8) is highly recommended.
How do I become a port maintainer?
Set your email address in the MAINTAINER field. When the port is accepted you will be the port's maintainer.

Lets assume there is a port I'd like to create of some custom C++ library that is currently not widely used but I use it in several of my other projects/programs. Should I still contribute the port to the official ports or "keep it to myself"?
All dependencies have to be met and installable as ports too.
 
Thank you for the quick & helpful response!

Not really needed unless you port has dependencies on other ports.
Do I need the actual ports tree for that? Could dependencies not be pulled in via pkg?

A clean system, so you can check if the dependencies are getting pulled in correctly. I also highly recommend setting up ports-mgmt/poudriere and running your port through poudriere-testport(8).
I do have a working poudriere setup (currently only building for FreeBSD 13.0 x86 tho). Could I reuse that or would one setup a separate poudriere instance just for testing ports that are currently being created?

Set your email address in the MAINTAINER field. When the port is accepted you will be the port's maintainer.
Where can I find more information on this process? How do I submit a port for review/approval?
 
Do I need the actual ports tree for that? Could dependencies not be pulled in via pkg?
Dependencies have to be met before the port itself will start building. If those dependencies aren't there it will build those from ports first. You can circumvent that by using make install-missing-packages.

I do have a working poudriere setup (currently only building for FreeBSD 13.0 x86 tho). Could I reuse that or would one setup a separate poudriere instance just for testing ports that are currently being created?
I use my existing poudriere install for this too. Just copy your port to the ports tree poudriere uses.

Where can I find more information on this process?

How do I submit a port for review/approval?
Create a PR for it, attach your port diff and wait.
 
Excuse me, maybe I've missed something in this thread, but is there any instructions or rules in the long path that begins after writing and compiling program to become "port" actually? What is the difference in port and programm itself?
 
I might misunderstand your question but if not: This is the reason why I started this topic. It seemed to me like the technical process of creating a port is somewhat well explained but I couldn't find the necessary information of what to do before and after that step.
 
I'd recommend a VM or jail as if things go horribly wrong it's not the end of the world, do your development here (in the ports tree) and then use Poudriere to verify dependencies etc.
tarball --> pre packaged source code, do note that links containing "archive" in path from GitHub and GitLab are not static ones and you should use USE_GITHUB or USE_GITLAB instead.
https://github.com/netdata/netdata/releases/download/v1.31.0/netdata-v1.31.0.tar.gz - Use MASTER_SITES
https://github.com/netdata/netdata/archive/refs/tags/v1.31.0.tar.gz - Use USE_GITHUB , this filename will also eventually clash with other ports (if they use the same naming convention) so it's a no go in that regard too.
 
is there any instructions or rules in the long path that begins after writing and compiling program to become "port" actually? What is the difference in port and programm itself?
The port is the FreeBSD instruction set plus access to a program within the ports tree starting at /usr/ports/ for compiling and installing. Each program is within a category and its own directory. The port includes Makefiles, a description and patches.

The ports tree includes additional instruction sets. The program source code, in compressed form, is downloaded when needed into the distfiles/ directory. The binaries, libraries and other parts of the program are then installed into place under /usr/local/ for use.
 
Don't be fooled: I was cherry-picking this utility for my first port. It's a pure C application that builds out-of-the-box on FreeBSD and has no dependencies. This was an extremely easy process. Basically not helping anyone here.
 
I wrote Thread bastille-jail-to-build-and-test-builds.82155, for using Bastille as a build and test environment for ports. This jail allows console use, which some things are easier to configure by being within the jail environment.


While planning for that thread, I noticed this one. I had to do research to understand it for the task of setting up the jail correctly which took some time.


utility for my first port. It's a pure C application that builds out-of-the-box on FreeBSD and has no dependencies.
That's a big step and it helps with the learning process for lots of people. This starting point is essential for more difficult ports.

I was playing with Makefiles, so I see that learning from the Porters handbook and learning how to set up a build environment is where a lot of work is.
 
Back
Top