Fix broken systemd-makefs path
This commit is contained in:
parent
fdfc3c3a3b
commit
2227078dc4
@ -1,21 +1,26 @@
|
||||
From 590bbc4941716658901709a42658962d665b06ad Mon Sep 17 00:00:00 2001
|
||||
From e03d06a4a631aec0cd0d9ae88ef75d374055e45e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 26 Oct 2021 16:08:36 +0200
|
||||
Subject: [PATCH 1/2] make: test that the config variables are not empty
|
||||
Subject: [PATCH 1/5] make: test that the config variables are not empty
|
||||
|
||||
If the user does something like "make SYSTEMD_SYSTEM_GENERATOR_DIR=", we
|
||||
would put things in /. I actually did something like this in an rpm build,
|
||||
where SYSTEMD_SYSTEM_GENERATOR_DIR is set using rpm macros, and not read
|
||||
from pkgconfig. We can easily catch this.
|
||||
where SYSTEMD_UTIL_DIR is set using rpm macros, and not read from pkgconfig,
|
||||
and the variable was defined but empty. We should catch this to avoid stupid
|
||||
operator mistakes.
|
||||
---
|
||||
Makefile | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
Makefile | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index ebbd135878..a15b95f483 100644
|
||||
index ebbd135878..49baab926f 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -21,6 +21,7 @@ program:
|
||||
@@ -18,9 +18,11 @@ export SYSTEMD_UTIL_DIR
|
||||
build: program systemd-service man
|
||||
|
||||
program:
|
||||
+ @test -n "$(SYSTEMD_UTIL_DIR)"
|
||||
@$(CARGO) build --release $(CARGOFLAGS)
|
||||
|
||||
systemd-service:
|
||||
@ -23,7 +28,7 @@ index ebbd135878..a15b95f483 100644
|
||||
@sed -e 's,@SYSTEMD_SYSTEM_GENERATOR_DIR@,$(SYSTEMD_SYSTEM_GENERATOR_DIR),' \
|
||||
< units/systemd-zram-setup@.service.in \
|
||||
> units/systemd-zram-setup@.service
|
||||
@@ -36,6 +37,9 @@ clean:
|
||||
@@ -36,6 +38,9 @@ clean:
|
||||
@rm -f units/systemd-zram-setup@.service
|
||||
|
||||
install: build
|
||||
|
@ -1,23 +1,23 @@
|
||||
From 5628c8f28940e30a40e4a5c006e738ad7b9991b6 Mon Sep 17 00:00:00 2001
|
||||
From 87f3f12d27f7a81891f9a6942de22a6084e9bc1a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 26 Oct 2021 16:11:53 +0200
|
||||
Subject: [PATCH 2/2] make: print executed commands
|
||||
Subject: [PATCH 2/5] make: print executed commands
|
||||
|
||||
The initial version of the Makefile used @ everywhere, but this hides
|
||||
errors. If anything, the user should use "make --silent" if they want
|
||||
to hide the commands.
|
||||
The initial version of the Makefile used @ everywhere, but this can hide
|
||||
errors in the executed commands. The user should instead use "make --silent" if
|
||||
they want to hide the commands.
|
||||
---
|
||||
Makefile | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index a15b95f483..0df1eaad64 100644
|
||||
index 49baab926f..ff3d4e80d9 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -18,23 +18,23 @@ export SYSTEMD_UTIL_DIR
|
||||
build: program systemd-service man
|
||||
@@ -19,23 +19,23 @@ build: program systemd-service man
|
||||
|
||||
program:
|
||||
@test -n "$(SYSTEMD_UTIL_DIR)"
|
||||
- @$(CARGO) build --release $(CARGOFLAGS)
|
||||
+ $(CARGO) build --release $(CARGOFLAGS)
|
||||
|
||||
|
38
0003-Print-the-path-to-the-makefs-command-in-help.patch
Normal file
38
0003-Print-the-path-to-the-makefs-command-in-help.patch
Normal file
@ -0,0 +1,38 @@
|
||||
From 85a44e5bff53fa28fc1346a3c1a789f9a3050345 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 26 Oct 2021 17:25:54 +0200
|
||||
Subject: [PATCH 3/5] Print the path to the makefs command in --help
|
||||
|
||||
It is called at runtime, but not in any output files, so if this
|
||||
is misconfigured, it can be quite hard to notice. So let's add this
|
||||
to make life easier when something is misconfigured.
|
||||
---
|
||||
src/main.rs | 1 +
|
||||
src/setup.rs | 2 +-
|
||||
2 files changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main.rs b/src/main.rs
|
||||
index a17e0f9235..5bfa556cd0 100644
|
||||
--- a/src/main.rs
|
||||
+++ b/src/main.rs
|
||||
@@ -41,6 +41,7 @@ fn get_opts() -> Opts {
|
||||
.number_of_values(2)
|
||||
.conflicts_with_all(&["setup-device", "reset-device"]),
|
||||
)
|
||||
+ .after_help(&*("Uses ".to_owned() + setup::SYSTEMD_MAKEFS_COMMAND + " to perform setup."))
|
||||
.get_matches();
|
||||
|
||||
let val = opts
|
||||
diff --git a/src/setup.rs b/src/setup.rs
|
||||
index befb0032f5..74572e55e0 100644
|
||||
--- a/src/setup.rs
|
||||
+++ b/src/setup.rs
|
||||
@@ -9,7 +9,7 @@ use std::os::unix::process::ExitStatusExt;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
-const SYSTEMD_MAKEFS_COMMAND: &str = concat!(
|
||||
+pub const SYSTEMD_MAKEFS_COMMAND: &str = concat!(
|
||||
env!(
|
||||
"SYSTEMD_UTIL_DIR",
|
||||
"Define $SYSTEMD_UTIL_DIR to the result of \
|
@ -0,0 +1,32 @@
|
||||
From 1b862b25f9c645dba7312ea2b06f065412713285 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 26 Oct 2021 17:45:39 +0200
|
||||
Subject: [PATCH 4/4] make: add an install subtarget that doesn't build
|
||||
anything
|
||||
|
||||
This is useful when we want to split the build and installation steps,
|
||||
and if there is anything to build in the installation step this is an
|
||||
error. For example, when doing 'make build && sudo make install'.
|
||||
---
|
||||
Makefile | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index ff3d4e80d9..4c4845e8db 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -37,7 +37,7 @@ clean:
|
||||
$(CARGO) clean
|
||||
rm -f units/systemd-zram-setup@.service
|
||||
|
||||
-install: build
|
||||
+install-nobuild:
|
||||
@test -n "$(SYSTEMD_SYSTEM_GENERATOR_DIR)"
|
||||
@test -n "$(SYSTEMD_SYSTEM_UNIT_DIR)"
|
||||
@test -n "$(PREFIX)"
|
||||
@@ -46,3 +46,5 @@ install: build
|
||||
$(INSTALL) -Dpm644 zram-generator.conf.example -t $(DESTDIR)$(PREFIX)/share/doc/zram-generator/
|
||||
$(INSTALL) -Dpm644 man/zram-generator.8 -t $(DESTDIR)$(PREFIX)/share/man/man8/
|
||||
$(INSTALL) -Dpm644 man/zram-generator.conf.5 -t $(DESTDIR)$(PREFIX)/share/man/man5/
|
||||
+
|
||||
+install: build install-nobuild
|
@ -0,0 +1,28 @@
|
||||
From f3c988c329939e4a0d6413ea9070db490c27dea5 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||
Date: Tue, 26 Oct 2021 17:45:39 +0200
|
||||
Subject: [PATCH 4/5] make: allow install target that doesn't build anything
|
||||
|
||||
This is useful when we want to split the build and installation steps,
|
||||
and if there is anything to build in the installation step it is an error.
|
||||
For example, when doing 'make build && sudo make install'.
|
||||
---
|
||||
Makefile | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index ff3d4e80d9..960728928f 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -37,7 +37,11 @@ clean:
|
||||
$(CARGO) clean
|
||||
rm -f units/systemd-zram-setup@.service
|
||||
|
||||
+ifndef NOBUILD
|
||||
install: build
|
||||
+endif
|
||||
+
|
||||
+install:
|
||||
@test -n "$(SYSTEMD_SYSTEM_GENERATOR_DIR)"
|
||||
@test -n "$(SYSTEMD_SYSTEM_UNIT_DIR)"
|
||||
@test -n "$(PREFIX)"
|
@ -16,6 +16,8 @@ Source1: zram-generator.conf
|
||||
|
||||
Patch1: 0001-make-test-that-the-config-variables-are-not-empty.patch
|
||||
Patch2: 0002-make-print-executed-commands.patch
|
||||
Patch3: 0003-Print-the-path-to-the-makefs-command-in-help.patch
|
||||
Patch4: 0004-make-allow-install-target-that-doesn-t-build-anythin.patch
|
||||
|
||||
ExclusiveArch: %{rust_arches}
|
||||
%if %{__cargo_skip_build}
|
||||
@ -114,7 +116,8 @@ export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
|
||||
%cargo_install
|
||||
|
||||
rm %{buildroot}%{_bindir}/zram-generator
|
||||
%make_install SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir}
|
||||
%make_install SYSTEMD_SYSTEM_UNIT_DIR=%{_unitdir} SYSTEMD_SYSTEM_GENERATOR_DIR=%{_systemdgeneratordir} \
|
||||
NOBUILD=1
|
||||
|
||||
install -Dpm0644 -t %{buildroot}%{_prefix}/lib/systemd %{SOURCE1}
|
||||
|
||||
@ -122,6 +125,11 @@ install -Dpm0644 -t %{buildroot}%{_prefix}/lib/systemd %{SOURCE1}
|
||||
%check
|
||||
export SYSTEMD_UTIL_DIR=%{_systemd_util_dir}
|
||||
%cargo_test
|
||||
|
||||
: ==============================================================================
|
||||
%{buildroot}%{_systemdgeneratordir}/zram-generator --help
|
||||
: ==============================================================================
|
||||
%{buildroot}%{_systemdgeneratordir}/zram-generator --help | grep -q %{_systemd_util_dir}/systemd-makefs
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
|
Loading…
Reference in New Issue
Block a user