#!/usr/bin/env perl # $Id$ # Copyright 2008 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # # Creates a .run file for updating the texlive.infra and bin-texlive packages # comparable to the windows .exe updater BEGIN { $^W = 1; ($mydir = $0) =~ s,/[^/]*$,,; unshift (@INC, "$mydir/.."); } our $mydir; use strict; use TeXLive::TLConfig; use TeXLive::TLUtils; use TeXLive::TLPOBJ; use TeXLive::TLPDB; use Getopt::Long; use Pod::Usage; use File::Path; use Cwd; my $help = 0; TeXLive::TLUtils::process_logging_options(); GetOptions("help|?" => \$help) or pod2usage(1); pod2usage(-exitstatus => 0, -verbose => 2) if $help; exit (&main ()); sub main { # get the db. chomp (my $Master = `cd $mydir/../.. && pwd`); my $tlpdb = TeXLive::TLPDB->new ("root" => $Master); die("Cannot find tlpdb in $Master\n") unless defined($tlpdb); my @packs = (); my $bintexlive = $tlpdb->get_package("bin-texlive"); my $texliveinfra = $tlpdb->get_package("texlive.infra"); push @packs, $bintexlive; push @packs, $texliveinfra; for my $a ($tlpdb->available_architectures) { next if ($a eq "win32"); my $foo = $tlpdb->get_package("bin-texlive.$a"); push @packs, $foo if defined($foo); my $bar = $tlpdb->get_package("texlive.infra.$a"); push @packs, $bar if defined($bar); } my @allfiles = (); for my $p (@packs) { push @allfiles, $p->all_files; } my $tmpdir = `mktemp -d`; chomp($tmpdir); for my $f (@allfiles) { if ($f !~ m!/!) { $f = "./$f"; } my ($dn, $fn) = TeXLive::TLUtils::dirname_and_basename($f); `mkdir -p \"$tmpdir/master/$dn\"`; `cp -a \"$Master/$f\" \"$tmpdir/master/$f\"`; } # get highest rev of all these packages. my $rev = 0; for my $p (@packs) { $rev = $p->revision if $rev > $p->revision; } # we have to create the tlpobj files, too my $tlpobjdir = "$InfraLocation/tlpobj"; if (! -d "$tmpdir/master/$tlpobjdir") { &TeXLive::TLUtils::mkdirhier("$tmpdir/master/$tlpobjdir"); } for my $p (@packs) { open(TMP,">$tmpdir/master/$tlpobjdir/$p->{'name'}.tlpobj") or die "Cannot create $tmpdir/master/$tlpobjdir/$p->{'name'}.tlpobj"; $p->writeout(\*TMP); close(TMP); } open (RUN, ">$tmpdir/runme.sh") or die "Cannot create $tmpdir/runme.sh: $!"; print RUN <<'EOF'; #!/bin/sh # # updater for tlmgr and infrastructure on unix # ROOT=`kpsewhich --var-value=SELFAUTOPARENT` if [ -r "$ROOT/tlpkg/texlive.tlpdb" ] ; then my ./master/bin . cp -a ./master/* "$ROOT/" # now try to get the list of installed architectures by listing the # directories in $ROOT/bin tlpobjs="\"$ROOT/tlpkg/tlpobj/bin-texlive.tlpobj\" \"$ROOT/tlpkg/tlpobj/texlive.infra\"" for a in "$ROOT/bin/*" ; do b=`basename $a` cp -a bin/$b "$ROOT/bin/" tlpobjs="$tlpobjs \"$ROOT/tlpkg/tlpobj/bin-texlive.$b\" \"$ROOT/tlpkg/tlpobj/texlive.infra.$b\"" done else # could be made more intelligent echo "Cannot find root, please call the .run script with --noexec --keep and" echo "then call the runme.sh script in the unpacked directory with the" echo "root as the first argument, i.e., someting like" echo " sh runme.sh /your/path/to/the/texlive/installaton/2008" exit 1 fi echo tlmgr _include_tlpobj $tlpobjs EOF close(RUN); `chmod ugo+x "$tmpdir/runme.sh"`; `makeself "$tmpdir" update-texlive-${rev}.run \"TeX Live Manager Updater ${rev}\" ./runme.sh`; return(0); } __END__ =head1 NAME tl-create-makeself - creates a .run file for bin-texlive and texlive.infra =head1 SYNOPSIS tl-create-makeself [OPTION]... =head1 OPTIONS Only the standard options B<-help> and B<-q>, B<-v>, and B<-logfile>=I are accepted; see the C function in L for details. There should be an option for the destination of the .run file. =head1 DESCRIPTION Creates an updater for Unix systems for the central TeX Live packages using makeself. =head1 AUTHORS AND COPYRIGHT This script and its documentation were written for the TeX Live distribution (L) and both are licensed under the GNU General Public License Version 2 or later. =cut ### Local Variables: ### perl-indent-level: 2 ### tab-width: 2 ### indent-tabs-mode: nil ### End: # vim:set tabstop=2 expandtab: #