diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..238e273 --- /dev/null +++ b/Makefile @@ -0,0 +1,26 @@ +NAME:=ifcfg-devname + +all: production check + +check: + @cargo test + +build: + @cargo build + +production: + @cargo build --release + +install: + mkdir -p $(DESTDIR)/usr/lib/udev/rules.d + install -p -m 0755 target/release/$(NAME) $(DESTDIR)/usr/lib/udev/ + install -p -m 644 rules/60-net.rules $(DESTDIR)/usr/lib/udev/rules.d/ + +uninstall: + rm -f $(DESTDIR)/usr/lib/udev/$(NAME) + rm -f $(DESTDIR)/usr/lib/udev/rules/60-net.rules + +clean: + @cargo clean + +.PHONY: check build production install uninstall clean diff --git a/rules/60-net.rules b/rules/60-net.rules new file mode 100644 index 0000000..ad58eba --- /dev/null +++ b/rules/60-net.rules @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/ifcfg-devname", RESULT=="?*", NAME="$result" diff --git a/rust-ifcfg-devname.spec b/rust-ifcfg-devname.spec index fb65e6c..5be442d 100644 --- a/rust-ifcfg-devname.spec +++ b/rust-ifcfg-devname.spec @@ -10,12 +10,13 @@ Summary: Udev helper utility that provides network interface naming # Upstream license specification: GPL-3.0 License: GPL-3.0-or-later -URL: https://crates.io/crates/ifcfg-devname +URL: https://crates.io/crates/%{crate} Source: %{crates_source} ExclusiveArch: %{rust_arches} BuildRequires: rust-packaging +BuildRequires: systemd-rpm-macros %global _description %{expand: Udev helper utility that provides network interface naming using ifcfg configuration.} @@ -32,7 +33,7 @@ License: GPL-3.0-or-later and MIT %license LICENSE %doc README.md -%{_bindir}/ifcfg-devname +%{_prefix}/lib/udev/%{crate} %{_udevrulesdir}/60-net.rules %package devel @@ -72,9 +73,7 @@ use the "default" feature of the "%{crate}" crate. %cargo_build %install -%cargo_install - -install -m 0755 -d $(DESTDIR)$(libdir)/udev +%make_install %if %{with check} %check diff --git a/usr/lib/udev/rules.d/60-net.rules b/usr/lib/udev/rules.d/60-net.rules deleted file mode 100644 index 9e60be2..0000000 --- a/usr/lib/udev/rules.d/60-net.rules +++ /dev/null @@ -1 +0,0 @@ -ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/usr/bin/ifcfg-devname", RESULT=="?*", NAME="$result"