mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Handle pkgbase array overrides gracefully
Instead of overwriting arrays, such as depends, from the pkgbase section, new entries should be appended. Replace array_merge() with a mixture of array_merge_recursive() and array_replace_recursive() that merges array fields and replaces non-array fields. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
e582cfe182
commit
34453d3295
2 changed files with 27 additions and 2 deletions
|
@ -147,7 +147,7 @@ if ($uid):
|
||||||
if (isset($section_info['pkgbase'])) {
|
if (isset($section_info['pkgbase'])) {
|
||||||
$pkgbase_info = $section_info;
|
$pkgbase_info = $section_info;
|
||||||
} elseif (isset($section_info['pkgname'])) {
|
} elseif (isset($section_info['pkgname'])) {
|
||||||
$pkginfo[] = array_merge($pkgbase_info, $section_info);
|
$pkginfo[] = array_pkgbuild_merge($pkgbase_info, $section_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$section_info = array(
|
$section_info = array(
|
||||||
|
@ -180,7 +180,7 @@ if ($uid):
|
||||||
if (isset($section_info['pkgbase'])) {
|
if (isset($section_info['pkgbase'])) {
|
||||||
$pkgbase_info = $section_info;
|
$pkgbase_info = $section_info;
|
||||||
} elseif (isset($section_info['pkgname'])) {
|
} elseif (isset($section_info['pkgname'])) {
|
||||||
$pkginfo[] = array_merge($pkgbase_info, $section_info);
|
$pkginfo[] = array_pkgbuild_merge($pkgbase_info, $section_info);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Use data from the PKGBUILD parser (deprecated!) */
|
/* Use data from the PKGBUILD parser (deprecated!) */
|
||||||
|
|
|
@ -572,3 +572,28 @@ function latest_pkgs($numpkgs) {
|
||||||
|
|
||||||
return $packages;
|
return $packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge pkgbase and package options
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* merged. If a key appears in both arrays and the corresponding value is not
|
||||||
|
* an array, the second value replaces the first one.
|
||||||
|
*
|
||||||
|
* @param array $pkgbase_info Options from the pkgbase section
|
||||||
|
* @param array $section_info Options from the package section
|
||||||
|
*
|
||||||
|
* @return array Merged information from both sections
|
||||||
|
*/
|
||||||
|
function array_pkgbuild_merge($pkgbase_info, $section_info) {
|
||||||
|
$pi = $pkgbase_info;
|
||||||
|
foreach ($section_info as $opt_key => $opt_val) {
|
||||||
|
if (is_array($opt_val)) {
|
||||||
|
$pi[$opt_key] += $opt_val;
|
||||||
|
} else {
|
||||||
|
$pi[$opt_key] = $opt_val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pi;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue