Subversion Repositories SvarDOS

Rev

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

Rev 190 Rev 192
Line 499... Line 499...
499
  }
499
  }
500
}
500
}
501
 
501
 
502
 
502
 
503
/* copy file src into dst, substituting all characters c1 by c2 */
503
/* copy file src into dst, substituting all characters c1 by c2 */
504
static void fcopysub(char *dst, char *src, char c1, char c2) {
504
static void fcopysub(const char *dst, const char *src, char c1, char c2) {
505
  FILE *fdd, *fds;
505
  FILE *fdd, *fds;
506
  int buff;
506
  int buff;
507
  fds = fopen(src, "rb");
507
  fds = fopen(src, "rb");
508
  if (fds == NULL) return;
508
  if (fds == NULL) return;
509
  fdd = fopen(dst, "wb");
509
  fdd = fopen(dst, "wb");
Line 522... Line 522...
522
  fclose(fdd);
522
  fclose(fdd);
523
  fclose(fds);
523
  fclose(fds);
524
}
524
}
525
 
525
 
526
 
526
 
527
static void bootfilesgen(int targetdrv, struct slocales *locales, int cdromdrv) {
527
static void bootfilesgen(char targetdrv, const struct slocales *locales, char cdromdrv) {
528
  char buff[128];
528
  char buff[128];
529
  char buff2[16];
529
  char buff2[16];
530
  char buff3[16];
530
  char buff3[16];
531
  FILE *fd;
531
  FILE *fd;
532
  /*** CONFIG.SYS ***/
532
  /*** CONFIG.SYS ***/
Line 605... Line 605...
605
  /*** PICOTCP ***/
605
  /*** PICOTCP ***/
606
  /*** WATTCP ***/
606
  /*** WATTCP ***/
607
}
607
}
608
 
608
 
609
 
609
 
610
static void installpackages(int targetdrv, int cdromdrv) {
610
static int installpackages(char targetdrv, char cdromdrv) {
611
  char *pkglist[] = {
611
  char pkglist[512];
612
    "A:\\UDVD2", /* this one's not part of CORE, hence it's stored right on the floppy */
-
 
613
    "APPEND",
-
 
614
    "ASSIGN",
-
 
615
    "ATTRIB",
-
 
616
    "CHKDSK",
-
 
617
    "CHOICE",
-
 
618
    "COMMAND",
-
 
619
    "COMP",
-
 
620
    "CPIDOS",
-
 
621
    "CTMOUSE",
-
 
622
    "DEBUG",
-
 
623
    "DEFRAG",
-
 
624
    "DELTREE",
-
 
625
    "DEVLOAD",
-
 
626
    "DISKCOMP",
-
 
627
    "DISKCOPY",
-
 
628
    "DISPLAY",
-
 
629
    "DOSFSCK",
-
 
630
    "EDIT",
-
 
631
    "EDLIN",
-
 
632
    "EXE2BIN",
-
 
633
    "FC",
-
 
634
    "FDAPM",
-
 
635
    "FDISK",
-
 
636
    "FDNPKG",
-
 
637
    "FIND",
-
 
638
    "FORMAT",
-
 
639
    "HELP",
-
 
640
    "HIMEMX",
-
 
641
    "KERNEL",
-
 
642
    "KEYB",
-
 
643
    "KEYB_LAY",
-
 
644
    "LABEL",
-
 
645
    "LBACACHE",
-
 
646
    "MEM",
-
 
647
    "MIRROR",
-
 
648
    "MODE",
-
 
649
    "MORE",
-
 
650
    "MOVE",
-
 
651
    "NANSI",
-
 
652
    "NLSFUNC",
-
 
653
    "PRINT",
-
 
654
    "RDISK",
-
 
655
    "RECOVER",
-
 
656
    "REPLACE",
-
 
657
    "SHARE",
-
 
658
    "SHSUCDX",
-
 
659
    "SORT",
-
 
660
    "SWSUBST",
-
 
661
    "TREE",
-
 
662
    "UNDELETE",
-
 
663
    "XCOPY",
-
 
664
    NULL
-
 
665
  };
-
 
666
  int i, pkglistlen;
612
  int i, pkglistlen;
-
 
613
  size_t pkglistflen;
667
  char buff[64];
614
  char buff[64];
-
 
615
  FILE *fd;
-
 
616
  char *pkgptr;
668
  newscreen(3);
617
  newscreen(3);
669
  /* count how long the pkg list is */
618
  /* load pkg list */
-
 
619
  fd = fopen("install.lst", "rb");
-
 
620
  if (fd == NULL) {
-
 
621
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: INSTALL.LST NOT FOUND", -1);
-
 
622
    input_getkey();
-
 
623
    return(-1);
-
 
624
  }
670
  for (pkglistlen = 0; pkglist[pkglistlen] != NULL; pkglistlen++);
625
  pkglistflen = fread(pkglist, 1, sizeof(pkglist), fd);
-
 
626
  fclose(fd);
-
 
627
  if (pkglistflen == sizeof(pkglist)) {
-
 
628
    video_putstring(10, 30, COLOR_BODY[mono], "ERROR: INSTALL.LST TOO LARGE", -1);
-
 
629
    input_getkey();
-
 
630
    return(-1);
-
 
631
  }
-
 
632
  pkglist[pkglistflen] = 0xff; /* mark the end of list */
-
 
633
  /* replace all \r and \n chars by 0 bytes, and count the number of packages */
-
 
634
  pkglistlen = 0;
-
 
635
  for (i = 0; i < pkglistflen; i++) {
-
 
636
    switch (pkglist[i]) {
-
 
637
      case '\n':
-
 
638
        pkglistlen++;
-
 
639
        /* FALLTHRU */
-
 
640
      case '\r':
-
 
641
        pkglist[i] = 0;
-
 
642
        break;
-
 
643
    }
-
 
644
  }
671
  /* set DOSDIR and friends */
645
  /* set DOSDIR */
672
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVARDOS", targetdrv);
646
  snprintf(buff, sizeof(buff), "%c:\\SYSTEM\\SVARDOS", targetdrv);
673
  setenv("DOSDIR", buff, 1);
647
  setenv("DOSDIR", buff, 1);
674
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
648
  snprintf(buff, sizeof(buff), "%c:\\TEMP", targetdrv);
675
  setenv("TEMP", buff, 1);
649
  setenv("TEMP", buff, 1);
676
  /* install packages */
650
  /* install packages */
-
 
651
  pkgptr = pkglist;
677
  for (i = 0; pkglist[i] != NULL; i++) {
652
  for (i = 0;; i++) {
678
    char buff[128];
653
    char buff[64];
-
 
654
    /* move forward to nearest entry or end of list */
-
 
655
    while (*pkgptr == 0) pkgptr++;
-
 
656
    if (*pkgptr == 0xff) break;
-
 
657
    /* install the package */
679
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkglist[i]);
658
    snprintf(buff, sizeof(buff), kittengets(4, 0, "Installing package %d/%d: %s"), i+1, pkglistlen, pkgptr);
680
    strcat(buff, "       ");
659
    strcat(buff, "       ");
681
    video_putstring(10, 1, COLOR_BODY[mono], buff, -1);
660
    video_putstringfix(10, 1, COLOR_BODY[mono], buff, sizeof(buff));
-
 
661
    snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\%s.ZIP > NUL", cdromdrv, pkgptr);
682
    if (pkglist[i][1] == ':') {
662
    if (system(buff) != 0) {
683
      snprintf(buff, sizeof(buff), "FDINST INSTALL %s.ZIP > NUL", pkglist[i]);
663
      video_putstring(10, 30, COLOR_BODY[mono], "ERROR: PKG INSTALL FAILED", -1);
684
    } else {
664
      input_getkey();
685
      snprintf(buff, sizeof(buff), "FDINST INSTALL %c:\\CORE\\%s.ZIP > NUL", cdromdrv, pkglist[i]);
665
      return(-1);
686
    }
666
    }
-
 
667
    /* jump to next entry or end of list */
-
 
668
    while ((*pkgptr != 0) && (*pkgptr != 0xff)) pkgptr++;
687
    system(buff);
669
    if (*pkgptr == 0xff) break;
688
  }
670
  }
-
 
671
  return(0);
689
}
672
}
690
 
673
 
691
 
674
 
692
static void finalreboot(void) {
675
static void finalreboot(void) {
693
  int y = 9;
676
  int y = 9;
Line 697... Line 680...
697
  input_getkey();
680
  input_getkey();
698
  reboot();
681
  reboot();
699
}
682
}
700
 
683
 
701
 
684
 
702
static void loadcp(struct slocales *locales) {
685
static void loadcp(const struct slocales *locales) {
703
  char buff[64];
686
  char buff[64];
704
  if (locales->codepage == 437) return;
687
  if (locales->codepage == 437) return;
705
  video_movecursor(1, 0);
688
  video_movecursor(1, 0);
706
  if (locales->egafile == 1) {
689
  if (locales->egafile == 1) {
707
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA.CPX) > NUL", locales->codepage);
690
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) A:\\EGA.CPX) > NUL", locales->codepage);
Line 727... Line 710...
727
/* checks CD drive drv for the presence of the SvarDOS install CD
710
/* checks CD drive drv for the presence of the SvarDOS install CD
728
 * returns 0 if found, non-zero otherwise */
711
 * returns 0 if found, non-zero otherwise */
729
static int checkcd(char drv) {
712
static int checkcd(char drv) {
730
  FILE *fd;
713
  FILE *fd;
731
  char fname[32];
714
  char fname[32];
732
  snprintf(fname, sizeof(fname), "%c:\\CORE\\MEM.ZIP", drv);
715
  snprintf(fname, sizeof(fname), "%c:\\MEM.ZIP", drv);
733
  fd = fopen(fname, "rb");
716
  fd = fopen(fname, "rb");
734
  if (fd == NULL) return(-1);
717
  if (fd == NULL) return(-1);
735
  fclose(fd);
718
  fclose(fd);
736
  return(0);
719
  return(0);
737
}
720
}
Line 777... Line 760...
777
  if (action == MENUPREV) goto SelectLang;
760
  if (action == MENUPREV) goto SelectLang;
778
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
761
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
779
  if (targetdrv == MENUQUIT) goto Quit;
762
  if (targetdrv == MENUQUIT) goto Quit;
780
  if (targetdrv == MENUPREV) goto WelcomeScreen;
763
  if (targetdrv == MENUPREV) goto WelcomeScreen;
781
  /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
764
  /*askaboutsources();*/ /* IF sources are available, ask if installing with them */
782
  installpackages(targetdrv, cdromdrv);    /* install packages */
765
  if (installpackages(targetdrv, cdromdrv) != 0) goto Quit;    /* install packages */
783
  bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
766
  bootfilesgen(targetdrv, &locales, cdromdrv); /* generate boot files and other configurations */
784
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
767
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
785
  /*netcfg();*/ /* basic networking config */
768
  /*netcfg();*/ /* basic networking config */
786
  finalreboot(); /* remove the CD and reboot */
769
  finalreboot(); /* remove the CD and reboot */
787
 
770