SF.net SVN: morphix: [2305] trunk/mmaker/debian

[email protected] Mon, 12 Jun 2006 06:20:22 -0700
Newsgroups gmane.linux.morphix.cvs
Message-ID <[email protected]>
Revision: 2305
Author:   alextreme
Date:     2006-06-12 06:20:16 -0700 (Mon, 12 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/morphix/?rev=2305&view=rev

Log Message:
-----------
  * adding an enable/disable function for base and mainmod builds

Modified Paths:
--------------
    trunk/mmaker/debian/changelog
    trunk/mmaker/libmorphix/makemodule.c
Modified: trunk/mmaker/debian/changelog
===================================================================
--- trunk/mmaker/debian/changelog	2006-06-12 12:46:28 UTC (rev 2304)
+++ trunk/mmaker/debian/changelog	2006-06-12 13:20:16 UTC (rev 2305)
@@ -1,3 +1,9 @@
+morphix-mmaker (0.4-31) unstable; urgency=low
+
+  * Updating documentation
+
+ -- root <[email protected]>  Fri,  9 Jun 2006 15:13:16 +0200
+
 morphix-mmaker (0.4-30) unstable; urgency=low
 
   * removing glib 2.8 dependancy (fopen ftw!)

Modified: trunk/mmaker/libmorphix/makemodule.c
===================================================================
--- trunk/mmaker/libmorphix/makemodule.c	2006-06-12 12:46:28 UTC (rev 2304)
+++ trunk/mmaker/libmorphix/makemodule.c	2006-06-12 13:20:16 UTC (rev 2305)
@@ -325,6 +325,81 @@
 }
 
 /**
+   Disable the daemons from starting, which causes junk to start on the host system
+   which we can't stop...
+*/
+
+gboolean disableDaemons(mmodule *module) {
+	gchar *cmdline = g_strdup_printf("%s/sbin/start-stop-daemon", module->dirname);
+	gchar *cmdline2 = NULL;
+	FILE *fp = NULL;
+
+	if (!g_file_test(cmdline,G_FILE_TEST_EXISTS)) {
+		g_free(cmdline);
+		fprintf(stderr, "Warning: unable to disable daemons\n");
+		return FALSE;
+	}
+	g_free(cmdline);
+
+	cmdline = g_strdup_printf("mv %s/sbin/start-stop-daemon %s/sbin/start-stop-daemon.REAL", module->dirname, module->dirname);
+	if (!ExecuteCommand(cmdline)) {
+		fprintf(stderr, "Unable to disable daemons, can't move start-stop-daemon\n");
+		g_free(cmdline);
+		return FALSE;
+	}
+       	g_free(cmdline);
+
+	cmdline = g_strdup_printf("%s/sbin/start-stop-daemon", module->dirname);
+	fp = fopen(cmdline, "w");
+	fprintf(fp, "#!/bin/sh\necho \"$0 called, doing nothing\"\n");
+	fclose(fp);
+	chmod(cmdline, 0755);
+	g_free(cmdline);
+	
+	cmdline = g_strdup_printf("%s/usr/sbin/policy-rc.d", module->dirname);
+	if (g_file_test(cmdline, G_FILE_TEST_EXISTS)) {
+		cmdline2 = g_strdup_printf("mv %s/usr/sbin/policy-rc.d %s/usr/sbin/policy-rc.d.REAL", module->dirname, module->dirname);
+		ExecuteCommand(cmdline2);
+		fp = fopen(cmdline, "w");
+		fprintf(fp, "#!/bin/sh\nexit 101\n");
+		fclose(fp);
+		chmod(cmdline, 0755);
+		g_free(cmdline2);
+	}
+	g_free(cmdline);
+
+	return TRUE;
+}
+
+/**
+   Re-enable the daemons for normal usage
+*/
+
+gboolean enableDaemons(mmodule *module) {
+	gchar *cmdline = g_strdup_printf("%s/sbin/start-stop-daemon.REAL", module->dirname);
+	if (g_file_test(cmdline, G_FILE_TEST_EXISTS)) {
+		g_free(cmdline);
+		cmdline = g_strdup_printf("mv %s/sbin/start-stop-daemon.REAL %s/sbin/start-stop-daemon", module->dirname, module->dirname);
+		ExecuteCommand(cmdline);
+	}
+	else {
+		g_free(cmdline);
+		fprintf(stderr, "Warning: Unable to enable daemons, module might be defect!\n");
+		return FALSE;
+	}
+	g_free(cmdline);
+
+	cmdline = g_strdup_printf("%s/usr/sbin/policy-rc.d.REAL", module->dirname);
+	if (g_file_test(cmdline, G_FILE_TEST_EXISTS)) {
+		g_free(cmdline);
+		cmdline = g_strdup_printf("mv %s/usr/sbin/policy-rc.d.REAL %s/usr/sbin/policy-rc.d", module->dirname, module->dirname);
+		ExecuteCommand(cmdline);
+	}
+	g_free(cmdline);
+
+	return TRUE;
+}
+/**
    Links the /proc directory of the module to that of the 
    host system. Necessary for certain packages, but one way to really
    mess up your host system (stuff gets started/restarted, a dedicated 
@@ -1126,6 +1201,9 @@
 		if (!initMainModule(module,xmlfilename,debtarball,debbzip2,debootdir)) {
 			return FALSE;
 		}
+		if (!disableDaemons(module)) {
+			return FALSE;
+		}
 		if (!addPackagesMainModule(module, extra_package_list)) {
 			return FALSE;
 		}
@@ -1138,7 +1216,9 @@
 		if (!executeCommands(module,module->dirname)) {
 			return FALSE;
 		}
-
+		if (!enableDaemons(module)) {
+			return FALSE;
+		}
 		if (!compressModule(module,outputfilename,leave_dir,FS_ISO9660,module->name)) {
 			return FALSE;
 		}
@@ -1147,6 +1227,9 @@
 		if (!initBaseModule(module,xmlfilename,debtarball,debbzip2,debootdir)) {
 			return FALSE;
 		}
+		if (!disableDaemons(module)) {
+			return FALSE;
+		}
 		if (!addPackagesBaseModule(module, extra_package_list)) {
 			return FALSE;
 		}
@@ -1169,7 +1252,9 @@
 		if (!executeCommands(module,module->dirname)) {
 			return FALSE;
 		}
-
+		if (!enableDaemons(module)) {
+			return FALSE;
+		}
 		if (!compressModule(module,outputfilename,leave_dir,FS_ISO9660,module->name)) {
 			return FALSE;
 		}


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