All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-filesystems][PATCH] btrfsmaintenance: add recipe for btrfsmaintenance scripts
@ 2022-05-12  9:27 Claudius Heine
  0 siblings, 0 replies; only message in thread
From: Claudius Heine @ 2022-05-12  9:27 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Claudius Heine

Btrfs requires regular maintenance in order to self-heal. Other
distributions like OpenSUSE, Debian and Fedora use these scripts to
perform those.

Signed-off-by: Claudius Heine <ch@denx.de>
---
 .../btrfsmaintenance/btrfsmaintenance_0.5.bb  | 62 +++++++++++++++++++
 ...change-sysconfig-path-to-etc-default.patch | 47 ++++++++++++++
 ...ective-to-btrfsmaintenance-refresh.s.patch | 33 ++++++++++
 3 files changed, 142 insertions(+)
 create mode 100644 meta-filesystems/recipes-utils/btrfsmaintenance/btrfsmaintenance_0.5.bb
 create mode 100644 meta-filesystems/recipes-utils/btrfsmaintenance/files/0001-change-sysconfig-path-to-etc-default.patch
 create mode 100644 meta-filesystems/recipes-utils/btrfsmaintenance/files/0002-add-WantedBy-directive-to-btrfsmaintenance-refresh.s.patch

diff --git a/meta-filesystems/recipes-utils/btrfsmaintenance/btrfsmaintenance_0.5.bb b/meta-filesystems/recipes-utils/btrfsmaintenance/btrfsmaintenance_0.5.bb
new file mode 100644
index 000000000..a4573cf59
--- /dev/null
+++ b/meta-filesystems/recipes-utils/btrfsmaintenance/btrfsmaintenance_0.5.bb
@@ -0,0 +1,62 @@
+
+SUMMARY = "Services for periodic btrfs maintenance tasks"
+DESCRIPTION = "A set of scripts supplementing the btrfs filesystem and aims \
+    to automate a few maintenance tasks. This means the scrub, balance, trim \
+    or defragmentation."
+HOMEPAGE = "https://github.com/kdave/btrfsmaintenance"
+LICENSE = "GPL-2.0-only"
+LIC_FILES_CHKSUM = "file://COPYING;md5=892f569a555ba9c07a568a7c0c4fa63a"
+
+SECTION = "base"
+
+DEPENDS = "btrfs-tools"
+
+SRC_URI = "git://github.com/kdave/${BPN};branch=master;protocol=https \
+    file://0001-change-sysconfig-path-to-etc-default.patch \
+    file://0002-add-WantedBy-directive-to-btrfsmaintenance-refresh.s.patch \
+"
+SRCREV = "be42cb6267055d125994abd6927cf3a26deab74c"
+
+UPSTREAM_CHECK_URI = "https://github.com/kdave/${BPN}/tags"
+UPSTREAM_CHECK_REGEX = "${BPN}/releases/tag/v(?P<pver>\d+(?:\.\d+)*)"
+
+RDEPENDS:${PN} = "bash"
+
+S="${WORKDIR}/git"
+
+inherit allarch
+
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+
+do_install() {
+    install -Dm0644 ${S}/btrfsmaintenance-refresh.path \
+        ${D}${systemd_system_unitdir}/btrfsmaintenance-refresh.path
+    install -Dm0644 ${S}/*.timer \
+        ${D}${systemd_system_unitdir}
+    install -Dm0644 ${S}/*.service \
+        ${D}${systemd_system_unitdir}
+
+    install -Dm0644 ${S}/btrfsmaintenance-functions \
+        ${D}${datadir}/${PN}/btrfsmaintenance-functions
+    install -Dm0755 ${S}/*.sh \
+        ${D}${datadir}/${PN}
+
+    install -Dm0644 ${S}/sysconfig.btrfsmaintenance \
+        ${D}${sysconfdir}/default/btrfsmaintenance
+}
+
+inherit systemd
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE:${PN} = " \
+    btrfs-scrub.timer \
+    btrfs-scrub.service \
+    btrfs-trim.timer \
+    btrfs-trim.service \
+    btrfs-balance.timer \
+    btrfs-balance.service \
+    btrfs-defrag.timer \
+    btrfs-defrag.service \
+    btrfsmaintenance-refresh.service \
+    btrfsmaintenance-refresh.path \
+"
diff --git a/meta-filesystems/recipes-utils/btrfsmaintenance/files/0001-change-sysconfig-path-to-etc-default.patch b/meta-filesystems/recipes-utils/btrfsmaintenance/files/0001-change-sysconfig-path-to-etc-default.patch
new file mode 100644
index 000000000..d425206f0
--- /dev/null
+++ b/meta-filesystems/recipes-utils/btrfsmaintenance/files/0001-change-sysconfig-path-to-etc-default.patch
@@ -0,0 +1,47 @@
+From b49dbe17e0d9ae463e5a34e6991aa2d3c70d2fb1 Mon Sep 17 00:00:00 2001
+From: Claudius Heine <ch@denx.de>
+Date: Wed, 11 May 2022 14:33:13 +0200
+Subject: [PATCH] change sysconfig path to /etc/default
+
+OE uses /etc/default for service configuration, not /etc/sysconfig which
+is used by SUSE and RedHat based distributions.
+
+Change the files accordingly
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Claudius Heine <ch@denx.de>
+---
+ btrfsmaintenance-refresh.path    | 4 ++--
+ btrfsmaintenance-refresh.service | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/btrfsmaintenance-refresh.path b/btrfsmaintenance-refresh.path
+index d56ad11..f0b4132 100644
+--- a/btrfsmaintenance-refresh.path
++++ b/btrfsmaintenance-refresh.path
+@@ -1,8 +1,8 @@
+ [Unit]
+-Description=Watch /etc/sysconfig/btrfsmaintenance
++Description=Watch /etc/default/btrfsmaintenance
+ 
+ [Path]
+-PathChanged=/etc/sysconfig/btrfsmaintenance
++PathChanged=/etc/default/btrfsmaintenance
+ 
+ [Install]
+ WantedBy=multi-user.target
+diff --git a/btrfsmaintenance-refresh.service b/btrfsmaintenance-refresh.service
+index 4ed1eb4..d6225a6 100644
+--- a/btrfsmaintenance-refresh.service
++++ b/btrfsmaintenance-refresh.service
+@@ -1,5 +1,5 @@
+ [Unit]
+-Description=Update cron periods from /etc/sysconfig/btrfsmaintenance
++Description=Update cron periods from /etc/default/btrfsmaintenance
+ 
+ [Service]
+ ExecStart=/usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh systemd-timer
+-- 
+2.33.3
+
diff --git a/meta-filesystems/recipes-utils/btrfsmaintenance/files/0002-add-WantedBy-directive-to-btrfsmaintenance-refresh.s.patch b/meta-filesystems/recipes-utils/btrfsmaintenance/files/0002-add-WantedBy-directive-to-btrfsmaintenance-refresh.s.patch
new file mode 100644
index 000000000..0da7992a0
--- /dev/null
+++ b/meta-filesystems/recipes-utils/btrfsmaintenance/files/0002-add-WantedBy-directive-to-btrfsmaintenance-refresh.s.patch
@@ -0,0 +1,33 @@
+From 420ae0f395838b852ae8b8fe5528056c36dc0919 Mon Sep 17 00:00:00 2001
+From: Claudius Heine <ch@denx.de>
+Date: Wed, 11 May 2022 15:14:22 +0200
+Subject: [PATCH] add WantedBy directive to btrfsmaintenance-refresh.service
+
+Just trigger the service on the first boot, to configure services to the
+configuration file deployed in the package, afterwards disable the
+service, so that is only triggered when the configuration file has
+changed.
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Claudius Heine <ch@denx.de>
+---
+ btrfsmaintenance-refresh.service | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/btrfsmaintenance-refresh.service b/btrfsmaintenance-refresh.service
+index d6225a6..58d0e09 100644
+--- a/btrfsmaintenance-refresh.service
++++ b/btrfsmaintenance-refresh.service
+@@ -3,4 +3,8 @@ Description=Update cron periods from /etc/default/btrfsmaintenance
+ 
+ [Service]
+ ExecStart=/usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh systemd-timer
++ExecStart=systemctl disable btrfsmaintenance-refresh.service
+ Type=oneshot
++
++[Install]
++WantedBy=multi-user.target
+-- 
+2.33.3
+
-- 
2.33.3



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-12  9:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12  9:27 [meta-filesystems][PATCH] btrfsmaintenance: add recipe for btrfsmaintenance scripts Claudius Heine

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.