Skip to Content.
Sympa Menu

sm-discuss - Re[2]: [SM-Discuss] sorcery purists do not read!

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Mark Andrews <msasgl AT msa-enterprises.com>
  • To: Sergey A Lipnevich <sergeyli AT pisem.net>
  • Cc: SM-Discuss AT lists.ibiblio.org
  • Subject: Re[2]: [SM-Discuss] sorcery purists do not read!
  • Date: Tue, 10 Dec 2002 18:58:19 +0000

Hello Sergey,

Tuesday, December 10, 2002, 4:57:57 PM, you wrote:

SAL> It brings the old questions of trying to automate a decision on what
SAL> part of coolthing-b5-beta-18 is the version, and if coolthing-6.5 is a
SAL> higher version than the former. Going in the direction of blending
SAL> different pieces of data together in such way will bring you nowhere.

I get where you are coming from now. The version and name are stored
seperately in the details file. I've never considered automating the
extraction of name and version from the name-version system viable.
It's there so version specific depends (including having multiple
versions of same package) can be handled cleanly by the code.

Of particular focus when I decided on this method was the linux
headers which should really be in a seperate spell and not sym linked
to whichever version of linux was last cast.

That way a linux-headers-2.4.20 could be cast (along with a warning
that that is the minimum kernel version that can be used for any code
compiled against those headers).

SAL> I mean something which would allow sort spells in the order of
SAL> dependency for casting. Currently, it's done with an elaborate part of
SAL> code which builds dependency trees using bash variable names (which is
SAL> either awesome or disgusting depending on one's programming tastes).

I was kinda thinking a 'castlist' temp file and sed / grep would do this job..

castlist file:-

SPELL1:SPELL5:SPELL6
SPELL2:
SPELL3:SPELL4
SPELL4:
SPELL5:SPELL3
SPELL6:SPELL2

First column is the spell. Anything extra is a dependancy.

This is off the top of my head so probably won't work as is, but
should give an idea of what I'm thinking:

NOTSORTED=1
while [[ NOTSORTED -eq 1 ]]; do
NOTCHANGED=1
for SPELLNAME in $(=sed "s/:.*//" /tmp/castlist); do
LINEPOSITION=${$(grep -n "^${SPELLNAME}:" /tmp/castlist)%%:*}
DEPENDPOSITION=${$(grep -n -m 1 ":${SPELLNAME}" /tmp/castlist)%%:*}
[[ -z ${DEPENDPOSTION} ]] ||
[[ ${LINEPOSITION} -lt ${DEPENDPOSITION} ]] &&
{ TEMPSPELL=`grep "^${SPELLNAME}:" /tmp/castlist`
sed "s/${TEMPSPELL}//" /tmp/castlist > castlist2
echo $TEMPSPELL >> /tmp/castlist2
mv castlist2 castlist
NOTCHANGED=0
break
}
done
[[ NOTCHANGED -eq 1 ]] && NOTSORTED=0
done

Then feed them to cast which would handle sorting out options for
available dependancies.. Obviously there's a bit of pre-processing
needed to avoid circular references, but that would go in the code to
add a spell to the cast list..

SAL> That's why I asked. I'm trying to figure out what does zsh has to offer
SAL> beyond bash. Is it GPL by the way?

Yes and there is a spell for it. I basically went through the man
pages for all the shells I could find and zsh was the one that clicked
for me. I'd recommend doing that rather than recommending zsh as YMMV.

Though quite a few distros seem to have zsh as standard, perhaps
because it can emulate ksh & csh as well.

>>Things like ${$(locate "*.h"):t} which fall over under bash but work
>>great in zsh spring immediately to mind.

SAL> You certainly can declare an intermediate local variable and do your
SAL> thing.

I know. But to me that's just another thing (variable name) I have to
remember and when I'm trying to hold an image of how an entire
distribution hangs together in my mind, freeing up a grey cell here
and there helps a lot. It's a work flow thing.

SAL> You were referring to sed and awk features that are in zsh, maybe
SAL> you could elaborate on that?

Sorry but I can't. It's certainly not a replacement for them, (sed and
grep) but certainly some of the simpler things can be done in other
ways just using zsh. Somewhere <shrug> I saw a zsh script that did a
colorised grep, so the text you were looking for was highlighted in
the result.

This isn't something I've bothered too much with yet as I know I may
end up bringing a variation of the code into SourceMage at some point
and don't want to stray too far ;-) zsh is my prototyping shell so to
speak.

Once I've got fully working code then I will be looking more closely
at optimisation through using shell only commands and maybe I
can answer this better then. In the meantime cast zsh & man zshall are
your friends.. Or checkout http://www.zsh.org for the online manuals.

--
Best regards,
Mark mailto:msasgl AT msa-enterprises.com





Archive powered by MHonArc 2.6.24.

Top of Page