summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 655b4c5ed00432fa0ca284a7c125a17da69d5e4b (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Maintainer: neycrol <330578697@qq.com>
# Maintainer: Ivan Shapovalov <intelfx@intelfx.name>
# Contributor: Kyle De'Vir (QuartzDragon) <kyle.devir.33@proton.me>

pkgname=bcachefs-tools-git
pkgname=(bcachefs-tools-git bcachefs-dkms-git)
_pkgname=bcachefs-tools
# Keep epoch=1 to preserve upgrade ordering from the previous date-based
# VCS pkgver scheme used in AUR history.
epoch=1
pkgver=1.38.6.r38.g7f64e89
pkgrel=1
pkgdesc="Bcachefs userspace tools (Git version)"
arch=('x86_64')
url="https://github.com/koverstreet/bcachefs-tools"
license=('GPL-2.0-only')
depends=(
    'bash'
    'fuse3'
    'libaio.so' 'libaio'
    'libblkid.so' 'libuuid.so' 'util-linux-libs'
    'libgcc'
    'libkeyutils.so' 'keyutils'
    'libsodium.so' 'libsodium'
    'libunwind.so' 'libunwind'
    'liburcu'
    'libz.so' 'zlib'
    'libzstd.so' 'zstd'
    'lz4'
    'libudev.so' 'systemd-libs'
    'udev'
)
makedepends=(
    'git'
    'cargo'
    'clang'
    'jq'
    'llvm'
    'pkgconf'
    'rust-bindgen'
)

source=("git+https://github.com/koverstreet/bcachefs-tools.git")
sha256sums=('SKIP')

_common_make_args=(
    PREFIX=/usr
    ROOT_SBINDIR=/usr/bin
    LIBEXECDIR=/usr/lib
    INITRAMFS_DIR=/usr/lib/initcpio
    CARGO_ARGS=--locked
)

pkgver() {
    cd "$_pkgname"
    git describe --long --abbrev=7 --tags 2>/dev/null \
        | sed 's/^v//;s/[^-]*-g/r&/;s/-/./g' \
    || printf "r%s.g%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
    cd "$_pkgname"

    # Fetch Rust deps up front so build/package stages don't need to
    # download crates again when using --locked.
    cargo fetch --locked --target "$(rustc --print host-tuple)"

    # _Disable_ cross-toolchain LTO because we are using different toolchains
    # for C/C++ and Rust code (i.e., LLVM LTO is incompatible with GCC LTO).
    # In this project, C/C++ code is linked into Rust code. Therefore, apply
    # a workaround to force generation of normal object code on C side:
    CFLAGS+=" -ffat-lto-objects"
    CXXFLAGS+=" -ffat-lto-objects"
}

build() {
    cd "$_pkgname"
    local -a make_args=("${_common_make_args[@]}")

    make "${make_args[@]}" all
}

package_bcachefs-tools-git() {
    provides=("bcachefs-tools=${pkgver%%.r*}")
    conflicts=(bcachefs-tools)

    cd "$_pkgname"
    local -a make_args=("${_common_make_args[@]}" "DESTDIR=$pkgdir")

    # run install but not install_dkms
    make "${make_args[@]}" install -o install_dkms

    # replace incompatible initcpio hooks
    rm -rf "$pkgdir"/usr/lib/initcpio/*
    install -Dm644 arch/etc/initcpio/hooks/bcachefs -t "$pkgdir/usr/lib/initcpio/hooks"
    install -Dm644 arch/etc/initcpio/install/bcachefs -t "$pkgdir/usr/lib/initcpio/install"

    # Shell completions
    "$pkgdir/usr/bin/bcachefs" completions bash \
        | install -Dm644 /dev/stdin "$pkgdir/usr/share/bash-completion/completions/bcachefs"
    "$pkgdir/usr/bin/bcachefs" completions fish \
        | install -Dm644 /dev/stdin "$pkgdir/usr/share/fish/vendor_completions.d/bcachefs.fish"
    "$pkgdir/usr/bin/bcachefs" completions zsh \
        | install -Dm644 /dev/stdin "$pkgdir/usr/share/zsh/site-functions/_bcachefs"
}

package_bcachefs-dkms-git() {
    pkgdesc="Bcachefs out-of-tree module (Git version)"
    depends=(
        dkms
    )
    provides=("bcachefs-dkms=${pkgver%%.r*}")
    conflicts=(bcachefs-dkms)

    cd "$_pkgname"
    local -a make_args=("${_common_make_args[@]}" "DESTDIR=$pkgdir")

    make "${make_args[@]}" install_dkms
}