10 ms·
What I Learned from porting my projects to FreeBSD
- otherflavors 8y agonow you should try openbsd or netbsd, as they are even less tolerant of linux-isms
- na85 8y agoGiven that Linux is the de facto standard, wouldn't it be more correct to describe the BSDisms as idiosyncrasies?
- the_trapper 8y agoIt's not usually seen that way because the BSDs are considered to be directly descended from the original UNIX codebase and GNU and Linux are clones.
- antpls 8y agoThe analogy isn't used correctly : BSD was initially a codebase clone of UNIX, in other words, BSD is a fork. GNU/Linux was initially developed from scratch to behave like UNIX to a certain extent (hence the name "Unix-like"). In other words, it's a rewrite inspired from a model.
- Fnoord 8y agoUNIX is a trademark, so you may not call something UNIX unless you are allowed to use that trademark (which costs several 100k USDs to get certified). Apple paid that price for macOS, so (certain versions of) macOS are UNIX. macOS has a marketshare in server market segment of around 0% (client of around 5%, iOS substantial though), and Linux is the defacto standard in that area. Which OS do people learn nowadays? Linux distributions. So it makes sense to see it from that PoV. Because chances are that you're going to use that defacto standard. And even if you prefer UNIX(tm) or BSD or Solaris you'd rather use Linux than Windows or OpenVMS. Cause the latter are aliens from outer space.
- msla 8y agoAs a purely technical note, there is a Linux which is a UNIX: Inspur K-UX. More philosophically, insisting on a definition of UNIX which includes z/OS and excludes Seventh Edition Unix isn't going to win you many friends. http://www.opengroup.org/csq/repository/norationale=1&noreferences=1&RID=ibm%252FXU1%252F6.html http://www.opengroup.org/csq/repository/norationale=1&norefe... And speaking of aliens from outer space, z/OS is a JCL-eating Martian speaking EBCDIC through its virtual cardpunch. ;)
- shlomifish 8y agoWe've written about certified UNIX wrt macOS vs. Linux here - https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ.mdwn#is-it-true-that-macos--mac-os-x-is-superior-to-linux-because-it-is-a-certified-unix https://github.com/shlomif/Freenode-programming-channel-FAQ/... .
- wbl 8y agoAliens have something to teach us. The current OS monoculture is not conducive to innovation.
- LambdaComplex 8y ago"BSD is what you get when a bunch of Unix hackers sit down to try to port a Unix system to the PC. Linux is what you get when a bunch of PC hackers sit down and try to write a Unix system for the PC."
- jrumbut 8y agoLinux may be the de facto standard, but BSD cares about the de jure standard. It's a matter of perspective. Also many of these are actually GNU idiosyncrasies, and from it's name GNU suggests that there is a standard, and they are going to be different.
- greglindahl 8y agoFun to think it's come full circle; BSD used to be the rule-breakers.
- hyperman1 8y agoIsn't that the history of computing? the word UNIX points at the disdain its makers had for Multics. They broke every rule IBM had. PCs were these toys for people who had no acces to real computers, until they were the standard. Microsoft provided toy OSes until they wiped out almost anybody else. Java, MySql and subversion are other examples. I've read somewhere that every succesfull product has a phase where the world laughs at it. If that hadn't happened, it would have been smothered in the cradle by the behemots of its time. Being laughed at gave it time to grow.
- acct1771 8y agoThey break the rule these days by actually giving a shit about security instead of doing what many of us are guilty of doing: dumbing it down for the lowest common denominator user to make money. Has created some incredible UI paradigms and elements, but...
- smcameron 8y agoI think of linux as the new SunOS 4.x. I remember back in the day when random crap you got would work fine on SunOS, but was a pain on HP-UX, AIX, or whatever other weird unix you had around. Now linux is like SunOS 4.x was back then.
- nineteen999 8y agoThat's a totally weird way to think of it, since up to SunOS 4.x, it was mostly based on BSD, and afterwards, after being renamed to Solaris, on SysV.
- wahern 8y agoWhich distro? Which libc? Which minimum kernel version? Which minimum version of GNU Make? Which specific version of GCC or clang? Linux isn't a static environment. The closest thing to static is POSIX, and by and large every Unix environment, including various Linux environments as well as BSD environments, asymptotically approach POSIX compliance. If you want to maintain a project long-term (5+ years), attempting to minimize deviations from POSIX is a solid strategy in terms of avoiding bit rot and long-term maintenance burdens. Sometimes it's unavoidable, but the point is to weigh your options carefully and don't undervalue the benefit of POSIX compliance. If you want to maximize the chance that your software will compile and execute correctly on a Linux distro 5+ years from now, a good first step is making sure it builds and runs natively on some of the BSDs. There's a trend to discount the value of POSIX and to even actively break POSIX compliance in a way that makes it very difficult to support both POSIX semantics and some feature du jure. Developers should be wary of those who do this because if such projects and their maintainers don't see any value in POSIX they're not likely to see value in the long-term maintenance and stability of whatever feature they're selling you on today. Else thread somebody says that they see Linux as the new SunOS. I agree.[1] But where is SunOS today? [1] Except that Sun put much more emphasis on backwards compatibility. The Linux kernel developers emphasize backward compatibility, but the distros don't, and if the distros rip something out then inevitably it gets removed from upstream. OTOH, while the kernel developers rightfully have said they won't compromise sane design for POSIX, it turns out that such situations have been exceedingly rare and in general they take POSIX compliance seriously.
- danieldk 8y agomaintainers don't see any value in POSIX The problem is that POSIX only provides a tiny subset of the API surface that an application might need today. Just to give two random examples: how can an application inhibit system sleep or use a webcam? The best one often can do is rely on some widely-used library and hope that they (will continue to) support multiple platforms. But where is SunOS today? Comparing apples and oranges. For a large part of its lifetime, SunOS was a proprietary UNIX that only worked with Sun hardware. If we include SunOS 5/Solaris, they open sourced Solaris way after Linux already had a stronghold in the market. Linux is now so dominant in mobile phones, servers, network devices, and IoT, that even it will take much longer to disappear than SunOS.
- deleted 8y ago[deleted]
- mcbain 8y agoIf your makefiles use gnu-isms (which is a valid choice) then I would lean towards using GNUmakefile and have Makefile call gmake - and don’t forget to use $(MAKE) for any recursion. This is less fragile and requires less dependence on replacing make in the $PATH.
- ComputerGuru 8y agoGlad I’m not the only one: https://github.com/neosmart/gmake-proxy https://github.com/neosmart/gmake-proxy All maintained and ready to go.
- rwmj 8y agoCould do all that, but FreeBSD could also have GNU make as the standard "make". I know there's some "license purity" reason why they don't want to do that, but don't expect everyone else to work around your self-imposed problem.
- minusf 8y agoisn't make older than gmake? it is normally gnu that adds extensions not compatible with the rest of the Unix world. making people believe sh == bash, make == gmake, m4 == gm4, and the list goes on for everything they touch.
- bewo001 8y agoEvery Unix used to have its own implementation of those standard tools. They were often quite buggy and outdated (eg the C compiler that came with SunOS and Solaris in the mid 1990's only supported K&R syntax). When installing Solaris, Sinix, AIX etc, you'd typically install the GNU tools immediately. I understand the FreeBSD folks' frustration, though.
- shlomifish 8y agoTo be frank, many of the GNU extensions are very useful. BSD tools have their own extensions over POSIX as well. Anyway, GNU software is FOSS and tends to be portable and so you can create something like GNU/FreeBSD or GNU/OpenBSD or whatever (Debian did it in the past). Naturally, the GPL/LGPL/etc. may not be "free" enough for the tastes of the BSD devs, but this is getting into politics.
- nikisweeting 8y agoJust wait till you discover FreeNAS, pfSense, and OpenBSD! A world of awesome, battle-tested software awaits once you join the BSD dark side.
- metildaa 8y agopfSense is great for a prosumer router. What gets me about it is cleaning up the mess it creates in business use cases, as pfSense is designed with a mindset that the pro will always be there, ready to attach a screen at a moments notice when interfaces change or packages get updated. Running PHP as root also isn't great, I'm not sure how that passes in the context of HIPPA.
- gigatexal 8y agoYou can always roll your own headless openBSD + pf
- liv-io 8y agoI can only recommend the same, OpenBSD + pf is simply perfect. If you manage a couple of firewalls add Ansible and you'll never consider vendor firewall appliances again: https://github.com/liv-io/ansible-roles-bsd/tree/master/openbsd_pf https://github.com/liv-io/ansible-roles-bsd/tree/master/open...
- mkhpalm 8y ago
- deleted 8y ago[deleted]
- dis-sys 8y ago"It is easier to port a shell than a shell script." This is gold!
- xvilka 8y agoOr just switch to Meson+Ninja [1][2] and enjoy all features of modern build systems. [1] https://mesonbuild.com/ https://mesonbuild.com/ [2] https://ninja-build.org/ https://ninja-build.org/
- dig1 8y agoBefore mesom/ninja, you had one problem - install gmake. Now you have three problems - install python, ninja and meson ;) Maybe fourth - learn how to use it
- jcelerier 8y ago> Before mesom/ninja, you had one problem - install gmake. No, you had as many problems as there are '%' and '$' symbols in this web page : http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/ multiplied by the number of permutations of tools in the different platforms you want to support, e.g. (gcc-mingw-windows, clang-cl-windows, msvc-windows (this one counts as 10), xcode-macos, gcc-macos). And let's not even get started with cross-compiling.
- enriquto 8y agoIn what sense isn't gnu make a modern build system?
- agambrahma 8y ago> FreeBSD’s grep does not have a "-P" flag by default (I continue to wonder what's stopping everyone from just ditching `grep` altogether and switching to `ag`/`rg`)
- andrewprock 8y agoAt the very least ag does not handle large files. It bails with an error after the file gets too big.
- shakna 8y agoIt can crash, on large files, particularly on macOS because mmap is disabled by default. But that should go away by streaming the file. e.g. cat haystack | ag 'Needle'
- sebcat 8y agoag Needle < haystack No need for cat
- torstenvl 8y agoYour version requires fewer keystrokes. It's also mental model-breaking and un-Unixy. Pipes, my good man! Pipe everything to everything!
- muxator 8y agoHow come knowing how to redirect stdin is un-Unixy? Pipes are a good tool, and so are many others. Having a good command of other basic mechanisms of the shell is going to hugely pay off, try to have a brief shot if you want [0]. [0] https://www.gnu.org/software/bash/manual/html_node/Redirections.html https://www.gnu.org/software/bash/manual/html_node/Redirecti...
- twic 8y agoNo. Useless Use of Cat is sufficiently unidiomatic that there is an award for it: http://porkmail.org/era/unix/award.html http://porkmail.org/era/unix/award.html
- throwaway487548 8y agoWow, it has no fucking systemd!
- DonHopkins 8y ago>Perl is portable shell — Guy Keren Which still has many of the terrible problems of the shell, because its original design was an imitation of several different shell scripting languages. If all you know is Perl and you're incapable of learning any other languages, or for some perverse reason you like the way Perl scripts look just as incomprehensible as shell scripts, and you're absolutely sure nobody else will ever need to look at or maintain your code, then by all means use Perl. But if you don't hate the people who will have to clean up after you or decipher and maintain what you're done, then please use Python or JavaScript instead of Perl or shell scripts.
- TurboHaskal 8y agoSo we should instead write scripts for people that all they know is Python and Javascript and are incapable of learning any other languages, right? Sorry but Perl is perfectly fine even by today’s standards.
- m45t3r 8y agoI can understand Python (it has a library in stdlib for running subprocess, and it is specially good after Python 3.4). However AFAIK JavaScript is bad for shell scripting. You need a external library to have sane subprocess call, unless you give up and allow command injection inside your scripts. Last time I looked even the alternatives in npm were not as good as what Python offered in stdlib. Actually, I don't know many languages that have a good way to call subprocess in stdlib. Ruby's Open3 comes in mind, however the API is kind horrible.
- DonHopkins 8y agoYou didn't think I meant running JavaScript in the browser, did you??! Of course JavaScript has an external library for sane subprocess calls, and is perfectly fine and commonly used for writing process management and system administration scripts. Please google "node.js" and "npm". [Edited for tone -- thanks mkesper.]
- m45t3r 8y ago
- raimue 8y agoThe author mentions to be unsatisfied with the solution to use symlinks for finding DocBook XSL files. The correct way to reference DocBook XSL stylesheets is to use the HTTP URL to the stylesheet, which will be looked up in the XML catalog of your system. This catalog file maps URLs to files on disk and is managed by your package manager. You should also forbid your tools to access these URLs directly (--nonet), as it would be incredicly slow and you rather want your build to fail in this case instead of downloading on-demand. xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl foobar.xml If you prefer to work with files instead of passing long URLs on command line, use a small wrapper file to import the real stylesheet and pass that on command line instead of using the URL. The advantage is that you can also put additional <xsl:param> tags to customize the output right into this file. <?xml version='1.0' ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/> <!-- put additional xsl:param here --> </xsl:stylesheet>
- blattimwind 8y agoIsn't referencing something like "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" http://docbook.sourceforge.net/release/xsl/current/manpages/... wrong, because that refers to some unspecified version (note the "/current/" bit)?
- jwilk 8y ago--nonet is also a necessity for security reasons. The downloaded XSLT stylesheets are not authenticated in any way.
- Sir_Cmpwn 8y agoFor anyone interested, I'm providing FreeBSD CI services on sr.ht. We use it to test wlroots[0]. https://builds.sr.ht/~sircmpwn/job/9348 https://builds.sr.ht/~sircmpwn/job/9348 I'm also working on OpenBSD and NetBSD, other kernels, and non-x86 architectures. If anyone is interested in using this to make their software more portable, please let me know! Email in my profile. [0] https://github.com/swaywm/wlroots https://github.com/swaywm/wlroots
- profquail 8y agoTravisCI has been asked repeatedly to provide FreeBSD as a build OS, and it doesn’t appear they’re interested in expanding beyond Linux/macOS on x86: * https://github.com/travis-ci/travis-ci/issues/1818 https://github.com/travis-ci/travis-ci/issues/1818 * https://github.com/travis-ci/travis-ci/issues/6671 https://github.com/travis-ci/travis-ci/issues/6671 * https://github.com/travis-ci/travis-ci/issues/5473 https://github.com/travis-ci/travis-ci/issues/5473 Do you plan on providing Github integration? Providing other OSes and platforms (e.g. ARM64, ppc64el) would be really useful for testing low-level projects like .NET Core runtime, node.js / libuv, etc., and integrating with Github would make it really easy for people to start adding this to their existing projects. If you do end up providing Github integration, consider listing a paid option for your service in the Github marketplace: https://github.com/marketplace/category/continuous-integration https://github.com/marketplace/category/continuous-integrati...
- Sir_Cmpwn 8y agoI already provide Github integration, but it's not very polished. That's how wlroots gets built, for example: https://github.com/swaywm/wlroots/pull/1341 https://github.com/swaywm/wlroots/pull/1341 (click "show all checks") I may add it to the marketplace once it's open for public registration and more polished.
- flurrything 8y agoAre these services free? We currently test Rust under qemu-system for FreeBSD and have no real good solution for OpenBSD and DragonflyBSD. It would be very interesting for us to do "native" testing.
- nopacience 8y agoFreeBSD is great! Even as a desktop. NVIDIA builds official drivers for FreeBSD. I dont know whats the status for newer AMD graphics card. Nvidia + Intel graphics also works very well. There is a port system where users can build the packages from sourcecode on their own machines. Its +- like gentoo. There is also a binary pkg system. It is faster to install since the packages are already built (binary). To upgrade from minor versions ie. 11.1 to 11.2 it is very simple and well documented. Just see in the manual freebsd-update There is native support for ZFS also which is great. Virtualbox works very well, so its possible to install other OSes in virtualbox. VMware i dont think is supported.
- howard941 8y agoAnother great thing about FreeBSD is it's not too hard going the other way: Embedding FreeBSD is a robust choice, one that can take you quickly to market as it did for me and a GPS on golf cart project I did in the late 90s with it, busybox, and some valuable help from PHK on getting support for the weirdo LCD panel the suits picked (we had to turn the panel upside down in the cart, the viewing angle was atrocious).
- rob 8y agoI wish more VPS providers offered OpenBSD and FreeBSD. I remember using FreeBSD a lot when I was 12-17 just messing around and setting up servers, etc but eventually moved to Debian because VPS' at the time didn't really offer these that much (reliably.)
- jancsika 8y agoIs there a jquery equivalent for shell scripting?
- lloeki 8y agoQuoting a quote from the article: > Perl is portable shell Which ironically I do use in this way but never formulated it in such a compact and witty way. I found Perl to be available basically by default on every platform I could encounter, from AIX 3 to Windows (it comes along with Git for Windows, which gives you bash too).