Split check_software() to libmakepkg
This opens the door for third parties who provide extensions to libmakepkg to supply scripts that confirm the presence of their dependant executables. Signed-off-by: Que Quotion <quequotion@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
d81b5cc2a5
commit
0bb04fa16a
15 changed files with 537 additions and 172 deletions
|
@ -40,6 +40,7 @@ LIBRARY = \
|
||||||
libmakepkgdir = $(datarootdir)/makepkg
|
libmakepkgdir = $(datarootdir)/makepkg
|
||||||
|
|
||||||
LIBMAKEPKGDIRS = \
|
LIBMAKEPKGDIRS = \
|
||||||
|
executable \
|
||||||
integrity \
|
integrity \
|
||||||
lint_config \
|
lint_config \
|
||||||
lint_package \
|
lint_package \
|
||||||
|
@ -49,6 +50,17 @@ LIBMAKEPKGDIRS = \
|
||||||
util
|
util
|
||||||
|
|
||||||
LIBMAKEPKG_IN = \
|
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.sh \
|
||||||
libmakepkg/integrity/generate_checksum.sh \
|
libmakepkg/integrity/generate_checksum.sh \
|
||||||
libmakepkg/integrity/generate_signature.sh \
|
libmakepkg/integrity/generate_signature.sh \
|
||||||
|
|
45
scripts/libmakepkg/executable.sh.in
Normal file
45
scripts/libmakepkg/executable.sh.in
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# executable.sh - confirm presence of dependent executables
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
}
|
37
scripts/libmakepkg/executable/ccache.sh.in
Normal file
37
scripts/libmakepkg/executable/ccache.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
42
scripts/libmakepkg/executable/checksum.sh.in
Normal file
42
scripts/libmakepkg/executable/checksum.sh.in
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
#
|
||||||
|
# checksum.sh - Confirm presence of binaries for checksum operations
|
||||||
|
#
|
||||||
|
# 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_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
|
||||||
|
}
|
37
scripts/libmakepkg/executable/distcc.sh.in
Normal file
37
scripts/libmakepkg/executable/distcc.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
37
scripts/libmakepkg/executable/fakeroot.sh.in
Normal file
37
scripts/libmakepkg/executable/fakeroot.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
44
scripts/libmakepkg/executable/gpg.sh.in
Normal file
44
scripts/libmakepkg/executable/gpg.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
37
scripts/libmakepkg/executable/gzip.sh.in
Normal file
37
scripts/libmakepkg/executable/gzip.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
26
scripts/libmakepkg/executable/meson.build
Normal file
26
scripts/libmakepkg/executable/meson.build
Normal file
|
@ -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
|
37
scripts/libmakepkg/executable/pacman.sh.in
Normal file
37
scripts/libmakepkg/executable/pacman.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
37
scripts/libmakepkg/executable/strip.sh.in
Normal file
37
scripts/libmakepkg/executable/strip.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
36
scripts/libmakepkg/executable/sudo.sh.in
Normal file
36
scripts/libmakepkg/executable/sudo.sh.in
Normal file
|
@ -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
|
||||||
|
}
|
109
scripts/libmakepkg/executable/vcs.sh.in
Normal file
109
scripts/libmakepkg/executable/vcs.sh.in
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
#
|
||||||
|
# vcs.sh - Confirm presence of binaries for VCS operations
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
libmakepkg_modules = [
|
libmakepkg_modules = [
|
||||||
|
{ 'name' : 'executable', 'has_subdir' : true },
|
||||||
{ 'name' : 'integrity', 'has_subdir' : true },
|
{ 'name' : 'integrity', 'has_subdir' : true },
|
||||||
{ 'name' : 'lint_config', 'has_subdir' : true },
|
{ 'name' : 'lint_config', 'has_subdir' : true },
|
||||||
{ 'name' : 'lint_package', 'has_subdir' : true },
|
{ 'name' : 'lint_package', 'has_subdir' : true },
|
||||||
|
|
|
@ -897,178 +897,6 @@ install_package() {
|
||||||
fi
|
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() {
|
check_build_status() {
|
||||||
if (( ! SPLITPKG )); then
|
if (( ! SPLITPKG )); then
|
||||||
fullver=$(get_full_version)
|
fullver=$(get_full_version)
|
||||||
|
|
Loading…
Add table
Reference in a new issue