I've always wanted to automate my automation. Before that happens, let just automate one more manual task.

patchperl-packing is a project that build a standalone patchperl program containing all dependencies, with fatpacker

The major goal of having such program is to make it quickly available for perlbrew users. Why ? Because various platforms failed to compile the official perl source for various reasons. Some minor patches are required. It would be nice if there are tools to hide such process for developers.

So far perlbrew still requires a system perl newer then 5.8, so the standalone patchperl should contain everything modules that has was not released with perl 5.8. Luckily fatpacker can trace all this easily. And perlbrew itself can be used for keeping a 5.8 installation around.

Here's the automation: https://github.com/gugod/patchperl-packing/blob/master/build.sh

The trick is to do these near the beginning of the script:

eval "$(perlbrew init-in-bash)"
perlbrew use ${perlenv}

The init-in-bash command echo out the bashrc content that is required to initialize the perlbrew shell wrapper. Doing shell scripting is then basically the same as using interactive shell. The perlbrew use command only effect the current shell environment. That would be until the exit of the script, or to the next invocation of use command. This is what's required here.

Also the setting is a perl installation with local lib perl-5.8.8@patchperl-packing. This is prepared manually in advance.

Latter on, major dependencies are installed with cpanm. We always want the latest version of Devel::PatchPerl. That is the purpose of this whole thing.

cpanm Devel::PatchPerl App::FatPacker || exit 1

The rest of the script are are basically invoking fatpacker, and do git commit + push. The git working copy path is also prepared manually.

The deployment is to schedule the script in my personal crontab:

39 * * * * /home/gugod/src/patchperl-packing/build.sh > /tmp/patchperl-packing.log

Notice that the PATH has /apps/perlbrew/bin in the beginning. This is mandatory for bash scripts that wishes to use perlbrew function to dynamically switch between different installations. PERLBREW_ROOT and PERLBREW_HOME are also mandatory. Copy them from an interactive shell should be OK.

There are two commits today ( 1865a3f8bac31109a4acfb22e396b578f0f1af11 and 30b15a4ae8f0786fbd9561c46eb5ea99d7be595e ) that are both generated automatically. This apparently worked as expected.

One more automated task.