r1611 - dev/concept/moongoo

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Wed Dec 1 04:18:55 PST 2004


Author: neocool
Date: 2004-12-01 05:18:53 -0700 (Wed, 01 Dec 2004)
New Revision: 1611

Added:
   dev/concept/moongoo/ass.c
   dev/concept/moongoo/ass.h
   dev/concept/moongoo/nalfs.c
   dev/concept/moongoo/nalfs.h
Modified:
   dev/concept/moongoo/Makefile
   dev/concept/moongoo/alfs.c
   dev/concept/moongoo/alfs.h
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/syn.c
Log:
* Support for two new syntaxes added:
	ASS - ALFS Simple Syntax
	nALFS legacy syntax


Modified: dev/concept/moongoo/Makefile
===================================================================
--- dev/concept/moongoo/Makefile	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/Makefile	2004-12-01 12:18:53 UTC (rev 1611)
@@ -7,9 +7,11 @@
 CFLAGS+=-Wall -Werror -g3
 
 BIN=moongoo
-OBJS=alfs.o book.o util.o repl.o syn.o
+OBJS=alfs.o book.o util.o repl.o syn.o nalfs.o ass.o
 
-BOOK=~/projects/alfs/book/index.xml
+#BOOK=~/projects/alfs/book/index.xml
+BOOK=~/projects/alfs/lfs-profile/LFS.xml
+#BOOK=~/projects/alfs/ass/index.xml
 #BOOK=~/projects/hive/unstable/profile.xml
 
 .PHONY: all clean compile run memcheck debug todo upload bug
@@ -47,3 +49,5 @@
 util.o: util.h
 book.o: book.h
 repl.o: repl.h
+nalfs.o: nalfs.h
+ass.o: ass.h

Modified: dev/concept/moongoo/alfs.c
===================================================================
--- dev/concept/moongoo/alfs.c	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/alfs.c	2004-12-01 12:18:53 UTC (rev 1611)
@@ -17,7 +17,7 @@
 	printf("%s ", cmd.cmd);
 	for (i=0;i<cmd.n;i++)
 		printf("%s ", cmd.arg[i]);
-	if (cmd.role!=NONE)
+	if (cmd.role!=ROLE_NONE)
 		printf("(%s)", role2str(cmd.role));
 	printf("\n");
 }
@@ -134,7 +134,7 @@
 {
 	switch (role)
 	{
-		case (NONE):
+		case (ROLE_NONE):
 			return "none";
 		case (NOEXECUTE):
 			return "noexecute";
@@ -156,7 +156,7 @@
 	char *prop = xmlGetProp(node, "role");
 
 	if (!prop)
-		return NONE;
+		return ROLE_NONE;
 	if (!strcmp(prop, "noexecute"))
 		return NOEXECUTE;
 	if (!strcmp(prop, "interactive"))
@@ -170,7 +170,7 @@
 
 	fprintf(stderr, "%s is an unknown role-attribute.\n", prop);
 	
-	return NONE;
+	return ROLE_NONE;
 }
 
 char *type2str (xmlElementType type)

Modified: dev/concept/moongoo/alfs.h
===================================================================
--- dev/concept/moongoo/alfs.h	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/alfs.h	2004-12-01 12:18:53 UTC (rev 1611)
@@ -9,7 +9,7 @@
 
 typedef enum
 {
-	NONE = 1,
+	ROLE_NONE = 1,
 	NOEXECUTE,
 	INTERACTIVE,
 	TESTSUITE,
@@ -17,8 +17,29 @@
 	CHROOT
 } role;
 
+typedef enum
+{
+	HASH_NONE = 1,
+	MD5,
+	SHA1
+} hash_algo;
+
+typedef enum
+{
+	PROTO_NONE = 1,
+	HTTP,
+	FTP
+} protocol;
+
 typedef struct
 {
+	hash_algo algo;
+	protocol proto;
+	char *url, *sum;
+} download;
+
+typedef struct
+{
 	char *cmd, **arg;
 	int n;
 	role role;

Added: dev/concept/moongoo/ass.c
===================================================================
--- dev/concept/moongoo/ass.c	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/ass.c	2004-12-01 12:18:53 UTC (rev 1611)
@@ -0,0 +1,97 @@
+#include <string.h>
+
+#include <ass.h>
+#include <util.h>
+
+profile *prof;
+
+// TODO: Support download/directory in the ASS parser
+void process_cmd3 (char *line, xmlNodePtr node)
+{
+	int i, j, k;
+
+	i = prof->n-1;
+	j = prof->ch[i].n-1;
+	prof->ch[i].pkg[j].build = realloc(prof->ch[i].pkg[j].build,
+			(++prof->ch[i].pkg[j].n)*sizeof(command));
+	k = prof->ch[i].pkg[j].n-1;
+	
+	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
+
+	if (strcnt(line, " "))
+	{
+		prof->ch[i].pkg[j].build[k].cmd = strcut(line, 0, whereis(line, ' '));
+		prof->ch[i].pkg[j].build[k].arg = tokenize(notrail(strstr(line, " "), 
+				" "), " ", &prof->ch[i].pkg[j].build[k].n);
+	}
+	else
+	{
+		prof->ch[i].pkg[j].build[k].cmd = line;
+		prof->ch[i].pkg[j].build[k].arg = NULL;
+		prof->ch[i].pkg[j].build[k].n = 0;
+	}
+}
+
+void t_shell2 (xmlNodePtr node, void *data)
+{
+	char *line = squeeze(xmlNodeGetContent(node));
+	line = strkill(line, "\\\n");
+
+	if (strcnt(line, "\n"))
+	{
+		char *tmp;
+
+		while ((line) && (strlen(line)))
+		{
+			tmp = strsep(&line, "\n");
+			process_cmd3(tmp, node);
+		}
+	}
+	else
+		process_cmd3(line, node);
+}
+
+void t_page (xmlNodePtr node, void *data)
+{
+	int i, j;
+
+	i = prof->n-1;
+	prof->ch[i].pkg = realloc(prof->ch[i].pkg,
+			(++prof->ch[i].n)*sizeof(package));
+	j = prof->ch[i].n-1;
+
+	prof->ch[i].pkg[j].name = find_value(node, "title");
+	prof->ch[i].pkg[j].vers = find_value(node, "version");
+	prof->ch[i].pkg[j].build = NULL;
+	prof->ch[i].pkg[j].n = 0;
+	foreach(node->children, "shell", (xml_handler_t)t_shell2, NULL);
+}
+
+void t_chapter2 (xmlNodePtr node, void *data)
+{
+	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
+	prof->ch[prof->n-1].ref = xmlGetProp(node, "ref");
+	prof->ch[prof->n-1].pkg = NULL;
+	prof->ch[prof->n-1].n = 0;
+	foreach(node->children, "page", (xml_handler_t)t_page, NULL);
+}
+
+profile *ass_profile (xmlNodePtr node)
+{
+	node = find_node(node, "ass");
+
+	if (!node)
+	{
+		fprintf(stderr, "XML document is not a valid ASS profile.\n");
+		return NULL;
+	}
+	
+	prof = (profile *)malloc(sizeof(profile));
+	prof->name = find_value(node, "title");
+	prof->vers = find_value(node, "version");
+	prof->ch = NULL;
+	prof->n = 0;
+	foreach(node->children, "chapter", (xml_handler_t)t_chapter2, NULL);
+	return prof;
+}

Added: dev/concept/moongoo/ass.h
===================================================================
--- dev/concept/moongoo/ass.h	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/ass.h	2004-12-01 12:18:53 UTC (rev 1611)
@@ -0,0 +1,8 @@
+#ifndef __ASS_H__
+#define __ASS_H__
+
+#include <alfs.h>
+
+profile *ass_profile (xmlNodePtr node);
+
+#endif

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/moongoo.c	2004-12-01 12:18:53 UTC (rev 1611)
@@ -5,6 +5,8 @@
 #include <book.h>
 #include <syn.h>
 #include <repl.h>
+#include <nalfs.h>
+#include <ass.h>
 #include <util.h>
 
 role default_filter[4] = { NOEXECUTE, INTERACTIVE, TESTSUITE, 0 };
@@ -28,14 +30,16 @@
 	cur=xmlDocGetRootElement(doc);
 	resolve_entities(cur);
 	
-	prof=bookasprofile(cur);
+	//prof=bookasprofile(cur);
 	//prof=syn_profile(cur);
+	prof=nalfs_profile(cur);
+	//prof=ass_profile(cur);
 	
-	if (prof)
+	/*if (prof)
 	{
 		set_filter(default_filter);
 		print_profile(*prof);
-	}
+	}*/
 	
 	xmlFreeDoc(doc);
 	return 0;

Added: dev/concept/moongoo/nalfs.c
===================================================================
--- dev/concept/moongoo/nalfs.c	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/nalfs.c	2004-12-01 12:18:53 UTC (rev 1611)
@@ -0,0 +1,61 @@
+#include <nalfs.h>
+
+profile *prof;
+
+// TODO: Parse all nALFS legacy commands to command* structs
+void t_stage2 (xmlNodePtr node, void *data)
+{
+	printf("%s\n", xmlGetProp(node, "name"));
+}
+
+void t_pkg2 (xmlNodePtr node, void *data)
+{
+	int i, j;
+
+	i = prof->n-1;
+	prof->ch[i].pkg = realloc(prof->ch[i].pkg,
+			(++prof->ch[i].n)*sizeof(package));
+	j = prof->ch[i].n-1;
+	
+	prof->ch[i].pkg[j].name = xmlGetProp(node, "name");
+	// TODO: <package version="moo"> cannot be parsed yet
+	prof->ch[i].pkg[j].vers = NULL;
+	prof->ch[i].pkg[j].build = NULL;
+	prof->ch[i].pkg[j].n = 0;
+	foreach(node->children, "stage", (xml_handler_t)t_stage2, NULL);
+}
+
+void t_alfs (xmlNodePtr node, void *data)
+{
+	// TODO: Handle <stage> node only pages, like chapter07/network.xml 
+	foreach(node->children, "package", (xml_handler_t)t_pkg2, NULL);
+}
+
+void t_stage (xmlNodePtr node, void *data)
+{
+	prof->ch = realloc(prof->ch, (++prof->n)*sizeof(chapter));
+	prof->ch[prof->n-1].name = xmlGetProp(node, "name");
+	prof->ch[prof->n-1].name = prof->ch[prof->n-1].name;
+	prof->ch[prof->n-1].pkg = NULL;
+	prof->ch[prof->n-1].n = 0;
+	foreach(node->children, "alfs", (xml_handler_t)t_alfs, NULL);
+}
+
+profile *nalfs_profile (xmlNodePtr node)
+{
+	node = find_node(node, "alfs");
+
+	if (!node)
+	{
+		fprintf(stderr, "XML document is not a valid nALFS profile.\n");
+		return NULL;
+	}
+	
+	prof = (profile *)malloc(sizeof(profile));
+	prof->name = "nALFS legacy profile";
+	prof->vers = entity_val("LFS-version");
+	prof->ch = NULL;
+	prof->n = 0;
+	foreach(node->children, "stage", (xml_handler_t)t_stage, NULL);
+	return prof;
+}

Added: dev/concept/moongoo/nalfs.h
===================================================================
--- dev/concept/moongoo/nalfs.h	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/nalfs.h	2004-12-01 12:18:53 UTC (rev 1611)
@@ -0,0 +1,8 @@
+#ifndef __NALFS_H__
+#define __NALFS_H__
+
+#include <alfs.h>
+
+profile *nalfs_profile (xmlNodePtr node);
+
+#endif

Modified: dev/concept/moongoo/syn.c
===================================================================
--- dev/concept/moongoo/syn.c	2004-12-01 01:32:17 UTC (rev 1610)
+++ dev/concept/moongoo/syn.c	2004-12-01 12:18:53 UTC (rev 1611)
@@ -5,6 +5,7 @@
 
 profile *prof;
 
+// TODO: Complete syn support
 void process_cmd2 (char *line, xmlNodePtr node)
 {
 	int i, j, k;
@@ -16,7 +17,7 @@
 			(++prof->ch[i].pkg[j].n)*sizeof(command));
 	k = prof->ch[i].pkg[j].n-1;
 
-	prof->ch[i].pkg[j].build[k].role = NONE;
+	prof->ch[i].pkg[j].build[k].role = ROLE_NONE;
 
 	if (strcnt(line, " "))
 	{




More information about the alfs-log mailing list