Github messages for voidlinux
 help / color / mirror / Atom feed
* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
  2020-03-06  9:54 ` xbps-triggers: binfmt: use --import Piraty
@ 2020-03-08  0:09 ` CameronNemo
  2020-04-19  7:26 ` [PR PATCH] [Updated] " CameronNemo
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-03-08  0:09 UTC (permalink / raw)
  To: ml

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

New comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-596150734

Comment:
Updated.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Updated]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
  2020-03-06  9:54 ` xbps-triggers: binfmt: use --import Piraty
  2020-03-08  0:09 ` CameronNemo
@ 2020-04-19  7:26 ` CameronNemo
  2020-07-10  0:17 ` fosslinux
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-04-19  7:26 UTC (permalink / raw)
  To: ml

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

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

https://github.com/CameronNemo/void-packages binfmt_files
https://github.com/void-linux/void-packages/pull/10395

 xbps-triggers: binfmt: use --import
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

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

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

From 936e89adf21578ad1e7e52b25676885c0d800951 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:33:08 -0700
Subject: [PATCH 1/3] xbps-triggers: binfmt: use --import

Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.
---
 Manual.md                                      |  9 +++++++--
 common/environment/setup-subpkg/subpkg.sh      |  1 +
 .../04-create-xbps-metadata-scripts.sh         |  4 ++++
 srcpkgs/xbps-triggers/files/binfmts            | 18 +++++++++++++++---
 srcpkgs/xbps-triggers/template                 |  2 +-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Manual.md b/Manual.md
index 92b57b1b2c2..fa2a8a51702 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1626,8 +1626,13 @@ executable binary formats, know as binfmts.
 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
 to register/remove entries from the arbitrary executable binary formats database.
 
-To include the trigger use the `binfmts` variable, as the trigger won't do anything unless
-it is defined.
+Include the trigger by specifying the `binfmt_files` variable. This variable
+contains a space separated list of format file, relative to
+`/usr/share/binfmts`. Each format file is passed to `update-binfmts --import`.
+
+The `binfmts` variable is deprecated, but still supported. The variable contains
+a newline separated list of arguments that are passed to
+`update-binfmts --package <pkgname> --install`.
 
 <a id="triggers_dkms"></a>
 #### dkms
diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh
index 6bf748fdc3d..fb97c7b5a20 100644
--- a/common/environment/setup-subpkg/subpkg.sh
+++ b/common/environment/setup-subpkg/subpkg.sh
@@ -40,6 +40,7 @@ unset -v make_dirs
 
 # xbps-triggers: binfmts
 unset -v binfmts
+unset -v binfmt_files
 
 # xbps-triggers: register-shell
 unset -v register_shell
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 3b1089cd410..fb49ef93b75 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -123,6 +123,10 @@ _EOF
 		_add_trigger binfmts
 		echo "export binfmts=\"${binfmts}\"" >> $tmpf
 	fi
+	if [ -n "${binfmt_files}" ]; then
+		_add_trigger binfmts
+		echo "export binfmt_files=\"${binfmt_files}\"" >> $tmpf
+	fi
 	#
 	# Handle GNU Info files.
 	#
diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts
index 16919833a80..cb9b680fc37 100755
--- a/srcpkgs/xbps-triggers/files/binfmts
+++ b/srcpkgs/xbps-triggers/files/binfmts
@@ -25,19 +25,26 @@ targets)
 	;;
 run)
 	[ -x /usr/bin/update-binfmts ] || exit 0
-	[ -z "${binfmts}" ] && exit 0
+	[ "${binfmts}" ] || [ "${binfmt_files}" ] || exit 0
 
 	case "$TARGET" in
 	post-install)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Installing binfmts...\n'
+		printf '%s' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
 			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--import "${binfmt}"
+		done
 		;;
 	pre-remove)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Removing binfmts...\n'
+		printf '%s' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
@@ -45,6 +52,11 @@ run)
 				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
 			fi
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--unimport "${binfmt}"
+		done
 		;;
 	*)
 		exit 1
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index c80bb30d3f5..2c76f76e3b1 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.114
+version=0.115
 revision=1
 archs=noarch
 bootstrap=yes

From 16a475ba35e724116e2c728d7a4dede5b8ce4f47 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:35:19 -0700
Subject: [PATCH 2/3] qemu-user-static: use binfmt_files

---
 srcpkgs/qemu-user-static/template | 94 ++++++++-----------------------
 1 file changed, 25 insertions(+), 69 deletions(-)

diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index b8607620523..99942fda0b5 100644
--- a/srcpkgs/qemu-user-static/template
+++ b/srcpkgs/qemu-user-static/template
@@ -1,7 +1,7 @@
 # Template file for 'qemu-user-static'
 pkgname=qemu-user-static
 version=4.2.0
-revision=1
+revision=2
 wrksrc="qemu-${version}"
 hostmakedepends="pkg-config automake python"
 makedepends="dtc-devel libglib-static pixman-devel libuuid-devel"
@@ -12,94 +12,50 @@ homepage="https://www.qemu.org"
 distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2"
 checksum=3cf4f3f73233a12211a045f07eef467fdc7bf3877568cd0c8a0cf36121da9fbd
 
-_fmts="aarch64 alpha arm armeb cris i386 m68k microblaze mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppc64le s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64"
-
-_aarch64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_alpha_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
-_alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_arm_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
-_arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_armeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
-_armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
-_cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_i386_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
-_i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_m68k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
-_m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblaze_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
-_microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips64el_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
-_ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64abi32_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64abi32_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_s390x_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
-_s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sh4_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-_sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_sh4eb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
-_sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
-_sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc32plus_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
-_sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
-_sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_x86_64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
-_x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc64le_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
-_ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*|i386*) _omit="i386|x86_64" ;;
-	aarch64*) _omit="aarch64" ;;
-	armv*) _omit="arm" ;;
-	mips*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-	*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-esac
-
-for _fmt in $_fmts; do
-	eval "case $_fmt in $_omit) magic= ;; *) magic=\"\$_${_fmt}_magic\" mask=\"\$_${_fmt}_mask\" ;; esac"
-	if [ "$magic" ]; then
-		binfmts+="/usr/bin/qemu-$_fmt-static --magic $magic --mask $mask --offset 0 --credential yes
-"
-	fi
+# Copied from ${wrksrc}/scripts/qemu-binfmt-conf.sh
+_binfmt_archs="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k
+ mips mipsel mipsn32 mipsn32el mips64 mips64el sh4 sh4eb s390x aarch64
+ aarch64_be hppa riscv32 riscv64 xtensa xtensaeb microblaze microblazeel or1k
+ x86_64"
+for a in ${_binfmt_archs}; do
+	binfmt_files="${binfmt_files:-}${binfmt_files:+ }qemu-${a}"
 done
-
-binfmts="${binfmts%?}"
 nopie=yes
 
 post_extract() {
 	sed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h
 }
+
 do_configure() {
 	./configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/libexec \
 		--disable-kvm --disable-vnc-png \
 		--disable-virtfs --disable-fdt --disable-seccomp \
 		--enable-linux-user --disable-system
 }
+
 do_build() {
 	make ${makejobs} LDFLAGS="-static -lrt -luuid"
 }
+
 do_install() {
 	make DESTDIR=${DESTDIR} install
+	# Install binfmt configurations
+	vmkdir usr/share/binfmts
+	HOST_ARCH="${XBPS_TARGET_MACHINE%-musl}" ./scripts/qemu-binfmt-conf.sh \
+		--debian --qemu-path /usr/bin --qemu-suffix -static \
+		--exportdir "${DESTDIR}/usr/share/binfmts"
 	# Remove unneeded stuff.
-	rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec
+	rm -rf -- "${DESTDIR}/etc" "${DESTDIR}/usr/libexec"
+	for d in doc locale man qemu; do
+		rm -rf -- "${DESTDIR}/usr/share/${d}"
+	done
 	for f in nbd io img; do
-		rm -f ${DESTDIR}/usr/bin/qemu-${f}
+		rm -f -- "${DESTDIR}/usr/bin/qemu-${f}"
 	done
+}
+
+post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
-		mv ${f} ${f}-static
+		mv "${f}" "${f}-static"
 	done
 }

From 96f21c86ef01183bf0950b0df5a8969cccbd8e1d Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Sun, 19 Apr 2020 00:25:06 -0700
Subject: [PATCH 3/3] wine: use binfmt_files

---
 srcpkgs/wine/files/binfmts/wine | 3 +++
 srcpkgs/wine/template           | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/wine/files/binfmts/wine

diff --git a/srcpkgs/wine/files/binfmts/wine b/srcpkgs/wine/files/binfmts/wine
new file mode 100644
index 00000000000..cb52a076334
--- /dev/null
+++ b/srcpkgs/wine/files/binfmts/wine
@@ -0,0 +1,3 @@
+package wine
+interpreter /usr/bin/wine
+magic MZ
diff --git a/srcpkgs/wine/template b/srcpkgs/wine/template
index dd14e702414..07745e664ed 100644
--- a/srcpkgs/wine/template
+++ b/srcpkgs/wine/template
@@ -1,7 +1,7 @@
 # Template file for 'wine'
 pkgname=wine
 version=5.6
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--without-gstreamer"
 short_desc="Run Microsoft Windows applications"
@@ -31,9 +31,11 @@ depends="libXi libXinerama libXcomposite libXcursor libOSMesa
  desktop-file-utils hicolor-icon-theme liberation-fonts-ttf
  gnutls"
 
-binfmts="/usr/bin/wine --magic MZ"
+binfmt_files="wine"
 
 post_install() {
+	# binfmt configuration
+	vinstall "${FILESDIR}/binfmts/wine" 0644 usr/share/binfmts
 	# Font aliasing settings for Win32 applications
 	install -d ${DESTDIR}/etc/fonts/conf.{avail,d}
 	install -m644 ${FILESDIR}/30-win32-aliases.conf ${DESTDIR}/etc/fonts/conf.avail

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (2 preceding siblings ...)
  2020-04-19  7:26 ` [PR PATCH] [Updated] " CameronNemo
@ 2020-07-10  0:17 ` fosslinux
  2020-07-22 13:08 ` [PR REVIEW] " sgn
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: fosslinux @ 2020-07-10  0:17 UTC (permalink / raw)
  To: ml

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

New comment by fosslinux on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-656412644

Comment:
ping

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (3 preceding siblings ...)
  2020-07-10  0:17 ` fosslinux
@ 2020-07-22 13:08 ` sgn
  2020-09-21  0:12 ` [PR PATCH] [Updated] " CameronNemo
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: sgn @ 2020-07-22 13:08 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r458776853

Comment:
```
printf '%s\n' ...
```
perhaps?

Otherwise, everything will be concatenated into single long line, and final newline is missing.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Updated]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (4 preceding siblings ...)
  2020-07-22 13:08 ` [PR REVIEW] " sgn
@ 2020-09-21  0:12 ` CameronNemo
  2020-09-21  0:13 ` [PR REVIEW] " CameronNemo
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-09-21  0:12 UTC (permalink / raw)
  To: ml

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

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

https://github.com/CameronNemo/void-packages binfmt_files
https://github.com/void-linux/void-packages/pull/10395

 xbps-triggers: binfmt: use --import
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

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

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

From e4f5f6757a1500573cb2ddf2b46c8fca80171778 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:33:08 -0700
Subject: [PATCH 1/3] xbps-triggers: binfmt: use --import

Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.
---
 Manual.md                                      |  9 +++++++--
 common/environment/setup-subpkg/subpkg.sh      |  1 +
 .../04-create-xbps-metadata-scripts.sh         |  4 ++++
 srcpkgs/xbps-triggers/files/binfmts            | 18 +++++++++++++++---
 srcpkgs/xbps-triggers/template                 |  2 +-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Manual.md b/Manual.md
index 4af3a7b78d9..d7afcc7b882 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1666,8 +1666,13 @@ executable binary formats, know as binfmts.
 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
 to register/remove entries from the arbitrary executable binary formats database.
 
-To include the trigger use the `binfmts` variable, as the trigger won't do anything unless
-it is defined.
+Include the trigger by specifying the `binfmt_files` variable. This variable
+contains a space separated list of format file, relative to
+`/usr/share/binfmts`. Each format file is passed to `update-binfmts --import`.
+
+The `binfmts` variable is deprecated, but still supported. The variable contains
+a newline separated list of arguments that are passed to
+`update-binfmts --package <pkgname> --install`.
 
 <a id="triggers_dkms"></a>
 #### dkms
diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh
index 0243d240048..0011d7558fb 100644
--- a/common/environment/setup-subpkg/subpkg.sh
+++ b/common/environment/setup-subpkg/subpkg.sh
@@ -40,6 +40,7 @@ unset -v make_dirs
 
 # xbps-triggers: binfmts
 unset -v binfmts
+unset -v binfmt_files
 
 # xbps-triggers: register-shell
 unset -v register_shell
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 1300c783b7d..d0cd0d620e5 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -123,6 +123,10 @@ _EOF
 		_add_trigger binfmts
 		echo "export binfmts=\"${binfmts}\"" >> $tmpf
 	fi
+	if [ -n "${binfmt_files}" ]; then
+		_add_trigger binfmts
+		echo "export binfmt_files=\"${binfmt_files}\"" >> $tmpf
+	fi
 	#
 	# Handle GNU Info files.
 	#
diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts
index 16919833a80..b9688097f4f 100755
--- a/srcpkgs/xbps-triggers/files/binfmts
+++ b/srcpkgs/xbps-triggers/files/binfmts
@@ -25,19 +25,26 @@ targets)
 	;;
 run)
 	[ -x /usr/bin/update-binfmts ] || exit 0
-	[ -z "${binfmts}" ] && exit 0
+	[ "${binfmts}" ] || [ "${binfmt_files}" ] || exit 0
 
 	case "$TARGET" in
 	post-install)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Installing binfmts...\n'
+		printf '%s\n' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
 			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--import "${binfmt}"
+		done
 		;;
 	pre-remove)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Removing binfmts...\n'
+		printf '%s\n' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
@@ -45,6 +52,11 @@ run)
 				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
 			fi
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--unimport "${binfmt}"
+		done
 		;;
 	*)
 		exit 1
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index 4131b479bef..75010d6bee7 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.117
+version=0.118
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

From e1757145e1ec40e3fdbc6681111d56b8fa5589fd Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:35:19 -0700
Subject: [PATCH 2/3] qemu-user-static: use binfmt_files

---
 srcpkgs/qemu-user-static/template | 91 ++++++++-----------------------
 1 file changed, 22 insertions(+), 69 deletions(-)

diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index 236da6cc290..a591378871b 100644
--- a/srcpkgs/qemu-user-static/template
+++ b/srcpkgs/qemu-user-static/template
@@ -1,7 +1,7 @@
 # Template file for 'qemu-user-static'
 pkgname=qemu-user-static
 version=5.1.0
-revision=1
+revision=2
 wrksrc="qemu-${version}"
 hostmakedepends="pkg-config automake python3"
 makedepends="dtc-devel libglib-static pixman-devel libuuid-devel"
@@ -12,73 +12,15 @@ homepage="https://www.qemu.org"
 distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2"
 checksum=8314b6e5fcc7bf9fa3915d504de6586a69cba30ffa27cbe9ba85d2cb9987fb3a
 
-_fmts="aarch64 alpha arm armeb cris i386 m68k microblaze mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppc64le s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64"
-
-_aarch64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_alpha_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
-_alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_arm_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
-_arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_armeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
-_armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
-_cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_i386_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
-_i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_m68k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
-_m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblaze_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
-_microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips64el_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
-_ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64abi32_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64abi32_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_s390x_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
-_s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sh4_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-_sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_sh4eb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
-_sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
-_sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc32plus_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
-_sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
-_sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_x86_64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
-_x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc64le_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
-_ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*|i386*) _omit="i386|x86_64" ;;
-	aarch64*) _omit="aarch64" ;;
-	armv*) _omit="arm" ;;
-	mips*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-	*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-esac
-
-for _fmt in $_fmts; do
-	eval "case $_fmt in $_omit) magic= ;; *) magic=\"\$_${_fmt}_magic\" mask=\"\$_${_fmt}_mask\" ;; esac"
-	if [ "$magic" ]; then
-		binfmts+="/usr/bin/qemu-$_fmt-static --magic $magic --mask $mask --offset 0 --credential yes
-"
-	fi
+# Copied from ${wrksrc}/scripts/qemu-binfmt-conf.sh
+_binfmt_archs="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k
+ mips mipsel mipsn32 mipsn32el mips64 mips64el sh4 sh4eb s390x aarch64
+ aarch64_be hppa riscv32 riscv64 xtensa xtensaeb microblaze microblazeel or1k
+ x86_64"
+for a in ${_binfmt_archs}; do
+	binfmt_files="${binfmt_files:-}${binfmt_files:+ }qemu-${a}"
 done
 
-binfmts="${binfmts%?}"
-
 post_extract() {
 	sed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h
 }
@@ -97,12 +39,23 @@ do_build() {
 
 do_install() {
 	make DESTDIR=${DESTDIR} install
+	# Install binfmt configurations
+	vmkdir usr/share/binfmts
+	HOST_ARCH="${XBPS_TARGET_MACHINE%-musl}" ./scripts/qemu-binfmt-conf.sh \
+		--debian --qemu-path /usr/bin --qemu-suffix -static \
+		--exportdir "${DESTDIR}/usr/share/binfmts"
 	# Remove unneeded stuff.
-	rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec
+	rm -rf -- "${DESTDIR}/etc" "${DESTDIR}/usr/libexec"
+	for d in doc locale man qemu; do
+		rm -rf -- "${DESTDIR}/usr/share/${d}"
+	done
 	for f in nbd io img; do
-		rm -f ${DESTDIR}/usr/bin/qemu-${f}
+		rm -f -- "${DESTDIR}/usr/bin/qemu-${f}"
 	done
+}
+
+post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
-		mv ${f} ${f}-static
+		mv "${f}" "${f}-static"
 	done
 }

From e710716e645cef665fe5b80ae7ef97ff04e045a1 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Sun, 19 Apr 2020 00:25:06 -0700
Subject: [PATCH 3/3] wine: use binfmt_files

---
 srcpkgs/wine/files/binfmts/wine | 3 +++
 srcpkgs/wine/template           | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/wine/files/binfmts/wine

diff --git a/srcpkgs/wine/files/binfmts/wine b/srcpkgs/wine/files/binfmts/wine
new file mode 100644
index 00000000000..cb52a076334
--- /dev/null
+++ b/srcpkgs/wine/files/binfmts/wine
@@ -0,0 +1,3 @@
+package wine
+interpreter /usr/bin/wine
+magic MZ
diff --git a/srcpkgs/wine/template b/srcpkgs/wine/template
index 39ef507a68c..ff61eaa99f1 100644
--- a/srcpkgs/wine/template
+++ b/srcpkgs/wine/template
@@ -1,7 +1,7 @@
 # Template file for 'wine'
 pkgname=wine
 version=5.17
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--bindir=/usr/libexec/wine"
 short_desc="Run Microsoft Windows applications"
@@ -89,7 +89,7 @@ wine-devel_package() {
 
 wine-common_package() {
 	short_desc+=" - common files"
-	binfmts="/usr/bin/wine --magic MZ"
+	binfmt_files="wine"
 	pkg_install() {
 		vmove usr/share
 		vmove etc/fonts
@@ -97,6 +97,7 @@ wine-common_package() {
 		do
 			vmove usr/bin/${file}
 		done
+		vinstall "${FILESDIR}/binfmts/wine" 0644 usr/share/binfmts
 	}
 }
 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (5 preceding siblings ...)
  2020-09-21  0:12 ` [PR PATCH] [Updated] " CameronNemo
@ 2020-09-21  0:13 ` CameronNemo
  2020-09-21  1:06 ` CameronNemo
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-09-21  0:13 UTC (permalink / raw)
  To: ml

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

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r491752389

Comment:
rebased and addressed this.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (6 preceding siblings ...)
  2020-09-21  0:13 ` [PR REVIEW] " CameronNemo
@ 2020-09-21  1:06 ` CameronNemo
  2020-09-21  1:07 ` CameronNemo
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-09-21  1:06 UTC (permalink / raw)
  To: ml

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

New comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-695862655

Comment:
the log length is maxing out, sorry y'all

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (7 preceding siblings ...)
  2020-09-21  1:06 ` CameronNemo
@ 2020-09-21  1:07 ` CameronNemo
  2020-11-01  1:40 ` ericonr
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-09-21  1:07 UTC (permalink / raw)
  To: ml

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

New comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-695862655

Comment:
the travis log length is maxing out, should have seen that coming, I guess

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (8 preceding siblings ...)
  2020-09-21  1:07 ` CameronNemo
@ 2020-11-01  1:40 ` ericonr
  2020-11-01 19:11 ` [PR PATCH] [Updated] " CameronNemo
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: ericonr @ 2020-11-01  1:40 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-720013457

Comment:
Ping for rebase :) 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Updated]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (9 preceding siblings ...)
  2020-11-01  1:40 ` ericonr
@ 2020-11-01 19:11 ` CameronNemo
  2020-11-01 19:11 ` CameronNemo
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-11-01 19:11 UTC (permalink / raw)
  To: ml

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

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

https://github.com/CameronNemo/void-packages binfmt_files
https://github.com/void-linux/void-packages/pull/10395

 xbps-triggers: binfmt: use --import
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

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

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

From 17034d64bda85c0e94dd008732acf9e00f383793 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:33:08 -0700
Subject: [PATCH 1/3] xbps-triggers: binfmt: use --import

Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.
---
 Manual.md                                      |  9 +++++++--
 common/environment/setup-subpkg/subpkg.sh      |  1 +
 .../04-create-xbps-metadata-scripts.sh         |  4 ++++
 srcpkgs/xbps-triggers/files/binfmts            | 18 +++++++++++++++---
 srcpkgs/xbps-triggers/template                 |  2 +-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Manual.md b/Manual.md
index 5b1266ba715..30bec4b1925 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1666,8 +1666,13 @@ executable binary formats, know as binfmts.
 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
 to register/remove entries from the arbitrary executable binary formats database.
 
-To include the trigger use the `binfmts` variable, as the trigger won't do anything unless
-it is defined.
+Include the trigger by specifying the `binfmt_files` variable. This variable
+contains a space separated list of format file, relative to
+`/usr/share/binfmts`. Each format file is passed to `update-binfmts --import`.
+
+The `binfmts` variable is deprecated, but still supported. The variable contains
+a newline separated list of arguments that are passed to
+`update-binfmts --package <pkgname> --install`.
 
 <a id="triggers_dkms"></a>
 #### dkms
diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh
index 0243d240048..0011d7558fb 100644
--- a/common/environment/setup-subpkg/subpkg.sh
+++ b/common/environment/setup-subpkg/subpkg.sh
@@ -40,6 +40,7 @@ unset -v make_dirs
 
 # xbps-triggers: binfmts
 unset -v binfmts
+unset -v binfmt_files
 
 # xbps-triggers: register-shell
 unset -v register_shell
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 1300c783b7d..d0cd0d620e5 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -123,6 +123,10 @@ _EOF
 		_add_trigger binfmts
 		echo "export binfmts=\"${binfmts}\"" >> $tmpf
 	fi
+	if [ -n "${binfmt_files}" ]; then
+		_add_trigger binfmts
+		echo "export binfmt_files=\"${binfmt_files}\"" >> $tmpf
+	fi
 	#
 	# Handle GNU Info files.
 	#
diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts
index 16919833a80..b9688097f4f 100755
--- a/srcpkgs/xbps-triggers/files/binfmts
+++ b/srcpkgs/xbps-triggers/files/binfmts
@@ -25,19 +25,26 @@ targets)
 	;;
 run)
 	[ -x /usr/bin/update-binfmts ] || exit 0
-	[ -z "${binfmts}" ] && exit 0
+	[ "${binfmts}" ] || [ "${binfmt_files}" ] || exit 0
 
 	case "$TARGET" in
 	post-install)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Installing binfmts...\n'
+		printf '%s\n' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
 			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--import "${binfmt}"
+		done
 		;;
 	pre-remove)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Removing binfmts...\n'
+		printf '%s\n' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
@@ -45,6 +52,11 @@ run)
 				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
 			fi
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--unimport "${binfmt}"
+		done
 		;;
 	*)
 		exit 1
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index 4131b479bef..75010d6bee7 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.117
+version=0.118
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

From cded4a01ff6f89474b0e6b5c0afa44a736b0893a Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:35:19 -0700
Subject: [PATCH 2/3] qemu-user-static: use binfmt_files

---
 srcpkgs/qemu-user-static/template | 91 ++++++++-----------------------
 1 file changed, 22 insertions(+), 69 deletions(-)

diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index 236da6cc290..a591378871b 100644
--- a/srcpkgs/qemu-user-static/template
+++ b/srcpkgs/qemu-user-static/template
@@ -1,7 +1,7 @@
 # Template file for 'qemu-user-static'
 pkgname=qemu-user-static
 version=5.1.0
-revision=1
+revision=2
 wrksrc="qemu-${version}"
 hostmakedepends="pkg-config automake python3"
 makedepends="dtc-devel libglib-static pixman-devel libuuid-devel"
@@ -12,73 +12,15 @@ homepage="https://www.qemu.org"
 distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2"
 checksum=8314b6e5fcc7bf9fa3915d504de6586a69cba30ffa27cbe9ba85d2cb9987fb3a
 
-_fmts="aarch64 alpha arm armeb cris i386 m68k microblaze mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppc64le s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64"
-
-_aarch64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_alpha_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
-_alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_arm_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
-_arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_armeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
-_armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
-_cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_i386_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
-_i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_m68k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
-_m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblaze_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
-_microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips64el_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
-_ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64abi32_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64abi32_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_s390x_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
-_s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sh4_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-_sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_sh4eb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
-_sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
-_sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc32plus_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
-_sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
-_sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_x86_64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
-_x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc64le_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
-_ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*|i386*) _omit="i386|x86_64" ;;
-	aarch64*) _omit="aarch64" ;;
-	armv*) _omit="arm" ;;
-	mips*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-	*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-esac
-
-for _fmt in $_fmts; do
-	eval "case $_fmt in $_omit) magic= ;; *) magic=\"\$_${_fmt}_magic\" mask=\"\$_${_fmt}_mask\" ;; esac"
-	if [ "$magic" ]; then
-		binfmts+="/usr/bin/qemu-$_fmt-static --magic $magic --mask $mask --offset 0 --credential yes
-"
-	fi
+# Copied from ${wrksrc}/scripts/qemu-binfmt-conf.sh
+_binfmt_archs="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k
+ mips mipsel mipsn32 mipsn32el mips64 mips64el sh4 sh4eb s390x aarch64
+ aarch64_be hppa riscv32 riscv64 xtensa xtensaeb microblaze microblazeel or1k
+ x86_64"
+for a in ${_binfmt_archs}; do
+	binfmt_files="${binfmt_files:-}${binfmt_files:+ }qemu-${a}"
 done
 
-binfmts="${binfmts%?}"
-
 post_extract() {
 	sed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h
 }
@@ -97,12 +39,23 @@ do_build() {
 
 do_install() {
 	make DESTDIR=${DESTDIR} install
+	# Install binfmt configurations
+	vmkdir usr/share/binfmts
+	HOST_ARCH="${XBPS_TARGET_MACHINE%-musl}" ./scripts/qemu-binfmt-conf.sh \
+		--debian --qemu-path /usr/bin --qemu-suffix -static \
+		--exportdir "${DESTDIR}/usr/share/binfmts"
 	# Remove unneeded stuff.
-	rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec
+	rm -rf -- "${DESTDIR}/etc" "${DESTDIR}/usr/libexec"
+	for d in doc locale man qemu; do
+		rm -rf -- "${DESTDIR}/usr/share/${d}"
+	done
 	for f in nbd io img; do
-		rm -f ${DESTDIR}/usr/bin/qemu-${f}
+		rm -f -- "${DESTDIR}/usr/bin/qemu-${f}"
 	done
+}
+
+post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
-		mv ${f} ${f}-static
+		mv "${f}" "${f}-static"
 	done
 }

From fec7a662eae73ada880eb9304ceefed9e908d50f Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Sun, 19 Apr 2020 00:25:06 -0700
Subject: [PATCH 3/3] wine: use binfmt_files

---
 srcpkgs/wine/files/binfmts/wine | 3 +++
 srcpkgs/wine/template           | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/wine/files/binfmts/wine

diff --git a/srcpkgs/wine/files/binfmts/wine b/srcpkgs/wine/files/binfmts/wine
new file mode 100644
index 00000000000..cb52a076334
--- /dev/null
+++ b/srcpkgs/wine/files/binfmts/wine
@@ -0,0 +1,3 @@
+package wine
+interpreter /usr/bin/wine
+magic MZ
diff --git a/srcpkgs/wine/template b/srcpkgs/wine/template
index 0b5ebe5a3e4..328657d549b 100644
--- a/srcpkgs/wine/template
+++ b/srcpkgs/wine/template
@@ -1,7 +1,7 @@
 # Template file for 'wine'
 pkgname=wine
 version=5.20
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--bindir=/usr/libexec/wine"
 short_desc="Run Microsoft Windows applications"
@@ -89,7 +89,7 @@ wine-devel_package() {
 
 wine-common_package() {
 	short_desc+=" - common files"
-	binfmts="/usr/bin/wine --magic MZ"
+	binfmt_files="wine"
 	pkg_install() {
 		vmove usr/share
 		vmove etc/fonts
@@ -97,6 +97,7 @@ wine-common_package() {
 		do
 			vmove usr/bin/${file}
 		done
+		vinstall "${FILESDIR}/binfmts/wine" 0644 usr/share/binfmts
 	}
 }
 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (10 preceding siblings ...)
  2020-11-01 19:11 ` [PR PATCH] [Updated] " CameronNemo
@ 2020-11-01 19:11 ` CameronNemo
  2020-11-02  4:08 ` ericonr
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-11-01 19:11 UTC (permalink / raw)
  To: ml

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

New comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-720136944

Comment:
rebased

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (11 preceding siblings ...)
  2020-11-01 19:11 ` CameronNemo
@ 2020-11-02  4:08 ` ericonr
  2020-11-02 17:49 ` [PR PATCH] [Updated] " CameronNemo
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: ericonr @ 2020-11-02  4:08 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-720225057

Comment:
Would you mind adding this patch? It fixes https://github.com/void-linux/void-packages/issues/23557

```
diff --git linux-user/syscall.c linux-user/syscall.c
index 945fc25..8d8b68a 100644
--- linux-user/syscall.c
+++ linux-user/syscall.c
@@ -3071,7 +3071,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
                                       int flags, int send)
 {
     abi_long ret, len;
-    struct msghdr msg;
+    struct msghdr msg = {0};
     abi_ulong count;
     struct iovec *vec;
     abi_ulong target_vec;
```

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Updated]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (12 preceding siblings ...)
  2020-11-02  4:08 ` ericonr
@ 2020-11-02 17:49 ` CameronNemo
  2021-01-13 18:22 ` [PR REVIEW] " ericonr
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2020-11-02 17:49 UTC (permalink / raw)
  To: ml

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

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

https://github.com/CameronNemo/void-packages binfmt_files
https://github.com/void-linux/void-packages/pull/10395

 xbps-triggers: binfmt: use --import
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

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

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

From 17034d64bda85c0e94dd008732acf9e00f383793 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:33:08 -0700
Subject: [PATCH 1/3] xbps-triggers: binfmt: use --import

Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.
---
 Manual.md                                      |  9 +++++++--
 common/environment/setup-subpkg/subpkg.sh      |  1 +
 .../04-create-xbps-metadata-scripts.sh         |  4 ++++
 srcpkgs/xbps-triggers/files/binfmts            | 18 +++++++++++++++---
 srcpkgs/xbps-triggers/template                 |  2 +-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Manual.md b/Manual.md
index 5b1266ba715..30bec4b1925 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1666,8 +1666,13 @@ executable binary formats, know as binfmts.
 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
 to register/remove entries from the arbitrary executable binary formats database.
 
-To include the trigger use the `binfmts` variable, as the trigger won't do anything unless
-it is defined.
+Include the trigger by specifying the `binfmt_files` variable. This variable
+contains a space separated list of format file, relative to
+`/usr/share/binfmts`. Each format file is passed to `update-binfmts --import`.
+
+The `binfmts` variable is deprecated, but still supported. The variable contains
+a newline separated list of arguments that are passed to
+`update-binfmts --package <pkgname> --install`.
 
 <a id="triggers_dkms"></a>
 #### dkms
diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh
index 0243d240048..0011d7558fb 100644
--- a/common/environment/setup-subpkg/subpkg.sh
+++ b/common/environment/setup-subpkg/subpkg.sh
@@ -40,6 +40,7 @@ unset -v make_dirs
 
 # xbps-triggers: binfmts
 unset -v binfmts
+unset -v binfmt_files
 
 # xbps-triggers: register-shell
 unset -v register_shell
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 1300c783b7d..d0cd0d620e5 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -123,6 +123,10 @@ _EOF
 		_add_trigger binfmts
 		echo "export binfmts=\"${binfmts}\"" >> $tmpf
 	fi
+	if [ -n "${binfmt_files}" ]; then
+		_add_trigger binfmts
+		echo "export binfmt_files=\"${binfmt_files}\"" >> $tmpf
+	fi
 	#
 	# Handle GNU Info files.
 	#
diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts
index 16919833a80..b9688097f4f 100755
--- a/srcpkgs/xbps-triggers/files/binfmts
+++ b/srcpkgs/xbps-triggers/files/binfmts
@@ -25,19 +25,26 @@ targets)
 	;;
 run)
 	[ -x /usr/bin/update-binfmts ] || exit 0
-	[ -z "${binfmts}" ] && exit 0
+	[ "${binfmts}" ] || [ "${binfmt_files}" ] || exit 0
 
 	case "$TARGET" in
 	post-install)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Installing binfmts...\n'
+		printf '%s\n' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
 			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--import "${binfmt}"
+		done
 		;;
 	pre-remove)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Removing binfmts...\n'
+		printf '%s\n' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
@@ -45,6 +52,11 @@ run)
 				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
 			fi
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--unimport "${binfmt}"
+		done
 		;;
 	*)
 		exit 1
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index 4131b479bef..75010d6bee7 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.117
+version=0.118
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

From 00060114571530bbcbbbea472758bab33042e490 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:35:19 -0700
Subject: [PATCH 2/3] qemu-user-static: use binfmt_files

---
 srcpkgs/qemu-user-static/template             | 91 +++++--------------
 .../qemu/patches/musl-initialize-msghdr.patch | 15 +++
 2 files changed, 37 insertions(+), 69 deletions(-)
 create mode 100644 srcpkgs/qemu/patches/musl-initialize-msghdr.patch

diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index 236da6cc290..a591378871b 100644
--- a/srcpkgs/qemu-user-static/template
+++ b/srcpkgs/qemu-user-static/template
@@ -1,7 +1,7 @@
 # Template file for 'qemu-user-static'
 pkgname=qemu-user-static
 version=5.1.0
-revision=1
+revision=2
 wrksrc="qemu-${version}"
 hostmakedepends="pkg-config automake python3"
 makedepends="dtc-devel libglib-static pixman-devel libuuid-devel"
@@ -12,73 +12,15 @@ homepage="https://www.qemu.org"
 distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2"
 checksum=8314b6e5fcc7bf9fa3915d504de6586a69cba30ffa27cbe9ba85d2cb9987fb3a
 
-_fmts="aarch64 alpha arm armeb cris i386 m68k microblaze mips mipsel mips64 mips64el ppc ppc64 ppc64abi32 ppc64le s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64"
-
-_aarch64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_alpha_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
-_alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_arm_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
-_arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_armeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
-_armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
-_cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_i386_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
-_i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_m68k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
-_m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblaze_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
-_microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips64el_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
-_ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64abi32_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64abi32_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_s390x_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
-_s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sh4_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-_sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_sh4eb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
-_sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
-_sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc32plus_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
-_sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
-_sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_x86_64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
-_x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_ppc64le_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
-_ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*|i386*) _omit="i386|x86_64" ;;
-	aarch64*) _omit="aarch64" ;;
-	armv*) _omit="arm" ;;
-	mips*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-	*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-esac
-
-for _fmt in $_fmts; do
-	eval "case $_fmt in $_omit) magic= ;; *) magic=\"\$_${_fmt}_magic\" mask=\"\$_${_fmt}_mask\" ;; esac"
-	if [ "$magic" ]; then
-		binfmts+="/usr/bin/qemu-$_fmt-static --magic $magic --mask $mask --offset 0 --credential yes
-"
-	fi
+# Copied from ${wrksrc}/scripts/qemu-binfmt-conf.sh
+_binfmt_archs="i386 i486 alpha arm armeb sparc32plus ppc ppc64 ppc64le m68k
+ mips mipsel mipsn32 mipsn32el mips64 mips64el sh4 sh4eb s390x aarch64
+ aarch64_be hppa riscv32 riscv64 xtensa xtensaeb microblaze microblazeel or1k
+ x86_64"
+for a in ${_binfmt_archs}; do
+	binfmt_files="${binfmt_files:-}${binfmt_files:+ }qemu-${a}"
 done
 
-binfmts="${binfmts%?}"
-
 post_extract() {
 	sed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h
 }
@@ -97,12 +39,23 @@ do_build() {
 
 do_install() {
 	make DESTDIR=${DESTDIR} install
+	# Install binfmt configurations
+	vmkdir usr/share/binfmts
+	HOST_ARCH="${XBPS_TARGET_MACHINE%-musl}" ./scripts/qemu-binfmt-conf.sh \
+		--debian --qemu-path /usr/bin --qemu-suffix -static \
+		--exportdir "${DESTDIR}/usr/share/binfmts"
 	# Remove unneeded stuff.
-	rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec
+	rm -rf -- "${DESTDIR}/etc" "${DESTDIR}/usr/libexec"
+	for d in doc locale man qemu; do
+		rm -rf -- "${DESTDIR}/usr/share/${d}"
+	done
 	for f in nbd io img; do
-		rm -f ${DESTDIR}/usr/bin/qemu-${f}
+		rm -f -- "${DESTDIR}/usr/bin/qemu-${f}"
 	done
+}
+
+post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
-		mv ${f} ${f}-static
+		mv "${f}" "${f}-static"
 	done
 }
diff --git a/srcpkgs/qemu/patches/musl-initialize-msghdr.patch b/srcpkgs/qemu/patches/musl-initialize-msghdr.patch
new file mode 100644
index 00000000000..c195f0c0b1f
--- /dev/null
+++ b/srcpkgs/qemu/patches/musl-initialize-msghdr.patch
@@ -0,0 +1,15 @@
+Source: https://github.com/void-linux/void-packages/issues/23557
+
+diff --git linux-user/syscall.c linux-user/syscall.c
+index 945fc25..8d8b68a 100644
+--- linux-user/syscall.c
++++ linux-user/syscall.c
+@@ -3071,7 +3071,7 @@ static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp,
+                                       int flags, int send)
+ {
+     abi_long ret, len;
+-    struct msghdr msg;
++    struct msghdr msg = {0};
+     abi_ulong count;
+     struct iovec *vec;
+     abi_ulong target_vec;

From a7b7b6089cb540f40ba60379d2d3a1d071b07d9c Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Sun, 19 Apr 2020 00:25:06 -0700
Subject: [PATCH 3/3] wine: use binfmt_files

---
 srcpkgs/wine/files/binfmts/wine | 3 +++
 srcpkgs/wine/template           | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/wine/files/binfmts/wine

diff --git a/srcpkgs/wine/files/binfmts/wine b/srcpkgs/wine/files/binfmts/wine
new file mode 100644
index 00000000000..cb52a076334
--- /dev/null
+++ b/srcpkgs/wine/files/binfmts/wine
@@ -0,0 +1,3 @@
+package wine
+interpreter /usr/bin/wine
+magic MZ
diff --git a/srcpkgs/wine/template b/srcpkgs/wine/template
index 0b5ebe5a3e4..328657d549b 100644
--- a/srcpkgs/wine/template
+++ b/srcpkgs/wine/template
@@ -1,7 +1,7 @@
 # Template file for 'wine'
 pkgname=wine
 version=5.20
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--bindir=/usr/libexec/wine"
 short_desc="Run Microsoft Windows applications"
@@ -89,7 +89,7 @@ wine-devel_package() {
 
 wine-common_package() {
 	short_desc+=" - common files"
-	binfmts="/usr/bin/wine --magic MZ"
+	binfmt_files="wine"
 	pkg_install() {
 		vmove usr/share
 		vmove etc/fonts
@@ -97,6 +97,7 @@ wine-common_package() {
 		do
 			vmove usr/bin/${file}
 		done
+		vinstall "${FILESDIR}/binfmts/wine" 0644 usr/share/binfmts
 	}
 }
 

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (13 preceding siblings ...)
  2020-11-02 17:49 ` [PR PATCH] [Updated] " CameronNemo
@ 2021-01-13 18:22 ` ericonr
  2021-02-11 21:39 ` ericonr
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: ericonr @ 2021-01-13 18:22 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r556736467

Comment:
The new list is missing ppc64abi32, sparc, sparc64, cris

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (14 preceding siblings ...)
  2021-01-13 18:22 ` [PR REVIEW] " ericonr
@ 2021-02-11 21:39 ` ericonr
  2021-04-27 22:44 ` [PR PATCH] [Updated] " CameronNemo
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: ericonr @ 2021-02-11 21:39 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-777809702

Comment:
I've imported the patch and will try to import the wine changes as well, we just need to decide on the supported platforms.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Updated]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (15 preceding siblings ...)
  2021-02-11 21:39 ` ericonr
@ 2021-04-27 22:44 ` CameronNemo
  2021-04-27 22:44 ` [PR REVIEW] " CameronNemo
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2021-04-27 22:44 UTC (permalink / raw)
  To: ml

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

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

https://github.com/CameronNemo/void-packages binfmt_files
https://github.com/void-linux/void-packages/pull/10395

 xbps-triggers: binfmt: use --import
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

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

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

From 8d9b15e21230c9ca02c77f281491f701d9c9d80f Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:33:08 -0700
Subject: [PATCH 1/3] xbps-triggers: binfmt: use --import

Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.
---
 Manual.md                                      |  9 +++++++--
 common/environment/setup-subpkg/subpkg.sh      |  1 +
 .../04-create-xbps-metadata-scripts.sh         |  4 ++++
 srcpkgs/xbps-triggers/files/binfmts            | 18 +++++++++++++++---
 srcpkgs/xbps-triggers/template                 |  2 +-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Manual.md b/Manual.md
index 73cd9088f9bc..c863cafeaf26 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1723,8 +1723,13 @@ executable binary formats, know as binfmts.
 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
 to register/remove entries from the arbitrary executable binary formats database.
 
-To include the trigger use the `binfmts` variable, as the trigger won't do anything unless
-it is defined.
+Include the trigger by specifying the `binfmt_files` variable. This variable
+contains a space separated list of format file, relative to
+`/usr/share/binfmts`. Each format file is passed to `update-binfmts --import`.
+
+The `binfmts` variable is deprecated, but still supported. The variable contains
+a newline separated list of arguments that are passed to
+`update-binfmts --package <pkgname> --install`.
 
 <a id="triggers_dkms"></a>
 #### dkms
diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh
index 0243d2400481..0011d7558fbc 100644
--- a/common/environment/setup-subpkg/subpkg.sh
+++ b/common/environment/setup-subpkg/subpkg.sh
@@ -40,6 +40,7 @@ unset -v make_dirs
 
 # xbps-triggers: binfmts
 unset -v binfmts
+unset -v binfmt_files
 
 # xbps-triggers: register-shell
 unset -v register_shell
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 8bb86c4487a5..ebd0d5e59567 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -123,6 +123,10 @@ _EOF
 		_add_trigger binfmts
 		echo "export binfmts=\"${binfmts}\"" >> $tmpf
 	fi
+	if [ -n "${binfmt_files}" ]; then
+		_add_trigger binfmts
+		echo "export binfmt_files=\"${binfmt_files}\"" >> $tmpf
+	fi
 	#
 	# Handle GNU Info files.
 	#
diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts
index 16919833a80b..cb9b680fc378 100755
--- a/srcpkgs/xbps-triggers/files/binfmts
+++ b/srcpkgs/xbps-triggers/files/binfmts
@@ -25,19 +25,26 @@ targets)
 	;;
 run)
 	[ -x /usr/bin/update-binfmts ] || exit 0
-	[ -z "${binfmts}" ] && exit 0
+	[ "${binfmts}" ] || [ "${binfmt_files}" ] || exit 0
 
 	case "$TARGET" in
 	post-install)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Installing binfmts...\n'
+		printf '%s' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
 			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--import "${binfmt}"
+		done
 		;;
 	pre-remove)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Removing binfmts...\n'
+		printf '%s' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
@@ -45,6 +52,11 @@ run)
 				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
 			fi
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--unimport "${binfmt}"
+		done
 		;;
 	*)
 		exit 1
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index 748942206ac5..5de97d53c210 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.120
+version=0.121
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

From e5ffd5567c62f0de889af38955a0ecca6a324e48 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:35:19 -0700
Subject: [PATCH 2/3] qemu-user-static: use binfmt_files

---
 srcpkgs/qemu-user-static/template | 115 ++++++------------------------
 1 file changed, 22 insertions(+), 93 deletions(-)

diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index 396eaeb30591..7c7ee47b63f2 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=5.2.0
-revision=2
+revision=3
 wrksrc="qemu-${version}"
 build_style=configure
 hostmakedepends="pkg-config automake python3 ninja"
@@ -14,97 +14,15 @@ homepage="https://www.qemu.org"
 distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2"
 checksum=7bd9334c02edaf02f5b0b52beb19fe7f72556c3ca0180e20f0095f0ef2f25f14
 
-_fmts="aarch64 aarch64_be alpha arm armeb cris hppa i386 m68k microblaze
- microblazeel mips mipsel mips64 mips64el mipsn32 mipsn32el or1k
- ppc ppcle ppc64 ppc64le riscv32 riscv64 s390x sh4 sh4eb
- sparc sparc32plus sparc64 x86_64 xtensa xtensaeb"
-
-_aarch64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_aarch64_be_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_be_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_alpha_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
-_alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_arm_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
-_arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_armeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
-_armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
-_cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_hppa_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f'
-_hppa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_i386_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
-_i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_m68k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
-_m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblaze_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
-_microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblazeel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xab\xba'
-_microblazeel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips64el_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mipsn32_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsn32el_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_or1k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5c'
-_or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
-_ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppcle_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00'
-_ppcle_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-_ppc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64le_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
-_ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-_riscv32_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00'
-_riscv32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_riscv64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00'
-_riscv64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_s390x_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
-_s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sh4_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-_sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_sh4eb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
-_sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
-_sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc32plus_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
-_sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
-_sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_x86_64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
-_x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_xtensa_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5e\x00'
-_xtensa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_xtensaeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5e'
-_xtensaeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*) _omit="i386|x86_64" ;;
-	aarch64*) _omit="aarch64" ;;
-	armv*) _omit="arm" ;;
-	ppc64le*) _omit="ppc64le|ppcle" ;;
-	ppc64*) _omit="ppc64|ppc" ;;
-	*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-esac
-
-for _fmt in $_fmts; do
-	eval "case $_fmt in $_omit) magic= ;; *) magic=\"\$_${_fmt}_magic\" mask=\"\$_${_fmt}_mask\" ;; esac"
-	if [ "$magic" ]; then
-		binfmts+="/usr/bin/qemu-$_fmt-static --magic $magic --mask $mask --offset 0 --credential yes
-"
-	fi
+# Copied from ${wrksrc}/scripts/qemu-binfmt-conf.sh
+_binfmt_archs="i386 i486 alpha arm armeb sparc sparc32plus sparc64 \
+ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \
+sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \
+microblaze microblazeel or1k x86_64 hexagon"
+for a in ${_binfmt_archs}; do
+	binfmt_files="${binfmt_files:-}${binfmt_files:+ }qemu-${a}"
 done
 
-binfmts="${binfmts%?}"
-
 post_extract() {
 	vsed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h
 }
@@ -125,12 +43,23 @@ do_configure() {
 
 do_install() {
 	make DESTDIR=${DESTDIR} install
+	# Install binfmt configurations
+	vmkdir usr/share/binfmts
+	HOST_ARCH="${XBPS_TARGET_MACHINE%-musl}" ./scripts/qemu-binfmt-conf.sh \
+		--debian --qemu-path /usr/bin --qemu-suffix -static \
+		--exportdir "${DESTDIR}/usr/share/binfmts"
 	# Remove unneeded stuff.
-	rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec
+	rm -rf -- "${DESTDIR}/etc" "${DESTDIR}/usr/libexec"
+	for d in doc locale man qemu; do
+		rm -rf -- "${DESTDIR}/usr/share/${d}"
+	done
 	for f in nbd io img; do
-		rm -f ${DESTDIR}/usr/bin/qemu-${f}
+		rm -f -- "${DESTDIR}/usr/bin/qemu-${f}"
 	done
+}
+
+post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
-		mv ${f} ${f}-static
+		mv "${f}" "${f}-static"
 	done
 }

From 953647910f07c4a310ba44fa847e643718d87abf Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Sun, 19 Apr 2020 00:25:06 -0700
Subject: [PATCH 3/3] wine: use binfmt_files

---
 srcpkgs/wine/files/binfmts/wine | 3 +++
 srcpkgs/wine/template           | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/wine/files/binfmts/wine

diff --git a/srcpkgs/wine/files/binfmts/wine b/srcpkgs/wine/files/binfmts/wine
new file mode 100644
index 000000000000..cb52a0763342
--- /dev/null
+++ b/srcpkgs/wine/files/binfmts/wine
@@ -0,0 +1,3 @@
+package wine
+interpreter /usr/bin/wine
+magic MZ
diff --git a/srcpkgs/wine/template b/srcpkgs/wine/template
index a88ba370500f..767bb9e0f8b6 100644
--- a/srcpkgs/wine/template
+++ b/srcpkgs/wine/template
@@ -1,7 +1,7 @@
 # Template file for 'wine'
 pkgname=wine
 version=6.7
-revision=1
+revision=2
 _pkgver=${version/r/-r}
 create_wrksrc=yes
 build_wrksrc=wine-${_pkgver}
@@ -91,6 +91,8 @@ do_check() {
 }
 
 post_install() {
+	# binfmt configuration
+	vinstall "${FILESDIR}/binfmts/wine" 0644 usr/share/binfmts
 	# Font aliasing settings for Win32 applications
 	install -d ${DESTDIR}/etc/fonts/conf.{avail,d}
 	install -m644 ${FILESDIR}/30-win32-aliases.conf ${DESTDIR}/etc/fonts/conf.avail
@@ -132,7 +134,7 @@ wine-devel_package() {
 
 wine-common_package() {
 	short_desc+=" - common files"
-	binfmts="/usr/bin/wine --magic MZ"
+	binfmt_files="wine"
 	pkg_install() {
 		vmove usr/share
 		vmove etc/fonts

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (16 preceding siblings ...)
  2021-04-27 22:44 ` [PR PATCH] [Updated] " CameronNemo
@ 2021-04-27 22:44 ` CameronNemo
  2021-04-27 23:08 ` CameronNemo
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2021-04-27 22:44 UTC (permalink / raw)
  To: ml

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

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r621667203

Comment:
I have accounted for sparc and sparc64. Someone needs to write a patch for QEMU to add ppcel (@q66 ?) and cris:

https://gitlab.com/qemu-project/qemu/-/blob/master/scripts/qemu-binfmt-conf.sh

https://wiki.qemu.org/Contribute/SubmitAPatch

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (17 preceding siblings ...)
  2021-04-27 22:44 ` [PR REVIEW] " CameronNemo
@ 2021-04-27 23:08 ` CameronNemo
  2021-04-27 23:13 ` ericonr
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2021-04-27 23:08 UTC (permalink / raw)
  To: ml

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

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r621677471

Comment:
On second thought, do we even want to have cris? It was ripped out of Linux in 4.16 (2018). And the existing ppcel patch just needs to be updated to take into account our use of the linked script.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (18 preceding siblings ...)
  2021-04-27 23:08 ` CameronNemo
@ 2021-04-27 23:13 ` ericonr
  2021-05-10 17:21 ` [PR PATCH] [Updated] " CameronNemo
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: ericonr @ 2021-04-27 23:13 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r621679620

Comment:
I'm okay with it being removed, just mention in the commit message please :)

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Updated]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (19 preceding siblings ...)
  2021-04-27 23:13 ` ericonr
@ 2021-05-10 17:21 ` CameronNemo
  2021-05-10 17:21 ` [PR REVIEW] " CameronNemo
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2021-05-10 17:21 UTC (permalink / raw)
  To: ml

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

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

https://github.com/CameronNemo/void-packages binfmt_files
https://github.com/void-linux/void-packages/pull/10395

 xbps-triggers: binfmt: use --import
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

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

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

From 8753895f6e78050bebb24603b65a7b86a89d2366 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:33:08 -0700
Subject: [PATCH 1/3] xbps-triggers: binfmt: use --import

Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.
---
 Manual.md                                      |  9 +++++++--
 common/environment/setup-subpkg/subpkg.sh      |  1 +
 .../04-create-xbps-metadata-scripts.sh         |  4 ++++
 srcpkgs/xbps-triggers/files/binfmts            | 18 +++++++++++++++---
 srcpkgs/xbps-triggers/template                 |  2 +-
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Manual.md b/Manual.md
index 73cd9088f9bc..c863cafeaf26 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1723,8 +1723,13 @@ executable binary formats, know as binfmts.
 During installation/removal it uses `update-binfmts` from the `binfmt-support` package
 to register/remove entries from the arbitrary executable binary formats database.
 
-To include the trigger use the `binfmts` variable, as the trigger won't do anything unless
-it is defined.
+Include the trigger by specifying the `binfmt_files` variable. This variable
+contains a space separated list of format file, relative to
+`/usr/share/binfmts`. Each format file is passed to `update-binfmts --import`.
+
+The `binfmts` variable is deprecated, but still supported. The variable contains
+a newline separated list of arguments that are passed to
+`update-binfmts --package <pkgname> --install`.
 
 <a id="triggers_dkms"></a>
 #### dkms
diff --git a/common/environment/setup-subpkg/subpkg.sh b/common/environment/setup-subpkg/subpkg.sh
index 0243d2400481..0011d7558fbc 100644
--- a/common/environment/setup-subpkg/subpkg.sh
+++ b/common/environment/setup-subpkg/subpkg.sh
@@ -40,6 +40,7 @@ unset -v make_dirs
 
 # xbps-triggers: binfmts
 unset -v binfmts
+unset -v binfmt_files
 
 # xbps-triggers: register-shell
 unset -v register_shell
diff --git a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
index 8bb86c4487a5..ebd0d5e59567 100644
--- a/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
+++ b/common/hooks/post-install/04-create-xbps-metadata-scripts.sh
@@ -123,6 +123,10 @@ _EOF
 		_add_trigger binfmts
 		echo "export binfmts=\"${binfmts}\"" >> $tmpf
 	fi
+	if [ -n "${binfmt_files}" ]; then
+		_add_trigger binfmts
+		echo "export binfmt_files=\"${binfmt_files}\"" >> $tmpf
+	fi
 	#
 	# Handle GNU Info files.
 	#
diff --git a/srcpkgs/xbps-triggers/files/binfmts b/srcpkgs/xbps-triggers/files/binfmts
index 16919833a80b..cb9b680fc378 100755
--- a/srcpkgs/xbps-triggers/files/binfmts
+++ b/srcpkgs/xbps-triggers/files/binfmts
@@ -25,19 +25,26 @@ targets)
 	;;
 run)
 	[ -x /usr/bin/update-binfmts ] || exit 0
-	[ -z "${binfmts}" ] && exit 0
+	[ "${binfmts}" ] || [ "${binfmt_files}" ] || exit 0
 
 	case "$TARGET" in
 	post-install)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Installing binfmts...\n'
+		printf '%s' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
 			update-binfmts --package ${PKGNAME} --install ${_bname} ${_bin} ${_args}
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--import "${binfmt}"
+		done
 		;;
 	pre-remove)
-		echo "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
+		printf 'Removing binfmts...\n'
+		printf '%s' "$binfmts" | tr '\' '&' 2> /dev/null | while read line; do
 			line=$(echo $line | tr '&' '\' 2> /dev/null)
 			set -- ${line}
 			_bin="$1"; shift; _args="$@"; _bname="$(basename ${_bin})"
@@ -45,6 +52,11 @@ run)
 				update-binfmts --package ${PKGNAME} --remove ${_bname} ${_bin}
 			fi
 		done
+		for binfmt in ${binfmt_files}; do
+			test -e "$(pwd)/usr/share/binfmts/${binfmt}" || continue
+			update-binfmts --importdir "$(pwd)/usr/share/binfmts" \
+				--unimport "${binfmt}"
+		done
 		;;
 	*)
 		exit 1
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index 748942206ac5..5de97d53c210 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.120
+version=0.121
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

From 8582d1632376495fe2f4c587e9b6b86cacc04c98 Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Fri, 19 Apr 2019 20:35:19 -0700
Subject: [PATCH 2/3] qemu-user-static: use binfmt_files

ppcel and cris architectures no longer ship binfmt files.
For the former, the ppcel patch will have to be updated to account for
the new binfmt method.
cris is old and largely unused, so it is being considered an acceptable
loss in functionality.
---
 srcpkgs/qemu-user-static/template       | 115 +++++-------------------
 srcpkgs/qemu/patches/qemu-binfmts.patch |  60 +++++++++++++
 2 files changed, 82 insertions(+), 93 deletions(-)
 create mode 100644 srcpkgs/qemu/patches/qemu-binfmts.patch

diff --git a/srcpkgs/qemu-user-static/template b/srcpkgs/qemu-user-static/template
index c6870e38d263..512eeb5ad4e1 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.0.0
-revision=1
+revision=2
 wrksrc="qemu-${version}"
 build_style=configure
 hostmakedepends="pkg-config automake python3 ninja"
@@ -14,97 +14,15 @@ homepage="https://www.qemu.org"
 distfiles="https://wiki.qemu.org/download/qemu-${version}.tar.bz2"
 checksum=7d306a03c67c0b667d21b55e1b172f5e55a9af5ee09cbd739fb2395aeca7860c
 
-_fmts="aarch64 aarch64_be alpha arm armeb cris hppa i386 m68k microblaze
- microblazeel mips mipsel mips64 mips64el mipsn32 mipsn32el or1k
- ppc ppcle ppc64 ppc64le riscv32 riscv64 s390x sh4 sh4eb
- sparc sparc32plus sparc64 x86_64 xtensa xtensaeb"
-
-_aarch64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_aarch64_be_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7'
-_aarch64_be_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_alpha_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90'
-_alpha_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_arm_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00'
-_arm_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_armeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28'
-_armeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
-_cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_hppa_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x0f'
-_hppa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_i386_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
-_i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_m68k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04'
-_m68k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblaze_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xba\xab'
-_microblaze_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_microblazeel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xab\xba'
-_microblazeel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsel_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsel_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mips64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mips64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mips64el_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mips64el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xfe\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_mipsn32_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08'
-_mipsn32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_mipsn32el_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00'
-_mipsn32el_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_or1k_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5c'
-_or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14'
-_ppc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppcle_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00'
-_ppcle_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-_ppc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15'
-_ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_ppc64le_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
-_ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
-_riscv32_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00'
-_riscv32_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_riscv64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00'
-_riscv64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_s390x_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16'
-_s390x_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sh4_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00'
-_sh4_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_sh4eb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a'
-_sh4eb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02'
-_sparc_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc32plus_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x12'
-_sparc32plus_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_sparc64_magic='\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b'
-_sparc64_mask='\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-_x86_64_magic='\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00'
-_x86_64_mask='\xff\xff\xff\xff\xff\xfe\xfe\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_xtensa_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5e\x00'
-_xtensa_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
-_xtensaeb_magic='\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x5e'
-_xtensaeb_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
-
-case "$XBPS_TARGET_MACHINE" in
-	x86_64*) _omit="i386|x86_64" ;;
-	aarch64*) _omit="aarch64" ;;
-	armv*) _omit="arm" ;;
-	ppc64le*) _omit="ppc64le|ppcle" ;;
-	ppc64*) _omit="ppc64|ppc" ;;
-	*) _omit="${XBPS_TARGET_MACHINE%-*}" ;;
-esac
-
-for _fmt in $_fmts; do
-	eval "case $_fmt in $_omit) magic= ;; *) magic=\"\$_${_fmt}_magic\" mask=\"\$_${_fmt}_mask\" ;; esac"
-	if [ "$magic" ]; then
-		binfmts+="/usr/bin/qemu-$_fmt-static --magic $magic --mask $mask --offset 0 --credential yes
-"
-	fi
+# Copied from ${wrksrc}/scripts/qemu-binfmt-conf.sh
+_binfmt_archs="i386 i486 alpha arm armeb sparc sparc32plus sparc64 \
+ppc ppc64 ppcle ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \
+sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \
+microblaze microblazeel or1k x86_64 cris"
+for a in ${_binfmt_archs}; do
+	binfmt_files="${binfmt_files:-}${binfmt_files:+ }qemu-${a}"
 done
 
-binfmts="${binfmts%?}"
-
 post_extract() {
 	vsed -i 's/__u64/unsigned long/' linux-user/host/aarch64/hostdep.h
 }
@@ -125,12 +43,23 @@ do_configure() {
 
 do_install() {
 	make DESTDIR=${DESTDIR} install
+	# Install binfmt configurations
+	vmkdir usr/share/binfmts
+	HOST_ARCH="${XBPS_TARGET_MACHINE%-musl}" ./scripts/qemu-binfmt-conf.sh \
+		--debian --qemu-path /usr/bin --qemu-suffix -static \
+		--exportdir "${DESTDIR}/usr/share/binfmts"
 	# Remove unneeded stuff.
-	rm -rf ${DESTDIR}/etc ${DESTDIR}/usr/share ${DESTDIR}/usr/libexec
+	rm -rf -- "${DESTDIR}/etc" "${DESTDIR}/usr/libexec"
+	for d in doc locale man qemu; do
+		rm -rf -- "${DESTDIR}/usr/share/${d}"
+	done
 	for f in nbd io img; do
-		rm -f ${DESTDIR}/usr/bin/qemu-${f}
+		rm -f -- "${DESTDIR}/usr/bin/qemu-${f}"
 	done
+}
+
+post_install() {
 	for f in ${DESTDIR}/usr/bin/*; do
-		mv ${f} ${f}-static
+		mv "${f}" "${f}-static"
 	done
 }
diff --git a/srcpkgs/qemu/patches/qemu-binfmts.patch b/srcpkgs/qemu/patches/qemu-binfmts.patch
new file mode 100644
index 000000000000..40c6f6481973
--- /dev/null
+++ b/srcpkgs/qemu/patches/qemu-binfmts.patch
@@ -0,0 +1,60 @@
+Source: Cameron Nemo <cnemo@tutanota.com>
+Upstream: false
+
+Add in the binfmts for ppcle and cris architectures.
+
+--- scripts/qemu-binfmt-conf.sh.orig	2021-04-27 16:04:03.556284793 -0700
++++ scripts/qemu-binfmt-conf.sh	2021-04-27 16:05:10.906096654 -0700
+@@ -2,9 +2,9 @@
+ # Enable automatic program execution by the kernel.
+ 
+ qemu_target_list="i386 i486 alpha arm armeb sparc sparc32plus sparc64 \
+-ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \
++ppc ppc64 ppcle ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \
+ sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \
+-microblaze microblazeel or1k x86_64"
++microblaze microblazeel or1k x86_64 cris"
+ 
+ i386_magic='\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00'
+ i386_mask='\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
+@@ -50,6 +50,10 @@
+ ppc64_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+ ppc64_family=ppc
+ 
++ppcle_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00'
++ppcle_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
++ppcle_family=ppcle
++
+ ppc64le_magic='\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00'
+ ppc64le_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00'
+ ppc64le_family=ppcle
+@@ -136,6 +140,10 @@
+ or1k_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff'
+ or1k_family=or1k
+ 
++cris_magic='\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x4c\x00'
++cris_mask='\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff'
++cris_family=cris
++
+ qemu_get_family() {
+     cpu=${HOST_ARCH:-$(uname -m)}
+     case "$cpu" in
+@@ -148,7 +156,7 @@
+     "Power Macintosh"|ppc64|powerpc|ppc)
+         echo "ppc"
+         ;;
+-    ppc64el|ppc64le)
++    ppc64el|ppc64le|ppcle)
+         echo "ppcle"
+         ;;
+     arm|armel|armhf|arm64|armv[4-9]*l|aarch64)
+@@ -163,6 +171,9 @@
+     riscv*)
+         echo "riscv"
+         ;;
++    cris*)
++        echo "cris"
++        ;;
+     *)
+         echo "$cpu"
+         ;;

From 3036e35c8c01f2d414113210225378c41c6de23a Mon Sep 17 00:00:00 2001
From: Cameron Nemo <cnemo@tutanota.com>
Date: Sun, 19 Apr 2020 00:25:06 -0700
Subject: [PATCH 3/3] wine: use binfmt_files

---
 srcpkgs/wine/files/binfmts/wine | 3 +++
 srcpkgs/wine/template           | 6 ++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/wine/files/binfmts/wine

diff --git a/srcpkgs/wine/files/binfmts/wine b/srcpkgs/wine/files/binfmts/wine
new file mode 100644
index 000000000000..cb52a0763342
--- /dev/null
+++ b/srcpkgs/wine/files/binfmts/wine
@@ -0,0 +1,3 @@
+package wine
+interpreter /usr/bin/wine
+magic MZ
diff --git a/srcpkgs/wine/template b/srcpkgs/wine/template
index 9a7171732704..cff15bd4e48e 100644
--- a/srcpkgs/wine/template
+++ b/srcpkgs/wine/template
@@ -1,7 +1,7 @@
 # Template file for 'wine'
 pkgname=wine
 version=6.8
-revision=1
+revision=2
 _pkgver=${version/r/-r}
 create_wrksrc=yes
 build_wrksrc=wine-${_pkgver}
@@ -91,6 +91,8 @@ do_check() {
 }
 
 post_install() {
+	# binfmt configuration
+	vinstall "${FILESDIR}/binfmts/wine" 0644 usr/share/binfmts
 	# Font aliasing settings for Win32 applications
 	install -d ${DESTDIR}/etc/fonts/conf.{avail,d}
 	install -m644 ${FILESDIR}/30-win32-aliases.conf ${DESTDIR}/etc/fonts/conf.avail
@@ -131,7 +133,7 @@ wine-devel_package() {
 
 wine-common_package() {
 	short_desc+=" - common files"
-	binfmts="/usr/bin/wine --magic MZ"
+	binfmt_files="wine"
 	pkg_install() {
 		vmove usr/share
 		vmove etc/fonts

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR REVIEW]  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (20 preceding siblings ...)
  2021-05-10 17:21 ` [PR PATCH] [Updated] " CameronNemo
@ 2021-05-10 17:21 ` CameronNemo
  2022-04-15  0:51 ` github-actions
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2021-05-10 17:21 UTC (permalink / raw)
  To: ml

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

New review comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#discussion_r629537800

Comment:
alright mentioned

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (21 preceding siblings ...)
  2021-05-10 17:21 ` [PR REVIEW] " CameronNemo
@ 2022-04-15  0:51 ` github-actions
  2022-04-29  2:13 ` [PR PATCH] [Closed]: " github-actions
  2022-09-30  3:12 ` CameronNemo
  24 siblings, 0 replies; 25+ messages in thread
From: github-actions @ 2022-04-15  0:51 UTC (permalink / raw)
  To: ml

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

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-1099749265

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PR PATCH] [Closed]:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (22 preceding siblings ...)
  2022-04-15  0:51 ` github-actions
@ 2022-04-29  2:13 ` github-actions
  2022-09-30  3:12 ` CameronNemo
  24 siblings, 0 replies; 25+ messages in thread
From: github-actions @ 2022-04-29  2:13 UTC (permalink / raw)
  To: ml

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

There's a closed pull request on the void-packages repository

 xbps-triggers: binfmt: use --import
https://github.com/void-linux/void-packages/pull/10395

Description:
Allow packages to specify format files to be imported by
the binfmt-support package, rather than specifying the
binfmt values in the package templates themselves.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
                   ` (23 preceding siblings ...)
  2022-04-29  2:13 ` [PR PATCH] [Closed]: " github-actions
@ 2022-09-30  3:12 ` CameronNemo
  24 siblings, 0 replies; 25+ messages in thread
From: CameronNemo @ 2022-09-30  3:12 UTC (permalink / raw)
  To: ml

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

New comment by CameronNemo on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-1263052726

Comment:
@classabbyamp if you want to look into using the binfmt import files, I think this PR is a good start

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re:  xbps-triggers: binfmt: use --import
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
@ 2020-03-06  9:54 ` Piraty
  2020-03-08  0:09 ` CameronNemo
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 25+ messages in thread
From: Piraty @ 2020-03-06  9:54 UTC (permalink / raw)
  To: ml

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

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/10395#issuecomment-595691458

Comment:
ping

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-09-30  3:12 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-10395@inbox.vuxu.org>
2020-03-06  9:54 ` xbps-triggers: binfmt: use --import Piraty
2020-03-08  0:09 ` CameronNemo
2020-04-19  7:26 ` [PR PATCH] [Updated] " CameronNemo
2020-07-10  0:17 ` fosslinux
2020-07-22 13:08 ` [PR REVIEW] " sgn
2020-09-21  0:12 ` [PR PATCH] [Updated] " CameronNemo
2020-09-21  0:13 ` [PR REVIEW] " CameronNemo
2020-09-21  1:06 ` CameronNemo
2020-09-21  1:07 ` CameronNemo
2020-11-01  1:40 ` ericonr
2020-11-01 19:11 ` [PR PATCH] [Updated] " CameronNemo
2020-11-01 19:11 ` CameronNemo
2020-11-02  4:08 ` ericonr
2020-11-02 17:49 ` [PR PATCH] [Updated] " CameronNemo
2021-01-13 18:22 ` [PR REVIEW] " ericonr
2021-02-11 21:39 ` ericonr
2021-04-27 22:44 ` [PR PATCH] [Updated] " CameronNemo
2021-04-27 22:44 ` [PR REVIEW] " CameronNemo
2021-04-27 23:08 ` CameronNemo
2021-04-27 23:13 ` ericonr
2021-05-10 17:21 ` [PR PATCH] [Updated] " CameronNemo
2021-05-10 17:21 ` [PR REVIEW] " CameronNemo
2022-04-15  0:51 ` github-actions
2022-04-29  2:13 ` [PR PATCH] [Closed]: " github-actions
2022-09-30  3:12 ` CameronNemo

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).