Subversion Repositories SvarDOS

Rev

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

Rev 1928 Rev 1930
Line 75... Line 75...
75
  unsigned short keybid;
75
  unsigned short keybid;
76
  unsigned short countryid; /* 1=USA, 33=FR, 48=PL, etc */
76
  unsigned short countryid; /* 1=USA, 33=FR, 48=PL, etc */
77
};
77
};
78
 
78
 
79
 
79
 
-
 
80
/* returns the DOS boot drive letter ('A', 'B', 'C', etc) */
-
 
81
static unsigned char GETDOSBOOTDRIVE(void);
-
 
82
#pragma aux GETDOSBOOTDRIVE = \
-
 
83
"mov ax, 0x3305" /* int 0x21,AX=3305 - get boot drive (MS-DOS 4.0+) */ \
-
 
84
"int 0x21" \
-
 
85
"jnc GOOD" \
-
 
86
"mov dl, 3"      /* fall back to "C" on error (DOS 3.x...) */ \
-
 
87
"GOOD:" \
-
 
88
"add dl, '@'"    /* convert the drive id (A=1, B=2...) into a drive letter */ \
-
 
89
modify [ax] \
-
 
90
value [dl]
-
 
91
 
-
 
92
 
80
/* install a dummy int24h handler that always fails. this is to avoid the
93
/* install a dummy int24h handler that always fails. this is to avoid the
81
 * annoying "abort, retry, fail... DOS messages. */
94
 * annoying "abort, retry, fail... DOS messages. */
82
static void install_int24(void) {
95
static void install_int24(void) {
83
  static unsigned char handler[] = { /* contains machine code instructions */
96
  static unsigned char handler[] = { /* contains machine code instructions */
84
    0xB0, 0x03,  /* mov al, 3   ; tell DOS the action has to FAIL   */
97
    0xB0, 0x03,  /* mov al, 3   ; tell DOS the action has to FAIL   */
Line 534... Line 547...
534
"int 0x21" \
547
"int 0x21" \
535
modify [ah] \
548
modify [ah] \
536
value [al]
549
value [al]
537
 
550
 
538
 
551
 
-
 
552
/* replace all occurences of char a by char b in s */
-
 
553
static void strtr(char *s, char a, char b) {
-
 
554
  for (;*s != 0; s++) {
-
 
555
    if (*s == a) *s = b;
-
 
556
  }
-
 
557
}
-
 
558
 
-
 
559
 
539
/* tries to write an empty file to drive.
560
/* tries to write an empty file to drive.
540
 * asks DOS to inhibit the int 24h handler for this job, so erros are
561
 * asks DOS to inhibit the int 24h handler for this job, so erros are
541
 * gracefully reported - unfortunately this does not work under FreeDOS because
562
 * gracefully reported - unfortunately this does not work under FreeDOS because
542
 * the DOS-C kernel does not implement the required flag.
563
 * the DOS-C kernel does not implement the required flag.
543
 * returns 0 on success (ie. "disk exists and is writeable"). */
564
 * returns 0 on success (ie. "disk exists and is writeable"). */
Line 580... Line 601...
580
  }
601
  }
581
  return(result);
602
  return(result);
582
}
603
}
583
 
604
 
584
 
605
 
585
static int preparedrive(char sourcedrv) {
606
static int preparedrive(void) {
586
  int driveremovable;
607
  int driveremovable;
587
  int selecteddrive = 3; /* default to 'C:' */
608
  int selecteddrive = 3; /* default to 'C:' */
588
  int cselecteddrive;
609
  int cselecteddrive;
589
  int ds;
610
  int ds;
590
  int choice;
611
  int choice;
Line 705... Line 726...
705
      snprintf(buff, sizeof(buff), svarlang_strid(0x0306), cselecteddrive); /* "The installation of SvarDOS to %c: is about to begin." */
726
      snprintf(buff, sizeof(buff), svarlang_strid(0x0306), cselecteddrive); /* "The installation of SvarDOS to %c: is about to begin." */
706
      mdr_cout_str(7, 40 - (strlen(buff) / 2), buff, COLOR_BODY, 80);
727
      mdr_cout_str(7, 40 - (strlen(buff) / 2), buff, COLOR_BODY, 80);
707
      choice = menuselect(10, 2, list, -1);
728
      choice = menuselect(10, 2, list, -1);
708
      if (choice < 0) return(MENUPREV);
729
      if (choice < 0) return(MENUPREV);
709
      if (choice == 1) return(MENUQUIT);
730
      if (choice == 1) return(MENUQUIT);
710
      snprintf(buff, sizeof(buff), "SYS %c: %c: > NUL", sourcedrv, cselecteddrive);
731
      snprintf(buff, sizeof(buff), "SYS %c: > NUL", cselecteddrive);
711
      exec(buff);
732
      exec(buff);
712
      sprintf(buff, "FDISK /MBR %d", driveid);
733
      sprintf(buff, "FDISK /MBR %d", driveid);
713
      exec(buff);
734
      exec(buff);
714
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
735
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
715
      mkdir(buff);
736
      mkdir(buff);
Line 747... Line 768...
747
    fprintf(fd, "\r\n");
768
    fprintf(fd, "\r\n");
748
  }
769
  }
749
}
770
}
750
 
771
 
751
 
772
 
-
 
773
/* generates configuration files on the dest drive, this is run once system booted successfully */
752
static void bootfilesgen(char targetdrv, const struct slocales *locales) {
774
static void bootfilesgen(const struct slocales *locales) {
753
  char buff[128];
775
  char buff[128];
754
  FILE *fd;
776
  FILE *fd;
-
 
777
  unsigned char bootdrv = GETDOSBOOTDRIVE();
-
 
778
 
-
 
779
  /****************
755
  /*** CONFIG.SYS ***/
780
   * CONFIG.SYS ***
-
 
781
   ****************/
756
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\CONFIG.SYS", targetdrv);
782
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\CONFIG.SYS", bootdrv);
757
  fd = fopen(buff, "wb");
783
  fd = fopen(buff, "wb");
758
  if (fd == NULL) return;
784
  if (fd == NULL) return;
759
  fprintf(fd, "; SvarDOS kernel configuration\r\n"
785
  fprintf(fd, "; SvarDOS kernel configuration\r\n"
760
              "\r\n"
786
              "\r\n"
761
              "; highest allowed drive letter\r\n"
787
              "; highest allowed drive letter\r\n"
Line 763... Line 789...
763
              "\r\n"
789
              "\r\n"
764
              "; max. number of files that programs are allowed to open simultaneously\r\n"
790
              "; max. number of files that programs are allowed to open simultaneously\r\n"
765
              "FILES=25\r\n");
791
              "FILES=25\r\n");
766
  fprintf(fd, "\r\n"
792
  fprintf(fd, "\r\n"
767
              "; XMS memory driver\r\n"
793
              "; XMS memory driver\r\n"
768
              "DEVICE=C:\\SVARDOS\\HIMEMX.EXE\r\n");
794
              "DEVICE=%c:\\SVARDOS\\HIMEMX.EXE\r\n", bootdrv);
769
  fprintf(fd, "\r\n"
795
  fprintf(fd, "\r\n"
770
              "; try moving DOS to upper memory, then to high memory\r\n"
796
              "; try moving DOS to upper memory, then to high memory\r\n"
771
              "DOS=UMB,HIGH\r\n");
797
              "DOS=UMB,HIGH\r\n");
772
  fprintf(fd, "\r\n"
798
  fprintf(fd, "\r\n"
773
              "; command interpreter (shell) location and default environment size\r\n"
799
              "; command interpreter (shell) location and environment size\r\n"
774
              "SHELL=C:\\COMMAND.COM /E:512 /P\r\n");
800
              "SHELL=%c:\\COMMAND.COM /E:512 /P\r\n", bootdrv);
775
  fprintf(fd, "\r\n"
801
  fprintf(fd, "\r\n"
776
              "; NLS configuration\r\n");
802
              "; NLS configuration\r\n");
777
  if (locales != NULL) {
803
  if (locales != NULL) {
778
    fprintf(fd, "COUNTRY=%03u,%u,C:\\SVARDOS\\COUNTRY.SYS\r\n", locales->countryid, locales->codepage);
804
    fprintf(fd, "COUNTRY=%03u,%u,%c:\\SVARDOS\\COUNTRY.SYS\r\n", locales->countryid, locales->codepage, bootdrv);
779
  } else {
805
  } else {
780
    fprintf(fd, "COUNTRY=001,437,C:\\SVARDOS\\COUNTRY.SYS\r\n");
806
    fprintf(fd, "COUNTRY=001,437,%c:\\SVARDOS\\COUNTRY.SYS\r\n", bootdrv);
781
  }
807
  }
782
  fprintf(fd, "\r\n"
808
  fprintf(fd, "\r\n"
783
              "; CD-ROM driver initialization\r\n"
809
              "; CD-ROM driver initialization\r\n"
784
              ";DEVICE=C:\\DRIVERS\\VIDECDD\\VIDE-CDD.SYS /D:SVCD0001\r\n");
810
              ";DEVICE=%c:\\DRIVERS\\VIDECDD\\VIDE-CDD.SYS /D:SVCD0001\r\n", bootdrv);
785
  fclose(fd);
811
  fclose(fd);
-
 
812
 
-
 
813
  /****************
786
  /*** AUTOEXEC.BAT ***/
814
   * AUTOEXEC.BAT *
-
 
815
   ****************/
787
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\AUTOEXEC.BAT", targetdrv);
816
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\AUTOEXEC.BAT", bootdrv);
788
  fd = fopen(buff, "wb");
817
  fd = fopen(buff, "wb");
789
  if (fd == NULL) return;
818
  if (fd == NULL) {
-
 
819
    return;
-
 
820
  } else {
-
 
821
    char *autoexec_bat1 =
790
  fprintf(fd, "@ECHO OFF\r\n");
822
      "@ECHO OFF\r\n"
791
  fprintf(fd, "SET TEMP=C:\\TEMP\r\n");
823
      "SET TEMP=@:\\TEMP\r\n"
792
  fprintf(fd, "SET DOSDIR=C:\\SVARDOS\r\n");
824
      "SET DOSDIR=@:\\SVARDOS\r\n"
793
  fprintf(fd, "SET NLSPATH=%%DOSDIR%%\\NLS\r\n");
825
      "SET NLSPATH=%DOSDIR%\\NLS\r\n"
794
  fprintf(fd, "SET DIRCMD=/O/P\r\n");
826
      "SET DIRCMD=/O/P\r\n"
795
  fprintf(fd, "SET WATTCP.CFG=%%DOSDIR%%\\CFG\r\n");
827
      "SET WATTCP.CFG=%DOSDIR%\\CFG\r\n"
796
  fprintf(fd, "PATH %%DOSDIR%%\r\n");
828
      "PATH %DOSDIR%\r\n"
797
  fprintf(fd, "PROMPT $P$G\r\n");
829
      "PROMPT $P$G\r\n"
798
  fprintf(fd, "\r\n"
830
      "\r\n"
799
              "REM enable CPU power saving\r\n"
831
      "REM enable CPU power saving\r\n"
800
              "FDAPM ADV:REG\r\n");
832
      "FDAPM ADV:REG\r\n"
801
  fprintf(fd, "\r\n");
833
      "\r\n";
802
  if (locales != NULL) genlocalesconf(fd, locales);
-
 
803
  fprintf(fd, "\r\n");
834
    char *autoexec_bat2 =
804
  fprintf(fd, "REM Uncomment the line below for CDROM support\r\n");
835
      "REM Uncomment the line below for CDROM support\r\n"
805
  fprintf(fd, "REM SHSUCDX /d:SVCD0001\r\n");
836
      "REM SHSUCDX /d:SVCD0001\r\n"
806
  fprintf(fd, "\r\n");
837
      "\r\n"
807
  fprintf(fd, "ECHO.\r\n");
838
      "ECHO.\r\n";
-
 
839
 
-
 
840
    /* replace all '@' occurences by bootdrive */
-
 
841
    strtr(autoexec_bat1, '@', bootdrv);
-
 
842
 
-
 
843
    /* write all to file */
-
 
844
    fputs(autoexec_bat1, fd);
-
 
845
    if (locales != NULL) genlocalesconf(fd, locales);
-
 
846
    fputs(autoexec_bat2, fd);
-
 
847
 
808
  fprintf(fd, "ECHO %s\r\n", svarlang_strid(0x0600)); /* "Welcome to SvarDOS!" */
848
    fprintf(fd, "ECHO %s\r\n", svarlang_strid(0x0600)); /* "Welcome to SvarDOS!" */
809
  fclose(fd);
849
    fclose(fd);
-
 
850
  }
-
 
851
 
810
  /*** CREATE DIRECTORY FOR CONFIGURATION FILES ***/
852
  /*** CREATE DIRECTORY FOR CONFIGURATION FILES ***/
811
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS", targetdrv);
853
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS", bootdrv);
812
  mkdir(buff);
854
  mkdir(buff);
813
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG", targetdrv);
855
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG", bootdrv);
814
  mkdir(buff);
856
  mkdir(buff);
-
 
857
 
-
 
858
  /****************
815
  /*** PKG.CFG ***/
859
   * PKG.CFG      *
-
 
860
   ****************/
816
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\PKG.CFG", targetdrv);
861
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\PKG.CFG", bootdrv);
817
  fd = fopen(buff, "wb");
862
  fd = fopen(buff, "wb");
818
  if (fd == NULL) return;
863
  if (fd == NULL) {
-
 
864
    return;
-
 
865
  } else {
-
 
866
    char *pkg_cfg =
819
  fprintf(fd, "# pkg config file - specifies locations where packages should be installed\r\n"
867
      "# pkg config file - specifies locations where packages should be installed\r\n"
-
 
868
      "\r\n"
-
 
869
      "# System boot drive\r\n"
-
 
870
      "bootdrive = @\r\n"
820
              "\r\n"
871
      "\r\n"
821
              "# DOS core binaries\r\n"
872
      "# DOS core binaries\r\n"
822
              "DIR BIN C:\\SVARDOS\r\n"
873
      "DIR BIN @:\\SVARDOS\r\n"
823
              "\r\n"
874
      "\r\n"
824
              "# Programs\r\n"
875
      "# Programs\r\n"
825
              "DIR PROGS C:\\\r\n"
876
      "DIR PROGS @:\\\r\n"
826
              "\r\n"
877
      "\r\n"
827
              "# Games \r\n"
878
      "# Games \r\n"
828
              "DIR GAMES C:\\\r\n"
879
      "DIR GAMES @:\\\r\n"
829
              "\r\n"
880
      "\r\n"
830
              "# Drivers\r\n"
881
      "# Drivers\r\n"
831
              "DIR DRIVERS C:\\DRIVERS\r\n"
882
      "DIR DRIVERS @:\\DRIVERS\r\n"
832
              "\r\n"
883
      "\r\n"
833
              "# Development tools\r\n"
884
      "# Development tools\r\n"
834
              "DIR DEVEL C:\\DEVEL\r\n");
885
      "DIR DEVEL @:\\DEVEL\r\n";
-
 
886
 
-
 
887
    /* replace all @ by the actual boot drive */
-
 
888
    strtr(pkg_cfg, '@', bootdrv);
-
 
889
 
-
 
890
    /* write to file */
-
 
891
    fputs(pkg_cfg, fd);
835
  fclose(fd);
892
    fclose(fd);
836
  /*** COUNTRY.SYS ***/
893
  }
-
 
894
 
837
  /*** PICOTCP ***/
895
  /*** PICOTCP ***/
-
 
896
  /* TODO (or not? maybe not that useful) */
-
 
897
 
838
  /*** WATTCP ***/
898
  /*** WATTCP ***/
839
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\WATTCP.CFG", targetdrv);
899
  snprintf(buff, sizeof(buff), "%c:\\SVARDOS\\CFG\\WATTCP.CFG", bootdrv);
840
  fd = fopen(buff, "wb");
900
  fd = fopen(buff, "wb");
841
  if (fd == NULL) return;
901
  if (fd == NULL) return;
842
  fprintf(fd, "my_ip = dhcp\r\n"
902
  fprintf(fd, "my_ip = dhcp\r\n"
843
              "#my_ip = 192.168.0.7\r\n"
903
              "#my_ip = 192.168.0.7\r\n"
844
              "#netmask = 255.255.255.0\r\n"
904
              "#netmask = 255.255.255.0\r\n"
Line 847... Line 907...
847
              "#gateway = 192.168.0.1\r\n");
907
              "#gateway = 192.168.0.1\r\n");
848
  fclose(fd);
908
  fclose(fd);
849
}
909
}
850
 
910
 
851
 
911
 
852
static int installpackages(char targetdrv, char srcdrv, const struct slocales *locales) {
912
static int copypackages(char targetdrv, const struct slocales *locales) {
853
  char pkglist[512];
913
  char pkglist[512];
854
  int i, pkglistlen;
914
  int i, pkglistlen;
855
  size_t pkglistflen;
915
  size_t pkglistflen;
856
  char buff[1024]; /* must be *at least* 1 sector big for efficient file copying */
916
  char buff[1024]; /* must be *at least* 1 sector big for efficient file copying */
857
  FILE *fd = NULL;
917
  FILE *fd = NULL;
Line 884... Line 944...
884
      case '\r':
944
      case '\r':
885
        pkglist[i] = 0;
945
        pkglist[i] = 0;
886
        break;
946
        break;
887
    }
947
    }
888
  }
948
  }
-
 
949
 
889
  /* copy pkg.exe to the new drive, along with all packages */
950
  /* copy pkg.exe, install.com and install.lng to the new drive, along with all packages */
890
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\pkg.exe", targetdrv);
951
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\PKG.EXE", targetdrv);
-
 
952
  fcopy(buff, buff + 8, buff, sizeof(buff));
-
 
953
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\INSTALL.COM", targetdrv);
-
 
954
  fcopy(buff, buff + 8, buff, sizeof(buff));
891
  snprintf(buff + 64, sizeof(buff) - 64, "%c:\\pkg.exe", srcdrv);
955
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\INSTALL.LNG", targetdrv);
892
  fcopy(buff, buff + 64, buff, sizeof(buff));
956
  fcopy(buff, buff + 8, buff, sizeof(buff));
893
 
957
 
894
  /* open the post-install autoexec.bat and prepare initial instructions */
958
  /* open the post-install autoexec.bat and prepare initial instructions */
895
  snprintf(buff, sizeof(buff), "%c:\\temp\\postinst.bat", targetdrv);
959
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\POSTINST.BAT", targetdrv);
896
  fd = fopen(buff, "wb");
960
  fd = fopen(buff, "wb");
897
  if (fd == NULL) return(-1);
961
  if (fd == NULL) return(-1);
-
 
962
  fprintf(fd, "@ECHO OFF\r\n"
-
 
963
              "INSTALL"  /* installer will run in 2nd stage (generating pkg.cfg and stuff) */
898
  fprintf(fd, "@ECHO OFF\r\nECHO INSTALLING SVARDOS BUILD %s\r\n", BUILDSTRING);
964
              "ECHO INSTALLING SVARDOS BUILD %s\r\n", BUILDSTRING);
899
 
965
 
900
  /* move COMMAND.COM so it does not clashes with the installation of the SVARCOM package */
966
  /* move COMMAND.COM so it does not clashes with the installation of the SVARCOM package */
901
  fprintf(fd, "COPY \\COMMAND.COM \\CMD.COM\r\n");
967
  fprintf(fd, "COPY \\COMMAND.COM \\CMD.COM\r\n");
902
  fprintf(fd, "SET COMSPEC=C:\\CMD.COM\r\n"); /* POSTINST.BAT is executed after system is rebooted, so the system drive is always C: */
968
  fprintf(fd, "SET COMSPEC=\\CMD.COM\r\n"); /* no drive letter because I do not know it */
903
  fprintf(fd, "DEL \\COMMAND.COM\r\n");
969
  fprintf(fd, "DEL \\COMMAND.COM\r\n");
904
 
970
 
905
  /* delete the temporary KERNEL.SYS - it will be properly installed from the package in a short moment */
971
  /* delete the temporary KERNEL.SYS - it will be properly installed from the package in a short moment */
906
  fprintf(fd, "DEL \\KERNEL.SYS\r\n");
972
  fprintf(fd, "DEL \\KERNEL.SYS\r\n");
907
 
973
 
Line 933... Line 999...
933
    snprintf(buff, sizeof(buff), svarlang_strid(0x0400), i+1, pkglistlen, pkgptr); /* "Installing package %d/%d: %s" */
999
    snprintf(buff, sizeof(buff), svarlang_strid(0x0400), i+1, pkglistlen, pkgptr); /* "Installing package %d/%d: %s" */
934
    strcat(buff, "       ");
1000
    strcat(buff, "       ");
935
    mdr_cout_str(10, 1, buff, COLOR_BODY, 40);
1001
    mdr_cout_str(10, 1, buff, COLOR_BODY, 40);
936
 
1002
 
937
    /* proceed with package copy */
1003
    /* proceed with package copy */
938
    sprintf(buff, "%c:\\temp\\%s.svp", targetdrv, pkgptr);
1004
    sprintf(buff, "%c:\\TEMP\\%s.svp", targetdrv, pkgptr);
939
    if (fcopy(buff, buff + 7, buff, sizeof(buff)) != 0) {
1005
    if (fcopy(buff, buff + 8, buff, sizeof(buff)) != 0) {
940
      mdr_cout_str(10, 30, "READ ERROR", COLOR_BODY, 80);
1006
      mdr_cout_str(10, 30, "READ ERROR", COLOR_BODY, 80);
941
      mdr_dos_getkey();
1007
      mdr_dos_getkey();
942
      fclose(fd);
1008
      fclose(fd);
943
      return(-1);
1009
      return(-1);
944
    }
1010
    }
Line 952... Line 1018...
952
  }
1018
  }
953
  /* set up locales so the "installation over" message is nicely displayed */
1019
  /* set up locales so the "installation over" message is nicely displayed */
954
  genlocalesconf(fd, locales);
1020
  genlocalesconf(fd, locales);
955
  /* replace autoexec.bat and config.sys now and write some nice message on screen */
1021
  /* replace autoexec.bat and config.sys now and write some nice message on screen */
956
  fprintf(fd, "DEL pkg.exe\r\n"
1022
  fprintf(fd, "DEL pkg.exe\r\n"
957
              "DEL C:\\CONFIG.SYS\r\n"
1023
              "DEL install.com\r\n"
958
              "COPY CONFIG.SYS C:\\\r\n"
1024
              "COPY CONFIG.SYS \\\r\n"
959
              "DEL CONFIG.SYS\r\n"
1025
              "DEL CONFIG.SYS\r\n"
960
              "DEL C:\\AUTOEXEC.BAT\r\n"
1026
              "DEL \\AUTOEXEC.BAT\r\n"
961
              "COPY AUTOEXEC.BAT C:\\\r\n"
1027
              "COPY AUTOEXEC.BAT \\\r\n"
962
              "DEL AUTOEXEC.BAT\r\n"
1028
              "DEL AUTOEXEC.BAT\r\n"
963
              "SET COMSPEC=C:\\COMMAND.COM\r\n"
1029
              "SET COMSPEC=\\COMMAND.COM\r\n"
964
              "DEL \\CMD.COM\r\n");
1030
              "DEL \\CMD.COM\r\n");
965
  /* print out the "installation over" message */
1031
  /* print out the "installation over" message */
966
  fprintf(fd, "ECHO.\r\n"
1032
  fprintf(fd, "ECHO.\r\n"
967
              "ECHO ");
1033
              "ECHO ");
968
  fprintf(fd, svarlang_strid(0x0502), BUILDSTRING); /* "SvarDOS installation is over. Please restart your computer now" */
1034
  fprintf(fd, svarlang_strid(0x0502), BUILDSTRING); /* "SvarDOS installation is over. Please restart your computer now" */
969
  fprintf(fd, "\r\n"
1035
  fprintf(fd, "\r\n"
970
              "ECHO.\r\n");
1036
              "ECHO.\r\n");
971
  fclose(fd);
1037
  fclose(fd);
972
 
1038
 
973
  /* dummy config.sys with a SHELL directive, EDR does not call command.com
-
 
974
   * with /P otherwise, see https://github.com/SvarDOS/edrdos/issues/74 */
-
 
975
  snprintf(buff, sizeof(buff), "%c:\\config.sys", targetdrv);
-
 
976
  fd = fopen(buff, "wb");
-
 
977
  if (fd == NULL) return(-1);
-
 
978
  fprintf(fd, "SHELL=C:\\COMMAND.COM /P\r\n");
-
 
979
  fclose(fd);
-
 
980
 
-
 
981
  /* prepare a dummy autoexec.bat that will call temp\postinst.bat */
1039
  /* prepare a dummy autoexec.bat that will call temp\postinst.bat */
982
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", targetdrv);
1040
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", targetdrv);
983
  fd = fopen(buff, "wb");
1041
  fd = fopen(buff, "wb");
984
  if (fd == NULL) return(-1);
1042
  if (fd == NULL) return(-1);
985
  fprintf(fd, "@ECHO OFF\r\n"
1043
  fprintf(fd, "@ECHO OFF\r\n"
986
              "SET DOSDIR=C:\\SVARDOS\r\n"
1044
              "SET DOSDIR=\\SVARDOS\r\n"
987
              "SET NLSPATH=%%DOSDIR%%\\NLS\r\n"
1045
              "SET NLSPATH=%%DOSDIR%%\\NLS\r\n"
988
              "PATH %%DOSDIR%%\r\n");
1046
              "PATH %%DOSDIR%%\r\n");
-
 
1047
  genlocalesconf(fd, locales);
989
  fprintf(fd, "CD TEMP\r\n"
1048
  fprintf(fd, "CD TEMP\r\n"
990
              "postinst.bat\r\n");
1049
              "postinst.bat\r\n");
991
  fclose(fd);
1050
  fclose(fd);
992
 
1051
 
993
  return(0);
1052
  return(0);
Line 1034... Line 1093...
1034
 
1093
 
1035
int main(void) {
1094
int main(void) {
1036
  struct slocales locales_data;
1095
  struct slocales locales_data;
1037
  struct slocales *locales = &locales_data;
1096
  struct slocales *locales = &locales_data;
1038
  int targetdrv;
1097
  int targetdrv;
1039
  int sourcedrv;
-
 
1040
  int action;
1098
  int action;
1041
 
1099
 
1042
  /* setup an internal int 24h handler ("always fail") so DOS does not output
1100
  /* setup an internal int 24h handler ("always fail") so DOS does not output
1043
   * the ugly "abort, retry, fail" messages */
1101
   * the ugly "abort, retry, fail" messages */
1044
  install_int24();
1102
  install_int24();
1045
 
1103
 
-
 
1104
  /* init screen and detect mono adapters */
-
 
1105
  if (mdr_cout_init(NULL, NULL) == 0) {
-
 
1106
    /* overload color scheme with mono settings */
-
 
1107
    COLOR_TITLEBAR = 0x70;
-
 
1108
    COLOR_TITLEVER = 0x70;
-
 
1109
    COLOR_BODY = 0x07;
-
 
1110
    COLOR_BODYWARN = 0x07;
-
 
1111
    COLOR_SELECT = 0x70;
-
 
1112
    COLOR_SELECTCUR = 0x07;
-
 
1113
  }
-
 
1114
 
-
 
1115
  /* is it stage 2 of the installation? */
-
 
1116
  if (fileexists("postinst.bat")) goto GENCONF;
-
 
1117
 
1046
  /* read the svardos build revision (from floppy label) */
1118
  /* read the svardos build revision (from floppy label) */
1047
  {
1119
  {
1048
    const char *fspec = "*.*";
1120
    const char *fspec = "*.*";
1049
    const char *res = (void*)0x9E; /* default DTA is at PSP:80h, field 1Eh of DTA is the ASCIZ file name */
1121
    const char *res = (void*)0x9E; /* default DTA is at PSP:80h, field 1Eh of DTA is the ASCIZ file name */
1050
 
1122
 
Line 1066... Line 1138...
1066
    }
1138
    }
1067
 
1139
 
1068
    memcpy(BUILDSTRING, res, 12);
1140
    memcpy(BUILDSTRING, res, 12);
1069
  }
1141
  }
1070
 
1142
 
1071
  sourcedrv = get_cur_drive() + 'A';
-
 
1072
 
-
 
1073
  /* init screen and detect mono adapters */
-
 
1074
  if (mdr_cout_init(NULL, NULL) == 0) {
-
 
1075
    /* overload color scheme with mono settings */
-
 
1076
    COLOR_TITLEBAR = 0x70;
-
 
1077
    COLOR_TITLEVER = 0x70;
-
 
1078
    COLOR_BODY = 0x07;
-
 
1079
    COLOR_BODYWARN = 0x07;
-
 
1080
    COLOR_SELECT = 0x70;
-
 
1081
    COLOR_SELECTCUR = 0x07;
-
 
1082
  }
-
 
1083
 
-
 
1084
  /* am I EN-only? */
1143
  /* am I EN-only? */
1085
  if (!fileexists("INSTALL.LNG")) locales = NULL;
1144
  if (!fileexists("INSTALL.LNG")) locales = NULL;
1086
 
1145
 
1087
 SelectLang:
1146
 SelectLang:
1088
  if (locales == NULL) goto WelcomeScreen;
1147
  if (locales == NULL) goto WelcomeScreen;
1089
  action = selectlang(locales); /* welcome to svardos, select your language */
1148
  action = selectlang(locales); /* welcome to svardos, select your language */
1090
  if (action != MENUNEXT) goto Quit;
1149
  if (action != MENUNEXT) goto QUIT;
1091
  loadcp(locales);
1150
  loadcp(locales);
1092
  svarlang_load("INSTALL.LNG", locales->lang); /* NLS support */
1151
  svarlang_load("INSTALL.LNG", locales->lang); /* NLS support */
1093
 
1152
 
1094
  action = selectkeyb(locales);  /* what keyb layout should we use? */
1153
  action = selectkeyb(locales);  /* what keyb layout should we use? */
1095
  if (action == MENUQUIT) goto Quit;
1154
  if (action == MENUQUIT) goto QUIT;
1096
  if (action == MENUPREV) goto SelectLang;
1155
  if (action == MENUPREV) goto SelectLang;
1097
 
1156
 
1098
 WelcomeScreen:
1157
 WelcomeScreen:
1099
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
1158
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
1100
  if (action == MENUQUIT) goto Quit;
1159
  if (action == MENUQUIT) goto QUIT;
1101
  if (action == MENUPREV) {
1160
  if (action == MENUPREV) {
1102
    if (locales == NULL) goto Quit;
1161
    if (locales == NULL) goto QUIT;
1103
    goto SelectLang;
1162
    goto SelectLang;
1104
  }
1163
  }
1105
 
1164
 
1106
  targetdrv = preparedrive(sourcedrv); /* what drive should we install from? check avail. space */
1165
  targetdrv = preparedrive(); /* what drive should we install to? check avail. space */
1107
  if (targetdrv == MENUQUIT) goto Quit;
1166
  if (targetdrv == MENUQUIT) goto QUIT;
1108
  if (targetdrv == MENUPREV) goto WelcomeScreen;
1167
  if (targetdrv == MENUPREV) goto WelcomeScreen;
1109
  bootfilesgen(targetdrv, locales); /* generate boot files and other configurations */
-
 
1110
  if (installpackages(targetdrv, sourcedrv, locales) != 0) goto Quit;    /* install packages */
1168
  if (copypackages(targetdrv, locales) != 0) goto QUIT;    /* copy packages to dst drive */
1111
  /*localcfg();*/ /* show local params (currency, etc), and propose to change them (based on localcfg) */
1169
  finalreboot(); /* remove the install medium and reboot */
-
 
1170
 
-
 
1171
  goto QUIT;
-
 
1172
 
1112
  /*netcfg();*/ /* basic networking config */
1173
 GENCONF: /* second stage of the installation (run from the destination disk) */
1113
  finalreboot(); /* remove the CD and reboot */
1174
  bootfilesgen(locales); /* generate boot files and other configurations */
1114
 
1175
 
1115
 Quit:
1176
 QUIT:
1116
  mdr_cout_locate(0, 0);
1177
  mdr_cout_locate(0, 0);
1117
  mdr_cout_close();
1178
  mdr_cout_close();
1118
  return(0);
1179
  return(0);
1119
}
1180
}