<setenv>, <stage>

Neven Has haski at sezampro.yu
Mon Apr 1 13:37:28 PST 2002


On Mon, Apr 01, 2002 at 10:54:11AM -0800, Jesse Tie-Ten-Quee wrote:
> > I mean, the only thing where it will make a difference, is the above
> > <setenv> (or <environment> inside <stage>). This is because it will
> > make setting the environment a container of that environment. So before
> > every element inside is executed, parser will have to go through
> > <stage> and _then_ set the environment.
> 
> > With the way it is now, one can easily skip some <setenv>s and
> > perhaps execute elements after it, which depend upon it.
> 
> Uh, skip?  What difference is it if it's inside a stage or it has it's
> own tags?  I don't see how that makes all that much more of a
> difference.

For example:

    <setenv> <!-- set the variable -->
        <variable>CPPFLAGS</variable>
        <value>-Dre_max_failures=re_max_failures2</value>
    </setenv>

    <configure/>

    <setenv> <!-- unset the variable -->
        <variable>CPPFLAGS</variable>
    </setenv>

If you want to start executing from <configure>, there is no reason for
<setenv> to be executed first.

It is totally independent of it, and nothing tells it that <setenv> might
_needs_ to be executed first.

But if <configure> is _inside_ <setenv>, as its child, it would be obvious
that it needs it.

And I'm talking XML-only here, I don't see it as an implementation issue,
purely a syntax one.

> I though the point of <stage> is to make it easier to group things.  I
> can't support such a change if i can't easily use <stage> like we are
> presently using <build> and so forth... otherwise, it's just making
> things more complicated then need be.  [however, i'll wait untill i see
> a good example before making a judgement on this]

Actually, the <stage> _would_ be like <*build> elements (containers
only). But with the variable name and additional feature - a possibility
to set the environment, change root directory and change user IDs.

> If you have the time, please do.  I've read most of the threads on this
> subject and so many things were said, it's just confusing me at this
> point.  It would probably simplify things overall for everyone too ;)
> 
> Even just like a portion of chapter 5 or something, to show if off.

Hm, this is messy. There are too many <stage>s everywhere and soooo many
nesting levels. I find it very hard to read. And I wrote it myself. ;)

I have added <stage>s wherever <*build> elements used to be. Also,
"stageInfo" and "packageInfo" are used. I haven't modified other
elements.

I have also attached a quick'n'dirty patch against nALFS-1.0.2,
as an example of how it would look ("*Info" elements should probably
be removed from the output). But this is more like "for fun" - we
shouldn't consider this when talking about syntax.

Anyway, after writing this, I'm not sure about <stage> any more. :/

It's hard to see what the stage really is - you have to find a stageInfo,
then search for name and finally read it. Simple elements that describe
themselves (<build>, <chroot> and others) make a profile much easier for
reading.


Neven
-------------- next part --------------
<!-- vi: set ts=4: -->

<!DOCTYPE alfs [
	<!ENTITY LFS "/mnt/lfs">
	<!ENTITY lfs-user "lfs">
	<!ENTITY packages_dir "/usr/src/packages">
	<!ENTITY build_dir "/usr/src">

	<!ENTITY bash-version "2.05a">
	<!ENTITY bash-package "bash-2.05a.tar.bz2">
	<!ENTITY bash-directory "bash-2.05a">

	<!ENTITY binutils-version "2.11.2">
	<!ENTITY binutils-package "binutils-2.11.2.tar.bz2">
	<!ENTITY binutils-directory "binutils-2.11.2">

	<!ENTITY bzip2-version "1.0.1">
	<!ENTITY bzip2-package "bzip2-1.0.1.tar.bz2">
	<!ENTITY bzip2-directory "bzip2-1.0.1">

	<!ENTITY diffutils-version "2.7">
	<!ENTITY diffutils-package "diffutils-2.7.tar.bz2">
	<!ENTITY diffutils-directory "diffutils-2.7">

]>

<alfs version="2.0">

<stage>
	<stageInfo>
		<name>Chapter 5, su-ing to &lfs-user;.</name>
		<user>&lfs-user;</user>
	</stageInfo>
	

	<package>
		<packageInfo>
			<name>bash</name>
			<version>&bash-version;</version>
		</packageInfo>

		<stage>
			<stageInfo>
				<name>Unpacking and configuring.</name>
			</stageInfo>

			<unpack>
				<archive>&LFS;&packages_dir;/&bash-package;</archive>
				<destination>&LFS;&build_dir;</destination>
			</unpack>

			<configure>
				<base>&LFS;&build_dir;/&bash-directory;</base>
				<param>--enable-static-link</param>
				<param>--prefix=&LFS;/usr</param>
				<param>--bindir=&LFS;/bin</param>
				<param>--with-curses</param>
			</configure>
		</stage>

		<stage>
			<stageInfo>
				<name>Compiling a package.</name>
			</stageInfo>

			<make>
				<base>&LFS;&build_dir;/&bash-directory;</base>
			</make>
		</stage>

		<stage>
			<stageInfo>
				<name>Installing a package.</name>
			</stageInfo>

			<make>
				<base>&LFS;&build_dir;/&bash-directory;</base>
				<param>install</param>
			</make>

			<link type="symbolic">
				<options>force</options>
				<base>&LFS;/bin</base>
				<target>bash</target>
				<name>sh</name>
			</link>
		</stage>

		<stage>
			<stageInfo>
				<name>Clean up.</name>
			</stageInfo>

			<remove>&LFS;&build_dir;/&bash-directory;</remove>
		</stage>
	</package>


	<package>
		<packageInfo>
			<name>binutils</name>
			<version>&binutils-version;</version>
		</packageInfo>

		<stage>
			<stageInfo>
				<name>Unpacking and configuring.</name>
			</stageInfo>
	
			<unpack>
				<archive>&LFS;&packages_dir;/&binutils-package;</archive>
				<destination>&LFS;&build_dir;</destination>
			</unpack>

			<mkdir>
				<dir>&LFS;&build_dir;/binutils-build</dir>
			</mkdir>

			<configure>
				<base>&LFS;&build_dir;/binutils-build</base>
				<command>../&binutils-directory;/configure</command>
				<param>--prefix=&LFS;/usr</param>
				<param>--disable-nls</param>
			</configure>
		</stage>

		<stage>
			<stageInfo>
				<name>Compiling a package.</name>
			</stageInfo>
	
			<make>
				<base>&LFS;&build_dir;/binutils-build</base>
				<param>LDFLAGS=-all-static</param>
				<param>tooldir=&LFS;/usr</param>
			</make>
		</stage>

		<stage>
			<stageInfo>
				<name>Installing a package.</name>
			</stageInfo>
	
			<make>
				<base>&LFS;&build_dir;/binutils-build</base>
				<param>tooldir=&LFS;/usr</param>
				<param>install</param>
			</make>
		</stage>

		<stage>
			<stageInfo>
				<name>Clean up.</name>
			</stageInfo>

			<remove>&LFS;&build_dir;/&binutils-directory;</remove>
			<remove>&LFS;&build_dir;/binutils-build</remove>
		</stage>
	</package>


	<package>
		<packageInfo>
			<name>bzip2</name>
			<version>&bzip2-version;</version>
		</packageInfo>

		<stage>
			<stageInfo>
				<name>Unpacking and configuring.</name>
			</stageInfo>

			<unpack>
				<archive>&LFS;&packages_dir;/&bzip2-package;</archive>
				<destination>&LFS;&build_dir;</destination>
			</unpack>
		</stage>

		<stage>
			<stageInfo>
				<name>Compiling a package.</name>
			</stageInfo>

			<make>
				<base>&LFS;&build_dir;/&bzip2-directory;</base>
				<param>CC="gcc -static"</param>
			</make>
		</stage>

		<stage>
			<stageInfo>
				<name>Installing a package.</name>
			</stageInfo>

			<make>
				<base>&LFS;&build_dir;/&bzip2-directory;</base>
				<param>PREFIX=&LFS;/usr</param>
				<param>install</param>
			</make>

			<move>
				<base>&LFS;/usr/bin</base>
				<source>bzcat bunzip2 bzip2 bzip2recover</source>
				<destination>&LFS;/bin</destination>
			</move>
		</stage>

		<stage>
			<stageInfo>
				<name>Clean up.</name>
			</stageInfo>
			<remove>&LFS;&build_dir;/&bzip2-directory;</remove>
		</stage>
	</package>


	<package>
		<packageInfo>
			<name>diffutils</name>
			<version>&diffutils-version;</version>
		</packageInfo>

		<stage>
			<stageInfo>
				<name>Unpacking and configuring.</name>
			</stageInfo>

			<unpack>
				<archive>
					&LFS;&packages_dir;/&diffutils-package;
				</archive>
				<destination>&LFS;&build_dir;</destination>
			</unpack>

			<stage>
				<stageInfo>
					<name>re_max_failures fix for diffutils</name>

					<environment mode="set">
						<variable>
							<name>CPPFLAGS</name>
							<value>-Dre_max_failures=re_max_failures2</value>
						</variable>
					</environment>
				</stageInfo>

				<configure>
					<base>&LFS;&build_dir;/&diffutils-directory;</base>
					<param>--prefix=&LFS;/usr</param>
				</configure>
			</stage>
		</stage>

		<stage>
			<stageInfo>
				<name>Compiling a package.</name>
			</stageInfo>
	
			<make>
				<base>&LFS;&build_dir;/&diffutils-directory;</base>
				<param>LDFLAGS=-static</param>
			</make>
		</stage>

		<stage>
			<stageInfo>
				<name>Installing a package.</name>
			</stageInfo>
	
			<make>
				<base>&LFS;&build_dir;/&diffutils-directory;</base>
				<param>install</param>
			</make>
		</stage>

		<stage>
			<stageInfo>
				<name>Clean up.</name>
			</stageInfo>

			<remove>&LFS;&build_dir;/&diffutils-directory;</remove>
		</stage>
	</package>
</stage>

</alfs>
-------------- next part --------------
===== src/elements.h 1.2 vs edited =====
--- 1.2/src/elements.h	Mon Mar 18 11:26:11 2002
+++ edited/src/elements.h	Mon Apr  1 22:14:48 2002
@@ -33,6 +33,8 @@
 
 static handler_t handlers[] = {
 
+HANDLER("stage", "Stage", NULL)
+
 #endif /* */
 
 
===== src/nalfs.c 1.28 vs edited =====
--- 1.28/src/nalfs.c	Fri Mar 29 17:03:58 2002
+++ edited/src/nalfs.c	Mon Apr  1 22:15:27 2002
@@ -963,15 +963,25 @@
 	/* More info taken from element's attributes or content. */
 	if (handler) {
 		if (strcmp(handler->name, "package") == 0) {
-			if ((tmp = El_package_name(el))) {
+			element_t *pinfo = first_param("packageInfo", el);
+			
+			if ((tmp = param_value("name", pinfo))) {
 				line = append_str(line, " ");
 				line = append_str(line, tmp);
 			}
-
-			if ((tmp = El_package_version(el))) {
+			if ((tmp = param_value("version", pinfo))) {
 				line = append_str(line, " ");
 				line = append_str(line, tmp);
 			}
+
+		} else if (strcmp(el->name, "stage") == 0) {
+			element_t *sinfo = first_param("stageInfo", el);
+
+			if ((tmp = param_value("name", sinfo))) {
+				line = append_str(line, ": ");
+				line = append_str(line, tmp);
+			}
+
 
 		} else if (strcmp(el->name, "execute") == 0) {
 			if ((tmp = param_value("command", el))) {
===== src/parser.c 1.6 vs edited =====
--- 1.6/src/parser.c	Mon Mar 25 22:05:36 2002
+++ edited/src/parser.c	Mon Apr  1 22:09:37 2002
@@ -199,7 +199,7 @@
 	return NULL;
 }
 
-static element_t *first_param(const char *name, element_t *element)
+element_t *first_param(const char *name, element_t *element)
 {
 	element_t *tmp;
 
===== src/parser.h 1.6 vs edited =====
--- 1.6/src/parser.h	Mon Mar 25 10:07:22 2002
+++ edited/src/parser.h	Mon Apr  1 22:09:37 2002
@@ -79,6 +79,7 @@
 char *attr_value(const char *name, element_t *element);
 char *param_value(const char *name, element_t *element);
 char *get_base_dir(element_t *el, char *dir);
+element_t *first_param(const char *name, element_t *element);
 char *append_param_elements(char *string, element_t *el);
 element_t *get_main_profile(element_t *el);
 int option_exists(const char *option, element_t *element);


More information about the alfs-discuss mailing list