[gnome-ostree-integration] Add bootloader installation service
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree-integration] Add bootloader installation service
- Date: Fri, 5 Apr 2013 22:03:31 +0000 (UTC)
commit a108e4ca9e3661057c39ad1bcdaf51082deea9a6
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Fri Apr 5 16:18:10 2013 -0400
Add bootloader installation service
This is used by the build system.
Signed-off-by: Colin Walters <walters verbum org>
Makefile-installboot.am | 12 ++++++++
Makefile.am | 1 +
configure.ac | 7 +++++
src/installboot/gnome-ostree-install-boot | 29 ++++++++++++++++++++
.../gnome-ostree-install-bootloader.service.in | 11 +++++++
.../gnome-ostree-install-bootloader.target | 4 +++
6 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/Makefile-installboot.am b/Makefile-installboot.am
new file mode 100644
index 0000000..74db6f9
--- /dev/null
+++ b/Makefile-installboot.am
@@ -0,0 +1,12 @@
+installbootdir = $(bindir)
+installboot_SCRIPTS = src/installboot/gnome-ostree-install-boot
+
+systemdservicemaindir = $(SYSTEMD_SYSTEM_UNIT_DIR)
+systemdservicemain_DATA = \
+ gnome-ostree-install-bootloader.service \
+ src/installboot/gnome-ostree-install-bootloader.target \
+ $(NULL)
+
+%.service: src/installboot/%.service.in Makefile
+ @sed -e "s|\ servicedir\@|$(libexecdir)|" $< | \
+ sed -e "s|\ bindir\@|$(bindir)|" > $ tmp && mv $ tmp $@
diff --git a/Makefile.am b/Makefile.am
index 62b4587..67878a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,6 +35,7 @@ privlib_LTLIBRARIES =
INSTALL_DATA_HOOKS =
include Makefile-integration.am
+include Makefile-installboot.am
install-data-hook: $(INSTALL_DATA_HOOKS)
diff --git a/configure.ac b/configure.ac
index a265430..ce02c61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,6 +19,13 @@ AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])
AM_PATH_PYTHON([2.6])
+PKG_PROG_PKG_CONFIG
+
+AC_ARG_WITH([systemdsystemunitdir],
+ AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
+ [Directory for systemd service files]),
+ [with_systemdsystemunitdir=$withval], [with_systemdsystemunitdir=$($PKG_CONFIG
--variable=systemdsystemunitdir systemd)])
+AC_SUBST(SYSTEMD_SYSTEM_UNIT_DIR, [$with_systemdsystemunitdir])
AC_CONFIG_FILES([
Makefile
diff --git a/src/installboot/gnome-ostree-install-boot b/src/installboot/gnome-ostree-install-boot
new file mode 100644
index 0000000..8721421
--- /dev/null
+++ b/src/installboot/gnome-ostree-install-boot
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Install extlinux on the currently active root device
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+set -e
+
+export BOOT_PARTITION=`cat /proc/mounts | tr -s " " | grep /boot | cut -d " " -f 1 | sed "s, ,,g"`
+export DEVICE=`echo ${BOOT_PARTITION} | sed -rn "s,(.+)([0-9]),\1,p"`
+export PARTITION=`echo ${BOOT_PARTITION} | sed -rn "s,(.+)([0-9]),\2,p"`
+
+if test -z "${DEVICE}"; then echo "Failed to determine device"; exit 1; fi
+
+dd if=/usr/lib/syslinux/mbr.bin of=${DEVICE}
+/usr/sbin/extlinux --install /boot/
+systemctl poweroff
diff --git a/src/installboot/gnome-ostree-install-bootloader.service.in
b/src/installboot/gnome-ostree-install-bootloader.service.in
new file mode 100644
index 0000000..897bd6a
--- /dev/null
+++ b/src/installboot/gnome-ostree-install-bootloader.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=One off bootloader installer
+AllowIsolate=yes
+Requires=basic.target
+
+[Service]
+Type=oneshot
+ExecStart= bindir@/gnome-ostree-install-boot
+
+[Install]
+WantedBy=gnome-ostree-install-bootloader.target
diff --git a/src/installboot/gnome-ostree-install-bootloader.target
b/src/installboot/gnome-ostree-install-bootloader.target
new file mode 100644
index 0000000..60f5725
--- /dev/null
+++ b/src/installboot/gnome-ostree-install-bootloader.target
@@ -0,0 +1,4 @@
+[Unit]
+Description=Bootloader installer
+Requires=gnome-ostree-install-bootloader.service
+AllowIsolate=yes
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]