mobundle

TL;DR

It seems that I didnt’ write about mobundle.

After posting csv2json some days ago, I received an email from a reader asking about MOBUNDLE.

The reader sifted through the bundled version of the program, which is sort-of fatpacked, but not quite. In fact, it has stuff like this at the beginning:


# __MOBUNDLE_INCLUSION__
BEGIN {
   my %file_for = (
# __MOBUNDLE_FILES__


# __MOBUNDLE_FILE__

      'Text/CSV_PP.pm' => <<'END_OF_FILE',
 package Text::CSV_PP;
...

So the reader asked… what gives? What’s this mobundle thing?

I thought I has already written about it, maybe in a previous version of the blog, but I don’t seem to be able to find it. So here we go… maybe again.

Before fatpack was a thing, a lot of years ago, I needed that kind of functionality to produce bundles. This started within the context of producing self-installing executables for software I had to put in difficult-to-reach places (you can read something about it in Parachuting Whatever, from the old blog).

From deployable I eventually decided to extract mobundle, which serves a purpose quite totally overalapping with fatpack. Alas, it did not have the fortune and following of fatpack, so I started to lean on the latter, mainly for maintenance reasons; every so often, though, I still revert to it, because it works quite well for my use cases.

I’d say that it implements the 80% of fatpack that fulfils 99% of my needs.

It has an --autoscan option to be lazy, but what I like most is the possibility to tell it exactly what modules should be included. It might seem counter-intuitive and also brittle, but in my case the modules that I want to bundle are mainly my own (like Template::Perlish, or Log::Log4perl::Tiny) and I know beforehand what I need exactly. So… no big deal.

When my program starts like this (note that empty line before the non-CORE modules):

#!/usr/bin/env perl
use v5.24;
use warnings;
use experimental 'signatures';
no warnings 'experimental::signatures';
use English '-no_match_vars';

use Log::Log4perl::Tiny;
use Template::Perlish;
...

I can use mobundle and ask it to keep the first paragraph at the beginning, then insert exactly the modules that I want, then keep the rest of the program as is:

mobundle --head-from-paragraph \
    --module Template::Perlish \
    --module Log::Log4perl::Tiny \
    --output my-program.bundle.pl \
    my-program.pl

or, more concisely:

mobundle -Pm Template::Perlish -m Log::Log4perl::Tiny \
    -o my-program.bundle.pl my-program.pl

It comes with a manual page (which can be asked with --man) and some --help… but no warranty nor applicability for a specific purpose!

Stay safe and bundled!


Comments? Octodon, , GitHub, Reddit, or drop me a line!