summaryrefslogtreecommitdiff
path: root/recipes-support/snapd/files/0001-packaging-use-templates-for-relevant-systemd-units.patch
blob: 4132f8b15b8111a6eaa781071b30b2798bb8703a (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
From 0ad3491ce6d26c3dc772a4397b98cb706dc53fbf Mon Sep 17 00:00:00 2001
From: Simon Fels <simon.fels@canonical.com>
Date: Fri, 24 Mar 2017 17:54:48 +0100
Subject: [PATCH 1/4] packaging: use templates for relevant systemd units

To make packaging across different distributionis a bit easier we
now use templates for some of our systemd units and replace things
which are in a different location with sed at build time.
---
 data/systemd/snapd.autoimport.service    | 10 ----------
 data/systemd/snapd.autoimport.service.in | 10 ++++++++++
 data/systemd/snapd.refresh.service       | 11 -----------
 data/systemd/snapd.refresh.service.in    | 11 +++++++++++
 data/systemd/snapd.service               | 11 -----------
 data/systemd/snapd.service.in            | 11 +++++++++++
 packaging/ubuntu-16.04/rules             | 11 +++++++++++
 7 files changed, 43 insertions(+), 32 deletions(-)
 delete mode 100644 data/systemd/snapd.autoimport.service
 create mode 100644 data/systemd/snapd.autoimport.service.in
 delete mode 100644 data/systemd/snapd.refresh.service
 create mode 100644 data/systemd/snapd.refresh.service.in
 delete mode 100644 data/systemd/snapd.service
 create mode 100644 data/systemd/snapd.service.in

diff --git a/data/systemd/snapd.autoimport.service b/data/systemd/snapd.autoimport.service
deleted file mode 100644
index 2c75f15..0000000
--- a/data/systemd/snapd.autoimport.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Auto import assertions from block devices
-After=snapd.service snapd.socket
-
-[Service]
-Type=oneshot
-ExecStart=/usr/bin/snap auto-import
-
-[Install]
-WantedBy=multi-user.target
diff --git a/data/systemd/snapd.autoimport.service.in b/data/systemd/snapd.autoimport.service.in
new file mode 100644
index 0000000..04b9a7e
--- /dev/null
+++ b/data/systemd/snapd.autoimport.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=Auto import assertions from block devices
+After=snapd.service snapd.socket
+
+[Service]
+Type=oneshot
+ExecStart=@bindir@/snap auto-import
+
+[Install]
+WantedBy=multi-user.target
diff --git a/data/systemd/snapd.refresh.service b/data/systemd/snapd.refresh.service
deleted file mode 100644
index 893217f..0000000
--- a/data/systemd/snapd.refresh.service
+++ /dev/null
@@ -1,11 +0,0 @@
-[Unit]
-Description=Automatically refresh installed snaps
-After=network-online.target snapd.socket
-Requires=snapd.socket
-ConditionPathExistsGlob=/snap/*/current
-Documentation=man:snap(1)
-
-[Service]
-Type=oneshot
-ExecStart=/usr/bin/snap refresh
-Environment=SNAP_REFRESH_FROM_EMERGENCY_TIMER=1
diff --git a/data/systemd/snapd.refresh.service.in b/data/systemd/snapd.refresh.service.in
new file mode 100644
index 0000000..d5cd14b
--- /dev/null
+++ b/data/systemd/snapd.refresh.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Automatically refresh installed snaps
+After=network-online.target snapd.socket
+Requires=snapd.socket
+ConditionPathExistsGlob=@SNAP_MOUNTDIR@/*/current
+Documentation=man:snap(1)
+
+[Service]
+Type=oneshot
+ExecStart=@bindir@/snap refresh
+Environment=SNAP_REFRESH_FROM_EMERGENCY_TIMER=1
diff --git a/data/systemd/snapd.service b/data/systemd/snapd.service
deleted file mode 100644
index 0863225..0000000
--- a/data/systemd/snapd.service
+++ /dev/null
@@ -1,11 +0,0 @@
-[Unit]
-Description=Snappy daemon
-Requires=snapd.socket
-
-[Service]
-ExecStart=/usr/lib/snapd/snapd
-EnvironmentFile=/etc/environment
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
diff --git a/data/systemd/snapd.service.in b/data/systemd/snapd.service.in
new file mode 100644
index 0000000..009e62e
--- /dev/null
+++ b/data/systemd/snapd.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Snappy daemon
+Requires=snapd.socket
+
+[Service]
+ExecStart=@libexecdir@/snapd/snapd
+EnvironmentFile=@SNAPD_ENVIRONMENT_FILE@
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/ubuntu-16.04/rules b/packaging/ubuntu-16.04/rules
index a1328ac..18611b6 100755
--- a/packaging/ubuntu-16.04/rules
+++ b/packaging/ubuntu-16.04/rules
@@ -90,6 +90,16 @@ override_dh_auto_build:
 	cd cmd && ( ./configure --prefix=/usr --libexecdir=/usr/lib/snapd $(VENDOR_ARGS))
 	$(MAKE) -C cmd all
 
+	# Generate the real systemd units out of the available templates
+	cat data/systemd/snapd.service.in | \
+		sed s:@libexecdir@:/usr/lib:g | \
+		sed s:@SNAPD_ENVIRONMENT_FILE@:/etc/environment:g > data/systemd/snapd.service
+	cat data/systemd/snapd.refresh.service.in | \
+		sed s:@bindir@:/usr/bin:g | \
+		sed s:@SNAP_MOUNTDIR@:/snap:g > data/systemd/snapd.refresh.service
+	cat data/systemd/snapd.autoimport.service.in | \
+		sed s:@bindir@:/usr/bin:g > data/systemd/snapd.autoimport.service
+
 override_dh_auto_test:
 	dh_auto_test -- $(GCCGOFLAGS)
 # a tested default (production) build should have no test keys
@@ -164,6 +174,7 @@ override_dh_install:
 	if [ -d share/locale ]; then \
 		cp -R share/locale debian/snapd/usr/share; \
 	fi
+
 	# install snapd's systemd units, done here instead of
 	# debian/snapd.install because the ubuntu/14.04 release
 	# branch adds/changes bits here
-- 
2.7.4