Add `# shellcheck` directives to quiet shellcheck, add PKGBUILD.proto

The added PKGBUILD.proto file is so that shellcheck can know know what
to expect that a PKGBUILD sets.
This commit is contained in:
Luke Shumaker 2017-05-05 18:41:10 -04:00 committed by Jan Alexander Steffens (heftig)
parent a396a69081
commit a9dab95334
No known key found for this signature in database
GPG Key ID: A5E9288C4FA415FA
14 changed files with 88 additions and 1 deletions

View File

@ -114,7 +114,7 @@ dist:
upload: upload:
scp devtools-$(V).tar.gz devtools-$(V).tar.gz.sig repos.archlinux.org:/srv/ftp/other/devtools/ scp devtools-$(V).tar.gz devtools-$(V).tar.gz.sig repos.archlinux.org:/srv/ftp/other/devtools/
check: $(BINPROGS) bash_completion makepkg-x86_64.conf check: $(BINPROGS) bash_completion makepkg-x86_64.conf PKGBUILD.proto
shellcheck $^ shellcheck $^
.PHONY: all clean install uninstall dist upload check .PHONY: all clean install uninstall dist upload check

48
PKGBUILD.proto Normal file
View File

@ -0,0 +1,48 @@
#!/hint/bash
# shellcheck disable=2034
# This is an example PKGBUILD file, so that shellcheck can know what
# variables to expect be set after including a PKGBUILD.
# Maintainer: Your Name <youremail@domain.com>
pkgname=NAME
pkgver=VERSION
pkgrel=1
epoch=
pkgdesc=""
arch=()
url=""
license=('GPL')
groups=()
depends=()
makedepends=()
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=("$pkgname-$pkgver.tar.gz"
"$pkgname-$pkgver.patch")
noextract=()
md5sums=()
validpgpkeys=()
prepare() {
:
}
build() {
:
}
check() {
:
}
package() {
:
}

View File

@ -58,7 +58,9 @@ else
cache_dirs=("$cache_dir") cache_dirs=("$cache_dir")
fi fi
# shellcheck disable=2016
host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
# shellcheck disable=2016
[[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g') [[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
# {{{ functions # {{{ functions

View File

@ -7,6 +7,7 @@ m4_include(lib/common.sh)
# Source makepkg.conf; fail if it is not found # Source makepkg.conf; fail if it is not found
if [[ -r '/etc/makepkg.conf' ]]; then if [[ -r '/etc/makepkg.conf' ]]; then
# shellcheck source=makepkg-x86_64.conf
source '/etc/makepkg.conf' source '/etc/makepkg.conf'
else else
die '/etc/makepkg.conf not found!' die '/etc/makepkg.conf not found!'
@ -14,8 +15,10 @@ fi
# Source user-specific makepkg.conf overrides # Source user-specific makepkg.conf overrides
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
elif [[ -r "$HOME/.makepkg.conf" ]]; then elif [[ -r "$HOME/.makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "$HOME/.makepkg.conf" source "$HOME/.makepkg.conf"
fi fi
@ -23,6 +26,7 @@ if [[ ! -f PKGBUILD ]]; then
die 'This must be run in the directory of a built package.' die 'This must be run in the directory of a built package.'
fi fi
# shellcheck source=PKGBUILD.proto
. ./PKGBUILD . ./PKGBUILD
if [[ ${arch[0]} == 'any' ]]; then if [[ ${arch[0]} == 'any' ]]; then
CARCH='any' CARCH='any'

View File

@ -5,6 +5,7 @@ m4_include(lib/common.sh)
# Source makepkg.conf; fail if it is not found # Source makepkg.conf; fail if it is not found
if [[ -r '/etc/makepkg.conf' ]]; then if [[ -r '/etc/makepkg.conf' ]]; then
# shellcheck source=makepkg-x86_64.conf
source '/etc/makepkg.conf' source '/etc/makepkg.conf'
else else
die '/etc/makepkg.conf not found!' die '/etc/makepkg.conf not found!'
@ -12,8 +13,10 @@ fi
# Source user-specific makepkg.conf overrides # Source user-specific makepkg.conf overrides
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
elif [[ -r "$HOME/.makepkg.conf" ]]; then elif [[ -r "$HOME/.makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "$HOME/.makepkg.conf" source "$HOME/.makepkg.conf"
fi fi
@ -23,6 +26,8 @@ if [[ ! -f PKGBUILD ]]; then
die 'No PKGBUILD file' die 'No PKGBUILD file'
fi fi
source=()
# shellcheck source=PKGBUILD.proto
. ./PKGBUILD . ./PKGBUILD
pkgbase=${pkgbase:-$pkgname} pkgbase=${pkgbase:-$pkgname}

View File

@ -44,6 +44,7 @@ msg "Downloading sources for %s" "${pkgbase}"
svn -q checkout -N "${target_svn}" target_checkout svn -q checkout -N "${target_svn}" target_checkout
mkdir -p "target_checkout/${pkgbase}/repos" mkdir -p "target_checkout/${pkgbase}/repos"
svn -q export "${source_svn}/${pkgbase}/trunk" "target_checkout/${pkgbase}/trunk" || die svn -q export "${source_svn}/${pkgbase}/trunk" "target_checkout/${pkgbase}/trunk" || die
# shellcheck source=PKGBUILD.proto
. "target_checkout/${pkgbase}/trunk/PKGBUILD" . "target_checkout/${pkgbase}/trunk/PKGBUILD"
msg "Downloading packages for %s" "${pkgbase}" msg "Downloading packages for %s" "${pkgbase}"
@ -56,6 +57,7 @@ for _arch in "${arch[@]}"; do
for _pkgname in "${pkgname[@]}"; do for _pkgname in "${pkgname[@]}"; do
fullver=$(get_full_version "$_pkgname") fullver=$(get_full_version "$_pkgname")
pkgpath="/srv/ftp/$source_repo/os/$repo_arch/$_pkgname-$fullver-${_arch}.pkg.tar.*" pkgpath="/srv/ftp/$source_repo/os/$repo_arch/$_pkgname-$fullver-${_arch}.pkg.tar.*"
# shellcheck disable=2029
ssh "$server" "cp $pkgpath staging/$target_repo" || die ssh "$server" "cp $pkgpath staging/$target_repo" || die
done done
done done
@ -68,10 +70,12 @@ pushd "target_checkout/${pkgbase}/trunk" >/dev/null
archrelease "${arch[@]/#/$target_repo-}" || die archrelease "${arch[@]/#/$target_repo-}" || die
popd >/dev/null popd >/dev/null
# shellcheck disable=2029
ssh "${server}" "${target_dbscripts}/db-update" || die ssh "${server}" "${target_dbscripts}/db-update" || die
msg "Removing %s from %s" "${pkgbase}" "${source_repo}" msg "Removing %s from %s" "${pkgbase}" "${source_repo}"
for _arch in "${arch[@]}"; do for _arch in "${arch[@]}"; do
# shellcheck disable=2029
ssh "${server}" "${source_dbscripts}/db-remove ${source_repo} ${_arch} ${pkgbase}" ssh "${server}" "${source_dbscripts}/db-remove ${source_repo} ${_arch} ${pkgbase}"
done done
svn -q checkout -N "${source_svn}" source_checkout svn -q checkout -N "${source_svn}" source_checkout

View File

@ -20,6 +20,7 @@ fi
find . -type d | while read -r d; do find . -type d | while read -r d; do
if [[ -f "$d/PKGBUILD" ]]; then if [[ -f "$d/PKGBUILD" ]]; then
pkgname=() depends=() makedepends=() optdepends=() pkgname=() depends=() makedepends=() optdepends=()
# shellcheck source=PKGBUILD.proto
. "$d/PKGBUILD" . "$d/PKGBUILD"
for dep in "${depends[@]}"; do for dep in "${depends[@]}"; do
# lose the version comparator, if any # lose the version comparator, if any

View File

@ -1,6 +1,8 @@
#!/hint/bash #!/hint/bash
# License: Unspecified # License: Unspecified
:
# shellcheck disable=2034
CHROOT_VERSION='v4' CHROOT_VERSION='v4'
## ##

View File

@ -35,35 +35,42 @@ readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
plain() { plain() {
local mesg=$1; shift local mesg=$1; shift
# shellcheck disable=2059
printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
} }
msg() { msg() {
local mesg=$1; shift local mesg=$1; shift
# shellcheck disable=2059
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
} }
msg2() { msg2() {
local mesg=$1; shift local mesg=$1; shift
# shellcheck disable=2059
printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
} }
warning() { warning() {
local mesg=$1; shift local mesg=$1; shift
# shellcheck disable=2059
printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
} }
error() { error() {
local mesg=$1; shift local mesg=$1; shift
# shellcheck disable=2059
printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
} }
stat_busy() { stat_busy() {
local mesg=$1; shift local mesg=$1; shift
# shellcheck disable=2059
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2 printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}...${ALL_OFF}" "$@" >&2
} }
stat_done() { stat_done() {
# shellcheck disable=2059
printf "${BOLD}done${ALL_OFF}\n" >&2 printf "${BOLD}done${ALL_OFF}\n" >&2
} }

View File

@ -1,12 +1,15 @@
#!/hint/bash #!/hint/bash
# License: Unspecified # License: Unspecified
:
# shellcheck disable=2034
_arch=( _arch=(
i686 i686
x86_64 x86_64
any any
) )
# shellcheck disable=2034
_tags=( _tags=(
core-i686 core-x86_64 core-any core-i686 core-x86_64 core-any
extra-i686 extra-x86_64 extra-any extra-i686 extra-x86_64 extra-any

View File

@ -241,6 +241,7 @@ EOF
# These functions aren't run in makechrootpkg, # These functions aren't run in makechrootpkg,
# so no global variables # so no global variables
_chrootbuild() { _chrootbuild() {
# shellcheck source=/dev/null
. /etc/profile . /etc/profile
# Beware, there are some stupid arbitrary rules on how you can # Beware, there are some stupid arbitrary rules on how you can
# use "$" in arguments to commands with "sudo -i". ${foo} or # use "$" in arguments to commands with "sudo -i". ${foo} or

View File

@ -1,3 +1,6 @@
#!/hint/bash
# shellcheck disable=2034
# #
# /etc/makepkg.conf # /etc/makepkg.conf
# #

View File

@ -1,3 +1,6 @@
#!/hint/bash
# shellcheck disable=2034
# #
# /etc/makepkg.conf # /etc/makepkg.conf
# #

View File

@ -21,6 +21,7 @@ fi
# Source makepkg.conf; fail if it is not found # Source makepkg.conf; fail if it is not found
if [[ -r '/etc/makepkg.conf' ]]; then if [[ -r '/etc/makepkg.conf' ]]; then
# shellcheck source=makepkg-x86_64.conf
source '/etc/makepkg.conf' source '/etc/makepkg.conf'
else else
die '/etc/makepkg.conf not found!' die '/etc/makepkg.conf not found!'
@ -28,8 +29,10 @@ fi
# Source user-specific makepkg.conf overrides # Source user-specific makepkg.conf overrides
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf" source "${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf"
elif [[ -r "$HOME/.makepkg.conf" ]]; then elif [[ -r "$HOME/.makepkg.conf" ]]; then
# shellcheck source=/dev/null
source "$HOME/.makepkg.conf" source "$HOME/.makepkg.conf"
fi fi
@ -50,6 +53,7 @@ bump_pkgrel() {
pkg_from_pkgbuild() { pkg_from_pkgbuild() {
# we want the sourcing to be done in a subshell so we don't pollute our current namespace # we want the sourcing to be done in a subshell so we don't pollute our current namespace
export CARCH PKGEXT export CARCH PKGEXT
# shellcheck source=PKGBUILD.proto
(source PKGBUILD; echo "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT") (source PKGBUILD; echo "$pkgname-$pkgver-$pkgrel-$CARCH$PKGEXT")
} }