From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/29710 Path: news.gmane.org!not-for-mail From: Sanjoy Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: updating context on Ubuntu 6.06 Date: Wed, 26 Jul 2006 20:47:22 +0100 Message-ID: References: <44C794A9.4050902@elvenkind.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1153943288 15576 80.91.229.2 (26 Jul 2006 19:48:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 Jul 2006 19:48:08 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Wed Jul 26 21:48:05 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1G5pM0-0004o7-Jt for gctc-ntg-context-518@m.gmane.org; Wed, 26 Jul 2006 21:47:36 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 227411FD19; Wed, 26 Jul 2006 21:47:36 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 08819-03; Wed, 26 Jul 2006 21:47:29 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id CE5E61FCAF; Wed, 26 Jul 2006 21:47:28 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 3FCAB1FCAF for ; Wed, 26 Jul 2006 21:47:26 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 06744-09-3 for ; Wed, 26 Jul 2006 21:47:24 +0200 (CEST) Original-Received: from mraos.ra.phy.cam.ac.uk (mraos.ra.phy.cam.ac.uk [131.111.48.8]) by ronja.ntg.nl (Postfix) with SMTP id 12AF11FC78 for ; Wed, 26 Jul 2006 21:47:23 +0200 (CEST) Original-Received: from skye.ra.phy.cam.ac.uk ([131.111.48.158] ident=mail) by mraos.ra.phy.cam.ac.uk with esmtp (Exim 4.43) id 1G5pLm-0003Qz-K2; Wed, 26 Jul 2006 20:47:22 +0100 Original-Received: from sanjoy by skye.ra.phy.cam.ac.uk with local (Exim 3.36 #1) id 1G5pLm-0005HT-00; Wed, 26 Jul 2006 20:47:22 +0100 Original-To: mailing list for ConTeXt users In-Reply-To: Your message of "Wed, 26 Jul 2006 18:13:29 +0200." <44C794A9.4050902@elvenkind.com> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:29710 Archived-At: > > 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