Fix incorrect systemd service-name after #540.

Currently, cargo-deb does not use the variant name option as systemd
service-name, causing the postgres variant with name 'chirpstack' to
install a 'chirpstack-postgres' systemd service. See also
https://github.com/kornelski/cargo-deb/issues/150.

This also fixes the RPM systemd service-name for the sqlite variant.
This commit is contained in:
Orne Brocaar 2024-11-04 12:19:19 +00:00
parent fdf168bd09
commit 0ed78a1d0a
2 changed files with 21 additions and 17 deletions

View File

@ -235,17 +235,12 @@
"/etc/chirpstack/region_us915_7.toml", "/etc/chirpstack/region_us915_7.toml",
] ]
suggests = "postgresql, mosquitto, redis" suggests = "postgresql, mosquitto, redis"
conflicts = "chirpstack-sqlite"
maintainer-scripts = "debian/" maintainer-scripts = "debian/"
systemd-units = { enable = true } systemd-units = { enable = true }
[package.metadata.deb.variants.postgres]
name = "chirpstack"
suggests = "postgresql, mosquitto, redis"
conflicts = "chirpstack-sqlite"
[package.metadata.deb.variants.sqlite] [package.metadata.deb.variants.sqlite]
default-features = false name = "chirpstack-sqlite"
features = ["sqlite"]
suggests = "mosquitto, redis" suggests = "mosquitto, redis"
conflicts = "chirpstack" conflicts = "chirpstack"
@ -271,12 +266,16 @@ chmod 640 /etc/chirpstack/*.toml
{ source = "rpm/chirpstack.service", dest = "/lib/systemd/system/chirpstack.service" }, { source = "rpm/chirpstack.service", dest = "/lib/systemd/system/chirpstack.service" },
] ]
[package.metadata.generate-rpm.variants.postgres] [package.metadata.generate-rpm.conflicts]
name = "chirpstack"
[package.metadata.generate-rpm.variants.postgres.conflicts]
chirpstack-sqlite = "*" chirpstack-sqlite = "*"
[package.metadata.generate-rpm.variants.sqlite] [package.metadata.generate-rpm.variants.sqlite]
name = "chirpstack-sqlite" name = "chirpstack-sqlite"
assets = [
{ source = "target/release/chirpstack", dest = "/usr/bin/chirpstack", mode = "755" },
{ source = "configuration/*", dest = "/etc/chirpstack" },
{ source = "rpm/chirpstack.service", dest = "/lib/systemd/system/chirpstack-sqlite.service" },
]
[package.metadata.generate-rpm.variants.sqlite.conflicts] [package.metadata.generate-rpm.variants.sqlite.conflicts]
chirpstack = "*" chirpstack = "*"

View File

@ -2,6 +2,11 @@
PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') PKG_VERSION := $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
DATABASE ?= postgres DATABASE ?= postgres
ifeq ($(DATABASE),postgres)
VARIANT_FLAGS ?=
else
VARIANT_FLAGS ?= --variant="$(DATABASE)"
endif
debug-amd64: debug-amd64:
cross build --target x86_64-unknown-linux-musl --no-default-features --features="$(DATABASE)" cross build --target x86_64-unknown-linux-musl --no-default-features --features="$(DATABASE)"
@ -17,13 +22,13 @@ dist:
cross build --target x86_64-unknown-linux-musl --release --no-default-features --features="$(DATABASE)" cross build --target x86_64-unknown-linux-musl --release --no-default-features --features="$(DATABASE)"
cross build --target armv7-unknown-linux-musleabihf --release --no-default-features --features="$(DATABASE)" cross build --target armv7-unknown-linux-musleabihf --release --no-default-features --features="$(DATABASE)"
cargo deb --target x86_64-unknown-linux-musl --no-build --no-strip --variant="$(DATABASE)" cargo deb --target x86_64-unknown-linux-musl --no-build --no-strip $(VARIANT_FLAGS)
cargo deb --target armv7-unknown-linux-musleabihf --no-build --no-strip --variant="$(DATABASE)" cargo deb --target armv7-unknown-linux-musleabihf --no-build --no-strip $(VARIANT_FLAGS)
cargo deb --target aarch64-unknown-linux-musl --no-build --no-strip --variant="$(DATABASE)" cargo deb --target aarch64-unknown-linux-musl --no-build --no-strip $(VARIANT_FLAGS)
cargo generate-rpm --target x86_64-unknown-linux-musl --target-dir ../target --variant="$(DATABASE)" cargo generate-rpm --target x86_64-unknown-linux-musl --target-dir ../target $(VARIANT_FLAGS)
cargo generate-rpm --target armv7-unknown-linux-musleabihf --target-dir ../target --variant="$(DATABASE)" cargo generate-rpm --target armv7-unknown-linux-musleabihf --target-dir ../target $(VARIANT_FLAGS)
cargo generate-rpm --target aarch64-unknown-linux-musl --target-dir ../target --variant="$(DATABASE)" cargo generate-rpm --target aarch64-unknown-linux-musl --target-dir ../target $(VARIANT_FLAGS)
mkdir -p ../dist mkdir -p ../dist