# I want to learn how to port new softwares to FreeBSD



## hbsd (Jan 4, 2022)

Hi
Everyday I see some softwares in github that does not run on FreeBSD.
I did many researches on the forum, handbook, youtube and Internet to learn how to port new softwares to FreeBSD, but I could not do it. I'm really sorry if my topic is too beginner. But I'm crazy about FreeBSD! I really want to be a port maintainer. I know that the users of this forum are so knowledgeable and I hope that they help me. I would be really grateful if you could give me a clue where to start. Again, I'm sorry if my topic is stupid or bothers you.
Thanks


----------



## SirDice (Jan 4, 2022)

hbsd said:


> I did many researches on the forum, handbook, youtube and Internet to learn how to port new softwares to FreeBSD, but I could not do it. I'm really sorry if my topic is too beginner.


We all started at the beginning, not knowing how it works. In your search did you find this: FreeBSD Porter's Handbook? It's not going to tell you exactly how to port stuff but it will explain how a FreeBSD port's Makefile works, which is were it all starts.



hbsd said:


> I really want to be a port maintainer.


There are a whole bunch of ports eagerly waiting for someone to maintain them. If the MAINTAINER is set to ports@freebsd.org then it's an unmaintained port. Those would be a great starting point. Find one you like, try and update it, see what issues you run into. If you have specific questions on how to get things to work in a port then ask here. You can submit patches for them, even if you're not yet willing to take over maintainership. That will at least give you some experience with the process of updating ports. Once you get a good feel for what is required and what needs to be done, pick a port (preferably one that's not maintained) and take over maintainership.


----------



## Erichans (Jan 4, 2022)

If you had not noticed, on the search page you can get a list of all not maintained ports:
not maintained ports


----------



## hbsd (Jan 4, 2022)

SirDice said:


> We all started at the beginning, not knowing how it works. In your search did you find this: FreeBSD Porter's Handbook? It's not going to tell you exactly how to port stuff but it will explain how a FreeBSD port's Makefile works, which is were it all starts.
> 
> 
> There are a whole bunch of ports eagerly waiting for someone to maintain them. If the MAINTAINER is set to ports@freebsd.org then it's an unmaintained port. Those would be a great starting point. Find one you like, try and update it, see what issues you run into. If you have specific questions on how to get things to work in a port then ask here. You can submit patches for them, even if you're not yet willing to take over maintainership. That will at least give you some experience with the process of updating ports. Once you get a good feel for what is required and what needs to be done, pick a port (preferably one that's not maintained) and take over maintainership.


Thank you so much for reply and the link. I read a handbook about FreeBSD, but I didn't know there was a book exactly about porting softwares to FreeBSD!
I thought all I had to do was download the source and compile or interpret the program!
I did this but I received a lot of errors. 
I was hoping there would be a quick way to do this because I am so impatient to do so.
Thank you again, I just started reading the book.


----------



## jbo (Jan 4, 2022)

hbsd What I'd recommend is to look for a piece of software which is comparably trivial to port to FreeBSD. I also did this for my first (and currently only) port: sysutils/cpufetch. I intentionally went looking for a C or C++ application with few to no dependencies in order to get familiar with the actual workflow before trying to tackle something larger. For your first port you _might_ also want to stay away from things which turn out to be more complex such as node.js based stuff (or really anything which would need to fetch dependencies during the build stage - as I understood that is really not trivial with the current ports system).

Alternatively, you might want to pick up an unmaintained port or fix a broken port.

In any case: step by step! As SirDice mentioned: We all started at zero. Your contributions will certainly be appreciated


----------



## SirDice (Jan 4, 2022)

hbsd said:


> I thought all I had to do was download the source and compile or interpret the program!


The general idea of a FreeBSD "port" is exactly that, but automated. A FreeBSD port automatically downloads the source (called the 'distfile') and extracts it in a work/ directory. It then applies one or more patches from files/. Next step is to run GNU configure if needed, or something else, which is all going to depend on how that source code has to be compiled or built. Once the build is done the compiled code is 'installed' in a staging area. From that staging area a package is created. It's this package that eventually gets installed on the system.


----------



## diizzy (Jan 4, 2022)

When someone else asked about this...

Read the Porters Handbook (https://docs.freebsd.org/en/books/porters-handbook/book/) and start by porting something simple, for example these three are small projects that compiles just fine if you follow the handbook.

https://software.es.net/iperf/ (GNU Autotools) - benchmarks/iperf3
https://gitlab.com/ecodis/exhale (CMake) - audio/exhale
https://github.com/zrythm/libaudec (Meson) - audio/libaudec (pulls in a few deps)

Create a dir called NAMEOFPORT-test in the ports tree (benchmarks/iperf3 -> benchmarks/iperf3-test) and create your own Makefile. You can use the correct project name etc so you would end up with a copy of the of the official port in the end.  Do trial 'n error until it compiles and make check-plist happy. You can always compare your Makefile to the original port to catch the mistakes you've made (if any).


----------



## hbsd (Jan 4, 2022)

diizzy said:


> When someone else asked about this...


Thank you for your reply. This forum it's not for professional users only. There are novice users like me. I learned tips in other topics as well as this topic. It is difficult for me to follow the documents at first. I even installed FreeBSD with the help of some youtube videos and after installing it, I started reading handbook. maybe it's wrong, but I need a quick guide at first to get a general understanding of it and then start learning the details.


----------



## Menelkir (Jan 5, 2022)

hbsd said:


> Thank you for your reply. This forum it's not for professional users only. There are novice users like me. I learned tips in other topics as well as this topic. It is difficult for me to follow the documents at first. I even installed FreeBSD with the help of some youtube videos and after installing it, I started reading handbook. maybe it's wrong, but I need a quick guide at first to get a general understanding of it and then start learning the details.


The porter's handbook have a section for a quick start, take a look: https://docs.freebsd.org/en/books/porters-handbook/quick-porting/
You can try porting something simple to understand the "mechanics", after that, you can take a look of what you need. I have a reasonable number of ports under my umbrella and I've always rely on porter's guide for something extra.


----------



## jbo (Jan 5, 2022)

SirDice said:


> It then applies one or more patches from files/.


I don't mean to be nitpicky but rather for my own knowledge: This should read more like: _"It then applies zero or more patches from files/."_ - yes?


----------



## hbsd (Jan 5, 2022)

Menelkir said:


> The porter's handbook have a section for a quick start, take a look: https://docs.freebsd.org/en/books/porters-handbook/quick-porting/
> You can try porting something simple to understand the "mechanics", after that, you can take a look of what you need. I have a reasonable number of ports under my umbrella and I've always rely on porter's guide for something extra.


Thank you. This is exactly what I want! Porter's Handbook looks amazing but it seems more like a reference, I mean it has too much information that confuse me at first. I needed something like a tutorial not a reference (just for getting started). 


Menelkir said:


> You can try porting something simple to understand the "mechanics


After reading that I'm looking for a simple/intermediate python project...


----------



## Menelkir (Jan 5, 2022)

hbsd said:


> Thank you. This is exactly what I want! Porter's Handbook looks amazing but it seems more like a reference, I mean it has too much information that confuse me at first. I needed something like a tutorial not a reference (just for getting started).
> 
> After reading that I'm looking for a simple/intermediate python project...


For getting started, just read the quick porting. If you need something extra, you use the rest of the handbook as a reference (everything you need about creating a port is there, from simple ones to complex ones). Here's an example of a really simple port: audio/pamixer.


----------



## astyle (Jan 6, 2022)

Rome was not built in a day.  As everyone else is pointing out, you gotta start simple. Y'know, beyond knowing how to write a program in a given language (python, bash, c/c++, ruby, etc), and fighting past compilation errors, there's a LOT more to know.  There's also source control, making sure you get the algorithm correctly, making sure the program actually does what you want it to do - and constant testing. All of that comes before you can even sniff the ports framework, let alone have your work accepted into the ports tree. Well, the journey of a thousand miles begins with one step.

Edit: After looking at what hbsd seems to want to port - I can say that it's probably better to get a really good handle on git and best practices, rather than rely on automation too much - that automation may have unintended consequences beyond what's advertised.


----------

