From 9023e950440c08502abf42d7707273ee0d0de0ea Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Mon, 6 Sep 2004 00:00:00 +0200 Subject: stable 2004.09.06 --- scripts/context/perl/mptopdf.pl | 28 +++--- scripts/context/perl/texexec.pl | 2 +- scripts/context/ruby/texsync.rb | 200 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+), 13 deletions(-) create mode 100644 scripts/context/ruby/texsync.rb (limited to 'scripts') diff --git a/scripts/context/perl/mptopdf.pl b/scripts/context/perl/mptopdf.pl index 026d8d80b..0528a4010 100644 --- a/scripts/context/perl/mptopdf.pl +++ b/scripts/context/perl/mptopdf.pl @@ -35,16 +35,16 @@ my $PassOn = '' ; "passon" => \$PassOn, "latex" => \$Latex ) ; -my $program = "MPtoPDF 1.2" ; +my $program = "MPtoPDF 1.3" ; my $pattern = $ARGV[0] ; my $done = 0 ; my $report = '' ; -my $latexswitch = " --tex=latex --format=latex " ; +my $texlatexswitch = " --tex=latex --format=latex " ; +my $mplatexswitch = " --tex=latex " ; -## $dosish = ($Config{'osname'} =~ /dos|mswin/i) ; -my $dosish = ($Config{'osname'} =~ /^(ms)?dos|^os\/2|^(ms|cyg)win/i) ; - -my $miktex = ($ENV{"TEXSYSTEM"} =~ /miktex/io); +my $dosish = ($Config{'osname'} =~ /^(ms)?dos|^os\/2|^(ms|cyg)win/i) ; +my $miktex = ($ENV{"TEXSYSTEM"} =~ /miktex/io); +my $escapeshell = ( ($ENV{'SHELL'}) && ($ENV{'SHELL'} =~ m/sh/i )); my @files ; my $command = my $mpbin = '' ; @@ -67,12 +67,14 @@ elsif ($pattern =~ /\.mp$/io) { if (/(documentstyle|documentclass|begin\{document\})/io) { $Latex = 1 ; last } } close (INP) } - if ($Latex) - { $rest .= " $latexswitch" } if ($RawMP) - { $mpbin = 'mpost' } + { if ($Latex) + { $rest .= " $mplatexswitch" } + $mpbin = 'mpost' } else - { $mpbin = 'texexec --mptex $PassOn' } + { if ($Latex) + { $rest .= " $texlatexswitch" } + $mpbin = 'texexec --mptex $PassOn' } my $error = system ("$mpbin $rest $pattern") ; if ($error) { print "\n$program : error while processing mp file\n" ; exit } @@ -96,8 +98,10 @@ foreach my $file (@files) else { $command = "pdfetex \\&mptopdf" } } else -# { $command = "pdfetex -progname=pdfetex -efmt=mptopdf" } - { $command = "pdfetex -progname=context \&mptopdf" } + { if ($dosish) + { $command = "pdfetex -progname=context &mptopdf" } + else + { $command = "pdfetex -progname=context \\&mptopdf" } } if ($dosish) { system ("$command \\relax $file") } else diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl index 01355b6a6..08d625f51 100644 --- a/scripts/context/perl/texexec.pl +++ b/scripts/context/perl/texexec.pl @@ -33,7 +33,7 @@ eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec perl -w - #D everything. Well, the result is a messy script like this ... Sorry. use strict ; -use warnings ; +#~ use warnings ; # strange warnings, todo # todo: second run of checksum of mp file with --nomprun changes # todo: warning if no args diff --git a/scripts/context/ruby/texsync.rb b/scripts/context/ruby/texsync.rb new file mode 100644 index 000000000..457e13c05 --- /dev/null +++ b/scripts/context/ruby/texsync.rb @@ -0,0 +1,200 @@ +#!/usr/bin/env ruby + +# program : texsync +# copyright : PRAGMA Advanced Document Engineering +# version : 1.1 - 2003/2004 +# author : Hans Hagen + +# For the moment this script only handles the 'minimal' context +# distribution. In due time I will add a few more options, like +# synchronization of the iso image. + +banner = ['TeXSync', 'version 1.1', '2002/2004', 'PRAGMA ADE/POD'] + +unless defined? ownpath + ownpath = $0.sub(/[\\\/]\w*?\.rb/i,'') + $: << ownpath +end + +require 'xmpl/switch' +require 'exa/logger' +require 'rbconfig' + +class Commands + + include CommandBase + + @@formats = ['en','nl','de','cz','it','ro'] + @@always = ['metafun','mptopdf','en','nl'] + @@rsync = 'rsync -r -z -c --progress --stats "--exclude=*.fmt" "--exclude=*.efmt" "--exclude=*.mem"' + + @@kpsewhich = Hash.new + + @@kpsewhich['minimal'] = 'SELFAUTOPARENT' + @@kpsewhich['context'] = 'TEXMFLOCAL' + @@kpsewhich['documentation'] = 'TEXMFLOCAL' + @@kpsewhich['unknown'] = 'SELFAUTOPARENT' + + def update + + report + + return unless destination = getdestination + + texpaths = gettexpaths + address = option('address') + user = option('user') + tree = option('tree') + force = option('force') + + ok = true + begin + report("synchronizing '#{tree}' from '#{address}' to '#{destination}'") + report + if texpaths then + texpaths.each do |path| + report("synchronizing path '#{path}' of '#{tree}' from '#{address}' to '#{destination}'") + command = "#{rsync} #{user}@#{address}::#{tree}/#{path} #{destination}/{path}" + ok = ok && system(command) if force + end + else + command = "#{@@rsync} #{user}@#{address}::#{tree} #{destination}" + ok = system(command) if force + end + rescue + report("error in running rsync") + ok = false + ensure + if force then + if ok then + if option('make') then + report("generating tex and metapost formats") + report + formats.delete_if do |f| + begin + `kpsewhich cont-#{f}`.chomp.empty? + rescue + end + end + str = [@@formats,@@always].flatten.uniq.join(' ') + begin + system("texexec --make --alone #{str}") + rescue + report("unable to generate formats '#{str}'") + else + report + end + else + report("regenerate the formats files if needed") + end + else + report("error in synchronizing '#{tree}'") + end + else + report("provide --force to execute '#{command}'") unless force + end + end + + end + + def list + + report + + address = option('address') + user = option('user') + result = nil + + begin + report("fetching list of trees from '#{address}'") + command = "#{@@rsync} #{user}@#{address}::" + if option('force') then + result = `#{command}`.chomp + else + report("provide --force to execute '#{command}'") + end + rescue + result = nil + else + if result then + report("available trees:") + report + reportlines(result) + end + ensure + report("unable to fetch list") unless result + end + + end + + private + + def gettexpaths + if option('full') then + texpaths = ['texmf','texmf-local','texmf-fonts','texmf-mswin','texmf-linux','texmf-macos'] + elsif option('terse') then + texpaths = ['texmf','texmf-local','texmf-fonts'] + case Config::CONFIG['host_os'] + when /mswin/ then texpaths.push('texmf-mswin') + when /linux/ then texpaths.push('texmf-linux') + when /darwin/ then texpaths.push('texmf-macosx') + end + else + texpaths = nil + end + texpaths + end + + def getdestination + if (destination = option('destination')) && ! destination.empty? then + begin + if @@kpsewhich.key?(destination) then + destination = @@kpsewhich[option('tree')] || @@kpsewhich['unknown'] + destination = `kpsewhich --expand-var=$#{destination}`.chomp + elsif ! FileTest.directory?(destination) then + destination = nil + end + rescue + report("unable to determine destination tex root") + else + if ! destination || destination.empty? then + report("no destination is specified") + elsif not FileTest.directory?(destination) then + report("invalid destination '#{destination}'") + elsif not FileTest.writable?(destination) then + report("destination '#{destination}' is not writable") + else + report("using destination '#{destination}'") + return destination + end + end + else + report("unknown destination") + end + return nil + end + +end + +logger = EXA::ExaLogger.new(banner.shift) +commandline = CommandLine.new + +commandline.registeraction('update', 'update installed tree') +commandline.registeraction('list', 'list available trees') + +commandline.registerflag('terse', 'download as less as possible (esp binaries)') +commandline.registerflag('full', 'download everything (all binaries)') +commandline.registerflag('force', 'confirm action') +commandline.registerflag('make', 'remake formats') + +commandline.registervalue('address', 'www.pragma-ade.com', 'adress of repository (www.pragma-ade)') +commandline.registervalue('user', 'guest', 'user account (guest)') +commandline.registervalue('tree', 'tex', 'tree to synchronize (tex)') +commandline.registervalue('destination', nil, 'destination of tree (kpsewhich)') + +commandline.registeraction('help') +commandline.registeraction('version') + +commandline.expand + +Commands.new(commandline,logger,banner).send(commandline.action || 'help') \ No newline at end of file -- cgit v1.2.3