Subversion Repositories SvarDOS

Rev

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

Rev 1891 Rev 1892
Line 99... Line 99...
99
 * pkgname must be at least 9 bytes long and is filled with the package name.
99
 * pkgname must be at least 9 bytes long and is filled with the package name.
100
 * the **zipfd pointer is updated with file descriptor of the open (to be
100
 * the **zipfd pointer is updated with file descriptor of the open (to be
101
 * installed) zip file.
101
 * installed) zip file.
102
 * the returned ziplist is guaranteed to have the APPINFO file as first node
102
 * the returned ziplist is guaranteed to have the APPINFO file as first node
103
 * the ziplist is also guaranteed not to contain any directory entries */
103
 * the ziplist is also guaranteed not to contain any directory entries */
104
struct ziplist *pkginstall_preparepackage(char *pkgname, const char *zipfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist) {
104
struct ziplist *pkginstall_preparepackage(char *pkgname, const char *zipfile, int flags, FILE **zipfd, const char *dosdir, const struct customdirs *dirlist, char bootdrive) {
105
  char fname[256];
105
  char fname[256];
106
  struct ziplist *appinfoptr = NULL;
106
  struct ziplist *appinfoptr = NULL;
107
  char *shortfile;
107
  char *shortfile;
108
  struct ziplist *ziplinkedlist = NULL, *curzipnode, *prevzipnode;
108
  struct ziplist *ziplinkedlist = NULL, *curzipnode, *prevzipnode;
109
  struct flist_t *flist = NULL;
109
  struct flist_t *flist = NULL;
Line 153... Line 153...
153
    }
153
    }
154
 
154
 
155
    /* remove 'directory' ZIP entries to avoid false alerts about directory already existing */
155
    /* remove 'directory' ZIP entries to avoid false alerts about directory already existing */
156
    if ((curzipnode->flags & ZIP_FLAG_ISADIR) != 0) goto DELETE_ZIP_NODE;
156
    if ((curzipnode->flags & ZIP_FLAG_ISADIR) != 0) goto DELETE_ZIP_NODE;
157
 
157
 
158
    /* is it a "link file"? remove it - FreeDOS-style link files are not supported */
-
 
159
    if (strstr(curzipnode->filename, "links\\") == curzipnode->filename) goto DELETE_ZIP_NODE;
-
 
160
 
-
 
161
    /* abort if entry is encrypted */
158
    /* abort if entry is encrypted */
162
    if ((curzipnode->flags & ZIP_FLAG_ENCRYPTED) != 0) {
159
    if ((curzipnode->flags & ZIP_FLAG_ENCRYPTED) != 0) {
163
      puts(svarlang_str(3, 20)); /* "ERROR: Package contains an encrypted file:" */
160
      puts(svarlang_str(3, 20)); /* "ERROR: Package contains an encrypted file:" */
164
      printf(" %s\n", curzipnode->filename);
161
      printf(" %s\n", curzipnode->filename);
165
      goto RAII_ERR;
162
      goto RAII_ERR;
Line 246... Line 243...
246
 
243
 
247
  for (curzipnode = ziplinkedlist->nextfile; curzipnode != NULL; curzipnode = curzipnode->nextfile) {
244
  for (curzipnode = ziplinkedlist->nextfile; curzipnode != NULL; curzipnode = curzipnode->nextfile) {
248
 
245
 
249
    /* look out for collisions with already existing files (unless we are
246
    /* look out for collisions with already existing files (unless we are
250
     * updating the package and the local file belongs to it */
247
     * updating the package and the local file belongs to it */
251
    shortfile = computelocalpath(curzipnode->filename, fname, dosdir, dirlist);
248
    shortfile = computelocalpath(curzipnode->filename, fname, dosdir, dirlist, bootdrive);
252
    strcat(fname, shortfile);
249
    strcat(fname, shortfile);
253
    if ((findfileinlist(flist, fname) == NULL) && (fileexists(fname) != 0)) {
250
    if ((findfileinlist(flist, fname) == NULL) && (fileexists(fname) != 0)) {
254
      puts(svarlang_str(3, 9)); /* "ERROR: Package contains a file that already exists locally:" */
251
      puts(svarlang_str(3, 9)); /* "ERROR: Package contains a file that already exists locally:" */
255
      printf(" %s\n", fname);
252
      printf(" %s\n", fname);
256
      goto RAII_ERR;
253
      goto RAII_ERR;
Line 310... Line 307...
310
}
307
}
311
 
308
 
312
 
309
 
313
/* install a package that has been prepared already. returns 0 on success,
310
/* install a package that has been prepared already. returns 0 on success,
314
 * or a negative value on error, or a positive value on warning */
311
 * or a negative value on error, or a positive value on warning */
315
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd) {
312
int pkginstall_installpackage(const char *pkgname, const char *dosdir, const struct customdirs *dirlist, struct ziplist *ziplinkedlist, FILE *zipfd, char bootdrive) {
316
  char buff[256];
313
  char buff[256];
317
  char fulldestfilename[256];
314
  char fulldestfilename[256];
318
  char *shortfile;
315
  char *shortfile;
319
  long filesextractedsuccess = 0, filesextractedfailure = 0;
316
  long filesextractedsuccess = 0, filesextractedfailure = 0;
320
  struct ziplist *curzipnode;
317
  struct ziplist *curzipnode;
Line 347... Line 344...
347
 
344
 
348
  /* write list of files in zip into the lst, and create the directories structure */
345
  /* write list of files in zip into the lst, and create the directories structure */
349
  for (curzipnode = ziplinkedlist->nextfile; curzipnode != NULL; curzipnode = curzipnode->nextfile) {
346
  for (curzipnode = ziplinkedlist->nextfile; curzipnode != NULL; curzipnode = curzipnode->nextfile) {
350
 
347
 
351
    /* substitute paths to custom dirs */
348
    /* substitute paths to custom dirs */
352
    shortfile = computelocalpath(curzipnode->filename, buff, dosdir, dirlist);
349
    shortfile = computelocalpath(curzipnode->filename, buff, dosdir, dirlist, bootdrive);
353
 
350
 
354
    /* log the filename to LSM metadata file + its CRC */
351
    /* log the filename to LSM metadata file + its CRC */
355
    fprintf(lsmfd, "%s%s?%08lX\r\n", buff, shortfile, curzipnode->crc32);
352
    fprintf(lsmfd, "%s%s?%08lX\r\n", buff, shortfile, curzipnode->crc32);
356
 
353
 
357
    /* create the path, just in case it doesn't exist yet */
354
    /* create the path, just in case it doesn't exist yet */