summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 349d9b6b04ef5cdc2f14d14423afb35863d7a44c (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
# Maintainer: Antony-hash512 <https://github.com/Antony-hash512>
pkgname=zero-kelvin
pkgver=0.3.0
pkgrel=3
pkgdesc="Cold storage utility for SquashFS-based data offloading with LUKS encryption support"
arch=('x86_64')
url="https://github.com/Antony-hash512/Zero-Kelvin"
license=('GPL3')
depends=(
    'glibc'
    'gcc-libs'
    'squashfs-tools'       # mksquashfs, unsquashfs
    'squashfs-tools-ng'    # tar2sqfs
    'squashfuse'           # FUSE mount without root
    'cryptsetup'           # LUKS encryption
    'rsync'                # File synchronization for unfreeze
    'util-linux'           # mount/umount, findmnt, lsblk
)
makedepends=('cargo' 'git')
checkdepends=('fish' 'bats')
optdepends=(
    #'rclone: Stream SquashFS images directly to remote storage (NAS/cloud)' #(todo)
)
provides=('0k' '0k-core' '0k-safe-rm' 'zero-kelvin-core' 'zero-kelvin-safe-rm')
conflicts=('zero-kelvin-testing')
source=("$pkgname::git+${url}.git#tag=v${pkgver}")
sha256sums=('SKIP')

options=(!debug !lto)

prepare() {
    cd "$pkgname"
    git submodule update --init --recursive
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
    cd "$pkgname"
    export RUSTUP_TOOLCHAIN=stable
    cargo build --release --locked
}

check() {
    cd "$pkgname"
    export RUSTUP_TOOLCHAIN=stable

    # Unit tests
    cargo test --release --locked --features testing

    # Integration tests (shell, no root)
    fish tests/run_shell_tests.fish --no-build-release --no-root
}

package() {
    cd "$pkgname"

    # Binaries
    install -Dm755 "target/release/0k"         "$pkgdir/usr/bin/0k"
    install -Dm755 "target/release/0k-core"    "$pkgdir/usr/bin/0k-core"
    install -Dm755 "target/release/0k-safe-rm" "$pkgdir/usr/bin/0k-safe-rm"

    # Alias symlinks
    ln -s 0k         "$pkgdir/usr/bin/zero-kelvin"
    ln -s 0k-core    "$pkgdir/usr/bin/zero-kelvin-core"
    ln -s 0k-safe-rm "$pkgdir/usr/bin/zero-kelvin-safe-rm"

    # License
    install -Dm644 LICENSE.GPLv3 "$pkgdir/usr/share/licenses/$pkgname/LICENSE.GPLv3"
    install -Dm644 LICENSE.docs "$pkgdir/usr/share/licenses/$pkgname/LICENSE.docs"

    # Documentation
    install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"

    # Man pages
    install -Dm644 man/0k.1      "$pkgdir/usr/share/man/man1/0k.1"
    install -Dm644 man/0k-core.1 "$pkgdir/usr/share/man/man1/0k-core.1"

    # Man page symlinks for aliases
    ln -s 0k.1      "$pkgdir/usr/share/man/man1/zero-kelvin.1"
    ln -s 0k-core.1 "$pkgdir/usr/share/man/man1/zero-kelvin-core.1"
}