From 936e89adf21578ad1e7e52b25676885c0d800951 Mon Sep 17 00:00:00 2001 From: Cameron Nemo 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 --install`. #### 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 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 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