summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 49692bdea96bba6662cf2074266ea7a1709902cb (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Maintainer: Yun Dou <dixyes@gmail.com>

_name=swow
_upstream=swow/swow
_branch=develop
pkgbase=php-swow-git
pkgname=('php-swow-git' 'php-legacy-swow-git')
pkgver=1.5.0.r3.gf4d8baf
pkgrel=1
pkgdesc="Swow coroutine IO extension for PHP, git \"${_branch}\" branch"
arch=('x86_64' 'arm64')
url="https://github.com/swow/swow"
license=('APACHE')
makedepends=('php' 'php-legacy' 'postgresql-libs')
depends=('glibc')
source=("${_name}-${_branch}::git+https://github.com/${_upstream}.git#branch=${_branch}")
sha512sums=('SKIP')

pkgver() {
    cd "$srcdir/${_name}-${_branch}"
    git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//g'
}

prepare() {

    echo -e "; the Swow extension requires curl to be activated first\n; and it's conflict with swoole\nextension=${_name}" > "${_name}-${_branch}/${_name}.ini"

    cp -av "${_name}-${_branch}" "${_name}-${_branch}-legacy"

    (
        cd "${_name}-${_branch}/ext"
        phpize
    )

    (
        cd "${_name}-${_branch}-legacy/ext"
        phpize-legacy
    )
}

build() {
    (
        cd "${_name}-${_branch}/ext"
        ./configure \
            --prefix=/usr \
            --enable-swow-ssl \
            --enable-swow-curl
        make
    )

    (
        cd "${_name}-${_branch}-legacy/ext"
        ./configure \
            --prefix=/usr \
            --enable-swow-ssl \
            --enable-swow-curl
        make
    )
}

check() {
    local EXTRA_PHPT_ARGS="-n --show-diff"
    (
        /usr/bin/php -d extension=${srcdir}/${_name}-${_branch}/ext/modules/swow.so --ri swow
        export TEST_PHP_EXECUTABLE=/usr/bin/php
        local TEST_PHP_ARGS="${EXTRA_PHPT_ARGS} -d extension=${srcdir}/${_name}-${_branch}/ext/modules/swow.so"
        cd "${_name}-${_branch}/ext"
        # since this is git, check may fail
        $TEST_PHP_EXECUTABLE run-tests.php $TEST_PHP_ARGS . || :
    )

    (
        /usr/bin/php-legacy -d extension=${srcdir}/${_name}-${_branch}-legacy/ext/modules/swow.so --ri swow
        export TEST_PHP_EXECUTABLE=/usr/bin/php-legacy
        local TEST_PHP_ARGS="${EXTRA_PHPT_ARGS} -d extension=${srcdir}/${_name}-${_branch}-legacy/ext/modules/swow.so"
        cd "${_name}-${_branch}-legacy/ext"
        # since this is git, check may fail
        $TEST_PHP_EXECUTABLE -n run-tests.php $TEST_PHP_ARGS . || :
    )
}

package_php-swow-git() {
    backup=("etc/php/conf.d/${_name}.ini")
    depends+=('php')
    provides+=('php-swow')
    conflicts+=('php-swow')

    cd "${_name}-${_branch}"
    make -C ext INSTALL_ROOT="$pkgdir/" install
    install -vDm 644 "${_name}.ini" -t "${pkgdir}/etc/php/conf.d/"
}

package_php-legacy-swow-git() {
    backup=("etc/php-legacy/conf.d/${_name}.ini")
    depends+=('php-legacy')
    provides+=('php-legacy-swow')
    conflicts+=('php-legacy-swow')

    cd "${_name}-${_branch}-legacy"
    make -C ext INSTALL_ROOT="$pkgdir/" install
    install -vDm 644 "${_name}.ini" -t "${pkgdir}/etc/php-legacy/conf.d/"
}