Github messages for voidlinux
 help / color / mirror / Atom feed
From: Animeshz <Animeshz@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] qemu qemu-user-static: Provide binfmt services
Date: Mon, 06 Jun 2022 05:40:46 +0200	[thread overview]
Message-ID: <20220606034046.6RELZXhmITAgJCXXc2wt2kZ4Z31XP8Fk7Wz2a04isdk@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-37419@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]

There is an updated pull request by Animeshz against master on the void-packages repository

https://github.com/Animeshz/void-packages binfmt
https://github.com/void-linux/void-packages/pull/37419

qemu qemu-user-static: Provide binfmt services
`binfmt-support` doesn't work as expected, prioritizes randomly (static & non-static binaries in case both `qemu` & `qemu-user-static` is installed), also does not add `F` flag onto the binfmts which are static (that is required to chroot without copying the binaries to chroot's `/usr/bin`). Ref: https://github.com/void-linux/void-mklive/issues/253#issuecomment-1146786352.

This adds up runit services so that one can easily create the binfmts specific to qemu using [scripts/qemu-binfmt-conf.sh](https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh) provided in the upstream qemu repository. It also prioritizes static service if symlinked to the service dir.

#### Testing the changes
- I tested the changes in this PR: **YES**


A patch file from https://github.com/void-linux/void-packages/pull/37419.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-binfmt-37419.patch --]
[-- Type: text/x-diff, Size: 4257 bytes --]

From 8753ef3508d215e6cd5e8c16c91d12dfeb4781a3 Mon Sep 17 00:00:00 2001
From: Animesh Sahu <animeshsahu19@yahoo.com>
Date: Mon, 6 Jun 2022 08:57:00 +0530
Subject: [PATCH] qemu qemu-user-static: Provide binfmt services

---
 .../files/qemu-user-static-binfmt/finish              |  5 +++++
 .../files/qemu-user-static-binfmt/run                 |  9 +++++++++
 srcpkgs/qemu-user-static/template                     |  6 +++++-
 srcpkgs/qemu/files/qemu-binfmt/finish                 |  5 +++++
 srcpkgs/qemu/files/qemu-binfmt/run                    | 11 +++++++++++
 srcpkgs/qemu/template                                 |  6 +++++-
 6 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/finish
 create mode 100644 srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/run
 create mode 100644 srcpkgs/qemu/files/qemu-binfmt/finish
 create mode 100644 srcpkgs/qemu/files/qemu-binfmt/run

diff --git a/srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/finish b/srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/finish
new file mode 100644
index 000000000000..0226413c0ed2
--- /dev/null
+++ b/srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/finish
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for i in /proc/sys/fs/binfmt_misc/qemu-*; do
+    echo -1 > $i
+done
diff --git a/srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/run b/srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/run
new file mode 100644
index 000000000000..98359ba22a52
--- /dev/null
+++ b/srcpkgs/qemu-user-static/files/qemu-user-static-binfmt/run
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
+    mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
+fi
+
+/usr/share/qemu-user-static/scripts/qemu-binfmt-conf.sh --qemu-suffix "-static" \
+    --qemu-path /usr/bin -c yes -p yes
+exec chpst -b qemu-user-static-binfmt pause
diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index cca001f8835b..af09e4da8cfe 100644
--- a/srcpkgs/qemu-user-static/template
+++ b/srcpkgs/qemu-user-static/template
@@ -2,7 +2,7 @@
 # This package should be updated together with qemu
 pkgname=qemu-user-static
 version=6.2.0
-revision=2
+revision=3
 wrksrc="qemu-${version}"
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec
@@ -125,4 +125,8 @@ post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
 		mv ${f} ${f}-static
 	done
+
+	vmkdir "usr/share/${pkgname}/scripts"
+	vinstall scripts/qemu-binfmt-conf.sh 755 "usr/share/${pkgname}/scripts"
+        vsv qemu-user-static-binfmt
 }
diff --git a/srcpkgs/qemu/files/qemu-binfmt/finish b/srcpkgs/qemu/files/qemu-binfmt/finish
new file mode 100644
index 000000000000..0226413c0ed2
--- /dev/null
+++ b/srcpkgs/qemu/files/qemu-binfmt/finish
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for i in /proc/sys/fs/binfmt_misc/qemu-*; do
+    echo -1 > $i
+done
diff --git a/srcpkgs/qemu/files/qemu-binfmt/run b/srcpkgs/qemu/files/qemu-binfmt/run
new file mode 100644
index 000000000000..bea4119538c2
--- /dev/null
+++ b/srcpkgs/qemu/files/qemu-binfmt/run
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Prioritize static binaries service if present
+sv check qemu-user-static-binfmt && exit 0
+
+if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
+    mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
+fi
+
+/usr/share/qemu/scripts/qemu-binfmt-conf.sh --qemu-path /usr/bin -c yes
+exec chpst -b qemu-binfmt pause
diff --git a/srcpkgs/qemu/template b/srcpkgs/qemu/template
index 17655fdbdda8..16f2bccd2eb6 100644
--- a/srcpkgs/qemu/template
+++ b/srcpkgs/qemu/template
@@ -2,7 +2,7 @@
 # This package should be updated together with qemu-user-static
 pkgname=qemu
 version=6.2.0
-revision=2
+revision=3
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec --localstatedir=/var
  --disable-glusterfs --disable-xen --enable-docs --enable-kvm --enable-libusb --enable-pie
@@ -79,6 +79,10 @@ post_install() {
 	chmod u+s ${DESTDIR}/usr/libexec/qemu-bridge-helper
 
 	vsv qemu-ga
+
+	vmkdir "usr/share/${pkgname}/scripts"
+	vinstall scripts/qemu-binfmt-conf.sh 755 "usr/share/${pkgname}/scripts"
+        vsv qemu-binfmt
 }
 
 qemu-ga_package() {

  reply	other threads:[~2022-06-06  3:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06  3:37 [PR PATCH] " Animeshz
2022-06-06  3:40 ` Animeshz [this message]
2022-06-06  3:45 ` [PR PATCH] [Updated] " Animeshz
2022-06-06  5:58 ` CameronNemo
2022-06-06 16:15 ` Animeshz
2022-07-01  5:25 ` AviKav
2022-09-30  2:15 ` github-actions
2022-10-15  2:16 ` [PR PATCH] [Closed]: " github-actions

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220606034046.6RELZXhmITAgJCXXc2wt2kZ4Z31XP8Fk7Wz2a04isdk@z \
    --to=animeshz@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).