aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-extended/zram/zram_0.2.bb
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2019-10-06 23:00:32 +0200
committerKhem Raj <raj.khem@gmail.com>2019-10-06 18:44:20 -0700
commit501df47c331e851925f1965b547e4d888a89555d (patch)
treebb0ffab1f5b10aa3c3713a55f64203c27ca51497 /meta-oe/recipes-extended/zram/zram_0.2.bb
parent2582668a348b6fcd1377b762ca26a05fb6d14b9d (diff)
downloadmeta-openembedded-contrib-501df47c331e851925f1965b547e4d888a89555d.tar.gz
zram: properly implement systemd service
The systemd service points ot a script which is not installed by zram or any of its dependencies. It seems that the service got migrated without the necessary script. The sysvinit script seems rather dated and initializes multiple zram instances to support multiprocessor systems. This is no longer necessary with modern implementations as newer kernel version support multiple streams by default. Create a modern implementation based on Fedoras zram package. Make use of systemd swap unit files instead of enabling swap directly. This removes the need for util-linux-swaponoff (since swap is now handled by systemd, which presumably depends on swaponoff). However, it adds the dependency to util-linux for zramctl. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-extended/zram/zram_0.2.bb')
-rw-r--r--meta-oe/recipes-extended/zram/zram_0.2.bb50
1 files changed, 50 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/zram/zram_0.2.bb b/meta-oe/recipes-extended/zram/zram_0.2.bb
new file mode 100644
index 0000000000..98c47af7ac
--- /dev/null
+++ b/meta-oe/recipes-extended/zram/zram_0.2.bb
@@ -0,0 +1,50 @@
+SUMMARY = "Linux zram compressed in-memory swap"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+inherit update-rc.d systemd
+
+RDEPENDS_${PN} = "kmod \
+ ${@bb.utils.contains('DISTRO_FEATURES','systemd','util-linux','util-linux-swaponoff',d)}"
+RRECOMMENDS_${PN} = "kernel-module-zram"
+
+PR = "r3"
+
+SRC_URI = " \
+ file://init \
+ file://zram-swap-init \
+ file://zram-swap-deinit \
+ file://zram-swap.service \
+ file://dev-zram0.swap \
+"
+
+do_install () {
+ # Install systemd related configuration file
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
+ install -d ${D}${sysconfdir}/init.d
+ install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/zram
+ fi
+
+ if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+ install -d ${D}${libexecdir}
+ install -m 0755 ${WORKDIR}/zram-swap-init ${D}${libexecdir}
+ install -m 0755 ${WORKDIR}/zram-swap-deinit ${D}${libexecdir}
+ install -d ${D}${systemd_unitdir}/system
+ install -m 0644 ${WORKDIR}/zram-swap.service ${D}${systemd_unitdir}/system/zram-swap.service
+ sed -i -e "s,@LIBEXECDIR@,${libexecdir},g" ${D}${systemd_unitdir}/system/zram-swap.service
+ install -m 0644 ${WORKDIR}/dev-zram0.swap ${D}${systemd_unitdir}/system/dev-zram0.swap
+ fi
+}
+
+FILES_${PN} = " \
+ ${sysconfdir} \
+ ${systemd_unitdir} \
+ ${libexecdir} \
+"
+INITSCRIPT_NAME = "zram"
+INITSCRIPT_PARAMS = "start 05 2 3 4 5 . stop 22 0 1 6 ."
+
+RPROVIDES_${PN} += "${PN}-systemd"
+RREPLACES_${PN} += "${PN}-systemd"
+RCONFLICTS_${PN} += "${PN}-systemd"
+SYSTEMD_SERVICE_${PN} = "dev-zram0.swap"