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.

606 lines
18 KiB

  1. #
  2. # PPM::XML::PPD
  3. #
  4. # Definition of the PPD file format.
  5. #
  6. ###############################################################################
  7. use PPM::XML::ValidatingElement;
  8. use Exporter;
  9. $PPM::XML::PPD::revision = '$Id: PPD.pm,v 1.2 2000/01/27 19:33:17 graham Exp $';
  10. $PPM::XML::PPD::VERSION = '0.01';
  11. ###############################################################################
  12. # Set up PPM::XML::PPD to export its sub-packages so that we can use them in
  13. # other XML documents without too much effort.
  14. ###############################################################################
  15. package PPM::XML::PPD;
  16. @ISA = qw( Exporter );
  17. %EXPORT_TAGS = ( 'elements' =>
  18. [ '%SOFTPKG::', '%IMPLEMENTATION::', '%DEPENDENCY::',
  19. '%TITLE::', '%ABSTRACT::', '%AUTHOR::',
  20. '%LANGUAGE::', '%LICENSE::', '%OS::',
  21. '%OSVERSION::', '%PERLCORE::', '%PROCESSOR::',
  22. '%CODEBASE::', '%INSTALL::', '%UNINSTALL::',
  23. '%ARCHITECTURE::',
  24. ] );
  25. Exporter::export_ok_tags( 'elements' );
  26. ###############################################################################
  27. # PPD Element: SOFTPKG
  28. ###############################################################################
  29. package PPM::XML::PPD::SOFTPKG;
  30. @ISA = qw( PPM::XML::ValidatingElement );
  31. @oattrs = qw( VERSION );
  32. @rattrs = qw( NAME );
  33. @okids = qw( ABSTRACT AUTHOR IMPLEMENTATION LICENSE TITLE INSTALL UNINSTALL );
  34. ###############################################################################
  35. # PPD Element: TITLE
  36. ###############################################################################
  37. package PPM::XML::PPD::TITLE;
  38. @ISA = qw( PPM::XML::ValidatingElement );
  39. ###############################################################################
  40. # PPD Element: ABSTRACT
  41. ###############################################################################
  42. package PPM::XML::PPD::ABSTRACT;
  43. @ISA = qw( PPM::XML::ValidatingElement );
  44. ###############################################################################
  45. # PPD Element: AUTHOR
  46. ###############################################################################
  47. package PPM::XML::PPD::AUTHOR;
  48. @ISA = qw( PPM::XML::ValidatingElement );
  49. ###############################################################################
  50. # PPD Element: LICENSE
  51. ###############################################################################
  52. package PPM::XML::PPD::LICENSE;
  53. @ISA = qw( PPM::XML::ValidatingElement );
  54. @rattrs = qw( HREF );
  55. ###############################################################################
  56. # PPD Element: IMPLEMENTATION
  57. ###############################################################################
  58. package PPM::XML::PPD::IMPLEMENTATION;
  59. @ISA = qw( PPM::XML::ValidatingElement );
  60. @okids = qw( DEPENDENCY INSTALL LANGUAGE OS OSVERSION PERLCORE PROCESSOR
  61. UNINSTALL ARCHITECTURE );
  62. @rkids = qw( CODEBASE );
  63. ###############################################################################
  64. # PPD Element: OS
  65. ###############################################################################
  66. package PPM::XML::PPD::OS;
  67. @ISA = qw( PPM::XML::ValidatingElement );
  68. @rattrs = qw( VALUE );
  69. sub validate_possible_attrs
  70. {
  71. my $self = shift;
  72. $self->compatibility_check();
  73. $self->SUPER::validate_possible_attrs( @_ );
  74. }
  75. sub validate_required_attrs
  76. {
  77. my $self = shift;
  78. $self->compatibility_check();
  79. $self->SUPER::validate_required_attrs( @_ );
  80. }
  81. sub compatibility_check
  82. {
  83. my $self = shift;
  84. if (exists $self->{NAME})
  85. {
  86. $self->{VALUE} = $self->{NAME};
  87. delete $self->{NAME};
  88. }
  89. }
  90. ###############################################################################
  91. # PPD Element: OSVERSION
  92. ###############################################################################
  93. package PPM::XML::PPD::OSVERSION;
  94. @ISA = qw( PPM::XML::ValidatingElement );
  95. @rattrs = qw( VALUE );
  96. sub validate_possible_attrs
  97. {
  98. my $self = shift;
  99. $self->compatibility_check();
  100. $self->SUPER::validate_possible_attrs( @_ );
  101. }
  102. sub validate_required_attrs
  103. {
  104. my $self = shift;
  105. $self->compatibility_check();
  106. $self->SUPER::validate_required_attrs( @_ );
  107. }
  108. sub compatibility_check
  109. {
  110. my $self = shift;
  111. if (exists $self->{NAME})
  112. {
  113. $self->{VALUE} = $self->{NAME};
  114. delete $self->{NAME};
  115. }
  116. }
  117. ###############################################################################
  118. # PPD Element: PROCESSOR
  119. ###############################################################################
  120. package PPM::XML::PPD::PROCESSOR;
  121. @ISA = qw( PPM::XML::ValidatingElement );
  122. @rattrs = qw( VALUE );
  123. sub validate_possible_attrs
  124. {
  125. my $self = shift;
  126. $self->compatibility_check();
  127. $self->SUPER::validate_possible_attrs( @_ );
  128. }
  129. sub validate_required_attrs
  130. {
  131. my $self = shift;
  132. $self->compatibility_check();
  133. $self->SUPER::validate_required_attrs( @_ );
  134. }
  135. sub compatibility_check
  136. {
  137. my $self = shift;
  138. if (exists $self->{NAME})
  139. {
  140. $self->{VALUE} = $self->{NAME};
  141. delete $self->{NAME};
  142. }
  143. }
  144. ###############################################################################
  145. # PPD Element: ARCHITECTURE
  146. ###############################################################################
  147. package PPM::XML::PPD::ARCHITECTURE;
  148. @ISA = qw( PPM::XML::ValidatingElement );
  149. @rattrs = qw( VALUE );
  150. sub validate_possible_attrs
  151. {
  152. my $self = shift;
  153. $self->compatibility_check();
  154. $self->SUPER::validate_possible_attrs( @_ );
  155. }
  156. sub validate_required_attrs
  157. {
  158. my $self = shift;
  159. $self->compatibility_check();
  160. $self->SUPER::validate_required_attrs( @_ );
  161. }
  162. sub compatibility_check
  163. {
  164. my $self = shift;
  165. if (exists $self->{NAME})
  166. {
  167. $self->{VALUE} = $self->{NAME};
  168. delete $self->{NAME};
  169. }
  170. }
  171. ###############################################################################
  172. # PPD Element: CODEBASE
  173. ###############################################################################
  174. package PPM::XML::PPD::CODEBASE;
  175. @ISA = qw( PPM::XML::ValidatingElement );
  176. @oattrs = qw( FILENAME );
  177. @rattrs = qw( HREF );
  178. ###############################################################################
  179. # PPD Element: DEPENDENCY
  180. ###############################################################################
  181. package PPM::XML::PPD::DEPENDENCY;
  182. @ISA = qw( PPM::XML::ValidatingElement );
  183. @rattrs = qw( NAME );
  184. @oattrs = qw( VERSION );
  185. ###############################################################################
  186. # PPD Element: LANGUAGE
  187. ###############################################################################
  188. package PPM::XML::PPD::LANGUAGE;
  189. @ISA = qw( PPM::XML::ValidatingElement );
  190. @rattrs = qw( VALUE );
  191. ###############################################################################
  192. # PPD Element: PERLCORE
  193. ###############################################################################
  194. package PPM::XML::PPD::PERLCORE;
  195. @ISA = qw( PPM::XML::ValidatingElement );
  196. @rattrs = qw( VERSION );
  197. ###############################################################################
  198. # PPD Element: INSTALL
  199. ###############################################################################
  200. package PPM::XML::PPD::INSTALL;
  201. @ISA = qw( PPM::XML::ValidatingElement );
  202. @oattrs = qw( HREF EXEC );
  203. ###############################################################################
  204. # PPD Element: UNINSTALL
  205. ###############################################################################
  206. package PPM::XML::PPD::UNINSTALL;
  207. @ISA = qw( PPM::XML::ValidatingElement );
  208. @oattrs = qw( HREF EXEC );
  209. __END__
  210. ###############################################################################
  211. # POD
  212. ###############################################################################
  213. =head1 NAME
  214. PPM::XML::PPD - PPD file format and XML parsing elements
  215. =head1 SYNOPSIS
  216. use XML::Parser;
  217. use PPM::XML::PPD;
  218. $p = new PPM::XML::Parser( Style => 'Objects', Pkg => 'PPM::XML::PPD' );
  219. ...
  220. =head1 DESCRIPTION
  221. This module provides a set of classes for parsing PPD files using the
  222. C<XML::Parser> module. Each of the classes is derived from
  223. C<PPM::XML::ValidatingElement>, with optional/required attributes/children
  224. enforced.
  225. =head1 MAJOR ELEMENTS
  226. =head2 SOFTPKG
  227. Defines a Perl Package. The root of a PPD document is B<always> a SOFTPKG
  228. element. The SOFTPKG element allows for the following attributes:
  229. =over 4
  230. =item NAME
  231. Required attribute. Name of the package (e.g. "Foobar").
  232. =item VERSION
  233. Version number of the package, in comma-delimited format (e.g. "1,0,0,0").
  234. =back
  235. =head2 IMPLEMENTATION
  236. Child of SOFTPKG, used to describe a particular implementation of the Perl
  237. Package. Multiple instances are valid, and should be used to describe
  238. different implementations/ports for different operating systems or
  239. architectures.
  240. =head2 DEPENDENCY
  241. Child of SOFTPKG or IMPLEMENTATION, used to indicate a dependency this Perl
  242. Package has on another Perl Package. Multiple instances are valid. The
  243. DEPENDENCY element allows for the following attributes:
  244. =over 4
  245. =item NAME
  246. Name of the package that this implementation is dependant upon.
  247. =item VERSION
  248. Version number of the dependency, in comma-delimited format (e.g. "1,0,0,0").
  249. =back
  250. =head1 MINOR ELEMENTS
  251. =head2 TITLE
  252. Child of SOFTPKG, used to state the title of the Perl Package. Only one
  253. instance should be present.
  254. =head2 ABSTRACT
  255. Child of SOFTPKG, used to provide a short description outlining the nature and
  256. purpose of the Perl Package. Only one instance should be present.
  257. =head2 AUTHOR
  258. Child of SOFTPKG, used to provide information about the author(s) of the Perl
  259. Package. Multiple instances are valid.
  260. =head2 LANGUAGE
  261. Child of IMPLEMENTATION, used to specify the language used within the given
  262. implementation of the Perl Package. Only one instance should be present.
  263. =head2 LICENSE
  264. Child of SOFTPKG, indicating the location of the appropriate license agreement
  265. or copyright notice for the Perl Package. Only one instance should be
  266. present. The LICENSE element allows for the following attributes:
  267. =over 4
  268. =item HREF
  269. Required attribute. A reference to the location of the license agreement or
  270. copyright notice for this package.
  271. =back
  272. =head2 OS
  273. Child of IMPLEMENTATION, used to outline the operating system required for this
  274. implementation of the Perl Package. Multiple instances are valid. Valid
  275. values can be taken from the OSD Specification and it's OS element. The OS
  276. element allows for the following attributes:
  277. =over 4
  278. =item VALUE
  279. The name of the operating system required for this implementation of the Perl
  280. Package. This value should be obtained from Config.pm as 'osname'.
  281. =back
  282. Note that previous versions of the PPD format used a 'NAME' attribute. It's
  283. use has been deprecated in preference of the 'VALUE' attribute. Also note that
  284. during validation, this element will automatically convert any existing 'NAME'
  285. attribute to be a 'VALUE' attribute.
  286. =head2 OSVERSION
  287. Child of IMPLEMENTATION, used to outline the required version of the operating
  288. system required for this implementation of the Perl Package. Only one instance
  289. should be present. The OSVERSION element allows for the following attributes:
  290. =over 4
  291. =item VALUE
  292. The version of the operating system required for installation of this
  293. implementation of the package, in a comma-delimited format (e.g. "3,1,0,0").
  294. =back
  295. Note that previous versions of the PPD format used a 'NAME' attribute. It's
  296. use has been deprecated in preference of the 'VALUE' attribute. Also note that
  297. during validation, this element will automatically convert any existing 'NAME'
  298. attribute to be a 'VALUE' attribute.
  299. =head2 PERLCORE
  300. Child of IMPLEMENTATION, used to specify the minimum version of the Perl core
  301. distribution that this Perl Package is to be used with. Only one instance
  302. should be present. The PERLCORE element allows for the following attributes:
  303. =over 4
  304. =item VERSION
  305. Version of the Perl core that is required for this implementation of the Perl
  306. Package.
  307. =back
  308. =head2 PROCESSOR
  309. Child of IMPLEMENTATION, outlining the cpu required for this implementation
  310. of the Perl Package. Only one instance should be present. The PROCESSOR
  311. element allows for the following attributes:
  312. =over 4
  313. =item VALUE
  314. CPU required for the installation of this implementation of the Perl Package.
  315. The following values are all valid according to the OSD Specification:
  316. x86 alpha mips sparc 680x0
  317. =back
  318. Note that previous versions of the PPD format used a 'NAME' attribute. It's
  319. use has been deprecated in preference of the 'VALUE' attribute. Also note that
  320. during validation, this element will automatically convert any existing 'NAME'
  321. attribute to be a 'VALUE' attribute.
  322. =head2 CODEBASE
  323. Child of IMPLEMENTATION, indicating a location where an archive of the Perl
  324. Package can be retrieved. Multiple instances are valid, and can be used to
  325. indicate multiple possible locations where the same version of the Perl Package
  326. can be retrieved. The CODEBASE element allows for the following attributes:
  327. =over 4
  328. =item FILENAME
  329. ???
  330. =item HREF
  331. Required attribute. A reference to the location of the Perl Package
  332. distribution.
  333. =back
  334. =head2 INSTALL
  335. Child of IMPLEMENTATION, used to provide either a reference to an
  336. installation script or a series of commands which can be used to install
  337. the Perl Package once it has been retrieved. If the EXEC attribute is not
  338. specified, the value is assumed to be one or more commands, separated by
  339. `;;'. Each such command will be executed by the Perl `system()' function.
  340. Only one instance should be present. The INSTALL element allows for
  341. the following attributes:
  342. =over 4
  343. =item HREF
  344. Reference to an external script which should be retrieved and run as part
  345. of the installation process. Both filenames and URLs should be considered
  346. valid.
  347. =item EXEC
  348. Name of interpreter/shell used to execute the installation script.
  349. If the value of EXEC is `PPM_PERL', the copy of Perl that is executing
  350. PPM itself ($^X) is used to execute the install script.
  351. =back
  352. =head2 UNINSTALL
  353. Child of IMPLEMENTATION, used to provide either a reference to an
  354. uninstallation script or a raw Perl script which can be used to uninstall the
  355. Perl Package at a later point. Only one instance should be present. The
  356. UNINSTALL element allows for the following attributs:
  357. =over 4
  358. =item HREF
  359. Reference to an external script which should be retrieved and run as part of
  360. the removal process. Both filenames and URLs should be considered valid.
  361. =item EXEC
  362. Name of interpreter/shell used to execute the uninstallation script.
  363. If the value of EXEC is `PPM_PERL', the copy of Perl that is executing
  364. PPM itself ($^X) is used to execute the install script.
  365. =back
  366. =head1 DOCUMENT TYPE DEFINITION
  367. The DTD for PPD documents is available from the ActiveState website and the
  368. latest version can be found at http://www.ActiveState.com/PPM/DTD/ppd.dtd
  369. This revision of the C<PPM::XML::PPD> module implements the following DTD:
  370. <!ELEMENT SOFTPKG (ABSTRACT | AUTHOR | IMPLEMENTATION | LICENSE | TITLE)*>
  371. <!ATTLIST SOFTPKG NAME CDATA #REQUIRED
  372. VERSION CDATA #IMPLIED>
  373. <!ELEMENT TITLE (#PCDATA)>
  374. <!ELEMENT ABSTRACT (#PCDATA)>
  375. <!ELEMENT AUTHOR (#PCDATA)>
  376. <!ELEMENT LICENSE EMPTY>
  377. <!ATTLIST LICENSE HREF CDATA #REQUIRED>
  378. <!ELEMENT IMPLEMENTATION (CODEBASE | DEPENDENCY | LANGUAGE | OS |
  379. OSVERSION | PERLCORE | PROCESSOR | INSTALL |
  380. UNINSTALL) *>
  381. <!ELEMENT CODEBASE EMPTY>
  382. <!ATTLIST CODEBASE FILENAME CDATA #IMPLIED
  383. HREF CDATA #REQUIRED>
  384. <!ELEMENT DEPENDENCY EMPTY>
  385. <!ATTLIST DEPENDENCY VERSION CDATA #IMPLIED
  386. NAME CDATA #REQUIRED>
  387. <!ELEMENT LANGUAGE EMPTY>
  388. <!ATTLIST LANGUAGE VALUE CDATA #REQUIRED>
  389. <!ELEMENT OS EMPTY>
  390. <!ATTLIST OS VALUE CDATA #REQUIRED>
  391. <!ELEMENT OSVERSION EMPTY>
  392. <!ATTLIST OSVERSION VALUE CDATA #REQUIRED>
  393. <!ELEMENT PERLCORE EMPTY>
  394. <!ATTLIST PERLCORE VERSION CDATA #REQUIRED>
  395. <!ELEMENT PROCESSOR EMPTY>
  396. <!ATTLIST PROCESSOR VALUE CDATA #REQUIRED>
  397. <!ELEMENT INSTALL (#PCDATA)>
  398. <!ATTLIST INSTALL HREF CDATA #IMPLIED
  399. EXEC CDATA #IMPLIED>
  400. <!ELEMENT UNINSTALL (#PCDATA)>
  401. <!ATTLIST UNINSTALL HREF CDATA #IMPLIED
  402. EXEC CDATA #IMPLIED>
  403. =head1 SAMPLE PPD FILE
  404. The following is a sample PPD file describing the C<Math-MatrixBool> module.
  405. Note that this may B<not> be a current/proper description of this module and is
  406. for sample purposes only.
  407. <SOFTPKG NAME="Math-MatrixBool" VERSION="4,2,0,0">
  408. <TITLE>Math-MatrixBool</TITLE>
  409. <ABSTRACT>Easy manipulation of matrices of booleans (Boolean Algebra)</ABSTRACT>
  410. <AUTHOR>Steffen Beyer (sb@sdm.de)</AUTHOR>
  411. <LICENSE HREF="http://www.ActiveState.com/packages/Math-MatrixBool/license.html" />
  412. <IMPLEMENTATION>
  413. <OS VALUE="WinNT" />
  414. <OS VALUE="Win95" />
  415. <PROCESSOR VALUE="x86" />
  416. <CODEBASE HREF="http://www.ActiveState.com/packages/Math-MatrixBool/Math-MatrixBool-4.2-bin-1-Win32.tar.gz" />
  417. <DEPENDENCY NAME="Bit-Vector" />
  418. <INSTALL>
  419. </INSTALL>
  420. <UNINSTALL>
  421. </UNINSTALL>
  422. </IMPLEMENTATION>
  423. <IMPLEMENTATION>
  424. <DEPENDENCY NAME="Bit-Vector" />
  425. <CODEBASE HREF="&CPAN;/CPAN/modules/by-module/Math/Math-MatrixBool-4.2.tar.gz" />
  426. <INSTALL>
  427. system("make"); ;;
  428. system("make test"); ;;
  429. system("make install"); ;;
  430. </INSTALL>
  431. </IMPLEMENTATION>
  432. </SOFTPKG>
  433. =head1 KNOWN BUGS/ISSUES
  434. Elements which are required to be empty (e.g. LICENSE) are not enforced as
  435. such.
  436. Notations above about elements for which "only one instance" or "multiple
  437. instances" are valid are not enforced; this primarily a guideline for
  438. generating your own PPD files.
  439. =head1 AUTHORS
  440. Graham TerMarsch <[email protected]>
  441. Murray Nesbitt <[email protected]>
  442. Dick Hardt <[email protected]>
  443. =head1 HISTORY
  444. v0.1 - Initial release
  445. =head1 SEE ALSO
  446. L<PPM::XML::ValidatingElement>,
  447. L<PPM::XML::Element>,
  448. L<XML::Parser>,
  449. OSD Specification (http://www.microsoft.com/standards/osd/)
  450. =cut