Meta(
    title: "Hitchhiker Linux: an origin story",
    summary: Some("I once accidentally built a Linux distro. A few years later, I did it again on purpose"),
    published: Some(Time(
        year: 2022,
        month: 9,
        day: 14,
        hour: 17,
        minute: 34,
        second: 7,
    )),
    tags: [
        "linux",
        "software",
    ],
)
---
Once upon a time, about 2011 to be a little more precise, live was not going my way. My marriage had blown up, my kids were strangers to me and I found myself rather on the far side of sanity. This is not in fact the worst thing that can happen to a man of course because I was still breathing. But I found myself at that time without a job, without a car, and without much in the way of motivation.

One gets bored after a time and finds a way to pass the time. I had left the vast majority of my earthly possessions behind in a storage unit and had at that time no computer. I missed it, however, and found a discarded carcass that I deceided to bring back to life (as one does) with a hard drive but no operating system. Having been a full time Linux and FreeBSD user previously, I wanted a Linux installation. This might be a good time to point out that I also had no internet connection, which combined with not having and operating system to begin with puts a damper on installing Linux. Among what meager possessions I did have with me, however, was an old briefcase with a 512MB pendrive and a CD tucked into a pocket, upon which was written a version of Puppy Linux.

So armed, I started making trips to the local public library in order to use their internet connection and began stuffing as many Slackware packages as possible onto my little 512MB pendrive. I would arrive on foot after a four mile walk (did I mention that I was at the time in the middle of nowhere?), ask to use a computer, and just load it up. So armed, I booted up the computer carcass with the trusty old Puppy Linux CD, formatted the disks to the then shiny ext3 filesystem and extracted each Slackware package individually onto the drive, examining the post install scripts to see if anything further needed done and manually running any needed commands. It took about two weeks to get a full graphical environment this way. And you thought that you had it bad installing from floppy....but I digress.

## The Star Wars connection
Several years prior to this I was at a midnight showing for Revenge of the Sith. Being a huge nerd I showed up early, with all of the other huge nerds. Having the better part of an hour to pass until the movie started I had brought along reading material, in this case a training manual for Red Hat Linux. Being among other fellow nerds it should perhaps not come as a surprise but the enormous bearded guy seated next to me was a Linux enthusiast and wasted no time in telling me that Red Hat was a waste of time. He also just so happened to have a full printed copy of the Linux From Scratch book in his car, which he proceeded to retrieve as a gift for his new friend. We enjoyed the movie and went our separate ways, and after glancing at the book I was intrigued but somewhat intimidated.

Fast forward to my shiny new Slackware installation with it's oh so compelling Fluxbox desktop. I figured in for a penny, what the hell. And so I began making more trips to the library and downloaded the current version of the book along with the required source packages and tarballs. Having nothing if not time on my hands I fired through the book in a day, and then began on Beyond Linux From Scratch. I caught the bug, and was having fun. So much fun that I decided that I would automate everything.

## Enter HitchHiker Linux Mark I
The resulting build system was pretty cool I thought. It wrapped most of the build using a master Makefile and a number of included .mk files such that you could build everything just by entering the source directory and typing `make buildworld`, just like on FreeBSD. Sure, it was kind of brittle, but it worked, and it was way faster than manually typing all of the commands. I even began work on a ports tree, which could quickly get a LAMP server up and running along with a host of other console base utilities. It developed to about the halfway point to a working graphical environment and then stalled, as I had to resume normal life with a job and adult responsibilities again. I saved the work in Git and figured on picking it back up at some later time.

## The SystemD resolvconf incident
It was not long after that when I encountered Arch Linux and began using it in favor of Slackware as my daily driver. It was great in that once configured it just kept running without ever needing a reinstall. I still use Arch on several computers, but there are still a few things that annoy me about Arch. One of them is SystemD. I know that's not an Arch specific thing, and I do see and admit some of the benefits that SystemD brought to the Linux desktop and server. That said, SystemD gave me the impetus to resurrect Hitchhiker. Upon setting up a new system (a Raspberry Pi) with a static IP I began encountering issues with the network. I've been doing this for years, and after double checking I was sure that I had dome it all correctly. But some programs would fail to resolve dns, and some had intermittent issues. When I did finally track the issue down it was due to resolv.conf no longer being the two line file that I had placed there to designate my chosen dns servers, but a symlink to a systemd controlled monstrosity that had replaced my own configuration. I was pissed. Not only does SystemD think that it should have control over this file, it thinks that a convoluted setup involving dnssec should be default. I happen to disagree. My long experience has been that two lines naming a primary and secondary server are ALL. THAT. YOU. EVER. NEED.

Nor was this an isolated thing. I've found that in it's default configuration, SystemD is just way too opinionated. The defaults work great for most people, but the moment that you want to do anything even remotely advanced it throuws up strange roadblocks. After looking around at the various other distros that used a different init system I was unsatisfied. I've since discovered Void Linux, which is excellent, but again I digress.

## HitchHiker Mark II
Thinking that my code was safe turned out to be a mistake. I had chosen Google Code as a platform to keep the original build system while I went off to live my life, back at the time when Google's slogan had been "Do no Evil". While I knew that things had changed in the interim, I was annoyed to discover that my code was all gone. Every project that I had entrusted to Google Code was just gone without a trace. Oh well, I remembered how I had done it once, so I knew how to do it again. More to the point, I knew what didn't work as well as I intended and had a good idea how to fix it.

I went a lot further this time. Linux From Scratch builds a temporary toolchain and environment, chroots into it and uses those tools to build the final system. This is kind of ugly to automate. HitchHiker instead creates a sysroot compiler and then builds the entire base system without having to chroot into it. A number of packages had to be patched. The benefit is that cross compilation is also possible. The system can build from just about any Linux distribution with a functional and relatively modern C compiler, on any architecture, for a number of architectures. It's tested to build correctly for x86_64, x86, aarch64, armv7, and riscv64.

Being a fan of the BSD's I ported a lot of the userland over to Linux. Some came from the Outils project and was ported from OpenBSD already. Some Linux specific utilities came from suckless, and I wrote a fair bit of others in C myself. You get lksh as /bin/sh (the Posix compatible version of the MirBSD Korn shell) and Zsh as a user shell. There are two editors, ee which comes from FreeBSD and heirloom Ex/Vi. So I'm typing this right now using a descendent of the original Unix Vi written by Bill Joy. For a time I was using The One True Awk, but had to replace it with Gawk as there were compatability issues when compiling a lot of third party software. The idea is to have a smallish base system which includes just enough operating system to bootstrap itself from source, upon which you can build whatever you want. The base system has a lot of C code imported directly into it, as is done for BSD, but tracks certain major pieces such as Gcc and Glibc and keeps them up to date. Third party packages are provided via NetBSD pkgsrc. I'm running the Mate desktop right now, with the option of Xfce and a long list of small Window Managers as optional.

Installation is pretty manual. You have to start from a working Linux environment, either making a dual boot or using a live image. You make your partitions, mount them and extract the tarball for the root filesystem. Then either add a Grub configuration entry (for a dual boot) or else install grub. You'll have to edit some config files in /etc and chroot into the system to set a root password. Init is via S6. Once installed, I'm going to be providing a tarball with a bootstrapped version of pkgsrc so that you can just install binary packages using the pkgin package manager from NetBSD. Pkgin works pretty much the same as Apt from a user perspective, so it's not going to seem too foreign for most users. Down the road HitchHiker is going to have it's own ports tree, as there's a lot of stuff that is Linux specific and not included in pkgsrc. I have some of the infrastructure in place for it, but it's not ready for public consumption yet.

I'm also working on a handbook that will guide users through installation and various configuration tasks like setting up the network, and working with the S6 init and supervision suite. It's partway done, but not gauranteed accurate yet as the system keeps evolving.

## When?
I'll be officially putting up the binaries for x86_64 sometime this quarter, followed at some later date with aarch64. I'm looking to get my hands on the next StarV board, after which I'll make it available on RiscV as well. 32-bit can be built for but I'm not going to compile packages for it myself. The source is already available and quite liberally licensed as BeerWare, with third party sources retaining their original licensing of course.

=> https://hitchhiker-linux.org HitchHiker Linux homepage
=> https://git.hitchhiker-linux.org Hitchhiker Linux git repository