Updated msys2 to msys2-base-x86_64-20200903

This commit is contained in:
Gator96100 2020-09-07 18:14:14 +02:00
commit 2307d54cb1
18501 changed files with 1684082 additions and 720361 deletions

View file

@ -0,0 +1,40 @@
#!/usr/bin/bash
#
# buildenv.sh - functions for altering the build environment before
# compilation
#
# Copyright (c) 2015-2020 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
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 RUSTFLAGS MAKEFLAGS CHOST
}

View file

@ -0,0 +1,35 @@
#!/usr/bin/bash
#
# buildflags.sh - Clear user-specified buildflags if requested
#
# Copyright (c) 2011-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/option.sh"
build_options+=('buildflags')
buildenv_functions+=('buildenv_buildflags')
buildenv_buildflags() {
if check_option "buildflags" "n"; then
unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS RUSTFLAGS DEBUG_RUSTFLAGS
fi
}

View file

@ -0,0 +1,55 @@
#!/usr/bin/bash
#
# compiler.sh - CCache and DistCC compilation
# ccache - Cache compilations and reuse them to save time on repetitions
# distcc - Distribute compilation of C and C++ across machines
#
# Copyright (c) 2007-2020 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:-'/usr/share/makepkg'}
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
}

View file

@ -0,0 +1,40 @@
#!/usr/bin/bash
#
# debugflags.sh - Specify flags for building a package with debugging
# symbols
#
# Copyright (c) 2012-2020 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:-'/usr/share/makepkg'}
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}"
DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
CFLAGS+=" $DEBUG_CFLAGS"
CXXFLAGS+=" $DEBUG_CXXFLAGS"
RUSTFLAGS+=" $DEBUG_RUSTFLAGS"
fi
}

View file

@ -0,0 +1,35 @@
#!/usr/bin/bash
#
# makeflags.sh - Clear user-specified makeflags if requested
#
# Copyright (c) 2007-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/option.sh"
build_options+=('makeflags')
buildenv_functions+=('buildenv_makeflags')
buildenv_makeflags() {
if check_option "makeflags" "n"; then
unset MAKEFLAGS
fi
}

View file

@ -0,0 +1,40 @@
#!/usr/bin/bash
#
# executable.sh - confirm presence of dependent executables
#
# Copyright (c) 2018-2020 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
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 || ret=1
done
return $ret
}

View file

@ -0,0 +1,38 @@
#!/usr/bin/bash
#
# ccache.sh - Confirm presence of ccache binary
#
# Copyright (c) 2011-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
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
}

View file

@ -0,0 +1,43 @@
#!/usr/bin/bash
#
# checksum.sh - Confirm presence of binaries for checksum operations
#
# Copyright (c) 2016-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
executable_functions+=('executable_checksum')
executable_checksum() {
if (( GENINTEG || ! SKIPCHECKSUMS )); then
local integlist
mapfile -t 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
}

View file

@ -0,0 +1,38 @@
#!/usr/bin/bash
#
# distcc.sh - Confirm presence of distcc binary
#
# Copyright (c) 2011-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
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
}

View file

@ -0,0 +1,49 @@
#!/usr/bin/bash
#
# gpg.sh - Confirm presence of gpg binary
#
# Copyright (c) 2011-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/option.sh"
executable_functions+=('executable_gpg')
executable_gpg() {
local ret=0
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
return $ret
}

View file

@ -0,0 +1,38 @@
#!/usr/bin/bash
#
# gzip.sh - Confirm presence of gzip binary
#
# Copyright (c) 2011-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
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
}

View file

@ -0,0 +1,37 @@
#!/usr/bin/bash
#
# pacman.sh - Confirm presence of pacman binary
#
# Copyright (c) 2012-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.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"
return 1
fi
fi
}

View file

@ -0,0 +1,38 @@
#!/usr/bin/bash
#
# strip.sh - Confirm presence of strip binary
#
# Copyright (c) 2011-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
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
}

View file

@ -0,0 +1,104 @@
#!/usr/bin/bash
#
# vcs.sh - Confirm presence of binaries for VCS operations
#
# Copyright (c) 2014-2020 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:-'/usr/share/makepkg'}
source "$LIBRARY/util/error.sh"
source "$LIBRARY/util/message.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"
plainerr "$(gettext "Aborting...")"
exit $E_CONFIG_ERROR
fi
printf "%s\n" "$client"
}
executable_vcs() {
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
}

View file

@ -2,7 +2,7 @@
#
# integrity.sh - functions relating to source integrity checking
#
# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2011-2020 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

View file

@ -2,7 +2,7 @@
#
# generate_checksum.sh - functions for generating source checksums
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
generate_one_checksum() {
local integ=$1 arch=$2 sources numsrc indentsz idx
@ -52,7 +53,7 @@ generate_one_checksum() {
proto="$(get_protocol "$netfile")"
case $proto in
bzr*|git*|hg*|svn*)
bzr|git|hg|svn)
sum="SKIP"
;;
*)
@ -78,7 +79,7 @@ generate_one_checksum() {
}
generate_checksums() {
msg "$(gettext "Generating checksums for source files...")"
msg "$(gettext "Generating checksums for source files...")" >&2
local integlist
if (( $# == 0 )); then

View file

@ -2,7 +2,7 @@
#
# generate_signature.sh - functions for generating PGP signatures
#
# Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2008-2020 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
@ -29,24 +29,26 @@ create_signature() {
local ret=0
local filename="$1"
local SIGNWITHKEY=""
local SIGNWITHKEY=()
if [[ -n $GPGKEY ]]; then
SIGNWITHKEY="-u ${GPGKEY}"
SIGNWITHKEY=(-u "${GPGKEY}")
fi
gpg --detach-sign --use-agent ${SIGNWITHKEY} --no-armor "$filename" &>/dev/null || ret=$?
gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" --no-armor "$filename" &>/dev/null || ret=$?
if (( ! ret )); then
msg2 "$(gettext "Created signature file %s.")" "${filename##*/}.sig"
else
warning "$(gettext "Failed to sign package file.")"
warning "$(gettext "Failed to sign package file %s.")" "${filename##*/}"
fi
return $ret
}
create_package_signatures() {
local ret=0
if [[ $SIGNPKG != 'y' ]]; then
return 0
fi
@ -59,7 +61,7 @@ create_package_signatures() {
pkgarch=$(get_pkg_arch $pkg)
pkg_file="$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}"
create_signature "$pkg_file"
create_signature "$pkg_file" || ret=$?
done
# check if debug package needs a signature
@ -68,7 +70,9 @@ create_package_signatures() {
pkgarch=$(get_pkg_arch)
pkg_file="$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}"
if [[ -f $pkg_file ]]; then
create_signature "$pkg_file"
create_signature "$pkg_file" || ret=$?
fi
fi
return $ret
}

View file

@ -2,7 +2,7 @@
#
# verify_checksum.sh - functions for checking source checksums
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -25,6 +25,7 @@ LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
check_checksums() {
local integ a

View file

@ -2,7 +2,7 @@
#
# verify_signature.sh - functions for checking PGP signatures
#
# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2011-2020 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
@ -49,8 +49,8 @@ check_pgpsigs() {
for netfile in "${all_sources[@]}"; do
proto="$(get_protocol "$netfile")"
if [[ $proto = git* ]]; then
verify_git_signature "$netfile" "$statusfile" || continue
if declare -f verify_${proto}_signature > /dev/null; then
verify_${proto}_signature "$netfile" "$statusfile" || continue
else
verify_file_signature "$netfile" "$statusfile" || continue
fi
@ -112,7 +112,7 @@ check_pgpsigs() {
if (( warnings )); then
warning "$(gettext "Warnings have occurred while verifying the signatures.")"
plain "$(gettext "Please make sure you really trust them.")"
plainerr "$(gettext "Please make sure you really trust them.")"
fi
}
@ -137,7 +137,7 @@ verify_file_signature() {
for ext in "" gz bz2 xz lrz lzo Z; do
if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then
found=1
break;
break
fi
done
if (( ! found )); then
@ -263,7 +263,8 @@ source_has_signatures() {
proto="$(get_protocol "$netfile")"
query=$(get_uri_query "$netfile")
if [[ ${netfile%%::*} = *.@(sig?(n)|asc) || ( $proto = git* && $query = signed ) ]]; then
if [[ ${netfile%%::*} = *.@(sig?(n)|asc) ]] || \
( declare -f verify_${proto}_signature > /dev/null && [[ $query = signed ]] ); then
return 0
fi
done

View file

@ -2,7 +2,7 @@
#
# lint_config.sh - functions for checking for makepkg.conf errors
#
# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2018-2020 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

View file

@ -0,0 +1,45 @@
#!/usr/bin/bash
#
# ext.sh - Check that source/package extensions have valid prefixes
#
# Copyright (c) 2019-2020 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_LINT_CONFIG_EXT_SH" ]] && return
LIBMAKEPKG_LINT_CONFIG_EXT_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
lint_config_functions+=('lint_ext')
lint_ext() {
local i var val ret=0
for i in 'SRCEXT/.src.tar' 'PKGEXT/.pkg.tar'; do
IFS='/' read -r var val < <(printf '%s\n' "$i")
if [[ ${!var} != ${val}* ]]; then
error "$(gettext "%s does not contain a valid package suffix (needs '%s', got '%s')")" \
"\$${var}" "${val}*" "${!var}"
ret=1
fi
done
return $ret
}

View file

@ -2,7 +2,7 @@
#
# paths.sh - Check that pathname components do not contain odd characters
#
# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2018-2020 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

View file

@ -0,0 +1,37 @@
#!/usr/bin/bash
#
# source_date_epoch.sh - Check that reproducible builds timestamp is valid
#
# Copyright (c) 2018-2020 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_LINT_CONFIG_SOURCE_DATE_EPOCH_SH ]] && return
LIBMAKEPKG_LINT_CONFIG_SOURCE_DATE_EPOCH_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
lint_config_functions+=('lint_source_date_epoch')
lint_source_date_epoch() {
if [[ $SOURCE_DATE_EPOCH = *[^[:digit:]]* ]]; then
error "$(gettext "%s contains invalid characters: %s")" \
"\$SOURCE_DATE_EPOCH" "${SOURCE_DATE_EPOCH//[[:digit:]]}"
return 1
fi
}

View file

@ -2,7 +2,7 @@
#
# variable.sh - Check that variables are or are not arrays as appropriate
#
# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2018-2020 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
@ -32,10 +32,10 @@ lint_config_variables() {
local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS
DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ
COMPRESSLRZ COMPRESSLZO COMPRESSZ)
local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS DEBUG_CFLAGS
DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED
STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY
PKGEXT SRCEXT)
local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS DEBUG_CFLAGS
DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES
STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER
GPGKEY PKGEXT SRCEXT)
local i keys ret=0
@ -60,5 +60,11 @@ lint_config_variables() {
fi
done
# pacman should be able to extract an email address from PACKAGER for WKD key lookup
local match='^([^<>]+ )?<[^<>]*>$'
if ! [[ $PACKAGER == "Unknown Packager" || $PACKAGER =~ $match ]]; then
warning "$(gettext "PACKAGER should have the format 'Example Name <email@address.invalid>'")"
fi
return $ret
}

View file

@ -2,7 +2,7 @@
#
# lint_package.sh - functions for checking for packaging errors
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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

View file

@ -2,7 +2,7 @@
#
# build_references.sh - Warn about files containing references to build directories
#
# Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2013-2020 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

View file

@ -2,7 +2,7 @@
#
# dotfiles.sh - check for dotfiles in the package root
#
# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2016-2020 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

View file

@ -2,7 +2,7 @@
#
# file_names.sh - check package file names
#
# Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2016-2020 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

View file

@ -2,7 +2,7 @@
#
# missing_backup.sh - Warn about missing files in the backup array
#
# Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2013-2020 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

View file

@ -2,7 +2,7 @@
#
# lint_pkgbuild.sh - functions for detecting PKGBUILD errors
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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

View file

@ -2,7 +2,7 @@
#
# arch.sh - Check the 'arch' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -33,8 +33,13 @@ lint_pkgbuild_functions+=('lint_arch')
lint_arch() {
local a name list ret=0
if [[ $arch == 'any' ]]; then
return 0
if in_array "any" "${arch[@]}"; then
if (( ${#arch[@]} == 1 )); then
return 0;
else
error "$(gettext "Can not use '%s' architecture with other architectures")" "any"
return 1;
fi
fi
for a in "${arch[@]}"; do

View file

@ -0,0 +1,82 @@
#!/usr/bin/bash
#
# arch_specific.sh - Check that arch specific variables can be arch specific.
#
# Copyright (c) 2014-2020 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_LINT_PKGBUILD_ARCH_SPECIFIC_SH" ]] && return
LIBMAKEPKG_LINT_PKGBUILD_ARCH_SPECIFIC_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
source "$LIBRARY/util/util.sh"
lint_pkgbuild_functions+=('lint_arch_specific')
lint_arch_specific() {
local i a pkg ret=0
# global variables
for a in ${arch[@]}; do
if [[ $a == "any" ]]; then
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if declare -p "${i}_${a}" > /dev/null 2>&1; then
error "$(gettext "Can not provide architecture specific variables for the '%s' architecture: %s")" "any" "${i}_${a}"
ret=1
fi
done
fi
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_arch_arrays[@]} && continue
v="${i}_${a}"
if declare -p "$v" > /dev/null 2>&1; then
error "$(gettext "%s can not be architecture specific: %s")" "$i" "${i}_${a}"
ret=1
fi
done
done
# package function variables
for pkg in ${pkgname[@]}; do
for a in ${arch[@]}; do
if [[ $a == "any" ]]; then
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if exists_function_variable "package_$pkg" "${i}_${a}"; then
error "$(gettext "Can not provide architecture specific variables for the '%s' architecture: %s")" "any" "${i}_${a}"
ret=1
fi
done
fi
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_arch_arrays[@]} && continue
if exists_function_variable "package_$pkg" "${i}_${a}"; then
error "$(gettext "%s can not be architecture specific: %s")" "$i" "${i}_${a}"
ret=1
fi
done
done
done
return $ret
}

View file

@ -2,7 +2,7 @@
#
# backup.sh - Check the 'backup' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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

View file

@ -2,7 +2,7 @@
#
# changelog.sh - Check the files in the 'changelog' array exist.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -32,11 +32,15 @@ lint_pkgbuild_functions+=('lint_changelog')
lint_changelog() {
local name file changelog_list
local file changelog_list
changelog_list=("${changelog[@]}")
for name in "${pkgname[@]}"; do
if extract_function_variable "package_$name" changelog 0 file; then
# set pkgname the same way we do for running package(), this way we get
# the right value in extract_function_variable
local pkgname_backup=(${pkgname[@]})
local pkgname
for pkgname in "${pkgname_backup[@]}"; do
if extract_function_variable "package_$pkgname" changelog 0 file; then
changelog_list+=("$file")
fi
done

View file

@ -2,7 +2,7 @@
#
# checkdepends.sh - Check the 'checkdepends' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@ -43,12 +43,10 @@ lint_checkdepends() {
for checkdepend in "${checkdepends_list[@]}"; do
name=${checkdepend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${checkdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname checkdepends "$name" || ret=1
if [[ $ver != $checkdepend ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" checkdepends || ret=1
if [[ $name != "$checkdepend" ]]; then
ver=${checkdepend##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" checkdepends || ret=1
fi
done

View file

@ -2,7 +2,7 @@
#
# conflicts.sh - Check the 'conflicts' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@ -43,12 +43,10 @@ lint_conflicts() {
for conflict in "${conflicts_list[@]}"; do
name=${conflict%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${conflict##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname conflicts "$name" || ret=1
if [[ $ver != $conflict ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" conflicts || ret=1
if [[ $name != "$conflict" ]]; then
ver=${conflict##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" conflicts || ret=1
fi
done

View file

@ -2,7 +2,7 @@
#
# depends.sh - Check the 'depends' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@ -43,13 +43,13 @@ lint_depends() {
for depend in "${depends_list[@]}"; do
name=${depend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${depend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname depends "$name" || ret=1
# Don't validate empty version because of https://bugs.archlinux.org/task/58776
if [[ $ver != $depend && -n $ver ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" depends || ret=1
if [[ $name != "$depend" ]]; then
ver=${depend##$name@(<|>|=|>=|<=)}
# Don't validate empty version because of https://bugs.archlinux.org/task/58776
if [[ -n $ver ]]; then
check_fullpkgver "$ver" depends || ret=1
fi
fi
done

View file

@ -2,7 +2,7 @@
#
# epoch.sh - Check the 'epoch' variable conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -29,9 +29,15 @@ source "$LIBRARY/util/message.sh"
lint_pkgbuild_functions+=('lint_epoch')
lint_epoch() {
check_epoch() {
local epoch=$1 type=$2
if [[ $epoch != *([[:digit:]]) ]]; then
error "$(gettext "%s must be an integer, not %s.")" "epoch" "$epoch"
error "$(gettext "%s must be an integer, not %s.")" "epoch${type:+ in $type}" "$epoch"
return 1
fi
}
lint_epoch() {
check_epoch "$epoch"
}

View file

@ -0,0 +1,58 @@
#!/usr/bin/bash
#
# fullpkgver.sh - Check whether a full version conforms to requirements.
#
# Copyright (c) 2018-2020 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_LINT_PKGBUILD_FULLPKGVER_SH" ]] && return
LIBMAKEPKG_LINT_PKGBUILD_FULLPKGVER_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/epoch.sh"
source "$LIBRARY/lint_pkgbuild/pkgrel.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
check_fullpkgver() {
local fullver=$1 type=$2
local ret=0
# If there are multiple colons or multiple hyphens, there's a
# question of how we split it--it's invalid either way, but it
# will affect error messages. Let's mimic version.c:parseEVR().
if [[ $fullver = *:* ]]; then
# split at the *first* colon
check_epoch "${fullver%%:*}" "$type" || ret=1
fullver=${fullver#*:}
fi
# Since ver isn't allowed to be empty, don't let rel strip it
# down to nothing. Given "-XXX", "pkgver isn't allowed to
# contain hyphens" is more helpful than "pkgver isn't allowed
# to be empty".
if [[ $fullver = ?*-* ]]; then
# split at the *last* hyphen
check_pkgrel "${fullver##*-}" "$type" || ret=1
fullver=${fullver%-*}
fi
check_pkgver "$fullver" "$type" || ret=1
return $ret
}

View file

@ -2,7 +2,7 @@
#
# install.sh - Check the files in the 'install' array exist.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -32,11 +32,15 @@ lint_pkgbuild_functions+=('lint_install')
lint_install() {
local list file name install_list ret=0
local list file install_list ret=0
install_list=("${install[@]}")
for name in "${pkgname[@]}"; do
extract_function_variable "package_$name" install 0 file
# set pkgname the same way we do for running package(), this way we get
# the right value in extract_function_variable
local pkgname_backup=(${pkgname[@]})
local pkgname
for pkgname in "${pkgname_backup[@]}"; do
extract_function_variable "package_$pkgname" install 0 file
install_list+=("$file")
done

View file

@ -2,7 +2,7 @@
#
# makedepends.sh - Check the 'makedepends' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@ -43,12 +43,10 @@ lint_makedepends() {
for makedepend in "${makedepends_list[@]}"; do
name=${makedepend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${makedepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname makedepends "$name" || ret=1
if [[ $ver != $makedepend ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" makedepends || ret=1
if [[ $name != "$makedepend" ]]; then
ver=${makedepend##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" makedepends || ret=1
fi
done

View file

@ -2,7 +2,7 @@
#
# optdepends.sh - Check the 'optdepends' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -23,6 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@ -41,12 +43,10 @@ lint_optdepends() {
for optdepend in "${optdepends_list[@]%%:[[:space:]]*}"; do
name=${optdepend%%@(<|>|=|>=|<=)*}
# remove optional epoch in version specifier
ver=${optdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
lint_one_pkgname optdepends "$name" || ret=1
if [[ $ver != $optdepend ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" optdepends || ret=1
if [[ $name != "$optdepend" ]]; then
ver=${optdepend##$name@(<|>|=|>=|<=)}
check_fullpkgver "$ver" optdepends || ret=1
fi
done

View file

@ -2,7 +2,7 @@
#
# options.sh - Check the 'options' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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

View file

@ -2,7 +2,7 @@
#
# package_function.sh - Check that required package functions exist.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -34,11 +34,18 @@ lint_package_function() {
local i ret=0
if (( ${#pkgname[@]} == 1 )); then
if have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
if have_function 'package' && have_function "package_$pkgname"; then
error "$(gettext "Conflicting %s and %s functions in %s")" "package()" "package_$pkgname()" "$BUILDFILE"
ret=1
elif have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
ret=1
fi
else
if have_function "package"; then
error "$(gettext "Extra %s function for split package '%s'")" "package()" "$pkgbase"
ret=1
fi
for i in "${pkgname[@]}"; do
if ! have_function "package_$i"; then
error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"

View file

@ -0,0 +1,62 @@
#!/usr/bin/bash
#
# package_function_variable.sh - Check variables inside the package function.
#
# Copyright (c) 2014-2020 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_LINT_PKGBUILD_PACKAGE_FUNCTION_VARIABLE_SH" ]] && return
LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_VARIABLE_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
source "$LIBRARY/util/util.sh"
lint_pkgbuild_functions+=('lint_package_function_variable')
lint_package_function_variable() {
local i a pkg ret=0
# package function variables
for pkg in ${pkgname[@]}; do
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_package_overrides[@]} && continue
if exists_function_variable "package_$pkg" "${i}_${a}"; then
error "$(gettext "%s can not be set inside a package function")" "${i}_${a}"
ret=1
fi
done
done
for i in ${pkgbuild_schema_arrays[@]} ${pkgbuild_schema_strings[@]}; do
in_array "$i" ${pkgbuild_schema_package_overrides[@]} && continue
if exists_function_variable "package_$pkg" "$i"; then
error "$(gettext "%s can not be set inside a package function")" "$i"
ret=1
fi
done
done
return $ret
}

View file

@ -2,7 +2,7 @@
#
# pkgbase.sh - Check the 'pkgbase' variable conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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

View file

@ -2,7 +2,7 @@
#
# pkglist.sh - Check the packages selected to build exist.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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

View file

@ -2,7 +2,7 @@
#
# pkgname.sh - Check the 'pkgname' variable conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -45,6 +45,10 @@ lint_one_pkgname() {
error "$(gettext "%s is not allowed to start with a dot.")" "$type"
ret=1
fi
if [[ $name = *[![:ascii:]]* ]]; then
error "$(gettext "%s may only contain ascii characters.")" "$type"
return 1
fi
if [[ $name = *[^[:alnum:]+_.@-]* ]]; then
error "$(gettext "%s contains invalid characters: '%s'")" \
"$type" "${name//[[:alnum:]+_.@-]}"

View file

@ -2,7 +2,7 @@
#
# pkgrel.sh - Check the 'pkgrel' variable conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -29,14 +29,19 @@ source "$LIBRARY/util/message.sh"
lint_pkgbuild_functions+=('lint_pkgrel')
lint_pkgrel() {
if [[ -z $pkgrel ]]; then
error "$(gettext "%s is not allowed to be empty.")" "pkgrel"
check_pkgrel() {
local rel=$1 type=$2
if [[ -z $rel ]]; then
error "$(gettext "%s is not allowed to be empty.")" "pkgrel${type:+ in $type}"
return 1
fi
if [[ $pkgrel != +([0-9])?(.+([0-9])) ]]; then
error "$(gettext "%s must be a decimal, not %s.")" "pkgrel" "$pkgrel"
if [[ $rel != +([0-9])?(.+([0-9])) ]]; then
error "$(gettext "%s must be of the form 'integer[.integer]', not %s.")" "pkgrel${type:+ in $type}" "$rel"
return 1
fi
}
lint_pkgrel() {
check_pkgrel "$pkgrel"
}

View file

@ -2,7 +2,7 @@
#
# pkgver.sh - Check the 'pkgver' variable conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -41,13 +41,13 @@ check_pkgver() {
error "$(gettext "%s is not allowed to contain colons, forward slashes, hyphens or whitespace.")" "pkgver${type:+ in $type}"
return 1
fi
if [[ $ver = *[![:ascii:]]* ]]; then
error "$(gettext "%s may only contain ascii characters.")" "pkgver${type:+ in $type}"
return 1
fi
}
lint_pkgver() {
if (( PKGVERFUNC )); then
# defer check to after getting version from pkgver function
return 0
fi
check_pkgver "$pkgver"
}

View file

@ -2,7 +2,7 @@
#
# provides.sh - Check the 'provides' array conforms to requirements.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
source "$LIBRARY/lint_pkgbuild/pkgname.sh"
source "$LIBRARY/lint_pkgbuild/pkgver.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
@ -48,12 +48,10 @@ lint_provides() {
continue
fi
name=${provide%=*}
# remove optional epoch in version specifier
ver=${provide##$name=?(+([0-9]):)}
lint_one_pkgname provides "$name" || ret=1
if [[ $ver != $provide ]]; then
# remove optional pkgrel in version specifier
check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" provides || ret=1
if [[ $name != "$provide" ]]; then
ver=${provide##$name=}
check_fullpkgver "$ver" provides || ret=1
fi
done

View file

@ -2,7 +2,7 @@
#
# source.sh - Check the 'source' array is not sparse.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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

View file

@ -2,7 +2,7 @@
#
# util.sh - utility functions for pkgbuild linting.
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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

View file

@ -2,7 +2,7 @@
#
# variable.sh - Check that variables are or are not arrays as appropriate
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -25,25 +25,17 @@ LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
lint_pkgbuild_functions+=('lint_variable')
lint_variable() {
# TODO: refactor - similar arrays are used elsewhere
local array=(arch backup checkdepends groups license noextract options
validpgpkeys)
local arch_array=(conflicts depends makedepends md5sums optdepends provides
replaces sha1sums sha224sums sha256sums sha384sums sha512sums
source)
local string=(changelog epoch install pkgdesc pkgrel pkgver url)
local i a v pkg keys out bad ret=0
local i a pkg out bad ret=0
# global variables
for i in ${array[@]} ${arch_array[@]}; do
eval "keys=(\"\${!$i[@]}\")"
if (( ${#keys[*]} > 0 )); then
for i in ${pkgbuild_schema_arrays[@]}; do
if declare -p $i > /dev/null 2>&1; then
if ! is_array $i; then
error "$(gettext "%s should be an array")" "$i"
ret=1
@ -54,21 +46,18 @@ lint_variable() {
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${arch_array[@]}; do
v="${i}_${a}"
eval "keys=(\"\${!${v}[@]}\")"
if (( ${#keys[*]} > 0 )); then
if ! is_array $v; then
error "$(gettext "%s_%s should be an array")" "$i" "$a"
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if declare -p "${i}_${a}" > /dev/null 2>&1; then
if ! is_array ${i}_${a}; then
error "$(gettext "%s should be an array")" "${i}_${a}"
ret=1
fi
fi
done
done
for i in ${string[@]}; do
eval "keys=(\"\${!$i[@]}\")"
if (( ${#keys[*]} > 0 )); then
for i in ${pkgbuild_schema_strings[@]}; do
if declare -p "$i" > /dev/null 2>&1; then
if is_array $i; then
error "$(gettext "%s should not be an array")" "$i"
ret=1
@ -78,7 +67,7 @@ lint_variable() {
# package function variables
for pkg in ${pkgname[@]}; do
for i in ${array[@]} ${arch_array[@]}; do
for i in ${pkgbuild_schema_arrays[@]}; do
if extract_function_variable "package_$pkg" $i 0 out; then
error "$(gettext "%s should be an array")" "$i"
ret=1
@ -88,15 +77,15 @@ lint_variable() {
for a in ${arch[@]}; do
[[ $a == "any" ]] && continue
for i in ${arch_array[@]}; do
for i in ${pkgbuild_schema_arch_arrays[@]}; do
if extract_function_variable "package_$pkg" "${i}_${a}" 0 out; then
error "$(gettext "%s_%s should be an array")" "$i" "$a"
error "$(gettext "%s should be an array")" "${i}_${a}"
ret=1
fi
done
done
for i in ${string[@]}; do
for i in ${pkgbuild_schema_strings[@]}; do
if extract_function_variable "package_$pkg" $i 1 out; then
error "$(gettext "%s should not be an array")" "$i"
ret=1

View file

@ -2,7 +2,7 @@
#
# source.sh - functions for downloading and extracting sources
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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
@ -59,26 +59,11 @@ download_sources() {
pushd "$SRCDEST" &>/dev/null
local proto=$(get_protocol "$netfile")
case "$proto" in
local)
download_local "$netfile"
;;
bzr*)
(( get_vcs )) && download_bzr "$netfile"
;;
git*)
(( get_vcs )) && download_git "$netfile"
;;
hg*)
(( get_vcs )) && download_hg "$netfile"
;;
svn*)
(( get_vcs )) && download_svn "$netfile"
;;
*)
download_file "$netfile"
;;
esac
if declare -f download_$proto > /dev/null; then
download_$proto "$netfile"
else
download_file "$netfile"
fi
popd &>/dev/null
done
@ -90,24 +75,11 @@ extract_sources() {
get_all_sources_for_arch 'all_sources'
for netfile in "${all_sources[@]}"; do
local file=$(get_filename "$netfile")
local proto=$(get_protocol "$netfile")
case "$proto" in
bzr*)
extract_bzr "$netfile"
;;
git*)
extract_git "$netfile"
;;
hg*)
extract_hg "$netfile"
;;
svn*)
extract_svn "$netfile"
;;
*)
extract_file "$file"
;;
esac
if declare -f extract_$proto > /dev/null; then
extract_$proto "$netfile"
else
extract_file "$netfile"
fi
done
}

View file

@ -2,7 +2,7 @@
#
# bzr.sh - function for handling the download and "extraction" of Bazaar sources
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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
@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_bzr() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local url=$(get_url "$netfile")
@ -47,7 +52,7 @@ download_bzr() {
msg2 "$(gettext "Branching %s...")" "${displaylocation}"
if ! bzr branch "$url" "$dir" --no-tree --use-existing-dir; then
error "$(gettext "Failure while branching %s")" "${displaylocation}"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
elif (( ! HOLDVER )); then
@ -78,7 +83,7 @@ extract_bzr() {
;;
*)
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
esac
fi
@ -93,12 +98,12 @@ extract_bzr() {
cd_safe "${dir##*/}"
if ! (bzr pull "$dir" -q --overwrite -r "$rev" && bzr clean-tree -q --detritus --force); then
error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "bzr"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
elif ! bzr checkout "$dir" -r "$rev"; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "bzr"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi

View file

@ -2,7 +2,7 @@
#
# file.sh - function for handling the download and extraction of source files
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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
@ -42,7 +42,7 @@ download_file() {
# find the client we should use for this URL
local -a cmdline
IFS=' ' read -a cmdline < <(get_downloadclient "$proto")
(( ${#cmdline[@]} )) || exit
wait $! || exit
local filename=$(get_filename "$netfile")
local url=$(get_url "$netfile")
@ -72,7 +72,7 @@ download_file() {
if ! command -- "${cmdline[@]}" >&2; then
[[ ! -s $dlfile ]] && rm -f -- "$dlfile"
error "$(gettext "Failure while downloading %s")" "$url"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
@ -83,8 +83,9 @@ download_file() {
}
extract_file() {
local file=$1
local netfile=$1
local file=$(get_filename "$netfile")
local filepath=$(get_filepath "$file")
rm -f "$srcdir/${file}"
ln -s "$filepath" "$srcdir/"
@ -96,13 +97,13 @@ extract_file() {
fi
# do not rely on extension for file type
local file_type=$(file -bizL -- "$file")
local file_type=$(file -S -bizL -- "$file")
local ext=${file##*.}
local cmd=''
case "$file_type" in
*application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
cmd="bsdtar" ;;
*application/x-gzip*)
*application/x-gzip*|*application/gzip*)
case "$ext" in
gz|z|Z) cmd="gzip" ;;
*) return;;
@ -136,7 +137,7 @@ extract_file() {
fi
if (( ret )); then
error "$(gettext "Failed to extract %s")" "$file"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi

View file

@ -2,7 +2,7 @@
#
# git.sh - function for handling the download and "extraction" of Git sources
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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
@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_git() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local dir=$(get_filepath "$netfile")
@ -45,7 +50,7 @@ download_git() {
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
if ! git clone --mirror "$url" "$dir"; then
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
elif (( ! HOLDVER )); then
@ -53,7 +58,7 @@ download_git() {
# Make sure we are fetching the right repo
if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
@ -82,13 +87,13 @@ extract_git() {
cd_safe "${dir##*/}"
if ! git fetch; then
error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
cd_safe "$srcdir"
elif ! git clone "$dir" "${dir##*/}"; then
elif ! git clone -s "$dir" "${dir##*/}"; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
@ -105,24 +110,24 @@ extract_git() {
;;
*)
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
esac
fi
if [[ ${fragment%%=*} = tag ]]; then
tagname="$(git tag -l --format='%(tag)' "$ref")"
if [[ -n $tagname && $tagname != $ref ]]; then
if [[ -n $tagname && $tagname != "$ref" ]]; then
error "$(gettext "Failure while checking out version %s, the git tag has been forged")" "$ref"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
fi
if [[ $ref != "origin/HEAD" ]] || (( updating )) ; then
if ! git checkout --force --no-track -B makepkg $ref; then
if ! git checkout --force --no-track -B makepkg "$ref" --; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
fi

View file

@ -2,7 +2,7 @@
#
# hg.sh - function for handling the download and "extraction" of Mercurial sources
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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
@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_hg() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local dir=$(get_filepath "$netfile")
@ -44,7 +49,7 @@ download_hg() {
msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
if ! hg clone -U "$url" "$dir"; then
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
elif (( ! HOLDVER )); then
@ -74,7 +79,11 @@ extract_hg() {
msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
pushd "$srcdir" &>/dev/null
local ref=tip
local ref=default
# Is the repository configured to checkout some ref other than 'default'?
if hg identify -r @ "$dir" >/dev/null 2>&1; then
ref=@
fi
if [[ -n $fragment ]]; then
case ${fragment%%=*} in
branch|revision|tag)
@ -82,7 +91,7 @@ extract_hg() {
;;
*)
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
esac
fi
@ -91,12 +100,12 @@ extract_hg() {
cd_safe "${dir##*/}"
if ! (hg pull && hg update -C -r "$ref"); then
error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "hg"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
elif ! hg clone -u "$ref" "$dir" "${dir##*/}"; then
error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi

View file

@ -2,7 +2,7 @@
#
# local.sh - function for handling the "download" of local sources
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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

View file

@ -2,7 +2,7 @@
#
# svn.sh - function for handling the download and "extraction" of Subversion sources
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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
@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_svn() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local fragment=${netfile#*#}
@ -55,7 +60,7 @@ download_svn() {
;;
*)
error "$(gettext "Unrecognized reference: %s")" "${fragment}"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
esac
fi
@ -65,7 +70,7 @@ download_svn() {
mkdir -p "$dir/.makepkg"
if ! svn checkout -r ${ref} --config-dir "$dir/.makepkg" "$url" "$dir"; then
error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
elif (( ! HOLDVER )); then

View file

@ -2,7 +2,7 @@
#
# srcinfo.sh - functions for writing .SRCINFO files
#
# Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2014-2020 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
@ -24,6 +24,7 @@ LIBMAKEPKG_SRCINFO_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/pkgbuild.sh"
source "$LIBRARY/util/schema.sh"
srcinfo_open_section() {
printf '%s = %s\n' "$1" "$2"
@ -63,7 +64,7 @@ srcinfo_write_section_details() {
local attr package_arch a
local multivalued_arch_attrs=(source provides conflicts depends replaces
optdepends makedepends checkdepends
{md5,sha{1,224,256,384,512}}sums)
"${known_hash_algos[@]/%/sums}")
for attr in "${singlevalued[@]}"; do
pkgbuild_extract_to_srcinfo "$1" "$attr" 0
@ -89,7 +90,7 @@ srcinfo_write_global() {
local multivalued=(arch groups license checkdepends makedepends
depends optdepends provides conflicts replaces
noextract options backup
source validpgpkeys {md5,sha{1,224,256,384,512}}sums)
source validpgpkeys "${known_hash_algos[@]/%/sums}")
srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
srcinfo_write_section_details ''

View file

@ -3,7 +3,7 @@
# tidy.sh - functions for modifying/removing installed files before
# package creation
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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

View file

@ -2,7 +2,7 @@
#
# docs.sh - Remove documentation files from the package
#
# Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2008-2020 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

View file

@ -2,7 +2,7 @@
#
# emptydirs.sh - Remove empty directories from the package
#
# Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2013-2020 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

View file

@ -2,7 +2,7 @@
#
# libtool.sh - Remove libtool files from the package
#
# Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2013-2020 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

View file

@ -2,7 +2,7 @@
#
# purge.sh - Remove unwanted files from the package
#
# Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2008-2020 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

View file

@ -2,7 +2,7 @@
#
# staticlibs.sh - Remove static library files from the package
#
# Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2013-2020 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
@ -34,7 +34,7 @@ tidy_staticlibs() {
if check_option "staticlibs" "n"; then
msg2 "$(gettext "Removing static library files...")"
local l
while read -rd '' l; do
while IFS= read -rd '' l; do
if [[ -f "${l%.a}.dll.a" || -h "${l%.a}.dll.a" ]]; then
rm "$l"
fi

View file

@ -2,7 +2,7 @@
#
# strip.sh - Strip debugging symbols from binary files
#
# Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2007-2020 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
@ -33,7 +33,7 @@ tidy_modify+=('tidy_strip')
source_files() {
LANG=C readelf "$1" --debug-dump | \
awk '/DW_AT_name +:/{name=$8}/DW_AT_comp_dir +:/{{if (name !~ /^\//) {printf "%s/", $8}}{print name}}'
awk '/DW_AT_name +:/{name=$8}/DW_AT_comp_dir +:/{{if (name == "<artificial>") next}{if (name !~ /^[<\/]/) {printf "%s/", $8}}{print name}}'
}
strip_file() {
@ -47,11 +47,14 @@ strip_file() {
fi
# copy source files to debug directory
local f t
while read -r t; do
f=${t/${dbgsrcdir}/"$srcdir"}
mkdir -p "${dbgsrc/"$dbgsrcdir"/}${t%/*}"
cp -- "$f" "${dbgsrc/"$dbgsrcdir"/}$t"
local file dest t
while IFS= read -r t; do
file=${t/${dbgsrcdir}/"$srcdir"}
dest="${dbgsrc/"$dbgsrcdir"/}$t"
if ! [[ -f $dest ]]; then
mkdir -p "${dest%/*}"
cp -- "$file" "$dest"
fi
done < <(source_files "$binary")
# copy debug symbols to debug directory
@ -77,13 +80,13 @@ strip_file() {
# it's pointing), and its contents pass the CRC32 check
# create any needed hardlinks
while read -rd '' file ; do
while IFS= read -rd '' file ; do
if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
mkdir -p "$dbgdir/${file%/*}"
ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
fi
done < <(find . -type f -perm -u+w -print0 2>/dev/null)
fi
;;
esac
@ -114,7 +117,7 @@ tidy_strip() {
find * -type f ! -name '*.dll.a' ! -name '*.lib' \
-a \( -name '*.a' -o -name '*.dll' -o -name '*.exe' -o -name '*.so' -o -name '*.so.*' -o -name '*.oct' -o -name '*.cmxs' \) -print0 \
-o -type f -executable ! -name '*.dll' ! -name '*.exe' ! -name '*.so' ! -name '*.so.[0-9]*' ! -name '*.oct' ! -name '*.cmxs' ! -name '*.a' ! -name '*.la' ! -name '*.lib' ! -name '*.exe.manifest' ! -name '*.exe.config' ! -name '*.dll.config' ! -name '*.mdb' ! -name '*-config' ! -name '*.csh' ! -name '*.sh' ! -name '*.pl' ! -name '*.pm' ! -name '*.py' ! -name '*.rb' ! -name '*.tcl' -print0 | \
while read -d $'\0' binary
while IFS= read -d $'\0' binary
do
# Skip thin archives from stripping
case "${binary##*/}" in
@ -149,7 +152,7 @@ tidy_strip() {
%PAR\.pm%) continue ;;
Caml1999X0[0-9][0-9]) continue ;;
esac
# Mono assemblies must not be stripped, but remove .mdb debug symbols,
# and make them non-executable so they're not launched by MS .NET
if LC_ALL=C file -b "${binary}" 2>&1 | grep -q "Mono/\.Net assembly"
@ -158,7 +161,7 @@ tidy_strip() {
rm -f "${binary}.mdb"
continue
fi
# check for .exe from non-automake Makefile which install(1) didn't fix
# strip(1) used to take care of this, but not anymore
case ${CHOST} in
@ -175,8 +178,8 @@ tidy_strip() {
;;
esac
chmod 0755 "${binary}";
case "$(file -bi "$binary")" in
case "$(file -S -bi "$binary")" in
*application/x-dosexec*) # Windows executables and dlls
strip_flags="$STRIP_SHARED";;
*application/x-sharedlib*) # Libraries (.so)

View file

@ -2,7 +2,7 @@
#
# zipman.sh - Compress man and info pages
#
# Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2011-2020 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
@ -35,12 +35,12 @@ tidy_zipman() {
msg2 "$(gettext "Compressing man and info pages...")"
local file files inode link
while read -rd ' ' inode; do
read file
find ${MAN_DIRS[@]} -type l 2>/dev/null |
while read -r link ; do
IFS= read -r file
find "${MAN_DIRS[@]}" -type l -print0 2>/dev/null |
while IFS= read -rd '' link ; do
if [[ "${file}" -ef "${link}" ]] ; then
rm -f "$link" "${link}.gz"
if [[ ${file%/*} = ${link%/*} ]]; then
if [[ ${file%/*} = "${link%/*}" ]]; then
ln -s -- "${file##*/}.gz" "${link}.gz"
else
ln -s -- "/${file}.gz" "${link}.gz"
@ -55,7 +55,7 @@ tidy_zipman() {
ln "${files[$inode]}.gz" "${file}.gz"
chmod 644 "${file}.gz"
fi
done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
done < <(find "${MAN_DIRS[@]}" -type f \! -name "*.gz" \! -name "*.bz2" \
-exec stat -c '%i %n' '{}' + 2>/dev/null)
fi
}

View file

@ -2,7 +2,7 @@
#
# util.sh - utility functions for makepkg
#
# Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2015-2020 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

View file

@ -2,7 +2,7 @@
#
# compress.sh - functions to compress archives in a uniform manner
#
# Copyright (c) 2017-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2017-2020 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
@ -29,18 +29,21 @@ source "$LIBRARY/util/message.sh"
# Wrapper around many stream compression formats, for use in the middle of a
# pipeline. A tar archive is passed on stdin and compressed to stdout.
compress_as() {
# $1: final archive filename extension for compression type detection
# $1: final archive filename extension for compression type detection
local filename="$1"
local ext=".tar${1##*.tar}"
case "$filename" in
*tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
*tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
*tar.xz) ${COMPRESSXZ[@]:-xz -c -z -T0 -} ;;
*tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
*tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
*tar.Z) ${COMPRESSZ[@]:-compress -c -f} ;;
*tar) cat ;;
case "$ext" in
*.tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
*.tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
*.tar.xz) ${COMPRESSXZ[@]:-xz -c -z -} ;;
*.tar.zst) ${COMPRESSZST[@]:-zstd -c -z -q -} ;;
*.tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
*.tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
*.tar.Z) ${COMPRESSZ[@]:-compress -c -f} ;;
*.tar.lz4) ${COMPRESSLZ4[@]:-lz4 -q} ;;
*.tar.lz) ${COMPRESSLZ[@]:-lzip -c -f} ;;
*.tar) cat ;;
*) warning "$(gettext "'%s' is not a valid archive extension.")" \
"$ext"; cat ;;
esac

View file

@ -0,0 +1,76 @@
#!/usr/bin/bash
#
# config.sh - functions for handling makepkg config files
#
# Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.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_UTIL_CONFIG_SH" ]] && return
LIBMAKEPKG_UTIL_CONFIG_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/error.sh"
source "$LIBRARY/util/message.sh"
source "$LIBRARY/util/util.sh"
# correctly source makepkg.conf, respecting user precedence and the system conf
source_makepkg_config() {
# $1: override system config file
local MAKEPKG_CONF=${1:-${MAKEPKG_CONF:-/etc/makepkg.conf}}
# Source the config file; fail if it is not found
if [[ -r $MAKEPKG_CONF ]]; then
source_safe "$MAKEPKG_CONF"
else
error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
plainerr "$(gettext "Aborting...")"
exit $E_CONFIG_ERROR
fi
# Source user-specific makepkg.conf overrides, but only if no override config
# file was specified
XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman"
if [[ $MAKEPKG_CONF = "/etc/makepkg.conf" ]]; then
if [[ -r $XDG_PACMAN_DIR/makepkg.conf ]]; then
source_safe "$XDG_PACMAN_DIR/makepkg.conf"
elif [[ -r $HOME/.makepkg.conf ]]; then
source_safe "$HOME/.makepkg.conf"
fi
fi
}
# load makepkg.conf by sourcing the configuration files, and preserving
# existing environment settings
load_makepkg_config() {
# $1: override system config file
local MAKEPKG_CONF=${1:-${MAKEPKG_CONF:-/etc/makepkg.conf}}
# preserve environment variables to override makepkg.conf
local restore_envvars=$(
for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH; do
# the output of 'declare -p' results in locally scoped values when used within a function
[[ -v $var ]] && printf '%s=%s\n' "$var" "${!var@Q}"
done
)
source_makepkg_config "$MAKEPKG_CONF"
eval "$restore_envvars"
}

View file

@ -0,0 +1,41 @@
#!/usr/bin/bash
#
# dirsize.sh - calculate size of all files in a directory
#
# Copyright (c) 2019-2020 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_UTIL_DIRSIZE_SH" ]] && return
LIBMAKEPKG_UTIL_DIRSIZE_SH=1
# find the total filesize of all files in the current directory while only
# counting multiply hardlinked files once
dirsize() {
local file inode
declare -A files
{
find . -type f -links 1 -exec cat {} + 2>/dev/null
while read -rd ' ' inode; do
IFS= read -r file
if [[ -z ${files[$inode]} ]]; then
files[$inode]=found
cat "$file"
fi
done < <(find . -type f -links +1 -exec stat -c '%i %n' {} + 2>/dev/null)
} | wc -c
}

View file

@ -2,7 +2,7 @@
#
# error.sh.in - error variable definitions for makepkg
#
# Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
#
# This program is free software; you can redistribute it and/or modify

View file

@ -2,7 +2,7 @@
#
# message.sh - functions for outputting messages in makepkg
#
# Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
#
# This program is free software; you can redistribute it and/or modify
@ -43,19 +43,35 @@ colorize() {
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
}
# plainerr/plainerr are primarily used to continue a previous message on a new
# line, depending on whether the first line is a regular message or an error
# output
plain() {
(( QUIET )) && return
local mesg=$1; shift
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
plainerr() {
plain "$@" >&2
}
msg() {
(( QUIET )) && return
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
msg2() {
(( QUIET )) && return
local mesg=$1; shift
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
ask() {
local mesg=$1; shift
printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@"
}
warning() {

View file

@ -2,7 +2,7 @@
#
# option.sh - functions to test if build/packaging options are enabled
#
# Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2009-2020 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
@ -48,6 +48,30 @@ in_opt_array() {
}
##
# usage : check_opt_array( $option, $expected_val, $haystack )
# return : 0 - matches expected
# 1 - does not match expected
# 127 - not found
##
check_opt_array() {
local option=$1 expected=$2; shift 2
in_opt_array "$option" "$@"
case $? in
0) # assert enabled
[[ $expected = y ]]
return ;;
1) # assert disabled
[[ $expected = n ]]
return ;;
esac
# not found
return 127
}
##
# Checks to see if options are present in makepkg.conf or PKGBUILD;
# PKGBUILD options always take precedence.
@ -58,29 +82,7 @@ in_opt_array() {
# 127 - not found
##
check_option() {
in_opt_array "$1" ${options[@]}
case $? in
0) # assert enabled
[[ $2 = y ]]
return ;;
1) # assert disabled
[[ $2 = n ]]
return
esac
# fall back to makepkg.conf options
in_opt_array "$1" ${OPTIONS[@]}
case $? in
0) # assert enabled
[[ $2 = y ]]
return ;;
1) # assert disabled
[[ $2 = n ]]
return
esac
# not found
return 127
check_opt_array "$@" "${OPTIONS[@]}" "${options[@]}"
}
@ -93,20 +95,10 @@ check_option() {
# 127 - not found
##
check_buildenv() {
in_opt_array "$1" ${BUILDENV[@]}
case $? in
0) # assert enabled
[[ $2 = "y" ]]
return ;;
1) # assert disabled
[[ $2 = "n" ]]
return ;;
esac
# not found
return 127
check_opt_array "$@" "${BUILDENV[@]}"
}
##
# Checks to see if options are present in BUILDENV or PKGBUILD;
# PKGBUILD options always take precedence.
@ -117,26 +109,5 @@ check_buildenv() {
# 127 - not found
##
check_buildoption() {
in_opt_array "$1" ${options[@]}
case $? in
0) # assert enabled
[[ $2 = y ]]
return ;;
1) # assert disabled
[[ $2 = n ]]
return
esac
in_opt_array "$1" ${BUILDENV[@]}
case $? in
0) # assert enabled
[[ $2 = y ]]
return ;;
1) # assert disabled
[[ $2 = n ]]
return
esac
# not found
return 127
check_opt_array "$@" "${BUILDENV[@]}" "${options[@]}"
}

View file

@ -2,7 +2,7 @@
#
# parseopts.sh - getopt_long-like parser
#
# Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2012-2020 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

View file

@ -2,7 +2,7 @@
#
# pkgbuild.sh - functions to extract information from PKGBUILD files
#
# Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2009-2020 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
@ -21,6 +21,8 @@
[[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
LIBMAKEPKG_UTIL_PKGBUILD_SH=1
source "$LIBRARY/util/schema.sh"
have_function() {
declare -f "$1" >/dev/null
@ -36,7 +38,7 @@ array_build() {
# it's an error to try to copy a value which doesn't exist.
declare -p "$2" &>/dev/null || return 1
# Build an array of the indicies of the source array.
# Build an array of the indices of the source array.
eval "keys=(\"\${!$2[@]}\")"
# Clear the destination array
@ -60,7 +62,7 @@ extract_global_variable() {
if (( isarray )); then
array_build ref "$attr"
[[ ${ref[@]} ]] && array_build "$outputvar" "$attr"
(( ${#ref[@]} )) && array_build "$outputvar" "$attr"
else
[[ ${!attr} ]] && printf -v "$outputvar" %s "${!attr}"
fi
@ -98,6 +100,15 @@ extract_function_variable() {
return $r
}
exists_function_variable() {
# $1: function name
# $2: variable name
local funcname=$1 attr=$2 out
extract_function_variable "$funcname" "$attr" 0 out ||
extract_function_variable "$funcname" "$attr" 1 out
}
get_pkgbuild_attribute() {
# $1: package name
# $2: attribute name
@ -144,7 +155,7 @@ get_pkgbuild_all_split_attributes() {
done
done
[[ ${all_list[@]} ]] && array_build "$outputvar" all_list
(( ${#all_list[@]} )) && array_build "$outputvar" all_list
}
##

View file

@ -0,0 +1,49 @@
#!/usr/bin/bash
#
# schema.sh - declare specific groups of pkgbuild variables
#
# Copyright (c) 2015-2020 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_SCHEMA_SH" ]] && return
LIBMAKEPKG_SCHEMA_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/util.sh"
known_hash_algos=({md5,sha{1,224,256,384,512},b2})
pkgbuild_schema_arrays=(arch backup checkdepends conflicts depends groups
license makedepends noextract optdepends options
provides replaces source validpgpkeys
"${known_hash_algos[@]/%/sums}")
pkgbuild_schema_strings=(changelog epoch install pkgbase pkgdesc pkgrel pkgver
url)
pkgbuild_schema_arch_arrays=(checkdepends conflicts depends makedepends
optdepends provides replaces source
"${known_hash_algos[@]/%/sums}")
pkgbuild_schema_package_overrides=(pkgdesc arch url license groups depends
optdepends provides conflicts replaces
backup options install changelog)
readonly -a known_hash_algos pkgbuild_schema_arrays \
pkgbuild_schema_strings pkgbuild_schema_arch_arrays \
pkgbuild_schema_package_overrides

View file

@ -2,7 +2,7 @@
#
# source.sh - functions to extract information from source URLs
#
# Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2010-2020 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
@ -41,10 +41,12 @@ get_protocol() {
if [[ $1 = *://* ]]; then
# strip leading filename
local proto="${1#*::}"
printf "%s\n" "${proto%%://*}"
proto="${proto%%://*}"
# strip proto+uri://
printf "%s\n" "${proto%%+*}"
elif [[ $1 = *lp:* ]]; then
local proto="${1#*::}"
printf "%s\n" "${proto%%lp:*}"
printf "%s\n" "${proto%%+lp:*}"
else
printf "%s\n" local
fi
@ -63,15 +65,15 @@ get_filename() {
local proto=$(get_protocol "$netfile")
case $proto in
bzr*|git*|hg*|svn*)
bzr|git|hg|svn)
filename=${netfile%%#*}
filename=${filename%%\?*}
filename=${filename%/}
filename=${filename##*/}
if [[ $proto = bzr* ]]; then
if [[ $proto = bzr ]]; then
filename=${filename#*lp:}
fi
if [[ $proto = git* ]]; then
if [[ $proto = git ]]; then
filename=${filename%%.git*}
fi
;;
@ -89,7 +91,7 @@ get_filepath() {
local proto="$(get_protocol "$1")"
case $proto in
bzr*|git*|hg*|svn*)
bzr|git|hg|svn)
if [[ -d "$startdir/$file" ]]; then
file="$startdir/$file"
elif [[ -d "$SRCDEST/$file" ]]; then
@ -154,7 +156,7 @@ get_downloadclient() {
# if we didn't find an agent, return an error
if [[ -z $agent ]]; then
error "$(gettext "Unknown download protocol: %s")" "$proto"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1 # $E_CONFIG_ERROR
fi
@ -163,7 +165,7 @@ get_downloadclient() {
if [[ ! -x $program ]]; then
local baseprog="${program##*/}"
error "$(gettext "The download program %s is not installed.")" "$baseprog"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1 # $E_MISSING_PROGRAM
fi

View file

@ -2,7 +2,7 @@
#
# util.sh - general utility functions
#
# Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2006-2020 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
#
# This program is free software; you can redistribute it and/or modify
@ -22,6 +22,10 @@
[[ -n "$LIBMAKEPKG_UTIL_UTIL_SH" ]] && return
LIBMAKEPKG_UTIL_UTIL_SH=1
LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
source "$LIBRARY/util/error.sh"
source "$LIBRARY/util/message.sh"
##
# usage : in_array( $needle, $haystack )
@ -42,7 +46,7 @@ is_array() {
local v=$1
local ret=1
if [[ $(declare -p "$v") == declare\ -*([[:alnum:]])a*([[:alnum:]])\ * ]]; then
if [[ ${!v@a} = *a* ]]; then
ret=0
fi
@ -51,7 +55,7 @@ is_array() {
# Canonicalize a directory path if it exists
canonicalize_path() {
local path="$1";
local path="$1"
if [[ -d $path ]]; then
(
@ -74,7 +78,7 @@ dir_is_empty() {
cd_safe() {
if ! cd "$1"; then
error "$(gettext "Failed to change to directory %s")" "$1"
plain "$(gettext "Aborting...")"
plainerr "$(gettext "Aborting...")"
exit 1
fi
}
@ -95,3 +99,16 @@ ensure_writable_dir() {
return 0
}
# source a file and fail if it does not succeed
source_safe() {
local shellopts=$(shopt -p extglob)
shopt -u extglob
if ! source "$@"; then
error "$(gettext "Failed to source %s")" "$1"
exit $E_MISSING_FILE
fi
eval "$shellopts"
}

View file

@ -0,0 +1,34 @@
if [[ -n "$MSYSTEM" ]]; then
readonly -a UTILS_NAME=('bsdtar'
'bzip2'
'bzr'
'cat'
'ccache'
'distcc'
'git'
'gpg'
'gzip'
'hg'
'lzip'
'lzop'
'openssl'
'svn'
'tput'
'uncompress'
'xargs'
'xz'
'zstd'
)
for wrapper in ${UTILS_NAME[@]}; do
eval "
${wrapper}"'() {
local UTILS_PATH="/usr/bin/"
if ! type -p ${UTILS_PATH}${FUNCNAME[0]} >/dev/null; then
error "$(gettext "Cannot find the %s binary required for makepkg.")" "${UTILS_PATH}${FUNCNAME[0]}"
exit 1
fi
${UTILS_PATH}${FUNCNAME[0]} "$@"
}'
done
fi