blob: 244cfeab49e13c6e540cb110358c04a5bdc4420e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# Maintainer: Luke Arms <luke@arms.to>
pkgname=pretty-php
pkgver=0.4.26
pkgrel=1
pkgdesc="The opinionated PHP code formatter"
arch=('any')
license=('MIT')
url="https://github.com/lkrms/pretty-php"
depends=('php')
makedepends=('php-sodium' 'git' 'composer')
source=("${pkgname}::git+https://github.com/lkrms/pretty-php.git#tag=v${pkgver}")
sha256sums=('SKIP')
prepare() {
cd "${srcdir}/${pkgname}"
rm -rf build/dist
}
build() {
_check_sodium
cd "${srcdir}/${pkgname}"
scripts/build.sh "v${pkgver}"
}
check() {
cd "${srcdir}/${pkgname}"
local phar
phar=$(_phar)
echo "Checking output of \`$phar --version\`"
"$phar" --version | grep -F "pretty-php v${pkgver}-"
}
package() {
cd "${srcdir}/${pkgname}"
local phar
phar=$(_phar)
install -Dm755 "$phar" "${pkgdir}/usr/bin/pretty-php"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
_phar() {
local phar=(build/dist/*)
[[ ${#phar[@]} -eq 1 ]] && [[ -x $phar ]] || return
printf '%s\n' "$phar"
}
_check_sodium() {
if ! php -m | grep -Fx sodium >/dev/null; then
local dir=${srcdir}/php.ini.d
mkdir -p "$dir"
echo 'extension=sodium' >"$dir/sodium.ini"
# If PHP_INI_SCAN_DIR is already in the environment, honour it, empty or
# otherwise
if [[ -n ${PHP_INI_SCAN_DIR+1} ]]; then
export PHP_INI_SCAN_DIR=${PHP_INI_SCAN_DIR:+$PHP_INI_SCAN_DIR:}$dir
return
fi
export PHP_INI_SCAN_DIR=:$dir
fi
}
|