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