Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

918 lines
31 KiB

  1. #
  2. #
  3. #
  4. use Env;
  5. ################################################################################
  6. $svcsetup_bin = "$ENV{SDXROOT}/admin/pchealth/helpctr/target/obj/i386/SvcSetup.exe";
  7. $lookup_VAR{ "BUILD_OUTPUT" } = "$ENV{_NTTREE}";
  8. $lookup_VAR{ "HC_SRC" } = "$ENV{SDXROOT}/admin/pchealth/helpctr";
  9. $lookup_VAR{ "HC_DATA" } = "$ENV{SDXROOT}/admin/pchealth/helpctr/Content";
  10. $lookup_VAR{ "HC_DB" } = "$ENV{SDXROOT}/admin/pchealth/HelpCtr/Content/Database";
  11. $lookup_VAR{ "HC_HTML" } = "$ENV{SDXROOT}/admin/pchealth/HelpCtr/Content/SystemPages";
  12. $lookup_VAR{ "SI_HTML" } = "$ENV{SDXROOT}/admin/pchealth/SysInfo/HTML";
  13. $lookup_VAR{ "SI_CTRL" } = "$ENV{SDXROOT}/admin/pchealth/SysInfo/Control";
  14. ################################################################################
  15. $lookup_SKU{ "All" } = [ "", "", "" ];
  16. #### $lookup_SKU{ "Personal_32" } = [ "Personal_32" , "p3", "\@p:\@3:" ];
  17. #### $lookup_SKU{ "Professional_32" } = [ "Professional_32" , "w3", "\@w!p:\@3:" ];
  18. #### $lookup_SKU{ "Server_32" } = [ "Server_32" , "s3", "\@s!e!b:\@3:" ];
  19. #### $lookup_SKU{ "Blade_32" } = [ "Blade_32" , "b3", "\@b:\@3:" ];
  20. #### $lookup_SKU{ "AdvancedServer_32" } = [ "AdvancedServer_32", "e3", "\@e!d:\@3:" ];
  21. #### #lookup_SKU{ "AdvancedServer_32" } = [ "AdvancedServer_32", "e3", "\@s!d:\@3:" ];
  22. #### $lookup_SKU{ "DataCenter_32" } = [ "DataCenter_32" , "d3", "\@d:\@3:" ];
  23. ####
  24. #### #lookup_SKU{ "Personal_64" } = [ "Personal_64" , "p6", "\@p:\@6:" ];
  25. #### $lookup_SKU{ "Professional_64" } = [ "Professional_64" , "w6", "\@w!p:\@6:" ];
  26. #### #lookup_SKU{ "Server_64" } = [ "Server_64" , "s6", "\@s!e!b:\@6:" ];
  27. #### #lookup_SKU{ "Blade_64" } = [ "Blade_64" , "b6", "\@b:\@6:" ];
  28. #### $lookup_SKU{ "AdvancedServer_64" } = [ "AdvancedServer_64", "e6", "\@e!d:\@6:" ];
  29. #### #lookup_SKU{ "AdvancedServer_64" } = [ "AdvancedServer_64", "e6", "\@sed:\@6:" ];
  30. #### $lookup_SKU{ "DataCenter_64" } = [ "DataCenter_64" , "d6", "\@d:\@6:" ];
  31. ################################################################################
  32. $SKU_32BITS = "\@\@:\@3:";
  33. ################################################################################
  34. $BITMASK_INSTALL_CORE = 0x0001;
  35. $BITMASK_INSTALL_WMIXMLT = 0x0002;
  36. $BITMASK_INSTALL_LAMEBTN = 0x0004;
  37. $BITMASK_INSTALL_UPLOADLB = 0x0008;
  38. $BITMASK_INSTALL_HELPCTR = 0x0010;
  39. $BITMASK_INSTALL_RCTOOL = 0x0020;
  40. $BITMASK_INSTALL_SYSINFO = 0x0040;
  41. $BITMASK_INSTALL_NETDIAG = 0x0080;
  42. $BITMASK_INSTALL_DVDUPGRD = 0x0100;
  43. $lookup_STR_to_MASK{ "ALL" } = -1;
  44. $lookup_STR_to_MASK{ "CORE" } = $BITMASK_INSTALL_CORE;
  45. $lookup_STR_to_MASK{ "WMIXMLT" } = $BITMASK_INSTALL_WMIXMLT;
  46. $lookup_STR_to_MASK{ "LAMEBTN" } = $BITMASK_INSTALL_LAMEBTN;
  47. $lookup_STR_to_MASK{ "UPLOADLB" } = $BITMASK_INSTALL_UPLOADLB;
  48. $lookup_STR_to_MASK{ "HELPCTR" } = $BITMASK_INSTALL_HELPCTR;
  49. $lookup_STR_to_MASK{ "RCTOOL" } = $BITMASK_INSTALL_RCTOOL;
  50. $lookup_STR_to_MASK{ "NETDIAG" } = $BITMASK_INSTALL_NETDIAG;
  51. $lookup_STR_to_MASK{ "SYSINFO" } = $BITMASK_INSTALL_SYSINFO;
  52. $lookup_STR_to_MASK{ "DVDUPGRD" } = $BITMASK_INSTALL_DVDUPGRD;
  53. ################################################################################
  54. $OPT_SKU = "";
  55. $OPT_COPY = 0; # Force the option, NOT TO COPY FILES, INF only.
  56. $OPT_VERBOSE = 0;
  57. $OPT_MODE = "NORMAL";
  58. $OPT_SIGNFILE = "";
  59. $OPT_INSTALL_DEFAULT = 1;
  60. $OPT_INSTALL = 0;
  61. $OPT_INSTALL_DIR = "FilesToDrop";
  62. $OPT_INSTALL_INF = "";
  63. $OPT_INSTALL_INFTXT = "";
  64. ################################################################################
  65. @SectionDefinition = (
  66. # Tag in the INF
  67. # | Directory where to install this tag
  68. # | | Delayed installation?
  69. # | | |
  70. # V V V
  71. [ "WINDOWS" , "%10%" , "" ],
  72. [ "SYSTEM" , "%11%" , "" ],
  73. [ "WMI" , "%11%\\WBEM" , "" ],
  74. [ "WMI_DLY" , "%11%\\WBEM" , "PCHDATA" ],
  75. [ "WMIDTD" , "%11%\\WBEM\\DTD" , "" ],
  76. [ "UL_BIN" , "%10%\\PCHealth\\UploadLB\\Binaries" , "" ],
  77. [ "UL_CFG" , "%10%\\PCHealth\\UploadLB\\Config" , "PCHDATA" ],
  78. [ "HC_BIN" , "%10%\\PCHealth\\HelpCtr\\Binaries" , "" ],
  79. [ "HC_BIN_DLY" , "%10%\\PCHealth\\HelpCtr\\Binaries" , "PCHDATA" ],
  80. [ "HC_DB" , "%10%\\PCHealth\\HelpCtr\\Database" , "PCHDATA" ],
  81. [ "HC_CFG" , "%10%\\PCHealth\\HelpCtr\\Config" , "PCHDATA" ],
  82. [ "HC_HTM_SYS" , "%10%\\PCHealth\\HelpCtr\\System" , "PCHDATA" ],
  83. [ "HC_HTM_CSS" , "%10%\\PCHealth\\HelpCtr\\System\\css" , "PCHDATA" ],
  84. [ "HC_HTM_DLG" , "%10%\\PCHealth\\HelpCtr\\System\\dialogs" , "PCHDATA" ],
  85. [ "HC_HTM_ERR" , "%10%\\PCHealth\\HelpCtr\\System\\errors" , "PCHDATA" ],
  86. [ "HC_HTM_PAN" , "%10%\\PCHealth\\HelpCtr\\System\\panels" , "PCHDATA" ],
  87. [ "HC_HTM_SUBPAN", "%10%\\PCHealth\\HelpCtr\\System\\panels\\subpanels" , "PCHDATA" ],
  88. [ "HC_HTM_SCR" , "%10%\\PCHealth\\HelpCtr\\System\\scripts" , "PCHDATA" ],
  89. [ "HC_HTM_IMG" , "%10%\\PCHealth\\HelpCtr\\System\\images" , "PCHDATA" ],
  90. [ "HC_HTM_IMG16" , "%10%\\PCHealth\\HelpCtr\\System\\images\\16x16" , "PCHDATA" ],
  91. [ "HC_HTM_IMG24" , "%10%\\PCHealth\\HelpCtr\\System\\images\\24x24" , "PCHDATA" ],
  92. [ "HC_HTM_IMG32" , "%10%\\PCHealth\\HelpCtr\\System\\images\\32x32" , "PCHDATA" ],
  93. [ "HC_HTM_IMG48" , "%10%\\PCHealth\\HelpCtr\\System\\images\\48x48" , "PCHDATA" ],
  94. [ "HC_HTM_EXP" , "%10%\\PCHealth\\HelpCtr\\System\\images\\Expando" , "PCHDATA" ],
  95. [ "HC_HTM_CTR" , "%10%\\PCHealth\\HelpCtr\\System\\images\\Centers" , "PCHDATA" ],
  96. [ "HC_HTM_LAM" , "%10%\\PCHealth\\HelpCtr\\System\\HelpComment" , "PCHDATA" ],
  97. [ "HC_HTM_BLB" , "%10%\\PCHealth\\HelpCtr\\System\\blurbs" , "PCHDATA" ],
  98. [ "HC_HTM_RC" , "%10%\\PCHealth\\HelpCtr\\System\\rc" , "PCHDATA" ],
  99. [ "HC_HTM_UPD" , "%10%\\PCHealth\\HelpCtr\\System\\UpdateCtr" , "PCHDATA" ],
  100. [ "HC_HTM_CPT" , "%10%\\PCHealth\\HelpCtr\\System\\CompatCtr" , "PCHDATA" ],
  101. [ "HC_HTM_DFS" , "%10%\\PCHealth\\HelpCtr\\System\\DFS" , "PCHDATA" ],
  102. [ "HC_HTM_ERRMSG", "%10%\\PCHealth\\HelpCtr\\System\\ErrMsg" , "PCHDATA" ],
  103. [ "SI_HTM" , "%10%\\PCHealth\\HelpCtr\\System\\sysinfo" , "PCHDATA" ],
  104. [ "SI_GIF" , "%10%\\PCHealth\\HelpCtr\\System\\sysinfo\\graphics" , "PCHDATA" ],
  105. [ "SI_PIE1" , "%10%\\PCHealth\\HelpCtr\\System\\sysinfo\\graphics\\33x16pie", "PCHDATA" ],
  106. [ "SI_PIE2" , "%10%\\PCHealth\\HelpCtr\\System\\sysinfo\\graphics\\47x24pie", "PCHDATA" ],
  107. [ "ND_HTM" , "%10%\\PCHealth\\HelpCtr\\System\\NetDiag" , "PCHDATA" ],
  108. [ "DVD_HTM" , "%10%\\PCHealth\\HelpCtr\\System\\DVDUpgrd" , "PCHDATA" ],
  109. );
  110. @ComponentDefinition = (
  111. # Tag in the INF
  112. # | Component to map to this tag
  113. # | | Bit mask for installation.
  114. # | | | Flags for SKU
  115. # | | | |
  116. # V V V V
  117. [ "WINDOWS" , "CompWindows" , "ALL" , "" ],
  118. [ "SYSTEM" , "CompSystem" , "ALL" , "" ],
  119. [ "WMI" , "CompWMI_prov" , "UPLOADLB", "" ],
  120. [ "WMI" , "CompWMIXMLT" , "WMIXMLT" , "" ],
  121. [ "WMIDTD" , "CompWMIDTD" , "WMIXMLT" , "" ],
  122. [ "UL_BIN" , "CompUL" , "UPLOADLB", "" ],
  123. [ "UL_CFG" , "CompUL_cfg" , "UPLOADLB", "" ],
  124. [ "HC_BIN" , "CompHC_bin" , "HELPCTR" , "" ],
  125. [ "HC_DB" , "CompHC_db" , "HELPCTR" , "" ],
  126. [ "HC_CFG" , "CompHC_cfg" , "HELPCTR" , "" ],
  127. [ "HC_CFG" , "CompHC_cfg" , "HELPCTR" , "" ],
  128. [ "HC_HTM_SYS" , "CompHC_system" , "HELPCTR" , "" ],
  129. [ "HC_HTM_CSS" , "CompHC_css" , "HELPCTR" , "" ],
  130. [ "HC_HTM_DLG" , "CompHC_dlg" , "HELPCTR" , "" ],
  131. [ "HC_HTM_ERR" , "CompHC_errors" , "HELPCTR" , "" ],
  132. [ "HC_HTM_PAN" , "CompHC_panels" , "HELPCTR" , "" ],
  133. [ "HC_HTM_SUBPAN", "CompHC_subpan" , "HELPCTR" , "" ],
  134. [ "HC_HTM_SCR" , "CompHC_scripts", "HELPCTR" , "" ],
  135. [ "HC_HTM_IMG" , "CompHC_images" , "HELPCTR" , "" ],
  136. [ "HC_HTM_IMG16" , "CompHC_16x16" , "HELPCTR" , "" ],
  137. [ "HC_HTM_IMG24" , "CompHC_24x24" , "HELPCTR" , "" ],
  138. [ "HC_HTM_IMG32" , "CompHC_32x32" , "HELPCTR" , "" ],
  139. [ "HC_HTM_IMG48" , "CompHC_48x48" , "HELPCTR" , "" ],
  140. [ "HC_HTM_EXP" , "CompHC_expando", "HELPCTR" , "" ],
  141. [ "HC_HTM_CTR" , "CompHC_centers", "HELPCTR" , "" ],
  142. [ "HC_HTM_LAM" , "CompHC_lame" , "HELPCTR" , "" ],
  143. [ "HC_HTM_BLB" , "CompHC_blurbs" , "HELPCTR" , "" ],
  144. [ "HC_HTM_RC" , "CompHC_rc" , "HELPCTR" , "" ],
  145. [ "HC_HTM_UPD" , "CompHC_update" , "HELPCTR" , "" ],
  146. [ "HC_HTM_CPT" , "CompHC_compat" , "HELPCTR" , "" ],
  147. [ "HC_HTM_DFS" , "CompHC_dfs" , "HELPCTR" , "" ],
  148. [ "HC_HTM_ERRMSG", "CompHC_errmsg" , "HELPCTR" , "" ],
  149. [ "HC_BIN" , "CompSI_bin" , "SYSINFO" , "" ],
  150. [ "WMI_DLY" , "CompSI_mof" , "SYSINFO" , "" ],
  151. [ "SI_HTM" , "CompSI_htm" , "SYSINFO" , "" ],
  152. [ "SI_GIF" , "CompSI_gif" , "SYSINFO" , "" ],
  153. [ "SI_PIE1" , "CompSI_pie1" , "SYSINFO" , "" ],
  154. [ "SI_PIE2" , "CompSI_pie2" , "SYSINFO" , "" ],
  155. [ "ND_HTM" , "CompND_htm" , "NETDIAG" , "" ],
  156. [ "DVD_HTM" , "CompDVD_htm" , "DVDUPGRD", "" ],
  157. );
  158. ${uniq_seq} = 0;
  159. foreach $in ( @SectionDefinition )
  160. {
  161. $infid = $$in[0];
  162. $dir = $$in[1];
  163. $lookup_INFID_to_FILES__source { $infid } = {};
  164. $lookup_INFID_to_FILES__destination{ $infid } = {};
  165. $lookup_INFID_to_DIR { $infid } = $dir;
  166. $lookup_DELAYED { $infid } = $$in[2] if $$in[2];
  167. }
  168. foreach $in ( @ComponentDefinition )
  169. {
  170. $infid = $$in[0];
  171. $comp = $$in[1];
  172. $prod = $$in[2];
  173. $sku = $$in[3];
  174. $lookup_COMP_to_FILES__destination{ $comp } = $lookup_INFID_to_FILES__destination{ $infid };
  175. $lookup_COMP_to_PRODUCT { $comp } = $prod;
  176. $lookup_COMP_to_INFID { $comp } = $infid;
  177. $lookup_COMP_to_SKU { $comp } = $sku;
  178. }
  179. ################################################################################
  180. sub mysystem
  181. {
  182. my($cmd) = @_;
  183. if ($OPT_VERBOSE == 1)
  184. {
  185. printf STDOUT ("%s\n", $cmd );
  186. }
  187. else
  188. {
  189. $cmd = qq|$cmd > nul 2>&1|;
  190. }
  191. return( system $cmd );
  192. }
  193. sub parseargs
  194. {
  195. $getarg="";
  196. foreach (@ARGV)
  197. {
  198. $arg = $_;
  199. if($getarg)
  200. {
  201. for ($getarg)
  202. {
  203. /^-sku$/i and do
  204. {
  205. $OPT_SKU=$arg;
  206. &Usage unless $lookup_SKU{ $OPT_SKU };
  207. last;
  208. };
  209. /^-install$/i and do
  210. {
  211. $OPT_INSTALL = 0 if $OPT_INSTALL_DEFAULT;
  212. undef $OPT_INSTALL_DEFAULT;
  213. $arg =~ tr/[a-z]/[A-Z]/;
  214. &Usage unless $lookup_STR_to_MASK{ $arg };
  215. $OPT_INSTALL |= $lookup_STR_to_MASK{ $arg };
  216. last;
  217. };
  218. /^-dir$/i and do
  219. {
  220. $OPT_INSTALL_DIR=$arg;
  221. last;
  222. };
  223. /^-inf$/i and do
  224. {
  225. $OPT_INSTALL_INF=$arg;
  226. last;
  227. };
  228. /^-inftxt$/i and do
  229. {
  230. $OPT_INSTALL_INFTXT=$arg;
  231. last;
  232. };
  233. /^-signfile$/i and do
  234. {
  235. $OPT_SIGNFILE=$arg;
  236. last;
  237. };
  238. }
  239. $getarg="";
  240. }
  241. else
  242. {
  243. for ($arg)
  244. {
  245. /^-normal$/i and do { $OPT_MODE = "NORMAL" ; last; };
  246. /^-standalone$/i and do { $OPT_MODE = "STANDALONE"; last; };
  247. /^-sku$/i and do { $getarg = $_; last; };
  248. /^-skipcopy$/i and do { $OPT_COPY = 0; last; };
  249. /^-docopy$/i and do { $OPT_COPY = 1; last; };
  250. /^-verbose$/i and do { $OPT_VERBOSE = 1; last; };
  251. /^-install$/i and do { $getarg = $_; last; };
  252. /^-dir$/i and do { $getarg = $_; last; };
  253. /^-inf$/i and do { $getarg = $_; last; };
  254. /^-inftxt$/i and do { $getarg = $_; last; };
  255. /^-signfile$/i and do { $getarg = $_; last; };
  256. printf ("Invalid option: %s\n\n", $_);
  257. &Usage;
  258. }
  259. }
  260. }
  261. $OPT_INSTALL_INF = $OPT_INSTALL_DIR unless $OPT_INSTALL_INF;
  262. $OPT_INSTALL_INFTXT = $OPT_INSTALL_DIR unless $OPT_INSTALL_INFTXT;
  263. }
  264. sub Usage
  265. {
  266. print q/CreateInf - Create the setup package for PC Health
  267. Usage: CreateInf [<options>]
  268. Options:
  269. -help Prints out this message.
  270. -sku Specify the flavor of the setup (default: Server_32).
  271. -skipcopy Do not copy files.
  272. -verbose Output a log of the operations.
  273. -debug Generate a setup for DEBUG. (symbols, etc.)
  274. -retail Generate a setup for RETAIL.
  275. -bbt Generate a setup for BBT. (instrumented exes, etc.)
  276. -opt Generate a setup for OPT. (optimized exes, etc.)
  277. -normal Generate an INF for NT setup. (default)
  278. -standalone Generate an INF for direct installation.
  279. -dir <path> The directory that will receive the files. (def: FilesToDrop)
  280. -install <part> Include <part> in the installation. You can repeat the option
  281. more than one to include multiple products. Valid values:
  282. ALL - Everything.
  283. CORE - The common modules.
  284. HELPCTR - Help And Support Services.
  285. NETDIAG - Network Diagnostics.
  286. SYSINFO - System Information.
  287. NETDIAG - Network diagnostics.
  288. DVDUPGRD - DVD upgrade.
  289. UPLOADLB - Upload Library..
  290. /;
  291. exit 1;
  292. }
  293. ################################################################################
  294. sub init
  295. {
  296. open IN, "cd |";
  297. $CWD=<IN>; chop $CWD;
  298. close IN;
  299. ## $SLMDIR="$ENV{SDXROOT}\\admin\\pchealth";
  300. ##
  301. ## open IN, "$ENV{SDXROOT}\\admin\\pchealth\\core\\include\\bldver.h" or die "Can't open build version file";
  302. ## @lines = grep /#define VER_PRODUCTBUILD /, <IN>;
  303. ## foreach (@lines)
  304. ## {
  305. ## $BUILDNUM=$1 if m/#define VER_PRODUCTBUILD +(\d+)/;
  306. ## }
  307. if ($OPT_COPY)
  308. {
  309. mysystem( qq|rd /S /Q "$OPT_INSTALL_DIR"| );
  310. mysystem( qq|md "$OPT_INSTALL_DIR"| );
  311. }
  312. }
  313. ################################################################################
  314. sub generate_list_of_copy_sections
  315. {
  316. my($out) = @_;
  317. my($infid,$list);
  318. $list = "CopyFiles=copy.inf";
  319. foreach $infid (sort keys %lookup_INFID_to_FILES__destination)
  320. {
  321. next if $lookup_DELAYED{$infid}; # Delayed installation
  322. if(keys %{ $lookup_INFID_to_FILES__destination{ $infid } })
  323. {
  324. $list="$list, $infid";
  325. }
  326. }
  327. printf $out ("%s\n", $list );
  328. }
  329. sub generate_destination_dirs
  330. {
  331. my($out) = @_;
  332. my($infid,$list,$dir);
  333. foreach $infid (sort keys %lookup_INFID_to_FILES__destination)
  334. {
  335. next if $lookup_DELAYED{$infid}; # Delayed installation
  336. if(keys %{ $lookup_INFID_to_FILES__destination{ $infid } })
  337. {
  338. $dir = $lookup_INFID_to_DIR{ $infid };
  339. $dir =~ s/\%([0-9]*)\%\\(.*)/$1,$2/g;
  340. $dir =~ s/\%([0-9]*)\%/$1/g;
  341. printf $out ("%s = %s\n", $infid, $dir );
  342. }
  343. }
  344. }
  345. sub generate_copy_sections
  346. {
  347. my ($out) = @_;
  348. my ($infid,$tmpfile,$ref,$dstfile,$sku,$got);
  349. my ($name,$ext);
  350. foreach $infid (sort keys %lookup_INFID_to_FILES__destination)
  351. {
  352. next if $lookup_DELAYED{$infid}; # Delayed installation
  353. $got=0;
  354. foreach $tmpfile (sort keys %{ $lookup_INFID_to_FILES__destination{ $infid } })
  355. {
  356. printf $out ("[%s]\n", $infid ) if $got == 0;
  357. $ref = $lookup_INFID_to_FILES__destination{ $infid }->{$tmpfile};
  358. $tmpfile = $$ref[0];
  359. $dstfile = $$ref[1];
  360. $sku = $$ref[2];
  361. ($name,$ext) = $dstfile =~ m/(.*)\.(.*)/x;
  362. printf $out ( $lookup_SKU{ $sku }[2] ) if $lookup_SKU{ $sku };
  363. #### #
  364. #### # If the file is 8.3 characters and should be renamed, do the renaming here.
  365. #### #
  366. #### if($tmpfile !~ $dstfile and length( $name ) <= 8 and length( $ext ) <= 3)
  367. #### {
  368. #### printf $out ("%s,%s\n", $dstfile, $tmpfile );
  369. #### }
  370. #### else
  371. #### {
  372. #### printf $out ("%s\n", $tmpfile );
  373. #### }
  374. #
  375. # If the file should be renamed, do the renaming here.
  376. #
  377. if($tmpfile !~ $dstfile)
  378. {
  379. printf $out ("%s,%s\n", $dstfile, $tmpfile );
  380. }
  381. else
  382. {
  383. printf $out ("%s\n", $tmpfile );
  384. }
  385. $got=1;
  386. }
  387. printf $out ("\n" ) if $got;
  388. }
  389. }
  390. sub generate_rename_section
  391. {
  392. my($out) = @_;
  393. my($infid,$first,$tmpfile,$dstfile,$sku,$dir);
  394. foreach $infid (sort keys %lookup_INFID_to_FILES__destination)
  395. {
  396. next if $lookup_DELAYED{$infid}; # Delayed installation
  397. $dir = $lookup_INFID_to_DIR{ $infid };
  398. $first=1;
  399. foreach $tmpfile (sort keys %{ $lookup_INFID_to_FILES__destination{ $infid } })
  400. {
  401. $ref = $lookup_INFID_to_FILES__destination{ $infid }->{$tmpfile};
  402. $tmpfile = $$ref[0];
  403. $dstfile = $$ref[1];
  404. $sku = $$ref[2];
  405. next if $tmpfile =~ $dstfile;
  406. #
  407. # If the file is 8.3 charactes, don't use rename section.
  408. #
  409. my ($name,$ext) = $dstfile =~ m/(.*)\.(.*)/x;
  410. next if (length( $name ) <= 8 and length( $ext ) <= 3);
  411. if($first)
  412. {
  413. printf $out ( "HKLM,%%KEY_RENAME%%\\PCHealth_%s,,,\"%s\"\n", $infid, $dir );
  414. $first=0;
  415. }
  416. printf $out ( $lookup_SKU{ $sku }[2] ) if $lookup_SKU{ $sku };
  417. printf $out ( "HKLM,%%KEY_RENAME%%\\PCHealth_%s,\"%s\",,\"%s\"\n", $infid, $tmpfile, $dstfile );
  418. }
  419. printf $out ("\n" ) unless $first;
  420. }
  421. }
  422. sub insert_disks
  423. {
  424. my($out) = @_;
  425. my($key);
  426. foreach (sort keys %list_disks)
  427. {
  428. $key = $_;
  429. printf $out ( "%s=%s\n", $key, $list_disks{$key} );
  430. }
  431. }
  432. ################################################################################
  433. sub process_file
  434. {
  435. my($srcfile,$dstfile1,$dstfile2) = @_;
  436. my($mode,$skip,$prevskip,$white,$lastwhite);
  437. my(@cond,$condIdx,$output);
  438. open IN, "$srcfile" or die "Can't open input file '$srcfile'";
  439. open OUT1, ">$dstfile1" or die "Can't open output file '$dstfile1'";
  440. open OUT2, ">$dstfile2" or die "Can't open output file '$dstfile2'";
  441. $mode = "";
  442. $value = "";
  443. $skip = 0;
  444. $prevskip = 0;
  445. $white = "";
  446. $lastwhite = "";
  447. $condIdx = 0;
  448. $cond[0] = ($mode,$value,$skip,$prevskip);
  449. $output = "OUT1";
  450. while(<IN>)
  451. {
  452. chop;
  453. if($condIdx > 0)
  454. {
  455. if(m/^\#endif/x)
  456. {
  457. ($mode,$value,$skip,$prevskip) = $cond[$--condIdx];
  458. next;
  459. }
  460. if(m/^\#else/x)
  461. {
  462. $skip = 1 - $skip;
  463. next;
  464. }
  465. }
  466. if(m/^\#if\s*(.*)\s+(.*)/x)
  467. {
  468. $cond[$condIdx++] = ($mode,$value,$skip,$prevskip);
  469. $prevskip = $skip;
  470. $skip = 1;
  471. $mode = $1;
  472. $value = $2;
  473. $mask = $lookup_STR_to_MASK{ $mode };
  474. $skip = 0 if $mode =~ /MODE/i and $value =~ $OPT_MODE;
  475. $skip = 0 if $mask and (($value != 0) xor (($OPT_INSTALL & $mask) != $mask));
  476. next;
  477. }
  478. next if($prevskip == 1 || $skip == 1);
  479. $white = m/^ *$/;
  480. next if($white && $whitelast);
  481. $whitelast = $white;
  482. do { insert_disks ( $output ); next; } if /___DISKS___/i;
  483. do { generate_copy_sections ( $output ); next; } if /___COPY_SECTIONS___/i;
  484. do { generate_destination_dirs ( $output ); next; } if /___DESTINATION_DIRS___/i;
  485. do { generate_list_of_copy_sections( $output ); next; } if /___LIST_OF_COPY_SECTIONS___/i;
  486. #### do { generate_rename_section ( $output ); next; } if /___RENAME___/i;
  487. do { next; } if /___RENAME___/i;
  488. $output = "OUT2" if /\[Strings\]/i;
  489. printf $output ("%s\n", "$_");
  490. }
  491. close IN;
  492. close OUT1;
  493. close OUT2;
  494. }
  495. sub fix_path
  496. {
  497. my($dir) = @_;
  498. $dir =~ s/\Q$ENV{SDXROOT}\E/\%SDXROOT\%/io;
  499. $dir =~ s/\%10\%/\%WINDIR\%/io;
  500. $dir =~ s/\%11\%/\%WINDIR\%\\system32/io;
  501. $dir =~ s/\%2\%//io;
  502. $dir =~ s/\%22\%//io;
  503. $dir =~ s|/|\\|og;
  504. $dir =~ s/\\[^\\]*\\\.\.\\/\\/iog;
  505. $dir =~ s/\\\.\\/\\/iog;
  506. return $dir;
  507. }
  508. sub generate_list_of_files_to_sign
  509. {
  510. my($outfile,$mode) = @_;
  511. my($infid,$hash1,$hash2,$dir,$srcfile,$tmpfile,$dstfile,$sku,$purpose,$loc,%hash3);
  512. foreach $infid (keys %lookup_DELAYED)
  513. {
  514. next unless $lookup_DELAYED{$infid} == $mode;
  515. $hash1 = $lookup_INFID_to_FILES__source { $infid };
  516. $hash2 = $lookup_INFID_to_FILES__destination{ $infid };
  517. $dir = $lookup_INFID_to_DIR { $infid };
  518. $dir = fix_path( $dir );
  519. foreach $tmpfile (keys %{ $hash2 })
  520. {
  521. $ref = $hash2->{$tmpfile};
  522. $tmpfile = $$ref[0];
  523. $dstfile = $$ref[1];
  524. $sku = $$ref[2];
  525. $purpose = $$ref[3];
  526. $loc = $$ref[4];
  527. $srcfile = $hash1->{$tmpfile}; $srcfile =~ s|/|\\|g;
  528. $srcfile = fix_path( $srcfile );
  529. $dstfile = fix_path( $dstfile );
  530. $hash3{ $sku . $loc . $srcfile } = [ $sku, $loc, $purpose, $srcfile, $tmpfile, $dstfile, $dir ];
  531. }
  532. }
  533. open OUT, ">$outfile" or die "Can't open output file '$outfile'";
  534. print OUT "#\n";
  535. print OUT "# <SKU> , <localization flag> , <location of source file> , <temporary name> , <final name> , <final destination>\n";
  536. print OUT "#\n";
  537. foreach $tmpfile (sort keys %hash3)
  538. {
  539. $ref = $hash3{$tmpfile};
  540. $sku = $$ref[0];
  541. $loc = $$ref[1];
  542. $purpose = $$ref[2];
  543. $srcfile = $$ref[3];
  544. $tmpfile = $$ref[4];
  545. $dstfile = $$ref[5];
  546. $dir = $$ref[6];
  547. printf OUT ("%s,%s,%s,%s,%s,%s,%s\n", $sku, $loc, $purpose, $srcfile, $tmpfile, $dstfile, $dir );
  548. }
  549. close OUT;
  550. }
  551. ################################################################################
  552. sub resolve_variables
  553. {
  554. my($line) = @_;
  555. my($got) = 1;
  556. my($var,$value);
  557. $in = $line;
  558. while($got)
  559. {
  560. $got = 0;
  561. foreach $key (keys %lookup_VAR)
  562. {
  563. if($line =~ m|\$$key|x)
  564. {
  565. $value = $lookup_VAR{ $key };
  566. $value =~ s|\\|/|g;
  567. $line =~ s|(\$$key)|$value|g;
  568. $got = 1;
  569. last;
  570. }
  571. }
  572. }
  573. return $line;
  574. }
  575. sub parse_line
  576. {
  577. my($line) = @_;
  578. my($quote, $quoted, $unquoted, $delim, $word, @pieces);
  579. while (length($line))
  580. {
  581. ($quote, $quoted, $unquoted, $delim) =
  582. $line =~ m/^(["']) # a $quote
  583. ((?:\\.|[^\1\\])*?) # and $quoted text
  584. \1 # followed by the same quote
  585. | # --OR--
  586. ^((?:\\.|[^\\"'])*?) # an $unquoted text
  587. (\Z(?!\n)|\s+|(?!^)(?=["'])) # plus EOL, delimiter, or quote
  588. /x; # extended layout
  589. return() unless(length($&));
  590. $line = $';
  591. $unquoted =~ s/\\(.)/$1/g;
  592. $quoted =~ s/\\(.)/$1/g if ($quote eq '"');
  593. $word .= ($quote) ? $quoted : $unquoted;
  594. if (length($delim))
  595. {
  596. push(@pieces, $word);
  597. undef $word;
  598. }
  599. if (!length($line))
  600. {
  601. push(@pieces, $word);
  602. }
  603. }
  604. return(@pieces);
  605. }
  606. sub parse_single_file
  607. {
  608. my($optcopy, $comp,$srcfile,$dstfile,$renfile,$purpose,$localize,$sku,$srcdir) = @_;
  609. my($infid);
  610. return unless $comp;
  611. #
  612. # Filter out file from products not installed.
  613. #
  614. return unless $lookup_STR_to_MASK{ $lookup_COMP_to_PRODUCT{ $comp } } & $OPT_INSTALL;
  615. $infid = $lookup_COMP_to_INFID{ $comp };
  616. #
  617. # Filter out unwanted files.
  618. #
  619. return if $dont_install_file{$srcfile};
  620. return if $dont_install_comp{$comp};
  621. $srcdir = resolve_variables( $srcdir );
  622. $dstfile = $srcfile unless $dstfile;
  623. $renfile = $dstfile unless $renfile;
  624. #
  625. # Install the same file into the same location only once.
  626. #
  627. printf STDOUT ("Duplicate file %s -> %s -> %s !!\n", $srcfile, $renfile, $dstfile) if $lookup_DUPLICATE{$renfile};
  628. $lookup_DUPLICATE{$renfile} = 1;
  629. return if $lookup_INFID_to_FILES__source{ $infid }->{$renfile};
  630. $lookup_INFID_to_FILES__source{ $infid }->{$renfile} = "$srcdir/$srcfile";
  631. $srcdir =~ s(/)(\\)g;
  632. ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat "$srcdir\\$srcfile";
  633. if(!$lookup_DELAYED{$infid})
  634. {
  635. #($name,$ext) = $renfile =~ m/(.*)\.(.*)/x;
  636. #if($list_disks{$renfile} or (length( $name ) > 8 or length( $ext ) > 3))
  637. #{
  638. # printf STDOUT ("File name collision!! %s\n", $renfile );
  639. # $renfile = "PCH" . $uniq_seq . ".img";
  640. # $uniq_seq++;
  641. #}
  642. $list_disks{$renfile} = "1,,$size";
  643. if($optcopy)
  644. {
  645. $copy_src = qq|$srcdir\\$srcfile|;
  646. $copy_dst = qq|$OPT_INSTALL_DIR\\$renfile|;
  647. mysystem( qq|copy "$copy_src" "$copy_dst"| ) == 0 or printf STDOUT ("Copy failed: %s -> %s\n", $copy_src, $copy_dst );
  648. }
  649. }
  650. if($lookup_COMP_to_FILES__destination{ $comp })
  651. {
  652. $lookup_COMP_to_FILES__destination{ $comp }->{ $renfile . "#" . $dstfile . "#" . $sku } = [ $renfile, $dstfile, $sku, $purpose, $localize ];
  653. }
  654. }
  655. sub parse_list_of_files
  656. {
  657. my($FileID,$file) = @_;
  658. my($infid,$comp,$srcfile,$dstfile,$renfile,$srcdir);
  659. open IN, "lst\\$file" or die "Can't open file listing '$file'";
  660. while(<IN>)
  661. {
  662. next if /^#/;
  663. chop;
  664. next if /^$/;
  665. parse_single_file( $OPT_COPY, parse_line( $_ ) );
  666. }
  667. close IN;
  668. }
  669. sub parse_list_of_sku
  670. {
  671. my($file) = @_;
  672. my($SKU,$cabinet,$prodfilt,$desktop,$server,$embedded);
  673. open IN, "$file" or die "Can't open SKU listing '$file'";
  674. while(<IN>)
  675. {
  676. next if /^#/;
  677. chop;
  678. next if /^$/;
  679. ($SKU,$cabinet,$prodfilt,$desktop,$server,$embedded) = parse_line( $_ );
  680. $lookup_SKU{ $SKU } = [ $SKU, $cabinet, $prodfilt ];
  681. }
  682. close IN;
  683. }
  684. ################################################################################
  685. parse_list_of_sku( "$ENV{SDXROOT}/admin/pchealth/redist/SKUlist.txt" );
  686. &parseargs;
  687. &init;
  688. #
  689. # Always install "atrace.dll" into %WINDIR%\system and ignore any other occurence.
  690. #
  691. # More, "atrace.dll" should be listed as soon as possible, so it won't be renamed.
  692. #
  693. parse_list_of_files( "COMMON" , "common.lst" ); $dont_install_file{"atrace.dll"} = 1;
  694. parse_list_of_files( "UPLOADLIB", "UploadLib.lst" );
  695. parse_list_of_files( "HELPCTR" , "HelpCtr.lst" );
  696. parse_list_of_files( "SYSINFO" , "SysInfo.lst" );
  697. parse_list_of_files( "NETDIAG" , "NetDiag.lst" );
  698. parse_list_of_files( "DVDUPGRD" , "DVDUpgrade.lst" );
  699. parse_list_of_files( "WMIXMLT" , "WmiXmlT.lst" );
  700. foreach $sku (keys %lookup_SKU)
  701. {
  702. next unless $lookup_SKU{ $sku }[1];
  703. parse_single_file( 0, "CompHC_bin", $lookup_SKU{ $sku }[1], "", "", "Database", "NoLoc", $sku, "\$HC_DATA" );
  704. }
  705. process_file( "inf\\PCHealth.INF", "$OPT_INSTALL_INF\\PCHealth.inx", "$OPT_INSTALL_INFTXT\\PCHealth.txt" );
  706. if($OPT_SIGNFILE)
  707. {
  708. generate_list_of_files_to_sign( $OPT_SIGNFILE, "PCHDATA" );
  709. }