diff options
author | Reinhard Kotucha <reinhard.kotucha@web.de> | 2008-01-04 20:31:22 +0000 |
---|---|---|
committer | Reinhard Kotucha <reinhard.kotucha@web.de> | 2008-01-04 20:31:22 +0000 |
commit | d6e6f6fdb53476740b27b79df3e92867bbab9f07 (patch) | |
tree | b99bbc8540b09b2b1923166bd3f5c537ee2ccf71 | |
parent | 1203501a386936b10d99db7bc5496214f421f44e (diff) |
mk_download_pkg: generate tgz/zip files for network installs.
git-svn-id: svn://tug.org/texlive/trunk@6036 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/tlpkg/bin/mk_download_pkg | 219 | ||||
-rw-r--r-- | Master/tlpkg/bin/mk_download_pkg.pl | 43 |
2 files changed, 219 insertions, 43 deletions
diff --git a/Master/tlpkg/bin/mk_download_pkg b/Master/tlpkg/bin/mk_download_pkg new file mode 100755 index 00000000000..49d74653890 --- /dev/null +++ b/Master/tlpkg/bin/mk_download_pkg @@ -0,0 +1,219 @@ +#!/usr/bin/env perl +$^W=1; + +# $Id$ +# mk_download_pkg +# +# Copyright 2008 Reinhard Kotucha +# This file is licensed under the GNU General Public License version 2 +# or any later version. + +# mk_download_pkg.pl is supposed to create the file "install-tl.zip" +# is needed for network downloads. + +BEGIN { + $^W = 1; + my $me=$0; + $thisdir=`pwd`; + chomp ($thisdir); + if ($me=~m!/!) { + ($::installerdir=$me)=~s!(.*)/.*$!$1/../..!; + } else { + $::installerdir='../..'; + } + chdir $installerdir or die "can't chdir \"$installerdir\".\n"; + $installerdir=`pwd`; + chomp ($installerdir); + unshift (@INC, "$::installerdir/tlpkg"); +} + +use TeXLive::TLUtils qw(mkdirhier copy get_system_tmpdir); +use Getopt::Long; +$Getopt::Long::autoabbrev=0; + +$opt_help=0; +$opt_quiet=0; +$opt_outputdir=0; + +sub usage { + print <<'EOF'; +Usage: + mk_download_pkg [-h|--help] [-q|--quiet] -o|--outputdir=dir + + mk_download_pkg generates a .tar.gz file for UNIX and a .zip file + for all systems containing all the files needed to install TeX Live + from the network. + + Options: + -h|--help Print this message. + + -o|--outputdir Target directory. Must exist and be writable. + + -q|--quiet Suppress messages. + +EOF +; + exit 0; +} + +usage if (@ARGV<1); + +GetOptions + "quiet|q", + "outputdir|o=s", + "help|h"; + +usage if ($opt_help); + +### determine directories. + +my $sys_tmp=get_system_tmpdir or die "No system TMPDIR found."; +my $tmpdir="$sys_tmp/install-tl-$$"; +my $inst_tmp="$sys_tmp/install-tl-$$/install-tl"; +my $outputdir="$opt_outputdir"; +$outputdir="$thisdir/$outputdir" unless ($outputdir=~m!^/!); + +### cleanup. + +my @signals=qw(HUP INT ILL FPE SEGV TERM ABRT QUIT BUS PIPE); + +sub cleanup { + if (-d "$tmpdir") { + system('rm', '-rf', "$tmpdir"); + } +} + +foreach my $signal (@signals) { + $SIG{"$signal"}=\&cleanup; +} + +### create directories. + +die "$tmpdir already exists.\n" if (-d "$tmpdir"); + +mkdir "$tmpdir" or die "Can't mkdir \"$tmpdir\".\n"; +mkdir "$inst_tmp" or die "Can't mkdir \"$inst_tmp\".\n"; + +unless ($opt_quiet) { + print "thisdir: \"$thisdir\"\n"; + print "installerdir: \"$installerdir\"\n"; + print "sys_tmp: \"$sys_tmp\"\n"; + print "tmpdir: \"$tmpdir\"\n"; + print "inst_tmp: \"$inst_tmp\"\n"; + print "outputdir: \"$outputdir\"\n"; +} + +die "outputdir \"$outputdir\" dosn't exist.\n" unless (-d "$outputdir"); +die "outputdir \"$outputdir\" is not writable.\n" unless (-w "$outputdir"); + +### save __DATA__ sections. + +while (<DATA>) { + last if /^__W32__/; + next if /^\s+$/; + next if /\s*\#/; + push @unix, $_; +} +chomp (@unix); + +while (<DATA>) { + last if /^__END__/; + next if /^__W32__/; + next if /^\s+$/; + next if /\s*\#/; + push @win32, $_; +} +chomp (@win32); + + +### copy files from the repository to tmpdir + +sub copy_files { + my @files=@_; + my ($dir, $file, $re_file); + + for (@files) { + if (/\/$/) { + open FIND, "find $_ -type f|"; + while (<FIND>) { + chomp ($_); + next if m!/\.svn/!; + ($dir, $file)=/^(.*)\/(.*)/; + mkdirhier "$inst_tmp/$dir"; + copy "$dir/$file", "$inst_tmp/$dir"; + } + close FIND; + } else { + s!^!./!; + ($dir, $file)=/^(.*)\/(.*)/; + $_=$file; + s/\./\\./g; + s/(\*)/\.$1/g; + $re_file=$_; + opendir DIR, "$dir"; + foreach my $file (readdir (DIR)) { + if ("$file" =~ /^$re_file$/) { + mkdirhier "$inst_tmp/$dir"; + copy "$dir/$file", "$inst_tmp/$dir"; + } + } + close DIR; + } + } +} + +### create the .tar.gz and the .zip file + +sub make_zip { + my $type=shift; + chdir "$tmpdir" or die "Can't chdir \"$tmpdir\".\n"; + if ($type eq 'zip') { + system('zip', '-rq', 'install-tl.zip', 'install-tl'); + } else { + system('tar', '-czf', 'install-tl.tar.gz', 'install-tl'); + } + chdir "$installerdir"; +} + +### copy generated files to outputdir + +sub install_zip { + copy "$tmpdir/install-tl.tar.gz", "$outputdir"; + system ('ls', '-l', "$outputdir/install-tl.tar.gz") unless ($opt_qiet); + copy "$tmpdir/install-tl.zip", "$outputdir"; + system ('ls', '-l', "$outputdir/install-tl.zip") unless ($opt_qiet); +} + +### main + +copy_files (@unix); +make_zip 'tgz'; + +copy_files (@win32); +make_zip 'zip'; + +install_zip; + +cleanup; + +__DATA__ +# common files: +install_tl.pl +install_tl.html +tlpkg/TeXLive/ +tlpkg/bin/lzma* +__W32__ +# extra files for Windows: +install_tl.bat +tlpkg/bin/wget.exe +tlpkg/bin/*tar* +tlpkg/bin/perl* +tlpkg/lib/Perl5_lib-TL_inst/ +__END__ + +### Local Variables: +### perl-indent-level: 2 +### tab-width: 2 +### indent-tabs-mode: nil +### End: +# vim:set tabstop=2 expandtab: # diff --git a/Master/tlpkg/bin/mk_download_pkg.pl b/Master/tlpkg/bin/mk_download_pkg.pl deleted file mode 100644 index 69a8cbe09f6..00000000000 --- a/Master/tlpkg/bin/mk_download_pkg.pl +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env perl -$^W=1; - -# $Id: $ -# mk_download_pkg.pl -# -# Copyright 2008 Reinhard Kotucha -# This file is licensed under the GNU General Public License version 2 -# or any later version. - -# mk_download_pkg.pl is supposed to create the file "install-tl.zip" -# is needed for network downloads. Currently it doesn't do anything -# useful but it converts wildcards to regular expressions. - -while (<DATA>) { - next if /^\s+$/; - next if /\s*\#/; - chomp ($_); - if (/\/$/) { - print "$_ is a directory.\n"; - } else { - ($dir, $file)=/^(.*)\/(.*)/; - $_=$file; - s/\./\\./g; - s/(\*)/\.$1/g; - $re_file=$_; - } - - opendir DIR, "$dir"; - foreach my $f (readdir (DIR)) { - if ("$f" =~ /^$re_file$/) { - print "$dir/$f\n"; - } - } - close DIR; -} - -__DATA__ -tlpkg/bin/lzma*.* -tlpkg/bin/*tar* -tlpkg/bin/perl* -tlpkg/bin/wget.exe -tlpkg/lib/ |