Building my own port/package distributing over self hosted repo


from the question you can guess I'm relatively new to FreeBSD....

What I wanna do is to build a package (web application from a git repository) and install it with pkg on a target system.

So by reading a lot (handbook, porters handbook, web) my understanding is that I would place my sources in
, write description, Makefile, etc... is that correct so far? Question is - where do I put those files? When I use poudriere I would put them in
And in poudriere config I would just configure the www/my-webapp port to be build?
mkone Welcome!

Yes, ports-mgmt/poudriere is the "default" tool for that, but you can also have a look on ports-mgmt/synth.

Some info: Poudriere, Synth, Synth Thread 54690.

This is a personal opinion, but since you seem to just need one local repository, I think ports-mgmt/synth would be more handy.

If you created a package, is because you created a port for that.

So, when building a port it will download the source from Github - unless it is in there already. So you do not need to manually download/place it in the /usr/ports/distfiles.

Also, using ports-mgmt/poudriere, by default, it does not use the default location for distfiles but one set in its directory at /usr/local/poudriere.

Now. One time you have a port and want it to be built using a tool (not manually), you will need to add it to your ports tree. Then, update the makefile of the category it is in.

Note: ports-mgmt/poudriere also install the ports tree in a different location by default.

Cheers! :beer:
Thank you for your answer.

So just that I'm getting it right: I download my source code from my (private.. thats why I have to download it manually) repository, save it to /usr/port/distfiles. I add the port to the port tree (which consists of the Makefile.. etc..).

So basically my build process would look something like this:
  1. git clone from my private repo to my buildserver
  2. tar it into /usr/ports/distfiles
  3. cd into /usr/local/ports/<poudriere-portsdir>
  4. run `make install`
Sorry for asking so dumb, but I was not able to find a "A-Z-compile-your-own-package" how to on the net... I probably searched wrong...
Almost. :)

ports-mgmt/poudriere is a building system, you do not need/should to use make in its ports tree, otherwise ports-mgmt/poudriere would not be necessary. Otherwise you could just add the custom port to the "normal" tree and use make in there for that specific port.

Just take careful a look in the Poudriere guide linked in my previous post, and make some tests, you should get quickly how it works.

Still, if just a single custom repository is necessary ports-mgmt/synth should be simpler to maintain (IMO).

ports-mgmt/poudriere-dev do support Git. I didn't take a look on it yet but eventually you could make it download from a private repository using SSH, IDK.

Sorry for asking so dumb, but I was not able to find a "A-Z-compile-your-own-package" how to on the net... I probably searched wrong...

You do need the "FreeBSD Porters Handbook" for that, specially THIS part, but worth reading everything. You can also find it in pdf format.

You could try this:
  1. create a fork/mirror of the FreeBSD ports tree mirror at GITHUB in you private git or create a svn one - it would be better for maintenance (IMO);
  2. add you port to it;
  3. point ports-mgmt/poudriere-dev to use your private git ports tree clone. You could also use ports-mgmt/synth, but you would need to update the ports tree separately/manually - nothing dramatic anyway;
  4. find a WAY to add your private source to DISTFILES, automatically or manually if necessary.
  5. build;
  6. distribute.
So, another and more simple idea if you will be using only packages from the FreeBSD repository + your custom package:
  1. build your package manually every time you need to do it, using make as pointed in the Porters Hanbook;
  2. move it to some folder somewhere, your liking;
  3. set a web server to provide packages from that folder (see the ports-mgmt/poudriere guide on how to do that);
  4. add this new "repository" to the clients (also, the ports-mgmt/poudriere guide have a example).
Using this way you do not need to set anything more than the web server (but can also be a ftp server) to provide your private package, but it worth only if all others packages will come from the FreeBSD official repository. I mean you do not need to deviate from the default options and so build some ports.
What I wanna do is to build a package (web application from a git repository) and install it with pkg on a target system.
Do note that you don't need to use /usr/ports for that at all. And although you can use some utilities even that isn't really needed, this whole procedure is very easily scripted if you want to.

If you look into pkg-create(8) you'll see what I mean. There really isn't any magical inner working here, at its core you're looking at rolling up a specific amount of files (or a program hierarchy) into a package. And that's it. Although you can indeed resort to using pre-made tools I always considered that a lot of extra overhead, in the end this process isn't that much different from creating an archive.

Another thing to keep in mind is that you need to address 2 things here: creating the package, and distributing it.

You can make this as easy or as difficult as you want. For example: pkg-add(8) is perfectly capable of retrieving a package from a remote source, it natively supports the HTTP, HTTPS and FTP protocols. So if you're looking at creating a package which should be distributed to some of your other servers then it couldn't be easier. Place it on a webserver, point the other servers to that URL and you're set. Optionally you could use a tool such as ftp/curl to keep track of any newer versions.

Another option is to manually build yourself a repository using pkg-repo(8). Once again something pretty trivial, and after that your other servers could be easily pointed to that repository which you can then use to distribute your software.

Quite frankly I think that this approach can be much more beneficial for you in the longer run. Sure, it's easy to blindly rely on some external tools to do the work for you. But once you know how this process actually works you'll soon notice that it's really not that much special and setting up a repository and maintaining it can even be done using a simple shell script.

The advantage comes from actually learning how this stuff works. That will also give you a much better insight in how those other programs are handling all this.

A small sidestep but in a way I always compare this to installing FreeBSD.. I've seen plenty of people who were wondering how they might be able to somehow automate or script the installer, even though it's really not that difficult to install FreeBSD without the installer in the first place; thus also making the whole process much more flexible.

Just my 2 cents of course.