texlive: split the package into multiple subpackages (#6229)

* texlive: split texlive_texmf into multiple subpackages (per collection)

There is one package for the runtime files, documentation and source files
for each TeXLive collection each. Packages that would be empty are omitted.
Additionaly, there are '_full' metapackages that depend on all the others.

The subpackage metadata and packageEntries are generated using perl scripts
that use the TeXLive package database API.

The package metadata is pre-generated because it needs already extracted and
preprocessed sources.

* texlive: fixes

 * change package descriptions to not contain the prefix "TeXLive" which is not allowed, being the package name
 * apply the $portDir workaround also for the PATCH function (see haikuporter issue #168)

* add missing config file to GLOBAL_WRITABLE_FILES

* remove the waiting on texlive's post-install scripts because it is not needed

* texlive: remove the alternate version of the createSubpackageInfos script

* texlive: add license header to the perl helper scripts
This commit is contained in:
Joachim Mairböck
2022-03-26 17:55:40 +01:00
committed by GitHub
parent 4b902ee6dc
commit 1801479c90
6 changed files with 1798 additions and 32 deletions

View File

@@ -0,0 +1,100 @@
#!/bin/perl
# Copyright 2021, Joachim Mairböck <j.mairboeck@gmail.com>
# Distributed under the terms of the MIT license.
# Helper script to generate the package metadata definitions for the texlive subpackages
# usage:
# perl -I $sourceDir/tlpkg createSubpackageInfos.pl <tlpdbroot> > subpackageInfos.recipe
#
# <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 BUILD function in the recipe),
# $sourceDir can be used inside the haikuporter chroot.
# Alternatively, after the installation of the texlive package,
# /boot/system/data/texlive can be used.
#
# This script uses the TeXLive perl modules, therefore it needs $sourceDir/tlpkg in @INC.
use strict;
use warnings;
use TeXLive::TLPDB;
print "# This file has been generated by createSubpackageInfos.pl\n\n";
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();
if (length $shortdesc >= 48) { # SUMMARY must not exceed 80 characters in total
$shortdesc = substr($shortdesc, 0, 46) . "…";
}
if ($shortdesc =~ /\.$/) { # SUMMARY must not end in a '.'
$shortdesc = substr($shortdesc, 0, -1);
}
$shortdesc =~ s'`'\`'g; # escape '`' characters
$longdesc =~ s'`'\`'g if $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=\"TeX Collection: $shortdesc\"\n";
print "DESCRIPTION_$collection=\"$longdesc\"\n" if $longdesc;
print "PROVIDES_$collection=\"\n";
print "\ttexlive_$collection = \$portVersion\n";
print "\t\"\n";
print "REQUIRES_$collection=\"\n";
print "\thaiku\n";
print "\ttexlive == \$portVersion base\n";
for my $dep (@depends) {
print "\ttexlive_", substr($dep, 11), "\n" if $dep =~ /^collection-/;
}
print "\t\"\n";
print "REQUIRES_full+=\"\n";
print "\ttexlive_$collection\n";
print "\t\"\n";
print "POST_INSTALL_SCRIPTS_$collection=\"\$relativePostInstallDir/texlive_postinstall.sh\"\n";
print "subpackages+=($collection)\n";
}
if (@docfiles) {
print "SUMMARY_${collection}_doc=\"TeX Collection: $shortdesc (documentation)\"\n";
print "DESCRIPTION_${collection}_doc=\"$longdesc\"\n" if $longdesc;
print "PROVIDES_${collection}_doc=\"\n";
print "\ttexlive_${collection}_doc = \$portVersion\n";
print "\t\"\n";
print "REQUIRES_${collection}_doc=\"\n";
print "\thaiku\n";
print "\ttexlive == \$portVersion base\n";
print "\t\"\n";
print "REQUIRES_full_doc+=\"\n";
print "\ttexlive_${collection}_doc\n";
print "\t\"\n";
print "subpackages+=(${collection}_doc)\n";
}
if (@srcfiles) {
print "SUMMARY_${collection}_source=\"TeX Collection: $shortdesc (source files)\"\n";
print "DESCRIPTION_${collection}_source=\"$longdesc\"\n" if $longdesc;
print "PROVIDES_${collection}_source=\"\n";
print "\ttexlive_${collection}_source = \$portVersion\n";
print "\t\"\n";
print "REQUIRES_${collection}_source=\"\n";
print "\thaiku\n";
print "\ttexlive == \$portVersion base\n";
print "\t\"\n";
print "REQUIRES_full_source+=\"\n";
print "\ttexlive_${collection}_source\n";
print "\t\"\n";
print "subpackages+=(${collection}_source)\n";
}
}

View File

@@ -0,0 +1,36 @@
#!/bin/perl
# Copyright 2021, Joachim Mairböck <j.mairboeck@gmail.com>
# Distributed under the terms of the MIT license.
# Helper script to get the packageEntries for texlive subpackages
# usage:
# perl -I $sourceDir/tlpkg getPackageEntries.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 $sourceDir/tlpkg 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) {
my $path = $ARGV[0] . $filename;
print $path, "\n" if -e $path; # ignore missing files
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
#!/bin/bash
fmtutil-sys --all
#mtxrun --generate
updmap-sys
processList=$(ps)
processCount=$(grep texlive_update.sh <<< "$processList" | wc -l)
if [ $processCount -eq 0 ]; then # if no texlive_update is running yet, run it
/boot/system/bin/texlive_update.sh &
fi

View File

@@ -0,0 +1,7 @@
#!/bin/bash
mktexlsr
fmtutil-sys --all
#mtxrun --generate
updmap-sys

View File

@@ -18,16 +18,20 @@ SOURCE_DIR="install-tl-20210324"
SOURCE_DIR_2="texlive-$fullVersion-texmf"
SOURCE_DIR_3="texlive-$fullVersion-extra"
ADDITIONAL_FILES="
createSubpackageInfos.pl
getPackageEntries.pl
subpackageInfos.recipe
texlive.profile
texlive_postinstall.sh
texlive_update.sh
"
POST_INSTALL_SCRIPTS="$relativePostInstallDir/texlive_postinstall.sh"
ARCHITECTURES="?any"
DISABLE_SOURCE_PACKAGE="yes"
PROVIDES="
texlive = $portVersion
cmd:texlive_update.sh
"
REQUIRES="
haiku
@@ -35,13 +39,36 @@ REQUIRES="
cmd:kpsewhich
"
PROVIDES_doc="
texlive_doc = $portVersion
SUMMARY_full="Metapackage for all TeXLive collections"
PROVIDES_full="
texlive_full = $portVersion
"
REQUIRES_doc="
cmd:kpsewhich
SUMMARY_full_doc="Metapackage for all TeXLive collections (documentation)"
PROVIDES_full_doc="
texlive_full_doc = $portVersion
"
SUMMARY_full_source="Metapackage for all TeXLive collections (source files)"
PROVIDES_full_source="
texlive_full_source = $portVersion
"
declare -a subpackages
# workaround for $portDir not being set correctly (or being empty)
# $workDir is not set when parsing recipes or during the PATCH function (outside the chroot), so use $portBaseDir instead.
# $portBaseDir can't be used when building the recipe because it points outside the chroot.
# In this case the (empty) $portDir is okay though.
if [ "${workDir-unset}" = unset -o "$recipeAction" = PATCH ]; then
portDir=$portBaseDir
fi
# note: this doesn't work (would need extracted and prepared sources already, after the BUILD function)
# $(perl -I $sourceDir/tlpkg $portDir/additional-files/createSubpackageInfos.pl $sourceDir)
# source the pregenerated subpackage infos instead
source $portDir/additional-files/subpackageInfos.recipe
BUILD_REQUIRES="
haiku_devel
cmd:kpsewhich
@@ -52,6 +79,7 @@ BUILD_PREREQUIRES="
GLOBAL_WRITABLE_FILES="
settings/texlive/ls-R auto-merge
var/texlive/fonts/conf/texlive-fontconfig.conf auto-merge
var/texlive/ls-R auto-merge
var/texlive/tex/generic/config/language.dat auto-merge
var/texlive/tex/generic/config/language.dat.lua auto-merge
@@ -166,7 +194,13 @@ GLOBAL_WRITABLE_FILES="
var/texlive/web2c/xetex/xetex.log
"
fetchTexLiveInstaller()
PATCH() {
sed -i "s|\`kpsewhich -var-value=SELFAUTOPARENT\`|\"$dataDir/texlive\"|" $sourceDir/tlpkg/TeXLive/TLUtils.pm
sed -i "s|\`kpsewhich -var-value=FC_CACHEDIR\`|\"$sharedStateDir/texlive/fonts/cache\"|" $sourceDir3/tlpkg/tlpostcode/xetex.pl
sed -i "s|\`kpsewhich -var-value=FONTCONFIG_PATH\`|\"$sharedStateDir/texlive/fonts/conf\"|" $sourceDir3/tlpkg/tlpostcode/xetex.pl
}
BUILD()
{
# Put the texmf-dist into the correct location
rm -rv texmf-dist || true
@@ -176,14 +210,14 @@ fetchTexLiveInstaller()
if [ $targetArchitecture = x86_gcc2 ] || [ $targetArchitecture = x86 ]; then
if [ ! -e bin/i386-haiku ] ; then
mkdir -p bin
ln -s /boot/system/bin bin/i386-haiku
mkdir -pv bin
ln -sv /boot/system/bin bin/i386-haiku
fi
else
if [ ! -e bin/${targetArchitecture}-haiku ] ; then
mkdir -p bin
ln -s /boot/system/bin bin/${targetArchitecture}-haiku
mkdir -pv bin
ln -sv /boot/system/bin bin/${targetArchitecture}-haiku
fi
fi
@@ -194,15 +228,8 @@ fetchTexLiveInstaller()
cp -v $sourceDir3/{README{,.usergroups},{index,doc}.html} .
}
PATCH() {
sed -i "s|\`kpsewhich -var-value=SELFAUTOPARENT\`|\"$dataDir/texlive\"|" $sourceDir/tlpkg/TeXLive/TLUtils.pm
sed -i "s|\`kpsewhich -var-value=FC_CACHEDIR\`|\"$sharedStateDir/texlive/fonts/cache\"|" $sourceDir3/tlpkg/tlpostcode/xetex.pl
sed -i "s|\`kpsewhich -var-value=FONTCONFIG_PATH\`|\"$sharedStateDir/texlive/fonts/conf\"|" $sourceDir3/tlpkg/tlpostcode/xetex.pl
}
INSTALL()
{
fetchTexLiveInstaller
export TEXLIVE_INSTALL_PREFIX=$dataDir/texlive
export TEXLIVE_INSTALL_TEXMFSYSVAR=$sharedStateDir/texlive
export TEXLIVE_INSTALL_TEXMFSYSCONFIG=$sysconfDir/texlive
@@ -230,18 +257,18 @@ INSTALL()
# replace it with the known working version from the main texlive_core package
cp -f /boot/system/data/texmf-dist/web2c/texmf.cnf $dataDir/texlive/texmf-dist/web2c/texmf.cnf
# remove useless libtool files and other unneeded files
rm -f $libDir/*.la
rm -rf $dataDir/texlive/bin
rm -f $dataDir/texlive/install-tl*
mkdir -p $postInstallDir
install -t $postInstallDir -m 755 $portDir/additional-files/texlive_postinstall.sh
mkdir -p $binDir
install -t $binDir -m 755 $portDir/additional-files/texlive_update.sh
# texmf_doc package
packageEntries doc \
$dataDir/texlive/texmf-dist/doc
# exit 1
for subpackage in ${subpackages[@]}; do
packageEntries $subpackage \
$(perl -I $sourceDir/tlpkg $portDir/additional-files/getPackageEntries.pl $dataDir/texlive/ $subpackage)
if [[ $subpackage != *_* ]]; then # ignore subpackages with a suffix (doc or source)
mkdir -p $(getPackagePrefix $subpackage)/$relativePostInstallDir
install -t $(getPackagePrefix $subpackage)/$relativePostInstallDir \
-m 755 $portDir/additional-files/texlive_postinstall.sh
fi
done
}