LinuxSA Mailing list archives

Index: [thread] [date] [subject] [author] [stats]
  From: Tim Riley <tr@rebel.net.au>
  To  : <syngin@gimp.org>
  Date: Tue, 17 Jul 2001 22:38:25 +0930

(forw) [tr@rebel.net.au: Re: Bash help]

Here ya go - enjoy :)

- Tim


----- Forwarded message from Tim Riley <tr@rebel.net.au> -----

Date: Tue, 17 Jul 2001 22:37:57 +0930
To: Richard Russell <richardrussell@internode.on.net>
Cc: linuxsa@linuxsa.org.au
From: Tim Riley <tr@rebel.net.au>
Subject: Re: Bash help

On Tue, Jul 17, 2001 at 06:38:50PM +0930, Richard Russell wrote:
> 
> > I've been making some modifications to a tool called protopkg, which
> > takes source code and makes a slackware package from it.  My first job
> > has been to make it read from one build file, instead of three.
> 
> first question: why? I would have thought that there may be a reason why
> it's in three files (perhaps because putting it in one simply won't work..
> but more likely because you want to share some of these files around, but
> not all of them -- three files may be the most logical way to arrange the
> code.)

I am extending protopkg to make it into a tool which will be used in the
situation of a ports system.  The reason I want one file instead of
three is becuase that way it is very easy to have multiple versions (ie.
multuple files) of a port in its directory - better to have three files
for three versions instead of nine.

> 
> > Previously, it had a 'prototype' file, in which there was certain
> > variables, as well as package specific compile() and install()
> > functions.  The other files it could use were 'sources' and 'rules.'  In
> > each of these files, there were various lines of text in between two
> > flags, in the following format:
> >
> > flag:
> > text
> > text
> > text
> > :flag
> 
> what type of text? Is this bash commands, environment variable settings, or
> some other config settings?

In the case of the files which were separate from the prototype file
originally, there was just text - for one, a URI and an MD5 checksum per
line, and for the other, a keyword and a path to a file.  The text
between the flags is handled by other functions in the protopkg script.

> 
> > There is a read_rules() function that extracts the information between
> > the flag name passed to it as an argument.  This is it below:
> 
> where? in the prototype file?

No.  The read_rules() function is in the protopkg script/program.  The
prototype file itself is never run, its functions are called by
protopkg.

> 
> >
> > read_rules() {
> >    sed -e '/^#/d' -e '/^$/d' | sed -n "/^${1}:/,/^:${1}$/p" |
> >    grep -Fv "${1}:" | grep -Fv ":${1}" | sed -e "s/^[ \t]*//"
> > }
> 
> ok, in playing around with this, I think that the read_rules() function just
> reads the stuff between the flags, and prints it to stdout, right?
> 

That's the one.

> > So, in order to combine all three files into one, I made another set of
> > flags to encapsulate that which was originally alone in the 'protopkg'
> > file (flag name is 'package') and then appended the other two files to
> > it.
> 
> ok, so it (the (new, modified) prototype file?) looks like:
> 
> ---------------
> #!/bin/bash
> 
> <bash program with read_rules function defined>
> 
> ...
> 
> package:
> flag:
> text
> text
> :flag
> 
> anotherflag:
> text
> text
> :anotherflag
> :package
> 
> -------------
> 
> right?

No - read_rules() and the other functions are contained withing the
`protopkg` script.  Essentially, the prototype file contains information
on how to build the source code tarball in question, along with some
other things.

An example would look like this:

------

package:
VERSION=2.0
PROGNAME=xmms-$VERSION-$ARCH-$BUILD
BUILD=1
ARCH=`/bin/arch`

DESC="\
Info about \n \
the package"

STRIPBIN=y
STIRPLIB=y
SETATTR=y

compile() {
 tar zxvf $CWD/xmms-$VERSION
 ./configure --prefix=/usr
 make
}

install() {
 make install
}

:package

sources:
 http://www.xmms.org/xmms-2.0.tar.gz
:sources

conf:
 /etc/xmms.conf
:conf

---------

The text between the 'package' flags is the stuff called by protopkg to
compile and install the package. 100% bash.  The rest is not bash code,
just lines of data that the protpkg scrip interprets.


> 
> > The problem starts here.  Originally, the entire prototype file was
> > sourced, which was OK since it contained only Bash stuff.  However, now
> > it doesn't, so I want to use the read_rules() function to just source
> > the stuff in between the 'package' flags.  My failed attempt is below.
> 
> This code (below) is from the new prototype file, right? or are you running
> it in your interactive shell (afaik, there's no reason to source something
> in a script...)?
> 
> >
> >      # This dumps it to a file called 

-- 
LinuxSA WWW: http://www.linuxsa.org.au/  IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
  mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject


Index: [thread] [date] [subject] [author] [stats]
Return to the LinuxSA Mailing List Information Page