From 0ad3491ce6d26c3dc772a4397b98cb706dc53fbf Mon Sep 17 00:00:00 2001 From: Simon Fels 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