summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3a337574dd2a232ae17a42ec9a125589b2b04a58 (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
# Maintainer: Luis Martinez <luis dot martinez at disroot dot org>

pkgname=alist
pkgver=3.40.0
_web_pkgver=3.39.2
pkgrel=1
pkgdesc="File list program that supports multiple storage"
arch=('x86_64' 'i686' 'arm' 'armv6h' 'arm7vh' 'aarch64' 'riscv64' 'loong64')
url="https://github.com/alist-org/alist"
license=('AGPL-3.0-only')
depends=('glibc')
makedepends=('go')
backup=('etc/alist/config.json')
install=alist.install
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
    "dist-$pkgver.tar.gz::${url}-web/releases/download/${_web_pkgver}/dist.tar.gz"
    'alist.service'
    'alist.tmpfiles'
    'alist.sysusers'
    'config.json')
sha256sums=('350f6d0610cebb70c645e52a87aaf0e8cb5bb275593ee22778ed8348da48b005'
            'd998315aff5544e7d7248214d02a3b04a92366bf0ac50fb4791b23833e8b543a'
            '5712b21aebf669fe9fb5d47dd685809d4d9670b1bb1d5e6fef962b9d11ba9d72'
            'c6b62c4a750ab921c2e8f965e4baeee28855c9a969b00eddd346670f2fdf12de'
            '3658370660806f73c3d9bc5f1b6e2a013c9520d34ffc4462df99f7692473613d'
            'b72f194a7b8855e97eeb76e63e179f38132cc9e6be9daa5b396699c9c11611de')

prepare() {
    cd "${srcdir}/$pkgname-$pkgver"
    rm -rf public/dist
    mv -f "${srcdir}/dist" public
    mkdir -p build
}

build() {
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
    cd "$pkgname-$pkgver"
    go mod download
    ## i tried, doesn't actually tag properly
    go build -o build \
        -ldflags="-linkmode external -extldflags '${LDFLAGS}' \
		-X 'github.com/alist-org/alist/conf.GoVersion=$(go version | awk '{print $3}')' \
		-X 'github.com/alist-org/alist/conf.GitTag=$pkgver'"
}

package() {
    cd "$pkgname-$pkgver"
    install -Dv "build/$pkgname" -t "$pkgdir/usr/bin/"
    install -Dvm644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
    install -Dvm644 "${srcdir}/alist.service" -t "${pkgdir}/usr/lib/systemd/system/"
    install -Dvm644 "${srcdir}/config.json" -t "${pkgdir}/etc/${pkgname}"
    install -Dvm644 "${srcdir}/alist.sysusers" "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
    install -Dvm644 "${srcdir}/alist.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
}