Skip to content

Instantly share code, notes, and snippets.

@jmairboeck
Last active August 22, 2021 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmairboeck/df92d13e7179cd22ff15c4d7e809a955 to your computer and use it in GitHub Desktop.
Save jmairboeck/df92d13e7179cd22ff15c4d7e809a955 to your computer and use it in GitHub Desktop.
Haiku texlive packaging scripts
#!/bin/perl
# Helper script to generate the package metadata definitions for the texlive_texmf subpackages
# usage:
# perl -I $sourceDir3 getpackageinfos.pl <tlpdbroot>
#
# <tlpdbroot> is the root of the TeXLive package database, containing tlpkg/texlive.tlpdb.
# It also needs the texmf-dist directory to work.
# After these have been symlinked to $sourceDir (by the fetchTeXLiveInstaller function in the recipe),
# $sourceDir can be used.
#
# This script uses the TeXLive perl modules, therefore it needs $sourceDir3 (the texlive-extra tarball) in @INC.
use strict;
use warnings;
use TeXLive::TLPDB;
my $tlpdb = TeXLive::TLPDB->new(root => $ARGV[0]);
my @collections = $tlpdb->collections();
for my $collectionPkgName (@collections) {
my $collection = substr $collectionPkgName, 11;
my $collectionPkg = $tlpdb->get_package($collectionPkgName);
my $shortdesc = $collectionPkg->shortdesc();
my $longdesc = $collectionPkg->longdesc();
my @depends = $collectionPkg->depends();
my @runfiles;
my @docfiles;
my @srcfiles;
for my $depName (@depends) {
my $depPkg = $tlpdb->get_package($depName);
push @runfiles, $depPkg->runfiles();
push @docfiles, $depPkg->docfiles();
push @srcfiles, $depPkg->srcfiles();
}
if (@runfiles) {
print "SUMMARY_$collection=\"TeXLive Collection: $shortdesc\"\n";
print "DESCRIPTION_$collection=\"$longdesc\"\n" if $longdesc;
print "PROVIDES_$collection=\"\n";
print "\ttexlive_texmf_$collection = \$portVersion\n";
print "\t\"\n";
print "REQUIRES_$collection=\"\n";
print "\thaiku\n";
print "\ttexlive_texmf = \$portVersion base\n";
for my $dep (@depends) {
print "\ttexlive_texmf_", substr($dep, 11), "\n" if rindex($dep, "collection-", 0) == 0;
}
print "\t\"\n";
print "REQUIRES_full+=\"\n";
print "\ttexlive_texmf_$collection\n";
print "\t\"\n";
print "subpackages+=($collection)\n";
}
if (@docfiles) {
print "SUMMARY_${collection}_doc=\"TeXLive Collection: $shortdesc (documentation)\"\n";
print "DESCRIPTION_${collection}_doc=\"$longdesc\"\n" if $longdesc;
print "PROVIDES_${collection}_doc=\"\n";
print "\ttexlive_texmf_${collection}_doc = \$portVersion\n";
print "\t\"\n";
print "REQUIRES_${collection}_doc=\"\n";
print "\thaiku\n";
print "\ttexlive_texmf = \$portVersion base\n";
print "\t\"\n";
print "REQUIRES_full_doc+=\"\n";
print "\ttexlive_texmf_${collection}_doc\n";
print "\t\"\n";
print "subpackages+=(${collection}_doc)\n";
}
if (@srcfiles) {
print "SUMMARY_${collection}_source=\"TeXLive Collection: $shortdesc (source files)\"\n";
print "DESCRIPTION_${collection}_source=\"$longdesc\"\n" if $longdesc;
print "PROVIDES_${collection}_source=\"\n";
print "\ttexlive_texmf_${collection}_source = \$portVersion\n";
print "\t\"\n";
print "REQUIRES_${collection}_source=\"\n";
print "\thaiku\n";
print "\ttexlive_texmf = \$portVersion base\n";
print "\t\"\n";
print "REQUIRES_full_source+=\"\n";
print "\ttexlive_texmf_${collection}_source\n";
print "\t\"\n";
print "subpackages+=(${collection}_source)\n";
}
}
#!/bin/perl
# Helper script to get the packageEntries for texlive_texmf subpackages
# usage:
# perl -I $sourceDir3 printfiles.pl <prefix> <collectionname>
#
# <prefix> is the root of the installation, containing tlpkg/texlive.tlpdb, i.e. $dataDir/texlive
# <collectionname> is the base name of the subpackage without prefix
#
# This script uses the TeXLive perl modules, therefore it needs $sourceDir3 (the texlive-extra tarball) in @INC.
use strict;
use warnings;
use TeXLive::TLPDB;
my $tlpdb = TeXLive::TLPDB->new(root => $ARGV[0]);
my ($collection, $suffix) = split "_", $ARGV[1];
my $tlpkg = $tlpdb->get_package("collection-$collection");
my @depnames = $tlpkg->depends();
foreach my $depname (@depnames) {
my $deppkg = $tlpdb->get_package($depname);
my $filesfield = do {
unless (defined $suffix) { "runfiles" }
elsif ($suffix eq "doc") { "docfiles" }
elsif ($suffix eq "source") { "srcfiles" }
};
my @files = @{$deppkg->{$filesfield}};
foreach my $filename (@files) {
print $ARGV[0], $filename, "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment