From 378ac59e63da63c495999ec62e0bced53376847e Mon Sep 17 00:00:00 2001 From: Bhanupong Petchlert Date: Sun, 17 Dec 2023 04:31:21 +0700 Subject: [PATCH] chore: Apply rust package guidelines of Arch Linux --- PKGBUILD.aur | 15 ++++++++------- PKGBUILD.local | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/PKGBUILD.aur b/PKGBUILD.aur index bc11741..29caecc 100644 --- a/PKGBUILD.aur +++ b/PKGBUILD.aur @@ -11,27 +11,28 @@ makedepends=(cargo) options=(!lto) source=("${pkgname}-${pkgver}.tar.gz::https://github.com/bpetlert/${pkgname}/archive/${pkgver}.tar.gz") -b2sums=('6d91eb014aad07e97c5ee41a65561ad3c3b88f1ca95c7f7558366b168a0a71f8aade8d90bb44b3b7c134b24a58a6b231767cd28d4d6f78d1b265a42f5ede014e') +b2sums=('e32adb0e17a5cd1ec5e089fee1a5dc67798177b8ee2e60d6a3974037a88f5e6c6967c97be05e21496ae8de0d8b821ec9831d70eb92c6bfe8d8c48c5536fa9a93') prepare() { cd "${pkgname}-${pkgver}" - cargo fetch --locked --target "$CARCH-unknown-linux-gnu" + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" } build() { cd "${pkgname}-${pkgver}" export RUSTUP_TOOLCHAIN=stable export CARGO_TARGET_DIR=target - cargo build --frozen --release + cargo build --frozen --release } package() { cd "${pkgname}-${pkgver}" - install -Dm755 "target/release/networkd-broker" "$pkgdir/usr/bin/networkd-broker" + install -Dm755 "target/release/networkd-broker" "${pkgdir}/usr/bin/networkd-broker" - install -Dm644 "networkd-broker.service" "$pkgdir/usr/lib/systemd/system/networkd-broker.service" + install -Dm644 "networkd-broker.service" "${pkgdir}/usr/lib/systemd/system/networkd-broker.service" - install -dm755 "$pkgdir/etc/networkd/broker.d/"{carrier.d,degraded.d,dormant.d,no-carrier.d,off.d,routable.d} + install -dm755 "${pkgdir}/etc/networkd/broker.d/"{carrier.d,degraded.d,dormant.d,no-carrier.d,off.d,routable.d} - install -Dm644 "README.adoc" "$pkgdir/usr/share/doc/${pkgname}/README.adoc" + install -Dm644 "README.adoc" "${pkgdir}/usr/share/doc/${pkgname}/README.adoc" } diff --git a/PKGBUILD.local b/PKGBUILD.local index 3106c3a..04dafea 100644 --- a/PKGBUILD.local +++ b/PKGBUILD.local @@ -15,34 +15,34 @@ source=() # Using the most recent annotated tag reachable from the last commit. pkgver() { - cd "$startdir" + cd "${startdir}" git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g' } prepare() { - cd "$startdir" - cargo fetch --locked --target "$CARCH-unknown-linux-gnu" + cd "${startdir}" + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" } build() { - cd "$startdir" - + cd "${startdir}" export RUSTUP_TOOLCHAIN=stable # Ignore target-dir in ~/.cargo/config, reset it to default: "target". - # Add "$srcdir" to support BUILDDIR variable in makepkg. - export CARGO_TARGET_DIR=$srcdir/target + # Add "${srcdir}" to support BUILDDIR variable in makepkg. + export CARGO_TARGET_DIR=${srcdir}/target - cargo build --frozen --release + cargo build --frozen --release } package() { - cd "$srcdir" - install -Dm755 "target/release/networkd-broker" "$pkgdir/usr/bin/networkd-broker" + cd "${srcdir}" + install -Dm755 "target/release/networkd-broker" "${pkgdir}/usr/bin/networkd-broker" - install -Dm644 "$startdir/networkd-broker.service" "$pkgdir/usr/lib/systemd/system/networkd-broker.service" + install -Dm644 "${startdir}/networkd-broker.service" "${pkgdir}/usr/lib/systemd/system/networkd-broker.service" - install -dm755 "$pkgdir/etc/networkd/broker.d/"{carrier.d,degraded.d,dormant.d,no-carrier.d,off.d,routable.d} + install -dm755 "${pkgdir}/etc/networkd/broker.d/"{carrier.d,degraded.d,dormant.d,no-carrier.d,off.d,routable.d} - install -Dm644 "$startdir/README.adoc" "$pkgdir/usr/share/doc/${pkgname}/README.adoc" + install -Dm644 "${startdir}/README.adoc" "${pkgdir}/usr/share/doc/${pkgname}/README.adoc" }