Subversion Repositories SvarDOS

Rev

Rev 1964 | Rev 1966 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1964 Rev 1965
Line 10... Line 10...
10
#include <unistd.h>    /* read() */
10
#include <unistd.h>    /* read() */
11
#include <sys/types.h> /* struct utimbuf */
11
#include <sys/types.h> /* struct utimbuf */
12
 
12
 
13
#include "helpers.h"   /* slash2backslash() */
13
#include "helpers.h"   /* slash2backslash() */
14
#include "fileexst.h"
14
#include "fileexst.h"
15
#include "kprintf.h"
-
 
16
#include "libunzip.h"  /* zip_listfiles()... */
15
#include "libunzip.h"  /* zip_listfiles()... */
17
#include "showinst.h"  /* pkg_loadflist() */
16
#include "showinst.h"  /* pkg_loadflist() */
18
#include "svarlang.lib\svarlang.h"
17
#include "svarlang.lib\svarlang.h"
19
 
18
 
20
#include "pkginst.h"   /* include self for control */
19
#include "pkginst.h"   /* include self for control */
Line 74... Line 73...
74
 
73
 
75
 
74
 
76
/* checks that pkgname is NOT installed. return 0 on success, non-zero otherwise. */
75
/* checks that pkgname is NOT installed. return 0 on success, non-zero otherwise. */
77
static int validate_package_not_installed(const char *pkgname, const char *dosdir) {
76
static int validate_package_not_installed(const char *pkgname, const char *dosdir) {
78
  if (is_package_installed(pkgname, dosdir) != 0) {
77
  if (is_package_installed(pkgname, dosdir) != 0) {
-
 
78
    char msg[256];
79
    kitten_printf(3, 18, pkgname); /* "Package %s is already installed! You might want to use the 'update' action." */
79
    /* "Package %s is already installed! You might want to use the 'update' action." */
-
 
80
    sprintf(msg, svarlang_str(3,18), pkgname);
80
    outputnl("");
81
    outputnl(msg);
81
    return(-1);
82
    return(-1);
82
  }
83
  }
83
  return(0);
84
  return(0);
84
}
85
}
85
 
86
 
Line 162... Line 163...
162
      goto RAII_ERR;
163
      goto RAII_ERR;
163
    }
164
    }
164
 
165
 
165
    /* abort if file is compressed with an unsupported method */
166
    /* abort if file is compressed with an unsupported method */
166
    if ((curzipnode->compmethod != ZIP_METH_STORE) && (curzipnode->compmethod != ZIP_METH_DEFLATE)) { /* unsupported compression method */
167
    if ((curzipnode->compmethod != ZIP_METH_STORE) && (curzipnode->compmethod != ZIP_METH_DEFLATE)) { /* unsupported compression method */
167
      kitten_printf(8, 2, curzipnode->compmethod); /* "ERROR: Package contains a file compressed with an unsupported method (%d):" */
168
      /* "ERROR: Package contains a file compressed with an unsupported method:" */
168
      outputnl("");
169
      outputnl(svarlang_str(8,2));
169
      outputnl(curzipnode->filename);
170
      outputnl(curzipnode->filename);
170
      goto RAII_ERR;
171
      goto RAII_ERR;
171
    }
172
    }
172
 
173
 
173
    /* is it the appinfo file? detach it from the list for now */
174
    /* is it the appinfo file? detach it from the list for now */
Line 330... Line 331...
330
  strcat(buff, pkgname);
331
  strcat(buff, pkgname);
331
  strcat(buff, ".lsm");
332
  strcat(buff, ".lsm");
332
  unzip_result = zip_unzip(zipfd, ziplinkedlist, buff, buff15k);
333
  unzip_result = zip_unzip(zipfd, ziplinkedlist, buff, buff15k);
333
  outputnl("");
334
  outputnl("");
334
  if (unzip_result != 0) {
335
  if (unzip_result != 0) {
335
    kitten_printf(10, 4, unzip_result); /* "ERROR: unzip failure (%d)" */
336
    sprintf(buff, svarlang_str(10,4), unzip_result); /* "ERROR: unzip failure (%d)" */
336
    outputnl("");
337
    outputnl(buff);
337
    return(-1);
338
    return(-1);
338
  }
339
  }
339
  filesextractedsuccess++;
340
  filesextractedsuccess++;
340
 
341
 
341
  /* open the (freshly created) LSM file */
342
  /* open the (freshly created) LSM file */
342
  lsmfd = fopen(buff, "ab"); /* opening in APPEND mode so I do not loose the LSM content */
343
  lsmfd = fopen(buff, "ab"); /* opening in APPEND mode so I do not loose the LSM content */
343
  if (lsmfd == NULL) {
344
  if (lsmfd == NULL) {
344
    kitten_printf(3, 10, buff); /* "ERROR: Could not create %s!" */
345
    /* "ERROR: Could not create %s!" */
-
 
346
    sprintf(buff15k, svarlang_str(3,10), buff);
345
    outputnl("");
347
    outputnl(buff15k);
346
    return(-2);
348
    return(-2);
347
  }
349
  }
348
  fprintf(lsmfd, "\r\n"); /* in case the LSM does not end with a clear line already */
350
  fprintf(lsmfd, "\r\n"); /* in case the LSM does not end with a clear line already */
349
 
351
 
350
  /* write list of files in zip into the lst, and create the directories structure */
352
  /* write list of files in zip into the lst, and create the directories structure */
Line 365... Line 367...
365
    output(" -> ");
367
    output(" -> ");
366
    output(buff);
368
    output(buff);
367
    unzip_result = zip_unzip(zipfd, curzipnode, fulldestfilename, buff15k);
369
    unzip_result = zip_unzip(zipfd, curzipnode, fulldestfilename, buff15k);
368
    outputnl("");
370
    outputnl("");
369
    if (unzip_result != 0) {
371
    if (unzip_result != 0) {
370
      kitten_printf(10, 4, unzip_result); /* "ERROR: unzip failure (%d)" */
372
      sprintf(buff, svarlang_str(10,4), unzip_result); /* "ERROR: unzip failure (%d)" */
371
      outputnl("");
373
      outputnl(buff);
372
      filesextractedfailure += 1;
374
      filesextractedfailure += 1;
373
    } else {
375
    } else {
374
      filesextractedsuccess += 1;
376
      filesextractedsuccess += 1;
375
    }
377
    }
376
  }
378
  }
377
  fclose(lsmfd);
379
  fclose(lsmfd);
378
 
380
 
-
 
381
  /* "Package %s installed: %ld errors, %ld files extracted." */
379
  kitten_printf(3, 19, pkgname, filesextractedfailure, filesextractedsuccess); /* "Package %s installed: %ld errors, %ld files extracted." */
382
  sprintf(buff15k, svarlang_str(3, 19), pkgname, filesextractedfailure, filesextractedsuccess);
380
  outputnl("");
383
  outputnl(buff15k);
381
 
384
 
382
  /* scan the LSM file for a "warn" message to display */
385
  /* scan the LSM file for a "warn" message to display */
383
  display_warn_if_exists(pkgname, dosdir, buff, sizeof(buff));
386
  display_warn_if_exists(pkgname, dosdir, buff, sizeof(buff));
384
 
387
 
385
  return(filesextractedfailure);
388
  return(filesextractedfailure);