Can’t compile a port software. Error: Unable to determine OS version. Either define OSVERSION, install /usr/include/sys/param.h or define SRC_BASE
-
Hi,
I'm trying to compile a port and I get this error:
make: "/usr/ports/Mk/bsd.port.mk" line 1177: Unable to determine OS version. Either define OSVERSION, install /usr/include/sys/param.h or define SRC_BASE. make: stopped in /usr/ports/devel/gh
This is what I did:
git clone --depth 1 https://github.com/pfsense/FreeBSD-ports /usr/ports
cd /usr/ports/devel/gh
make install clean
How can I fix it?
Regards, Antoine
-
Where are you trying to compile this port? You can't do any development work on the firewall as none of the required supporting libraries and utilities are installed (and they should never be -- it's a firewall not a software development box).
The proper way to build ports is to create a totally separate FreeBSD machine (a virtual machine is great for this), install the required development tools, and then build the port of your choice.
One warning, don't expect a port built this way to seamlessly install on pfSense. It is likely you will see incompatibilities between the customized pfSense kernel and the stock FreeBSD one on your builder.
If you want to build a customized port that will actually install on a pfSense machine without issue, you will need to read through this very long thread and follow the steps outlined there in the various posts: https://forum.netgate.com/topic/169749/pfsense-compile-requirements-for-3rd-party-software. Be prepared to spend quite a bit of time getting it work correctly, but in the end it will work . I do this all the time to build and test new versions of the Snort and Suricata packages for which I am the volunteer maintainer. When you build the "package builder machine" described in the thread, you must select the proper pfSense branch (RELENG or DEVEL) for the target pfSense machine.
-
@bmeeks
I was trying to compile ports on a Virtualbox machine, and yes, then I would copy it on my real router.So, I understand that I must install a corresponding FreeBSD version.
Since I have pfSense 2.7.2, and that
uname -a
gives me14.0-CURRENT
, I should download FreeBSD 14.0-STABLE, according to the post you linked in your reply?But I don’t see it in the FreeBSD download site…
https://download.freebsd.org/releases/amd64/Regards, Antoine
-
@antoine2711 said in Can’t compile a port software. Error: Unable to determine OS version. Either define OSVERSION, install /usr/include/sys/param.h or define SRC_BASE:
@bmeeks
I was trying to compile ports on a Virtualbox machine, and yes, then I would copy it on my real router.So, I understand that I must install a corresponding FreeBSD version.
Since I have pfSense 2.7.2, and that
uname -a
gives me14.0-CURRENT
, I should download FreeBSD 14.0-STABLE, according to the post you linked in your reply?But I don’t see it in the FreeBSD download site…
https://download.freebsd.org/releases/amd64/Regards, Antoine
Well, it gets complicated quickly when trying to compile ports for pfSense. As you found, you can't actually download and install 14.0-STABLE now. What I would do is follow the steps outlined in several of the posts in the thread I linked earlier. You will need to read most (if not all) of the posts in that thread to get the gist of how to proceed. It is very hard to do, and there is lots that is not documented. The folks who contributed to that linked thread all give tidbits of what is required and what eventually worked for them. You will need quite a bit of experience with code development/compiling/linking and with using
pkg
to get things working. It's not a click once or twice and you're done affair. It will take a lot of tinkering.You will first need to install a vanilla FreeBSD virtual machine to act a base platform for the package builder. You can install 14.2-STABLE for that as it is available. It really does not matter much because then you would need to follow the steps to clone and check out the pfsense/pfsense repo and pfsense/FreeBSD-ports repo from GitHub. Then follow the steps described in the posts from that linked thread to properly configure the local
build.conf
file and then set up a Poudriere package builder using the relevant pfSense branch (that is RELENG_2_7_2 if building for the current CE version of pfSense).The ports are best built using a Poudriere jail that is created using the FreeBSD source code directly from the pfSense repos on GitHub. The tools needed to do that are described in the linked thread. It's just going to be an exercise to read them all and understand the flow. It is NOT a trivial thing -- that I can guarantee you . And you very well may get frustrated and throw up your hands before finishing. Many others have done that.
This post in that long thread is a good summary of the "final solution": https://forum.netgate.com/topic/169749/pfsense-compile-requirements-for-3rd-party-software/101. But to fully understand what the post is summarizing, you need to research the material in all of the previous posts.
-
Yes, I understand this is not an easy task. I’ve been using pfSense since before 2009. I started to program in BASIC in 1981, and assembler in 1984. I’ve programmed as a paid job in many languages though not full-time. There are so many things to know in this field, I’m very humble about my knowledge. Hence my beginner questions.
That being said, I’m ready to do the leg work. I just need pointers.
But your answers made me think of another way to fix my problem. If I get the lastest pkg file, I could install them directly on pfSense? I’m just looking to install small utilities, like my password manages client, 1password-client2.
I looked at the FreeBSD repo for the packages, but I can’t get the URL to download one.
http://pkg.freebsd.org/FreeBSD:14:amd64/latest/.This is the YAML info for my package. What would be the correct link to download it?
{"name":"1password-client2","origin":"security/1password-client2","version":"2.30.3","comment":"1Password CLI client","maintainer":"ler@FreeBSD.org","www":"https://developer.1password.com/docs/cli/upgrade","abi":"FreeBSD:14:amd64","arch":"freebsd:14:x86:64","prefix":"/usr/local","sum":"b49f2f82f2b9c291c43cb28cda4175528bfd1522e66962466be4b8b12fccbc19","flatsize":23599360,"path":"All/1password-client2-2.30.3.pkg","repopath":"All/1password-client2-2.30.3.pkg","licenselogic":"single","pkgsize":6988638,"desc":"This is a command-line interface to the 1Password password management\nservice.\n\nThis is the release of the CLI Version 2.","categories":["security"],"annotations":{"build_timestamp":"2024-11-09T01:08:10+0000","ports_top_git_hash":"203aa1081a","ports_top_checkout_unclean":"no","port_git_hash":"5e21b76903","port_checkout_unclean":"no","built_by":"poudriere-git-3.4.2","FreeBSD_version":"1401000"}}
Should I install the Poudriere tool to do so?
Thanks for your time to help me.
Regards, Antoine
-
Hi @bmeeks, I was able to retreive the
pkg
in the cache folder of my FreeBSD (/var/cache/pkg
).Thanks for your help again. I’m ok for now.
Best Regards, Antoine
-
@antoine2711 said in Can’t compile a port software. Error: Unable to determine OS version. Either define OSVERSION, install /usr/include/sys/param.h or define SRC_BASE:
Hi @bmeeks, I was able to retreive the
pkg
in the cache folder of my FreeBSD (/var/cache/pkg
).Thanks for your help again. I’m ok for now.
Best Regards, Antoine
The risk with installing packages from the stock FreeBSD repo (or any other repo except the official pfSense repo for your version) is that the versions of various shared library dependencies may differ from what is currently used by pfSense. The
pkg
utility will automatically attempt to download and install any shared library dependencies needed by the package you are installing. So long as those are the same ABI and shared library versions as what already exists on the pfSense installation, you are fine. It's when they differ that your pfSense installation can get broken - and sometimes irretrievably broken.