Skip to content

Commit

Permalink
chore: Apply rust package guidelines of Arch Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetlert committed Dec 16, 2023
1 parent 7a9724e commit 378ac59
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
15 changes: 8 additions & 7 deletions PKGBUILD.aur
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
26 changes: 13 additions & 13 deletions PKGBUILD.local
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 378ac59

Please sign in to comment.