summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5f04e846edf97312b5e20afe3e07fd5e68dd2c6f (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
# Maintainer: taotieren <admin@taotieren.com>

pkgname=sudo-rs
pkgver=0.2.0
pkgrel=2
pkgdesc="A memory safe implementation of sudo and su."
arch=('any')
url="https://github.com/memorysafety/sudo-rs"
license=('Apache 2.0', 'MIT')
provides=(${pkgname})
conflicts=(${pkgname})
replaces=(sudo)
depends=()
makedepends=(cargo
    clang
    pam)
backup=()
options=('!strip')
#install=${pkgname}.install
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('2d1e6bdfc8f14a6023328ffd48a00f7c973409e7bdc6199f484c095ad9817090')

# Use LTO
export CARGO_PROFILE_RELEASE_LTO=true CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1

# Use debug
export CARGO_PROFILE_RELEASE_DEBUG=2

build() {
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target

    cd "${srcdir}/${pkgname}-${pkgver}/"
    cargo build --release --all-features
}

# check() {
#     export RUSTUP_TOOLCHAIN=stable
#     export CARGO_TARGET_DIR=target
#
#     cd "${srcdir}/${pkgname}-${pkgver}/"
#     cargo test --release --all-features
# }

package() {
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target

    cd "${srcdir}/${pkgname}-${pkgver}/"
    cargo install --no-track --all-features --root "$pkgdir/usr/" --path .
    install -Dm0644 "${srcdir}/${pkgname}-${pkgver}/"LICENSE* -t "$pkgdir/usr/share/licenses/${pkgname}/"


# Rename it to end in `-rs` to eliminate conflicts with `sudo` `utils-linux`.
    directory="$pkgdir/usr/bin"

    cd "$directory"

    for file in *; do
        if [ -x "$file" ]; then
            new_name="${file}-rs"
            mv "$file" "$new_name"
            chmod u+s "$new_name"
        fi
    done
}