[Libreoffice-commits] .: Branch 'feature/crossmsi' - setup_native/source

Eilidh McAdam emcadam at kemper.freedesktop.org
Fri Jul 13 06:43:40 PDT 2012


 setup_native/source/win32/wintools/makecab/makecab.c |   66 ++++++++++---------
 1 file changed, 35 insertions(+), 31 deletions(-)

New commits:
commit e47b6388eed41616e36fff139d45ec19c63350fa
Author: Eilidh McAdam <eilidh at lanedo.com>
Date:   Fri Jul 13 14:41:17 2012 +0100

    Use lcab to generate cabinets for now.
    
    lcab is expected in the sys. path.
    
    Change-Id: Ie1cd8a45966bbd84ce84f2ad1d86da492eafa321

diff --git a/setup_native/source/win32/wintools/makecab/makecab.c b/setup_native/source/win32/wintools/makecab/makecab.c
index b822cd6..3cca945 100644
--- a/setup_native/source/win32/wintools/makecab/makecab.c
+++ b/setup_native/source/win32/wintools/makecab/makecab.c
@@ -298,6 +298,8 @@ int main(int argc, char *argv[])
     DDFSRCFILE *srcListCurr = NULL;
     HFCI fci = NULL;
     ERF erf;
+    char * cmd = NULL;
+    unsigned int cmdSize = 0;
 
     while (argv[1] && (argv[1][0] == '-' || argv[1][0] == '/'))
     {
@@ -324,44 +326,45 @@ int main(int argc, char *argv[])
     }
     CabVerb = v;
 
-    srcList = srcListCurr;
-    if (ddfFile != NULL)
+    if (ddfFile == NULL)
     {
-        cabLog(CABLOG_MSG, "=== Parsing directive file \"%s\"===", ddfFile);
-        switch(ParseDdf(ddfFile, &ddfVars, &srcListCurr, v))
-        {
-        case DDFERR_UNREAD: cabLog(CABLOG_ERR, "Could not open directive file."); break;
-        }
-        getcwd(ddfVars.szCabPath, MAX_PATH-1);
-        strcat(ddfVars.szCabPath, "/");
+        cabLog(CABLOG_ERR, "No DDF file specified.");
+        return 1;
     }
 
-    if (srcListCurr != NULL)
+    cabLog(CABLOG_MSG, "=== Parsing directive file \"%s\"===", ddfFile);
+    switch(ParseDdf(ddfFile, &ddfVars, &srcListCurr, v))
     {
-        cabLogCCAB(&ddfVars);
-        fci = FCICreate(&erf, fnFilePlaced, fnMemAlloc, fnMemFree, fnOpen, fnRead,
-                        fnWrite, fnClose, fnSeek, fnDelete, fnGetTempFile, &ddfVars, NULL);
+    case DDFERR_UNREAD: cabLog(CABLOG_ERR, "Could not open directive file."); break;
+    }
+    getcwd(ddfVars.szCabPath, MAX_PATH-1);
+    strcat(ddfVars.szCabPath, "/");
 
-        if (fci != NULL)
-        {
-            cabLog(CABLOG_MSG, "=== Adding files to cabinet ===");
-            for (;srcListCurr != NULL; srcListCurr = srcListCurr->next)
-            {
-                cabLog(CABLOG_MSG, "Adding file: %s%s (%s)", ddfVars.szCabPath, srcListCurr->fileName, srcListCurr->cabName);
-                if (!FCIAddFile(fci, srcListCurr->fileName, srcListCurr->cabName, srcListCurr->extract, fnGetNextCab, fnStatus, fnGetOpenInfo, srcListCurr->cmpType))
-                    cabLogErr(&erf, "A problem occurred while adding a file");
-            }
+    srcList = srcListCurr;
+    if (srcList == NULL)
+    {
+        cabLog(CABLOG_ERR, "No input files were specified.");
+        return 2;
+    }
 
-            cabLog(CABLOG_MSG, "=== Flushing the cabinet ===");
-            if (!FCIFlushCabinet(fci, FALSE, fnGetNextCab, fnStatus))
-                cabLogErr(&erf, "A problem occurred while flushing the cabinet");
-            FCIDestroy(fci);
-        }
-        else
-        {
-            cabLogErr(&erf, "Could not get FCI context");
-        }
+    /* Construct system call to lcab */
+    for(srcListCurr = srcList; srcListCurr != NULL; srcListCurr = srcListCurr->next)
+        cmdSize += strlen(srcListCurr->fileName) + 1;
+    cmdSize += strlen(ddfVars.szCabPath) + strlen(ddfVars.szCab);
+    cmdSize += 6; /* room for "lcab " and \0 */
+    cmd = malloc(cmdSize);
+    strcpy(cmd, "lcab ");
+    for (srcListCurr = srcList; srcListCurr != NULL; srcListCurr = srcListCurr->next)
+    {
+        strcat(cmd, srcListCurr->fileName);
+        strcat(cmd, " ");
     }
+    strcat(cmd, ddfVars.szCabPath);
+    strcat(cmd, ddfVars.szCab);
+
+    cabLog(CABLOG_MSG, "syscall: %s\n", cmd);
+    system(cmd);
+    free(cmd);
 
     cabLog(CABLOG_MSG, "=== Cleaning up resources ===");
     /* Free list of cab source files */
@@ -371,5 +374,6 @@ int main(int argc, char *argv[])
         free(srcListCurr);
         srcListCurr = next;
     }
+    cabLog(CABLOG_MSG, "Cabinet file %s/%s created.", ddfVars.szCabPath, ddfVars.szCab);
     return 0;
 }


More information about the Libreoffice-commits mailing list