[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Change the configuration of depmod and link modules to better place (#593941)



Depmod doesn't support absolute paths so far, so we have to use small workaround. COnfigure it to prefer lib/modules/<kernel>/updates and make updates a symlink to /tmp/DD/lib/modules.

This way depmod -a should see the modules and modprobe too...
---
 docs/driverdisc.txt |    4 ++--
 loader/driverdisk.c |   40 +++++++++++++++++++++++++++-------------
 scripts/mk-images   |    2 +-
 3 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/docs/driverdisc.txt b/docs/driverdisc.txt
index 779e71e..dee3a30 100644
--- a/docs/driverdisc.txt
+++ b/docs/driverdisc.txt
@@ -91,8 +91,8 @@ to respect some rules.
 
 - All updated modules belong to /lib/modules/<kernel version>/..  according to
   their usual location
-- All new modules belong to /tmp/DD/lib/modules
-- All new firmware files belong to /tmp/DD/lib/firmware
+- All new modules belong to /lib/modules/<kernel version>/updates
+- All new firmware files belong to /lib/firmware
 - The rpm repo with updated packages belongs to /tmp/DD-initrd/
 - The (empty) trigger file /.rundepmod must be present
 
diff --git a/loader/driverdisk.c b/loader/driverdisk.c
index b7e2d82..da3d3c2 100644
--- a/loader/driverdisk.c
+++ b/loader/driverdisk.c
@@ -143,13 +143,11 @@ int globErrFunc(const char *epath, int eerrno)
     return 0;
 }
 
-int dlabelUnpackRPMDir(char* rpmdir, char* destination)
+int dlabelUnpackRPMDir(char* rpmdir, char* destination, char *kernelver)
 {
-    char *kernelver;
-    struct utsname unamedata;
     char *oldcwd;
     char *globpattern;
-    int rc;
+    int rc = 0;
 
     /* get current working directory */ 
     oldcwd = getcwd(NULL, 0);
@@ -165,12 +163,6 @@ int dlabelUnpackRPMDir(char* rpmdir, char* destination)
         return 1;
     }
 
-    /* get running kernel version */
-    rc = uname(&unamedata);
-    checked_asprintf(&kernelver, "%s",
-            rc ? "unknown" : unamedata.release);
-    logMessage(DEBUGLVL, "Kernel version: %s", kernelver);
-
     checked_asprintf(&globpattern, "%s/*.rpm", rpmdir);
     glob_t globres;
     char** globitem;
@@ -192,7 +184,6 @@ int dlabelUnpackRPMDir(char* rpmdir, char* destination)
     }
 
     /* cleanup */
-    free(kernelver);
     free(oldcwd);
     return rc;
 }
@@ -247,7 +238,9 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
     struct moduleBallLocation * location;
     struct stat sb;
     static int disknum = 0;
-    int fd, ret;
+    int rc, fd, ret;
+    char *kernelver;
+    struct utsname unamedata;
 
     /* check for new version */
     sprintf(file, "%s/rhdd3", mntpt);
@@ -265,6 +258,12 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
     title[sb.st_size] = '\0';
     close(fd);
 
+    /* get running kernel version */
+    rc = uname(&unamedata);
+    checked_asprintf(&kernelver, "%s",
+            rc ? "unknown" : unamedata.release);
+    logMessage(DEBUGLVL, "Kernel version: %s", kernelver);
+
     sprintf(file, DD_RPMDIR_TEMPLATE, disknum);
     mkdirChain(file);
     mkdirChain(DD_MODULES);
@@ -284,13 +283,25 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
     copyDirectory(src, dest, copyWarnFn, copyErrorFn);
 
     /* unpack packages from dest into location->path */
-    if (dlabelUnpackRPMDir(dest, DD_EXTRACTED)) {
+    if (dlabelUnpackRPMDir(dest, DD_EXTRACTED, kernelver)) {
         /* fatal error, log this and jump to exception handler */
         logMessage(ERROR, "Error unpacking RPMs from driver disc no.%d",
                 disknum);
         goto loadDriverDiscException;
     }
 
+
+    /* ensure updates directory exists */
+    sprintf(file, "/lib/modules/%s/updates", kernelver);
+    mkdirChain(file);
+
+    /* make sure driver update are referenced from system module dir
+       but from a different subdir, initrd overlays use the main
+       /lib/modules/<kernel>/updates
+     */
+    sprintf(file, "/lib/modules/%s/updates/DD", kernelver);
+    rc = symlink(DD_MODULES, file);
+
     /* run depmod to refresh modules db */
     if (system("depmod -a")) {
       /* this is not really fatal error, it might still work, log it */
@@ -313,6 +324,9 @@ static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) {
 
 loadDriverDiscException:
 
+    /* cleanup */
+    free(kernelver);
+
     if (!FL_CMDLINE(flags))
         newtPopWindow();
 
diff --git a/scripts/mk-images b/scripts/mk-images
index 2627904..2ae76b7 100755
--- a/scripts/mk-images
+++ b/scripts/mk-images
@@ -333,7 +333,7 @@ makemoduletree() {
     # create depmod.conf to support DDs
     mkdir -p $MMB_DIR/etc/depmod.d
     cat > $MMB_DIR/etc/depmod.d/dd.conf << EOF
-search /tmp/DD/lib/modules built-in
+search updates built-in
 EOF
 
     # clean up leftover cruft
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]