r1643 - in dev/concept/moongoo: . libalfs syntax

neocool at linuxfromscratch.org neocool at linuxfromscratch.org
Sat Dec 11 14:42:22 PST 2004


Author: neocool
Date: 2004-12-11 15:42:21 -0700 (Sat, 11 Dec 2004)
New Revision: 1643

Modified:
   dev/concept/moongoo/libalfs/alfs.c
   dev/concept/moongoo/libalfs/alfs.h
   dev/concept/moongoo/libalfs/repl.c
   dev/concept/moongoo/libalfs/repl.h
   dev/concept/moongoo/libalfs/util.c
   dev/concept/moongoo/libalfs/util.h
   dev/concept/moongoo/moo.xml
   dev/concept/moongoo/moongoo.c
   dev/concept/moongoo/plugin.h
   dev/concept/moongoo/syntax/ass.c
   dev/concept/moongoo/syntax/blfs.c
   dev/concept/moongoo/syntax/book.c
   dev/concept/moongoo/syntax/nalfs.c
   dev/concept/moongoo/syntax/syn.c
Log:
Update.


Modified: dev/concept/moongoo/libalfs/alfs.c
===================================================================
--- dev/concept/moongoo/libalfs/alfs.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/libalfs/alfs.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -4,6 +4,7 @@
 #include <alfs.h>
 #include <util.h>
 
+bool colors = true;
 role *filter = NULL;
 
 void print_links (profile prof)
@@ -35,16 +36,65 @@
 	printf("\n");
 }
 
+static void __print_deps (profile *prof, package pkg, int indent)
+{
+	int i;
+
+	printfi(indent, "%s\n", pkg.name);
+	
+	if (!pkg.dep)
+		return;
+
+	for (i=0;i<pkg.o;i++)
+	{
+		if (!pkg.dep[i].name)
+			continue;
+
+		if (pkg.dep[i].type==OPT)
+			continue;
+		
+		if (prof)
+		{
+			int j;
+			package *p = search_pkg(prof, lower_case(pkg.dep[i].name), NULL);
+				
+			for (j=0;j<indent;j++)
+				printf("\t");
+				
+			if (!p)
+				fprintf(stderr, "Dependency %s does not exist.\n", 
+					pkg.dep[i].name);
+			else
+				__print_deps(NULL, *p, indent+1);
+				//print_deptree(*prof, *p);
+		}
+		else
+			printfi(indent+1, "%s\n", pkg.dep[i].name);
+	}
+}
+
+void print_deps (package pkg)
+{
+	__print_deps(NULL, pkg, 0);
+}
+
+void print_deptree (profile prof, package pkg)
+{
+	__print_deps(&prof, pkg, 0);
+}
+
 void print_pkg (package pkg)
 {
 	int i;
 	
-	term_set(RESET, GREEN, BLACK);
+	if (colors)
+		term_set(RESET, GREEN, BLACK);
 	if (!pkg.vers)
 		printf("%s\n\n", pkg.name);
 	else
 		printf("%s\nVersion: %s\n\n", pkg.name, pkg.vers);
-	term_reset();
+	if (colors)
+		term_reset();
 	
 	for (i=0;i<pkg.n;i++)
 		print_cmd(pkg.build[i]);
@@ -58,9 +108,11 @@
 	if (!ch.n)
 		return;
 
-	term_set(RESET, RED, BLACK);
+	if (colors)
+		term_set(RESET, RED, BLACK);
 	printf("%s\n", ch.name);
-	term_reset();
+	if (colors)
+		term_reset();
 	for (i=0;i<ch.n;i++)
 		print_pkg(ch.pkg[i]);
 }
@@ -69,9 +121,11 @@
 {
 	int i;
 
-	term_set(RESET, BLUE, BLACK);
+	if (colors)
+		term_set(RESET, BLUE, BLACK);
 	printf("%s %s\n", prof.name, ((prof.vers) ? (prof.vers) : ""));
-	term_reset();
+	if (colors)
+		term_reset();
 	for (i=0;i<prof.n;i++)
 		print_chapter(prof.ch[i]);
 }

Modified: dev/concept/moongoo/libalfs/alfs.h
===================================================================
--- dev/concept/moongoo/libalfs/alfs.h	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/libalfs/alfs.h	2004-12-11 22:42:21 UTC (rev 1643)
@@ -26,6 +26,14 @@
 	SHA1
 } hash_algo;
 
+typedef enum
+{
+	DEP_NONE = 1,
+	OPT,
+	REQ,
+	RECOM
+} dtype;
+
 typedef struct
 {
 	hash_algo algo;
@@ -42,11 +50,19 @@
 
 typedef struct
 {
+	dtype type;
+	char *name;
+} dep;
+
+typedef struct
+{
 	char *name, *vers;
 	command *build;
 	int n;
 	download *dl;
 	int m;
+	dep *dep;
+	int o;
 } package;
 
 typedef struct
@@ -71,8 +87,12 @@
 typedef void (*xml_handler_t) (xmlNodePtr node, void *data);
 typedef bool (*xml_match_t) (xmlNodePtr node, void *data);
 
+extern bool colors;
+
 void print_subtree (xmlNodePtr node);
 void print_pkg (package pkg);
+void print_deps (package pkg);
+void print_deptree (profile prof, package pkg);
 void print_cmd (command cmd);
 void print_chapter (chapter ch);
 void print_profile (profile prof);

Modified: dev/concept/moongoo/libalfs/repl.c
===================================================================
--- dev/concept/moongoo/libalfs/repl.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/libalfs/repl.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -11,17 +11,31 @@
 	char *opt = get_option(r, repl);
 
 	if (!opt)
-		return;
-	
-	if (!strcmp(opt, ""))
 	{
 		fprintf(stderr, "Unconfigured replaceable: %s\n", repl);
 		return;
 	}
 	
+	if (!strcmp(opt, ""))
+		return;
+	
 	xmlNodeSetContent(node, opt);
 }
 
+void print_config (replaceable *r)
+{
+	int i=0;
+
+	if (!r)
+		return;
+	
+	while (r[i].orig)
+	{
+		printf("%s = %s\n", r[i].orig, r[i].repl);
+		i++;
+	}
+}		
+
 char *get_option (replaceable *r, char *key)
 {
 	int i=0;
@@ -36,7 +50,7 @@
 		i++;
 	}
 
-	return "";
+	return NULL;
 }
 
 replaceable *init_repl (char *fname)

Modified: dev/concept/moongoo/libalfs/repl.h
===================================================================
--- dev/concept/moongoo/libalfs/repl.h	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/libalfs/repl.h	2004-12-11 22:42:21 UTC (rev 1643)
@@ -6,5 +6,6 @@
 void t_repl (xmlNodePtr node, void *data);
 replaceable *init_repl (char *fname);
 char *get_option (replaceable *r, char *key);
+void print_config (replaceable *r);
 
 #endif

Modified: dev/concept/moongoo/libalfs/util.c
===================================================================
--- dev/concept/moongoo/libalfs/util.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/libalfs/util.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -1,4 +1,5 @@
 #include <ctype.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -415,3 +416,18 @@
 		
 	return foo;
 }
+
+void printfi (int indent, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+	char msg[512];
+
+	va_start(args, fmt);
+	vsnprintf(msg, 512, fmt, args);
+	va_end(args);
+
+	for (i=0;i<indent;i++)
+		printf("  ");
+	printf("%s", msg);
+}

Modified: dev/concept/moongoo/libalfs/util.h
===================================================================
--- dev/concept/moongoo/libalfs/util.h	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/libalfs/util.h	2004-12-11 22:42:21 UTC (rev 1643)
@@ -44,5 +44,6 @@
 char *cut_trail (char *str, char *delim);
 char *strdog_path (char *str1, char *str2);
 char *extonly (char *url);
+void printfi (int indent, const char *fmt, ...);
 
 #endif

Modified: dev/concept/moongoo/moo.xml
===================================================================
--- dev/concept/moongoo/moo.xml	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/moo.xml	2004-12-11 22:42:21 UTC (rev 1643)
@@ -1,4 +1,5 @@
 <answers>
+<!-- *** LFS *** -->
 <!-- Install partition -->
 <answer name="[xxx]">discs/disc0/part5</answer>
 <answer name="[fff]">ext3</answer>
@@ -22,6 +23,42 @@
 <answer name="[/path/to/your/keymap]"></answer>
 <!-- Paths -->
 <answer name="[unpacked sources dir]">/usr/src</answer>
+
+<!-- *** BLFS *** -->
+<!-- Devices -->
+<answer name="[CD Drive]">/dev/cdroms/cdrom0</answer>
+<answer name="[dvd drive]">cdroms/cdrom0</answer>
+<!-- Paths -->
+<answer name="[your home directory]">/home/neocool</answer>
+<!-- Favourites -->
+<answer name="[browser]">opera</answer>
+<answer name="[X]">15</answer> <!-- ISO 8859-X -->
+<!-- Dummies for noexecute commands -->
+<answer name="[CA_DN_field]"></answer>
+<answer name="[filename]"></answer>
+<answer name="[/path/to/source/tree]"></answer>
+<answer name="[username]"></answer>
+<answer name="[insert existing groups]"></answer>
+<answer name="[servername]"></answer>
+<answer name="[sourcedir]"></answer>
+<answer name="[repository test]"></answer>
+<answer name="[cvstest]"></answer>
+<answer name="[vendortag]"></answer>
+<answer name="[releasetag]"></answer>
+<!-- Bind -->
+<answer name="[Insert secret from rndc-confgen's output here]"></answer>
+<!-- DHCP -->
+<answer name="[192.168.5.0]"></answer> <!-- Subnet -->
+<answer name="[255.255.255.0]"></answer> <!-- Netmask -->
+<answer name="[192.168.5.10] [192.168.5.240]"></answer> <!-- IP range -->
+<answer name="[195.168.5.255]"></answer> <!-- Broadcast address -->
+<answer name="[192.168.5.1]"></answer> <!-- Router -->
+<!-- MPlayer -->
+<answer name="[font size]">24</answer>
+<!-- MySQL -->
+<answer name="[new-password]">moongoo!</answer>
+
+<!-- *** ALFS *** -->
 <!-- Paralell building -->
 <answer name="PARALELL">666</answer>
 </answers>

Modified: dev/concept/moongoo/moongoo.c
===================================================================
--- dev/concept/moongoo/moongoo.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/moongoo.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -36,7 +36,7 @@
 		return 2;
 	}
 
-	while ((c = getopt(argc, argv, "s:qVhc:b")) != EOF)
+	while ((c = getopt(argc, argv, "s:qVhc:bC")) != EOF)
 	{
 		switch (c)
 		{
@@ -67,7 +67,8 @@
 			case 'h':
 				printf("moongoo [OPTIONS] BOOK\n");
 				printf("\t-b\t\tBuild\n");
-				printf("\t-c CONF.XML\tXML configuration file.\n");
+				printf("\t-C\t\tNo colors in output\n");
+				printf("\t-c CONF.XML\tXML configuration file\n");
 				printf("\t-h\t\tPrint this fluff\n");
 				printf("\t-q\t\tNo output\n");
 				printf("\t-s SYNTAX\tChoose syntax (help shows them)\n");
@@ -81,6 +82,9 @@
 				build = true;
 				quiet = true;
 				break;
+			case 'C':
+				colors = false;
+				break;
 		}
 	}
 
@@ -91,7 +95,7 @@
 	xmlXIncludeProcessFlags(doc, XML_PARSE_NOENT);
 	cur = xmlDocGetRootElement(doc);
 
-	f = strdog(getenv("HOME"), MOO_XML);
+	f = strdog(getenv("HOME"), moo_xml);
 	if (access(f, R_OK))
 	{
 		if (access("moo.xml", R_OK))
@@ -100,9 +104,9 @@
 			r = init_repl("moo.xml");
 	}
 	else
-		r = init_repl(strdog(getenv("HOME"), MOO_XML));
+		r = init_repl(f);
 	free(f);
-	
+
 	while (plugin[i].path)
 	{
 		if (!strcmp(syn, plugarg(plugin[i].path)))
@@ -125,12 +129,20 @@
 	{
 		/*package *glibc = search_pkg(prof, "glibc", 
 			"chapter-building-system");*/
+		package *gtk2 = search_pkg(prof, "gtk+",
+			"x-lib");
+		
 		sed_paralell (prof, paralell_filter, popt_pkg, popt_cmd);
 		set_filter(default_filter);
 		
+		if (gtk2)
+		{
+			//print_pkg(*gtk2);
+			print_deptree(*prof, *gtk2);
+		}
 		/*if (glibc)
 			print_pkg(*glibc);*/
-		print_profile(*prof);
+		//print_profile(*prof);
 		//print_links(*prof);
 	}
 

Modified: dev/concept/moongoo/plugin.h
===================================================================
--- dev/concept/moongoo/plugin.h	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/plugin.h	2004-12-11 22:42:21 UTC (rev 1643)
@@ -3,7 +3,7 @@
 
 #include <libalfs.h>
 
-#define PLUG_VER	3
+#define PLUG_VER	4
 #define PLUG_EXT	"so"
 
 typedef struct

Modified: dev/concept/moongoo/syntax/ass.c
===================================================================
--- dev/concept/moongoo/syntax/ass.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/syntax/ass.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -140,6 +140,8 @@
 	prof->ch[i].pkg[j].n = 0;
 	prof->ch[i].pkg[j].dl = NULL;
 	prof->ch[i].pkg[j].m = 0;
+	prof->ch[i].pkg[j].dep = NULL;
+	prof->ch[i].pkg[j].o = 0;
 
 	foreach(node->children, "download", (xml_handler_t)t_down, NULL);
 	t_unpack(prof->ch[i].pkg[j].dl[0].url);

Modified: dev/concept/moongoo/syntax/blfs.c
===================================================================
--- dev/concept/moongoo/syntax/blfs.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/syntax/blfs.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -67,9 +67,61 @@
 
 static void t_userinput (xmlNodePtr node, void *data)
 {
+	// TODO: Add all possible replaceables to moo.xml
+	/*replaceable *r = (replaceable *)data;
+	foreach(node->children, "replaceable", (xml_handler_t)t_repl, r);*/
 	foreach(node->children, "command", (xml_handler_t)t_command, NULL);
 }
 
+static void t_xref (xmlNodePtr node, void *data)
+{
+	dtype *type = (dtype *)data;
+	char *role = xmlGetProp(node, "role");
+	int i, j, k;
+
+	if ((role)&&(!strcmp(role, "no")))
+		return;
+	
+	i = prof->n-1;
+	j = prof->ch[i].n-1;
+	prof->ch[i].pkg[j].dep = realloc(prof->ch[i].pkg[j].dep,
+			(++prof->ch[i].pkg[j].o)*sizeof(dep));
+	k = prof->ch[i].pkg[j].o-1;
+
+	prof->ch[i].pkg[j].dep[k].name = xmlGetProp(node, "linkend");
+	prof->ch[i].pkg[j].dep[k].type = *type;
+}
+
+static void t_sect4 (xmlNodePtr node, void *data)
+{
+	char *title = find_value(node->children, "title");
+	dtype type;
+
+	if (!strncmp(title, "Optional", 8))
+		type = OPT;
+	else
+	if (!strcmp(title, "Required"))
+		type = REQ;
+	else
+	if (!strcmp(title, "Recommended"))
+		type = RECOM;
+	else
+	{
+		fprintf(stderr, "Unknown dependency type '%s'\n", title);
+		type = DEP_NONE;
+	}
+	
+	foreach(node->children, "xref", (xml_handler_t)t_xref, &type);
+}
+
+static void t_sect3 (xmlNodePtr node, void *data)
+{
+	char *title = strstr(find_value(node->children, "title"), " ");
+	
+	if ((title)&&(!strncmp(lower_case(title), " dependencies", 13)))
+		foreach(node->children, "sect4", (xml_handler_t)t_sect4, NULL);
+}
+
 static void t_sect1 (xmlNodePtr node, void *data)
 {
 	int i, j;
@@ -101,7 +153,13 @@
 		strlen(title)-strlen(tmp)) : title;
 	prof->ch[i].pkg[j].build = NULL;
 	prof->ch[i].pkg[j].n = 0;
-	foreach(node->children, "userinput", (xml_handler_t)t_userinput, NULL);
+	prof->ch[i].pkg[j].dl = NULL;
+	prof->ch[i].pkg[j].m = 0;
+	prof->ch[i].pkg[j].dep = NULL;
+	prof->ch[i].pkg[j].o = 0;
+	
+	foreach(node->children, "sect3", (xml_handler_t)t_sect3, data);
+	foreach(node->children, "userinput", (xml_handler_t)t_userinput, data);
 
 	if (!prof->ch[i].pkg[j].n)
 		prof->ch[i].n--;
@@ -114,12 +172,12 @@
 	prof->ch[prof->n-1].ref = xmlGetProp(node, "id");
 	prof->ch[prof->n-1].pkg = NULL;
 	prof->ch[prof->n-1].n = 0;
-	foreach(node->children, "sect1", (xml_handler_t)t_sect1, NULL);
+	foreach(node->children, "sect1", (xml_handler_t)t_sect1, data);
 }
 
 static void t_part (xmlNodePtr node, void *data)
 {
-	foreach(node->children, "chapter", (xml_handler_t)t_chapter, NULL);
+	foreach(node->children, "chapter", (xml_handler_t)t_chapter, data);
 }
 
 profile *parse_blfs (xmlNodePtr node, replaceable *r)
@@ -139,6 +197,6 @@
 	prof->vers++;
 	prof->ch = NULL;
 	prof->n = 0;
-	foreach(node->children, "part", (xml_handler_t)t_part, NULL);
+	foreach(node->children, "part", (xml_handler_t)t_part, r);
 	return prof;
 }

Modified: dev/concept/moongoo/syntax/book.c
===================================================================
--- dev/concept/moongoo/syntax/book.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/syntax/book.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -8,6 +8,7 @@
 command *cmd;
 int num;
 profile *prof;
+replaceable *r;
 
 profile *bookasprofile (xmlNodePtr node, replaceable *r);
 
@@ -47,7 +48,7 @@
 {
 	char *line;
 
-	foreach(node->children, "replaceable", (xml_handler_t)t_repl, NULL);
+	foreach(node->children, "replaceable", (xml_handler_t)t_repl, r);
 	line = squeeze(xmlNodeGetContent(node));
 	line = strkill(line, "\\\n");
 
@@ -112,6 +113,11 @@
 	prof->ch[i].pkg[j].vers = tmp ? strcut(tmp, 1, strlen(tmp)) : NULL;
 	prof->ch[i].pkg[j].name = tmp ? strcut(title, 0, 
 		strlen(title)-strlen(tmp)) : title;
+	prof->ch[i].pkg[j].dl = NULL;
+	prof->ch[i].pkg[j].m = 0;
+	prof->ch[i].pkg[j].dep = NULL;
+	prof->ch[i].pkg[j].o = 0;
+	
 	prof->ch[i].pkg[j].build = t_userinput(node->children, 
 		&prof->ch[i].pkg[j].n);
 
@@ -129,7 +135,7 @@
 	foreach(node->children, "sect1", (xml_handler_t)t_sect1, NULL);
 }
 
-profile *bookasprofile (xmlNodePtr node, replaceable *r)
+profile *bookasprofile (xmlNodePtr node, replaceable *_r)
 {
 	xmlNodePtr info = find_node(node, "bookinfo");
 
@@ -138,7 +144,8 @@
 		fprintf(stderr, "XML document is not a valid LFS book.\n");
 		return NULL;
 	}
-	
+
+	r = _r;
 	prof = (profile *)malloc(sizeof(profile));
 	prof->name = find_value(info, "title");
 	prof->vers = find_value(info, "subtitle");

Modified: dev/concept/moongoo/syntax/nalfs.c
===================================================================
--- dev/concept/moongoo/syntax/nalfs.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/syntax/nalfs.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -294,6 +294,10 @@
 	prof->ch[i].pkg[j].vers = xmlGetProp(node, "version");
 	prof->ch[i].pkg[j].build = NULL;
 	prof->ch[i].pkg[j].n = 0;
+	prof->ch[i].pkg[j].dl = NULL;
+	prof->ch[i].pkg[j].m = 0;
+	prof->ch[i].pkg[j].dep = NULL;
+	prof->ch[i].pkg[j].o = 0;
 	
 	foreach(node->children, "stage", (xml_handler_t)t_stage2, NULL);
 }

Modified: dev/concept/moongoo/syntax/syn.c
===================================================================
--- dev/concept/moongoo/syntax/syn.c	2004-12-11 16:26:35 UTC (rev 1642)
+++ dev/concept/moongoo/syntax/syn.c	2004-12-11 22:42:21 UTC (rev 1643)
@@ -82,6 +82,11 @@
 	prof->ch[i].pkg[j].vers = find_value(node, "version");
 	prof->ch[i].pkg[j].build = NULL;
 	prof->ch[i].pkg[j].n = 0;
+	prof->ch[i].pkg[j].dl = NULL;
+	prof->ch[i].pkg[j].m = 0;
+	prof->ch[i].pkg[j].dep = NULL;
+	prof->ch[i].pkg[j].o = 0;
+	
 	foreach(node->children, "shell", (xml_handler_t)t_shell, NULL);
 
 	if (!prof->ch[i].pkg[j].n)




More information about the alfs-log mailing list