diff options
author | Dave Reisner <dreisner@archlinux.org> | 2014-07-25 20:01:48 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-08-08 05:44:25 +0200 |
commit | 2b556d89de0d3f10466b4db4d8915a3ffb1163de (patch) | |
tree | 94487f5689c4a15e4d589abf3e6058624c8bd53a /scripts | |
parent | cbd6c300b5bdf61b7df80f42cf06c69a6e4fde60 (diff) | |
download | pacman-2b556d89de0d3f10466b4db4d8915a3ffb1163de.tar.gz pacman-2b556d89de0d3f10466b4db4d8915a3ffb1163de.tar.xz |
PKGBUILD: handle arch specific attributes
This introduces support for architecture-specific conflicts, depends,
optdepends, makedepends, replaces, and conflicts by appending "_$CARCH"
to the array name. For example, in the global section:
arch=('i686' 'x86_64')
depends=('foo')
depends_x86_64=('bar')
This will generate depends of 'foo' and 'bar' on x86_64, but only 'foo'
on i686. Moreover, this is supported in the package functions with the
same heuristics as the generic names, e.g.
...
arch=('i686' 'x86_64')
depends=('foo')
...
package_somepkg() {
depends_x86_64=('bar')
...
}
Again, will cause x86_64 to have depends of 'foo' and 'bar', but only
'foo' for i686.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/makepkg.sh.in | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 82aee3de..b40c38dd 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1475,6 +1475,24 @@ source_safe() { shopt -s extglob } +merge_arch_attrs() { + local attr supported_attrs=( + provides conflicts depends replaces optdepends + makedepends checkdepends) + + for attr in "${supported_attrs[@]}"; do + eval "$attr+=(\"\${${attr}_$CARCH[@]}\")" + done + + # ensure that calling this function is idempotent. + unset -v "${supported_attrs[@]/%/_$CARCH}" +} + +source_buildfile() { + source_safe "$@" + merge_arch_attrs +} + run_function_safe() { local restoretrap @@ -1893,6 +1911,8 @@ write_pkginfo() { local size="$(@DUPATH@ @DUFLAGS@)" size="$(( ${size%%[^0-9]*} * 1024 ))" + merge_arch_attrs + msg2 "$(gettext "Generating %s file...")" ".PKGINFO" printf "# Generated by makepkg %s\n" "$makepkg_version" printf "# using %s\n" "$(fakeroot -v)" @@ -2359,13 +2379,24 @@ lint_arch() { } lint_provides() { - local list name provides_list ret=0 + local a list name provides_list ret=0 provides_list=("${provides[@]}") + for a in "${arch[@]}"; do + array_build list "provides_$a" + provides_list+=("${list[@]}") + done + for name in "${pkgname[@]}"; do if extract_function_var "package_$name" provides 1 list; then provides_list+=("${list[@]}") fi + + for a in "${arch[@]}"; do + if extract_function_var "package_$name" "provides_$a" 1 list; then + provides_list+=("${list[@]}") + fi + done done for provide in "${provides_list[@]}"; do @@ -2399,13 +2430,24 @@ lint_backup() { } lint_optdepends() { - local list name optdepends_list ret=0 + local a list name optdepends_list ret=0 optdepends_list=("${optdepends[@]}") + for a in "${arch[@]}"; do + array_build list "optdepends_$a" + optdepends_list+=("${list[@]}") + done + for name in "${pkgname[@]}"; do if extract_function_var "package_$name" optdepends 1 list; then optdepends_list+=("${list[@]}") fi + + for a in "${arch[@]}"; do + if extract_function_var "package_$name" "optdepends_$a" 1 list; then + optdepends_list+=("${list[@]}") + fi + done done for name in "${optdepends_list[@]}"; do @@ -3161,7 +3203,7 @@ else if [[ ${BUILDFILE:0:1} != "/" ]]; then BUILDFILE="$startdir/$BUILDFILE" fi - source_safe "$BUILDFILE" + source_buildfile "$BUILDFILE" fi # set defaults if they weren't specified in buildfile |