]> git.pld-linux.org Git - packages/php-pear-PEAR_Command_Packaging.git/blame - php-pear-PEAR_Command_Packaging.patch
- drop obsolete and outdated manual inclusion of rpm macros
[packages/php-pear-PEAR_Command_Packaging.git] / php-pear-PEAR_Command_Packaging.patch
CommitLineData
462360eb
ER
1--- PEAR_Command_Packaging-0.2.0/usr/share/pear/PEAR/Command/Packaging.php 2011-04-10 18:34:41.270846822 +0300
2+++ PEAR_Command_Packaging-0.2.0/usr/share/pear/PEAR/Command/Packaging.php 2011-05-03 09:26:29.397841813 +0300
c7370ff4
ER
3@@ -54,6 +54,11 @@
4 'arg' => 'FILE',
5 'doc' => 'Use FILE as RPM spec file template'
6 ),
7+ 'output' => array(
8+ 'shortopt' => 'o',
9+ 'arg' => 'FILE',
10+ 'doc' => 'Use FILE as output filename'
11+ ),
12 'rpm-release' => array(
13 'shortopt' => 'r',
14 'arg' => 'RELEASE',
0016a88c 15@@ -121,10 +126,10 @@
e3e1e10f
ER
16 * $commands array above and in Packaging.xml so that it is consistent.
17 */
18 var $_rpm_pkgname_format = array(
19- 'pkg' => '%C::%s',
e8de4f4b 20+ 'pkg' => 'php-%c-%s',
e3e1e10f
ER
21 'chan' => 'php-channel-%c',
22 );
0016a88c
ER
23-
24+
25 /**
26 * The default format of various dependencies that might be generated in the
27 * spec file. The currently-handled dependency types are:
e8de4f4b
ER
28@@ -140,9 +145,11 @@
29 * %P = use the same as whatever rpm_pkgname_format is set to be
30 */
e3e1e10f 31 var $_rpm_depname_format = array(
e8de4f4b
ER
32- 'pkg' => '%P',
33+ 'pkg' => 'php-%c-%s',
e3e1e10f
ER
34 'ext' => 'php-%l',
35- 'php' => 'php',
0016a88c 36+ 'pear-pkg' => 'php-pear-%s',
e3e1e10f
ER
37+ 'pecl-ext' => 'php-pecl-%l',
38+ 'php' => 'php-common',
39 'chan' => 'php-channel(%n)',
40 );
ef7632ee 41
0016a88c 42@@ -159,7 +166,7 @@
e3e1e10f
ER
43 * chan - used when generating a spec file for a channel
44 */
45 var $_rpm_specname_format = array(
46- 'pkg' => '%P-%v.spec',
47+ 'pkg' => '%P.spec',
48 'chan' => 'php-channel-%c.spec'
49 );
50
462360eb 51@@ -182,22 +189,30 @@
e3e1e10f
ER
52 * need to be listed here
53 */
54 var $_file_prefixes = array(
55- 'php' => '%{_libdir}/php/pear',
56+ 'php' => '%{php_pear_dir}',
57 'doc' => '',
58- 'ext' => '%{_libdir}/php',
59- 'test' => '%{_libdir}/php/tests/%s',
60- 'data' => '%{_libdir}/php/data/%s',
61+ 'ext' => '%{%php_extensiondir}',
62+ 'test' => '%{php_pear_dir}/tests/%s',
63+ 'data' => '%{php_pear_dir}/data/%s',
64 'script' => '%{_bindir}',
65 'cfg' => '%{_sysconfdir}/pear',
66 'www' => '%{_datadir}/pear/www'
462360eb
ER
67 );
68+
69+ /**
70+ * Role packages to use for non-standard file roles. Used when generating
71+ * specs for packages only.
72+ */
73+ var $_role_packages = array(
74+ 'horde' => 'php-horde-Horde_Role',
75+ );
76
77 /**
78 * The format to use when adding new RPM header lines to the spec file, in
e3e1e10f
ER
79 * printf format. The first '%s' is the RPM header name followed by a colon,
80 * the second is the header value.
81 */
82- var $_spec_line_format = '%s %s';
83+ var $_spec_line_format = "%s\t%s";
84
85 // ------------------------------------------------------------------------
86 // --- END DISTRIBUTION CONFIG
462360eb 87@@ -247,6 +262,7 @@
e3e1e10f
ER
88 'test_dir' => '',
89 'test_files_statement' => '',// empty string, or list of test files
90 'www_files_statement' => '', // empty string, or newline-separated list of files with "www" role
91+ '_noautoreq' => '', // no autoreqdep. PLD Linux specific
92 );
93
94 // The name of the template spec file to use
462360eb 95@@ -330,15 +346,24 @@
c7370ff4
ER
96
97 // Initialise the RPM package/dep naming format options
98 $this->_initialiseNamingOptions($options);
99-
100+
101 // Set the RPM release version
e3e1e10f
ER
102 if (isset($options['rpm-release'])) {
103 $this->_output['release'] = $options['rpm-release'];
058d51f5
ER
104 }
105+
c7370ff4
ER
106+ // Pass output file in options
107+ if (isset($options['output'])) {
108+ $this->_output['output-file'] = $options['output'];
109+ }
110+
e3e1e10f
ER
111+ // PLD Linux specific. need source md5
112+ $this->_output['tarball'] = $source_file;
113+ $this->_output['tarball_md5'] = md5(file_get_contents($source_file));
ef7632ee 114
e3e1e10f
ER
115 // Set the PEAR RPM name for the PEAR core package
116 $this->_output['pear_rpm_name'] = $this->_getRPMName('PEAR', 'pear.php.net', null, 'pkgdep');
117-
ef7632ee 118+
e3e1e10f
ER
119 // If source file ends in ".xml" we assume we are creating an RPM spec
120 // for a channel rather than an actual package
121 if (substr(strtolower($source_file), -4) == '.xml') {
462360eb 122@@ -378,13 +403,40 @@
e3e1e10f
ER
123 /**
124 * Format an RPM header line to be added to the spec file
125 * @param string $header The name of the RPM header to be added
126- * @param string $value The contents of the RPM header
127+ * @param mixed $value The contents of the RPM header
128 * @return string
129 */
130- function _formatRpmHeader($header, $value)
131+ function _formatRpmHeader($header, $values)
462360eb 132+ {
e3e1e10f
ER
133+ // PLD Linux: we want values sorted and each on their line
134+ $values = (array )$values;
135+ sort($values);
136+ $ret = '';
137+ foreach ($values as $value) {
138+ $ret .= sprintf($this->_spec_line_format, $header . ':', $value) . "\n";
139+ }
140+ return $ret;
462360eb 141+ }
ef7632ee 142+
5e8b1d0c 143+
e3e1e10f
ER
144+ /*
145+ * Get an version for RPM package.
146+ *
147+ * @param string $version Package version (e.g. '1.2.3RC1')
148+ * @return string Normalized version
149+ */
150+ function _formatRpmVersion($version)
462360eb
ER
151 {
152- return sprintf($this->_spec_line_format, $header . ':', $value);
ef7632ee 153+
e3e1e10f
ER
154+ // In PLD Linux alpha, beta, rc versions are noted in Release: not Version: tag.
155+ preg_match('/^(?P<version>[0-9.]+)(?P<extraversion>.*)$/', $version, $m);
156+ if ($m['extraversion']) {
157+ $version = "{$m['version']}-0.{$m['extraversion']}";
158+ }
a1113279 159+
e3e1e10f 160+ return $version;
462360eb 161 }
a1113279 162+
e3e1e10f
ER
163
164 /**
165 * Replace a macro in the output spec file
462360eb 166@@ -410,16 +462,20 @@
c7370ff4
ER
167 } else {
168 $package_name = null;
169 }
170-
171+
172 // Work out the name of the output spec file
173- $spec_file = $this->_getRPMNameFromFormat(
174- $this->_rpm_specname_format[$type],
175- $package_name,
176- $this->_output['possible_channel'],
177- $this->_output['channel_alias'],
178- $this->_output['version']
179- );
180-
181+ if (isset($this->_output['output-file'])) {
182+ $spec_file = $this->_output['output-file'];
183+ } else {
184+ $spec_file = $this->_getRPMNameFromFormat(
185+ $this->_rpm_specname_format[$type],
186+ $package_name,
187+ $this->_output['possible_channel'],
188+ $this->_output['channel_alias'],
189+ $this->_output['version']
190+ );
191+ }
192+
193 // Write the actual file
194 $wp = fopen($spec_file, 'wb');
195 if (!$wp) {
462360eb 196@@ -457,7 +513,7 @@
e3e1e10f
ER
197
198 $rpmdep = $this->_getRPMName(null, $cf->getName(), $cf->getAlias(), 'chandep');
199 if (!empty($rpmdep) && $rpmdep != $this->_output['rpm_package']) {
200- $this->_output['extra_headers'] = $this->_formatRpmHeader('Provides', "$rpmdep") . "\n";
201+ $this->_output['extra_headers'] = $this->_formatRpmHeader('Provides', $rpmdep) . "\n";
202 }
203
204 // Channels don't really have version numbers; this will need to be
462360eb 205@@ -564,7 +620,7 @@
e3e1e10f
ER
206
207 // Set up some of the basic macros
208 $this->_output['rpm_package'] = $this->_getRPMName($pf->getPackage(), $pf->getChannel(), null, 'pkg');
209- $this->_output['description'] = wordwrap($package_info['description']);
210+ $this->_output['description'] = wordwrap($package_info['description'], 70);
211 $this->_output['summary'] = trim($package_info['summary']);
212 $this->_output['possible_channel'] = $pf->getChannel();
213 $this->_output['channel_alias'] = $this->_getChannelAlias($pf->getPackage(), $pf->getChannel());
462360eb
ER
214@@ -591,7 +647,7 @@
215
216 // Generate the Requires and Conflicts for the RPM
217 if ($pf->getDeps()) {
218- $this->_generatePackageDeps($pf);
219+ $this->_generatePackageDeps($pf, $package_info['filelist']);
220 }
221
222 // Hook to support virtual Provides, where the dependency name differs
223@@ -646,14 +702,24 @@
e3e1e10f
ER
224 if (substr($this->_file_prefixes[$role], -2) == '%s') {
225 $this->_output[$macro_name] = str_replace('%s', $pf->getPackage(), $this->_file_prefixes[$role]);
226 } else {
227+ $attr = '';
228 if ($role == 'cfg') {
229- $this->_output[$macro_name] = '%config(noreplace) ' . implode("\n%config(noreplace) ", $files);
230- } else {
231- $this->_output[$macro_name] = implode("\n", $files);
232+ $attr = '%config(noreplace) %verify(not md5 mtime size) ';
233+ } elseif ($role == 'script') {
234+ $attr = '%attr(755,root,root) ';
ef7632ee 235 }
e3e1e10f
ER
236+ $this->_output[$macro_name] = $attr . implode("\n$attr", $files);
237 }
238 }
239 $this->_output['files'] = trim($this->_output['files']);
70b1083e
ER
240+
241+ // figure registry file location
242+ if (in_array($this->_output['possible_channel'], $this->_standard_channels)) {
243+ $registry_dir = '%s/.registry/*.reg';
244+ } else {
245+ $registry_dir = '%s/.registry/.channel.*/*.reg';
246+ }
247+ $this->_output['registry_files_statement'] = str_replace('%s', $this->_file_prefixes['php'], $registry_dir);
248
249 // Handle doc files
250 if (isset($file_list['doc'])) {
462360eb
ER
251@@ -683,14 +749,13 @@
252 }
253
e3e1e10f 254
462360eb
ER
255- function _generatePackageDeps($pf)
256+ function _generatePackageDeps($pf, $filelist)
e3e1e10f
ER
257 {
258- $requires = $conflicts = array();
259+ $buildrequires = $requires = $conflicts = $suggests = array();
260 if ($pf->getPackagexmlVersion() == '1.0') {
c9a11f9c 261- foreach ($pf->getDeps() as $dep) {
e3e1e10f
ER
262- if (isset($dep['optional']) && $dep['optional'] == 'yes') {
263- continue;
264- }
c9a11f9c
ER
265+ $deps = $pf->getDeps();
266+ foreach ($deps as $dep) {
e3e1e10f
ER
267+ $optional = isset($dep['optional']) && $dep['optional'] == 'yes';
268
269 if (!isset($dep['type']) || $dep['type'] == 'pkg') {
270 $type = 'pkgdep';
462360eb 271@@ -698,8 +763,14 @@
c9a11f9c
ER
272 $type = $dep['type'];
273 }
274
275- if (!isset($dep['channel'])) $dep['channel'] = null;
276 if (!isset($dep['name'])) $dep['name'] = ''; //e.g. "php" dep
277+ if (!isset($dep['channel'])) {
278+ // we need to figure out channel as pecl packages are might
279+ // be named differently than pear packages.
280+ $chan_alias = $this->_getChannelAlias($dep['name']);
281+ $reg = &$this->config->getRegistry();
282+ $dep['channel'] = $reg->channelName($chan_alias);
283+ }
284
285 // $package contains the *dependency name* here, which may or may
286 // not be the same as the package name
462360eb 287@@ -725,21 +796,25 @@
e3e1e10f
ER
288 if ($dep['rel'] == 'has') {
289 // We use $package as the index to the $requires array to de-duplicate deps.
290 // Note that in the case of duplicate deps, versioned deps will "win" - see several lines down.
291- $requires[$package] = $package;
292+ if ($optional) {
293+ $suggests[$package] = $package;
294+ } else {
295+ $requires[$package] = $package;
296+ }
297 } elseif ($dep['rel'] == 'not') {
298 $conflicts[] = $package;
299 } elseif ($dep['rel'] == 'ne') {
300- $conflicts[] = $package . ' = ' . $dep['version'];
301+ $version = $this->_formatRpmVersion($dep['version']);
302+ $conflicts[] = $package . ' = ' . $version;
303 } elseif (isset($trans[$dep['rel']])) {
304- $requires[$package] = $package . ' ' . $trans[$dep['rel']] . ' ' . $dep['version'];
305+ $version = $this->_formatRpmVersion($dep['version']);
306+ if ($optional) {
307+ $suggests[$package] = $package . ' ' . $trans[$dep['rel']] . ' ' . $version;
308+ } else {
309+ $requires[$package] = $package . ' ' . $trans[$dep['rel']] . ' ' . $version;
310+ }
ef7632ee 311 }
e3e1e10f
ER
312 }
313- if (count($requires)) {
314- $this->_output['extra_headers'] .= $this->_formatRpmHeader('Requires', implode(', ', $requires)) . "\n";
315- }
316- if (count($conflicts)) {
317- $this->_output['extra_headers'] .= $this->_formatRpmHeader('Conflicts', implode(', ', $conflicts)) . "\n";
318- }
319 } else {
320 $this->_output['package2xml'] = '2'; // tell the spec to use package2.xml
321 $deps = $pf->getDeps(true);
462360eb 322@@ -842,10 +917,10 @@
e3e1e10f
ER
323 }
324 } else {
325 if (isset($dep['min'])) {
326- $requires[$package] = $package . ' >= ' . $dep['min'];
327+ $requires[$package] = $package . ' >= ' . $this->_formatRpmVersion($dep['min']);
328 }
329 if (isset($dep['max'])) {
330- $requires[$package] = $package . ' <= ' . $dep['max'];
331+ $requires[$package] = $package . ' <= ' . $this->_formatRpmVersion($dep['max']);
332 }
333 if (isset($dep['exclude'])) {
334 $ex = $dep['exclude'];
462360eb 335@@ -865,17 +940,125 @@
e3e1e10f
ER
336 $tar->popErrorHandling();
337 if ($a === null || PEAR::isError($a)) {
338- $this->_output['package2xml'] = '';
339 // this doesn't have a package.xml version 1.0
340- $requires[$this->_output['pear_rpm_name']] = $this->_output['pear_rpm_name'] . ' >= ' .
341- $deps['required']['pearinstaller']['min'];
342+ $this->_output['package2xml'] = '';
343+ $version = $this->_formatRpmVersion($deps['required']['pearinstaller']['min']);
344+ // PLD linux hack: include epoch for PEAR package
345+ $version = "1:{$version}";
346+ $buildrequires[$this->_output['pear_rpm_name']] = $this->_output['pear_rpm_name'] . ' >= ' . $version;
666df649
ER
347 }
348- if (count($requires)) {
349- $this->_output['extra_headers'] .= $this->_formatRpmHeader('Requires', implode(', ', $requires)) . "\n";
e3e1e10f
ER
350+ }
351+
352+ if (isset($deps['required']['extension'])) {
353+ if (!isset($deps['required']['extension'][0])) {
354+ $deps['required']['extension'] = array($deps['required']['extension']);
462360eb 355+ }
e3e1e10f
ER
356+ foreach ((array )$deps['required']['extension'] as $dep) {
357+ if (!isset($dep['channel'])) $dep['channel'] = null;
358+ // $package contains the *dependency name* here, which may or may
359+ // not be the same as the package name
360+ $package = $this->_getRPMName($dep['name'], $dep['channel'], null, 'ext');
a1113279 361+
e3e1e10f
ER
362+ if (empty($package)) {
363+ continue;
364+ }
a1113279 365+
e3e1e10f 366+ $requires[$package] = $package;
462360eb
ER
367+ }
368+ }
e3e1e10f
ER
369+
370+ if (isset($deps['required']['subpackage'])) {
371+ if (!isset($deps['required']['subpackage'][0])) {
372+ $deps['required']['subpackage'] = array($deps['required']['subpackage']);
0016a88c 373+ }
e3e1e10f
ER
374+ foreach ($deps['required']['subpackage'] as $dep) {
375+ if (!isset($dep['channel'])) $dep['channel'] = null;
376+
377+ // $package contains the *dependency name* here, which may or may
378+ // not be the same as the package name
379+ $package = $this->_getRPMName($dep['name'], $dep['channel'], null, 'pkgdep');
a1113279 380+
e3e1e10f
ER
381+ if (empty($package)) {
382+ continue;
383+ }
384+
385+ $requires[$package] = $package;
386+ // XXX: should be more complese like above with ranges, etc
0016a88c
ER
387+ }
388+ }
5e8b1d0c 389+
e3e1e10f
ER
390+ if (isset($deps['optional']['package'])) {
391+ if (!isset($deps['optional']['package'][0])) {
392+ $deps['optional']['package'] = array($deps['optional']['package']);
666df649 393+ }
e3e1e10f
ER
394+ foreach ($deps['optional']['package'] as $dep) {
395+ if (!isset($dep['channel'])) $dep['channel'] = null;
396+
397+ // $package contains the *dependency name* here, which may or may
398+ // not be the same as the package name
399+ $package = $this->_getRPMName($dep['name'], $dep['channel'], null, 'pkgdep');
400+
401+ if (empty($package)) {
402+ continue;
403+ }
404+
405+ // suggests are not versioned (makes no sense in poldek)
406+ $suggests[$package] = $package;
407+
0d58ecc5 408+ // PLD Linux: Fill extra info for _noautoreq deps
e3e1e10f 409+ $this->_output['_noautoreq'] .= " pear(". str_replace('_', '/', $dep['name']) . ".*)";
462360eb
ER
410 }
411- if (count($conflicts)) {
412- $this->_output['extra_headers'] .= $this->_formatRpmHeader('Conflicts', implode(', ', $conflicts)) . "\n";
a1113279 413+ }
a1113279 414+
e3e1e10f
ER
415+ if (isset($deps['optional']['extension'])) {
416+ if (!isset($deps['optional']['extension'][0])) {
417+ $deps['optional']['extension'] = array($deps['optional']['extension']);
418+ }
419+ foreach ($deps['optional']['extension'] as $dep) {
420+ if (!isset($dep['channel'])) $dep['channel'] = null;
421+
422+ // $package contains the *dependency name* here, which may or may
423+ // not be the same as the package name
424+ $package = $this->_getRPMName($dep['name'], $dep['channel'], null, 'ext');
40e896a5 425+
e3e1e10f
ER
426+ if (empty($package)) {
427+ continue;
428+ }
429+
430+ // suggests are not versioned (makes no sense in poldek)
431+ $suggests[$package] = $package;
462360eb
ER
432 }
433 }
434 }
435+
436+ // go over filelist, to see if we need custom Role package presence
437+ foreach ($filelist as $filename => $attr) {
438+ // Ignore files with no role set or that didn't get installed
439+ if (!isset($attr['role']) || !isset($attr['installed_as'])) {
440+ continue;
441+ }
442+ $role = $attr['role'];
443+
444+ if (!isset($this->_file_prefixes[$role])) {
445+ if (isset($this->_role_packages[$role])) {
446+ $pkg = $this->_role_packages[$role];
447+ $buildrequires[$pkg] = $pkg;
70b1083e 448+ }
462360eb 449+ // TODO: else use some rpm virtual provides for role?
70b1083e
ER
450+ }
451+ }
40e896a5 452+
e3e1e10f
ER
453+ // append extra headers which we collected
454+ if (count($buildrequires)) {
455+ $this->_output['extra_headers'] .= $this->_formatRpmHeader('BuildRequires', $buildrequires) . "\n";
456+ }
457+ if (count($requires)) {
458+ $this->_output['extra_headers'] .= $this->_formatRpmHeader('Requires', $requires) . "\n";
459+ }
460+ if (count($conflicts)) {
461+ $this->_output['extra_headers'] .= $this->_formatRpmHeader('Conflicts', $conflicts) . "\n";
462+ }
463+ if (count($suggests)) {
464+ $this->_output['extra_headers'] .= $this->_formatRpmHeader('Suggests', $suggests) . "\n";
462360eb 465+ }
e3e1e10f
ER
466 }
467
462360eb 468@@ -927,9 +1110,21 @@
e3e1e10f
ER
469 case 'pkg':
470 return $this->_getRPMNameFromFormat($this->_rpm_pkgname_format['pkg'], $package_name, $chan_name, $chan_alias);
471 case 'pkgdep':
472- $type = 'pkg';
473+ // PLD Linux: pecl extensions have different naming format
474+ if ($chan_alias == 'PECL') {
475+ $type = 'pecl-ext';
0016a88c
ER
476+ } elseif ($chan_alias == 'PEAR') {
477+ $type = 'pear-pkg';
e3e1e10f
ER
478+ } else {
479+ $type = 'pkg';
480+ }
481 // let it drop through...
482 default:
666df649
ER
483+ // PLD Linux: sanitize gtk2 ext name.
484+ // http://bugs.php.net/bug.php?id=52663
485+ if ($type == 'ext' && $package_name == 'php-gtk') {
486+ $package_name = 'gtk2';
487+ }
c7370ff4 488 if (isset($this->_rpm_depname_format[$type]) && !empty($this->_rpm_depname_format[$type])) {
666df649
ER
489 return $this->_getRPMNameFromFormat($this->_rpm_depname_format[$type], $package_name, $chan_name, $chan_alias);
490 }
This page took 0.165489 seconds and 4 git commands to generate.