1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
#!/usr/bin/env perl
#
# tlrepo-from-minimals.pl
# Copyright 2008 Norbert Preining
# Licensed under GPLv2 or higher
BEGIN {
$^W = 1;
chomp ($mydir = `dirname $0`);
unshift (@INC, "$mydir/..");
}
use strict;
use TeXLive::TLConfig;
use TeXLive::TLPSRC;
use TeXLive::TLPOBJ;
use TeXLive::TLPDB;
use TeXLive::TLTREE;
use TeXLive::TLUtils;
use Getopt::Long;
use Pod::Usage;
my %min_to_tl_arch = qw/freebsd i386-freebsd
freebsd-amd64 amd64-freebsd
linux i386-linux
linux-64 x86_64-linux
linux-ppc powerpc-linux
osx-universal universal-darwin
mswin win32
solaris-intel i386-solaris
solaris-sparc sparc-solaris/;
my $help = 0;
my $dist = "current";
my $dest = "web";
my $opt_luatex = 0;
my $opt_modules = 0;
my $opt_context = 0;
my $opt_all = 0;
my $opt_dontclean = 0;
my $source = ".";
my $opt_recreate = 0;
TeXLive::TLUtils::process_logging_options();
GetOptions(
"source=s" => \$source,
"dist=s" => \$dist,
"dest=s" => \$dest,
"luatex" => \$opt_luatex,
"modules" => \$opt_modules,
"context" => \$opt_context,
"all" => \$opt_all,
"dont-clean" => \$opt_dontclean,
"recreate" => \$opt_recreate,
"help|?" => \$help) or pod2usage(1);
pod2usage(-exitstatus => 0, -verbose => 2) if $help;
#
if ($opt_all) {
$opt_luatex = $opt_context = $opt_modules = 1;
}
#
# create a temporary directory for storage of the various files
my $tmp = `mktemp -d`;
chomp($tmp);
info("Using tmp dir $tmp\n");
# copy context files
if ($opt_context) {
info("Copying files for ConTeXt ... ");
system("mkdir -p $tmp/texmf-dist");
system("cp -a $source/$dist/context/current/* $tmp/texmf-dist");
system("mkdir -p $tmp/tlpkg/tlpsrc");
system("cp $source/tlpkg/tlpsrc/context.tlpsrc $tmp/tlpkg/tlpsrc");
system("cp $source/tlpkg/tlpsrc/bin-context.tlpsrc $tmp/tlpkg/tlpsrc");
for my $i (keys %min_to_tl_arch) {
system("mkdir -p $tmp/bin/$min_to_tl_arch{$i}");
system("cp -a $source/$dist/bin/context/$i/bin/* $tmp/bin/$min_to_tl_arch{$i}");
if ($i eq "mswin") {
system("cp -a $tmp/bin/$min_to_tl_arch{$i}/mpost.exe $tmp/bin/$min_to_tl_arch{$i}/metafun.exe");
} else {
system("ln -s mpost $tmp/bin/$min_to_tl_arch{$i}/metafun");
}
# that is needed otherwise the dangling symlink is ignored
system("touch $tmp/bin/$min_to_tl_arch{$i}/mpost");
}
get_from_tug("texmf-dist/tex/mptopdf/config/mptopdf.ini",
"$tmp/texmf-dist/tex/mptopdf/config/mptopdf.ini");
get_from_tug("texmf/fmtutil/format.context.cnf",
"$tmp/texmf/fmtutil/format.context.cnf");
#
# we want to create the .ini files for the used languages. We could
# just copy from tug the files there, but some have been renamed, so
# we create them on the spot.
#
# Copying would be:
#for my $l (qw/cz de en fr it nl ro uk/) {
# get_from_tug("texmf-dist/tex/context/config/cont-$l.ini"
# "$tmp/texmf-dist/tex/context/config/cont-$l.ini");
#}
for my $l (glob "$source/$dist/context/current/tex/context/base/cont-??.tex") {
my $bn = TeXLive::TLUtils::basename($l);
my $ll = $bn;
$ll =~ s/cont-(..)\.tex/$1/;
system('printf \'\\\\input ' . "$bn" . '\n\\\\endinput\n\' > ' . "$tmp/texmf-dist/tex/context/config/cont-$ll.ini");
}
info("done\n");
}
if ($opt_modules) {
info("Copying files for ConTeXt modules ... ");
system("cp -a $source/$dist/modules/all/* $tmp/texmf-dist");
system("mkdir -p $tmp/tlpkg/tlpsrc");
system("cp $source/tlpkg/tlpsrc/context-*.tlpsrc $tmp/tlpkg/tlpsrc");
# we didn't copy the context-letter and context-taspresent because
# they are not present in the context minimals
info("done\n");
}
if ($opt_luatex) {
info("Copying files for luatex ... ");
for my $i (keys %min_to_tl_arch) {
system("mkdir -p $tmp/bin/$min_to_tl_arch{$i}");
system("cp -a $source/$dist/bin/luatex/$i/bin/* $tmp/bin/$min_to_tl_arch{$i}");
if ($i eq "mswin") {
system("cp -a $tmp/bin/$min_to_tl_arch{$i}/luatex.exe $tmp/bin/$min_to_tl_arch{$i}/pdfluatex.exe");
} else {
system("ln -s luatex $tmp/bin/$min_to_tl_arch{$i}/pdfluatex");
}
}
system("mkdir -p $tmp/tlpkg/tlpsrc");
system("cp $source/tlpkg/tlpsrc/luatex.tlpsrc $tmp/tlpkg/tlpsrc");
get_from_tug("texmf/fmtutil/format.luatex.cnf",
"$tmp/texmf/fmtutil/format.luatex.cnf");
info("done\n");
}
# copy the tlpkg stuff
info("Copying files for infrastructure ... ");
get_from_tug("tlpkg/TeXLive", "$tmp/tlpkg/TeXLive");
get_from_tug("tlpkg/bin", "$tmp/tlpkg/bin");
system("cp $source/tlpkg/tlpsrc/00texlive.config.tlpsrc $tmp/tlpkg/tlpsrc");
# should we get that from TUG, too?
get_from_tug("tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc",
"$tmp/tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc");
info("done\n");
# create new tlpdb
info("Creating the texlive.tlpdb ... \n");
system("perl $tmp/tlpkg/bin/tlpsrc2tlpdb -from-files -with-win-pattern-warning -all");
info("done\n");
# get the current texlive.tlpdb from the tug server
get_from_tug("tlpkg/texlive.tlpdb", "$tmp/texlive-dist.tlpdb");
my $tltlpdb = TeXLive::TLPDB->new;
$tltlpdb->from_file("$tmp/texlive-dist.tlpdb");
die("Cannot read original tlpdb from $tmp/texlive-dist.tlpdb") unless defined($tltlpdb);
my $mitlpdb = TeXLive::TLPDB->new(root => "$tmp");
die("Cannot read minimals tlpdb from $tmp/tlpkg/texlive.tlpdb") unless defined($mitlpdb);
for my $p ($mitlpdb->list_packages) {
next if ($p =~ m/^00texlive/);
my $mitlp = $mitlpdb->get_package($p);
die "Cannot get $p from minimals tlpdb" unless defined($mitlp);
my $tltlp = $tltlpdb->get_package($p);
die "Cannot get $p from original tlpdb" unless defined($tltlp);
# fix the revision by adding 1 to the revision as currently shipped by TL
$mitlp->revision($tltlp->revision + 1);
# the following is actually replacing the original tlpobj
$mitlpdb->add_tlpobj($mitlp);
# now make basic comparision of the file lists
my @tlrun = $tltlp->runfiles;
my @mirun = $mitlp->runfiles;
my @diffrun = compare_lists(\@tlrun, \@mirun);
my @tlsrc = $tltlp->srcfiles;
my @misrc = $mitlp->srcfiles;
my @diffsrc = compare_lists(\@tlsrc, \@misrc);
my @tldoc = $tltlp->docfiles;
my @midoc = $mitlp->docfiles;
my @diffdoc = compare_lists(\@tldoc, \@midoc);
my %tlbin = %{$tltlp->binfiles};
my %mibin = %{$mitlp->binfiles};
my @tlbin = ();
my @mibin = ();
for my $a (values %min_to_tl_arch) {
push @tlbin, @{$tlbin{$a}} if defined($tlbin{$a});
push @mibin, @{$mibin{$a}} if defined($mibin{$a});
}
my @diffbin = compare_lists(\@tlbin, \@mibin);
if (@diffrun || @diffbin || @diffdoc || @diffsrc) {
print "\nDifferences for $p found:\n(- removed from texlive for minimals)\n(+ added to minimals (not present in texlive))\n";
print "runfiles:\n" if (@diffrun);
for my $l (@diffrun) {
print "$l\n";
}
print "binfiles:\n" if (@diffbin);
for my $l (@diffbin) {
print "$l\n";
}
print "docfiles:\n" if (@diffdoc);
for my $l (@diffdoc) {
print "$l\n";
}
print "srcfiles:\n" if (@diffsrc);
for my $l (@diffsrc) {
print "$l\n";
}
print "\n";
}
}
$mitlpdb->save;
# create the containers
info("Creating containers ... ");
my $cmd = "perl $tmp/tlpkg/bin/tl-update-containers -location $dest -no-setup";
$cmd .= " -recreate" if $opt_recreate;
system($cmd);
info("done\ņ");
if (!$opt_dontclean) {
info("Cleaning tmp directory (probably dangerous!!!) ... ");
system("rm -rf \"$tmp\"");
info ("done\n");
}
info("Finished!\n");
sub compare_lists {
my ($aref, $bref) = @_;
my @aa = @$aref;
my @bb = @$bref;
my @added = ();
my @removed = ();
my @diff = ();
AA: for my $a (@aa) {
for my $b (@bb) {
next AA if ($a eq $b);
}
# next AA was not called, so it was not found under $b, thus it is removed
push @removed, $a;
}
BB: for my $b (@bb) {
for my $a (@aa) {
next BB if ($a eq $b);
}
# next BB was not called, so it was not found under $a, thus it is added
push @added, $b;
}
for my $a (sort @removed) {
push @diff, "-$a";
}
for my $a (sort @added) {
push @diff, "+$a";
}
return(@diff);
}
sub get_from_tug {
my ($what, $dest) = @_;
my $dn = TeXLive::TLUtils::dirname($dest);
system("mkdir -p $dn");
#system("rsync .... Master/$what $dest");
info("WARNING: we are not actually fetching $what from tug, but copying!\n");
system("cp -a /src/TeX/texlive-svn/Master/$what $dest");
}
### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #
|