blob: 3d18d90c5da4c828d1c6b31efe3eebdb702dbd2a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/bin/bash
fetch_source() {
echo "Extracting from running system..."
}
build() {
COPYLIST="list_dpkg_output"
[ -e "${COPYLIST}" ] && rm "${COPYLIST}"
list_packet_files >> "${COPYLIST}"
tarcopy "$(cat "${COPYLIST}" | sort -u)" "${MODULE_BUILD_DIR}"
# Generate systemd files
mkdir -p "$MODULE_BUILD_DIR/etc/systemd/system/dbus.service.d"
# This is REQUIRED, otherwise the session daemon won't start (can be empty, but has to exist...)
mkdir -p "${MODULE_BUILD_DIR}/etc/dbus-1/session.d"
# We will either find the service file or generate it,
# thus we can already create the drop-in for uuidgen
UUIDGEN=$(find "$MODULE_BUILD_DIR" -name dbus-uuidgen -executable | head -n 1)
[ -z "$UUIDGEN" ] && perror "Could not determine dbus-uuidgen location"
cat <<-EOF > "$MODULE_BUILD_DIR/etc/systemd/system/dbus.service.d/uuidgen.conf"
[Service]
ExecStartPre=/${UUIDGEN#$MODULE_BUILD_DIR} --ensure
EOF
# First check if there is a system dbus file and copy it if so
declare -A found
for unit_type in service socket; do
for candidate in {,/usr}"/lib/systemd/system/dbus.${unit_type}"; do
if [ -e "$candidate" ]; then
cp -a "$candidate" "${MODULE_BUILD_DIR}/etc/systemd/system" \
|| perror "Failed to copy '$found' to '$MODULE_BUILD_DIR'."
found["$unit_type"]=oui
fi
done
done
# If not found, generate service file from the template
if [ -z "${found["service"]}" ]; then
# This is ugly, as the command line arguments changed over time. Try to do the right thing (whatever that is)
# Find path for: dbus-daemon
local DAEMON=$(find "$MODULE_BUILD_DIR" -name dbus-daemon -executable | head -n 1)
[ -z "$DAEMON" ] && perror "Could not determine dbus-daemon location"
DAEMON="/${DAEMON#$MODULE_BUILD_DIR}"
# Find path for: dbus-send
local SEND=$(find "$MODULE_BUILD_DIR" -name dbus-send -executable | head -n 1)
[ -z "$SEND" ] && perror "Could not determine dbus-send location"
SEND="/${SEND#$MODULE_BUILD_DIR}"
# Fill in the template
sed "s,%DAEMON%,$DAEMON,g;s,%SEND%,$SEND,g" "${MODULE_DIR}/templates/dbus.service" \
> "$MODULE_BUILD_DIR/etc/systemd/system/dbus.service" \
|| perror "Could not generate $MODULE_BUILD_DIR/etc/systemd/system/dbus.service"
fi
# Same for socket file
if [ -z "${found["socket"]}" ]; then
cp "${MODULE_DIR}/templates/dbus.socket" "$MODULE_BUILD_DIR/etc/systemd/system" \
|| perror "Could not copy templates/dbus.socket to build dir."
fi
}
post_copy() {
:
}
|