SF.net SVN: morphix: [2194] trunk/morphixinstaller/src/instlib.c

[email protected]
Newsgroups gmane.linux.morphix.cvs
Message-ID <[email protected]>
Revision: 2194
Author:   alextreme
Date:     2006-04-01 08:39:28 -0800 (Sat, 01 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/morphix/?rev=2194&view=rev

Log Message:
-----------
  * adding lots of extra output, some extra checks when parsing the list of kernel modules

Modified Paths:
--------------
    trunk/morphixinstaller/src/instlib.c
Modified: trunk/morphixinstaller/src/instlib.c
===================================================================
--- trunk/morphixinstaller/src/instlib.c	2006-04-01 15:55:41 UTC (rev 2193)
+++ trunk/morphixinstaller/src/instlib.c	2006-04-01 16:39:28 UTC (rev 2194)
@@ -449,6 +449,9 @@
 	int i;
 	gchar *cmdline;
 	gchar *filename;
+
+	debug("Executing minimodule install scripts\n");
+
 	for (i = 0; i < MAX_MINIMODULES; i++) { /* unlimited? */
 		gchar *minimoddir = g_strdup_printf("/mnt/mini/mod%d",i);
 		if (g_file_test(minimoddir,G_FILE_TEST_IS_DIR) == TRUE) {
@@ -457,22 +460,24 @@
 				cmdline = g_strdup_printf("mkdir -p %s/mnt/mini/",ROOT_MOUNTPOINT);
 				ExecuteCommand(cmdline);
 				g_free(cmdline);
+
+				debug("Copying over minimodule\n");
 				// if no file, copy recursively the minimodule
 				cmdline = g_strdup_printf("cp -a /mnt/mini/mod%d %s/mnt/mini/",i,ROOT_MOUNTPOINT);
 				ExecuteCommand(cmdline);
-				g_free(minimoddir);
-				g_free(cmdline);
-				g_free(filename);
-				continue;
 			}
-			// else
-			cmdline = g_strdup_printf("sh %s",filename);
-			ExecuteCommand(cmdline);
+			else {
+				debug("Executing minimodule install script\n");
+				cmdline = g_strdup_printf("sh %s",filename);
+				ExecuteCommand(cmdline);
+			}
 			g_free(cmdline);
 			g_free(filename);
 		}
 		g_free(minimoddir);
 	}
+
+	debug("Done executing minimodule install scripts\n");
 	return TRUE;
 }
 
@@ -634,40 +639,57 @@
 
 	sprintf(cmdline,"mkdir %s/root",ROOT_MOUNTPOINT);
 	ExecuteCommand(cmdline);	
+
+	debug("Building /etc/modules using currently-loaded kernel modules (hotplug should handle this?)\n");
 	
 	/* make /etc/modules */
 
 	if (!g_file_get_contents(PROC_MODULES,&modules,&modules_len,NULL)) {
 		/* error */
+		debug("Unable to retrieve module list, something is very wrong...\n");
 	}
-	
-	/* generate a modules script */
-	mod_array = g_strsplit(modules,"\n",0);
-	i = 0;
-	sprintf(cmdline,"%s/etc/modules",ROOT_MOUNTPOINT);
-	file = fopen(cmdline,"w");
-	while (mod_array[i][0] != '\0') {
-		sscanf(mod_array[i],"%s",mod_buf);
-		// skip any livecd-only modules
-		// as most people wouldn't need them anyway,
-		// and they might muck up some stuff
-		// (well, translucency could)
-		if (strcmp(mod_buf,"translucency") != 0 &&
-		    strcmp(mod_buf,"cowloop") != 0 &&
-		    strcmp(mod_buf,"mini_fo") != 0 &&
-		    strcmp(mod_buf,"ide_scsi") != 0 &&
-		    strcmp(mod_buf,"cloop") != 0) {
-			debug("%s\n",mod_buf);
-			fprintf(file,"%s\n",mod_buf);
+	else {
+		/* generate a modules script */
+		mod_array = g_strsplit(modules,"\n",0);
+		if (mod_array == NULL) {
+			debug("Unable to parse module list, aborting /etc/modules section");
 		}
-		i++;
-	}
+		else {
+			i = 0;
+			sprintf(cmdline,"%s/etc/modules",ROOT_MOUNTPOINT);
+			debug("Opening %s\n", cmdline);
+			file = fopen(cmdline,"w");
+			while (mod_array[i][0] != '\0') {
+				if (mod_array[i] == NULL) {
+					debug("Aborting, NULL found in mod_array\n");
+					break;
+				}
+				debug("Checking if module %s needs to be installed\n",mod_array[i]);
+				sscanf(mod_array[i],"%s",mod_buf);
+				// skip any livecd-only modules
+				// as most people wouldn't need them anyway,
+				// and they might muck up some stuff
+				// (well, translucency could)
+				if (strcmp(mod_buf,"translucency") != 0 &&
+				    strcmp(mod_buf,"cowloop") != 0 &&
+				    strcmp(mod_buf,"mini_fo") != 0 &&
+				    strcmp(mod_buf,"ide_scsi") != 0 &&
+				    strcmp(mod_buf,"cloop") != 0) {
+					debug("%s\n",mod_buf);
+					fprintf(file,"%s\n",mod_buf);
+				}
+				i++;
+			} /* while mod_array[i][0] != '\0' */
+			fclose(file);
+		} /* Check if mod_array != NULL */
+	} /* Check if /proc/modules != NULL */
+		// write a new fstab, with the partitions that have been
+		// selected
 
-	fclose(file);
-	// write a new fstab, with the partitions that have been
-	// selected
-	sprintf(cmdline,"%s/etc/fstab",ROOT_MOUNTPOINT);
+	debug("Building fstab");
 
+       	sprintf(cmdline,"%s/etc/fstab",ROOT_MOUNTPOINT);
+
 	file = fopen(cmdline,"w");
 	if (file == NULL) {
 		debug("Unable to open %s, something went very wrong during the install. Aborting!\n",cmdline);
@@ -899,7 +921,7 @@
 			int cnt;
 			for (cnt = 0; cnt < n; ++cnt) {
 				if (strncmp(ep[cnt]->d_name,".",1) != 0 &&
-				    strlen(ep[cnt]->d_name) > 2) {
+				    strlen(ep[cnt]->d_name) > 3) {
 					strncpy(modulelist[modulecount],ep[cnt]->d_name,strlen(ep[cnt]->d_name) - 3); /* ugly hack to remove the .ko from each module. This can be done easier, this can be done better, but it's done */
 
 					modulelist[modulecount++][strlen(ep[cnt]->d_name) -2 ] = '\0';


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.