Building From Source

written September 29th, 2021
                                  .
                                  ').
                                /;((
                              .'____`.
                              | g    | create
                              |  a   | something
                              |   r  | worth
                              | bash | rewriting
                              `-____-'

The first code I ever wrote was written in AutoHotKey. It's a scripting language for Windows. It's object is simple: allow users to automate the boring stuff. I abused the language and built GUI programs with it. I wouldn't recommend it but here we are.

I was in IT. Most of my time was spent setting up servers, installing printers, or practicing my patience while debugging over the phone with customers. There was a lot of boring stuff waiting to be automated. I'm grateful I got my start writing code during that time, but I also got to spend a lot of time playing sys admin.

My terminal adventures mostly consisted of me stumbling my way through commands I didn't understand. No one ever told me about man. I barely knew what Linux was and OpenBSD could have been something that NASA used to keep astronauts alive in space.

I've come a long way since my AutoHotKey days. I no longer write scripts in Windows. Instead, I avoid PHP at all costs, ship JavaScript bundles that are too large, and dream of grokking Rust. But lately I've been spending a lot of my time closer to my roots.

My friend Alex and I have started exploring our very own tilde community. We named it garbash because of a joke that was made in a PR to fix some of our bash scripts at Monthly. It's our tiny own space on the internet to play on the web like the days of old. We have our own git, IRC, email, and web servers.

It's given me a chance to connect with my past in a way I didn't expect. I'm no longer wrestling printer drivers or battling the bugs within my AutoHotKey fax management software. Instead, Alex and I are pair programming and configuring software that is open and free.

One great thing about OpenBSD is that the source code is publicly available. All of the source is in one repo. It's even available for online perusing.

If you want to build from the source files, you can clone their publicly available code to your machine! OpenBSD expects everything to live in /usr/src which is where the source code lives the garbash server.

Let's take a look inside /usr/src:

$ ls -lah /usr/src
total 120
drwxrwxr-x   16 root  wsrc    512B Sep 22 00:49 .
drwxr-xr-x   16 root  wheel   512B Sep 21 21:07 ..
-rw-r--r--    1 alex  wsrc     39B Sep 22 00:47 .git
-rw-r--r--    1 alex  wsrc      7B Sep 22 00:47 .gitignore
-rw-r--r--    1 alex  wsrc    3.6K Sep 22 00:47 Makefile
-rw-r--r--    1 alex  wsrc   15.7K Sep 22 00:47 Makefile.cross
drwxr-xr-x   32 alex  wsrc    512B Sep 22 00:47 bin
drwxr-xr-x   21 alex  wsrc    512B Sep 22 00:47 distrib
drwxr-xr-x   26 alex  wsrc    1.5K Sep 22 00:47 etc
drwxr-xr-x   43 alex  wsrc    1.0K Sep 22 00:47 games
drwxr-xr-x    8 alex  wsrc    512B Sep 22 00:48 gnu
drwxr-xr-x    6 alex  wsrc    2.0K Sep 22 00:48 include
drwxr-xr-x   37 alex  wsrc    1.0K Sep 22 00:48 lib
drwxr-xr-x   29 alex  wsrc    1.0K Sep 22 00:48 libexec
drwxr-xr-x   13 alex  wsrc    512B Sep 22 00:48 regress
drwxr-xr-x   68 alex  wsrc    1.5K Sep 22 00:48 sbin
drwxr-xr-x   12 alex  wsrc    512B Sep 22 00:48 share
drwxr-xr-x   25 alex  wsrc    512B Sep 22 00:49 sys
drwxr-xr-x  208 alex  wsrc    3.5K Sep 22 00:49 usr.bin
drwxr-xr-x  147 alex  wsrc    2.5K Sep 22 00:49 usr.sbin

All of that source code just waiting to be built. If we take a look inside the bin directory, there might be some familiar names.

$ ls -lah /usr/src/bin
total 136
drwxr-xr-x  32 alex  wsrc   512B Sep 22 00:47 .
drwxrwxr-x  16 root  wsrc   512B Sep 22 00:49 ..
-rw-r--r--   1 alex  wsrc   241B Sep 22 00:47 Makefile
-rw-r--r--   1 alex  wsrc   145B Sep 22 00:47 Makefile.inc
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 cat
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 chio
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 chmod
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 cp
drwxr-xr-x   3 alex  wsrc   1.0K Sep 22 00:47 csh
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 date
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 dd
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 df
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 domainname
drwxr-xr-x   2 alex  wsrc   512B Sep 22 00:47 echo
... and so much more!

A wild cat appears! I can literally use cat to read the code that compiles to make cat (cat /usr/src/bin/cat/cat.c). If you wanted to, you could rewrite cat in anyway you please and rebuild the program. If you feel up to it, you can build an OpenBSD release from source. Alex wrote a great post about doing out-of-tree builds on OpenBSD. It's recommended reading if you're looking for something a little more technical.

There are a lot of other cool things about OpenBSD. They provide full source access, provide an incredibly generous approach to licensing, want to be the most secure operating system, and more.

A few years ago, when I was still doing IT, I took a lot of it for granted. I looked at programming as my way out. I was looking at it from the wrong angle back then. My focus was completing tasks for work. I learned what I needed to to make it through my day.

Today, I'm an explorer. More akin to John Carmack than Jacques Cousteau but you know what I mean. I don't want to be a sys admin, but building from source? Sign me up!