Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package acpid to handle shutdown signals #437

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"acpid",
"aws-iam-authenticator",
"bash",
"ca-certificates",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 1a6c5126697cb171eae3922d822ae90b18176e1f Mon Sep 17 00:00:00 2001
From: iliana destroyer of worlds <[email protected]>
Date: Fri, 18 Oct 2019 22:56:45 +0000
Subject: [PATCH] Remove shell dependency by only shutting down

Thar doesn't have a shell, so this is a hack to get what we want
(shutdown behavior on power button press) without rearchitecting acpid.
---
event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/event.c b/event.c
index 6c67062..defdc42 100644
--- a/event.c
+++ b/event.c
@@ -687,7 +687,7 @@ do_cmd_rule(struct rule *rule, const char *event)
fprintf(stdout, "BEGIN HANDLER MESSAGES\n");
}
umask(0077);
- execl("/bin/sh", "/bin/sh", "-c", action, NULL);
+ execl("/sbin/shutdown", "/sbin/shutdown", "-h", "now", "Power button pressed", NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we run systemctl poweroff instead, so that the action here matches the configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, brain split. Going to change these both to shutdown -h now.

/* should not get here */
acpid_log(LOG_ERR, "execl(): %s", strerror(errno));
_exit(EXIT_FAILURE);
--
2.20.1

22 changes: 22 additions & 0 deletions packages/acpid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "acpid"
version = "0.1.0"
edition = "2018"
publish = false
build = "build.rs"

[lib]
path = "pkg.rs"

[[package.metadata.build-package.external-files]]
url = "http://downloads.sourceforge.net/acpid2/acpid-2.0.32.tar.xz"
sha512 = "c7afffdf9818504e1ac03b0ad693a05f772bfd07af9808262b3b6bb82ca4dabe6253c94e6dc59e5be6f0da9e815e8bcf2d3e16f02b23d0248b6bad4509e78be7"

[build-dependencies]
buildsys = { path = "../../tools/buildsys" }
glibc = { path = "../glibc", optional=true }

[features]
cascade = [
"glibc",
]
9 changes: 9 additions & 0 deletions packages/acpid/acpid.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=ACPI event daemon

[Service]
Type=forking
ExecStart=/usr/sbin/acpid -c /usr/lib/acpid/events

[Install]
WantedBy=multi-user.target
43 changes: 43 additions & 0 deletions packages/acpid/acpid.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Name: %{_cross_os}acpid
Version: 2.0.32
Release: 1%{?dist}
Summary: ACPI event daemon
License: GPLv2+
URL: http://sourceforge.net/projects/acpid2/
Source0: http://downloads.sourceforge.net/acpid2/acpid-%{version}.tar.xz
Source1: acpid.service
Source2: power.conf
Patch1: 0001-Remove-shell-dependency-by-only-shutting-down.patch
BuildRequires: gcc-%{_cross_target}
BuildRequires: %{_cross_os}glibc-devel
Requires: %{_cross_os}glibc

%description
%{summary}.

%prep
%autosetup -n acpid-%{version} -p1

%build
%cross_configure
%make_build

%install
%make_install

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_libdir}/acpid/events
install -p -m 0644 %{S:2} %{buildroot}%{_cross_libdir}/acpid/events/power

%files
%{_cross_sbindir}/acpid
%{_cross_unitdir}/acpid.service
%{_cross_libdir}/acpid/
%exclude %{_cross_bindir}/acpi_listen
%exclude %{_cross_sbindir}/kacpimon
%exclude %{_cross_docdir}
%exclude %{_cross_mandir}

%changelog
6 changes: 6 additions & 0 deletions packages/acpid/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
if let Err(e) = buildsys::build_package() {
eprintln!("{}", e);
std::process::exit(1);
}
}
1 change: 1 addition & 0 deletions packages/acpid/pkg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// not used
2 changes: 2 additions & 0 deletions packages/acpid/power.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
event=button/power
action=/sbin/shutdown -h now "Power button pressed"
1 change: 1 addition & 0 deletions packages/release/release.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Source1009: prepare-var-lib-thar.service
Source1010: var-lib-thar.mount

BuildArch: noarch
Requires: %{_cross_os}acpid
Requires: %{_cross_os}apiclient
Requires: %{_cross_os}apiserver
%if %{with shell}
Expand Down