2021-01-07 22:30:30 +00:00
|
|
|
# Copyright 2021 Oliver Smith
|
2020-02-20 20:07:28 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2017-05-26 20:08:45 +00:00
|
|
|
import logging
|
pmb: qemu-user-static from aport, not from Debian
Overview:
In order to execute foreign arch binaries on the host system, we are
using the Linux kernel's binfmt_misc feature in combination with
static builds of QEMU. Before this patch, the statically compiled
QEMU binaries were taken from Debian (mostly because I did not realize
that Alpine ships them as well). Now we can use the ones from the aport.
Benefits:
This allows us to easily update and patch the QEMU executables, we
don't need to be in sync with Debian's versions anymore.
Alpine's package is more modular, so we can save some download,
install, zap time, as well as disk space: setting up an armhf chroot
with pmbootstrap took ~102 MB before, now it's ~18 MB.
Detailed changes:
* Remove `cross/qemu-user-static-repack` aport
* Add `data/qemu-user-binfmt.txt` with the binfmt_misc flags for ELF
binaries of various arches (extracted from Debian's packaging)
* When parsing that file, don't write verbose messages to
`pmbootstrap log` anymore, only to the verbose log (can be enabled
with `pmbootstrap -v`)
* Rename `pmb.parse.arch.alpine_to_debian()` to ...`alpine_to_qemu()`
* Rename `arch_debian` to `arch_qemu`
2018-08-01 21:38:37 +00:00
|
|
|
import pmb.config
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
# Get magic and mask from binfmt info file
|
|
|
|
# Return: {magic: ..., mask: ...}
|
|
|
|
|
|
|
|
|
2021-10-16 16:15:54 +00:00
|
|
|
def binfmt_info(arch_qemu):
|
2017-05-26 20:08:45 +00:00
|
|
|
# Parse the info file
|
|
|
|
full = {}
|
2018-09-17 10:06:57 +00:00
|
|
|
info = pmb.config.pmb_src + "/pmb/data/qemu-user-binfmt.txt"
|
pmb: qemu-user-static from aport, not from Debian
Overview:
In order to execute foreign arch binaries on the host system, we are
using the Linux kernel's binfmt_misc feature in combination with
static builds of QEMU. Before this patch, the statically compiled
QEMU binaries were taken from Debian (mostly because I did not realize
that Alpine ships them as well). Now we can use the ones from the aport.
Benefits:
This allows us to easily update and patch the QEMU executables, we
don't need to be in sync with Debian's versions anymore.
Alpine's package is more modular, so we can save some download,
install, zap time, as well as disk space: setting up an armhf chroot
with pmbootstrap took ~102 MB before, now it's ~18 MB.
Detailed changes:
* Remove `cross/qemu-user-static-repack` aport
* Add `data/qemu-user-binfmt.txt` with the binfmt_misc flags for ELF
binaries of various arches (extracted from Debian's packaging)
* When parsing that file, don't write verbose messages to
`pmbootstrap log` anymore, only to the verbose log (can be enabled
with `pmbootstrap -v`)
* Rename `pmb.parse.arch.alpine_to_debian()` to ...`alpine_to_qemu()`
* Rename `arch_debian` to `arch_qemu`
2018-08-01 21:38:37 +00:00
|
|
|
logging.verbose("parsing: " + info)
|
2017-05-26 20:08:45 +00:00
|
|
|
with open(info, "r") as handle:
|
|
|
|
for line in handle:
|
|
|
|
if line.startswith('#') or "=" not in line:
|
|
|
|
continue
|
2019-06-25 07:18:00 +00:00
|
|
|
split = line.split("=")
|
|
|
|
key = split[0].strip()
|
|
|
|
value = split[1]
|
2017-05-26 20:08:45 +00:00
|
|
|
full[key] = value[1:-2]
|
|
|
|
|
|
|
|
ret = {}
|
pmb: qemu-user-static from aport, not from Debian
Overview:
In order to execute foreign arch binaries on the host system, we are
using the Linux kernel's binfmt_misc feature in combination with
static builds of QEMU. Before this patch, the statically compiled
QEMU binaries were taken from Debian (mostly because I did not realize
that Alpine ships them as well). Now we can use the ones from the aport.
Benefits:
This allows us to easily update and patch the QEMU executables, we
don't need to be in sync with Debian's versions anymore.
Alpine's package is more modular, so we can save some download,
install, zap time, as well as disk space: setting up an armhf chroot
with pmbootstrap took ~102 MB before, now it's ~18 MB.
Detailed changes:
* Remove `cross/qemu-user-static-repack` aport
* Add `data/qemu-user-binfmt.txt` with the binfmt_misc flags for ELF
binaries of various arches (extracted from Debian's packaging)
* When parsing that file, don't write verbose messages to
`pmbootstrap log` anymore, only to the verbose log (can be enabled
with `pmbootstrap -v`)
* Rename `pmb.parse.arch.alpine_to_debian()` to ...`alpine_to_qemu()`
* Rename `arch_debian` to `arch_qemu`
2018-08-01 21:38:37 +00:00
|
|
|
logging.verbose("filtering by architecture: " + arch_qemu)
|
2017-05-26 20:08:45 +00:00
|
|
|
for type in ["mask", "magic"]:
|
pmb: qemu-user-static from aport, not from Debian
Overview:
In order to execute foreign arch binaries on the host system, we are
using the Linux kernel's binfmt_misc feature in combination with
static builds of QEMU. Before this patch, the statically compiled
QEMU binaries were taken from Debian (mostly because I did not realize
that Alpine ships them as well). Now we can use the ones from the aport.
Benefits:
This allows us to easily update and patch the QEMU executables, we
don't need to be in sync with Debian's versions anymore.
Alpine's package is more modular, so we can save some download,
install, zap time, as well as disk space: setting up an armhf chroot
with pmbootstrap took ~102 MB before, now it's ~18 MB.
Detailed changes:
* Remove `cross/qemu-user-static-repack` aport
* Add `data/qemu-user-binfmt.txt` with the binfmt_misc flags for ELF
binaries of various arches (extracted from Debian's packaging)
* When parsing that file, don't write verbose messages to
`pmbootstrap log` anymore, only to the verbose log (can be enabled
with `pmbootstrap -v`)
* Rename `pmb.parse.arch.alpine_to_debian()` to ...`alpine_to_qemu()`
* Rename `arch_debian` to `arch_qemu`
2018-08-01 21:38:37 +00:00
|
|
|
key = arch_qemu + "_" + type
|
2017-05-26 20:08:45 +00:00
|
|
|
if key not in full:
|
2021-01-31 18:16:56 +00:00
|
|
|
raise RuntimeError(
|
|
|
|
f"Could not find key {key} in binfmt info file: {info}")
|
2017-05-26 20:08:45 +00:00
|
|
|
ret[type] = full[key]
|
pmb: qemu-user-static from aport, not from Debian
Overview:
In order to execute foreign arch binaries on the host system, we are
using the Linux kernel's binfmt_misc feature in combination with
static builds of QEMU. Before this patch, the statically compiled
QEMU binaries were taken from Debian (mostly because I did not realize
that Alpine ships them as well). Now we can use the ones from the aport.
Benefits:
This allows us to easily update and patch the QEMU executables, we
don't need to be in sync with Debian's versions anymore.
Alpine's package is more modular, so we can save some download,
install, zap time, as well as disk space: setting up an armhf chroot
with pmbootstrap took ~102 MB before, now it's ~18 MB.
Detailed changes:
* Remove `cross/qemu-user-static-repack` aport
* Add `data/qemu-user-binfmt.txt` with the binfmt_misc flags for ELF
binaries of various arches (extracted from Debian's packaging)
* When parsing that file, don't write verbose messages to
`pmbootstrap log` anymore, only to the verbose log (can be enabled
with `pmbootstrap -v`)
* Rename `pmb.parse.arch.alpine_to_debian()` to ...`alpine_to_qemu()`
* Rename `arch_debian` to `arch_qemu`
2018-08-01 21:38:37 +00:00
|
|
|
logging.verbose("=> " + str(ret))
|
2017-05-26 20:08:45 +00:00
|
|
|
return ret
|