Subversion Repositories SvarDOS

Rev

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

Rev 1949 Rev 1950
Line 925... Line 925...
925
 
925
 
926
 
926
 
927
/* generates locales-related configurations and writes them to file (this
927
/* generates locales-related configurations and writes them to file (this
928
 * is used to compute autoexec.bat content) */
928
 * is used to compute autoexec.bat content) */
929
static void genlocalesconf(FILE *fd, const struct slocales *locales) {
929
static void genlocalesconf(FILE *fd, const struct slocales *locales) {
930
  if (locales == NULL) return;
-
 
931
 
930
 
932
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
931
  fprintf(fd, "SET LANG=%s\r\n", locales->lang);
933
 
932
 
934
  if (locales->egafile > 0) {
933
  if (locales->egafile > 0) {
935
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
934
    fprintf(fd, "DISPLAY CON=(EGA,,1)\r\n");
Line 963... Line 962...
963
value [al]
962
value [al]
964
 
963
 
965
 
964
 
966
/* generates configuration files on the dest drive, this is run once system
965
/* generates configuration files on the dest drive, this is run once system
967
 * booted successfully on the dst drive (postinst stage) */
966
 * booted successfully on the dst drive (postinst stage) */
968
static void bootfilesgen(const struct slocales *locales) {
967
static void bootfilesgen(void) {
969
  char buff[128];
968
  char buff[128];
970
  FILE *fd;
969
  FILE *fd;
971
  unsigned char bootdrv = get_cur_drive() + 'A';
970
  unsigned char bootdrv = get_cur_drive() + 'A';
-
 
971
  struct slocales locales;
-
 
972
 
-
 
973
  /* load locales from ZLOCALES.DAT */
-
 
974
  fd = fopen("ZLOCALES.DAT", "rb");
-
 
975
  if (fd == NULL) return;
-
 
976
  fread(&locales, sizeof(struct slocales), 1, fd);
-
 
977
  fclose(fd);
-
 
978
 
-
 
979
  svarlang_load("INSTALL.LNG", locales.lang);
972
 
980
 
973
  /****************
981
  /****************
974
   * CONFIG.SYS ***
982
   * CONFIG.SYS ***
975
   ****************/
983
   ****************/
976
  snprintf(buff, sizeof(buff), "%c:\\CONFIG.SYS", bootdrv);
984
  snprintf(buff, sizeof(buff), "%c:\\CONFIG.SYS", bootdrv);
Line 992... Line 1000...
992
  fprintf(fd, "\r\n"
1000
  fprintf(fd, "\r\n"
993
              "; command interpreter (shell) location and environment size\r\n"
1001
              "; command interpreter (shell) location and environment size\r\n"
994
              "SHELL=%c:\\COMMAND.COM /E:512 /P\r\n", bootdrv);
1002
              "SHELL=%c:\\COMMAND.COM /E:512 /P\r\n", bootdrv);
995
  fprintf(fd, "\r\n"
1003
  fprintf(fd, "\r\n"
996
              "; NLS configuration\r\n");
1004
              "; NLS configuration\r\n");
997
  if (locales != NULL) {
-
 
998
    fprintf(fd, "COUNTRY=%03u,%u,%c:\\SVARDOS\\COUNTRY.SYS\r\n", locales->countryid, locales->codepage, bootdrv);
1005
  fprintf(fd, "COUNTRY=%03u,%u,%c:\\SVARDOS\\COUNTRY.SYS\r\n", locales.countryid, locales.codepage, bootdrv);
999
  } else {
-
 
1000
    fprintf(fd, "COUNTRY=001,437,%c:\\SVARDOS\\COUNTRY.SYS\r\n", bootdrv);
-
 
1001
  }
-
 
1002
  fprintf(fd, "\r\n"
1006
  fprintf(fd, "\r\n"
1003
              "; CD-ROM driver initialization\r\n"
1007
              "; CD-ROM driver initialization\r\n"
1004
              ";DEVICE=%c:\\DRIVERS\\VIDECDD\\VIDE-CDD.SYS /D:SVCD0001\r\n", bootdrv);
1008
              ";DEVICE=%c:\\DRIVERS\\VIDECDD\\VIDE-CDD.SYS /D:SVCD0001\r\n", bootdrv);
1005
  fclose(fd);
1009
  fclose(fd);
1006
 
1010
 
Line 1034... Line 1038...
1034
    /* replace all '#' occurences by bootdrive */
1038
    /* replace all '#' occurences by bootdrive */
1035
    strtr(autoexec_bat1, '#', bootdrv);
1039
    strtr(autoexec_bat1, '#', bootdrv);
1036
 
1040
 
1037
    /* write all to file */
1041
    /* write all to file */
1038
    fputs(autoexec_bat1, fd);
1042
    fputs(autoexec_bat1, fd);
1039
    if (locales != NULL) genlocalesconf(fd, locales);
1043
    genlocalesconf(fd, &locales);
1040
    fputs(autoexec_bat2, fd);
1044
    fputs(autoexec_bat2, fd);
1041
 
1045
 
1042
    fprintf(fd, "ECHO %s\r\n", svarlang_strid(0x0600)); /* "Welcome to SvarDOS!" */
1046
    fprintf(fd, "ECHO %s\r\n", svarlang_strid(0x0600)); /* "Welcome to SvarDOS!" */
1043
    fclose(fd);
1047
    fclose(fd);
1044
  }
1048
  }
Line 1105... Line 1109...
1105
 
1109
 
1106
  /****************
1110
  /****************
1107
   * POSTINST.BAT *
1111
   * POSTINST.BAT *
1108
   ****************/
1112
   ****************/
1109
  /* create the postinst.bat file for actual installation of packages */
1113
  /* create the postinst.bat file for actual installation of packages */
1110
  snprintf(buff, sizeof(buff), "POSTINST.BAT");
-
 
1111
  fd = fopen(buff, "wb");
1114
  fd = fopen("POSTINST.BAT", "wb");
1112
  if (fd == NULL) {
1115
  if (fd == NULL) return;
1113
    return;
-
 
1114
  }
-
 
1115
  fprintf(fd,
1116
  fprintf(fd,
1116
    "@ECHO OFF\r\n"
1117
    "@ECHO OFF\r\n"
1117
    "SET DOSDIR=%c:\\SVARDOS\r\n"
1118
    "SET DOSDIR=%c:\\SVARDOS\r\n"
1118
    "PATH %%DOSDIR%%\r\n"
1119
    "PATH %%DOSDIR%%\r\n"
1119
    "ECHO INSTALLING PACKAGES\r\n"
1120
    "ECHO INSTALLING PACKAGES\r\n"
1120
    "COPY \\COMMAND.COM \\CMD.COM\r\n" /* move COMMAND.COM so it does not clashes with the installation of the SVARCOM package */
1121
    "COPY \\COMMAND.COM \\CMD.COM\r\n" /* move COMMAND.COM so it does not clashes with the installation of the SVARCOM package */
1121
    "SET COMSPEC=%c:\\CMD.COM\r\n"
1122
    "SET COMSPEC=%c:\\CMD.COM\r\n"
1122
    "DEL \\AUTOEXEC.BAT\r\n"
1123
    "DEL \\AUTOEXEC.BAT\r\n"
1123
    "COPY AUTOEXEC.BAT \\\r\n"
1124
    "COPY AUTOEXEC.BAT \\\r\n"
-
 
1125
    "DEL AUTOEXEC.BAT\r\n"
-
 
1126
    "DEL ZLOCALES.DAT\r\n"
1124
    "DEL \\COMMAND.COM\r\n"
1127
    "DEL \\COMMAND.COM\r\n"
1125
    "DEL \\KERNEL.SYS\r\n" /* KERNEL.SYS will be installed from the package in a moment */
1128
    "DEL \\KERNEL.SYS\r\n" /* KERNEL.SYS will be installed from the package in a moment */
1126
    "FOR %%%%P IN (*.SVP) DO PKG INSTALL %%%%P\r\n" /* install packages */
1129
    "FOR %%%%P IN (*.SVP) DO PKG INSTALL %%%%P\r\n" /* install packages */
1127
    "DEL *.SVP\r\n", bootdrv, bootdrv);
1130
    "DEL *.SVP\r\n", bootdrv, bootdrv);
1128
 
1131
 
Line 1131... Line 1134...
1131
              "DEL install.com\r\n"
1134
              "DEL install.com\r\n"
1132
              "DEL install.lng\r\n"
1135
              "DEL install.lng\r\n"
1133
              "SET COMSPEC=\\COMMAND.COM\r\n"
1136
              "SET COMSPEC=\\COMMAND.COM\r\n"
1134
              "DEL \\CMD.COM\r\n");
1137
              "DEL \\CMD.COM\r\n");
1135
  /* print out the "installation over" message (load codepage first, now that MODE is installed) */
1138
  /* print out the "installation over" message (load codepage first, now that MODE is installed) */
1136
  genlocalesconf(fd, locales);
1139
  genlocalesconf(fd, &locales);
1137
  fprintf(fd, "ECHO.\r\n"
1140
  fprintf(fd, "ECHO.\r\n"
1138
              "ECHO ");
1141
              "ECHO ");
1139
  fprintf(fd, svarlang_strid(0x0502)); /* "SvarDOS installation is over. Please restart your computer now" */
1142
  fprintf(fd, svarlang_strid(0x0502)); /* "SvarDOS installation is over. Please restart your computer now" */
1140
  fprintf(fd, "\r\n"
1143
  fprintf(fd, "\r\n"
1141
              "ECHO.\r\n");
1144
              "ECHO.\r\n");
Line 1233... Line 1236...
1233
      *pkgptr = 0;
1236
      *pkgptr = 0;
1234
      pkgptr++;
1237
      pkgptr++;
1235
    }
1238
    }
1236
  }
1239
  }
1237
 
1240
 
1238
  /* create an empty postinst.bat file so installer knows it is 2nd stage */
1241
  /* dump locales into ZLOCALES.DAT so the 2nd stage install can get them back */
1239
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\POSTINST.BAT", drvletter);
1242
  snprintf(buff, sizeof(buff), "%c:\\TEMP\\ZLOCALES.DAT", drvletter);
1240
  fd = fopen(buff, "wb");
1243
  fd = fopen(buff, "wb");
1241
  if (fd == NULL) return(-1);
1244
  if (fd == NULL) return(-1);
-
 
1245
  fwrite(locales, sizeof(struct slocales), 1, fd);
1242
  fclose(fd);
1246
  fclose(fd);
1243
 
1247
 
1244
  /* prepare a dummy autoexec.bat that will exec install and call temp\postinst.bat */
1248
  /* prepare a dummy autoexec.bat that will exec install and call temp\postinst.bat */
1245
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", drvletter);
1249
  snprintf(buff, sizeof(buff), "%c:\\autoexec.bat", drvletter);
1246
  fd = fopen(buff, "wb");
1250
  fd = fopen(buff, "wb");
1247
  if (fd == NULL) return(-1);
1251
  if (fd == NULL) return(-1);
1248
  fprintf(fd, "@ECHO OFF\r\n"
1252
  fprintf(fd, "@ECHO OFF\r\n"
1249
              "PATH %%DOSDIR%%\r\n");
-
 
1250
  fprintf(fd, "CD TEMP\r\n"
1253
              "CD TEMP\r\n"
1251
              "install\r\n"   /* installer will run in 2nd stage (generating autoexec.bat, pkg.cfg and stuff) */
1254
              "install\r\n"   /* installer will run in 2nd stage (generating autoexec.bat, pkg.cfg and stuff) */
1252
              "postinst.bat\r\n");
1255
              "postinst.bat\r\n");
1253
  fclose(fd);
1256
  fclose(fd);
1254
 
1257
 
1255
  return(0);
1258
  return(0);
Line 1293... Line 1296...
1293
  }
1296
  }
1294
}
1297
}
1295
 
1298
 
1296
 
1299
 
1297
int main(void) {
1300
int main(void) {
1298
  struct slocales locales_data;
1301
  struct slocales locales;
1299
  struct slocales *locales = &locales_data;
-
 
1300
  int targetdrv;
1302
  int targetdrv;
1301
  int action;
1303
  int action;
1302
 
1304
 
1303
  /* setup an internal int 24h handler ("always fail") so DOS does not output
1305
  /* setup an internal int 24h handler ("always fail") so DOS does not output
1304
   * the ugly "abort, retry, fail" messages */
1306
   * the ugly "abort, retry, fail" messages */
Line 1314... Line 1316...
1314
    COLOR_SELECT = 0x70;
1316
    COLOR_SELECT = 0x70;
1315
    COLOR_SELECTCUR = 0x07;
1317
    COLOR_SELECTCUR = 0x07;
1316
  }
1318
  }
1317
 
1319
 
1318
  /* is it stage 2 of the installation? */
1320
  /* is it stage 2 of the installation? */
1319
  if (fileexists("postinst.bat")) goto GENCONF;
1321
  if (fileexists("ZLOCALES.DAT")) goto GENCONF;
1320
 
1322
 
1321
  /* read the svardos build revision (from floppy label) */
1323
  /* read the svardos build revision (from floppy label) */
1322
  {
1324
  {
1323
    const char *fspec = "*.*";
1325
    const char *fspec = "*.*";
1324
    const char *res = (void*)0x9E; /* default DTA is at PSP:80h, field 1Eh of DTA is the ASCIZ file name */
1326
    const char *res = (void*)0x9E; /* default DTA is at PSP:80h, field 1Eh of DTA is the ASCIZ file name */
Line 1341... Line 1343...
1341
    }
1343
    }
1342
 
1344
 
1343
    memcpy(BUILDSTRING, res, 12);
1345
    memcpy(BUILDSTRING, res, 12);
1344
  }
1346
  }
1345
 
1347
 
1346
  /* am I EN-only? */
-
 
1347
  if (!fileexists("INSTALL.LNG")) locales = NULL;
-
 
1348
 
-
 
1349
 SelectLang:
1348
 SelectLang:
1350
  if (locales == NULL) goto WelcomeScreen;
-
 
1351
  action = selectlang(locales); /* welcome to svardos, select your language */
1349
  action = selectlang(&locales); /* welcome to svardos, select your language */
1352
  if (action != MENUNEXT) goto QUIT;
1350
  if (action != MENUNEXT) goto QUIT;
1353
  loadcp(locales);
1351
  loadcp(&locales);
1354
  svarlang_load("INSTALL.LNG", locales->lang); /* NLS support */
1352
  svarlang_load("INSTALL.LNG", locales.lang); /* NLS support */
1355
 
1353
 
1356
  action = selectkeyb(locales);  /* what keyb layout should we use? */
1354
  action = selectkeyb(&locales);  /* what keyb layout should we use? */
1357
  if (action == MENUQUIT) goto QUIT;
1355
  if (action == MENUQUIT) goto QUIT;
1358
  if (action == MENUPREV) goto SelectLang;
1356
  if (action == MENUPREV) goto SelectLang;
1359
 
1357
 
1360
 WelcomeScreen:
1358
 WelcomeScreen:
1361
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
1359
  action = welcomescreen(); /* what svardos is, ask whether to run live dos or install */
1362
  if (action == MENUQUIT) goto QUIT;
1360
  if (action == MENUQUIT) goto QUIT;
1363
  if (action == MENUPREV) {
1361
  if (action == MENUPREV) goto SelectLang;
1364
    if (locales == NULL) goto QUIT;
-
 
1365
    goto SelectLang;
-
 
1366
  }
-
 
1367
 
1362
 
1368
 SelDriveScreen:
1363
 SelDriveScreen:
1369
  targetdrv = selectdrive();
1364
  targetdrv = selectdrive();
1370
  if (targetdrv == MENUQUIT) goto QUIT;
1365
  if (targetdrv == MENUQUIT) goto QUIT;
1371
  if (targetdrv == MENUPREV) goto WelcomeScreen;
1366
  if (targetdrv == MENUPREV) goto WelcomeScreen;
Line 1374... Line 1369...
1374
  if (action == MENUQUIT) goto QUIT;
1369
  if (action == MENUQUIT) goto QUIT;
1375
  if (action == MENUPREV) goto SelDriveScreen;
1370
  if (action == MENUPREV) goto SelDriveScreen;
1376
  targetdrv = (targetdrv & 0xff) + 'A'; /* convert the part+hd+drv value to a DOS letter */
1371
  targetdrv = (targetdrv & 0xff) + 'A'; /* convert the part+hd+drv value to a DOS letter */
1377
 
1372
 
1378
  /* copy packages to dst drive */
1373
  /* copy packages to dst drive */
1379
  if (copypackages(targetdrv, locales) != 0) goto QUIT;
1374
  if (copypackages(targetdrv, &locales) != 0) goto QUIT;
1380
  finalreboot(); /* remove the install medium and reboot */
1375
  finalreboot(); /* remove the install medium and reboot */
1381
 
1376
 
1382
  goto QUIT;
1377
  goto QUIT;
1383
 
1378
 
1384
 GENCONF: /* second stage of the installation (run from the destination disk) */
1379
 GENCONF: /* second stage of the installation (run from the destination disk) */
1385
  bootfilesgen(locales); /* generate boot files and other configurations */
1380
  bootfilesgen(); /* generate boot files and other configurations */
1386
 
1381
 
1387
 QUIT:
1382
 QUIT:
1388
  mdr_cout_locate(0, 0);
1383
  mdr_cout_locate(0, 0);
1389
  mdr_cout_close();
1384
  mdr_cout_close();
1390
  return(0);
1385
  return(0);