Skip to contentSkip to conversation

util-linux: Add missing MIT license

PATCH New Richard Purdie 1 participant 3 messages Mar 29, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 util-linux: Add missing MIT license

The MIT license was missing from the license list for util-linux. Add a patch, submitted to upstream which adds the missing license mentions.

---
 meta/recipes-core/util-linux/util-linux.inc   |  5 ++-
 .../util-linux/util-linux/mit-license.patch   | 45 +++++++++++++++++++
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-core/util-linux/util-linux/mit-license.patch
meta/recipes-core/util-linux/util-linux.inc +3 -2
index 4e9d22f2690..d96f00fbab5 100644
@@ -6,14 +6,14 @@ disk partitioning, kernel message management, filesystem creation, and system lo
 
 SECTION = "base"
 
-LICENSE = "GPL-1.0-or-later & GPL-2.0-or-later & LGPL-2.1-or-later & BSD-2-Clause & BSD-3-Clause & BSD-4-Clause"
+LICENSE = "GPL-1.0-or-later & GPL-2.0-or-later & LGPL-2.1-or-later & BSD-2-Clause & BSD-3-Clause & BSD-4-Clause & MIT"
 LICENSE:${PN}-fdisk = "GPL-1.0-or-later"
 LICENSE:${PN}-libblkid = "LGPL-2.1-or-later"
 LICENSE:${PN}-libfdisk = "LGPL-2.1-or-later"
 LICENSE:${PN}-libmount = "LGPL-2.1-or-later"
 LICENSE:${PN}-libsmartcols = "LGPL-2.1-or-later"
 
-LIC_FILES_CHKSUM = "file://README.licensing;md5=6b0e0a2320e66e62eef9b8149a6faec4 \
+LIC_FILES_CHKSUM = "file://README.licensing;md5=cc80239f106687ab39ef0271ff5cf4ba \
                     file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
                     file://Documentation/licenses/COPYING.GPL-2.0-or-later;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
                     file://Documentation/licenses/COPYING.LGPL-2.1-or-later;md5=4fbd65380cdd255951079008b364516c \
@@ -29,6 +29,7 @@ LIC_FILES_CHKSUM = "file://README.licensing;md5=6b0e0a2320e66e62eef9b8149a6faec4
 FILESEXTRAPATHS:prepend := "${THISDIR}/util-linux:"
 MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-linux-${PV}.tar.xz \
+           file://mit-license.patch \
            file://configure-sbindir.patch \
            file://runuser.pamd \
            file://runuser-l.pamd \
meta/recipes-core/util-linux/util-linux/mit-license.patch new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.40.1
#1 lore raw

PATCH 2/3 util-linux: Add fcntl-lock

Add a version of flock that uses the fnctl based lockf locking instead of flock based locks. This allows us to take the same lock that opkg would use from a shell script. The two different locking mechanisms operate independently of each other.

Inserting this C file into the util-linux build seems like the easiest/best place to insert the code. At this point it hasn't been discussed with upstream.

---
 meta/recipes-core/util-linux/util-linux.inc   |   1 +
 .../util-linux/util-linux/fcntl-lock.c        | 332 ++++++++++++++++++
 .../util-linux/util-linux_2.39.3.bb           |   7 +
 3 files changed, 340 insertions(+)
 create mode 100644 meta/recipes-core/util-linux/util-linux/fcntl-lock.c
meta/recipes-core/util-linux/util-linux.inc +1 -0
index d96f00fbab5..f4b547215e8 100644
@@ -38,6 +38,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/util-linux/v${MAJOR_VERSION}/util-lin
            file://display_testname_for_subtest.patch \
            file://avoid_parallel_tests.patch \
            file://0001-login-utils-include-libgen.h-for-basename-API.patch \
+           file://fcntl-lock.c \
            "
 
 SRC_URI[sha256sum] = "7b6605e48d1a49f43cc4b4cfc59f313d0dd5402fa40b96810bd572e167dfed0f"
meta/recipes-core/util-linux/util-linux/fcntl-lock.c new file +332 -0

332 lines not on this page · raw message

meta/recipes-core/util-linux/util-linux_2.39.3.bb +7 -0
index 3e87dcc2c2c..83b3f4e05b3 100644
@@ -147,6 +147,11 @@ SYSTEMD_AUTO_ENABLE:${PN}-uuidd = "disable"
 SYSTEMD_SERVICE:${PN}-fstrim = "fstrim.timer fstrim.service"
 SYSTEMD_AUTO_ENABLE:${PN}-fstrim = "disable"
 
+do_compile:append () {
+	cp ${WORKDIR}/fcntl-lock.c ${S}/fcntl-lock.c
+	${CC} ${CFLAGS} ${LDFLAGS} ${S}/fcntl-lock.c -o ${B}/fcntl-lock
+}
+
 do_install () {
 	# with ccache the timestamps on compiled files may
 	# end up earlier than on their inputs, this allows
@@ -182,6 +187,8 @@ do_install () {
 	echo 'MOUNTALL="-t nonfs,nosmbfs,noncpfs"' > ${D}${sysconfdir}/default/mountall
 
 	rm -f ${D}${bindir}/chkdupexe
+
+	install -m 0755 ${B}/fcntl-lock ${D}${bindir}
 }
 
 do_install:append:class-target () {
Signature · 1 line
2.40.1
#2 lore raw

PATCH 3/3 run-postinsts: Add workaround for locking deadlock issue

In reply to Richard Purdie

When run-postinsts is installed, a service is added for system which can run while the package is still being installed. This calls "opkg configure" and if package management is still running, it can deadlock and error.

To work around this, call fcntl-lock on the opkg lock file and if the lock was held, it would wait to obtain it. This wait gives the package management time to finish the install before the configure can then take the lock and run.

Note the dependency in SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS otherwise we'd see sstate selftest failures.

Also ensure that if the configure fails, the scripts returns an error. This applies to opkg and dpkg.

---
 meta/conf/layer.conf                                  |  1 +
 .../run-postinsts/run-postinsts/run-postinsts         | 11 +++++++++--
 .../run-postinsts/run-postinsts_1.0.bb                |  2 ++
 3 files changed, 12 insertions(+), 2 deletions(-)
meta/conf/layer.conf +1 -0
index 62f86f361ad..efbf2610f99 100644
@@ -87,6 +87,7 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   sato-icon-theme->gtk+3 \
   adwaita-icon-theme->gdk-pixbuf \
   adwaita-icon-theme->gtk+3 \
+  run-postinsts->util-linux \
 "
 
 # Avoid adding bison-native to the sysroot without a specific
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts +9 -2
index 95dccb9cae1..1f3e692029c 100755
@@ -81,11 +81,18 @@ remove_rcsd_link=1
 if $pm_installed; then
 	case $pm in
 		"ipk")
-			eval opkg configure $append_log
+			if ! `fcntl-lock --wait 30 /run/opkg.lock true`; then
+				eval echo "Unable to obtain the opkg lock, deadlock?" $append_log
+			fi
+			if ! eval "opkg configure $append_log"; then
+			    exit 1
+			fi
 			;;
 
 		"deb")
-			eval dpkg --configure -a $append_log
+			if ! eval "eval dpkg --configure -a $append_log"; then
+			    exit 1
+			fi
 			;;
 	esac
 else
meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb +2 -0
index 72ba8c02270..e977942de87 100644
@@ -12,6 +12,8 @@ S = "${WORKDIR}"
 
 inherit allarch systemd update-rc.d
 
+RDEPENDS:${PN} = "util-linux-fcntl-lock"
+
 INITSCRIPT_NAME = "run-postinsts"
 INITSCRIPT_PARAMS = "start 99 S ."
 
Signature · 1 line
2.40.1