Compare commits

...

15 Commits

Author SHA1 Message Date
Oliver Smith 8c7e99acd9
Prepare 1.43.1 release 2022-05-15 18:47:46 +02:00
David Wronek be9aab895b
pmb.install: Check for alpine-conf version (MR 2182)
Upstream Alpine change the way how `setup-timezone` works, it no longer
uses the `-z` argument to change the timezone.
2022-05-15 16:51:53 +02:00
Clayton Craft 9901cb31ea
pmb.parse.depends: ignore conflict dependency that no longer exists (MR 2181)
So it looks like some packages might be mentioned in the "depends=" of
other packages and marked as conflict, for example:
    depends="!foo"

..and the conflicting package can be dropped from the repo entirely if
it is no longer needed, however the reference to it in `depends=` still
exists. This handles that situation by just ignoring the missing package
if it is only a conflicting dependency.

fixes https://gitlab.com/postmarketOS/pmaports/-/issues/1525
2022-05-12 22:26:53 -07:00
Oliver Smith 6fbe916e0d
Prepare 1.43.0 release 2022-04-14 09:33:20 +02:00
Oliver Smith 7abb281296
partitions_mount: fix finding the partition (MR 2178)
Instead of trying both "${dev}1" and "${dev}p1" as partition paths, only
try one of them depending on if "${dev}" ends in a number or not. This
fixes getting a wrong /dev/loop11 partition by accident if there are
many loop devices, instead of only looking for the correct path
/dev/loop1p1. People reported this happening with snaps on ubuntu.
2022-04-14 09:09:46 +02:00
Minecrell faf523911a
pmb.install: Treat empty "flash_sparse_samsung_format" as disabled (MR 2180)
Deviceinfo variables are empty strings by default if they are unset
in the deviceinfo file, so the "is not None" check currently enables
the sm_sparse_image_tool for all existing devices using sparse format.

Simplify the check to convert the string to a bool. Empty strings
evaluate to False so this should work as originally intended.
2022-04-13 21:01:20 +02:00
Enrico Lumetti dee8e34298
pmb.config, pmb.install: add option to handle Samsung sparse image format (MR 2177) 2022-04-13 08:59:29 +02:00
Newbyte ff569ece14
config: Move ASHMEM into conditional (MR 2176)
Option was dropped and is no longer available.

See https://lore.kernel.org/all/20220315123457.2354812-1-hch@lst.de
And 721412ed3d
2022-04-05 21:04:22 +02:00
Newbyte 9a74848f19
pmb.parse.kconfig: print a helpful error message on invalid kconfig name (MR 2172)
Currently pmbootstrap prints a stacktrace if there's no . in the
kernel configuration name. Let's make it more helpful.
2022-04-02 16:36:17 +02:00
Alexey Min 0bab8ab6d2
install: fix alignment of information messages (MR 2174)
Make it in line with other information messages in this section.
Otherwise lk2nd flashing info paragraph looks shifted to the right.
2022-03-29 20:06:40 +03:00
Alexey Min fd74b54001
config: allow using flash_lk2nd with heimdall too (MR 2174)
One of the main purposes of lk2nd is to have a replacement for
the stock bootloader "Odin mode" on many Samsung devices with
sane fastboot implementation, which supports many more features
like live booting and many others.

This is done by using heimdall to flash lk2nd to device's boot
partition. Allow this method to be used with this flash action.
2022-03-29 15:36:08 +03:00
Newbyte 5389543c1a
helpers/envkernel.sh: use "$pmbootstrap" in cross_compiler_version() (MR 2173)
This fixes an issue where if pmbootstrap is accessed via a
different command than pmbootstrap on the user's system (I have it
set to pmb for example), cross_compiler_version() would try to use
a command that doesn't exist. On my system, this results in it
always asking if I want to install pmbootstrap every time I run
envkerenl.sh.
2022-03-24 00:25:01 +03:00
Bart Ribbers 1eef7fbdeb
pmb.parse.kconfig: implement UEFI kconfig check (MR 2169) 2022-03-16 09:25:00 +01:00
Oliver Smith 8c429f74ca
test_kconfig_check: note: don't add device tests (MR 2169)
Add a comment that we shouldn't add more tests relying on devices in
currently checked out pmaports.git (see issue 2105).
2022-03-16 09:25:00 +01:00
Oliver Smith 301f0995fb
pmb.parse.kconfig.check_file: fix broken f-string (MR 2169) 2022-03-16 09:24:55 +01:00
13 changed files with 229 additions and 25 deletions

View File

@ -260,7 +260,7 @@ set_alias_pmbroot_kernelroot() {
cross_compiler_version() {
if [ "$need_cross_compiler" = 1 ]; then
pmbootstrap chroot --user -- "${cross_compiler}gcc" --version \
"$pmbootstrap" chroot --user -- "${cross_compiler}gcc" --version \
2> /dev/null | grep "^.*gcc " | \
awk -F'[()]' '{ print $1 "("$2")" }'
else

View File

@ -158,4 +158,5 @@ def menuconfig(args, pkgname, use_oldconfig):
force_containers_check=False,
force_zram_check=False,
force_netboot_check=False,
force_uefi_check=False,
details=True)

View File

@ -17,7 +17,7 @@ from pmb.config.sudo import which_sudo
#
# Exported variables (internal configuration)
#
version = "1.42.0"
version = "1.43.1"
pmb_src = os.path.normpath(os.path.realpath(__file__) + "/../../..")
apk_keys_path = pmb_src + "/pmb/data/keys"
arch_native = pmb.parse.arch.alpine_native()
@ -27,11 +27,11 @@ arch_native = pmb.parse.arch.alpine_native()
# Update this frequently to prevent a MITM attack with an outdated version
# (which may contain a vulnerable apk/openssl, and allows an attacker to
# exploit the system!)
apk_tools_min_version = {"edge": "2.12.9-r1",
apk_tools_min_version = {"edge": "2.12.9-r3",
"v3.15": "2.12.7-r3",
"v3.14": "2.12.7-r0",
"v3.13": "2.12.7-r0",
"v3.12": "2.10.8-r0"}
"v3.12": "2.10.8-r1"}
# postmarketOS aports compatibility (checked against "version" in pmaports.cfg)
pmaports_min_version = "7"
@ -336,7 +336,6 @@ necessary_kconfig_options_anbox = {
"SQUASHFS_XZ": True,
"SQUASHFS_XATTR": True,
"TMPFS_XATTR": True,
"ASHMEM": True,
"ANDROID_BINDER_IPC": True,
"ANDROID_BINDERFS": False,
"ANDROID_BINDER_DEVICES": ["binder", "hwbinder"],
@ -362,6 +361,11 @@ necessary_kconfig_options_anbox = {
"PSI": True, # required by userspace OOM killer in Waydroid
"PSI_DEFAULT_DISABLED": False,
}
},
"<5.18_rc1": { # option has been dropped
"all": {
"ASHMEM": True,
}
}
}
@ -581,6 +585,22 @@ necessary_kconfig_options_netboot = {
},
}
# Necessary UEFI boot config options
necessary_kconfig_options_uefi = {
">=0.0.0": { # all versions
"all": { # all arches
"EFI_STUB": True,
"EFI": True,
"DMI": True,
"EFI_ESRT": True,
"EFI_VARS_PSTORE": True,
"EFI_PARAMS_FROM_FDT": True,
"EFI_RUNTIME_WRAPPERS": True,
"EFI_GENERIC_STUB": True,
}
},
}
#
# PARSE
#
@ -711,6 +731,7 @@ deviceinfo_attributes = [
"flash_pagesize",
"flash_fastboot_max_size",
"flash_sparse",
"flash_sparse_samsung_format",
"rootfs_image_sector_size",
"sd_embed_firmware",
"sd_embed_firmware_step_size",
@ -881,7 +902,10 @@ flashers = {
"--padding_size", "$FLASH_PAGESIZE",
"--output", "/vbmeta.img"],
["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img"],
["rm", "-f", "/vbmeta.img"]]
["rm", "-f", "/vbmeta.img"]],
"flash_lk2nd": [
["heimdall_wait_for_device.sh"],
["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img"]]
},
},
"adb": {

View File

@ -384,6 +384,7 @@ def kconfig(args):
containers=args.containers,
zram=args.zram,
netboot=args.netboot,
uefi=args.uefi,
details=True):
logging.info("kconfig check succeeded!")
return
@ -420,6 +421,7 @@ def kconfig(args):
force_containers_check=args.containers,
force_zram_check=args.zram,
force_netboot_check=args.netboot,
force_uefi_check=args.uefi,
details=True):
error = True

View File

@ -714,6 +714,19 @@ def install_system_image(args, size_reserve, suffix, step, steps,
pmb.chroot.user(args, ["mv", "-f", sys_image_sparse, sys_image],
working_dir="/home/pmos/rootfs/")
# patch sparse image for Samsung devices if specified
samsungify_strategy = args.deviceinfo["flash_sparse_samsung_format"]
if samsungify_strategy:
logging.info("(native) convert sparse image into Samsung's sparse image format")
pmb.chroot.apk.install(args, ["sm-sparse-image-tool"])
sys_image = f"{args.device}.img"
sys_image_patched = f"{args.device}-patched.img"
pmb.chroot.user(args, ["sm_sparse_image_tool", "samsungify", "--strategy",
samsungify_strategy, sys_image, sys_image_patched],
working_dir="/home/pmos/rootfs/")
pmb.chroot.user(args, ["mv", "-f", sys_image_patched, sys_image],
working_dir="/home/pmos/rootfs/")
def print_flash_info(args):
""" Print flashing information, based on the deviceinfo data and the
@ -790,7 +803,7 @@ def print_flash_info(args):
if "flash_lk2nd" in flasher_actions and \
os.path.exists(args.work + "/chroot_rootfs_" + args.device +
"/boot/lk2nd.img"):
logging.info(" * Your device supports and may even require"
logging.info("* Your device supports and may even require"
" flashing lk2nd. You should flash it before"
" flashing anything else. Use 'pmbootstrap flasher"
" flash_lk2nd' to do that.")
@ -982,7 +995,14 @@ def create_device_rootfs(args, step, steps):
setup_keymap(args)
# Set timezone
pmb.chroot.root(args, ["setup-timezone", "-z", args.timezone], suffix)
arch = args.deviceinfo["arch"]
package = pmb.helpers.package.get(args, "alpine-conf", arch)
version = package["version"].split("-r")[0]
if not pmb.parse.version.check_string(version, ">=3.14.0"):
pmb.chroot.root(args, ["setup-timezone", "-z", args.timezone], suffix)
else:
pmb.chroot.root(args, ["setup-timezone", args.timezone], suffix)
# Set locale
if locale_is_set:

View File

@ -19,23 +19,27 @@ def partitions_mount(args, layout, sdcard):
img_path = "/home/pmos/rootfs/" + args.device + ".img"
prefix = pmb.install.losetup.device_by_back_file(args, img_path)
partition_prefix = None
tries = 20
# Devices ending with a number have a "p" before the partition number,
# /dev/sda1 has no "p", but /dev/mmcblk0p1 has. See add_partition() in
# block/partitions/core.c of linux.git.
partition_prefix = prefix
if str.isdigit(prefix[-1:]):
partition_prefix = f"{prefix}p"
found = False
for i in range(tries):
for symbol in ["p", ""]:
if os.path.exists(prefix + symbol + "1"):
partition_prefix = symbol
if partition_prefix is not None:
if os.path.exists(f"{partition_prefix}1"):
found = True
break
logging.debug(f"NOTE: ({i + 1}/{tries}) failed to find the install "
"partition. Retrying...")
time.sleep(0.1)
if partition_prefix is None:
raise RuntimeError("Unable to find the partition prefix,"
" expected the first partition of " +
prefix + " to be located at " + prefix +
"1 or " + prefix + "p1!")
if not found:
raise RuntimeError(f"Unable to find the first partition of {prefix}, "
f"expected it to be at {partition_prefix}1!")
partitions = [layout["boot"], layout["root"]]
@ -43,7 +47,7 @@ def partitions_mount(args, layout, sdcard):
partitions += [layout["kernel"]]
for i in partitions:
source = prefix + partition_prefix + str(i)
source = f"{partition_prefix}{i}"
target = args.work + "/chroot_native/dev/installp" + str(i)
pmb.helpers.mount.bind_file(args, source, target)

View File

@ -477,7 +477,9 @@ def arguments_kconfig(subparser):
check.add_argument("--zram", action="store_true", help="check"
" options needed for zram support too")
check.add_argument("--netboot", action="store_true", help="check"
" options needed for netboooting too")
" options needed for netbooting too")
check.add_argument("--uefi", action="store_true", help="check"
" options needed for uefi too")
add_kernel_arg(check)
# "pmbootstrap kconfig edit"

View File

@ -144,6 +144,11 @@ def recurse(args, pkgnames, suffix="native"):
# Nothing found
if not package:
if is_conflict:
# This package was probably dropped from the repos, so we don't
# care if it doesn't exist since it's a conflicting depend that
# wouldn't be installed anyways.
continue
source = 'world'
if pkgname_depend in required_by:
source = ', '.join(required_by[pkgname_depend])

View File

@ -92,6 +92,7 @@ def check_config(config_path, config_path_pretty, config_arch, pkgver,
containers=False,
zram=False,
netboot=False,
uefi=False,
details=False):
logging.debug(f"Check kconfig: {config_path}")
with open(config_path) as handle:
@ -113,6 +114,8 @@ def check_config(config_path, config_path_pretty, config_arch, pkgver,
components["zram"] = pmb.config.necessary_kconfig_options_zram
if netboot:
components["netboot"] = pmb.config.necessary_kconfig_options_netboot
if uefi:
components["uefi"] = pmb.config.necessary_kconfig_options_uefi
results = [check_config_options_set(config, config_path_pretty,
config_arch, options, component,
@ -163,6 +166,7 @@ def check(args, pkgname,
force_containers_check=False,
force_zram_check=False,
force_netboot_check=False,
force_uefi_check=False,
details=False):
"""
Check for necessary kernel config options in a package.
@ -194,10 +198,23 @@ def check(args, pkgname,
"pmb:kconfigcheck-zram" in apkbuild["options"])
check_netboot = force_netboot_check or (
"pmb:kconfigcheck-netboot" in apkbuild["options"])
check_uefi = force_uefi_check or (
"pmb:kconfigcheck-uefi" in apkbuild["options"])
for config_path in glob.glob(aport + "/config-*"):
# The architecture of the config is in the name, so it just needs to be
# extracted
config_arch = os.path.basename(config_path).split(".")[1]
config_name = os.path.basename(config_path)
config_name_split = config_name.split(".")
if len(config_name_split) != 2:
raise RuntimeError(f"{config_name} is not a valid kernel config "
"name. Ensure that the _config property in your "
"kernel APKBUILD has a . before the "
"architecture name, e.g. .aarch64 or .armv7, "
"and that there is no excess punctuation "
"elsewhere in the name.")
config_arch = config_name_split[1]
config_path_pretty = f"linux-{flavor}/{os.path.basename(config_path)}"
ret &= check_config(config_path, config_path_pretty, config_arch,
pkgver,
@ -208,6 +225,7 @@ def check(args, pkgname,
containers=check_containers,
zram=check_zram,
netboot=check_netboot,
uefi=check_uefi,
details=details)
return ret
@ -245,7 +263,8 @@ def extract_version(config_file):
def check_file(config_file, anbox=False, nftables=False,
containers=False, zram=False, netboot=False, details=False):
containers=False, zram=False, netboot=False, uefi=False,
details=False):
"""
Check for necessary kernel config options in a kconfig file.
@ -254,11 +273,12 @@ def check_file(config_file, anbox=False, nftables=False,
arch = extract_arch(config_file)
version = extract_version(config_file)
logging.debug(f"Check kconfig: parsed arch={arch}, version={version} from "
"file: {config_file}")
f"file: {config_file}")
return check_config(config_file, config_file, arch, version,
anbox=anbox,
nftables=nftables,
containers=containers,
zram=zram,
netboot=netboot,
uefi=uefi,
details=details)

View File

@ -38,8 +38,15 @@ def test_kconfig_check(args):
nftables=True)
assert pmb.parse.kconfig.check_file(dir + "good-zram",
zram=True)
assert pmb.parse.kconfig.check_file(dir + "good-uefi",
uefi=True)
assert not pmb.parse.kconfig.check_file(dir + "bad-uefi",
uefi=True)
# tests on real devices
# *** do not add more of these! ***
# moving forward, tests in pmbootstrap.git should become more/completely
# independent of the currently checked out pmaports.git (#2105)
# it's a postmarketOS device, it will have the required options, and
# supports nftables (with pmb:kconfigcheck-nftables)

View File

@ -146,13 +146,16 @@ def test_recurse(args, monkeypatch):
depends = {
"test": ["libtest", "so:libtest.so.1"],
"libtest": ["libtest_depend"],
"libtest_depend": ["!libtest_conflict"],
"libtest_depend": ["!libtest_conflict", "!libtest_conflict_missing"],
"libtest_conflict": [],
"so:libtest.so.1": ["libtest_depend"],
}
def package_from_index(args, pkgname, install, aport, suffix):
return {"pkgname": pkgname, "depends": depends[pkgname]}
if pkgname in depends:
return {"pkgname": pkgname, "depends": depends[pkgname]}
else:
return None
monkeypatch.setattr(pmb.parse.depends, "package_from_index",
package_from_index)

58
test/testdata/kconfig_check/bad-uefi vendored Normal file
View File

@ -0,0 +1,58 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.12.2 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="aarch64-alpine-linux-musl-gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100301
CONFIG_CLANG_VERSION=0
CONFIG_LD_IS_BFD=y
CONFIG_LD_VERSION=23502
CONFIG_LLD_VERSION=0
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_TABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y
#
# General setup
#
CONFIG_LOCALVERSION="-zram-good"
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_LZMA is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# needed for bubblewrap
CONFIG_USER_NS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CGROUPS=y
CONFIG_DEVTMPFS=y
CONFIG_DM_CRYPT=y
CONFIG_INPUT_EVDEV=y
CONFIG_SYSVIPC=y
CONFIG_VT=y
CONFIG_UEVENT_HELPER=y
CONFIG_LBDAF=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_XTS=y
CONFIG_TMPFS_POSIX_ACL=y
### here's one explicitely disabled:
# ANDROID_PARANOID_NETWORK is not set
### here's one set to module:
CONFIG_EXT4_FS=m
### here's a line set to no:
CONFIG_KINETO_GAN=n
# the required options
#
CONFIG_EFI=n
CONFIG_EFI_STUB=n
CONFIG_DMI=n
CONFIG_EFI_ESRT=n
CONFIG_EFI_VARS_PSTORE=n
CONFIG_EFI_PARAMS_FROM_FDT=n
CONFIG_EFI_RUNTIME_WRAPPERS=n
CONFIG_EFI_GENERIC_STUB=n

58
test/testdata/kconfig_check/good-uefi vendored Normal file
View File

@ -0,0 +1,58 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.12.2 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="aarch64-alpine-linux-musl-gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100301
CONFIG_CLANG_VERSION=0
CONFIG_LD_IS_BFD=y
CONFIG_LD_VERSION=23502
CONFIG_LLD_VERSION=0
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_TABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y
#
# General setup
#
CONFIG_LOCALVERSION="-zram-good"
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_LZMA is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# needed for bubblewrap
CONFIG_USER_NS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CGROUPS=y
CONFIG_DEVTMPFS=y
CONFIG_DM_CRYPT=y
CONFIG_INPUT_EVDEV=y
CONFIG_SYSVIPC=y
CONFIG_VT=y
CONFIG_UEVENT_HELPER=y
CONFIG_LBDAF=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_XTS=y
CONFIG_TMPFS_POSIX_ACL=y
### here's one explicitely disabled:
# ANDROID_PARANOID_NETWORK is not set
### here's one set to module:
CONFIG_EXT4_FS=m
### here's a line set to no:
CONFIG_KINETO_GAN=n
# the required options
#
CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_DMI=y
CONFIG_EFI_ESRT=y
CONFIG_EFI_VARS_PSTORE=y
CONFIG_EFI_PARAMS_FROM_FDT=y
CONFIG_EFI_RUNTIME_WRAPPERS=y
CONFIG_EFI_GENERIC_STUB=y