From 84a8c2bb49e91f5e94c2c6c7245172994f517a91 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sun, 16 Feb 2014 18:01:05 -0600
Subject: systemd: 208

---
 .../systemd/0001-Reinstate-TIMEOUT-handling.patch  | 124 -------
 ...ng-references-to-var-lib-backlight-random.patch |  54 +++
 ...ator-When-parsing-the-root-cmdline-option.patch |  29 ++
 ...-stop-a-running-user-manager-from-garbage.patch |  36 ++
 ...unt-check-for-NULL-before-reading-pm-what.patch |  29 ++
 ...-fix-off-by-one-error-in-tag_to_udev_node.patch |  50 +++
 ...ator-Generate-explicit-dependencies-on-sy.patch | 102 ++++++
 ...nerator-Generate-explicit-dependencies-on.patch |  55 ++++
 ...FsckPassNo-from-systemd-fsck-root.service.patch |  22 ++
 ...005-mount-service-drop-FsckPassNo-support.patch | 364 +++++++++++++++++++++
 .../0006-efi-boot-generator-hookup-to-fsck.patch   |  81 +++++
 ...sck-root-only-run-when-requested-in-fstab.patch |  95 ++++++
 abs/core/systemd/PKGBUILD                          | 258 +++++++--------
 abs/core/systemd/initcpio-hook-udev                |   4 +-
 abs/core/systemd/initcpio-install-systemd          | 159 +++++++++
 abs/core/systemd/initcpio-install-timestamp        |  14 -
 abs/core/systemd/initcpio-install-udev             |   5 +-
 abs/core/systemd/locale.sh                         |  60 ----
 abs/core/systemd/systemd-187-2.src.tar.gz          |   1 -
 abs/core/systemd/systemd-tools.install             |  35 --
 abs/core/systemd/systemd.install                   | 113 ++++++-
 21 files changed, 1296 insertions(+), 394 deletions(-)
 delete mode 100644 abs/core/systemd/0001-Reinstate-TIMEOUT-handling.patch
 create mode 100644 abs/core/systemd/0001-fix-lingering-references-to-var-lib-backlight-random.patch
 create mode 100644 abs/core/systemd/0001-fstab-generator-When-parsing-the-root-cmdline-option.patch
 create mode 100644 abs/core/systemd/0001-login-Don-t-stop-a-running-user-manager-from-garbage.patch
 create mode 100644 abs/core/systemd/0001-mount-check-for-NULL-before-reading-pm-what.patch
 create mode 100644 abs/core/systemd/0001-shared-util-fix-off-by-one-error-in-tag_to_udev_node.patch
 create mode 100644 abs/core/systemd/0002-fstab-generator-Generate-explicit-dependencies-on-sy.patch
 create mode 100644 abs/core/systemd/0003-gpt-auto-generator-Generate-explicit-dependencies-on.patch
 create mode 100644 abs/core/systemd/0004-Remove-FsckPassNo-from-systemd-fsck-root.service.patch
 create mode 100644 abs/core/systemd/0005-mount-service-drop-FsckPassNo-support.patch
 create mode 100644 abs/core/systemd/0006-efi-boot-generator-hookup-to-fsck.patch
 create mode 100644 abs/core/systemd/0007-fsck-root-only-run-when-requested-in-fstab.patch
 mode change 100644 => 100755 abs/core/systemd/PKGBUILD
 create mode 100644 abs/core/systemd/initcpio-install-systemd
 delete mode 100644 abs/core/systemd/initcpio-install-timestamp
 delete mode 100644 abs/core/systemd/locale.sh
 delete mode 120000 abs/core/systemd/systemd-187-2.src.tar.gz
 delete mode 100644 abs/core/systemd/systemd-tools.install

diff --git a/abs/core/systemd/0001-Reinstate-TIMEOUT-handling.patch b/abs/core/systemd/0001-Reinstate-TIMEOUT-handling.patch
deleted file mode 100644
index 766dcb8..0000000
--- a/abs/core/systemd/0001-Reinstate-TIMEOUT-handling.patch
+++ /dev/null
@@ -1,124 +0,0 @@
-From 2127f99fb43d2ef950e95329ce40bdd5da8b015c Mon Sep 17 00:00:00 2001
-From: Dave Reisner <dreisner@archlinux.org>
-Date: Fri, 25 May 2012 19:43:24 -0400
-Subject: [PATCH] Reinstate TIMEOUT= handling
-
-This is mostly to deal with ipw2?00 drivers which have yet to be fixed
-in the kernel.
----
- src/libudev/libudev-device.c  |   19 +++++++++++++++++++
- src/libudev/libudev-private.h |    1 +
- src/udev/udevd.c              |   13 ++++++++++---
- 3 files changed, 30 insertions(+), 3 deletions(-)
-
-diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
-index a8277d1..5966189 100644
---- a/src/libudev/libudev-device.c
-+++ b/src/libudev/libudev-device.c
-@@ -68,6 +68,7 @@ struct udev_device {
-         struct udev_list tags_list;
-         unsigned long long int seqnum;
-         unsigned long long int usec_initialized;
-+        int timeout;
-         int devlink_priority;
-         int refcount;
-         dev_t devnum;
-@@ -89,6 +90,21 @@ struct udev_device {
-         bool db_persist;
- };
- 
-+int udev_device_get_timeout(struct udev_device *udev_device)
-+{
-+        return udev_device->timeout;
-+}
-+
-+static int udev_device_set_timeout(struct udev_device *udev_device, int timeout)
-+{
-+        char num[32];
-+
-+        udev_device->timeout = timeout;
-+        snprintf(num, sizeof(num), "%u", timeout);
-+        udev_device_add_property(udev_device, "TIMEOUT", num);
-+        return 0;
-+}
-+
- /**
-  * udev_device_get_seqnum:
-  * @udev_device: udev device
-@@ -362,6 +378,8 @@ void udev_device_add_property_from_string_parse(struct udev_device *udev_device,
- 
-                 util_strscpyl(path, sizeof(path), TEST_PREFIX "/sys", &property[8], NULL);
-                 udev_device_set_syspath(udev_device, path);
-+        } else if (strncmp(property, "TIMEOUT=", 8) == 0) {
-+                udev_device_set_timeout(udev_device, strtoull(&property[8], NULL, 10));
-         } else if (startswith(property, "SUBSYSTEM=")) {
-                 udev_device_set_subsystem(udev_device, &property[10]);
-         } else if (startswith(property, "DEVTYPE=")) {
-@@ -605,6 +623,7 @@ struct udev_device *udev_device_new(struct udev *udev)
-         udev_list_init(udev, &udev_device->sysattr_value_list, true);
-         udev_list_init(udev, &udev_device->sysattr_list, false);
-         udev_list_init(udev, &udev_device->tags_list, true);
-+        udev_device->timeout = -1;
-         udev_device->watch_handle = -1;
-         /* copy global properties */
-         udev_list_entry_foreach(list_entry, udev_get_properties_list_entry(udev))
-diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
-index 4eb4a59..99aefeb 100644
---- a/src/libudev/libudev-private.h
-+++ b/src/libudev/libudev-private.h
-@@ -70,6 +70,7 @@ const char *udev_device_get_id_filename(struct udev_device *udev_device);
- void udev_device_set_is_initialized(struct udev_device *udev_device);
- int udev_device_add_tag(struct udev_device *udev_device, const char *tag);
- void udev_device_cleanup_tags_list(struct udev_device *udev_device);
-+int udev_device_get_timeout(struct udev_device *udev_device);
- unsigned long long udev_device_get_usec_initialized(struct udev_device *udev_device);
- void udev_device_set_usec_initialized(struct udev_device *udev_device, unsigned long long usec_initialized);
- int udev_device_get_devlink_priority(struct udev_device *udev_device);
-diff --git a/src/udev/udevd.c b/src/udev/udevd.c
-index 0d85960..cd24462 100644
---- a/src/udev/udevd.c
-+++ b/src/udev/udevd.c
-@@ -384,7 +384,7 @@ out:
-         }
- }
- 
--static void event_run(struct event *event)
-+static void event_run(struct event *event, bool force)
- {
-         struct udev_list_node *loop;
- 
-@@ -410,7 +410,7 @@ static void event_run(struct event *event)
-                 return;
-         }
- 
--        if (children >= children_max) {
-+        if (!force && children >= children_max) {
-                 if (children_max > 1)
-                         log_debug("maximum number (%i) of children reached\n", children);
-                 return;
-@@ -444,6 +444,13 @@ static int event_queue_insert(struct udev_device *dev)
- 
-         event->state = EVENT_QUEUED;
-         udev_list_node_append(&event->node, &event_list);
-+
-+        /* run all events with a timeout set immediately */
-+        if (udev_device_get_timeout(dev) > 0) {
-+                event_run(event, true);
-+                return 0;
-+        }
-+
-         return 0;
- }
- 
-@@ -549,7 +556,7 @@ static void event_queue_start(struct udev *udev)
-                 if (is_devpath_busy(event))
-                         continue;
- 
--                event_run(event);
-+                event_run(event, false);
-         }
- }
- 
--- 
-1.7.10.2
-
diff --git a/abs/core/systemd/0001-fix-lingering-references-to-var-lib-backlight-random.patch b/abs/core/systemd/0001-fix-lingering-references-to-var-lib-backlight-random.patch
new file mode 100644
index 0000000..49b960c
--- /dev/null
+++ b/abs/core/systemd/0001-fix-lingering-references-to-var-lib-backlight-random.patch
@@ -0,0 +1,54 @@
+From 6c8c92fef72cf6a7ef7109a424ef82dbdc4f6952 Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner@archlinux.org>
+Date: Wed, 2 Oct 2013 07:46:24 -0400
+Subject: [PATCH] fix lingering references to /var/lib/{backlight,random-seed}
+
+This should have been part of ef5bfcf668e6029faa78534dfe.
+---
+ man/systemd-backlight@.service.xml  | 2 +-
+ man/systemd-random-seed.service.xml | 2 +-
+ units/systemd-backlight@.service.in | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/man/systemd-backlight@.service.xml b/man/systemd-backlight@.service.xml
+index 2b73625..4318964 100644
+--- a/man/systemd-backlight@.service.xml
++++ b/man/systemd-backlight@.service.xml
+@@ -58,7 +58,7 @@
+                 is a service that restores the display backlight
+                 brightness at early-boot and saves it at shutdown. On
+                 disk, the backlight brightness is stored in
+-                <filename>/var/lib/backlight/</filename>. Note that by
++                <filename>/var/lib/systemd/backlight/</filename>. Note that by
+                 default, only firmware backlight devices are
+                 saved/restored.</para>
+         </refsect1>
+diff --git a/man/systemd-random-seed.service.xml b/man/systemd-random-seed.service.xml
+index 8cd14b7..e5cd037 100644
+--- a/man/systemd-random-seed.service.xml
++++ b/man/systemd-random-seed.service.xml
+@@ -61,7 +61,7 @@
+                 for details. Saving/restoring the random seed across
+                 boots increases the amount of available entropy early
+                 at boot. On disk the random seed is stored in
+-                <filename>/var/lib/random-seed</filename>.</para>
++                <filename>/var/lib/systemd/random-seed</filename>.</para>
+         </refsect1>
+ 
+         <refsect1>
+diff --git a/units/systemd-backlight@.service.in b/units/systemd-backlight@.service.in
+index b0e75db..5caa5d5 100644
+--- a/units/systemd-backlight@.service.in
++++ b/units/systemd-backlight@.service.in
+@@ -9,7 +9,7 @@
+ Description=Load/Save Screen Backlight Brightness of %I
+ Documentation=man:systemd-backlight@.service(8)
+ DefaultDependencies=no
+-RequiresMountsFor=/var/lib/backlight
++RequiresMountsFor=/var/lib/systemd/backlight
+ Conflicts=shutdown.target
+ After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service
+ Before=sysinit.target shutdown.target
+-- 
+1.8.4
+
diff --git a/abs/core/systemd/0001-fstab-generator-When-parsing-the-root-cmdline-option.patch b/abs/core/systemd/0001-fstab-generator-When-parsing-the-root-cmdline-option.patch
new file mode 100644
index 0000000..3cdbcf0
--- /dev/null
+++ b/abs/core/systemd/0001-fstab-generator-When-parsing-the-root-cmdline-option.patch
@@ -0,0 +1,29 @@
+From 7f5806d7095a197e4788a7803642831beec295bf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Mon, 30 Sep 2013 00:32:33 +0200
+Subject: [PATCH 1/7] fstab-generator: When parsing the root= cmdline option,
+ set FsckPassNo to 1
+
+[tomegun: without this we would never fsck the rootfs if it was directly
+mounted 'rw' from the initrd. We now risk fsck'ing it twice in the case it
+is mounted 'ro', so that should be addressed in a separate patch.]
+---
+ src/fstab-generator/fstab-generator.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
+index 9e7d55d..a7536f8 100644
+--- a/src/fstab-generator/fstab-generator.c
++++ b/src/fstab-generator/fstab-generator.c
+@@ -442,7 +442,7 @@ static int parse_new_root_from_proc_cmdline(void) {
+         }
+ 
+         log_debug("Found entry what=%s where=/sysroot type=%s", what, type);
+-        r = add_mount(what, "/sysroot", type, opts, 0, noauto, nofail, false,
++        r = add_mount(what, "/sysroot", type, opts, 1, noauto, nofail, false,
+                       SPECIAL_INITRD_ROOT_FS_TARGET, "/proc/cmdline");
+ 
+         return (r < 0) ? r : 0;
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0001-login-Don-t-stop-a-running-user-manager-from-garbage.patch b/abs/core/systemd/0001-login-Don-t-stop-a-running-user-manager-from-garbage.patch
new file mode 100644
index 0000000..9a92209
--- /dev/null
+++ b/abs/core/systemd/0001-login-Don-t-stop-a-running-user-manager-from-garbage.patch
@@ -0,0 +1,36 @@
+From 95842c3f552072c9d153b3c0200f1bbb5bc3c2fb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Sun, 15 Dec 2013 12:18:00 +0100
+Subject: [PATCH] login: Don't stop a running user manager from
+ garbage-collecting the user.
+
+With the current logic, a user will never be garbage-collected, since its
+manager will always be around. Change the logic such that a user is
+garbage-collected when it has no sessions and linger is disabled.
+
+This is a backport from the master branch to 208 which also backports
+the improved handling of running slice and service jobs.
+---
+ src/login/logind-user.c | 6 ------
+ 1 file changed, 6 deletions(-)
+
+diff --git a/src/login/logind-user.c b/src/login/logind-user.c
+index adbe638..e2fce5c 100644
+--- a/src/login/logind-user.c
++++ b/src/login/logind-user.c
+@@ -629,12 +629,6 @@ int user_check_gc(User *u, bool drop_not_started) {
+         if (u->slice_job || u->service_job)
+                 return 1;
+ 
+-        if (u->slice && manager_unit_is_active(u->manager, u->slice) != 0)
+-                return 1;
+-
+-        if (u->service && manager_unit_is_active(u->manager, u->service) != 0)
+-                return 1;
+-
+         return 0;
+ }
+ 
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0001-mount-check-for-NULL-before-reading-pm-what.patch b/abs/core/systemd/0001-mount-check-for-NULL-before-reading-pm-what.patch
new file mode 100644
index 0000000..2725648
--- /dev/null
+++ b/abs/core/systemd/0001-mount-check-for-NULL-before-reading-pm-what.patch
@@ -0,0 +1,29 @@
+From 9c03872bc8fb2a381eafe7301ef9811b641686dd Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner@archlinux.org>
+Date: Fri, 4 Oct 2013 18:22:40 -0400
+Subject: [PATCH] mount: check for NULL before reading pm->what
+
+Since a57f7e2c828b85, a mount unit with garbage in it would cause
+systemd to crash on loading it.
+
+ref: https://bugs.freedesktop.org/show_bug.cgi?id=70148
+---
+ src/core/mount.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/core/mount.c b/src/core/mount.c
+index 93bfa99..db055f0 100644
+--- a/src/core/mount.c
++++ b/src/core/mount.c
+@@ -182,7 +182,7 @@ static int mount_add_mount_links(Mount *m) {
+          * for the source path (if this is a bind mount) to be
+          * available. */
+         pm = get_mount_parameters_fragment(m);
+-        if (pm && path_is_absolute(pm->what)) {
++        if (pm && pm->what && path_is_absolute(pm->what)) {
+                 r = unit_require_mounts_for(UNIT(m), pm->what);
+                 if (r < 0)
+                         return r;
+-- 
+1.8.4.1
+
diff --git a/abs/core/systemd/0001-shared-util-fix-off-by-one-error-in-tag_to_udev_node.patch b/abs/core/systemd/0001-shared-util-fix-off-by-one-error-in-tag_to_udev_node.patch
new file mode 100644
index 0000000..8c8ea46
--- /dev/null
+++ b/abs/core/systemd/0001-shared-util-fix-off-by-one-error-in-tag_to_udev_node.patch
@@ -0,0 +1,50 @@
+From 1d5989fd803d2019de0f6aaaf3cfb1cb2bbc3cdb Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner@archlinux.org>
+Date: Sun, 6 Oct 2013 18:26:23 -0400
+Subject: [PATCH] shared/util: fix off-by-one error in tag_to_udev_node
+
+Triggered false negatives when encoding a string which needed every
+character to be escaped, e.g. "LABEL=/".
+---
+ src/shared/util.c            | 2 +-
+ src/test/test-device-nodes.c | 4 +++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/shared/util.c b/src/shared/util.c
+index 82f4221..31cea79 100644
+--- a/src/shared/util.c
++++ b/src/shared/util.c
+@@ -3527,7 +3527,7 @@ static char *tag_to_udev_node(const char *tagvalue, const char *by) {
+         if (u == NULL)
+                 return NULL;
+ 
+-        enc_len = strlen(u) * 4;
++        enc_len = strlen(u) * 4 + 1;
+         t = new(char, enc_len);
+         if (t == NULL)
+                 return NULL;
+diff --git a/src/test/test-device-nodes.c b/src/test/test-device-nodes.c
+index 2f3dedb..59ba4be 100644
+--- a/src/test/test-device-nodes.c
++++ b/src/test/test-device-nodes.c
+@@ -26,7 +26,7 @@
+ 
+ /* helpers for test_encode_devnode_name */
+ static char *do_encode_string(const char *in) {
+-        size_t out_len = strlen(in) * 4;
++        size_t out_len = strlen(in) * 4 + 1;
+         char *out = malloc(out_len);
+ 
+         assert_se(out);
+@@ -46,6 +46,8 @@ static void test_encode_devnode_name(void) {
+         assert_se(expect_encoded_as("pinkiepie", "pinkiepie"));
+         assert_se(expect_encoded_as("valíd\\ųtf8", "valíd\\x5cųtf8"));
+         assert_se(expect_encoded_as("s/ash/ng", "s\\x2fash\\x2fng"));
++        assert_se(expect_encoded_as("/", "\\x2f"));
++        assert_se(expect_encoded_as("!", "\\x21"));
+ }
+ 
+ int main(int argc, char *argv[]) {
+-- 
+1.8.4.1
+
diff --git a/abs/core/systemd/0002-fstab-generator-Generate-explicit-dependencies-on-sy.patch b/abs/core/systemd/0002-fstab-generator-Generate-explicit-dependencies-on-sy.patch
new file mode 100644
index 0000000..57edf64
--- /dev/null
+++ b/abs/core/systemd/0002-fstab-generator-Generate-explicit-dependencies-on-sy.patch
@@ -0,0 +1,102 @@
+From 64e70e4b86d3f732d3513189312f6220d1d5cfbc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Mon, 30 Sep 2013 01:34:44 +0200
+Subject: [PATCH 2/7] fstab-generator: Generate explicit dependencies on
+ systemd-fsck@.service instead of using FsckPassNo
+
+[tomegun:
+  * order all fsck instances after fsck-root
+  * check for OOM
+  * added notes in the manpages]
+---
+ man/systemd-fsck@.service.xml         |  3 ++-
+ man/systemd-fstab-generator.xml       |  5 +++++
+ src/fstab-generator/fstab-generator.c | 21 +++++++++++++++++----
+ units/systemd-fsck@.service.in        |  2 +-
+ 4 files changed, 25 insertions(+), 6 deletions(-)
+
+diff --git a/man/systemd-fsck@.service.xml b/man/systemd-fsck@.service.xml
+index e934352..17bd1c0 100644
+--- a/man/systemd-fsck@.service.xml
++++ b/man/systemd-fsck@.service.xml
+@@ -62,7 +62,8 @@
+                 system
+                 check. <filename>systemd-fsck-root.service</filename> is
+                 responsible for file system checks on the root
+-                file system.</para>
++                file system. The root file system check is performed
++                before the other file systems.</para>
+ 
+                 <para><filename>systemd-fsck</filename> will
+                 forward file system checking progress to the
+diff --git a/man/systemd-fstab-generator.xml b/man/systemd-fstab-generator.xml
+index 9ca16c7..740db8f 100644
+--- a/man/systemd-fstab-generator.xml
++++ b/man/systemd-fstab-generator.xml
+@@ -61,6 +61,11 @@
+                 reloaded. This will instantiate mount and swap units
+                 as necessary.</para>
+ 
++                <para>The <term><varname>passno</varname></term> field
++                is treated like a simlpe boolean, and the ordering information
++                is discarded. However, the root filesystem is checked
++                before all the other filesystems.</para>
++
+                 <para>See
+                 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+                 and
+diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
+index a7536f8..77247de 100644
+--- a/src/fstab-generator/fstab-generator.c
++++ b/src/fstab-generator/fstab-generator.c
+@@ -209,17 +209,30 @@ static int add_mount(
+                         "Before=%s\n",
+                         post);
+ 
++        if (passno > 0) {
++                _cleanup_free_ char *fsck = NULL;
++
++                fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
++                if (!fsck)
++                        return log_oom();
++
++                fprintf(f,
++                        "Requires=%s\n"
++                        "After=%s\n",
++                        fsck,
++                        fsck);
++        }
++
++
+         fprintf(f,
+                 "\n"
+                 "[Mount]\n"
+                 "What=%s\n"
+                 "Where=%s\n"
+-                "Type=%s\n"
+-                "FsckPassNo=%i\n",
++                "Type=%s\n",
+                 what,
+                 where,
+-                type,
+-                passno);
++                type);
+ 
+         if (!isempty(opts) &&
+             !streq(opts, "defaults"))
+diff --git a/units/systemd-fsck@.service.in b/units/systemd-fsck@.service.in
+index e229cdc..c12efa8 100644
+--- a/units/systemd-fsck@.service.in
++++ b/units/systemd-fsck@.service.in
+@@ -10,7 +10,7 @@ Description=File System Check on %f
+ Documentation=man:systemd-fsck@.service(8)
+ DefaultDependencies=no
+ BindsTo=%i.device
+-After=systemd-readahead-collect.service systemd-readahead-replay.service %i.device
++After=systemd-readahead-collect.service systemd-readahead-replay.service %i.device systemd-fsck-root.service
+ Before=shutdown.target
+ 
+ [Service]
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0003-gpt-auto-generator-Generate-explicit-dependencies-on.patch b/abs/core/systemd/0003-gpt-auto-generator-Generate-explicit-dependencies-on.patch
new file mode 100644
index 0000000..c1b3aa0
--- /dev/null
+++ b/abs/core/systemd/0003-gpt-auto-generator-Generate-explicit-dependencies-on.patch
@@ -0,0 +1,55 @@
+From 4c8bda2442bfc6d84a5deb241dc29efcb81bf3af Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Mon, 30 Sep 2013 01:34:45 +0200
+Subject: [PATCH 3/7] gpt-auto-generator: Generate explicit dependencies on
+ systemd-fsck@.service instead of using FsckPassNo
+
+[tomegun: check for OOM]
+---
+ src/gpt-auto-generator/gpt-auto-generator.c | 14 +++++++++-----
+ 1 file changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
+index fae4b71..25440e7 100644
+--- a/src/gpt-auto-generator/gpt-auto-generator.c
++++ b/src/gpt-auto-generator/gpt-auto-generator.c
+@@ -182,7 +182,7 @@ static int add_swap(const char *path, const char *fstype) {
+ }
+ 
+ static int add_home(const char *path, const char *fstype) {
+-        _cleanup_free_ char *unit = NULL, *lnk = NULL;
++        _cleanup_free_ char *unit = NULL, *lnk = NULL, *fsck = NULL;
+         _cleanup_fclose_ FILE *f = NULL;
+ 
+         if (dir_is_empty("/home") <= 0)
+@@ -200,19 +200,23 @@ static int add_home(const char *path, const char *fstype) {
+                 return -errno;
+         }
+ 
++        fsck = unit_name_from_path_instance("systemd-fsck", path, ".service");
++        if (!fsck)
++                return log_oom();
++
+         fprintf(f,
+                 "# Automatically generated by systemd-gpt-auto-generator\n\n"
+                 "[Unit]\n"
+                 "DefaultDependencies=no\n"
+-                "After=" SPECIAL_LOCAL_FS_PRE_TARGET "\n"
++                "Requires=%s\n"
++                "After=" SPECIAL_LOCAL_FS_PRE_TARGET " %s\n"
+                 "Conflicts=" SPECIAL_UMOUNT_TARGET "\n"
+                 "Before=" SPECIAL_UMOUNT_TARGET " " SPECIAL_LOCAL_FS_TARGET "\n\n"
+                 "[Mount]\n"
+                 "What=%s\n"
+                 "Where=/home\n"
+-                "Type=%s\n"
+-                "FsckPassNo=2\n",
+-                path, fstype);
++                "Type=%s\n",
++                fsck, fsck, path, fstype);
+ 
+         fflush(f);
+         if (ferror(f)) {
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0004-Remove-FsckPassNo-from-systemd-fsck-root.service.patch b/abs/core/systemd/0004-Remove-FsckPassNo-from-systemd-fsck-root.service.patch
new file mode 100644
index 0000000..90ff545
--- /dev/null
+++ b/abs/core/systemd/0004-Remove-FsckPassNo-from-systemd-fsck-root.service.patch
@@ -0,0 +1,22 @@
+From 4952a9beff339b75641a7a84c226c11d6bd680c4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thomas=20B=C3=A4chler?= <thomas@archlinux.org>
+Date: Mon, 30 Sep 2013 01:34:46 +0200
+Subject: [PATCH 4/7] Remove FsckPassNo from systemd-fsck-root.service
+
+---
+ units/systemd-fsck-root.service.in | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/units/systemd-fsck-root.service.in b/units/systemd-fsck-root.service.in
+index 4388314..4162983 100644
+--- a/units/systemd-fsck-root.service.in
++++ b/units/systemd-fsck-root.service.in
+@@ -19,5 +19,4 @@ Type=oneshot
+ RemainAfterExit=yes
+ ExecStart=@rootlibexecdir@/systemd-fsck
+ StandardOutput=journal+console
+-FsckPassNo=1
+ TimeoutSec=0
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0005-mount-service-drop-FsckPassNo-support.patch b/abs/core/systemd/0005-mount-service-drop-FsckPassNo-support.patch
new file mode 100644
index 0000000..9758c46
--- /dev/null
+++ b/abs/core/systemd/0005-mount-service-drop-FsckPassNo-support.patch
@@ -0,0 +1,364 @@
+From accdd018ede77ef1c057775396c18c73406cbcb4 Mon Sep 17 00:00:00 2001
+From: Tom Gundersen <teg@jklm.no>
+Date: Sat, 5 Oct 2013 17:28:09 +0200
+Subject: [PATCH 5/7] mount/service: drop FsckPassNo support
+
+We now treat passno as boleans in the generators, and don't need this any more. fsck itself
+is able to sequentialize checks on the same local media, so in the common case the ordering
+is redundant.
+
+It is still possible to force an order by using .d fragments, in case that is desired.
+---
+ TODO                                  |  4 ---
+ man/systemd.mount.xml                 | 22 ---------------
+ man/systemd.service.xml               | 27 -------------------
+ src/core/load-fragment-gperf.gperf.m4 |  2 --
+ src/core/load-fragment.c              | 30 ---------------------
+ src/core/load-fragment.h              |  1 -
+ src/core/mount.c                      | 32 +---------------------
+ src/core/mount.h                      |  1 -
+ src/core/service.c                    | 51 -----------------------------------
+ src/core/service.h                    |  2 --
+ 10 files changed, 1 insertion(+), 171 deletions(-)
+
+diff --git a/TODO b/TODO
+index 29a76ef..f0060d9 100644
+--- a/TODO
++++ b/TODO
+@@ -84,8 +84,6 @@ Features:
+ 
+ * ensure scope units may be started only a single time
+ 
+-* document that in instead of FsckPassNo= people should just add a manual dep to systemd-fsck@.service to their mount units.
+-
+ * better error message if you run systemctl without systemd running
+ 
+ * systemctl status output should should include list of triggering units and their status
+@@ -562,8 +560,6 @@ Features:
+ 
+ * when breaking cycles drop sysv services first, then services from /run, then from /etc, then from /usr
+ 
+-* move passno parsing to fstab generator
+-
+ * automount: implement expire:
+    - set superblock timeout AUTOFS_DEV_IOCTL_TIMEOUT_CMD
+    - periodically run AUTOFS_DEV_IOCTL_EXPIRE_CMD
+diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
+index 48af1ca..217289a 100644
+--- a/man/systemd.mount.xml
++++ b/man/systemd.mount.xml
+@@ -273,28 +273,6 @@
+         </refsect1>
+ 
+         <refsect1>
+-                <title>Compatibility Options</title>
+-
+-                <para>The following option is also available in the
+-                <literal>[Mount]</literal> section, but exists purely
+-                for compatibility reasons and should not be used in
+-                newly written mount files.</para>
+-
+-                <variablelist class='unit-directives'>
+-                        <varlistentry>
+-                                <term><varname>FsckPassNo=</varname></term>
+-
+-                                <listitem><para>The pass number for
+-                                the file system checking service for
+-                                this mount. See
+-                                <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+-                                for more information on this setting.
+-                                </para></listitem>
+-                        </varlistentry>
+-                </variablelist>
+-        </refsect1>
+-
+-        <refsect1>
+                   <title>See Also</title>
+                   <para>
+                           <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+diff --git a/man/systemd.service.xml b/man/systemd.service.xml
+index 81a4078..b1e3af2 100644
+--- a/man/systemd.service.xml
++++ b/man/systemd.service.xml
+@@ -970,33 +970,6 @@
+                                 range 0-99.</para></listitem>
+                         </varlistentry>
+ 
+-                        <varlistentry>
+-                                <term><varname>FsckPassNo=</varname></term>
+-                                <listitem><para>Set the fsck passno
+-                                priority to use to order this service
+-                                in relation to other file system
+-                                checking services. This option is only
+-                                necessary to fix ordering in relation
+-                                to fsck jobs automatically created for
+-                                all <filename>/etc/fstab</filename>
+-                                entries with a value in the fs_passno
+-                                column > 0. As such it should only be
+-                                used as option for fsck
+-                                services. Almost always it is a better
+-                                choice to add explicit ordering
+-                                directives via
+-                                <varname>After=</varname> or
+-                                <varname>Before=</varname>,
+-                                instead. For more details see
+-                                <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. If
+-                                used, pass an integer value in the
+-                                same range as
+-                                <filename>/etc/fstab</filename>'s
+-                                fs_passno column. See
+-                                <citerefentry><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+-                                for details.</para></listitem>
+-                        </varlistentry>
+-
+                 </variablelist>
+         </refsect1>
+ 
+diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
+index 31fb7bc..e3025d2 100644
+--- a/src/core/load-fragment-gperf.gperf.m4
++++ b/src/core/load-fragment-gperf.gperf.m4
+@@ -173,7 +173,6 @@ Service.NonBlocking,             config_parse_bool,                  0,
+ Service.BusName,                 config_parse_unit_string_printf,    0,                             offsetof(Service, bus_name)
+ Service.NotifyAccess,            config_parse_notify_access,         0,                             offsetof(Service, notify_access)
+ Service.Sockets,                 config_parse_service_sockets,       0,                             0
+-Service.FsckPassNo,              config_parse_fsck_passno,           0,                             offsetof(Service, fsck_passno)
+ EXEC_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
+ CGROUP_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
+ KILL_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
+@@ -225,7 +224,6 @@ Mount.What,                      config_parse_string,                0,
+ Mount.Where,                     config_parse_path,                  0,                             offsetof(Mount, where)
+ Mount.Options,                   config_parse_string,                0,                             offsetof(Mount, parameters_fragment.options)
+ Mount.Type,                      config_parse_string,                0,                             offsetof(Mount, parameters_fragment.fstype)
+-Mount.FsckPassNo,                config_parse_fsck_passno,           0,                             offsetof(Mount, parameters_fragment.passno)
+ Mount.TimeoutSec,                config_parse_sec,                   0,                             offsetof(Mount, timeout_usec)
+ Mount.DirectoryMode,             config_parse_mode,                  0,                             offsetof(Mount, directory_mode)
+ EXEC_CONTEXT_CONFIG_ITEMS(Mount)m4_dnl
+diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
+index fb7efca..4067930 100644
+--- a/src/core/load-fragment.c
++++ b/src/core/load-fragment.c
+@@ -1033,35 +1033,6 @@ int config_parse_sysv_priority(const char *unit,
+ }
+ #endif
+ 
+-int config_parse_fsck_passno(const char *unit,
+-                             const char *filename,
+-                             unsigned line,
+-                             const char *section,
+-                             const char *lvalue,
+-                             int ltype,
+-                             const char *rvalue,
+-                             void *data,
+-                             void *userdata) {
+-
+-        int *passno = data;
+-        int i, r;
+-
+-        assert(filename);
+-        assert(lvalue);
+-        assert(rvalue);
+-        assert(data);
+-
+-        r = safe_atoi(rvalue, &i);
+-        if (r || i < 0) {
+-                log_syntax(unit, LOG_ERR, filename, line, -r,
+-                           "Failed to parse fsck pass number, ignoring: %s", rvalue);
+-                return 0;
+-        }
+-
+-        *passno = (int) i;
+-        return 0;
+-}
+-
+ DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode");
+ 
+ int config_parse_kill_signal(const char *unit,
+@@ -2708,7 +2679,6 @@ void unit_dump_config_items(FILE *f) {
+                 { config_parse_start_limit_action,    "ACTION" },
+                 { config_parse_set_status,            "STATUS" },
+                 { config_parse_service_sockets,       "SOCKETS" },
+-                { config_parse_fsck_passno,           "PASSNO" },
+                 { config_parse_environ,               "ENVIRON" },
+                 { config_parse_syscall_filter,        "SYSCALL" },
+                 { config_parse_cpu_shares,            "SHARES" },
+diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
+index 90e5e3a..404df76 100644
+--- a/src/core/load-fragment.h
++++ b/src/core/load-fragment.h
+@@ -56,7 +56,6 @@ int config_parse_exec_secure_bits(const char *unit, const char *filename, unsign
+ int config_parse_bounding_set(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_limit(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_sysv_priority(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+-int config_parse_fsck_passno(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_kill_signal(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_exec_mount_flags(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+ int config_parse_timer(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+diff --git a/src/core/mount.c b/src/core/mount.c
+index 70cd372..88563b3 100644
+--- a/src/core/mount.c
++++ b/src/core/mount.c
+@@ -313,33 +313,6 @@ static int mount_add_device_links(Mount *m) {
+         if (r < 0)
+                 return r;
+ 
+-        if (p->passno > 0 &&
+-            UNIT(m)->manager->running_as == SYSTEMD_SYSTEM) {
+-                char *name;
+-                Unit *fsck;
+-                /* Let's add in the fsck service */
+-
+-                /* aka SPECIAL_FSCK_SERVICE */
+-                name = unit_name_from_path_instance("systemd-fsck", p->what, ".service");
+-                if (!name)
+-                        return -ENOMEM;
+-
+-                r = manager_load_unit_prepare(UNIT(m)->manager, name, NULL, NULL, &fsck);
+-                if (r < 0) {
+-                        log_warning_unit(name,
+-                                         "Failed to prepare unit %s: %s", name, strerror(-r));
+-                        free(name);
+-                        return r;
+-                }
+-                free(name);
+-
+-                SERVICE(fsck)->fsck_passno = p->passno;
+-
+-                r = unit_add_two_dependencies(UNIT(m), UNIT_AFTER, UNIT_REQUIRES, fsck, true);
+-                if (r < 0)
+-                        return r;
+-        }
+-
+         return 0;
+ }
+ 
+@@ -1410,7 +1383,6 @@ static int mount_add_one(
+                 const char *where,
+                 const char *options,
+                 const char *fstype,
+-                int passno,
+                 bool set_flags) {
+         int r;
+         Unit *u;
+@@ -1530,8 +1502,6 @@ static int mount_add_one(
+         free(p->fstype);
+         p->fstype = f;
+ 
+-        p->passno = passno;
+-
+         if (load_extras) {
+                 r = mount_add_extras(MOUNT(u));
+                 if (r < 0)
+@@ -1601,7 +1571,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
+                 if (!d || !p)
+                         return log_oom();
+ 
+-                k = mount_add_one(m, d, p, o, fstype, 0, set_flags);
++                k = mount_add_one(m, d, p, o, fstype, set_flags);
+                 if (k < 0)
+                         r = k;
+         }
+diff --git a/src/core/mount.h b/src/core/mount.h
+index 7cd4320..a955069 100644
+--- a/src/core/mount.h
++++ b/src/core/mount.h
+@@ -58,7 +58,6 @@ typedef struct MountParameters {
+         char *what;
+         char *options;
+         char *fstype;
+-        int passno;
+ } MountParameters;
+ 
+ typedef enum MountResult {
+diff --git a/src/core/service.c b/src/core/service.c
+index 96ed2d3..ce75757 100644
+--- a/src/core/service.c
++++ b/src/core/service.c
+@@ -1056,48 +1056,6 @@ static int service_load_sysv(Service *s) {
+ }
+ #endif
+ 
+-static int fsck_fix_order(Service *s) {
+-        Unit *other;
+-        int r;
+-
+-        assert(s);
+-
+-        if (s->fsck_passno <= 0)
+-                return 0;
+-
+-        /* For each pair of services where both have an fsck priority
+-         * we order things based on it. */
+-
+-        LIST_FOREACH(units_by_type, other, UNIT(s)->manager->units_by_type[UNIT_SERVICE]) {
+-                Service *t;
+-                UnitDependency d;
+-
+-                t = SERVICE(other);
+-
+-                if (s == t)
+-                        continue;
+-
+-                if (UNIT(t)->load_state != UNIT_LOADED)
+-                        continue;
+-
+-                if (t->fsck_passno <= 0)
+-                        continue;
+-
+-                if (t->fsck_passno < s->fsck_passno)
+-                        d = UNIT_AFTER;
+-                else if (t->fsck_passno > s->fsck_passno)
+-                        d = UNIT_BEFORE;
+-                else
+-                        continue;
+-
+-                r = unit_add_dependency(UNIT(s), d, UNIT(t), true);
+-                if (r < 0)
+-                        return r;
+-        }
+-
+-        return 0;
+-}
+-
+ static int service_verify(Service *s) {
+         assert(s);
+ 
+@@ -1254,10 +1212,6 @@ static int service_load(Unit *u) {
+                         return r;
+ #endif
+ 
+-                r = fsck_fix_order(s);
+-                if (r < 0)
+-                        return r;
+-
+                 if (s->bus_name)
+                         if ((r = unit_watch_bus_name(u, s->bus_name)) < 0)
+                                 return r;
+@@ -1381,11 +1335,6 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
+                         prefix, s->sysv_runlevels);
+ #endif
+ 
+-        if (s->fsck_passno > 0)
+-                fprintf(f,
+-                        "%sFsckPassNo: %i\n",
+-                        prefix, s->fsck_passno);
+-
+         if (s->status_text)
+                 fprintf(f, "%sStatus Text: %s\n",
+                         prefix, s->status_text);
+diff --git a/src/core/service.h b/src/core/service.h
+index ce5b5e0..37fa6ff 100644
+--- a/src/core/service.h
++++ b/src/core/service.h
+@@ -157,8 +157,6 @@ struct Service {
+         pid_t main_pid, control_pid;
+         int socket_fd;
+ 
+-        int fsck_passno;
+-
+         bool permissions_start_only;
+         bool root_directory_start_only;
+         bool remain_after_exit;
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0006-efi-boot-generator-hookup-to-fsck.patch b/abs/core/systemd/0006-efi-boot-generator-hookup-to-fsck.patch
new file mode 100644
index 0000000..3830ecf
--- /dev/null
+++ b/abs/core/systemd/0006-efi-boot-generator-hookup-to-fsck.patch
@@ -0,0 +1,81 @@
+From d09ee17da21b7ca2259067ac4e54f8a1cc3c0fc0 Mon Sep 17 00:00:00 2001
+From: Tom Gundersen <teg@jklm.no>
+Date: Sat, 5 Oct 2013 17:32:21 +0200
+Subject: [PATCH 6/7] efi-boot-generator: hookup to fsck
+
+---
+ TODO                                        |  1 -
+ src/efi-boot-generator/efi-boot-generator.c | 26 ++++++++++++++++++++++----
+ 2 files changed, 22 insertions(+), 5 deletions(-)
+
+diff --git a/TODO b/TODO
+index f0060d9..814d82d 100644
+--- a/TODO
++++ b/TODO
+@@ -308,7 +308,6 @@ Features:
+ * introduce ExecCondition= in services
+ 
+ * EFI:
+-  - fsck hookup for the ESP mount is missing
+   - write man page for efi boot generator
+   - honor language efi variables for default language selection (if there are any?)
+   - honor timezone efi variables for default timezone selection (if there are any?)
+diff --git a/src/efi-boot-generator/efi-boot-generator.c b/src/efi-boot-generator/efi-boot-generator.c
+index 05b95ed..e20d325 100644
+--- a/src/efi-boot-generator/efi-boot-generator.c
++++ b/src/efi-boot-generator/efi-boot-generator.c
+@@ -26,13 +26,14 @@
+ #include "path-util.h"
+ #include "util.h"
+ #include "mkdir.h"
++#include "unit-name.h"
+ 
+ static const char *arg_dest = "/tmp";
+ 
+ int main(int argc, char *argv[]) {
+         int r = EXIT_SUCCESS;
+         sd_id128_t id;
+-        _cleanup_free_ char *name = NULL;
++        _cleanup_free_ char *name = NULL, *what = NULL, *fsck = NULL;
+         _cleanup_fclose_ FILE *f = NULL;
+ 
+         if (argc > 1 && argc != 4) {
+@@ -75,15 +76,32 @@ int main(int argc, char *argv[]) {
+                 return EXIT_FAILURE;
+         }
+ 
++        r = asprintf(&what,
++                     "/dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
++                     SD_ID128_FORMAT_VAL(id));
++        if (r < 0) {
++                log_oom();
++                return EXIT_FAILURE;
++        }
++
++        fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
++        if (!fsck) {
++                log_oom();
++                return EXIT_FAILURE;
++        }
++
+         fprintf(f,
+                 "# Automatially generated by systemd-efi-boot-generator\n\n"
+                 "[Unit]\n"
+-                "Description=EFI System Partition\n\n"
++                "Description=EFI System Partition\n"
++                "Requires=%s\n"
++                "After=%s\n"
++                "\n"
+                 "[Mount]\n"
+                 "Where=/boot\n"
+-                "What=/dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n"
++                "What=%s\n"
+                 "Options=umask=0077\n",
+-                SD_ID128_FORMAT_VAL(id));
++                fsck, fsck, what);
+ 
+         free(name);
+         name = strjoin(arg_dest, "/boot.automount", NULL);
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/0007-fsck-root-only-run-when-requested-in-fstab.patch b/abs/core/systemd/0007-fsck-root-only-run-when-requested-in-fstab.patch
new file mode 100644
index 0000000..112b5b5
--- /dev/null
+++ b/abs/core/systemd/0007-fsck-root-only-run-when-requested-in-fstab.patch
@@ -0,0 +1,95 @@
+From a7623afb7a48ab1d7b5b24fbd5f1033acfb2301c Mon Sep 17 00:00:00 2001
+From: Tom Gundersen <teg@jklm.no>
+Date: Sat, 19 Oct 2013 11:38:42 +0200
+Subject: [PATCH 7/7] fsck-root: only run when requested in fstab
+
+fsck-root is redundant in case an initrd is used, or in case the rootfs
+is never remounted 'rw', so the new default is the correct behavior for
+most users. For the rest, they should enable it in fstab.
+---
+ Makefile.am                           |  1 -
+ man/systemd-fsck@.service.xml         |  4 +++-
+ src/fstab-generator/fstab-generator.c | 31 ++++++++++++++++++++++---------
+ 3 files changed, 25 insertions(+), 11 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index ca01179..a29a32a 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -4447,7 +4447,6 @@ SYSINIT_TARGET_WANTS += \
+ 	systemd-update-utmp.service
+ LOCAL_FS_TARGET_WANTS += \
+ 	systemd-remount-fs.service \
+-	systemd-fsck-root.service \
+ 	tmp.mount
+ MULTI_USER_TARGET_WANTS += \
+ 	getty.target \
+diff --git a/man/systemd-fsck@.service.xml b/man/systemd-fsck@.service.xml
+index 17bd1c0..811392b 100644
+--- a/man/systemd-fsck@.service.xml
++++ b/man/systemd-fsck@.service.xml
+@@ -63,7 +63,9 @@
+                 check. <filename>systemd-fsck-root.service</filename> is
+                 responsible for file system checks on the root
+                 file system. The root file system check is performed
+-                before the other file systems.</para>
++                before the other file systems. Either service is enabled
++                at boot if passno in <filename>/etc/fstab</filename> for
++                the filesystem is set to a value greater than zero.</para>
+ 
+                 <para><filename>systemd-fsck</filename> will
+                 forward file system checking progress to the
+diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
+index 77247de..78d7609 100644
+--- a/src/fstab-generator/fstab-generator.c
++++ b/src/fstab-generator/fstab-generator.c
+@@ -210,17 +210,29 @@ static int add_mount(
+                         post);
+ 
+         if (passno > 0) {
+-                _cleanup_free_ char *fsck = NULL;
++                if (streq(where, "/")) {
++                        lnk = strjoin(arg_dest, "/", SPECIAL_LOCAL_FS_TARGET, ".wants/", "systemd-fsck-root.service", NULL);
++                        if (!lnk)
++                                return log_oom();
+ 
+-                fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
+-                if (!fsck)
+-                        return log_oom();
++                        mkdir_parents_label(lnk, 0755);
++                        if (symlink("systemd-fsck-root.service", lnk) < 0) {
++                                log_error("Failed to create symlink %s: %m", lnk);
++                                return -errno;
++                        }
++                } else {
++                        _cleanup_free_ char *fsck = NULL;
+ 
+-                fprintf(f,
+-                        "Requires=%s\n"
+-                        "After=%s\n",
+-                        fsck,
+-                        fsck);
++                        fsck = unit_name_from_path_instance("systemd-fsck", what, ".service");
++                        if (!fsck)
++                                return log_oom();
++
++                        fprintf(f,
++                                "Requires=%s\n"
++                                "After=%s\n",
++                                fsck,
++                                fsck);
++                }
+         }
+ 
+ 
+@@ -248,6 +260,7 @@ static int add_mount(
+ 
+         if (!noauto) {
+                 if (post) {
++                        free(lnk);
+                         lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
+                         if (!lnk)
+                                 return log_oom();
+-- 
+1.8.5.1
+
diff --git a/abs/core/systemd/PKGBUILD b/abs/core/systemd/PKGBUILD
old mode 100644
new mode 100755
index d677cfc..de605e8
--- a/abs/core/systemd/PKGBUILD
+++ b/abs/core/systemd/PKGBUILD
@@ -1,103 +1,140 @@
 # Maintainer: Dave Reisner <dreisner@archlinux.org>
-# Contributor: Tom Gundersen <teg@jklm.no>
+# Maintainer: Tom Gundersen <teg@jklm.no>
 
 pkgbase=systemd
-pkgname=('systemd' 'libsystemd' 'systemd-tools' 'systemd-sysvcompat')
-pkgver=187
-pkgrel=2
+pkgname=('systemd' 'systemd-sysvcompat')
+pkgver=208
+pkgrel=4
 arch=('i686' 'x86_64')
 url="http://www.freedesktop.org/wiki/Software/systemd"
-license=('GPL2' 'LGPL2.1' 'MIT')
 makedepends=('acl' 'cryptsetup' 'dbus-core' 'docbook-xsl' 'gobject-introspection' 'gperf'
-             'gtk-doc' 'intltool' 'kmod' 'libcap' 'libxslt' 'linux-api-headers' 'pam' 'xz')
-options=('!libtool')
+             'gtk-doc' 'intltool' 'kmod' 'libcap' 'libgcrypt'  'libmicrohttpd' 'libxslt'
+             'linux-api-headers' 'pam' 'python2' 'quota-tools' 'xz')
+options=('strip' 'debug')
 source=("http://www.freedesktop.org/software/$pkgname/$pkgname-$pkgver.tar.xz"
         'initcpio-hook-udev'
+        'initcpio-install-systemd'
         'initcpio-install-udev'
-        'initcpio-install-timestamp'
-        '0001-Reinstate-TIMEOUT-handling.patch'
-        'locale.sh')
-md5sums=('26606e3c84448800ef0b3ffd57e6e8b6'
-         'e99e9189aa2f6084ac28b8ddf605aeb8'
-         '59e91c4d7a69b7bf12c86a9982e37ced'
-         'df69615503ad293c9ddf9d8b7755282d'
-         '5543be25f205f853a21fa5ee68e03f0d'
-         'f15956945052bb911e5df81cf5e7e5dc')
+        '0001-fix-lingering-references-to-var-lib-backlight-random.patch'
+        '0001-mount-check-for-NULL-before-reading-pm-what.patch'
+        '0001-shared-util-fix-off-by-one-error-in-tag_to_udev_node.patch'
+        '0001-login-Don-t-stop-a-running-user-manager-from-garbage.patch'
+        '0001-fstab-generator-When-parsing-the-root-cmdline-option.patch'
+        '0002-fstab-generator-Generate-explicit-dependencies-on-sy.patch'
+        '0003-gpt-auto-generator-Generate-explicit-dependencies-on.patch'
+        '0004-Remove-FsckPassNo-from-systemd-fsck-root.service.patch'
+        '0005-mount-service-drop-FsckPassNo-support.patch'
+        '0006-efi-boot-generator-hookup-to-fsck.patch'
+        '0007-fsck-root-only-run-when-requested-in-fstab.patch')
+
+prepare() {
+  cd "$pkgname-$pkgver"
+  patch -Np1 < "$srcdir"/0001-fix-lingering-references-to-var-lib-backlight-random.patch
+  patch -Np1 < "$srcdir"/0001-mount-check-for-NULL-before-reading-pm-what.patch
+  patch -Np1 < "$srcdir"/0001-shared-util-fix-off-by-one-error-in-tag_to_udev_node.patch
+  # Fix lingering user managers
+  patch -Np1 < "$srcdir"/0001-login-Don-t-stop-a-running-user-manager-from-garbage.patch
+  # Backport changes in fstab passno handling
+  # Basically, we only need 0001 and 0007, but 0007 is based on earlier patches,
+  # and it doesn't hurt to backport them all.
+  patch -Np1 < "$srcdir"/0001-fstab-generator-When-parsing-the-root-cmdline-option.patch
+  patch -Np1 < "$srcdir"/0002-fstab-generator-Generate-explicit-dependencies-on-sy.patch
+  patch -Np1 < "$srcdir"/0003-gpt-auto-generator-Generate-explicit-dependencies-on.patch
+  patch -Np1 < "$srcdir"/0004-Remove-FsckPassNo-from-systemd-fsck-root.service.patch
+  patch -Np1 < "$srcdir"/0005-mount-service-drop-FsckPassNo-support.patch
+  patch -Np1 < "$srcdir"/0006-efi-boot-generator-hookup-to-fsck.patch
+  patch -Np1 < "$srcdir"/0007-fsck-root-only-run-when-requested-in-fstab.patch
+
+  autoreconf
+}
 
 build() {
   cd "$pkgname-$pkgver"
 
-  # still waiting on ipw2x00 to get fixed...
-  patch -Np1 <"$srcdir/0001-Reinstate-TIMEOUT-handling.patch"
-
   ./configure \
       --libexecdir=/usr/lib \
       --localstatedir=/var \
       --sysconfdir=/etc \
-      --enable-split-usr \
       --enable-introspection \
       --enable-gtk-doc \
       --disable-audit \
       --disable-ima \
-      --with-pamlibdir=/usr/lib/security \
-      --with-distro=arch \
-      --with-usb-ids-path=/usr/share/hwdata/usb.ids \
-      --with-pci-ids-path=/usr/share/hwdata/pci.ids \
-      --with-firmware-path=/usr/lib/firmware/updates:/lib/firmware/updates:/usr/lib/firmware:/lib/firmware
+      --with-sysvinit-path= \
+      --with-sysvrcnd-path= \
+      --with-firmware-path="/usr/lib/firmware/updates:/usr/lib/firmware"
 
   make
 }
 
+check() {
+  make -C "$pkgname-$pkgver" check || :
+}
+
 package_systemd() {
   pkgdesc="system and service manager"
-  depends=('acl' 'dbus-core' "libsystemd=$pkgver" 'kmod' 'libcap' 'pam'
-           "systemd-tools=$pkgver" 'util-linux' 'xz')
-  optdepends=('initscripts: legacy support for hostname and vconsole setup'
-              'initscripts-systemd: legacy generator for initialization scripts'
-              'python2-cairo: systemd-analyze'
-              'python2-dbus: systemd-analyze'
-              'systemd-arch-units: collection of native unit files for Arch daemon/init scripts'
+  license=('GPL2' 'LGPL2.1' 'MIT')
+  depends=('acl' 'bash' 'dbus-core' 'glib2' 'kbd' 'kmod' 'hwids' 'libcap' 'libgcrypt'
+           'pam' 'util-linux' 'xz')
+  provides=("libsystemd=$pkgver" 'nss-myhostname' "systemd-tools=$pkgver" "udev=$pkgver"
+            'libgudev-1.0.so' 'libsystemd-daemon.so' 'libsystemd-id128.so'
+            'libsystemd-journal.so' 'libsystemd-login.so' 'libudev.so')
+  replaces=('libsystemd' 'nss-myhostname' 'systemd-tools' 'udev')
+  conflicts=('libsystemd' 'nss-myhostname' 'systemd-tools' 'udev')
+  optdepends=('cryptsetup: required for encrypted block devices'
+              'libmicrohttpd: systemd-journal-gatewayd'
+              'quota-tools: kernel-level quota management'
+              'python2: systemd library bindings'
               'systemd-sysvcompat: symlink package to provide sysvinit binaries')
   backup=(etc/dbus-1/system.d/org.freedesktop.systemd1.conf
           etc/dbus-1/system.d/org.freedesktop.hostname1.conf
           etc/dbus-1/system.d/org.freedesktop.login1.conf
           etc/dbus-1/system.d/org.freedesktop.locale1.conf
+          etc/dbus-1/system.d/org.freedesktop.machine1.conf
           etc/dbus-1/system.d/org.freedesktop.timedate1.conf
+          etc/pam.d/systemd-user
+          etc/systemd/bootchart.conf
+          etc/systemd/journald.conf
+          etc/systemd/logind.conf
           etc/systemd/system.conf
           etc/systemd/user.conf
-          etc/systemd/logind.conf
-          etc/systemd/journald.conf)
+          etc/udev/udev.conf)
   install="systemd.install"
 
   make -C "$pkgname-$pkgver" DESTDIR="$pkgdir" install
 
   printf "d /run/console 0755 root root\n" > "$pkgdir/usr/lib/tmpfiles.d/console.conf"
 
-  install -dm755 "$pkgdir/bin"
-  ln -s ../usr/lib/systemd/systemd "$pkgdir/bin/systemd"
-
-  # move bash-completion and symlink for loginctl
-  install -Dm644 "$pkgdir/etc/bash_completion.d/systemd-bash-completion.sh" \
-    "$pkgdir/usr/share/bash-completion/completions/systemctl"
-  ln -s systemctl "$pkgdir/usr/share/bash-completion/completions/loginctl"
-  rm -rf "$pkgdir/etc/bash_completion.d"
+  # fix .so links in manpage stubs
+  find "$pkgdir/usr/share/man" -type f -name '*.[[:digit:]]' \
+      -exec sed -ri '1s|^\.so (.*)\.([0-9]+)|.so man\2/\1.\2|' {} +
 
   # don't write units to /etc by default -- we'll enable this on post_install
   # as a sane default
   rm "$pkgdir/etc/systemd/system/getty.target.wants/getty@tty1.service"
   rmdir "$pkgdir/etc/systemd/system/getty.target.wants"
 
-  # fix systemd-analyze for python2. the 'plot' verb does not work
-  # with py3k due to a bug in python-cairo
-  sed -i '1s/python$/python2/' "$pkgdir/usr/bin/systemd-analyze"
+  # get rid of RPM macros
+  rm -r "$pkgdir/usr/lib/rpm"
+
+  # add back tmpfiles.d/legacy.conf
+  install -m644 "systemd-$pkgver/tmpfiles.d/legacy.conf" "$pkgdir/usr/lib/tmpfiles.d"
+
+  # Replace dialout/tape/cdrom group in rules with uucp/storage/optical group
+  sed -i 's#GROUP="dialout"#GROUP="uucp"#g;
+          s#GROUP="tape"#GROUP="storage"#g;
+          s#GROUP="cdrom"#GROUP="optical"#g' "$pkgdir"/usr/lib/udev/rules.d/*.rules
 
-  ### split off libsystemd (libs, includes, pkgconfig, man3)
-  rm -rf "$srcdir/_libsystemd"
-  install -dm755 "$srcdir"/_libsystemd/usr/{include,lib/pkgconfig}
-  cd "$srcdir"/_libsystemd
-  mv "$pkgdir/usr/lib"/libsystemd-*.so* usr/lib
-  mv "$pkgdir/usr/include/systemd" usr/include
-  mv "$pkgdir/usr/lib/pkgconfig"/libsystemd-*.pc usr/lib/pkgconfig
+  # add mkinitcpio hooks
+  install -Dm644 "$srcdir/initcpio-install-systemd" "$pkgdir/usr/lib/initcpio/install/systemd"
+  install -Dm644 "$srcdir/initcpio-install-udev" "$pkgdir/usr/lib/initcpio/install/udev"
+  install -Dm644 "$srcdir/initcpio-hook-udev" "$pkgdir/usr/lib/initcpio/hooks/udev"
+
+  # ensure proper permissions for /var/log/journal
+  chown root:systemd-journal "$pkgdir/var/log/journal"
+  chmod 2755 "$pkgdir/var/log/journal"
+
+  # fix pam file
+  sed 's|system-auth|system-login|g' -i "$pkgdir/etc/pam.d/systemd-user"
 
   ### split out manpages for sysvcompat
   rm -rf "$srcdir/_sysvcompat"
@@ -105,105 +142,42 @@ package_systemd() {
   mv "$pkgdir"/usr/share/man/man8/{telinit,halt,reboot,poweroff,runlevel,shutdown}.8 \
      "$srcdir"/_sysvcompat/usr/share/man/man8
 
-  ### split out systemd-tools/udev
-  rm -rf "$srcdir/_tools"
-  install -dm755 \
-      "$srcdir"/_tools/etc/udev \
-      "$srcdir"/_tools/usr/bin \
-      "$srcdir"/_tools/usr/include \
-      "$srcdir"/_tools/usr/lib/udev \
-      "$srcdir"/_tools/usr/lib/systemd/system/{sysinit,sockets}.target.wants \
-      "$srcdir"/_tools/usr/lib/girepository-1.0 \
-      "$srcdir"/_tools/usr/share/pkgconfig \
-      "$srcdir"/_tools/usr/share/gir-1.0 \
-      "$srcdir"/_tools/usr/share/gtk-doc/html/{g,lib}udev \
-      "$srcdir"/_tools/usr/share/man/man{1,5,7,8}
-
-  cd "$srcdir/_tools"
-  mv "$pkgdir"/etc/udev etc
-  mv "$pkgdir"/etc/{binfmt,modules-load,sysctl,tmpfiles}.d etc
-  mv "$pkgdir"/usr/bin/udevadm usr/bin
-  mv "$pkgdir"/usr/bin/systemd-machine-id-setup usr/bin
-  mv "$pkgdir"/usr/lib/pkgconfig usr/lib
-  mv "$pkgdir"/usr/lib/systemd/systemd-udevd usr/lib/systemd
-  mv "$pkgdir"/usr/lib/systemd/system/systemd-udev* usr/lib/systemd/system
-  mv "$pkgdir"/usr/lib/systemd/system/sysinit.target.wants/systemd-udev* usr/lib/systemd/system/sysinit.target.wants
-  mv "$pkgdir"/usr/lib/systemd/system/sockets.target.wants/systemd-udev* usr/lib/systemd/system/sockets.target.wants
-  mv "$pkgdir"/usr/lib/lib{,g}udev* usr/lib
-  mv "$pkgdir"/usr/lib/{binfmt,sysctl,modules-load,tmpfiles}.d usr/lib
-  mv "$pkgdir"/usr/lib/udev usr/lib
-  mv "$pkgdir"/usr/include/{libudev.h,gudev-1.0} usr/include
-  mv "$pkgdir"/usr/lib/girepository-1.0 usr/lib
-  mv "$pkgdir"/usr/share/pkgconfig/udev.pc usr/share/pkgconfig
-  mv "$pkgdir"/usr/share/gir-1.0 usr/share
-  mv "$pkgdir"/usr/share/gtk-doc/html/{g,lib}udev usr/share/gtk-doc/html
-  mv "$pkgdir"/usr/share/man/man7/udev.7 usr/share/man/man7
-  mv "$pkgdir"/usr/share/man/man8/{systemd-{tmpfiles,udevd},udevadm}.8 usr/share/man/man8
-  mv "$pkgdir"/usr/share/man/man1/systemd-{ask-password,delta,detect-virt,machine-id-setup}.1 usr/share/man/man1
-  mv "$pkgdir"/usr/share/man/man5/{binfmt,modules-load,sysctl,tmpfiles}.d.5 usr/share/man/man5
-  mv "$pkgdir"/usr/share/man/man5/{hostname,{vconsole,locale}.conf,crypttab}.5 usr/share/man/man5
-  mv "$pkgdir"/usr/bin/systemd-{ask-password,delta,detect-virt,tmpfiles,tty-ask-password-agent} usr/bin
-  mv "$pkgdir"/usr/lib/systemd/systemd-{ac-power,binfmt,cryptsetup,modules-load,random-seed,remount-fs,reply-password,sysctl,timestamp,vconsole-setup} usr/lib/systemd
+  # include MIT license, since it's technically custom
+  install -Dm644 "$srcdir/$pkgname-$pkgver/LICENSE.MIT" \
+      "$pkgdir/usr/share/licenses/systemd/LICENSE.MIT"
 }
 
 package_systemd-sysvcompat() {
   pkgdesc="sysvinit compat for systemd"
-  conflicts=('sysvinit' 'initscripts')
+  license=('GPL2')
+  groups=('base')
+  conflicts=('sysvinit')
+  depends=('systemd')
 
   mv "$srcdir/_sysvcompat"/* "$pkgdir"
 
-  install -dm755 "$pkgdir/sbin"
-  for tool in runlevel reboot shutdown poweroff halt telinit; do
-    ln -s '/usr/bin/systemctl' "$pkgdir/sbin/$tool"
+  install -dm755 "$pkgdir/usr/bin"
+  #for tool in runlevel reboot shutdown poweroff halt telinit; do
+  for tool in runlevel telinit; do
+    ln -s 'systemctl' "$pkgdir/usr/bin/$tool"
   done
 
-  ln -s '../usr/lib/systemd/systemd' "$pkgdir/sbin/init"
-
-  install -Dm755 "$srcdir/locale.sh" "$pkgdir/etc/profile.d/locale.sh"
-}
-
-package_libsystemd() {
-  pkgdesc="systemd client libraries"
-  depends=('xz')
-
-  mv "$srcdir/_libsystemd"/* "$pkgdir"
-}
-
-package_systemd-tools() {
-  pkgdesc='standalone tools from systemd'
-  url='http://www.freedesktop.org/wiki/Software/systemd'
-  depends=('acl' 'bash' 'glibc' 'glib2' 'libsystemd' 'kmod' 'hwids' 'util-linux' 'kbd')
-  optdepends=('cryptsetup: required for encrypted block devices')
-  provides=("udev=$pkgver")
-  conflicts=('udev')
-  replaces=('udev')
-  install='systemd-tools.install'
-
-  mv "$srcdir/_tools/"* "$pkgdir"
-
-  # the path to udevadm is hardcoded in some places
-  install -d "$pkgdir/sbin"
-  ln -s ../usr/bin/udevadm "$pkgdir/sbin/udevadm"
-
-  # udevd is no longer udevd because systemd. why isn't udevadm now udevctl?
-  ln -s ../lib/systemd/systemd-udevd "$pkgdir/usr/bin/udevd"
-
-  # add back tmpfiles.d/legacy.conf
-  install -m644 "systemd-$pkgver/tmpfiles.d/legacy.conf" "$pkgdir/usr/lib/tmpfiles.d"
-
-  # Replace dialout/tape/cdrom group in rules with uucp/storage/optical group
-  sed -i 's#GROUP="dialout"#GROUP="uucp"#g;
-          s#GROUP="tape"#GROUP="storage"#g;
-          s#GROUP="cdrom"#GROUP="optical"#g' "$pkgdir"/usr/lib/udev/rules.d/*.rules
-
-  # add mkinitcpio hooks
-  install -Dm644 "$srcdir/initcpio-install-udev" "$pkgdir/usr/lib/initcpio/install/udev"
-  install -Dm644 "$srcdir/initcpio-hook-udev" "$pkgdir/usr/lib/initcpio/hooks/udev"
-  install -Dm644 "$srcdir/initcpio-install-timestamp" "$pkgdir/usr/lib/initcpio/install/timestamp"
-
-  # XXX: kill off coredump rule until the journal can recover coredumps
-  # this file needs to come back as part of systemd, not systemd-tools
-  rm "$pkgdir/usr/lib/sysctl.d/coredump.conf"
+  ln -s '../lib/systemd/systemd' "$pkgdir/usr/bin/init"
 }
 
 # vim: ft=sh syn=sh et
+md5sums=('df64550d92afbffb4f67a434193ee165'
+         '29245f7a240bfba66e2b1783b63b6b40'
+         '8b68b0218a3897d4d37a6ccf47914774'
+         'bde43090d4ac0ef048e3eaee8202a407'
+         '1b191c4e7a209d322675fd199e3abc66'
+         'a693bef63548163ffc165f4c4801ebf7'
+         'ccafe716d87df9c42af0d1960b5a4105'
+         '441e3d464ee6af5fe4af6a8bc10d7980'
+         '718d841203cf2ea9e24a7d0f1d19d48b'
+         '623c77bad0d2968e44963d72924825f1'
+         'e52fc8368853c7800ab03ab8868cfd41'
+         '2096f33bd36dfa0a7f0431d0a429787a'
+         'd2481a6ea199b581e243a950125b0ca6'
+         'c2aee634a3a6c50778968f0d5c756f40'
+         'ef8b8212d504bb73c10bf4e85f0703b2')
diff --git a/abs/core/systemd/initcpio-hook-udev b/abs/core/systemd/initcpio-hook-udev
index 75da7e4..0bc32e0 100644
--- a/abs/core/systemd/initcpio-hook-udev
+++ b/abs/core/systemd/initcpio-hook-udev
@@ -1,7 +1,9 @@
 #!/usr/bin/ash
 
 run_earlyhook() {
-    udevd --daemon --resolve-names=never
+    kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
+    systemd-tmpfiles --prefix=/dev --create
+    /usr/lib/systemd/systemd-udevd --daemon --resolve-names=never
     udevd_running=1
 }
 
diff --git a/abs/core/systemd/initcpio-install-systemd b/abs/core/systemd/initcpio-install-systemd
new file mode 100644
index 0000000..2c59074
--- /dev/null
+++ b/abs/core/systemd/initcpio-install-systemd
@@ -0,0 +1,159 @@
+#!/bin/bash
+
+strip_quotes() {
+  local len=${#1} quotes=$'[\'"]' str=${!1}
+
+  if [[ ${str:0:1} = ${str: -1} && ${str:0:1} = $quotes ]]; then
+    declare -g "$1=${str:1:-1}"
+  fi
+}
+
+add_udev_rule() {
+    # Add an udev rules file to the initcpio image. Dependencies on binaries
+    # will be discovered and added.
+    #   $1: path to rules file (or name of rules file)
+
+    local rules= rule= key= value= binary=
+
+    rules=$(PATH=/usr/lib/udev/rules.d:/lib/udev/rules.d type -P "$1")
+    if [[ -z $rules ]]; then
+        # complain about not found rules
+        return 1
+    fi
+
+    add_file "$rules"
+
+    while IFS=, read -ra rule; do
+        # skip empty lines, comments
+        [[ -z $rule || $rule = @(+([[:space:]])|#*) ]] && continue
+
+        for pair in "${rule[@]}"; do
+            IFS=' =' read -r key value <<< "$pair"
+            case $key in
+                RUN@({program}|+)|IMPORT{program}|ENV{REMOVE_CMD})
+                    strip_quotes 'value'
+                    # just take the first word as the binary name
+                    binary=${value%% *}
+                    if [[ ${binary:0:1} != '/' ]]; then
+                        binary=$(PATH=/usr/lib/udev:/lib/udev type -P "$binary")
+                    fi
+                    add_binary "$binary"
+                    ;;
+            esac
+        done
+    done <"$rules"
+}
+
+add_systemd_unit() {
+    # Add a systemd unit file to the initcpio image. Hard dependencies on binaries
+    # and other unit files will be discovered and added.
+    #   $1: path to rules file (or name of rules file)
+
+    local unit= rule= entry= key= value= binary= dep=
+
+    unit=$(PATH=/usr/lib/systemd/system:/lib/systemd/system type -P "$1")
+    if [[ -z $unit ]]; then
+        # complain about not found unit file
+        return 1
+    fi
+
+    add_file "$unit"
+
+    while IFS='=' read -r key values; do
+        read -ra values <<< "$values"
+
+        case $key in
+            Requires|OnFailure)
+                # only add hard dependencies (not Wants)
+                map add_systemd_unit "${values[@]}"
+                ;;
+            Exec*)
+                # don't add binaries unless they are required
+                if [[ ${values[0]:0:1} != '-' ]]; then
+                    add_binary "${values[0]}"
+                fi
+                ;;
+        esac
+
+    done <"$unit"
+
+    # preserve reverse soft dependency
+    for dep in {/usr,}/lib/systemd/system/*.wants/${unit##*/}; do
+        if [[ -L $dep ]]; then
+            add_symlink "$dep"
+        fi
+    done
+
+    # add hard dependencies
+    if [[ -d $unit.requires ]]; then
+        for dep in "$unit".requires/*; do
+            add_systemd_unit ${dep##*/}
+        done
+    fi
+}
+
+build() {
+    local rules unit
+
+    # from base
+    add_binary /bin/mount
+    add_binary /usr/bin/kmod /usr/bin/modprobe
+
+    # systemd
+    add_binary /usr/lib/systemd/systemd /init
+    add_binary /usr/bin/systemd-tmpfiles
+
+    # generate sysroot.mount and sysroot-usr.mount
+    add_file "/usr/lib/systemd/system-generators/systemd-fstab-generator"
+
+    # udev rules and systemd units
+    map add_udev_rule "$rules" \
+            50-udev-default.rules \
+            60-persistent-storage.rules \
+            64-btrfs.rules \
+            80-drivers.rules \
+            99-systemd.rules \
+
+    map add_systemd_unit \
+            ctrl-alt-del.target \
+            initrd-cleanup.service \
+            initrd-fs.target \
+            initrd-parse-etc.service \
+            initrd-root-fs.target \
+            initrd-switch-root.service \
+            initrd-switch-root.target \
+            initrd-udevadm-cleanup-db.service \
+            initrd.target \
+            kmod-static-nodes.service \
+            sockets.target \
+            systemd-fsck@.service \
+            systemd-journald.service \
+            systemd-tmpfiles-setup-dev.service \
+            systemd-udev-trigger.service \
+            systemd-udevd-control.socket \
+            systemd-udevd-kernel.socket \
+            systemd-udevd.service
+
+    add_symlink "/usr/lib/systemd/system/default.target" "initrd.target"
+
+    # libdbus needs the passwd info of the root user
+    # TODO: make sure this is no longer necessary when systemctl moves to sd-bus
+    add_file "/etc/nsswitch.conf"
+    add_file "/etc/passwd"
+    add_binary "$(readlink -f /usr/lib/libnss_files.so)"
+
+    # udev wants /etc/group since it doesn't launch with --resolve-names=never
+    add_file "/etc/group"
+}
+
+help() {
+    cat <<HELPEOF
+This will install a basic systemd setup in your initramfs, and is meant to
+replace the 'base', 'usr', 'udev' and 'timestamp' hooks. Other hooks with runtime
+components will need to be ported, and will not work as intended. You also may
+wish to still include the 'base' hook (before this hook) to ensure that a
+rescue shell exists on your initramfs.
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
diff --git a/abs/core/systemd/initcpio-install-timestamp b/abs/core/systemd/initcpio-install-timestamp
deleted file mode 100644
index 259cc70..0000000
--- a/abs/core/systemd/initcpio-install-timestamp
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-build() {
-    add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/systemd-timestamp
-}
-
-help() {
-    cat <<HELPEOF
-Provides support for RD_TIMESTAMP in early userspace, which can be read by a
-program such as systemd-analyze to determine boot time.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/abs/core/systemd/initcpio-install-udev b/abs/core/systemd/initcpio-install-udev
index 7624299..419c19e 100644
--- a/abs/core/systemd/initcpio-install-udev
+++ b/abs/core/systemd/initcpio-install-udev
@@ -4,10 +4,11 @@ build() {
     local rules tool
 
     add_file "/etc/udev/udev.conf"
-    add_binary /usr/lib/systemd/systemd-udevd /usr/bin/udevd
+    add_binary /usr/lib/systemd/systemd-udevd
     add_binary /usr/bin/udevadm
+    add_binary /usr/bin/systemd-tmpfiles
 
-    for rules in 50-udev-default.rules 60-persistent-storage.rules 80-drivers.rules; do
+    for rules in 50-udev-default.rules 60-persistent-storage.rules 64-btrfs.rules 80-drivers.rules; do
         add_file "/usr/lib/udev/rules.d/$rules"
     done
     for tool in ata_id scsi_id; do
diff --git a/abs/core/systemd/locale.sh b/abs/core/systemd/locale.sh
deleted file mode 100644
index a4c413e..0000000
--- a/abs/core/systemd/locale.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-if [ ! -r /etc/locale.conf ]; then
-  return
-fi
-
-. /etc/locale.conf
-
-if [ "${LANG+x}" = 'x' ]; then
-  export LANG
-fi
-
-if [ "${LC_CTYPE+x}" = 'x' ]; then
-  export LC_CTYPE
-fi
-
-if [ "${LC_NUMERIC+x}" = 'x' ]; then
-  export LC_NUMERIC
-fi
-
-if [ "${LC_TIME+x}" = 'x' ]; then
-  export LC_TIME
-fi
-
-if [ "${LC_COLLATE+x}" = 'x' ]; then
-  export LC_COLLATE
-fi
-
-if [ "${LC_MONETARY+x}" = 'x' ]; then
-  export LC_MONETARY
-fi
-
-if [ "${LC_MESSAGES+x}" = 'x' ]; then
-  export LC_MESSAGES
-fi
-
-if [ "${LC_PAPER+x}" = 'x' ]; then
-  export LC_PAPER
-fi
-
-if [ "${LC_NAME+x}" = 'x' ]; then
-  export LC_NAME
-fi
-
-if [ "${LC_ADDRESS+x}" = 'x' ]; then
-  export LC_ADDRESS
-fi
-
-if [ "${LC_TELEPHONE+x}" = 'x' ]; then
-  export LC_TELEPHONE
-fi
-
-if [ "${LC_MEASUREMENT+x}" = 'x' ]; then
-  export LC_MEASUREMENT
-fi
-
-if [ "${LC_IDENTIFICATION+x}" = 'x' ]; then
-  export LC_IDENTIFICATION
-fi
-
diff --git a/abs/core/systemd/systemd-187-2.src.tar.gz b/abs/core/systemd/systemd-187-2.src.tar.gz
deleted file mode 120000
index 980a3eb..0000000
--- a/abs/core/systemd/systemd-187-2.src.tar.gz
+++ /dev/null
@@ -1 +0,0 @@
-/data/pkg_repo/src_packages/systemd-187-2.src.tar.gz
\ No newline at end of file
diff --git a/abs/core/systemd/systemd-tools.install b/abs/core/systemd/systemd-tools.install
deleted file mode 100644
index 7d0bd87..0000000
--- a/abs/core/systemd/systemd-tools.install
+++ /dev/null
@@ -1,35 +0,0 @@
-# arg 1:  the new package version
-# arg 2:  the old package version
-
-post_install() {
-  systemd-machine-id-setup
-}
-
-post_upgrade() {
-  systemd-machine-id-setup
-
-  if [ "$(vercmp $2 174)" -lt 0 ]; then
-    echo " * We now use upstream rules for assigning devices to the 'disk', 'optical',"
-    echo "   'scanner' and 'video' groups. Beware of any changes."
-    echo " * We no longer create symlinks from /dev/<dev> to /dev/<dev>0."
-    echo " * For security reasons, we no longer add devices to the 'storage' group. Use"
-    echo "   udisks and friends, or add custom rules to /etc/udev.d/rules/, if you want"
-    echo "   this functionality back."
-    echo " * We no longer create the static nodes on install needed for an initrd-less"
-    echo "   boot where devtmpfs is not mounted by the kernel, this only affects fresh"
-    echo "   installs."
-  fi
-  if [ "$(vercmp $2 175)" -lt 0 ]; then
-    echo " * devtmpfs support is now a hard requirement. Users of the official Arch"
-    echo "   kernels have this enabled."
-  fi
-  if [ "$(vercmp $2 181)" -lt 0 ]; then
-    echo " * udev-compat has been removed, and should be uninstalled."
-    echo " * Framebuffers are no longer blacklisted by default."
-    echo " * binaries moved from /sbin to /usr/bin"
-  fi
-  if [ "$(vercmp $2 181-3)" -lt 0 ]; then
-    echo " * if your kernel does not provide /dev/loop-control, you need to manually"
-    echo "   load the 'loop' module before using losetup"
-  fi
-}
diff --git a/abs/core/systemd/systemd.install b/abs/core/systemd/systemd.install
index e369f09..1e79585 100644
--- a/abs/core/systemd/systemd.install
+++ b/abs/core/systemd/systemd.install
@@ -4,33 +4,116 @@ sd_booted() {
   [ -e sys/fs/cgroup/systemd ]
 }
 
+add_privs() {
+  if ! setcap "$2" "$1" 2>/dev/null; then
+    echo "==> Warning: setcap failed, falling back to setuid root on /$1"
+    chmod u+s "$1"
+  fi
+}
+
+post_common() {
+  systemd-machine-id-setup
+
+  add_privs usr/bin/systemd-detect-virt 'cap_dac_override,cap_sys_ptrace+ep'
+
+  udevadm hwdb --update
+  journalctl --update-catalog
+
+  if sd_booted; then
+    systemctl --system daemon-reexec
+  fi
+}
+
+mask_net_naming() {
+  if [ ! -e etc/udev/rules.d/80-net-name-slot.rules ]; then
+    printf >etc/udev/rules.d/80-net-name-slot.rules '# %s\n' \
+      "This file masks persistent renaming rules for network devices. If you" \
+      "delete this file, /usr/lib/udev/rules.d/80-net-name-slot.rules may" \
+      "rename network devices according to ID_NET_NAME_{ONBOARD,SLOT,PATH}" \
+      "properties of your network devices, with priority in that order. See" \
+      "the output of 'udevadm test-builtin net_id /sys/class/net/\$interface'" \
+      "for details on what that new name might be." \
+      "" \
+      "http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
+  fi
+}
+
+_208_changes() {
+  chown root:systemd-journal var/log/journal
+  chmod 2755 var/log/journal
+
+  if [ -e var/lib/backlight ] && [ ! -e var/lib/systemd/backlight ]; then
+    mv -T var/lib/backlight var/lib/systemd/backlight
+  fi
+
+  if [ -e var/lib/random-seed ] && [ ! -e var/lib/systemd/random-seed ]; then
+    mv -T var/lib/random-seed var/lib/systemd/random-seed
+  fi
+}
+
 post_install() {
+  post_common
+
   # enable getty@tty1 by default, but don't track the file
-  systemctl enable getty@.service
+  systemctl enable getty@tty1.service
 
-  echo ":: Append 'init=/bin/systemd' to your kernel command line in your"
-  echo "   bootloader to replace sysvinit with systemd"
+  echo ":: Append 'init=/usr/lib/systemd/systemd' to your kernel command line in your"
+  echo "   bootloader to replace sysvinit with systemd, or install systemd-sysvcompat"
 }
 
 post_upgrade() {
-  if sd_booted; then
-    # we moved the binary in 44-2 to /usr, so a reexec leads to a
-    # coredump. refuse this reexec and warn the user that they should
-    # reboot instead.
-    if [ "$(vercmp 44-2 "$2")" -eq 1 ]; then
-      echo "warning: refusing to reexec systemd. the system should be rebooted."
-    else
-      systemctl daemon-reload
-      systemctl daemon-reexec
-    fi
-  fi
+  post_common
 
   # getty@tty1.service is no longer enabled by default, but we don't want to break
   # existing setups.
   if [ "$(vercmp 183 "$2")" -eq 1 ]; then
     # systemctl seems to be whiny on sysvinit. this will succeed unless something
     # horrific happens, so just mask the error.
-    systemctl -q enable getty@.service || true
+    systemctl -q enable getty@tty1.service || true
+  fi
+
+  if [ "$(vercmp 194-4 "$2")" -eq 1 ]; then
+    printf '==> journald now writes to /var/log/journal by default. This can be\n'
+    printf '    controlled with the Storage setting in /etc/systemd/journald.conf\n'
+  fi
+
+  # logind's protocol changed. kindly restart the daemon to avoid locking
+  # out further logins.
+  if [ "$(vercmp 195 "$2")" -eq 1 ]; then
+    if sd_booted; then
+      systemctl restart systemd-logind.service
+    fi
+  fi
+
+  if [ "$(vercmp 196-1 "$2")" -eq 1 ]; then
+    printf '==> The legacy configuration options are no longer supported in rc.conf,\n'
+    printf '    convert your rc.conf to the new configuration formats.\n'
+  fi
+
+  if [ "$(vercmp 197-1 "$2")" -eq 1 ]; then
+    mask_net_naming
+    printf '==> Persistent net naming rules have been shipped as disabled.\n'
+    printf '    See /etc/udev/rules.d/80-net-name-slot.rules for more detail\n'
+  fi
+
+  if [ "$(vercmp 204-1 "$2")" -eq 1 ]; then
+    printf '==> The /bin/systemd symlink has been removed. Any references in your\n'
+    printf '    bootloader (or elsewhere) must be updated to /usr/lib/systemd/systemd.\n'
+  fi
+
+  if [ "$(vercmp 205-1 "$2")" -eq 1 ]; then
+    printf '==> systemd 205 restructures the cgroup hierarchy and changes internal\n'
+    printf '    protocols. You should reboot at your earliest convenience.\n'
+  fi
+
+  if [ "$(vercmp 206-1 "$2")" -eq 1 ]; then
+    printf '==> The "timestamp" hook for mkinitcpio no longer exists. If you used\n'
+    printf '    this hook, you must remove it from /etc/mkinitcpio.conf. A "systemd"\n'
+    printf '    hook has been added which provides this functionality, and more.\n'
+  fi
+
+  if [ "$(vercmp 208-1 "$2")" -eq 1 ]; then
+    _208_changes
   fi
 }
 
-- 
cgit v0.12

