install.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,98 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { This is the install program for the DOS version of Free Pascal }
  13. {$A+,B-,D+,E+,F-,G-,I-,L+,N-,O-,P-,Q+,R+,S+,T-,V-,X+,Y+}
  14. {$M 16384,0,16384}
  15. program install;
  16. uses
  17. app,dialogs,views,objects,menus,drivers,strings,msgbox,dos;
  18. var
  19. binpath,startpath : string;
  20. successfull : boolean;
  21. const
  22. version = '0';
  23. release = '99'
  24. patchlevel = '6';
  25. filenr = version+release+patchlevel;
  26. doc_version = '101';
  27. procedure uppervar(var s : string);
  28. var
  29. i : integer;
  30. begin
  31. for i:=1 to length(s) do
  32. s[i]:=upcase(s[i]);
  33. end;
  34. function file_exists(const f : string;const path : string) : boolean;
  35. begin
  36. file_exists:=fsearch(f,path)<>'';
  37. end;
  38. procedure do_install(const s : string);
  39. begin
  40. if not(file_exists(s+'.ZIP',startpath)) then
  41. begin
  42. messagebox('File: '+s+' missed for the selected installation. '+
  43. 'Installation doesn''t becomes complete',nil,mferror+mfokbutton);
  44. halt(1);
  45. end;
  46. swapvectors;
  47. exec(startpath+'\UNZIP.EXE','-qq -o '+startpath+'\'+s);
  48. swapvectors;
  49. if doserror<>0 then
  50. begin
  51. messagebox('Error when extracting. Disk full?',nil,mferror+mfokbutton);
  52. halt(1);
  53. end;
  54. end;
  55. function createdir(const s : string) : boolean;
  56. var
  57. result : longint;
  58. begin
  59. chdir(s);
  60. if ioresult=0 then
  61. begin
  62. {$ifdef german}
  63. result:=messagebox('Das Installationsverzeichnis existiert schon. '+
  64. 'Soll ein neues Installationsverzeichnis angegeben werden?',nil,
  65. mferror+mfyesbutton+mfnobutton);
  66. {$else}
  67. result:=messagebox('The installation directory exists already. '+
  68. 'Do want to enter a new installation directory ?',nil,
  69. mferror+mfyesbutton+mfnobutton);
  70. {$endif}
  71. createdir:=result=cmyes;
  72. exit;
  73. end;
  74. mkdir(s);
  75. if ioresult<>0 then
  76. begin
  77. {$ifdef german}
  78. messagebox('Das Installationsverzeichnis konnte nicht angelegt werden',
  79. @s,mferror+mfokbutton);
  80. {$else}
  81. messagebox('The installation directory couldn''t be created',
  82. @s,mferror+mfokbutton);
  83. {$endif}
  84. createdir:=true;
  85. exit;
  86. end;
  87. createdir:=false;
  88. end;
  89. procedure changedir(const s : string);
  90. begin
  91. chdir(s);
  92. if ioresult<>0 then
  93. begin
  94. {$ifdef german}
  95. messagebox('Fehler beim Wechseln in das Installationsverzeichnis. '+
  96. 'Installationsprogramm wird beendet',@s,mferror+mfokbutton);
  97. {$else}
  98. messagebox('Error when changing directory ',@s,mferror+mfokbutton);
  99. {$endif}
  100. halt(1);
  101. end;
  102. end;
  103. const
  104. cmstart = 1000;
  105. type
  106. pinstalldialog = ^tinstalldialog;
  107. tinstalldialog = object(tdialog)
  108. constructor init;
  109. end;
  110. tapp = object(tapplication)
  111. procedure initmenubar;virtual;
  112. procedure handleevent(var event : tevent);virtual;
  113. end;
  114. function diskspace(const zipfile : string) : string;
  115. var
  116. clustersize : longint;
  117. f : file;
  118. begin
  119. diskspace:='';
  120. end;
  121. var
  122. mask_components : longint;
  123. constructor tinstalldialog.init;
  124. var
  125. r : trect;
  126. line : integer;
  127. p,f : pview;
  128. s : string;
  129. const breite = 76;
  130. hoehe = 20;
  131. x1 = (80-breite) div 2;
  132. y1 = (23-hoehe) div 2;
  133. x2 = x1+breite;
  134. y2 = y1+hoehe;
  135. begin
  136. r.assign(x1,y1,x2,y2);
  137. {$ifdef german}
  138. inherited init(r,'Installieren');
  139. {$else}
  140. inherited init(r,'Install');
  141. {$endif}
  142. line:=2;
  143. r.assign(3,line+1,28,line+2);
  144. p:=new(pinputline,init(r,79));
  145. f:=p;
  146. s:='C:\PP';
  147. p^.setdata(s);
  148. insert(p);
  149. r.assign(3,line,8,line+1);
  150. insert(new(plabel,init(r,'~P~ath',p)));
  151. insert(p);
  152. inc(line,3);
  153. r.assign(3,line+1,breite-3,line+11);
  154. p:=new(pcheckboxes,init(r,
  155. newsitem('~B~asic system (required)'+diskspace('BASEDOS.ZIP'),
  156. newsitem('GNU ~L~inker and GNU Assembler (required)'+diskspace('GNUASLD.ZIP'),
  157. newsitem('D~e~mos'+diskspace('DEMO.ZIP'),
  158. newsitem('GNU ~D~ebugger'+diskspace('GDB.ZIP'),
  159. newsitem('GNU ~U~tilities (required to recompile run time library)'+diskspace('GNUUTILS.ZIP'),
  160. newsitem('Documentation (~H~TML)'+diskspace('DOCS.ZIP'),
  161. newsitem('Documentation (~P~ostscript)'+diskspace('DOC100PS.ZIP'),
  162. newsitem('~R~un time library sources'+diskspace('RL09900S.ZIP'),
  163. newsitem('~C~ompiler sources'+diskspace('PP09900S.ZIP'),
  164. newsitem('Documentation sources (La~T~eX)'+diskspace('DOC100S.ZIP'),
  165. nil
  166. ))))))))))));
  167. pcluster(p)^.enablemask:=mask_components;
  168. insert(p);
  169. r.assign(3,line,14,line+1);
  170. insert(new(plabel,init(r,'~C~omponents',p)));
  171. inc(line,12);
  172. { Free Vision
  173. r.assign(3,line+1,breite-3,line+3);
  174. p:=new(pcheckboxes,init(r,
  175. newsitem('~B~asic system',
  176. newsitem('~D~ocumentation',
  177. newsitem('S~a~mples',
  178. newsitem('~S~ources',
  179. nil
  180. ))))));
  181. pcluster(p)^.enablemask:=mask_freevision;
  182. insert(p);
  183. r.assign(3,line,15,line+1);
  184. insert(new(plabel,init(r,'~F~ree Vision',p)));
  185. inc(line,4);
  186. }
  187. r.assign((breite div 2)-14,line,(breite div 2)-4,line+2);
  188. insert(new(pbutton,init(r,'~O~k',cmok,bfdefault)));
  189. r.assign((breite div 2)+4,line,(breite div 2)+14,line+2);
  190. insert(new(pbutton,init(r,'~C~ancel',cmcancel,bfnormal)));
  191. f^.select;
  192. end;
  193. procedure tapp.handleevent(var event : tevent);
  194. var
  195. p : pinstalldialog;
  196. p2 : pdialog;
  197. p3 : pstatictext;
  198. r : trect;
  199. c : word;
  200. t : text;
  201. installdata : record
  202. path : string[79];
  203. components : word;
  204. end;
  205. f : file;
  206. label
  207. insertdisk1,insertdisk2,newpath;
  208. begin
  209. inherited handleevent(event);
  210. if event.what=evcommand then
  211. if event.command=cmstart then
  212. begin
  213. clearevent(event);
  214. installdata.path:='C:\PP';
  215. installdata.components:=0;
  216. mask_components:=$0;
  217. { searching files }
  218. if file_exists('BASEDOS.ZIP',startpath) then
  219. inc(mask_components,1);
  220. if file_exists('GNUASLD.ZIP',startpath) then
  221. inc(mask_components,2);
  222. if file_exists('DEMO.ZIP',startpath) then
  223. inc(mask_components,4);
  224. if file_exists('GDB.ZIP',startpath) then
  225. inc(mask_components,8);
  226. if file_exists('GNUUTILS.ZIP',startpath) then
  227. inc(mask_components,16);
  228. if file_exists('DOCS.ZIP',startpath) then
  229. inc(mask_components,32);
  230. if file_exists('DOC+doc_version+PS.ZIP',startpath) then
  231. inc(mask_components,64);
  232. if file_exists('RL'+filenr+'S.ZIP',startpath) then
  233. inc(mask_components,128);
  234. if file_exists('PP'+filenr+'S.ZIP',startpath) then
  235. inc(mask_components,256);
  236. if file_exists('DOC+doc_version+S.ZIP',startpath) then
  237. inc(mask_components,512);
  238. while true do
  239. begin
  240. newpath:
  241. p:=new(pinstalldialog,init);
  242. { default settings }
  243. c:=executedialog(p,@installdata);
  244. if c=cmok then
  245. begin
  246. if installdata.path[length(installdata.path)]='\' then
  247. dec(byte(installdata.path[0]));
  248. uppervar(installdata.path);
  249. binpath:=installdata.path+'\BIN';
  250. if createdir(installdata.path) then
  251. goto newpath;
  252. changedir(installdata.path);
  253. {$ifdef unused_code}
  254. assign(t,'SET_PP.BAT');
  255. rewrite(t);
  256. if ioresult<>0 then
  257. {$ifdef german}
  258. messagebox('Datei SET_PP.BAT konnte nicht erstellt werden',nil,mfokbutton+mferror)
  259. {$else}
  260. messagebox('File SET_PP.BAT can''t be created',nil,mfokbutton+mferror)
  261. {$endif}
  262. else
  263. begin
  264. { never used:
  265. writeln(t,'SET LINUXUNITS='+installdata.path+'\LINUXUNITS');
  266. writeln(t,'SET PPBIN='+installdata.path+'\BIN');
  267. writeln(t,'SET PASLIB='+installdata.path+'\LIB');
  268. writeln(t,'SET OS2UNITS='+installdata.path+'\OS2UNITS');
  269. writeln(t,'SET DOSUNITS='+installdata.path+'\DOSUNITS;'+installdata.path+'\BIN');
  270. }
  271. writeln('REM This file may contain nothing else');
  272. write(t,'SET GO32=');
  273. {$ifdef german}
  274. if messagebox('Wollen Sie den Coprozessoremulator verwenden?',
  275. nil,mfyesbutton+mfnobutton)=cmyes then
  276. write(t,'emu '+installdata.path+'\DRIVERS\EMU387');
  277. {$else}
  278. if messagebox('Install math coprocessor emulation?',
  279. nil,mfyesbutton+mfnobutton)=cmyes then
  280. write(t,'emu '+installdata.path+'\DRIVERS\EMU387');
  281. {$endif}
  282. writeln(t);
  283. close(t);
  284. end;
  285. {$endif unused_code}
  286. if getenv('UNZIP')<>'' then
  287. begin
  288. {$ifdef german}
  289. messagebox('Die Umgebungsvariable UNZIP sollte'#13+
  290. 'nicht gesetzt sein',nil,mfokbutton+mfinformation)
  291. {$else}
  292. messagebox('The enviroment variable UNZIP shouldn''t be set',nil,
  293. mfokbutton+mfinformation)
  294. {$endif}
  295. end;
  296. r.assign(20,7,60,16);
  297. p2:=new(pdialog,init(r,'Information'));
  298. r.assign(6,4,38,5);
  299. {$ifdef german}
  300. p3:=new(pstatictext,init(r,'Dateien werden entpackt ...'));
  301. {$else}
  302. p3:=new(pstatictext,init(r,'Extracting files ...'));
  303. {$endif}
  304. p2^.insert(p3);
  305. desktop^.insert(p2);
  306. if (installdata.components and 1)<>0 then
  307. do_install('BASEDOS');
  308. if (installdata.components and 2)<>0 then
  309. do_install('GNUASLD');
  310. if (installdata.components and 4)<>0 then
  311. do_install('DEMO');
  312. if (installdata.components and 8)<>0 then
  313. do_install('GDB');
  314. if (installdata.components and 16)<>0 then
  315. do_install('GNUUTILS');
  316. if (installdata.components and 32)<>0 then
  317. do_install('DOCS');
  318. if (installdata.components and 64)<>0 then
  319. do_install('DOC+doc_version+PS');
  320. if (installdata.components and 128)<>0 then
  321. do_install('RL'+filenr+'S');
  322. if (installdata.components and 256)<>0 then
  323. do_install('PP'+filenr+'S');
  324. if (installdata.components and 512)<>0 then
  325. do_install('DOC+doc_version+S');
  326. assign(t,'BIN\PPC386.CFG');
  327. rewrite(t);
  328. writeln(t,'-l');
  329. writeln(t,'#section GO32V1');
  330. writeln(t,'-Up',installdata.path+'\RTL\DOS\GO32V1');
  331. writeln(t,'#section GO32V2');
  332. writeln(t,'-Up',installdata.path+'\RTL\DOS\GO32V2');
  333. close(t);
  334. desktop^.delete(p2);
  335. dispose(p2,done);
  336. {$ifdef german}
  337. messagebox('Installation erfolgreich abgeschlossen',nil,mfinformation+mfokbutton);
  338. {$else}
  339. messagebox('Installation successfull',nil,mfinformation+mfokbutton);
  340. {$endif}
  341. event.what:=evcommand;
  342. event.command:=cmquit;
  343. successfull:=true;
  344. handleevent(event);
  345. end;
  346. break;
  347. end;
  348. end;
  349. end;
  350. procedure tapp.initmenubar;
  351. var
  352. r : trect;
  353. begin
  354. getextent(r);
  355. r.b.y:=r.a.y+1;
  356. {$ifdef german}
  357. menubar:=new(pmenubar,init(r,newmenu(
  358. newsubmenu('~I~nstallation',hcnocontext,newmenu(
  359. newitem('~S~tart','',kbnokey,cmstart,hcnocontext,
  360. newline(
  361. newitem('~B~eenden','Alt+X',kbaltx,cmquit,hcnocontext,
  362. nil)))
  363. ),
  364. nil))));
  365. {$else}
  366. menubar:=new(pmenubar,init(r,newmenu(
  367. newsubmenu('~I~nstallation',hcnocontext,newmenu(
  368. newitem('~S~tart','',kbnokey,cmstart,hcnocontext,
  369. newline(
  370. newitem('~E~xit','Alt+X',kbaltx,cmquit,hcnocontext,
  371. nil)))
  372. ),
  373. nil))));
  374. {$endif}
  375. end;
  376. var
  377. installapp : tapp;
  378. oldexitproc : pointer;
  379. procedure myexitproc;far;
  380. begin
  381. exitproc:=oldexitproc;
  382. end;
  383. var
  384. b : byte;
  385. begin
  386. getdir(0,startpath);
  387. {
  388. startpath:=paramstr(0);
  389. for b:=length(startpath) downto 1 do
  390. if startpath[b]='\' then
  391. begin
  392. startpath[0]:=chr(b-1);
  393. break;
  394. end;
  395. }
  396. oldexitproc:=exitproc;
  397. exitproc:=@myexitproc;
  398. successfull:=false;
  399. installapp.init;
  400. installapp.run;
  401. installapp.done;
  402. if successfull then
  403. begin
  404. writeln('Extend your PATH variable with');
  405. writeln(binpath);
  406. writeln;
  407. writeln('To compile files enter PPC386 [file]');
  408. end;
  409. end.
  410. {
  411. $Log$
  412. Revision 1.2 1998-04-07 22:47:57 florian
  413. + version/release/patch numbers as string added
  414. }