A jar of Perl: PAR – II : repacking

After reading the previous post on PAR, you may want to unpack, modify and repack an existing PAR application.

Let’s play the game with a ficticious my-perl-webapp.bin

= First: unpack and analyze =

#mkdir /tmp/tmpdir/;
#unzip my-perl-webapp.bin -d /tmp/tmpdir/;
# cd /tmp/tmpdir

In tmpdir we’ll find:
the usual ./script/ directory with all the perl files run by the application;
the main.pl auto-generated by par;
the MANIFEST and META.yml files;
the ./lib/ directory with all the dependencies.

= Second: modify whatever =

Now you have all the perl files and you can modify and fix whatever you want.
Check and test before rebuild!

= Third: repack (simple) =

The first time we’ll try to repack with a simple:

# pp -P -o /tmp/my-perl-webapp-1.bin script/{all .pl files but main.pl } ;

Remember that main.pl is auto-generated by PAR.
When everything is done, check if all the dependencies have been added (ex. confronting package content with unzip -t)

= Fourth: repack (working) =

Repacking may require some more work. The pp command may not notify all the required dependencies you need.
You can check the MANIFEST for a list of files to add to your package.

Add to the package all the files present in the original one. You can do it with

# pp -a lib/file1.pm -a lib/file2.pm … -P -o …

To speed up things we’ll use find:

# find lib -type f -printf ” -a %p ” | \
xargs pp -P \
-o /tmp/my-perl-webapp-1.bin \
script/{all .pl files but main.pl }
-a META.yml

If you don’t remember how find -printf works you can check #man