ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Sanjoy Mahajan <sanjoy@mrao.cam.ac.uk>
Subject: Re: updating context on Ubuntu 6.06
Date: Wed, 26 Jul 2006 20:47:22 +0100	[thread overview]
Message-ID: <E1G5pLm-0005HT-00@skye.ra.phy.cam.ac.uk> (raw)
In-Reply-To: Your message of "Wed, 26 Jul 2006 18:13:29 +0200." <44C794A9.4050902@elvenkind.com>

> > Whereas the "$@" form would produce
> > 
> >   texmfstart.rb "--option=hi there"
> > 
> > This second form is what you want, no?
> 
> Ah, I see. (is that bash-only?)

It was hard to find a machine not running bash, a measure of the
success of free software.  But I eventually found a nearby Solaris
machine running 'sh' (couldn't tell which version), but it's man entry
says the same:

     if $@ is within a pair of double quotes, the positional
     parameters are substituted and quoted, separated by unquoted
     spaces ("$1""$2" ... )

So I think it's safe, and increases robustness, to change $@ -> "$@"
in all the stub scripts.

> Would it not work to simply point the variable TEXMFLOCAL to
> ~/texmf?

I was a little leery but tried it.  Meanwhile here's a patch that
fixes the need for that:

--- a/scripts/context/ruby/ctxtools.rb	Wed Jul 26 14:50:16 2006 -0400
+++ b/scripts/context/ruby/ctxtools.rb	Wed Jul 26 14:53:57 2006 -0400
@@ -2314,7 +2314,7 @@ class Commands
         end
 
         def locatedlocaltree
-            return `kpsewhich --expand-var $TEXMFLOCAL`.chomp rescue nil
+            return `kpsewhich --expand-var '$TEXMFLOCAL'`.chomp rescue nil
         end
 
         def extractarchive(archive)

The only problem is that it'll now, as intended, use the TEXMFLOCAL
from texmf.cnf.  But TEXMFLOCAL is probably not ~/texmf, so you'll
still have to force the setting like this:

  TEXMFLOCAL=~/texmf texmfstart ctxtools --updatecontext

The next problem was this message during the update:

chmod: cannot access `scripts/context/unix/stubs/*': No such file or directory

For my second attempt at ruby programming (the first being the two
glorious quotes above), I looked to see what ctxtools.rb was doing
around the chmod.  It was supposed to report an error with this line:

 report("change x-permissions of '" + stubs + "' manually")

But the line was not executed, because it was in a ruby 'rescue' clause.
But when system("chmod +x ....") fails, it returns false, but does not
throw an exception for rescue.  So I rewrote the extractarchive()
function to wrap the system() calls in if/unless clauses rather than
rescue clauses.  In doing so I noticed why the chmod failed: the path
should be

  scripts/context/stubs/unix/*

rather than

  scripts/context/unix/stubs/*

The patch below does that change as well as the change of rescue ->
if/unless.  With these patches the automatic update went smoothly.

One question: How safe is it that the ctxtools.rb script is
overwritten by the unzip in the middle of running the script?  Will
ruby execute half from the old script and half from the new script?
It wasn't an issue for me, I eventually realized, because the -u
switch to unzip meant that my updated ctxtools.rb was not overwritten.
But in general it will be.


--- a/scripts/context/ruby/ctxtools.rb	Wed Jul 26 14:54:24 2006 -0400
+++ b/scripts/context/ruby/ctxtools.rb	Wed Jul 26 15:36:21 2006 -0400
@@ -2318,26 +2318,19 @@ class Commands
         end
 
         def extractarchive(archive)
-            if FileTest.file?(archive) then
-                begin
-                    system("unzip -uo #{archive}")
-                rescue
-                    report("fatal error, make sure that you have 'unzip' in your path")
-                    return false
-                else
-                    if System.unix? then
-                        begin
-                            system("chmod +x scripts/context/unix/stubs/*")
-                        rescue
-                            report("change x-permissions of 'scripts/context/unix/stubs/*' manually")
-                        end
-                    end
-                    return true
-                end
-            else
+            unless FileTest.file?(archive) then
                 report("fatal error, '{archive}' has not been downloaded")
                 return false
             end
+            unless system("unzip -uo #{archive}") then
+                report("fatal error, make sure that you have 'unzip' in your path")
+                return false
+            end
+            stubs = "scripts/context/stubs/unix/*"
+            if System.unix? and not system("chmod +x " + stubs) then
+                report("change x-permissions of '" + stubs + "' manually")
+            end
+            return true
         end
 
         def remakeformats

  reply	other threads:[~2006-07-26 19:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-24 20:24 Sanjoy Mahajan
2006-07-26  8:36 ` Ralf Schmitt
2006-07-26  9:36   ` Taco Hoekwater
2006-07-26 10:36     ` Jano Kula
2006-07-26 11:20     ` Ralf Schmitt
2006-07-26 15:17     ` Sanjoy Mahajan
2006-07-26 16:13       ` Taco Hoekwater
2006-07-26 19:47         ` Sanjoy Mahajan [this message]
2006-07-26 20:34           ` Taco Hoekwater
2006-07-26 20:57           ` Hans Hagen
2006-07-26 21:01           ` Hans Hagen
2006-07-26 21:29             ` Switching Font Size in a Natural Table Neal Lester
2006-08-01 23:31               ` Mojca Miklavec
2006-07-26 22:10             ` updating context on Ubuntu 6.06 Sanjoy Mahajan
2006-07-27  8:05               ` Hans Hagen
2006-07-27  8:46                 ` Taco Hoekwater
2006-07-27  8:04           ` Hans Hagen
2006-07-27 12:37             ` Sanjoy Mahajan
2006-07-26 21:02         ` Hans Hagen
2006-07-26 14:43   ` Sanjoy Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1G5pLm-0005HT-00@skye.ra.phy.cam.ac.uk \
    --to=sanjoy@mrao.cam.ac.uk \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).