Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shlomif/what-i-learned-from-porting-to-freebsd

What I Learned from porting my projects to FreeBSD
https://github.com/shlomif/what-i-learned-from-porting-to-freebsd

bsd docbook docbook5 foss freebsd gnu hacktoberfest linux opensource operating-systems perl

Last synced: 14 days ago
JSON representation

What I Learned from porting my projects to FreeBSD

Awesome Lists containing this project

README

        

What I learned from porting my projects to FreeBSD
==================================================
Shlomi Fish
:Date: 2018-10-07
:Revision: $Id$

[id="intro"]
Introduction
------------

I set up a local https://www.freebsd.org/[FreeBSD] VirtualBox VM to test
something, and it seems to work very well. Due to the novelty factor, I decided
to get my software projects to build and pass the tests there.

[id="the_projects"]
The Projects
------------

* https://github.com/shlomif/shlomif-computer-settings/ (my dotfiles).

* https://web-cpan.shlomifish.org/latemp/

* https://fc-solve.shlomifish.org/

* https://www.shlomifish.org/open-source/projects/black-hole-solitaire-solver/

* https://better-scm.shlomifish.org/source/

* http://perl-begin.org/source/

* https://www.shlomifish.org/meta/site-source/

* Written using a mix of C, Perl 5, Python, Ruby, GNU Bash, XML, CMake, XSLT,
XHTML5, XHTML1.1, https://github.com/thewml/website-meta-language[Website META Language], JavaScript and more.

* Work fine on several Linux distributions and have
https://en.wikipedia.org/wiki/Travis_CI using Ubuntu 14.04 hosts

* Some pass builds and tests on AppVeyor/Win64

[id="lessons"]
What I Learned:
---------------

[id="reliable"]
FreeBSD on VBox has become very reliable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Survived a host power interruption - https://twitter.com/shlomif/status/1048852791987527680 .

* I recall that some years back, rebooting with X running (because input was
not enabled) has https://en.wikipedia.org/wiki/List_of_military_slang_terms#FUBAR[FUBARed] the +/etc+ directory prompting a reinstall, so FreeBSD on VirtualBox has come a long way.

[id="usr_local"]
Some executables on FreeBSD are in /usr/local/bin instead of /usr/bin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Linux they are almost always in +/usr/bin/+ only:

* https://github.com/shlomif/shlomif-computer-settings/blob/master/shlomif-settings/home-bin-executables/bin/fix-perl-shebang.pl[script to fix the perl shebang line]

* +/usr/bin/env+ is your friend.

* https://www.freebsd.org/cgi/man.cgi?hier%287%29[man hier(7)] explains the
difference.

[id="gmake"]
make on FreeBSD is not GNU make
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* One can call +gmake+

* No +gmake+ on some older versions of Debian/Ubuntu/etc.
+
* Solution for Debian:
+
--------------
mkdir -p "$HOME/bin"
ln -sf /usr/bin/make "$HOME/bin/gmake"
export PATH="$HOME/bin:$PATH"
--------------
+
* +gmake+ alias under +/usr/bin/+ is present again in recent versions of Debian.

[id="m4"]
m4 on FreeBSD is not compatible with GNU m4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Fixed in https://github.com/thewml/website-meta-language/commit/97c4ce264b66c880ea0016c096fda9d3188c0f4e[this commit] by first checking for +gm4+ and
then falling back on plain +m4+.

[id="cpan_dists"]
Some CPAN Modules fail to install using local-lib there
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* No idea why.

* Sometimes +cpanm -n+ (“no test”) helps.

* +pkg install -y p5-Foo-Bar+ as root for other times.

[id="docbook_xsl"]
DocBook/XSL Does Not Live Under /usr/share/sgml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Fixed using a symlink on the FreeBSD system.

* Unhappy with this solution.

* On the “Hacker News” discussion, it was recommended to use +xsltproc --nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl foobar.xml+ ( https://news.ycombinator.com/item?id=18318771[Reference] )

[id="grep_dash_P"]
FreeBSD's grep does not have a “-P” flag by default
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* The “-P” flag is not in http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html[the POSIX’s grep specification]

* Solution:
+
-----------------
- ) | grep -vP '^<\?xml ver' \
+ ) | perl -p -0777 -e 's%\A<\?xml ver[^>]*>%%' \
-----------------

* Does not exactly do the same operation, but even more correct.

* {blank}
+
[quote, Guy Keren]
Perl is portable shell

[id="nproc"]
FreeBSD has no "nproc" command
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* https://unix.stackexchange.com/questions/108821/number-of-cores-on-freebsd

* nproc(1) is available in FreeBSD as of 13.2-RELEASE. ( https://man.freebsd.org/cgi/man.cgi?query=nproc&sektion=1&manpath=FreeBSD+14.0-CURRENT[Reference.] )

* Added a small shell executable under +~/bin/nproc+ .

[id="to_do"]
What still does not work:
-------------------------

* Valgrind tests fail - possibly due to https://github.com/shlomif/perl-Test-RunValgrind/issues/5[this bug]

* Spellchecking tests fail, like on Ubuntu, as it seems https://en.wikipedia.org/wiki/Hunspell[hunspell] has system-dependent dictionaries. (Workaround: +export SKIP_SPELL_CHECK=",en,"+.)

[id="conclusion"]
Conclusion:
-----------

[quote, Larry Wall]
https://www.quotes.net/quote/34583[It is easier to port a shell than a shell script.]

* I ran into some cases where my scriptology was lacking and suboptimal, even
for my own personal use, and fixed them.

[id="coverage"]
Coverage:
---------

* https://www.reddit.com/r/freebsd/comments/9ncmrs/what_i_learned_from_porting_my_projects_to_freebsd/[On the /r/freebsd subreddit] - with some discussion.

* https://news.ycombinator.com/item?id=18318771[Hacker News comments] - with a lot of discussion, including some with technical insights.

[id="continuations"]
Continuations / sequels / updates:
----------------------------------

* https://github.com/shlomif/what-i-learned-from-porting-to-freebsd[“What I learned from porting my projects to FreeBSD”]

* https://github.com/shlomif/why-my-projects-cannot-support-netbsd-yet[“Why my projects cannot support NetBSD (yet)”]

* https://github.com/shlomif/why-the-BSDs-should-not-blame-USL-vs-BSDi-for-linux-dominance[“Why the BSDs should not blame the USL vs BSDi lawsuits for Linux’s dominance”]