This introduces support for architecutre-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. --- v2: 1) extended this to a bunch more attributes -- some of them I can't necessarily reason an immediate use case for, but conceptually could have their uses as arch-specific attributes. 2) Added documentation 3) Added check_sanity support post mega-refactoring. doc/PKGBUILD.5.txt | 21 +++++++++++++++++++++ scripts/makepkg.sh.in | 46 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 17e8af2..5cebbbd 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -183,17 +183,26 @@ If the dependency name appears to be a library (ends with .so), makepkg will try to find a binary that depends on the library in the built package and append the version needed by the binary. Appending the version yourself disables automatic detection. ++ +Architecture-specific depends can be added by appending an underscore and the +architecture name e.g., 'depends_x86_64=()'. *makedepends (array)*:: An array of packages this package depends on to build but are not needed at runtime. Packages in this list follow the same format as depends. ++ +Architecture-specific makedepends can be added by appending an underscore and +the architecture name e.g., 'makedepends_x86_64=()'. *checkdepends (array)*:: An array of packages this package depends on to run its test suite but are not needed at runtime. Packages in this list follow the same format as depends. These dependencies are only considered when the check() function is present and is to be run by makepkg. ++ +Architecture-specific checkdepends can be added by appending an underscore and +the architecture name e.g., 'checkdepends_x86_64=()'. *optdepends (array)*:: An array of packages (and accompanying reasons) that are not essential for @@ -203,12 +212,18 @@ disables automatic detection. for specifying optdepends is: optdepends=('fakeroot: for makepkg usage as normal user') ++ +Architecture-specific optdepends can be added by appending an underscore and +the architecture name e.g., 'optdepends_x86_64=()'. *conflicts (array)*:: An array of packages that will conflict with this package (i.e. they cannot both be installed at the same time). This directive follows the same format as depends. Versioned conflicts are supported using the operators as described in `depends`. ++ +Architecture-specific conflicts can be added by appending an underscore and +the architecture name e.g., 'conflicts_x86_64=()'. *provides (array)*:: An array of ``virtual provisions'' this package provides. This allows @@ -224,6 +239,9 @@ only specific versions of a package may be provided. If the provision name appears to be a library (ends with .so), makepkg will try to find the library in the built package and append the correct version. Appending the version yourself disables automatic detection. ++ +Architecture-specific provides can be added by appending an underscore and +the architecture name e.g., 'provides_x86_64=()'. *replaces (array)*:: An array of packages this package should replace. This can be used @@ -234,6 +252,9 @@ version. Appending the version yourself disables automatic detection. + Sysupgrade is currently the only pacman operation that utilizes this field. A normal sync or upgrade will not use its value. ++ +Architecture-specific replaces can be added by appending an underscore and +the architecture name e.g., 'replaces_x86_64=()'. *options (array)*:: This array allows you to override some of makepkg's default behavior diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index baa3720..564ae1f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1487,6 +1487,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 @@ -1905,6 +1923,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)" @@ -2361,12 +2381,22 @@ 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 extract_function_var "package_$name" provides 1 list provides_list+=("${list[@]}") + + for a in "${arch[@]}"; do + extract_function_var "package_$name" "provides_$a" 1 list + provides_list+=("${list[@]}") + done done for provide in "${provides_list[@]}"; do @@ -2399,12 +2429,22 @@ 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 extract_function_var "package_$name" optdepends 1 list optdepends_list+=("${list[@]}") + + for a in "${arch[@]}"; do + extract_function_var "package_$name" "optdepends_$a" 1 list + optdepends_list+=("${list[@]}") + done done for name in "${optdepends_list[@]}"; do @@ -3091,7 +3131,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 -- 2.0.3