[pacman-dev] [PATCH 1/1] Split prepare_buildenv() to libmakepkg scripts
From: Que Quotion <quequotion@gmail.com> As Eli Schwartz has pointed out: https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022501.html It would be beneficial to makepkg to have this function ported to libmakepkg and split into individual scripts. Supersedes: https://patchwork.archlinux.org/patch/540/ Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 6 ++ scripts/libmakepkg/buildenv.sh.in | 55 ++++++++++++++++++ scripts/libmakepkg/buildenv/buildflags.sh.in | 34 +++++++++++ scripts/libmakepkg/buildenv/ccache.sh.in | 45 +++++++++++++++ scripts/libmakepkg/buildenv/distcc.sh.in | 47 +++++++++++++++ scripts/libmakepkg/buildenv/makeflags.sh.in | 34 +++++++++++ scripts/libmakepkg/buildenv/meson.build | 20 +++++++ scripts/libmakepkg/meson.build | 1 + scripts/makepkg.sh.in | 60 +------------------- 9 files changed, 243 insertions(+), 59 deletions(-) create mode 100644 scripts/libmakepkg/buildenv.sh.in create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/ccache.sh.in create mode 100644 scripts/libmakepkg/buildenv/distcc.sh.in create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/meson.build diff --git a/scripts/Makefile.am b/scripts/Makefile.am index c6b6220e..8e669f71 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -41,6 +41,7 @@ LIBRARY = \ libmakepkgdir = $(datarootdir)/makepkg LIBMAKEPKGDIRS = \ + buildenv \ integrity \ lint_config \ lint_package \ @@ -50,6 +51,11 @@ LIBMAKEPKGDIRS = \ util LIBMAKEPKG_IN = \ + libmakepkg/buildenv.sh \ + libmakepkg/buildenv/buildflags.sh \ + libmakepkg/buildenv/ccache.sh \ + libmakepkg/buildenv/distcc.sh \ + libmakepkg/buildenv/makeflags.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ libmakepkg/integrity/generate_signature.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in new file mode 100644 index 00000000..a14a3a9a --- /dev/null +++ b/scripts/libmakepkg/buildenv.sh.in @@ -0,0 +1,55 @@ +#!/bin/bash +# +# buildenv.sh - functions for altering the build environment before +# compiliation +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return +LIBMAKEPKG_BUILDENV_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + + +declare -a build_options + +for lib in "$LIBRARY/buildenv/"*.sh; do + source "$lib" +done + +readonly -a build_options + +prepare_buildenv() { + msg "$(gettext "Preparing build environment...")" + + for func in ${build_options[@]}; do + $func + done + + if check_option "debug" "y"; then + DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + CFLAGS+=" $DEBUG_CFLAGS" + CXXFLAGS+=" $DEBUG_CXXFLAGS" + fi + + # ensure all necessary build variables are exported + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST +} diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in new file mode 100644 index 00000000..fb49a85c --- /dev/null +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -0,0 +1,34 @@ +#!/usr/bin/bash +# +# buildflags.sh - Clear user-specified buildflags if requested +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('buildflags') + +buildflags() { + if check_option "buildflags" "n"; then + unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/ccache.sh.in b/scripts/libmakepkg/buildenv/ccache.sh.in new file mode 100644 index 00000000..122033a9 --- /dev/null +++ b/scripts/libmakepkg/buildenv/ccache.sh.in @@ -0,0 +1,45 @@ +#!/usr/bin/bash +# +# ccache.sh - Cache compiliations and recycle them to save time on repititions +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_CCACHE_SH" ]] && return +LIBMAKEPKG_BUILDENV_CCACHE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + +build_options+=('ccache') + +local ccache=0 + +ccache() { + if check_buildoption "ccache" "y"; then + if ! type -p ccache >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" + return 1 + fi + + if [ -d /usr/lib/ccache/bin ]; then + export PATH="/usr/lib/ccache/bin:$PATH" + ccache=1 + fi + fi +} diff --git a/scripts/libmakepkg/buildenv/distcc.sh.in b/scripts/libmakepkg/buildenv/distcc.sh.in new file mode 100644 index 00000000..f7580705 --- /dev/null +++ b/scripts/libmakepkg/buildenv/distcc.sh.in @@ -0,0 +1,47 @@ +#!/usr/bin/bash +# +# distcc.sh - Distribute compliation to reduce compilation time +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_DISTCC_SH" ]] && return +LIBMAKEPKG_BUILDENV_DISTCC_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + +build_options+=('distcc') + +distcc() { + if check_buildoption "distcc" "y"; then + if ! type -p distcc >/dev/null; then + error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" + return 1 + fi + + if (( ccache )); then + export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" + export CCACHE_BASEDIR="$srcdir" + elif [[ -d /usr/lib/distcc/bin ]]; then + export PATH="/usr/lib/distcc/bin:$PATH" + fi + + export DISTCC_HOSTS + fi +} diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in new file mode 100644 index 00000000..53ac1e4c --- /dev/null +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -0,0 +1,34 @@ +#!/usr/bin/bash +# +# makeflags.sh - Clear user-specified makeflags if requested +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('makeflags') + +makeflags() { + if check_option "makeflags" "n"; then + unset MAKEFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build new file mode 100644 index 00000000..e0d07287 --- /dev/null +++ b/scripts/libmakepkg/buildenv/meson.build @@ -0,0 +1,20 @@ +libmakepkg_module = 'buildenv' + +sources = [ + 'buildflags.sh.in', + 'ccache.sh.in', + 'distcc.sh.in', + 'makeflags.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build index 07475b4d..3a487f0d 100644 --- a/scripts/libmakepkg/meson.build +++ b/scripts/libmakepkg/meson.build @@ -1,4 +1,5 @@ libmakepkg_modules = [ + { 'name' : 'buildenv', 'has_subdir' : true }, { 'name' : 'integrity', 'has_subdir' : true }, { 'name' : 'lint_config', 'has_subdir' : true }, { 'name' : 'lint_package', 'has_subdir' : true }, diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3ac03d11..8ce006fb 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -48,11 +48,10 @@ declare -r startdir="$(pwd -P)" LIBRARY=${LIBRARY:-'@libmakepkgdir@'} -build_options=('ccache' 'distcc' 'buildflags' 'makeflags') splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' 'backup' 'options' 'install' 'changelog') -readonly -a build_options splitpkg_overrides +readonly -a splitpkg_overrides known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512') @@ -380,47 +379,6 @@ source_buildfile() { source_safe "$@" } -prepare_buildenv() { - # clear user-specified buildflags if requested - if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS - fi - - if check_option "debug" "y"; then - DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - CFLAGS+=" $DEBUG_CFLAGS" - CXXFLAGS+=" $DEBUG_CXXFLAGS" - fi - - # clear user-specified makeflags if requested - if check_option "makeflags" "n"; then - unset MAKEFLAGS - fi - - # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST - - local ccache=0 - - # use ccache if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "ccache" "y" && [[ -d /usr/lib/ccache/bin ]]; then - export PATH="/usr/lib/ccache/bin:$PATH" - ccache=1 - fi - - # use distcc if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "distcc" "y"; then - if (( ccache )); then - export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" - export CCACHE_BASEDIR="$srcdir" - elif [[ -d /usr/lib/distcc/bin ]]; then - export PATH="/usr/lib/distcc/bin:$PATH" - fi - export DISTCC_HOSTS - fi -} - run_function_safe() { local restoretrap restoreshopt @@ -1029,22 +987,6 @@ check_software() { done fi - # distcc - compilation with distcc - if check_buildoption "distcc" "y"; then - if ! type -p distcc >/dev/null; then - error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - ret=1 - fi - fi - - # ccache - compilation with ccache - if check_buildoption "ccache" "y"; then - if ! type -p ccache >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" - ret=1 - fi - fi - # strip - strip symbols from binaries/libraries if check_option "strip" "y"; then if ! type -p strip >/dev/null; then -- 2.19.1
On 11/3/18 12:54 PM, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
As Eli Schwartz has pointed out: https://lists.archlinux.org/pipermail/pacman-dev/2018-May/022501.html
It would be beneficial to makepkg to have this function ported to libmakepkg and split into individual scripts.
Supersedes: https://patchwork.archlinux.org/patch/540/
Thanks for putting in the work to (re)do this.
Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 6 ++ scripts/libmakepkg/buildenv.sh.in | 55 ++++++++++++++++++ scripts/libmakepkg/buildenv/buildflags.sh.in | 34 +++++++++++ scripts/libmakepkg/buildenv/ccache.sh.in | 45 +++++++++++++++ scripts/libmakepkg/buildenv/distcc.sh.in | 47 +++++++++++++++ scripts/libmakepkg/buildenv/makeflags.sh.in | 34 +++++++++++ scripts/libmakepkg/buildenv/meson.build | 20 +++++++ scripts/libmakepkg/meson.build | 1 + scripts/makepkg.sh.in | 60 +------------------- 9 files changed, 243 insertions(+), 59 deletions(-) create mode 100644 scripts/libmakepkg/buildenv.sh.in create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/ccache.sh.in create mode 100644 scripts/libmakepkg/buildenv/distcc.sh.in create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/meson.build
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index c6b6220e..8e669f71 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -41,6 +41,7 @@ LIBRARY = \ libmakepkgdir = $(datarootdir)/makepkg
LIBMAKEPKGDIRS = \ + buildenv \ integrity \ lint_config \ lint_package \ @@ -50,6 +51,11 @@ LIBMAKEPKGDIRS = \ util
LIBMAKEPKG_IN = \ + libmakepkg/buildenv.sh \ + libmakepkg/buildenv/buildflags.sh \ + libmakepkg/buildenv/ccache.sh \ + libmakepkg/buildenv/distcc.sh \ + libmakepkg/buildenv/makeflags.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ libmakepkg/integrity/generate_signature.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in new file mode 100644 index 00000000..a14a3a9a --- /dev/null +++ b/scripts/libmakepkg/buildenv.sh.in @@ -0,0 +1,55 @@ +#!/bin/bash +# +# buildenv.sh - functions for altering the build environment before +# compiliation +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return +LIBMAKEPKG_BUILDENV_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + + +declare -a build_options + +for lib in "$LIBRARY/buildenv/"*.sh; do + source "$lib" +done + +readonly -a build_options + +prepare_buildenv() { + msg "$(gettext "Preparing build environment...")" + + for func in ${build_options[@]}; do + $func + done + + if check_option "debug" "y"; then + DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + CFLAGS+=" $DEBUG_CFLAGS" + CXXFLAGS+=" $DEBUG_CXXFLAGS" + fi + + # ensure all necessary build variables are exported + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST +}
Why is this on its own, not in a dropin?
diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in new file mode 100644 index 00000000..fb49a85c --- /dev/null +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -0,0 +1,34 @@ +#!/usr/bin/bash +# +# buildflags.sh - Clear user-specified buildflags if requested +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('buildflags')
If you look at the way we do this in other sections, this should probably be namespaced as buildenv_buildflags
+buildflags() { + if check_option "buildflags" "n"; then + unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/ccache.sh.in b/scripts/libmakepkg/buildenv/ccache.sh.in new file mode 100644 index 00000000..122033a9 --- /dev/null +++ b/scripts/libmakepkg/buildenv/ccache.sh.in @@ -0,0 +1,45 @@ +#!/usr/bin/bash +# +# ccache.sh - Cache compiliations and recycle them to save time on repititions +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_CCACHE_SH" ]] && return +LIBMAKEPKG_BUILDENV_CCACHE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + +build_options+=('ccache') + +local ccache=0 + +ccache() { + if check_buildoption "ccache" "y"; then + if ! type -p ccache >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" + return 1 + fi + + if [ -d /usr/lib/ccache/bin ]; then + export PATH="/usr/lib/ccache/bin:$PATH" + ccache=1 + fi + fi +}
ccache is now both a function name and a variable name... And the variable is declared as local, but outside of a function -- instead, it's relying on the fact that libmakepkg typically sources this file while inside another function. I don't know whether we should be doing this... I'm inclined to think that at least ccache and distcc should be in the same dropin file and parsed as the same buildenv function as a result. Maybe buildenv_compiler.
diff --git a/scripts/libmakepkg/buildenv/distcc.sh.in b/scripts/libmakepkg/buildenv/distcc.sh.in new file mode 100644 index 00000000..f7580705 --- /dev/null +++ b/scripts/libmakepkg/buildenv/distcc.sh.in @@ -0,0 +1,47 @@ +#!/usr/bin/bash +# +# distcc.sh - Distribute compliation to reduce compilation time +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_DISTCC_SH" ]] && return +LIBMAKEPKG_BUILDENV_DISTCC_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + +build_options+=('distcc') + +distcc() { + if check_buildoption "distcc" "y"; then + if ! type -p distcc >/dev/null; then + error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" + return 1 + fi + + if (( ccache )); then + export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" + export CCACHE_BASEDIR="$srcdir" + elif [[ -d /usr/lib/distcc/bin ]]; then + export PATH="/usr/lib/distcc/bin:$PATH" + fi + + export DISTCC_HOSTS + fi +} diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in new file mode 100644 index 00000000..53ac1e4c --- /dev/null +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -0,0 +1,34 @@ +#!/usr/bin/bash +# +# makeflags.sh - Clear user-specified makeflags if requested +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('makeflags') + +makeflags() { + if check_option "makeflags" "n"; then + unset MAKEFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build new file mode 100644 index 00000000..e0d07287 --- /dev/null +++ b/scripts/libmakepkg/buildenv/meson.build @@ -0,0 +1,20 @@ +libmakepkg_module = 'buildenv' + +sources = [ + 'buildflags.sh.in', + 'ccache.sh.in', + 'distcc.sh.in', + 'makeflags.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build index 07475b4d..3a487f0d 100644 --- a/scripts/libmakepkg/meson.build +++ b/scripts/libmakepkg/meson.build @@ -1,4 +1,5 @@ libmakepkg_modules = [ + { 'name' : 'buildenv', 'has_subdir' : true }, { 'name' : 'integrity', 'has_subdir' : true }, { 'name' : 'lint_config', 'has_subdir' : true }, { 'name' : 'lint_package', 'has_subdir' : true }, diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3ac03d11..8ce006fb 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -48,11 +48,10 @@ declare -r startdir="$(pwd -P)"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
-build_options=('ccache' 'distcc' 'buildflags' 'makeflags') splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' 'backup' 'options' 'install' 'changelog') -readonly -a build_options splitpkg_overrides +readonly -a splitpkg_overrides
known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512')
@@ -380,47 +379,6 @@ source_buildfile() { source_safe "$@" }
-prepare_buildenv() { - # clear user-specified buildflags if requested - if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS - fi - - if check_option "debug" "y"; then - DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - CFLAGS+=" $DEBUG_CFLAGS" - CXXFLAGS+=" $DEBUG_CXXFLAGS" - fi - - # clear user-specified makeflags if requested - if check_option "makeflags" "n"; then - unset MAKEFLAGS - fi - - # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST - - local ccache=0 - - # use ccache if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "ccache" "y" && [[ -d /usr/lib/ccache/bin ]]; then - export PATH="/usr/lib/ccache/bin:$PATH" - ccache=1 - fi - - # use distcc if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "distcc" "y"; then - if (( ccache )); then - export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" - export CCACHE_BASEDIR="$srcdir" - elif [[ -d /usr/lib/distcc/bin ]]; then - export PATH="/usr/lib/distcc/bin:$PATH" - fi - export DISTCC_HOSTS - fi -} - run_function_safe() { local restoretrap restoreshopt
@@ -1029,22 +987,6 @@ check_software() { done fi
- # distcc - compilation with distcc - if check_buildoption "distcc" "y"; then - if ! type -p distcc >/dev/null; then - error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - ret=1 - fi - fi - - # ccache - compilation with ccache - if check_buildoption "ccache" "y"; then - if ! type -p ccache >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" - ret=1 - fi - fi - # strip - strip symbols from binaries/libraries if check_option "strip" "y"; then if ! type -p strip >/dev/null; then
-- Eli Schwartz Bug Wrangler and Trusted User
+ if check_option "debug" "y"; then + DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + CFLAGS+=" $DEBUG_CFLAGS" + CXXFLAGS+=" $DEBUG_CXXFLAGS" + fi + + # ensure all necessary build variables are exported + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST +}
Why is this on its own, not in a dropin?
I needed feedback on this; since the debugflags don't have a corresponding build_option I wasn't sure what to do with them. Your feedback on the ccache/distcc section gave me an idea.
+build_options+=('buildflags')
If you look at the way we do this in other sections, this should probably be namespaced as buildenv_buildflags
I've kept the name as it was in the original implementation to avoid upsetting anyone who might be using this flag in a PKGBUILD or makepkg.conf.
+ccache() { + if check_buildoption "ccache" "y"; then + if ! type -p ccache >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" + return 1 + fi + + if [ -d /usr/lib/ccache/bin ]; then + export PATH="/usr/lib/ccache/bin:$PATH" + ccache=1 + fi + fi +}
ccache is now both a function name and a variable name...
And the variable is declared as local, but outside of a function -- instead, it's relying on the fact that libmakepkg typically sources this file while inside another function. I don't know whether we should be doing this...
I'm inclined to think that at least ccache and distcc should be in the same dropin file and parsed as the same buildenv function as a result. Maybe buildenv_compiler.
I'd rather have them separate, as they may be used separately, but then I don't know how to ensure the ccache macro would be called before the distcc macro, so I put them into compiler.sh.in Attached patch is succesive, and should be applied after the previous. I can resubmit if you want a single patch.
From: Que Quotion <quequotion@gmail.com> Being misled by git's documentation, my attempt to attach this patch to the previous mail was foiled. That's really, really frustrating. Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 4 +-- scripts/libmakepkg/buildenv.sh.in | 13 ++------ scripts/libmakepkg/buildenv/buildflags.sh.in | 1 + .../buildenv/{ccache.sh.in => compiler.sh.in} | 27 +++++++++++++--- .../{distcc.sh.in => debugflags.sh.in} | 31 +++++++------------ scripts/libmakepkg/buildenv/makeflags.sh.in | 1 + scripts/libmakepkg/buildenv/meson.build | 4 +-- 7 files changed, 43 insertions(+), 38 deletions(-) rename scripts/libmakepkg/buildenv/{ccache.sh.in => compiler.sh.in} (69%) rename scripts/libmakepkg/buildenv/{distcc.sh.in => debugflags.sh.in} (56%) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 8e669f71..adced908 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -53,8 +53,8 @@ LIBMAKEPKGDIRS = \ LIBMAKEPKG_IN = \ libmakepkg/buildenv.sh \ libmakepkg/buildenv/buildflags.sh \ - libmakepkg/buildenv/ccache.sh \ - libmakepkg/buildenv/distcc.sh \ + libmakepkg/buildenv/compiler.sh \ + libmakepkg/buildenv/debugflags.sh \ libmakepkg/buildenv/makeflags.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index a14a3a9a..9c1f02f4 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -28,28 +28,21 @@ source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -declare -a build_options +declare -a build_options build_macros for lib in "$LIBRARY/buildenv/"*.sh; do source "$lib" done -readonly -a build_options +readonly -a build_options build_macros prepare_buildenv() { msg "$(gettext "Preparing build environment...")" - for func in ${build_options[@]}; do + for func in ${build_macros[@]}; do $func done - if check_option "debug" "y"; then - DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - CFLAGS+=" $DEBUG_CFLAGS" - CXXFLAGS+=" $DEBUG_CXXFLAGS" - fi - # ensure all necessary build variables are exported export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST } diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index fb49a85c..55d7fbce 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -26,6 +26,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" build_options+=('buildflags') +build_macros+=('buildflags') buildflags() { if check_option "buildflags" "n"; then diff --git a/scripts/libmakepkg/buildenv/ccache.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in similarity index 69% rename from scripts/libmakepkg/buildenv/ccache.sh.in rename to scripts/libmakepkg/buildenv/compiler.sh.in index 122033a9..dec19ac8 100644 --- a/scripts/libmakepkg/buildenv/ccache.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -26,11 +26,12 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -build_options+=('ccache') +build_options+=('ccache' 'distcc') +build_macros+=('use_ccache' 'use_distcc') -local ccache=0 +using_ccache=0 -ccache() { +use_ccache() { if check_buildoption "ccache" "y"; then if ! type -p ccache >/dev/null; then error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" @@ -39,7 +40,25 @@ ccache() { if [ -d /usr/lib/ccache/bin ]; then export PATH="/usr/lib/ccache/bin:$PATH" - ccache=1 + using_ccache=1 fi fi } + +use_distcc() { + if check_buildoption "distcc" "y"; then + if ! type -p distcc >/dev/null; then + error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" + return 1 + fi + + if (( using_ccache )); then + export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" + export CCACHE_BASEDIR="$srcdir" + elif [[ -d /usr/lib/distcc/bin ]]; then + export PATH="/usr/lib/distcc/bin:$PATH" + fi + + export DISTCC_HOSTS + fi +} diff --git a/scripts/libmakepkg/buildenv/distcc.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in similarity index 56% rename from scripts/libmakepkg/buildenv/distcc.sh.in rename to scripts/libmakepkg/buildenv/debugflags.sh.in index f7580705..8627e242 100644 --- a/scripts/libmakepkg/buildenv/distcc.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -1,6 +1,7 @@ #!/usr/bin/bash # -# distcc.sh - Distribute compliation to reduce compilation time +# debugflags.sh - Specify flags for building a package with debugging +# symbols # # Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> # @@ -18,30 +19,20 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -[[ -n "$LIBMAKEPKG_BUILDENV_DISTCC_SH" ]] && return -LIBMAKEPKG_BUILDENV_DISTCC_SH=1 +[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} -source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -build_options+=('distcc') +build_macros+=('debugflags') -distcc() { - if check_buildoption "distcc" "y"; then - if ! type -p distcc >/dev/null; then - error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - return 1 - fi - - if (( ccache )); then - export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" - export CCACHE_BASEDIR="$srcdir" - elif [[ -d /usr/lib/distcc/bin ]]; then - export PATH="/usr/lib/distcc/bin:$PATH" - fi - - export DISTCC_HOSTS +debugflags() { + if check_option "debug" "y"; then + DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + CFLAGS+=" $DEBUG_CFLAGS" + CXXFLAGS+=" $DEBUG_CXXFLAGS" fi } diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in index 53ac1e4c..b0c438d2 100644 --- a/scripts/libmakepkg/buildenv/makeflags.sh.in +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -26,6 +26,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" build_options+=('makeflags') +build_macros+=('makeflags') makeflags() { if check_option "makeflags" "n"; then diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build index e0d07287..34d4ba7b 100644 --- a/scripts/libmakepkg/buildenv/meson.build +++ b/scripts/libmakepkg/buildenv/meson.build @@ -2,8 +2,8 @@ libmakepkg_module = 'buildenv' sources = [ 'buildflags.sh.in', - 'ccache.sh.in', - 'distcc.sh.in', + 'compiler.sh.in', + 'debugflags.sh.in', 'makeflags.sh.in', ] -- 2.19.1
On 5/11/18 12:35 am, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
Being misled by git's documentation, my attempt to attach this patch to the previous mail was foiled. That's really, really frustrating.
Put comments like this under the "---" line. Also, it is useful to provide some context to the patch in the commit message.
Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 4 +-- scripts/libmakepkg/buildenv.sh.in | 13 ++------ scripts/libmakepkg/buildenv/buildflags.sh.in | 1 + .../buildenv/{ccache.sh.in => compiler.sh.in} | 27 +++++++++++++--- .../{distcc.sh.in => debugflags.sh.in} | 31 +++++++------------ scripts/libmakepkg/buildenv/makeflags.sh.in | 1 + scripts/libmakepkg/buildenv/meson.build | 4 +-- 7 files changed, 43 insertions(+), 38 deletions(-) rename scripts/libmakepkg/buildenv/{ccache.sh.in => compiler.sh.in} (69%) rename scripts/libmakepkg/buildenv/{distcc.sh.in => debugflags.sh.in} (56%)
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 8e669f71..adced908 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -53,8 +53,8 @@ LIBMAKEPKGDIRS = \ LIBMAKEPKG_IN = \ libmakepkg/buildenv.sh \ libmakepkg/buildenv/buildflags.sh \ - libmakepkg/buildenv/ccache.sh \ - libmakepkg/buildenv/distcc.sh \ + libmakepkg/buildenv/compiler.sh \ + libmakepkg/buildenv/debugflags.sh \ libmakepkg/buildenv/makeflags.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index a14a3a9a..9c1f02f4 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -28,28 +28,21 @@ source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh"
-declare -a build_options +declare -a build_options build_macros
I just figure out why you are doing this and then the next patch has: -declare -a build_options build_macros +declare -a buildenv_options I'm not doing any further review. A
From: Que Quotion <quequotion@gmail.com> Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/buildenv/debugflags.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index 8627e242..1ad2ad8b 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -19,8 +19,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return -LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1 +[[ -n "$LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} -- 2.19.1
From: Que Quotion <quequotion@gmail.com> Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/buildenv.sh.in | 6 +++--- scripts/libmakepkg/buildenv/buildflags.sh.in | 5 ++--- scripts/libmakepkg/buildenv/compiler.sh.in | 7 +++---- scripts/libmakepkg/buildenv/debugflags.sh.in | 4 ++-- scripts/libmakepkg/buildenv/makeflags.sh.in | 5 ++--- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index 9c1f02f4..91e99780 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -28,18 +28,18 @@ source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -declare -a build_options build_macros +declare -a buildenv_options for lib in "$LIBRARY/buildenv/"*.sh; do source "$lib" done -readonly -a build_options build_macros +readonly -a buildenv_options prepare_buildenv() { msg "$(gettext "Preparing build environment...")" - for func in ${build_macros[@]}; do + for func in ${buildenv_options[@]}; do $func done diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index 55d7fbce..1a21241d 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -25,10 +25,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" -build_options+=('buildflags') -build_macros+=('buildflags') +buildenv_options+=('buildenv_buildflags') -buildflags() { +buildenv_buildflags() { if check_option "buildflags" "n"; then unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS fi diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index dec19ac8..b7bb1d65 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -26,12 +26,11 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -build_options+=('ccache' 'distcc') -build_macros+=('use_ccache' 'use_distcc') +buildenv_options+=('buildenv_ccache' 'buildenv_distcc') using_ccache=0 -use_ccache() { +buildenv_ccache() { if check_buildoption "ccache" "y"; then if ! type -p ccache >/dev/null; then error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" @@ -45,7 +44,7 @@ use_ccache() { fi } -use_distcc() { +buildenv_distcc() { if check_buildoption "distcc" "y"; then if ! type -p distcc >/dev/null; then error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index 1ad2ad8b..ac5f76db 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -26,9 +26,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" -build_macros+=('debugflags') +buildenv_options+=('buildenv_debugflags') -debugflags() { +buildenv_debugflags() { if check_option "debug" "y"; then DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in index b0c438d2..0e5bb36b 100644 --- a/scripts/libmakepkg/buildenv/makeflags.sh.in +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -25,10 +25,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" -build_options+=('makeflags') -build_macros+=('makeflags') +buildenv_options+=('buildenv_makeflags') -makeflags() { +buildenv_makeflags() { if check_option "makeflags" "n"; then unset MAKEFLAGS fi -- 2.19.1
From: Que Quotion <quequotion@gmail.com> Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/buildenv.sh.in | 6 +++--- scripts/libmakepkg/buildenv/buildflags.sh.in | 2 +- scripts/libmakepkg/buildenv/compiler.sh.in | 2 +- scripts/libmakepkg/buildenv/debugflags.sh.in | 2 +- scripts/libmakepkg/buildenv/makeflags.sh.in | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index 91e99780..b49b24bf 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -28,18 +28,18 @@ source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -declare -a buildenv_options +declare -a buildenv_functions for lib in "$LIBRARY/buildenv/"*.sh; do source "$lib" done -readonly -a buildenv_options +readonly -a buildenv_functions prepare_buildenv() { msg "$(gettext "Preparing build environment...")" - for func in ${buildenv_options[@]}; do + for func in ${buildenv_functions[@]}; do $func done diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index 1a21241d..4bdfd6a1 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -25,7 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" -buildenv_options+=('buildenv_buildflags') +buildenv_functions+=('buildenv_buildflags') buildenv_buildflags() { if check_option "buildflags" "n"; then diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index b7bb1d65..384b94da 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -26,7 +26,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" -buildenv_options+=('buildenv_ccache' 'buildenv_distcc') +buildenv_functions+=('buildenv_ccache' 'buildenv_distcc') using_ccache=0 diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in index ac5f76db..65aa6c0a 100644 --- a/scripts/libmakepkg/buildenv/debugflags.sh.in +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -26,7 +26,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" -buildenv_options+=('buildenv_debugflags') +buildenv_functions+=('buildenv_debugflags') buildenv_debugflags() { if check_option "debug" "y"; then diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in index 0e5bb36b..2d4a44c6 100644 --- a/scripts/libmakepkg/buildenv/makeflags.sh.in +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -25,7 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" -buildenv_options+=('buildenv_makeflags') +buildenv_functions+=('buildenv_makeflags') buildenv_makeflags() { if check_option "makeflags" "n"; then -- 2.19.1
From: Que Quotion <quequotion@gmail.com> Drop-ins for finding executables Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 10 ++ scripts/libmakepkg/buildenv.sh.in | 1 - scripts/libmakepkg/buildenv/buildflags.sh.in | 1 + scripts/libmakepkg/buildenv/compiler.sh.in | 19 +-- scripts/libmakepkg/buildenv/makeflags.sh.in | 1 + scripts/libmakepkg/executable.sh.in | 44 ++++++ scripts/libmakepkg/executable/ccache.sh.in | 37 +++++ scripts/libmakepkg/executable/checksum.sh.in | 43 +++++ scripts/libmakepkg/executable/distcc.sh.in | 37 +++++ scripts/libmakepkg/executable/fakeroot.sh.in | 37 +++++ scripts/libmakepkg/executable/gpg.sh.in | 38 +++++ scripts/libmakepkg/executable/gzip.sh.in | 37 +++++ scripts/libmakepkg/executable/meson.build | 25 +++ scripts/libmakepkg/executable/strip.sh.in | 37 +++++ scripts/libmakepkg/executable/sudo.sh.in | 36 +++++ scripts/libmakepkg/executable/vcs.sh.in | 107 +++++++++++++ scripts/libmakepkg/meson.build | 1 + scripts/makepkg.sh.in | 156 ------------------- 18 files changed, 497 insertions(+), 170 deletions(-) create mode 100644 scripts/libmakepkg/executable.sh.in create mode 100644 scripts/libmakepkg/executable/ccache.sh.in create mode 100644 scripts/libmakepkg/executable/checksum.sh.in create mode 100644 scripts/libmakepkg/executable/distcc.sh.in create mode 100644 scripts/libmakepkg/executable/fakeroot.sh.in create mode 100644 scripts/libmakepkg/executable/gpg.sh.in create mode 100644 scripts/libmakepkg/executable/gzip.sh.in create mode 100644 scripts/libmakepkg/executable/meson.build create mode 100644 scripts/libmakepkg/executable/strip.sh.in create mode 100644 scripts/libmakepkg/executable/sudo.sh.in create mode 100644 scripts/libmakepkg/executable/vcs.sh.in diff --git a/scripts/Makefile.am b/scripts/Makefile.am index adced908..02188e9f 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -51,6 +51,16 @@ LIBMAKEPKGDIRS = \ util LIBMAKEPKG_IN = \ + libmakepkg/executable.sh \ + libmakepkg/executable/ccache.sh \ + libmakepkg/executable/checksum.sh \ + libmakepkg/executable/distcc.sh \ + libmakepkg/executable/fakeroot.sh \ + libmakepkg/executable/gpg.sh \ + libmakepkg/executable/gzip.sh \ + libmakepkg/executable/strip.sh \ + libmakepkg/executable/sudo.sh \ + libmakepkg/executable/vcs.sh \ libmakepkg/buildenv.sh \ libmakepkg/buildenv/buildflags.sh \ libmakepkg/buildenv/compiler.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in index b49b24bf..c3442c42 100644 --- a/scripts/libmakepkg/buildenv.sh.in +++ b/scripts/libmakepkg/buildenv.sh.in @@ -25,7 +25,6 @@ LIBMAKEPKG_BUILDENV_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/message.sh" -source "$LIBRARY/util/option.sh" declare -a buildenv_functions diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in index 4bdfd6a1..ac207fd3 100644 --- a/scripts/libmakepkg/buildenv/buildflags.sh.in +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" +build_options+=('buildflags') buildenv_functions+=('buildenv_buildflags') buildenv_buildflags() { diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index 384b94da..38399269 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -1,6 +1,8 @@ #!/usr/bin/bash # -# ccache.sh - Cache compiliations and recycle them to save time on repititions +# compiler.sh - CCache and DistCC compilation +# ccache - Cache compiliations and recycle them to save time on repititions +# distcc - Distribute compliation to reduce compilation time # # Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> # @@ -18,25 +20,21 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -[[ -n "$LIBMAKEPKG_BUILDENV_CCACHE_SH" ]] && return -LIBMAKEPKG_BUILDENV_CCACHE_SH=1 +[[ -n "$LIBMAKEPKG_BUILDENV_COMPILER_SH" ]] && return +LIBMAKEPKG_BUILDENV_COMPILER_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" +build_options+=('ccache' 'distcc') buildenv_functions+=('buildenv_ccache' 'buildenv_distcc') using_ccache=0 buildenv_ccache() { if check_buildoption "ccache" "y"; then - if ! type -p ccache >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" - return 1 - fi - if [ -d /usr/lib/ccache/bin ]; then export PATH="/usr/lib/ccache/bin:$PATH" using_ccache=1 @@ -46,11 +44,6 @@ buildenv_ccache() { buildenv_distcc() { if check_buildoption "distcc" "y"; then - if ! type -p distcc >/dev/null; then - error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - return 1 - fi - if (( using_ccache )); then export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" export CCACHE_BASEDIR="$srcdir" diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in index 2d4a44c6..45e77468 100644 --- a/scripts/libmakepkg/buildenv/makeflags.sh.in +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'} source "$LIBRARY/util/option.sh" +build_options+=('makeflags') buildenv_functions+=('buildenv_makeflags') buildenv_makeflags() { diff --git a/scripts/libmakepkg/executable.sh.in b/scripts/libmakepkg/executable.sh.in new file mode 100644 index 00000000..06ed86e2 --- /dev/null +++ b/scripts/libmakepkg/executable.sh.in @@ -0,0 +1,44 @@ +#!/bin/bash +# +# executable.sh - functions for altering the build environment before +# compiliation +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" + + +declare -a executable_functions + +for lib in "$LIBRARY/executable/"*.sh; do + source "$lib" +done + +readonly -a executable_functions + +check_software() { + msg "$(gettext "Checking for needed software...")" + + for func in ${executable_functions[@]}; do + $func + done +} diff --git a/scripts/libmakepkg/executable/ccache.sh.in b/scripts/libmakepkg/executable/ccache.sh.in new file mode 100644 index 00000000..f31a2014 --- /dev/null +++ b/scripts/libmakepkg/executable/ccache.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# ccache.sh - Cache compiliations and recycle them to save time on repititions +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_CCACHE_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_CCACHE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_ccache') + +executable_ccache() { + if check_buildoption "ccache" "y"; then + if ! type -p ccache >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" + return 1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/checksum.sh.in b/scripts/libmakepkg/executable/checksum.sh.in new file mode 100644 index 00000000..4ddb20a6 --- /dev/null +++ b/scripts/libmakepkg/executable/checksum.sh.in @@ -0,0 +1,43 @@ +#!/usr/bin/bash +# +# checksum.sh - Checksum operations +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_CHECKSUM_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_CHECKSUM_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_checksum') + +executable_checksum() { + if (( GENINTEG || ! SKIPCHECKSUMS )); then + local integlist + IFS=$'\n' read -rd '' -a integlist < <(get_integlist) + + local integ + for integ in "${integlist[@]}"; do + if ! type -p "${integ}sum" >/dev/null; then + error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum" + return 1 + fi + done + fi +} diff --git a/scripts/libmakepkg/executable/distcc.sh.in b/scripts/libmakepkg/executable/distcc.sh.in new file mode 100644 index 00000000..e794d51a --- /dev/null +++ b/scripts/libmakepkg/executable/distcc.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# distcc.sh - Distribute compliation to reduce compilation time +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_DISTCC_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_DISTCC_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_distcc') + +executable_distcc() { + if check_buildoption "distcc" "y"; then + if ! type -p distcc >/dev/null; then + error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" + return 1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/fakeroot.sh.in b/scripts/libmakepkg/executable/fakeroot.sh.in new file mode 100644 index 00000000..7c03ebeb --- /dev/null +++ b/scripts/libmakepkg/executable/fakeroot.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# fakeroot.sh - Correct package file permissions +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_FAKEROOT_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_FAKEROOT_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_fakeroot') + +executable_fakeroot() { + if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then + if ! type -p fakeroot >/dev/null; then + error "$(gettext "Cannot find the %s binary.")" "fakeroot" + return 1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/gpg.sh.in b/scripts/libmakepkg/executable/gpg.sh.in new file mode 100644 index 00000000..0c198473 --- /dev/null +++ b/scripts/libmakepkg/executable/gpg.sh.in @@ -0,0 +1,38 @@ +#!/usr/bin/bash +# +# gpg.sh - Package signing or source verification +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_GPG_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_GPG_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_gpg') + +executable_gpg() { + if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } } || \ + { (( ! SKIPPGPCHECK )) && source_has_signatures }; then + if ! type -p gpg >/dev/null; then + error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" + return 1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/gzip.sh.in b/scripts/libmakepkg/executable/gzip.sh.in new file mode 100644 index 00000000..6d90369e --- /dev/null +++ b/scripts/libmakepkg/executable/gzip.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# gzip.sh - Compressig man and info pages +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_GZIP_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_GZIP_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_gzip') + +executable_gzip() { + if check_option "zipman" "y"; then + if ! type -p gzip >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" + return 1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/meson.build b/scripts/libmakepkg/executable/meson.build new file mode 100644 index 00000000..f6f86a4d --- /dev/null +++ b/scripts/libmakepkg/executable/meson.build @@ -0,0 +1,25 @@ +libmakepkg_module = 'executable' + +sources = [ + 'ccache.sh.in', + 'checksum.sh.in', + 'distcc.sh.in', + 'fakeroot.sh.in', + 'gpg.sh.in', + 'gzip.sh.in', + 'strip.sh.in', + 'sudo.sh.in', + 'vcs.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/executable/strip.sh.in b/scripts/libmakepkg/executable/strip.sh.in new file mode 100644 index 00000000..8d66c02a --- /dev/null +++ b/scripts/libmakepkg/executable/strip.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# strip.sh - Strip symbols from binaries/libraries +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_STRIP_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_STRIP_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_strip') + +executable_strip() { + if check_option "strip" "y"; then + if ! type -p strip >/dev/null; then + error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" + return 1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/sudo.sh.in b/scripts/libmakepkg/executable/sudo.sh.in new file mode 100644 index 00000000..04807604 --- /dev/null +++ b/scripts/libmakepkg/executable/sudo.sh.in @@ -0,0 +1,36 @@ +#!/usr/bin/bash +# +# sudo.sh - Check for sudo if we will need it during makepkg execution +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_SUDO_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_SUDO_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_sudo') + +executable_sudo() { + if (( DEP_BIN || RMDEPS || INSTALL )); then + if ! type -p sudo >/dev/null; then + warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su" + fi + fi +} diff --git a/scripts/libmakepkg/executable/vcs.sh.in b/scripts/libmakepkg/executable/vcs.sh.in new file mode 100644 index 00000000..966c3680 --- /dev/null +++ b/scripts/libmakepkg/executable/vcs.sh.in @@ -0,0 +1,107 @@ +#!/usr/bin/bash +# +# vcs.sh - Tools to download vcs sources +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_VCS_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_VCS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_vcs') + +get_vcsclient() { + local proto=${1%%+*} + + local i + for i in "${VCSCLIENTS[@]}"; do + local handler="${i%%::*}" + if [[ $proto = "$handler" ]]; then + local client="${i##*::}" + break + fi + done + + # if we didn't find an client, return an error + if [[ -z $client ]]; then + error "$(gettext "Unknown download protocol: %s")" "$proto" + plain "$(gettext "Aborting...")" + exit $E_CONFIG_ERROR + fi + + printf "%s\n" "$client" +} + +check_vcs_software() { + local netfile all_sources all_deps deps + + if (( SOURCEONLY == 1 )); then + # we will not download VCS sources + return 0 + fi + + if [[ -z $PACMAN_PATH ]]; then + warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" + return 0 + fi + + # we currently only use global depends/makedepends arrays for --syncdeps + for attr in depends makedepends; do + get_pkgbuild_attribute "$pkg" "$attr" 1 'deps' + all_deps+=("${deps[@]}") + + get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps' + all_deps+=("${deps[@]}") + done + + get_all_sources_for_arch 'all_sources' + for netfile in ${all_sources[@]}; do + local proto=$(get_protocol "$netfile") + + case $proto in + bzr*|git*|hg*|svn*) + if ! type -p ${proto%%+*} > /dev/null; then + local client + client=$(get_vcsclient "$proto") || exit $? + # ensure specified program is installed + local uninstalled + uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED + # if not installed, check presence in depends or makedepends + if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then + if ! in_array "$client" ${all_deps[@]}; then + error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ + "$client" "${proto%%+*}" + return 1 + fi + fi + fi + ;; + *) + # non VCS source + ;; + esac + done +} + +executable_vcs() { + if ! check_vcs_software; then + return 1 + fi +} diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build index 3a487f0d..bfba56a5 100644 --- a/scripts/libmakepkg/meson.build +++ b/scripts/libmakepkg/meson.build @@ -1,5 +1,6 @@ libmakepkg_modules = [ { 'name' : 'buildenv', 'has_subdir' : true }, + { 'name' : 'executable', 'has_subdir' : true }, { 'name' : 'integrity', 'has_subdir' : true }, { 'name' : 'lint_config', 'has_subdir' : true }, { 'name' : 'lint_package', 'has_subdir' : true }, diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 8ce006fb..4449ccf7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -855,162 +855,6 @@ install_package() { fi } -get_vcsclient() { - local proto=${1%%+*} - - local i - for i in "${VCSCLIENTS[@]}"; do - local handler="${i%%::*}" - if [[ $proto = "$handler" ]]; then - local client="${i##*::}" - break - fi - done - - # if we didn't find an client, return an error - if [[ -z $client ]]; then - error "$(gettext "Unknown download protocol: %s")" "$proto" - plain "$(gettext "Aborting...")" - exit $E_CONFIG_ERROR - fi - - printf "%s\n" "$client" -} - -check_vcs_software() { - local netfile all_sources all_deps deps ret=0 - - if (( SOURCEONLY == 1 )); then - # we will not download VCS sources - return $ret - fi - - if [[ -z $PACMAN_PATH ]]; then - warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" - return $ret - fi - - # we currently only use global depends/makedepends arrays for --syncdeps - for attr in depends makedepends; do - get_pkgbuild_attribute "$pkg" "$attr" 1 'deps' - all_deps+=("${deps[@]}") - - get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps' - all_deps+=("${deps[@]}") - done - - get_all_sources_for_arch 'all_sources' - for netfile in ${all_sources[@]}; do - local proto=$(get_protocol "$netfile") - - case $proto in - bzr*|git*|hg*|svn*) - if ! type -p ${proto%%+*} > /dev/null; then - local client - client=$(get_vcsclient "$proto") || exit $? - # ensure specified program is installed - local uninstalled - uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED - # if not installed, check presence in depends or makedepends - if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then - if ! in_array "$client" ${all_deps[@]}; then - error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ - "$client" "${proto%%+*}" - ret=1 - fi - fi - fi - ;; - *) - # non VCS source - ;; - esac - done - - return $ret -} - -check_software() { - # check for needed software - local ret=0 - - # check for PACMAN if we need it - if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then - if [[ -z $PACMAN_PATH ]]; then - error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN" - ret=1 - fi - fi - - # check for sudo if we will need it during makepkg execution - if (( DEP_BIN || RMDEPS || INSTALL )); then - if ! type -p sudo >/dev/null; then - warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su" - fi - fi - - # fakeroot - correct package file permissions - if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then - if ! type -p fakeroot >/dev/null; then - error "$(gettext "Cannot find the %s binary.")" "fakeroot" - ret=1 - fi - fi - - # gpg - package signing - if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then - if ! type -p gpg >/dev/null; then - error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" - ret=1 - fi - fi - - # gpg - source verification - if (( ! SKIPPGPCHECK )) && source_has_signatures; then - if ! type -p gpg >/dev/null; then - error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg" - ret=1 - fi - fi - - # checksum operations - if (( GENINTEG || ! SKIPCHECKSUMS )); then - local integlist - IFS=$'\n' read -rd '' -a integlist < <(get_integlist) - - local integ - for integ in "${integlist[@]}"; do - if ! type -p "${integ}sum" >/dev/null; then - error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum" - ret=1 - fi - done - fi - - # strip - strip symbols from binaries/libraries - if check_option "strip" "y"; then - if ! type -p strip >/dev/null; then - error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" - ret=1 - fi - fi - - # gzip - compressig man and info pages - if check_option "zipman" "y"; then - if ! type -p gzip >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" - ret=1 - fi - fi - - # tools to download vcs sources - if ! check_vcs_software; then - ret=1 - fi - - return $ret -} - check_build_status() { if (( ! SPLITPKG )); then fullver=$(get_full_version) -- 2.19.1
From: Que Quotion <quequotion@gmail.com> also restore check for pacman! Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 2 ++ scripts/libmakepkg/executable.sh.in | 7 +++- scripts/libmakepkg/executable/ccache.sh.in | 2 +- scripts/libmakepkg/executable/distcc.sh.in | 2 +- scripts/libmakepkg/executable/fakeroot.sh.in | 2 +- scripts/libmakepkg/executable/gpg.sh.in | 2 +- scripts/libmakepkg/executable/gzip.sh.in | 2 +- scripts/libmakepkg/executable/meson.build | 1 + scripts/libmakepkg/executable/pacman.sh.in | 37 ++++++++++++++++++++ scripts/libmakepkg/executable/strip.sh.in | 2 +- scripts/libmakepkg/executable/vcs.sh.in | 12 ++++--- 11 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 scripts/libmakepkg/executable/pacman.sh.in diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 02188e9f..6e47c1a1 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -42,6 +42,7 @@ libmakepkgdir = $(datarootdir)/makepkg LIBMAKEPKGDIRS = \ buildenv \ + executable \ integrity \ lint_config \ lint_package \ @@ -58,6 +59,7 @@ LIBMAKEPKG_IN = \ libmakepkg/executable/fakeroot.sh \ libmakepkg/executable/gpg.sh \ libmakepkg/executable/gzip.sh \ + libmakepkg/executable/pacman.sh \ libmakepkg/executable/strip.sh \ libmakepkg/executable/sudo.sh \ libmakepkg/executable/vcs.sh \ diff --git a/scripts/libmakepkg/executable.sh.in b/scripts/libmakepkg/executable.sh.in index 06ed86e2..57953600 100644 --- a/scripts/libmakepkg/executable.sh.in +++ b/scripts/libmakepkg/executable.sh.in @@ -36,9 +36,14 @@ done readonly -a executable_functions check_software() { - msg "$(gettext "Checking for needed software...")" + msg "$(gettext "Checking for needed software...")" + + local ret=0 for func in ${executable_functions[@]}; do $func done + + return $ret + } diff --git a/scripts/libmakepkg/executable/ccache.sh.in b/scripts/libmakepkg/executable/ccache.sh.in index f31a2014..a745be79 100644 --- a/scripts/libmakepkg/executable/ccache.sh.in +++ b/scripts/libmakepkg/executable/ccache.sh.in @@ -31,7 +31,7 @@ executable_ccache() { if check_buildoption "ccache" "y"; then if ! type -p ccache >/dev/null; then error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" - return 1 + ret=1 fi fi } diff --git a/scripts/libmakepkg/executable/distcc.sh.in b/scripts/libmakepkg/executable/distcc.sh.in index e794d51a..b47a8915 100644 --- a/scripts/libmakepkg/executable/distcc.sh.in +++ b/scripts/libmakepkg/executable/distcc.sh.in @@ -31,7 +31,7 @@ executable_distcc() { if check_buildoption "distcc" "y"; then if ! type -p distcc >/dev/null; then error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - return 1 + ret=1 fi fi } diff --git a/scripts/libmakepkg/executable/fakeroot.sh.in b/scripts/libmakepkg/executable/fakeroot.sh.in index 7c03ebeb..83c7a0f6 100644 --- a/scripts/libmakepkg/executable/fakeroot.sh.in +++ b/scripts/libmakepkg/executable/fakeroot.sh.in @@ -31,7 +31,7 @@ executable_fakeroot() { if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then if ! type -p fakeroot >/dev/null; then error "$(gettext "Cannot find the %s binary.")" "fakeroot" - return 1 + ret=1 fi fi } diff --git a/scripts/libmakepkg/executable/gpg.sh.in b/scripts/libmakepkg/executable/gpg.sh.in index 0c198473..f53f186d 100644 --- a/scripts/libmakepkg/executable/gpg.sh.in +++ b/scripts/libmakepkg/executable/gpg.sh.in @@ -32,7 +32,7 @@ executable_gpg() { { (( ! SKIPPGPCHECK )) && source_has_signatures }; then if ! type -p gpg >/dev/null; then error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" - return 1 + ret=1 fi fi } diff --git a/scripts/libmakepkg/executable/gzip.sh.in b/scripts/libmakepkg/executable/gzip.sh.in index 6d90369e..222c5a47 100644 --- a/scripts/libmakepkg/executable/gzip.sh.in +++ b/scripts/libmakepkg/executable/gzip.sh.in @@ -31,7 +31,7 @@ executable_gzip() { if check_option "zipman" "y"; then if ! type -p gzip >/dev/null; then error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" - return 1 + ret=1 fi fi } diff --git a/scripts/libmakepkg/executable/meson.build b/scripts/libmakepkg/executable/meson.build index f6f86a4d..8536a540 100644 --- a/scripts/libmakepkg/executable/meson.build +++ b/scripts/libmakepkg/executable/meson.build @@ -7,6 +7,7 @@ sources = [ 'fakeroot.sh.in', 'gpg.sh.in', 'gzip.sh.in', + 'pacman.sh.in', 'strip.sh.in', 'sudo.sh.in', 'vcs.sh.in', diff --git a/scripts/libmakepkg/executable/pacman.sh.in b/scripts/libmakepkg/executable/pacman.sh.in new file mode 100644 index 00000000..9af475bd --- /dev/null +++ b/scripts/libmakepkg/executable/pacman.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# pacman.sh - Check for PACMAN if we need it +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_PACMAN_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_PACMAN_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_pacman') + +executable_pacman() { + if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then + if [[ -z $PACMAN_PATH ]]; then + error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/strip.sh.in b/scripts/libmakepkg/executable/strip.sh.in index 8d66c02a..318e2b97 100644 --- a/scripts/libmakepkg/executable/strip.sh.in +++ b/scripts/libmakepkg/executable/strip.sh.in @@ -31,7 +31,7 @@ executable_strip() { if check_option "strip" "y"; then if ! type -p strip >/dev/null; then error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" - return 1 + ret=1 fi fi } diff --git a/scripts/libmakepkg/executable/vcs.sh.in b/scripts/libmakepkg/executable/vcs.sh.in index 966c3680..728cb78e 100644 --- a/scripts/libmakepkg/executable/vcs.sh.in +++ b/scripts/libmakepkg/executable/vcs.sh.in @@ -50,16 +50,16 @@ get_vcsclient() { } check_vcs_software() { - local netfile all_sources all_deps deps + local netfile all_sources all_deps deps ret=0 if (( SOURCEONLY == 1 )); then # we will not download VCS sources - return 0 + return $ret fi if [[ -z $PACMAN_PATH ]]; then warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" - return 0 + return $ret fi # we currently only use global depends/makedepends arrays for --syncdeps @@ -88,7 +88,7 @@ check_vcs_software() { if ! in_array "$client" ${all_deps[@]}; then error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ "$client" "${proto%%+*}" - return 1 + ret=1 fi fi fi @@ -98,10 +98,12 @@ check_vcs_software() { ;; esac done + + return $ret } executable_vcs() { if ! check_vcs_software; then - return 1 + ret=1 fi } -- 2.19.1
From: Que Quotion <quequotion@gmail.com> Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/executable/gpg.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/libmakepkg/executable/gpg.sh.in b/scripts/libmakepkg/executable/gpg.sh.in index f53f186d..8b6b8aa2 100644 --- a/scripts/libmakepkg/executable/gpg.sh.in +++ b/scripts/libmakepkg/executable/gpg.sh.in @@ -28,8 +28,8 @@ source "$LIBRARY/util/option.sh" executable_functions+=('executable_gpg') executable_gpg() { - if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } } || \ - { (( ! SKIPPGPCHECK )) && source_has_signatures }; then + if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; } || \ + { (( ! SKIPPGPCHECK )) && source_has_signatures; }; then if ! type -p gpg >/dev/null; then error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" ret=1 -- 2.19.1
On 5/11/18 11:27 pm, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
^ this is where context goes. It will help me to understand why this patch is needed.
Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/executable/gpg.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/libmakepkg/executable/gpg.sh.in b/scripts/libmakepkg/executable/gpg.sh.in index f53f186d..8b6b8aa2 100644 --- a/scripts/libmakepkg/executable/gpg.sh.in +++ b/scripts/libmakepkg/executable/gpg.sh.in @@ -28,8 +28,8 @@ source "$LIBRARY/util/option.sh" executable_functions+=('executable_gpg')
executable_gpg() { - if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } } || \ - { (( ! SKIPPGPCHECK )) && source_has_signatures }; then + if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; } || \ + { (( ! SKIPPGPCHECK )) && source_has_signatures; }; then if ! type -p gpg >/dev/null; then error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" ret=1
From: Que Quotion <quequotion@gmail.com> Should have done this a when putting the two functions together Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/buildenv/compiler.sh.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index 38399269..e2b31916 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -25,13 +25,12 @@ LIBMAKEPKG_BUILDENV_COMPILER_SH=1 LIBRARY=${LIBRARY:-'@libmakepkgdir@'} -source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh" build_options+=('ccache' 'distcc') buildenv_functions+=('buildenv_ccache' 'buildenv_distcc') -using_ccache=0 +local using_ccache=0 buildenv_ccache() { if check_buildoption "ccache" "y"; then -- 2.19.1
On 5/11/18 11:50 pm, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
Should have done this a when putting the two functions together
Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/buildenv/compiler.sh.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index 38399269..e2b31916 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -25,13 +25,12 @@ LIBMAKEPKG_BUILDENV_COMPILER_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
-source "$LIBRARY/util/message.sh" source "$LIBRARY/util/option.sh"
Extra change unrelated to the patch.
build_options+=('ccache' 'distcc') buildenv_functions+=('buildenv_ccache' 'buildenv_distcc')
-using_ccache=0 +local using_ccache=0
This variable is set in a previous patch (I assume). Fix it by submitting a v2.
buildenv_ccache() { if check_buildoption "ccache" "y"; then
From: Que Quotion <quequotion@gmail.com> Caused makepkg to fail to run. Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/buildenv/compiler.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in index e2b31916..c5cd9b4f 100644 --- a/scripts/libmakepkg/buildenv/compiler.sh.in +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -30,7 +30,7 @@ source "$LIBRARY/util/option.sh" build_options+=('ccache' 'distcc') buildenv_functions+=('buildenv_ccache' 'buildenv_distcc') -local using_ccache=0 +using_ccache=0 buildenv_ccache() { if check_buildoption "ccache" "y"; then -- 2.19.1
From: Que Quotion <quequotion@gmail.com> Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/executable.sh.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/libmakepkg/executable.sh.in b/scripts/libmakepkg/executable.sh.in index 57953600..6328effc 100644 --- a/scripts/libmakepkg/executable.sh.in +++ b/scripts/libmakepkg/executable.sh.in @@ -36,8 +36,6 @@ done readonly -a executable_functions check_software() { - msg "$(gettext "Checking for needed software...")" - local ret=0 for func in ${executable_functions[@]}; do @@ -45,5 +43,4 @@ check_software() { done return $ret - } -- 2.19.1
On 6/11/18 2:23 am, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/libmakepkg/executable.sh.in | 3 --- 1 file changed, 3 deletions(-)
diff --git a/scripts/libmakepkg/executable.sh.in b/scripts/libmakepkg/executable.sh.in index 57953600..6328effc 100644 --- a/scripts/libmakepkg/executable.sh.in +++ b/scripts/libmakepkg/executable.sh.in @@ -36,8 +36,6 @@ done readonly -a executable_functions
check_software() { - msg "$(gettext "Checking for needed software...")" -
This is a patch for a string I assume is added earlier in your patch series. Don't submit an additional patch. Fix the previous one. A
From: Que Quotion <quequotion@gmail.com> This version is inclusive of all previous patches. Split prepare_builenv() and check_software() out of makepkg and into individual .sh.in scripts for libmakepkg. Creates two new libmakepkg modules: 'buildenv' and 'executable'. This further simplifies makepkg and allows for third-party drop-in scripts to add extentions (see makepkg-optimize on AUR). Third parties providing an extention that relies on some program should also provide an executable/program.sh to confirm its presence. Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 18 ++ scripts/libmakepkg/buildenv.sh.in | 47 ++++ scripts/libmakepkg/buildenv/buildflags.sh.in | 35 +++ scripts/libmakepkg/buildenv/compiler.sh.in | 55 +++++ scripts/libmakepkg/buildenv/debugflags.sh.in | 38 ++++ scripts/libmakepkg/buildenv/makeflags.sh.in | 35 +++ scripts/libmakepkg/buildenv/meson.build | 20 ++ scripts/libmakepkg/executable.sh.in | 46 ++++ scripts/libmakepkg/executable/ccache.sh.in | 37 ++++ scripts/libmakepkg/executable/checksum.sh.in | 43 ++++ scripts/libmakepkg/executable/distcc.sh.in | 37 ++++ scripts/libmakepkg/executable/fakeroot.sh.in | 37 ++++ scripts/libmakepkg/executable/gpg.sh.in | 38 ++++ scripts/libmakepkg/executable/gzip.sh.in | 37 ++++ scripts/libmakepkg/executable/meson.build | 26 +++ scripts/libmakepkg/executable/pacman.sh.in | 37 ++++ scripts/libmakepkg/executable/strip.sh.in | 37 ++++ scripts/libmakepkg/executable/sudo.sh.in | 36 ++++ scripts/libmakepkg/executable/vcs.sh.in | 109 ++++++++++ scripts/libmakepkg/meson.build | 2 + scripts/makepkg.sh.in | 216 +------------------ 21 files changed, 771 insertions(+), 215 deletions(-) create mode 100644 scripts/libmakepkg/buildenv.sh.in create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/compiler.sh.in create mode 100644 scripts/libmakepkg/buildenv/debugflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/meson.build create mode 100644 scripts/libmakepkg/executable.sh.in create mode 100644 scripts/libmakepkg/executable/ccache.sh.in create mode 100644 scripts/libmakepkg/executable/checksum.sh.in create mode 100644 scripts/libmakepkg/executable/distcc.sh.in create mode 100644 scripts/libmakepkg/executable/fakeroot.sh.in create mode 100644 scripts/libmakepkg/executable/gpg.sh.in create mode 100644 scripts/libmakepkg/executable/gzip.sh.in create mode 100644 scripts/libmakepkg/executable/meson.build create mode 100644 scripts/libmakepkg/executable/pacman.sh.in create mode 100644 scripts/libmakepkg/executable/strip.sh.in create mode 100644 scripts/libmakepkg/executable/sudo.sh.in create mode 100644 scripts/libmakepkg/executable/vcs.sh.in diff --git a/scripts/Makefile.am b/scripts/Makefile.am index c6b6220e..6e47c1a1 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -41,6 +41,8 @@ LIBRARY = \ libmakepkgdir = $(datarootdir)/makepkg LIBMAKEPKGDIRS = \ + buildenv \ + executable \ integrity \ lint_config \ lint_package \ @@ -50,6 +52,22 @@ LIBMAKEPKGDIRS = \ util LIBMAKEPKG_IN = \ + libmakepkg/executable.sh \ + libmakepkg/executable/ccache.sh \ + libmakepkg/executable/checksum.sh \ + libmakepkg/executable/distcc.sh \ + libmakepkg/executable/fakeroot.sh \ + libmakepkg/executable/gpg.sh \ + libmakepkg/executable/gzip.sh \ + libmakepkg/executable/pacman.sh \ + libmakepkg/executable/strip.sh \ + libmakepkg/executable/sudo.sh \ + libmakepkg/executable/vcs.sh \ + libmakepkg/buildenv.sh \ + libmakepkg/buildenv/buildflags.sh \ + libmakepkg/buildenv/compiler.sh \ + libmakepkg/buildenv/debugflags.sh \ + libmakepkg/buildenv/makeflags.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ libmakepkg/integrity/generate_signature.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in new file mode 100644 index 00000000..3126e94c --- /dev/null +++ b/scripts/libmakepkg/buildenv.sh.in @@ -0,0 +1,47 @@ +#!/bin/bash +# +# buildenv.sh - functions for altering the build environment before +# compiliation +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return +LIBMAKEPKG_BUILDENV_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" + + +declare -a buildenv_functions build_options + +for lib in "$LIBRARY/buildenv/"*.sh; do + source "$lib" +done + +readonly -a buildenv_functions build_options + +prepare_buildenv() { + msg "$(gettext "Preparing build environment...")" + + for func in ${buildenv_functions[@]}; do + $func + done + + # ensure all necessary build variables are exported + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST +} diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in new file mode 100644 index 00000000..ac207fd3 --- /dev/null +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -0,0 +1,35 @@ +#!/usr/bin/bash +# +# buildflags.sh - Clear user-specified buildflags if requested +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('buildflags') +buildenv_functions+=('buildenv_buildflags') + +buildenv_buildflags() { + if check_option "buildflags" "n"; then + unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in new file mode 100644 index 00000000..c5cd9b4f --- /dev/null +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -0,0 +1,55 @@ +#!/usr/bin/bash +# +# compiler.sh - CCache and DistCC compilation +# ccache - Cache compiliations and recycle them to save time on repititions +# distcc - Distribute compliation to reduce compilation time +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_COMPILER_SH" ]] && return +LIBMAKEPKG_BUILDENV_COMPILER_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('ccache' 'distcc') +buildenv_functions+=('buildenv_ccache' 'buildenv_distcc') + +using_ccache=0 + +buildenv_ccache() { + if check_buildoption "ccache" "y"; then + if [ -d /usr/lib/ccache/bin ]; then + export PATH="/usr/lib/ccache/bin:$PATH" + using_ccache=1 + fi + fi +} + +buildenv_distcc() { + if check_buildoption "distcc" "y"; then + if (( using_ccache )); then + export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" + export CCACHE_BASEDIR="$srcdir" + elif [[ -d /usr/lib/distcc/bin ]]; then + export PATH="/usr/lib/distcc/bin:$PATH" + fi + + export DISTCC_HOSTS + fi +} diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in new file mode 100644 index 00000000..65aa6c0a --- /dev/null +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -0,0 +1,38 @@ +#!/usr/bin/bash +# +# debugflags.sh - Specify flags for building a package with debugging +# symbols +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +buildenv_functions+=('buildenv_debugflags') + +buildenv_debugflags() { + if check_option "debug" "y"; then + DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + CFLAGS+=" $DEBUG_CFLAGS" + CXXFLAGS+=" $DEBUG_CXXFLAGS" + fi +} diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in new file mode 100644 index 00000000..45e77468 --- /dev/null +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -0,0 +1,35 @@ +#!/usr/bin/bash +# +# makeflags.sh - Clear user-specified makeflags if requested +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('makeflags') +buildenv_functions+=('buildenv_makeflags') + +buildenv_makeflags() { + if check_option "makeflags" "n"; then + unset MAKEFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build new file mode 100644 index 00000000..34d4ba7b --- /dev/null +++ b/scripts/libmakepkg/buildenv/meson.build @@ -0,0 +1,20 @@ +libmakepkg_module = 'buildenv' + +sources = [ + 'buildflags.sh.in', + 'compiler.sh.in', + 'debugflags.sh.in', + 'makeflags.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/executable.sh.in b/scripts/libmakepkg/executable.sh.in new file mode 100644 index 00000000..6328effc --- /dev/null +++ b/scripts/libmakepkg/executable.sh.in @@ -0,0 +1,46 @@ +#!/bin/bash +# +# executable.sh - functions for altering the build environment before +# compiliation +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" + + +declare -a executable_functions + +for lib in "$LIBRARY/executable/"*.sh; do + source "$lib" +done + +readonly -a executable_functions + +check_software() { + local ret=0 + + for func in ${executable_functions[@]}; do + $func + done + + return $ret +} diff --git a/scripts/libmakepkg/executable/ccache.sh.in b/scripts/libmakepkg/executable/ccache.sh.in new file mode 100644 index 00000000..a745be79 --- /dev/null +++ b/scripts/libmakepkg/executable/ccache.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# ccache.sh - Cache compiliations and recycle them to save time on repititions +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_CCACHE_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_CCACHE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_ccache') + +executable_ccache() { + if check_buildoption "ccache" "y"; then + if ! type -p ccache >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/checksum.sh.in b/scripts/libmakepkg/executable/checksum.sh.in new file mode 100644 index 00000000..4ddb20a6 --- /dev/null +++ b/scripts/libmakepkg/executable/checksum.sh.in @@ -0,0 +1,43 @@ +#!/usr/bin/bash +# +# checksum.sh - Checksum operations +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_CHECKSUM_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_CHECKSUM_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_checksum') + +executable_checksum() { + if (( GENINTEG || ! SKIPCHECKSUMS )); then + local integlist + IFS=$'\n' read -rd '' -a integlist < <(get_integlist) + + local integ + for integ in "${integlist[@]}"; do + if ! type -p "${integ}sum" >/dev/null; then + error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum" + return 1 + fi + done + fi +} diff --git a/scripts/libmakepkg/executable/distcc.sh.in b/scripts/libmakepkg/executable/distcc.sh.in new file mode 100644 index 00000000..b47a8915 --- /dev/null +++ b/scripts/libmakepkg/executable/distcc.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# distcc.sh - Distribute compliation to reduce compilation time +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_DISTCC_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_DISTCC_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_distcc') + +executable_distcc() { + if check_buildoption "distcc" "y"; then + if ! type -p distcc >/dev/null; then + error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/fakeroot.sh.in b/scripts/libmakepkg/executable/fakeroot.sh.in new file mode 100644 index 00000000..83c7a0f6 --- /dev/null +++ b/scripts/libmakepkg/executable/fakeroot.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# fakeroot.sh - Correct package file permissions +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_FAKEROOT_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_FAKEROOT_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_fakeroot') + +executable_fakeroot() { + if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then + if ! type -p fakeroot >/dev/null; then + error "$(gettext "Cannot find the %s binary.")" "fakeroot" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/gpg.sh.in b/scripts/libmakepkg/executable/gpg.sh.in new file mode 100644 index 00000000..8b6b8aa2 --- /dev/null +++ b/scripts/libmakepkg/executable/gpg.sh.in @@ -0,0 +1,38 @@ +#!/usr/bin/bash +# +# gpg.sh - Package signing or source verification +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_GPG_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_GPG_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_gpg') + +executable_gpg() { + if { [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; } || \ + { (( ! SKIPPGPCHECK )) && source_has_signatures; }; then + if ! type -p gpg >/dev/null; then + error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/gzip.sh.in b/scripts/libmakepkg/executable/gzip.sh.in new file mode 100644 index 00000000..222c5a47 --- /dev/null +++ b/scripts/libmakepkg/executable/gzip.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# gzip.sh - Compressig man and info pages +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_GZIP_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_GZIP_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_gzip') + +executable_gzip() { + if check_option "zipman" "y"; then + if ! type -p gzip >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/meson.build b/scripts/libmakepkg/executable/meson.build new file mode 100644 index 00000000..8536a540 --- /dev/null +++ b/scripts/libmakepkg/executable/meson.build @@ -0,0 +1,26 @@ +libmakepkg_module = 'executable' + +sources = [ + 'ccache.sh.in', + 'checksum.sh.in', + 'distcc.sh.in', + 'fakeroot.sh.in', + 'gpg.sh.in', + 'gzip.sh.in', + 'pacman.sh.in', + 'strip.sh.in', + 'sudo.sh.in', + 'vcs.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/executable/pacman.sh.in b/scripts/libmakepkg/executable/pacman.sh.in new file mode 100644 index 00000000..9af475bd --- /dev/null +++ b/scripts/libmakepkg/executable/pacman.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# pacman.sh - Check for PACMAN if we need it +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_PACMAN_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_PACMAN_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_pacman') + +executable_pacman() { + if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then + if [[ -z $PACMAN_PATH ]]; then + error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/strip.sh.in b/scripts/libmakepkg/executable/strip.sh.in new file mode 100644 index 00000000..318e2b97 --- /dev/null +++ b/scripts/libmakepkg/executable/strip.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# strip.sh - Strip symbols from binaries/libraries +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_STRIP_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_STRIP_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_strip') + +executable_strip() { + if check_option "strip" "y"; then + if ! type -p strip >/dev/null; then + error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/sudo.sh.in b/scripts/libmakepkg/executable/sudo.sh.in new file mode 100644 index 00000000..04807604 --- /dev/null +++ b/scripts/libmakepkg/executable/sudo.sh.in @@ -0,0 +1,36 @@ +#!/usr/bin/bash +# +# sudo.sh - Check for sudo if we will need it during makepkg execution +# +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_SUDO_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_SUDO_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_sudo') + +executable_sudo() { + if (( DEP_BIN || RMDEPS || INSTALL )); then + if ! type -p sudo >/dev/null; then + warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su" + fi + fi +} diff --git a/scripts/libmakepkg/executable/vcs.sh.in b/scripts/libmakepkg/executable/vcs.sh.in new file mode 100644 index 00000000..83f89a8d --- /dev/null +++ b/scripts/libmakepkg/executable/vcs.sh.in @@ -0,0 +1,109 @@ +#!/usr/bin/bash +# +#vcs.sh - Tools to download vcs sources +# +#Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org> +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2 of the License, or +#(at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_VCS_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_VCS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_vcs') + +get_vcsclient() { + local proto=${1%%+*} + + local i + for i in "${VCSCLIENTS[@]}"; do + local handler="${i%%::*}" + if [[ $proto = "$handler" ]]; then + local client="${i##*::}" + break + fi + done + + # if we didn't find an client, return an error + if [[ -z $client ]]; then + error "$(gettext "Unknown download protocol: %s")" "$proto" + plain "$(gettext "Aborting...")" + exit $E_CONFIG_ERROR + fi + + printf "%s\n" "$client" +} + +check_vcs_software() { + local netfile all_sources all_deps deps ret=0 + + if (( SOURCEONLY == 1 )); then + # we will not download VCS sources + return $ret + fi + + if [[ -z $PACMAN_PATH ]]; then + warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" + return $ret + fi + + # we currently only use global depends/makedepends arrays for --syncdeps + for attr in depends makedepends; do + get_pkgbuild_attribute "$pkg" "$attr" 1 'deps' + all_deps+=("${deps[@]}") + + get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps' + all_deps+=("${deps[@]}") + done + + get_all_sources_for_arch 'all_sources' + for netfile in ${all_sources[@]}; do + local proto=$(get_protocol "$netfile") + + case $proto in + bzr*|git*|hg*|svn*) + if ! type -p ${proto%%+*} > /dev/null; then + local client + client=$(get_vcsclient "$proto") || exit $? + # ensure specified program is installed + local uninstalled + uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED + # if not installed, check presence in depends or makedepends + if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then + if ! in_array "$client" ${all_deps[@]}; then + error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ + "$client" "${proto%%+*}" + ret=1 + fi + fi + fi + ;; + *) + # non VCS source + ;; + esac + done + + return $ret +} + +executable_vcs() { + if ! check_vcs_software; then + ret=1 + fi +} diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build index 07475b4d..bfba56a5 100644 --- a/scripts/libmakepkg/meson.build +++ b/scripts/libmakepkg/meson.build @@ -1,4 +1,6 @@ libmakepkg_modules = [ + { 'name' : 'buildenv', 'has_subdir' : true }, + { 'name' : 'executable', 'has_subdir' : true }, { 'name' : 'integrity', 'has_subdir' : true }, { 'name' : 'lint_config', 'has_subdir' : true }, { 'name' : 'lint_package', 'has_subdir' : true }, diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3ac03d11..4449ccf7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -48,11 +48,10 @@ declare -r startdir="$(pwd -P)" LIBRARY=${LIBRARY:-'@libmakepkgdir@'} -build_options=('ccache' 'distcc' 'buildflags' 'makeflags') splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' 'backup' 'options' 'install' 'changelog') -readonly -a build_options splitpkg_overrides +readonly -a splitpkg_overrides known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512') @@ -380,47 +379,6 @@ source_buildfile() { source_safe "$@" } -prepare_buildenv() { - # clear user-specified buildflags if requested - if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS - fi - - if check_option "debug" "y"; then - DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - CFLAGS+=" $DEBUG_CFLAGS" - CXXFLAGS+=" $DEBUG_CXXFLAGS" - fi - - # clear user-specified makeflags if requested - if check_option "makeflags" "n"; then - unset MAKEFLAGS - fi - - # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST - - local ccache=0 - - # use ccache if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "ccache" "y" && [[ -d /usr/lib/ccache/bin ]]; then - export PATH="/usr/lib/ccache/bin:$PATH" - ccache=1 - fi - - # use distcc if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "distcc" "y"; then - if (( ccache )); then - export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" - export CCACHE_BASEDIR="$srcdir" - elif [[ -d /usr/lib/distcc/bin ]]; then - export PATH="/usr/lib/distcc/bin:$PATH" - fi - export DISTCC_HOSTS - fi -} - run_function_safe() { local restoretrap restoreshopt @@ -897,178 +855,6 @@ install_package() { fi } -get_vcsclient() { - local proto=${1%%+*} - - local i - for i in "${VCSCLIENTS[@]}"; do - local handler="${i%%::*}" - if [[ $proto = "$handler" ]]; then - local client="${i##*::}" - break - fi - done - - # if we didn't find an client, return an error - if [[ -z $client ]]; then - error "$(gettext "Unknown download protocol: %s")" "$proto" - plain "$(gettext "Aborting...")" - exit $E_CONFIG_ERROR - fi - - printf "%s\n" "$client" -} - -check_vcs_software() { - local netfile all_sources all_deps deps ret=0 - - if (( SOURCEONLY == 1 )); then - # we will not download VCS sources - return $ret - fi - - if [[ -z $PACMAN_PATH ]]; then - warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" - return $ret - fi - - # we currently only use global depends/makedepends arrays for --syncdeps - for attr in depends makedepends; do - get_pkgbuild_attribute "$pkg" "$attr" 1 'deps' - all_deps+=("${deps[@]}") - - get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps' - all_deps+=("${deps[@]}") - done - - get_all_sources_for_arch 'all_sources' - for netfile in ${all_sources[@]}; do - local proto=$(get_protocol "$netfile") - - case $proto in - bzr*|git*|hg*|svn*) - if ! type -p ${proto%%+*} > /dev/null; then - local client - client=$(get_vcsclient "$proto") || exit $? - # ensure specified program is installed - local uninstalled - uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED - # if not installed, check presence in depends or makedepends - if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then - if ! in_array "$client" ${all_deps[@]}; then - error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ - "$client" "${proto%%+*}" - ret=1 - fi - fi - fi - ;; - *) - # non VCS source - ;; - esac - done - - return $ret -} - -check_software() { - # check for needed software - local ret=0 - - # check for PACMAN if we need it - if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then - if [[ -z $PACMAN_PATH ]]; then - error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN" - ret=1 - fi - fi - - # check for sudo if we will need it during makepkg execution - if (( DEP_BIN || RMDEPS || INSTALL )); then - if ! type -p sudo >/dev/null; then - warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su" - fi - fi - - # fakeroot - correct package file permissions - if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then - if ! type -p fakeroot >/dev/null; then - error "$(gettext "Cannot find the %s binary.")" "fakeroot" - ret=1 - fi - fi - - # gpg - package signing - if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then - if ! type -p gpg >/dev/null; then - error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" - ret=1 - fi - fi - - # gpg - source verification - if (( ! SKIPPGPCHECK )) && source_has_signatures; then - if ! type -p gpg >/dev/null; then - error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg" - ret=1 - fi - fi - - # checksum operations - if (( GENINTEG || ! SKIPCHECKSUMS )); then - local integlist - IFS=$'\n' read -rd '' -a integlist < <(get_integlist) - - local integ - for integ in "${integlist[@]}"; do - if ! type -p "${integ}sum" >/dev/null; then - error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum" - ret=1 - fi - done - fi - - # distcc - compilation with distcc - if check_buildoption "distcc" "y"; then - if ! type -p distcc >/dev/null; then - error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - ret=1 - fi - fi - - # ccache - compilation with ccache - if check_buildoption "ccache" "y"; then - if ! type -p ccache >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" - ret=1 - fi - fi - - # strip - strip symbols from binaries/libraries - if check_option "strip" "y"; then - if ! type -p strip >/dev/null; then - error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" - ret=1 - fi - fi - - # gzip - compressig man and info pages - if check_option "zipman" "y"; then - if ! type -p gzip >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" - ret=1 - fi - fi - - # tools to download vcs sources - if ! check_vcs_software; then - ret=1 - fi - - return $ret -} - check_build_status() { if (( ! SPLITPKG )); then fullver=$(get_full_version) -- 2.19.1
On 6/11/18 12:27 pm, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
This version is inclusive of all previous patches.
Split prepare_builenv() and check_software() out of makepkg and into individual .sh.in scripts for libmakepkg. Creates two new libmakepkg modules: 'buildenv' and 'executable'.
This further simplifies makepkg and allows for third-party drop-in scripts to add extentions (see makepkg-optimize on AUR).
Third parties providing an extention that relies on some program should also provide an executable/program.sh to confirm its presence.
And now we have one big-ass patch [1] that combines two quite unrelated changes. What I need to see is: - one patch for check_software(). - one patch for prepare_buildenv() extensions. The prepare_biuldenv() extensions may even be two separate patches but the looks of things. Allan [1] https://xkcd.com/37/
From: Que Quotion <quequotion@gmail.com> This opens the door for third parties who provide extensions to libmakepkg to supply scripts that confirm the presence of their dependant executables. See makepkg-optimize in the AUR for examples. Signed-off-by: Que Quotion <quequotion@gmail.com> --- Split v2 patch into two patches as requested. First, split check_software() out so that we can split prepare_buildenv() out as a separate patch later. scripts/Makefile.am | 12 ++ scripts/libmakepkg/executable.sh.in | 45 +++++ scripts/libmakepkg/executable/ccache.sh.in | 37 ++++ scripts/libmakepkg/executable/checksum.sh.in | 42 +++++ scripts/libmakepkg/executable/distcc.sh.in | 37 ++++ scripts/libmakepkg/executable/fakeroot.sh.in | 37 ++++ scripts/libmakepkg/executable/gpg.sh.in | 44 +++++ scripts/libmakepkg/executable/gzip.sh.in | 37 ++++ scripts/libmakepkg/executable/meson.build | 26 +++ scripts/libmakepkg/executable/pacman.sh.in | 37 ++++ scripts/libmakepkg/executable/strip.sh.in | 37 ++++ scripts/libmakepkg/executable/sudo.sh.in | 36 ++++ scripts/libmakepkg/executable/vcs.sh.in | 109 ++++++++++++ scripts/libmakepkg/meson.build | 1 + scripts/makepkg.sh.in | 172 ------------------- 15 files changed, 537 insertions(+), 172 deletions(-) create mode 100644 scripts/libmakepkg/executable.sh.in create mode 100644 scripts/libmakepkg/executable/ccache.sh.in create mode 100644 scripts/libmakepkg/executable/checksum.sh.in create mode 100644 scripts/libmakepkg/executable/distcc.sh.in create mode 100644 scripts/libmakepkg/executable/fakeroot.sh.in create mode 100644 scripts/libmakepkg/executable/gpg.sh.in create mode 100644 scripts/libmakepkg/executable/gzip.sh.in create mode 100644 scripts/libmakepkg/executable/meson.build create mode 100644 scripts/libmakepkg/executable/pacman.sh.in create mode 100644 scripts/libmakepkg/executable/strip.sh.in create mode 100644 scripts/libmakepkg/executable/sudo.sh.in create mode 100644 scripts/libmakepkg/executable/vcs.sh.in diff --git a/scripts/Makefile.am b/scripts/Makefile.am index c6b6220e..739aeb36 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -41,6 +41,7 @@ LIBRARY = \ libmakepkgdir = $(datarootdir)/makepkg LIBMAKEPKGDIRS = \ + executable \ integrity \ lint_config \ lint_package \ @@ -50,6 +51,17 @@ LIBMAKEPKGDIRS = \ util LIBMAKEPKG_IN = \ + libmakepkg/executable.sh \ + libmakepkg/executable/ccache.sh \ + libmakepkg/executable/checksum.sh \ + libmakepkg/executable/distcc.sh \ + libmakepkg/executable/fakeroot.sh \ + libmakepkg/executable/gpg.sh \ + libmakepkg/executable/gzip.sh \ + libmakepkg/executable/pacman.sh \ + libmakepkg/executable/strip.sh \ + libmakepkg/executable/sudo.sh \ + libmakepkg/executable/vcs.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ libmakepkg/integrity/generate_signature.sh \ diff --git a/scripts/libmakepkg/executable.sh.in b/scripts/libmakepkg/executable.sh.in new file mode 100644 index 00000000..68c48038 --- /dev/null +++ b/scripts/libmakepkg/executable.sh.in @@ -0,0 +1,45 @@ +#!/bin/bash +# +# executable.sh - confirm presence of dependent executables +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" + + +declare -a executable_functions + +for lib in "$LIBRARY/executable/"*.sh; do + source "$lib" +done + +readonly -a executable_functions + +check_software() { + local ret=0 + + for func in ${executable_functions[@]}; do + $func + done + + return $ret +} diff --git a/scripts/libmakepkg/executable/ccache.sh.in b/scripts/libmakepkg/executable/ccache.sh.in new file mode 100644 index 00000000..6871d64a --- /dev/null +++ b/scripts/libmakepkg/executable/ccache.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# ccache.sh - Confirm presence of CCache binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_CCACHE_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_CCACHE_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_ccache') + +executable_ccache() { + if check_buildoption "ccache" "y"; then + if ! type -p ccache >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/checksum.sh.in b/scripts/libmakepkg/executable/checksum.sh.in new file mode 100644 index 00000000..c17dc67c --- /dev/null +++ b/scripts/libmakepkg/executable/checksum.sh.in @@ -0,0 +1,42 @@ +#!/usr/bin/bash +# +# checksum.sh - Confirm presence of Checksum binaries +# +# Copyright (c) 201-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_CHECKSUM_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_CHECKSUM_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + + +executable_functions+=('executable_checksum') + +executable_checksum() { + if (( GENINTEG || ! SKIPCHECKSUMS )); then + local integlist + IFS=$'\n' read -rd '' -a integlist < <(get_integlist) + + local integ + for integ in "${integlist[@]}"; do + if ! type -p "${integ}sum" >/dev/null; then + error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum" + return 1 + fi + done + fi +} diff --git a/scripts/libmakepkg/executable/distcc.sh.in b/scripts/libmakepkg/executable/distcc.sh.in new file mode 100644 index 00000000..854726cb --- /dev/null +++ b/scripts/libmakepkg/executable/distcc.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# distcc.sh - Confirm presence of DistCC binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_DISTCC_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_DISTCC_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_distcc') + +executable_distcc() { + if check_buildoption "distcc" "y"; then + if ! type -p distcc >/dev/null; then + error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/fakeroot.sh.in b/scripts/libmakepkg/executable/fakeroot.sh.in new file mode 100644 index 00000000..efd04587 --- /dev/null +++ b/scripts/libmakepkg/executable/fakeroot.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# fakeroot.sh - Confirm presence of Fakeroot binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_FAKEROOT_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_FAKEROOT_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_fakeroot') + +executable_fakeroot() { + if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then + if ! type -p fakeroot >/dev/null; then + error "$(gettext "Cannot find the %s binary.")" "fakeroot" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/gpg.sh.in b/scripts/libmakepkg/executable/gpg.sh.in new file mode 100644 index 00000000..a6476632 --- /dev/null +++ b/scripts/libmakepkg/executable/gpg.sh.in @@ -0,0 +1,44 @@ +#!/usr/bin/bash +# +# gpg.sh - Confirm presence of GPG binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_GPG_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_GPG_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_gpg') + +executable_gpg() { + if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then + if ! type -p gpg >/dev/null; then + error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" + ret=1 + fi + fi + + if (( ! SKIPPGPCHECK )) && source_has_signatures; then + if ! type -p gpg >/dev/null; then + error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/gzip.sh.in b/scripts/libmakepkg/executable/gzip.sh.in new file mode 100644 index 00000000..ed2beb3d --- /dev/null +++ b/scripts/libmakepkg/executable/gzip.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# gzip.sh - Confirm presence of GZip binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_GZIP_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_GZIP_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_gzip') + +executable_gzip() { + if check_option "zipman" "y"; then + if ! type -p gzip >/dev/null; then + error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/meson.build b/scripts/libmakepkg/executable/meson.build new file mode 100644 index 00000000..8536a540 --- /dev/null +++ b/scripts/libmakepkg/executable/meson.build @@ -0,0 +1,26 @@ +libmakepkg_module = 'executable' + +sources = [ + 'ccache.sh.in', + 'checksum.sh.in', + 'distcc.sh.in', + 'fakeroot.sh.in', + 'gpg.sh.in', + 'gzip.sh.in', + 'pacman.sh.in', + 'strip.sh.in', + 'sudo.sh.in', + 'vcs.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/executable/pacman.sh.in b/scripts/libmakepkg/executable/pacman.sh.in new file mode 100644 index 00000000..21765f16 --- /dev/null +++ b/scripts/libmakepkg/executable/pacman.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# pacman.sh - Confirm presence of pacman binary +# +# Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_PACMAN_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_PACMAN_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_pacman') + +executable_pacman() { + if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then + if [[ -z $PACMAN_PATH ]]; then + error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/strip.sh.in b/scripts/libmakepkg/executable/strip.sh.in new file mode 100644 index 00000000..9b3f468e --- /dev/null +++ b/scripts/libmakepkg/executable/strip.sh.in @@ -0,0 +1,37 @@ +#!/usr/bin/bash +# +# strip.sh - Confirm presense of Strip binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_STRIP_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_STRIP_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_strip') + +executable_strip() { + if check_option "strip" "y"; then + if ! type -p strip >/dev/null; then + error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" + ret=1 + fi + fi +} diff --git a/scripts/libmakepkg/executable/sudo.sh.in b/scripts/libmakepkg/executable/sudo.sh.in new file mode 100644 index 00000000..bd8044f7 --- /dev/null +++ b/scripts/libmakepkg/executable/sudo.sh.in @@ -0,0 +1,36 @@ +#!/usr/bin/bash +# +# sudo.sh - Confirm presence of Sudo binary +# +# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_SUDO_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_SUDO_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_sudo') + +executable_sudo() { + if (( DEP_BIN || RMDEPS || INSTALL )); then + if ! type -p sudo >/dev/null; then + warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su" + fi + fi +} diff --git a/scripts/libmakepkg/executable/vcs.sh.in b/scripts/libmakepkg/executable/vcs.sh.in new file mode 100644 index 00000000..f73e0cf6 --- /dev/null +++ b/scripts/libmakepkg/executable/vcs.sh.in @@ -0,0 +1,109 @@ +#!/usr/bin/bash +# +#vcs.sh - Confirm presence of VCS binaries +# +#Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2 of the License, or +#(at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_EXECUTABLE_VCS_SH" ]] && return +LIBMAKEPKG_EXECUTABLE_VCS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +executable_functions+=('executable_vcs') + +get_vcsclient() { + local proto=${1%%+*} + + local i + for i in "${VCSCLIENTS[@]}"; do + local handler="${i%%::*}" + if [[ $proto = "$handler" ]]; then + local client="${i##*::}" + break + fi + done + + # if we didn't find an client, return an error + if [[ -z $client ]]; then + error "$(gettext "Unknown download protocol: %s")" "$proto" + plain "$(gettext "Aborting...")" + exit $E_CONFIG_ERROR + fi + + printf "%s\n" "$client" +} + +check_vcs_software() { + local netfile all_sources all_deps deps ret=0 + + if (( SOURCEONLY == 1 )); then + # we will not download VCS sources + return $ret + fi + + if [[ -z $PACMAN_PATH ]]; then + warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" + return $ret + fi + + # we currently only use global depends/makedepends arrays for --syncdeps + for attr in depends makedepends; do + get_pkgbuild_attribute "$pkg" "$attr" 1 'deps' + all_deps+=("${deps[@]}") + + get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps' + all_deps+=("${deps[@]}") + done + + get_all_sources_for_arch 'all_sources' + for netfile in ${all_sources[@]}; do + local proto=$(get_protocol "$netfile") + + case $proto in + bzr*|git*|hg*|svn*) + if ! type -p ${proto%%+*} > /dev/null; then + local client + client=$(get_vcsclient "$proto") || exit $? + # ensure specified program is installed + local uninstalled + uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED + # if not installed, check presence in depends or makedepends + if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then + if ! in_array "$client" ${all_deps[@]}; then + error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ + "$client" "${proto%%+*}" + ret=1 + fi + fi + fi + ;; + *) + # non VCS source + ;; + esac + done + + return $ret +} + +executable_vcs() { + if ! check_vcs_software; then + ret=1 + fi +} diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build index 07475b4d..872e61ca 100644 --- a/scripts/libmakepkg/meson.build +++ b/scripts/libmakepkg/meson.build @@ -1,4 +1,5 @@ libmakepkg_modules = [ + { 'name' : 'executable', 'has_subdir' : true }, { 'name' : 'integrity', 'has_subdir' : true }, { 'name' : 'lint_config', 'has_subdir' : true }, { 'name' : 'lint_package', 'has_subdir' : true }, diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 3ac03d11..fe9b5aa0 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -897,178 +897,6 @@ install_package() { fi } -get_vcsclient() { - local proto=${1%%+*} - - local i - for i in "${VCSCLIENTS[@]}"; do - local handler="${i%%::*}" - if [[ $proto = "$handler" ]]; then - local client="${i##*::}" - break - fi - done - - # if we didn't find an client, return an error - if [[ -z $client ]]; then - error "$(gettext "Unknown download protocol: %s")" "$proto" - plain "$(gettext "Aborting...")" - exit $E_CONFIG_ERROR - fi - - printf "%s\n" "$client" -} - -check_vcs_software() { - local netfile all_sources all_deps deps ret=0 - - if (( SOURCEONLY == 1 )); then - # we will not download VCS sources - return $ret - fi - - if [[ -z $PACMAN_PATH ]]; then - warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN" - return $ret - fi - - # we currently only use global depends/makedepends arrays for --syncdeps - for attr in depends makedepends; do - get_pkgbuild_attribute "$pkg" "$attr" 1 'deps' - all_deps+=("${deps[@]}") - - get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps' - all_deps+=("${deps[@]}") - done - - get_all_sources_for_arch 'all_sources' - for netfile in ${all_sources[@]}; do - local proto=$(get_protocol "$netfile") - - case $proto in - bzr*|git*|hg*|svn*) - if ! type -p ${proto%%+*} > /dev/null; then - local client - client=$(get_vcsclient "$proto") || exit $? - # ensure specified program is installed - local uninstalled - uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED - # if not installed, check presence in depends or makedepends - if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then - if ! in_array "$client" ${all_deps[@]}; then - error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \ - "$client" "${proto%%+*}" - ret=1 - fi - fi - fi - ;; - *) - # non VCS source - ;; - esac - done - - return $ret -} - -check_software() { - # check for needed software - local ret=0 - - # check for PACMAN if we need it - if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then - if [[ -z $PACMAN_PATH ]]; then - error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN" - ret=1 - fi - fi - - # check for sudo if we will need it during makepkg execution - if (( DEP_BIN || RMDEPS || INSTALL )); then - if ! type -p sudo >/dev/null; then - warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su" - fi - fi - - # fakeroot - correct package file permissions - if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then - if ! type -p fakeroot >/dev/null; then - error "$(gettext "Cannot find the %s binary.")" "fakeroot" - ret=1 - fi - fi - - # gpg - package signing - if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then - if ! type -p gpg >/dev/null; then - error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg" - ret=1 - fi - fi - - # gpg - source verification - if (( ! SKIPPGPCHECK )) && source_has_signatures; then - if ! type -p gpg >/dev/null; then - error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg" - ret=1 - fi - fi - - # checksum operations - if (( GENINTEG || ! SKIPCHECKSUMS )); then - local integlist - IFS=$'\n' read -rd '' -a integlist < <(get_integlist) - - local integ - for integ in "${integlist[@]}"; do - if ! type -p "${integ}sum" >/dev/null; then - error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum" - ret=1 - fi - done - fi - - # distcc - compilation with distcc - if check_buildoption "distcc" "y"; then - if ! type -p distcc >/dev/null; then - error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc" - ret=1 - fi - fi - - # ccache - compilation with ccache - if check_buildoption "ccache" "y"; then - if ! type -p ccache >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache" - ret=1 - fi - fi - - # strip - strip symbols from binaries/libraries - if check_option "strip" "y"; then - if ! type -p strip >/dev/null; then - error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip" - ret=1 - fi - fi - - # gzip - compressig man and info pages - if check_option "zipman" "y"; then - if ! type -p gzip >/dev/null; then - error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip" - ret=1 - fi - fi - - # tools to download vcs sources - if ! check_vcs_software; then - ret=1 - fi - - return $ret -} - check_build_status() { if (( ! SPLITPKG )); then fullver=$(get_full_version) -- 2.19.2
On 27/11/18 7:23 pm, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
This opens the door for third parties who provide extensions to libmakepkg to supply scripts that confirm the presence of their dependant executables.
See makepkg-optimize in the AUR for examples.
Signed-off-by: Que Quotion <quequotion@gmail.com> --- Split v2 patch into two patches as requested. First, split check_software() out so that we can split prepare_buildenv() out as a separate patch later.
I had reviewed this offline. A couple of issues crept in while doing the latest revisions (truncated copyright year, indenting in copyright notice for one file), but I have fixed these and pulled the patch. Thanks, Allan
From: Que Quotion <quequotion@gmail.com> This opens the door for third parties to provide libmakepkg extentions for the purpose of altering the build environment. See makepkg-optimize in the AUR for examples. Signed-off-by: Que Quotion <quequotion@gmail.com> --- scripts/Makefile.am | 6 +++ scripts/libmakepkg/buildenv.sh.in | 47 +++++++++++++++++ scripts/libmakepkg/buildenv/buildflags.sh.in | 35 +++++++++++++ scripts/libmakepkg/buildenv/compiler.sh.in | 55 ++++++++++++++++++++ scripts/libmakepkg/buildenv/debugflags.sh.in | 38 ++++++++++++++ scripts/libmakepkg/buildenv/makeflags.sh.in | 35 +++++++++++++ scripts/libmakepkg/buildenv/meson.build | 20 +++++++ scripts/libmakepkg/meson.build | 1 + scripts/makepkg.sh.in | 44 +--------------- 9 files changed, 238 insertions(+), 43 deletions(-) create mode 100644 scripts/libmakepkg/buildenv.sh.in create mode 100644 scripts/libmakepkg/buildenv/buildflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/compiler.sh.in create mode 100644 scripts/libmakepkg/buildenv/debugflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/makeflags.sh.in create mode 100644 scripts/libmakepkg/buildenv/meson.build diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 739aeb36..6e47c1a1 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -41,6 +41,7 @@ LIBRARY = \ libmakepkgdir = $(datarootdir)/makepkg LIBMAKEPKGDIRS = \ + buildenv \ executable \ integrity \ lint_config \ @@ -62,6 +63,11 @@ LIBMAKEPKG_IN = \ libmakepkg/executable/strip.sh \ libmakepkg/executable/sudo.sh \ libmakepkg/executable/vcs.sh \ + libmakepkg/buildenv.sh \ + libmakepkg/buildenv/buildflags.sh \ + libmakepkg/buildenv/compiler.sh \ + libmakepkg/buildenv/debugflags.sh \ + libmakepkg/buildenv/makeflags.sh \ libmakepkg/integrity.sh \ libmakepkg/integrity/generate_checksum.sh \ libmakepkg/integrity/generate_signature.sh \ diff --git a/scripts/libmakepkg/buildenv.sh.in b/scripts/libmakepkg/buildenv.sh.in new file mode 100644 index 00000000..3126e94c --- /dev/null +++ b/scripts/libmakepkg/buildenv.sh.in @@ -0,0 +1,45 @@ +#!/bin/bash +# +# buildenv.sh - functions for altering the build environment before +# compiliation +# +# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_SH" ]] && return +LIBMAKEPKG_BUILDENV_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/message.sh" + + +declare -a buildenv_functions build_options + +for lib in "$LIBRARY/buildenv/"*.sh; do + source "$lib" +done + +readonly -a buildenv_functions build_options + +prepare_buildenv() { + for func in ${buildenv_functions[@]}; do + $func + done + + # ensure all necessary build variables are exported + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST +} diff --git a/scripts/libmakepkg/buildenv/buildflags.sh.in b/scripts/libmakepkg/buildenv/buildflags.sh.in new file mode 100644 index 00000000..ac207fd3 --- /dev/null +++ b/scripts/libmakepkg/buildenv/buildflags.sh.in @@ -0,0 +1,35 @@ +#!/usr/bin/bash +# +# buildflags.sh - Clear user-specified buildflags if requested +# +# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_BUILDFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('buildflags') +buildenv_functions+=('buildenv_buildflags') + +buildenv_buildflags() { + if check_option "buildflags" "n"; then + unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/compiler.sh.in b/scripts/libmakepkg/buildenv/compiler.sh.in new file mode 100644 index 00000000..c5cd9b4f --- /dev/null +++ b/scripts/libmakepkg/buildenv/compiler.sh.in @@ -0,0 +1,55 @@ +#!/usr/bin/bash +# +# compiler.sh - CCache and DistCC compilation +# ccache - Cache compiliations and recycle them to save time on repititions +# distcc - Distribute compliation to reduce compilation time +# +# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_COMPILER_SH" ]] && return +LIBMAKEPKG_BUILDENV_COMPILER_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('ccache' 'distcc') +buildenv_functions+=('buildenv_ccache' 'buildenv_distcc') + +using_ccache=0 + +buildenv_ccache() { + if check_buildoption "ccache" "y"; then + if [ -d /usr/lib/ccache/bin ]; then + export PATH="/usr/lib/ccache/bin:$PATH" + using_ccache=1 + fi + fi +} + +buildenv_distcc() { + if check_buildoption "distcc" "y"; then + if (( using_ccache )); then + export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" + export CCACHE_BASEDIR="$srcdir" + elif [[ -d /usr/lib/distcc/bin ]]; then + export PATH="/usr/lib/distcc/bin:$PATH" + fi + + export DISTCC_HOSTS + fi +} diff --git a/scripts/libmakepkg/buildenv/debugflags.sh.in b/scripts/libmakepkg/buildenv/debugflags.sh.in new file mode 100644 index 00000000..65aa6c0a --- /dev/null +++ b/scripts/libmakepkg/buildenv/debugflags.sh.in @@ -0,0 +1,38 @@ +#!/usr/bin/bash +# +# debugflags.sh - Specify flags for building a package with debugging +# symbols +# +# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_DEBUGFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +buildenv_functions+=('buildenv_debugflags') + +buildenv_debugflags() { + if check_option "debug" "y"; then + DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" + CFLAGS+=" $DEBUG_CFLAGS" + CXXFLAGS+=" $DEBUG_CXXFLAGS" + fi +} diff --git a/scripts/libmakepkg/buildenv/makeflags.sh.in b/scripts/libmakepkg/buildenv/makeflags.sh.in new file mode 100644 index 00000000..45e77468 --- /dev/null +++ b/scripts/libmakepkg/buildenv/makeflags.sh.in @@ -0,0 +1,35 @@ +#!/usr/bin/bash +# +# makeflags.sh - Clear user-specified makeflags if requested +# +# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +[[ -n "$LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH" ]] && return +LIBMAKEPKG_BUILDENV_MAKEFLAGS_SH=1 + +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +source "$LIBRARY/util/option.sh" + +build_options+=('makeflags') +buildenv_functions+=('buildenv_makeflags') + +buildenv_makeflags() { + if check_option "makeflags" "n"; then + unset MAKEFLAGS + fi +} diff --git a/scripts/libmakepkg/buildenv/meson.build b/scripts/libmakepkg/buildenv/meson.build new file mode 100644 index 00000000..34d4ba7b --- /dev/null +++ b/scripts/libmakepkg/buildenv/meson.build @@ -0,0 +1,20 @@ +libmakepkg_module = 'buildenv' + +sources = [ + 'buildflags.sh.in', + 'compiler.sh.in', + 'debugflags.sh.in', + 'makeflags.sh.in', +] + +foreach src : sources + output_dir = join_paths(get_option('datadir'), 'makepkg', libmakepkg_module) + + custom_target( + libmakepkg_module + '_' + src.underscorify(), + command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@' ], + input : src, + output : '@BASENAME@', + install : true, + install_dir : output_dir) +endforeach diff --git a/scripts/libmakepkg/meson.build b/scripts/libmakepkg/meson.build index 872e61ca..bfba56a5 100644 --- a/scripts/libmakepkg/meson.build +++ b/scripts/libmakepkg/meson.build @@ -1,4 +1,5 @@ libmakepkg_modules = [ + { 'name' : 'buildenv', 'has_subdir' : true }, { 'name' : 'executable', 'has_subdir' : true }, { 'name' : 'integrity', 'has_subdir' : true }, { 'name' : 'lint_config', 'has_subdir' : true }, diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index fe9b5aa0..4449ccf7 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -48,11 +48,10 @@ declare -r startdir="$(pwd -P)" LIBRARY=${LIBRARY:-'@libmakepkgdir@'} -build_options=('ccache' 'distcc' 'buildflags' 'makeflags') splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' 'backup' 'options' 'install' 'changelog') -readonly -a build_options splitpkg_overrides +readonly -a splitpkg_overrides known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512') @@ -380,47 +379,6 @@ source_buildfile() { source_safe "$@" } -prepare_buildenv() { - # clear user-specified buildflags if requested - if check_option "buildflags" "n"; then - unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS - fi - - if check_option "debug" "y"; then - DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}" - CFLAGS+=" $DEBUG_CFLAGS" - CXXFLAGS+=" $DEBUG_CXXFLAGS" - fi - - # clear user-specified makeflags if requested - if check_option "makeflags" "n"; then - unset MAKEFLAGS - fi - - # ensure all necessary build variables are exported - export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST - - local ccache=0 - - # use ccache if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "ccache" "y" && [[ -d /usr/lib/ccache/bin ]]; then - export PATH="/usr/lib/ccache/bin:$PATH" - ccache=1 - fi - - # use distcc if it is requested (check buildenv and PKGBUILD opts) - if check_buildoption "distcc" "y"; then - if (( ccache )); then - export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc" - export CCACHE_BASEDIR="$srcdir" - elif [[ -d /usr/lib/distcc/bin ]]; then - export PATH="/usr/lib/distcc/bin:$PATH" - fi - export DISTCC_HOSTS - fi -} - run_function_safe() { local restoretrap restoreshopt -- 2.19.1
On 27/11/18 7:23 pm, Que Quotion wrote:
From: Que Quotion <quequotion@gmail.com>
This opens the door for third parties to provide libmakepkg extentions for the purpose of altering the build environment.
See makepkg-optimize in the AUR for examples.
Signed-off-by: Que Quotion <quequotion@gmail.com> ---
OK. Caught a couple of typos. Also, some of these options have been around forever... I see some of them originating in 2007 at the latest. I suspect they may go back further, but just started the copyright year on the split files from then. Allan
From: Que Quotion <quequotion@gmail.com> Thank you for the assistance, and the merges. I triple checked these patches before sending them. I might have extremely early onset Alzheimer's. ¯\_(ツ)_/¯
participants (3)
-
Allan McRae
-
Eli Schwartz
-
Que Quotion