FreeBSD is in need of a new linux_base port. It is on my TODOÂ list since a long time, but I do not get the time to create one. I still do not have the time to work on a new one, but when you read this, I managed to get the time to create a HOWTOÂ which describes what needs to be done to createÂ a new linux_base port.
I will not describe how to create a new linux_base port from scratch, I will just describe how you can copy the last one and update it to something newer based upon the existing infrastructure for RPM packages.
Specific questions which come up during porting a new Linux release should be asked on [email protected],Â there are more people which canÂ answer questions than here in myÂ blog. IÂ will add useful information to this HOWTO if necessary.
In the easy case most of the work is searching the right RPMs and their dependencies to use, and to create the plist.
Why do we need a new linux_base port?
The currentÂ linux_base portÂ is basedÂ upon Fedora 10, which is end of life since December 2009.Â Even Fedora 13 is already end of life. Fedora 16 is supposedÂ to beÂ released this year. From a support point of view, Fedora 15 or maybe even Fedora 16 would be a good target for the next linux_base port. Other alternatives would be to use an extended lifetime release of another RPM based distribution, like for exampleÂ CentOSÂ 6 (which seems to beÂ based upon Fedora 12 with backports from Fedora 13 and 14). Using a Linux release which is toldÂ to beÂ supported for at least 10 years, sounds nice from a FreeBSD point of view (only minor changesÂ to the linux ports in such a case, instead of creating a complete new linux_base each N+2 releases like with Fedora), but it also means additional work if you want to create the firstÂ linux_base port for it.
The mysteriesÂ you have to conquer if you want to create a new linux_base port
What we do not know is, if Fedora 15/16, CentOS 6, or any other Linux releaseÂ will work in a supported FreeBSD release. There are two ways to find this out.
The first one is to take an existing Linux system, chrootÂ into it (either via NFS or after making a copy into a directory of a FreeBSD system), and to run a lot of programs (acroread, skype, shells, scripts, â€¦). The LTPÂ testsuiteÂ is not that much useful here, as it will test mostly kernel features, but we do not know which kernel features are mandatory for a givenÂ userland of a Linux release.
The second way of testing if a givenÂ Linux release works on FreeBSD is to actually create a new linux_base port for it and test it without chrooting.
The first way is faster, if you are only interested in testing if something works. The second way provides an easy to setupÂ testbed for FreeBSDÂ kernel developers to fix the Linuxulator so that it works with the new linux_base port. Both ways have their merits, but it is up to the person doing the work to decide which way to go.
The meat: HOWTO create a new linux_base port
First off, you need a system (or a jail) without any linux_base port installed. After thatÂ you canÂ create a new linux_base port (= lbN),Â by justÂ making a copy of the latest one (= lbO). InÂ lbNÂ you need to add lbOÂ as a CONFLICT, and in all other existing linux_base ports, you need to add lbN as a conflict.
Change the PORTNAME, PORTVERSION, reset the PORTREVISIONÂ in lbN, and set LINUX_DIST_VERÂ to the new Linux-release version inÂ theÂ lbNÂ MakefileÂ (this is used in PORTSDIR/Mk/bsd.linux-rpm.mk and PORTSDIR/Mk/bsd.linux-apps.mk).
If you do not stay with Fedora, there is some more work to do before you can have a look at chosing RPMsÂ for installation. You need to have a look at PORTSDIR/Mk/bsd.linux-rpm.mk and add some cases for the new LINUX_DIST you want to use. Do not forget to set LINUX_DIST in theÂ lbNÂ MakefileÂ to theÂ name of the distributionÂ you use.Â You also need to augment the LINUX_DIST_VER check in PORTSDIR/Mk/bsd.linux-rpm.mk with some LINUX_DIST conditionals. If you are lucky, the directory structure for downloads is similar to the Fedora structure, and there is not a lot to do here.
When this is done, you can have a look at the BIN_DISTFILES variable in the lbNÂ Makefile. Try to find similar RPMsÂ for the new Linux release you want to port. Some may not beÂ available, and it may also be the case thatÂ different ones are neededÂ instead. I suggest to first work with the ones which are available (make makesum, test install andÂ create plist). After that you need to find out what the replacementÂ RPMsÂ for non-existing ones are. You are on your own here. Search around the net, and/or have a look at theÂ dependencies in the RPMsÂ of lbOÂ to determineÂ if something was addedÂ as a dependency of something else or not (if not, forget about it ATM). When you managed to find replacement RPMs, you can now have a look at the dependencies of the RPMsÂ in lbN. Do not add blindly all dependencies, not all are neededÂ in FreeBSD (the linux_base ports are not supposed to create an environment which you can chrootÂ into, they are supposedÂ to augment the FreeBSD system to beÂ able to run Linux programs in ports like they where FreeBSDÂ native programs). What you need in the linux_base ports are libraries, config and data files which do not exist in FreeBSD or have a differentÂ syntax than in FreeBSD (those configÂ or data files which are just in a different place, can beÂ symlinked), and basic shell commands (whichÂ commands are neededÂ or notâ€¦ wellâ€¦ good question, in the past we made decisionsÂ what to includeÂ based upon problem reports from users). Now for the things which are not available and where not added as a dependency. Those are things which are either used during install, or where useful to have in the past. Find out by what it was replaced and have a look if this replacement can easily be used instead. If it can be used, add it. If not, wellâ€¦ bad luck, we (the FreeBSD community)Â will see how to handle this somehow.
If you think that you have all you need in BIN_DISTFILES, please update SRC_DISTFILES accordingly andÂ generate the distfile viaÂ Â make â€“DPACKAGE_BUILDING makesum to have the checksums of the sources (for legalÂ reasons we need them on our mirrors).
The next step is to have a look at REMOVE_DIRS, REMOVE_FILES and ADD_DIRS if something needs to be modified. Most of them are there to fall back to the corresponding FreeBSD directories/files, or because they are not needed at all (REMOVE_*). Do not remove directories from ADD_DIRS, they are created here to fix some edge conditions (I do not remember exactly why we had to add them, and IÂ do not take the timeÂ ATM to search in the CVS history).
If you are lucky, this is all (make sure the plistÂ is correct). If you are not lucky and you need to make some modifications to files, have a look at the do-build target in the Makefile, this is the place where some changes are done to create a nice user experience.
If you arrive here while creatingÂ a new linux_base port,Â lean back and feel a bitÂ proud. You managed to create a new linux_base port. It is not very well testedÂ at this moment, and it is far from everything which needs to beÂ done to have the complete Linux infrastructure for a given Linux release, but the most important part is done. Please notify [email protected]Â and call for testers.
What is missing?
UPDATE: I got some time to write how to update the Linux-infrastructure ports.