summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c31066fb6b0ee08db5f6d257f21542c504acca1c (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
# Maintainer: Kyle De'Vir (QuartzDragon) <kyle.devir.mykolab.com>

pkgname=bcachefs-tools-git
pkgver=v1.20.0.r1.g67c9b37
pkgrel=1
pkgdesc="BCacheFS filesystem utilities (Git)"
arch=('x86_64')
url="https://github.com/koverstreet/bcachefs-tools"
license=('GPL-2.0-only')

provides=(bcachefs-tools)
conflicts=(bcachefs-tools)
depends=(
  bash
  fuse3
  gcc-libs
  libaio.so libaio
  libblkid.so libuuid.so util-linux-libs
  libkeyutils.so keyutils
  libsodium.so libsodium
  liburcu
  libz.so zlib
  libzstd.so zstd
  lz4
  libudev.so systemd-libs
  udev
)
makedepends=(
  cargo
  clang
  llvm
  pkgconf
  valgrind
)

_reponame="bcachefs-tools"
_repo_url="https://github.com/koverstreet/$_reponame"

options=('!lto' '!strip')
source=("git+$_repo_url")
b2sums=('SKIP')

pkgver() {
    cd "$srcdir/$_reponame"
    git describe --long --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
    cd "$srcdir/$_reponame"

    # this uses malloc_usable_size, which is incompatible with fortification level 3
    export CFLAGS="${CFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
    export CXXFLAGS="${CXXFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"

    BCACHEFS_FUSE=1 make \
        LIBEXECDIR=/usr/lib \
        DESTDIR="${pkgdir}" \
        ROOT_SBINDIR="/usr/bin" \
        INITRAMFS_DIR="/usr/lib/initcpio/"
}

package() {
    cd "$srcdir/$_reponame"

    # this uses malloc_usable_size, which is incompatible with fortification level 3
    export CFLAGS="${CFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
    export CXXFLAGS="${CXXFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"

    BCACHEFS_FUSE=1 make \
        PREFIX="/usr" \
        LIBEXECDIR=/usr/lib \
        DESTDIR="${pkgdir}" \
        ROOT_SBINDIR="/usr/bin" \
        INITRAMFS_DIR="/usr/lib/initcpio/" \
        install

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

    # package completions
    install -dm755 "${pkgdir}"/usr/share/{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}
    "${pkgdir}"/usr/bin/bcachefs completions bash > "${pkgdir}"/usr/share/bash-completion/completions/bcachefs
    "${pkgdir}"/usr/bin/bcachefs completions fish > "${pkgdir}"/usr/share/fish/vendor_completions.d/bcachefs.fish
    "${pkgdir}"/usr/bin/bcachefs completions zsh > "${pkgdir}"/usr/share/zsh/site-functions/_bcachefs
}