Packaging
April 18, 2021 ยท View on GitHub
(Some of) the files have metainformation to allow them to be packaged without including everything in chj-bin and its dependencies (a form of tree shaking / dead code elimination). The metadata is incomplete, patches are welcome.
packaging-get-key file Key allows to
retrieve a metadata key. Example:
# packaging-get-key xlastfile Depends
(lastfile )
# packaging-get-key trigger-listen Tags
(ipc)
The values are lists of symbols in Scheme-compatible S-expression format.
-
Depends: a list of dependencies (excluding Perl modules retrievable viapackaging-perl-getdeps). If a dependency is a plain symbol, then it's the file name inside the local repository. Otherwise it's a list of at least 2 symbols, the package source (a distro, let's minimize it to justdebianif possible?), the package name, then the filenames used from it. -
Tags: a list of symbols. Feel free to invent new ones if necessary.
Dependencies on Perl modules in Perl code are not listed in
Depends. Instead, use packaging-perl-getdeps file(s) to retrieve them.
Algorithm for finding all dependencies
Finding all dependencies for a set of files consists of:
-
for each file, get the value associated with the
Dependsmetadata key (and if not present in the file, add it there, and then please feed back the patch). As mentioned above, thepackaging-get-keyscript can provide this. -
also for each file, check if it's a Perl file (look at the shebang line), if so, extract the Perl level dependencies (
useandrequire). As mentioned above, thepackaging-perl-getdepsscript can provide these. -
recursively, find the dependencies of the files found via the two steps above, too. Careful:
Dependsallows dependency circles (and Perl modules, too, even though that shouldn't happen), thus, avoid recursion on files that have already been processed. -
For each Perl module dependency, find out which package it comes from. You can use
perl-namespace2pathto get the file path corresponding to the namespace, check if it exists inchj-perllib(orfunctional-perl/FunctionalPerlfrom CPAN), if not, check via the system packaging system or CPAN where it can be found. -
Pack up the files from
chj-bin(andchj-perllib, if that is not packaged separately) that are needed, specify a dependency on the other packages needed.
(Partial) usage example:
$ cd /opt/chj/perllib
$ t=$(mktemp)
$ perl-getdeps Chj/Transform/Xml2Sexpr.pm Chj/xtmpfile.pm | perl-namespace2path > "$t"
$ # Modules which are part of chj-perllib:
$ filter $(C test -f _) < "$t" | perl-path2namespace --no-use
Chj::IO::Tempfile
Chj::schemestring
Chj::xtmpfile
$ # Modules which are *not* part of chj-perllib:
$ filter $(C test '!' -f _) < "$t" | perl-path2namespace --no-use
Exporter
XML::LibXML
strict
(Note that strict and Exporter are part of the Perl core.)