Re: Anyone wants to program some perl?
On Sat, Mar 10, 2012 at 03:27:57PM +0900, Norbert Preining wrote:
> Hi everyone,
>
> if you want to get involved with Debian and TeX Live packaging
> and programming, here is a first idea:
>
> target: write a perl function that takes a TeX Live package name and
> a root directory as input, and generates a list of collapsed
> directories and files for that pacakge.
I think the attached is a good first stab at the job. It can handle
multiple packages as well as individual packages.
Julian
#! /usr/bin/perl -w
# Generate list of files/directories for a list of texlive packages
# Copyright 2012 Julian Gilbey
# Some of this code is based on code by Norbert Preining and Frank Küster
# This file is licensed under the GNU General Public License version 2
# or any later version.
# Usage: gen-pkg-filelist.pl TLPROOTDIR TEXMFDIR pkg ...
# TLPROOTDIR is the directory *containing* the tlpkg directory
# TEXMFDIR is the texmf-dist directory
my ($texdir, $tlroot);
BEGIN {
$^W = 1;
$tlprootdir = shift @ARGV;
$texmfdir = shift @ARGV;
# make Perl find our packages first:
unshift (@INC, "$tlprootdir/tlpkg");
}
use TeXLive::TLUtils qw(collapse_dirs);
use TeXLive::TLPDB;
use TeXLive::TLConfig;
my $tlpdb = TeXLive::TLPDB->new (root => $tlprootdir);
if (! defined $tlpdb) { die "Couldn't load the texlive database!\n"; }
my @filelist;
my %licenses;
for my $pkg (@ARGV) {
my $tlp = $tlpdb->get_package($pkg);
push @filelist, $tlp->runfiles;
push @filelist, $tlp->docfiles;
$licenses{$pkg} = exists $tlp->cataloguedata->{'license'} ?
$tlp->cataloguedata->{'license'} : "";
}
for my $pkg (sort keys %licenses) {
print "$pkg: $licenses{$pkg}\n";
}
for (@filelist) { s%^$RelocPrefix/%%; }
chdir $texmfdir or die "Can't chdir to $texmfdir: $!";
@files_dirs = collapse_dirs(@filelist);
for (@files_dirs) {
if (-d $_) { print "$_/*\n"; }
else { print "$_\n"; }
}
### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #
Reply to: