summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
committerKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
commit824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch)
treeabfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/scripts/context/ruby
parent689aefb0727676ed3cddf331337b4be226495e72 (diff)
context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip
git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby')
-rw-r--r--Master/texmf-dist/scripts/context/ruby/base/logger.rb3
-rw-r--r--Master/texmf-dist/scripts/context/ruby/base/tex.rb3
-rw-r--r--Master/texmf-dist/scripts/context/ruby/fcd_start.rb472
-rw-r--r--Master/texmf-dist/scripts/context/ruby/mpstools.rb7
-rw-r--r--Master/texmf-dist/scripts/context/ruby/texexec.rb2
-rw-r--r--Master/texmf-dist/scripts/context/ruby/texsync.rb206
6 files changed, 5 insertions, 688 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/base/logger.rb b/Master/texmf-dist/scripts/context/ruby/base/logger.rb
index 2526cdb0e25..2245ab331f0 100644
--- a/Master/texmf-dist/scripts/context/ruby/base/logger.rb
+++ b/Master/texmf-dist/scripts/context/ruby/base/logger.rb
@@ -47,7 +47,8 @@ class Logger
print("\n")
return true
when 1
- message = str.first
+ # message = str.first
+ message = str.first.join(' ')
else
message = [str].flatten.collect{|s| s.to_s}.join(' ').chomp
end
diff --git a/Master/texmf-dist/scripts/context/ruby/base/tex.rb b/Master/texmf-dist/scripts/context/ruby/base/tex.rb
index 8f56839851c..9ba842501ea 100644
--- a/Master/texmf-dist/scripts/context/ruby/base/tex.rb
+++ b/Master/texmf-dist/scripts/context/ruby/base/tex.rb
@@ -362,7 +362,8 @@ class TEX
def mpsformats() @@mpsformats.keys.sort end
def defaulttexformats() ['en','nl','mptopdf'] end
- def defaultmpsformats() ['metafun'] end
+ # def defaultmpsformats() ['metafun'] end # no longer formats
+ def defaultmpsformats() [] end
def texmakeextras(format) @@texmakestr[format] || '' end
def mpsmakeextras(format) @@mpsmakestr[format] || '' end
diff --git a/Master/texmf-dist/scripts/context/ruby/fcd_start.rb b/Master/texmf-dist/scripts/context/ruby/fcd_start.rb
deleted file mode 100644
index 3d04754fac9..00000000000
--- a/Master/texmf-dist/scripts/context/ruby/fcd_start.rb
+++ /dev/null
@@ -1,472 +0,0 @@
-# Hans Hagen / PRAGMA ADE / 2005 / www.pragma-ade.com
-#
-# Fast Change Dir
-#
-# This is a kind of variant of the good old ncd
-# program. This script uses the same indirect cmd
-# trick as Erwin Waterlander's wcd program.
-#
-# === windows: fcd.cmd ===
-#
-# @echo off
-# ruby -S fcd_start.rb %1 %2 %3 %4 %5 %6 %7 %8 %9
-# if exist "%HOME%/fcd_stage.cmd" call %HOME%/fcd_stage.cmd
-#
-# === linux: fcd (fcd.sh) ===
-#
-# !/usr/bin/env sh
-# ruby -S fcd_start.rb $1 $2 $3 $4 $5 $6 $7 $8 $9
-# if test -f "$HOME/fcd_stage.sh" ; then
-# . $HOME/fcd_stage.sh ;
-# fi;
-#
-# ===
-#
-# On linux, one should source the file: ". fcd args" in order
-# to make the chdir persistent.
-#
-# You can create a stub with:
-#
-# ruby fcd_start.rb --stub --verbose
-#
-# usage:
-#
-# fcd --make t:\
-# fcd --add f:\project
-# fcd [--find] whatever
-# fcd [--find] whatever c (c being a list entry)
-# fcd [--find] whatever . (last choice with this pattern)
-# fcd --list
-
-# todo: HOMEDRIVE\HOMEPATH
-
-require 'rbconfig'
-
-class FastCD
-
- @@rootpath = nil
-
- ['HOME','TEMP','TMP','TMPDIR'].each do |key|
- if ENV[key] then
- if FileTest.directory?(ENV[key]) then
- @@rootpath = ENV[key]
- break
- end
- end
- end
-
- exit unless @@rootpath
-
- @@mswindows = RbConfig::CONFIG['host_os'] =~ /mswin/
- @@maxlength = 26
-
- require 'Win32API' if @@mswindows
-
- if @@mswindows then
- @@stubcode = [
- '@echo off',
- '',
- 'if not exist "%HOME%" goto temp',
- '',
- ':home',
- '',
- 'ruby -S fcd_start.rb %1 %2 %3 %4 %5 %6 %7 %8 %9',
- '',
- 'if exist "%HOME%\fcd_stage.cmd" call %HOME%\fcd_stage.cmd',
- 'goto end',
- '',
- ':temp',
- '',
- 'ruby -S fcd_start.rb %1 %2 %3 %4 %5 %6 %7 %8 %9',
- '',
- 'if exist "%TEMP%\fcd_stage.cmd" call %TEMP%\fcd_stage.cmd',
- 'goto end',
- '',
- ':end'
- ].join("\n")
- else
- @@stubcode = [
- '#!/usr/bin/env sh',
- '',
- 'ruby -S fcd_start.rb $1 $2 $3 $4 $5 $6 $7 $8 $9',
- '',
- 'if test -f "$HOME/fcd_stage.sh" ; then',
- ' . $HOME/fcd_stage.sh ;',
- 'fi;'
- ].join("\n")
- end
-
- @@selfpath = File.dirname($0)
- @@datafile = File.join(@@rootpath,'fcd_state.dat')
- @@histfile = File.join(@@rootpath,'fcd_state.his')
- @@cdirfile = File.join(@@rootpath,if @@mswindows then 'fcd_stage.cmd' else 'fcd_stage.sh' end)
- @@stubfile = File.join(@@selfpath,if @@mswindows then 'fcd.cmd' else 'fcd' end)
-
- def initialize(verbose=false)
- @list = Array.new
- @hist = Hash.new
- @result = Array.new
- @pattern = ''
- @result = ''
- @verbose = verbose
- if f = File.open(@@cdirfile,'w') then
- f << "#{if @@mswindows then 'rem' else '#' end} no dir to change to"
- f.close
- else
- report("unable to create stub #{@@cdirfile}")
- end
- end
-
- def filename(name)
- File.join(@@root,name)
- end
-
- def report(str,verbose=@verbose)
- puts(">> #{str}") if verbose
- end
-
- def flush(str,verbose=@verbose)
- print(str) if verbose
- end
-
- def clear
- if FileTest.file?(@@histfile)
- begin
- File.delete(@@histfile)
- rescue
- report("error in deleting history file '#{@histfile}'")
- else
- report("history file '#{@histfile}' is deleted")
- end
- else
- report("no history file '#{@histfile}'")
- end
- end
-
- def scan(dir='.')
- begin
- [dir].flatten.sort.uniq.each do |dir|
- begin
- Dir.chdir(dir)
- report("scanning '#{dir}'")
- # flush(">> ")
- Dir.glob("**/*").each do |d|
- if FileTest.directory?(d) then
- @list << File.expand_path(d)
- # flush(".")
- end
- end
- # flush("\n")
- @list = @list.sort.uniq
- report("#{@list.size} entries found")
- rescue
- report("unknown directory '#{dir}'")
- end
- end
- rescue
- report("invalid dir specification ")
- end
- end
-
- def save
- begin
- if f = File.open(@@datafile,'w') then
- @list.each do |l|
- f.puts(l)
- end
- f.close
- report("#{@list.size} status bytes saved in #{@@datafile}")
- else
- report("unable to save status in #{@@datafile}")
- end
- rescue
- report("error in saving status in #{@@datafile}")
- end
- end
-
- def remember
- if @hist[@pattern] == @result then
- # no need to save result
- else
- begin
- if f = File.open(@@histfile,'w') then
- @hist[@pattern] = @result
- @hist.keys.each do |k|
- f.puts("#{k} #{@hist[k]}")
- end
- f.close
- report("#{@hist.size} history entries saved in #{@@histfile}")
- else
- report("unable to save history in #{@@histfile}")
- end
- rescue
- report("error in saving history in #{@@histfile}")
- end
- end
- end
-
- def load
- begin
- @list = IO.read(@@datafile).split("\n")
- report("#{@list.length} status bytes loaded from #{@@datafile}")
- rescue
- report("error in loading status from #{@@datafile}")
- end
- begin
- IO.readlines(@@histfile).each do |line|
- if line =~ /^(.*?)\s+(.*)$/i then
- @hist[$1] = $2
- end
- end
- report("#{@hist.length} history entries loaded from #{@@histfile}")
- rescue
- report("error in loading history from #{@@histfile}")
- end
- end
-
- def show
- begin
- puts("directories:")
- puts("\n")
- if @list.length > 0 then
- @list.each do |l|
- puts(l)
- end
- else
- puts("no entries")
- end
- puts("\n")
- puts("history:")
- puts("\n")
- if @hist.length > 0 then
- @hist.keys.sort.each do |h|
- puts("#{h} >> #{@hist[h]}")
- end
- else
- puts("no entries")
- end
- rescue
- end
- end
-
- def find(pattern=nil)
- begin
- if pattern = [pattern].flatten.first then
- if pattern.length > 0 and @pattern = pattern then
- @result = @list.grep(/\/#{@pattern}$/i)
- if @result.length == 0 then
- @result = @list.grep(/\/#{@pattern}[^\/]*$/i)
- end
- end
- else
- puts(Dir.pwd.gsub(/\\/o, '/'))
- end
- rescue
- puts("some error")
- end
- end
-
- def chdir(dir)
- begin
- if dir then
- if f = File.open(@@cdirfile,'w') then
- if @@mswindows then
- f.puts("cd /d #{dir.gsub('/','\\')}")
- else
- f.puts("cd #{dir.gsub("\\",'/')}")
- end
- f.close
- end
- @result = dir
- report("changing to #{dir}",true)
- else
- report("not changing dir")
- end
- rescue
- end
- end
-
- def choose(args=[])
- offset = 97
- unless @pattern.empty? then
- begin
- case @result.size
- when 0 then
- report("dir '#{@pattern}' not found",true)
- when 1 then
- chdir(@result[0])
- else
- list = @result.dup
- begin
- if answer = args[1] then # assignment & test
- if answer == '.' and @hist.key?(@pattern) then
- if FileTest.directory?(@hist[@pattern]) then
- print("last choice ")
- chdir(@hist[@pattern])
- return
- end
- else
- index = answer[0] - offset
- if dir = list[index] then
- chdir(dir)
- return
- end
- end
- end
- rescue
- puts("some error")
- end
- loop do
- print("\n")
- list.each_index do |i|
-begin
- if i < @@maxlength then
- # puts("#{(i+?a).chr} #{list[i]}")
- puts("#{(i+offset).chr} #{list[i]}")
- else
- puts("\n there are #{list.length-@@maxlength} entries more")
- break
- end
-rescue
- puts("some error")
-end
- end
- print("\n>> ")
- if answer = wait then
- if answer >= offset and answer <= offset+25 then
- index = answer - offset
- if dir = list[index] then
- print("#{answer.chr} ")
- chdir(dir)
- elsif @hist.key?(@pattern) and FileTest.directory?(@hist[@pattern]) then
- print("last choice ")
- chdir(@hist[@pattern])
- else
- print("quit\n")
- end
- break
- elsif list.length >= @@maxlength then
- @@maxlength.times do |i| list.shift end
- print("next set")
- print("\n")
- elsif @hist.key?(@pattern) and FileTest.directory?(@hist[@pattern]) then
- print("last choice ")
- chdir(@hist[@pattern])
- break
- else
- print("quit\n")
- break
- end
- end
- end
- end
- rescue
- report($!)
- end
- end
- end
-
- def wait
- begin
- $stdout.flush
- return getc
- rescue
- return nil
- end
- end
-
- def getc
- begin
- if @@mswindows then
- ch = Win32API.new('crtdll','_getch',[],'L').call
- else
- system('stty raw -echo')
- ch = $stdin.getc
- system('stty -raw echo')
- end
- rescue
- ch = nil
- end
- return ch
- end
-
- def check
- unless FileTest.file?(@@stubfile) then
- report("creating stub #{@@stubfile}")
- begin
- if f = File.open(@@stubfile,'w') then
- f.puts(@@stubcode)
- f.close
- end
- rescue
- report("unable to create stub #{@@stubfile}")
- else
- unless @mswindows then
- begin
- File.chmod(0755,@@stubfile)
- rescue
- report("unable to change protections on #{@@stubfile}")
- end
- end
- end
- else
- report("stub #{@@stubfile} already present")
- end
- end
-
-end
-
-$stdout.sync = true
-
-verbose, action, args = false, :find, Array.new
-
-usage = "fcd [--add|clear|find|list|make|show|stub] [--verbose] [pattern]"
-version = "1.0.2"
-
-def quit(message)
- puts(message)
- exit
-end
-
-ARGV.each do |a|
- case a
- when '-a', '--add' then action = :add
- when '-c', '--clear' then action = :clear
- when '-f', '--find' then action = :find
- when '-l', '--list' then action = :show
- when '-m', '--make' then action = :make
- when '-s', '--show' then action = :show
- when '--stub' then action = :stub
- when '-v', '--verbose' then verbose = true
- when '--version' then quit("version: #{version}")
- when '-h', '--help' then quit("usage: #{usage}")
- when /^\-\-.*/ then quit("error: unknown switch #{a}, try --help")
- else args << a
- end
-end
-
-fcd = FastCD.new(verbose)
-fcd.report("Fast Change Dir / version #{version}")
-
-case action
- when :make then
- fcd.clear
- fcd.scan(args)
- fcd.save
- when :clear then
- fcd.clear
- when :add then
- fcd.load
- fcd.scan(args)
- fcd.save
- when :show then
- fcd.load
- fcd.show
- when :find then
- fcd.load
- fcd.find(args)
- fcd.choose(args)
- fcd.remember
- when :stub
- fcd.check
-end
diff --git a/Master/texmf-dist/scripts/context/ruby/mpstools.rb b/Master/texmf-dist/scripts/context/ruby/mpstools.rb
deleted file mode 100644
index 534bfb95bcf..00000000000
--- a/Master/texmf-dist/scripts/context/ruby/mpstools.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# todo
-#
-# this script will replace mptopdf and makempy
-
-puts("This program is yet unfinished, for the moment it just calls 'mptopdf'.\n\n")
-
-system("texmfstart mptopdf #{ARGV.join(' ')}")
diff --git a/Master/texmf-dist/scripts/context/ruby/texexec.rb b/Master/texmf-dist/scripts/context/ruby/texexec.rb
index 32c9d0ca538..c673cb46b17 100644
--- a/Master/texmf-dist/scripts/context/ruby/texexec.rb
+++ b/Master/texmf-dist/scripts/context/ruby/texexec.rb
@@ -733,7 +733,7 @@ class Commands
else
n += 1
end
- r << ' ' + s
+ r << ' ' + s.to_s
end
report(r) unless r.empty?
end
diff --git a/Master/texmf-dist/scripts/context/ruby/texsync.rb b/Master/texmf-dist/scripts/context/ruby/texsync.rb
deleted file mode 100644
index fd6593f05fb..00000000000
--- a/Master/texmf-dist/scripts/context/ruby/texsync.rb
+++ /dev/null
@@ -1,206 +0,0 @@
-#!/usr/bin/env ruby
-
-# program : texsync
-# copyright : PRAGMA Advanced Document Engineering
-# version : 2003-2005
-# author : Hans Hagen
-#
-# project : ConTeXt / eXaMpLe
-# concept : Hans Hagen
-# info : j.hagen@xs4all.nl
-# www : www.pragma-ade.com
-
-# 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.
-
-# taco's sync: rsync -au -v rsync://www.pragma-ade.com/all ./htdocs
-
-banner = ['TeXSync', 'version 1.1.1', '2002/2004', 'PRAGMA ADE/POD']
-
-$: << File.expand_path(File.dirname($0)) ; $: << File.join($:.last,'lib') ; $:.uniq!
-
-require 'base/switch'
-require 'base/logger'
-# require 'base/tool'
-
-require 'rbconfig'
-
-class Commands
-
- include CommandBase
-
- @@formats = ['en','nl','de','cz','it','ro', 'fr']
- @@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 RbConfig::CONFIG['host_os'] # or: Tool.ruby_platform
- 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 = Logger.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')