Fix parsing of array overrides

If a depends (makedepends, checkdepends, optdepends, conflicts,
provides, replaces, license, groups, source) line appears in a package
section, it replaces the corresponding array from the pkgbase section.
If there is a single "depends = " line in the package section, the
depends array of that package is considered empty.

This partly reverts the behavior introduced in commit 137a9ae (Fix
parsing of array overrides, 2014-05-03).

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-05-03 18:01:49 +02:00
parent e161c4f94b
commit 782e9eb188
2 changed files with 12 additions and 5 deletions

View file

@ -135,7 +135,7 @@ if ($uid):
$pkginfo = array(); $pkginfo = array();
$section_info = array(); $section_info = array();
foreach (explode("\n", $srcinfo_raw) as $line) { foreach (explode("\n", $srcinfo_raw) as $line) {
$line = trim($line); $line = ltrim($line);
if (empty($line) || $line[0] == '#') { if (empty($line) || $line[0] == '#') {
continue; continue;
} }

View file

@ -577,9 +577,12 @@ function latest_pkgs($numpkgs) {
* Merge pkgbase and package options * Merge pkgbase and package options
* *
* Merges entries of the first and the second array. If any key appears in both * Merges entries of the first and the second array. If any key appears in both
* arrays and the corresponding value is an array itself, the arrays are * arrays and the corresponding value in the second array is either a non-array
* merged. If a key appears in both arrays and the corresponding value is not * type or a non-empty array, the value from the second array replaces the
* an array, the second value replaces the first one. * value from the first array. If the value from the second array is an array
* containing a single empty string, the value in the resulting array becomes
* an empty array instead. If the value in the second array is empty, the
* resulting array contains the value from the first array.
* *
* @param array $pkgbase_info Options from the pkgbase section * @param array $pkgbase_info Options from the pkgbase section
* @param array $section_info Options from the package section * @param array $section_info Options from the package section
@ -590,7 +593,11 @@ function array_pkgbuild_merge($pkgbase_info, $section_info) {
$pi = $pkgbase_info; $pi = $pkgbase_info;
foreach ($section_info as $opt_key => $opt_val) { foreach ($section_info as $opt_key => $opt_val) {
if (is_array($opt_val)) { if (is_array($opt_val)) {
$pi[$opt_key] += $opt_val; if ($opt_val == array('')) {
$pi[$opt_key] = array();
} elseif (count($opt_val) > 0) {
$pi[$opt_key] = $opt_val;
}
} else { } else {
$pi[$opt_key] = $opt_val; $pi[$opt_key] = $opt_val;
} }