diff --git a/pmb/__init__.py b/pmb/__init__.py index e0c8e0fa..f8438674 100644 --- a/pmb/__init__.py +++ b/pmb/__init__.py @@ -24,7 +24,7 @@ def main(): os.umask(0o22) # Sanity checks - other.check_grsec(args) + other.check_grsec() if not args.as_root and os.geteuid() == 0: raise RuntimeError("Do not run pmbootstrap as root!") diff --git a/pmb/build/envkernel.py b/pmb/build/envkernel.py index 44b2409a..a54f61d5 100644 --- a/pmb/build/envkernel.py +++ b/pmb/build/envkernel.py @@ -12,7 +12,7 @@ import pmb.helpers.pmaports import pmb.parse -def match_kbuild_out(args, word): +def match_kbuild_out(word): """ Look for paths in the following formats: "//arch//boot" @@ -47,7 +47,7 @@ def match_kbuild_out(args, word): return "" if out_dir is None else out_dir.strip("/") -def find_kbuild_output_dir(args, function_body): +def find_kbuild_output_dir(function_body): """ Guess what the kernel build output directory is. Parses each line of the function word by word, looking for paths which contain the kbuild output @@ -61,7 +61,7 @@ def find_kbuild_output_dir(args, function_body): guesses = [] for line in function_body: for item in line.split(): - kbuild_out = match_kbuild_out(args, item) + kbuild_out = match_kbuild_out(item) if kbuild_out is not None: guesses.append(kbuild_out) break @@ -176,7 +176,7 @@ def package_kernel(args): kbuild_out = apkbuild["_outdir"] else: function_body = pmb.parse.function_body(aport + "/APKBUILD", "package") - kbuild_out = find_kbuild_output_dir(args, function_body) + kbuild_out = find_kbuild_output_dir(function_body) suffix = pmb.build.autodetect.suffix(args, apkbuild, arch) # Install package dependencies diff --git a/pmb/build/menuconfig.py b/pmb/build/menuconfig.py index bfa67493..4cbefcc6 100644 --- a/pmb/build/menuconfig.py +++ b/pmb/build/menuconfig.py @@ -14,7 +14,7 @@ import pmb.helpers.run import pmb.parse -def get_arch(args, apkbuild): +def get_arch(apkbuild): """ Take the architecture from the APKBUILD or complain if it's ambiguous. This function only gets called if --arch is not set. @@ -90,7 +90,7 @@ def menuconfig(args, pkgname, use_oldconfig): # Read apkbuild aport = pmb.helpers.pmaports.find(args, pkgname) apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD") - arch = args.arch or get_arch(args, apkbuild) + arch = args.arch or get_arch(apkbuild) suffix = pmb.build.autodetect.suffix(args, apkbuild, arch) cross = pmb.build.autodetect.crosscompile(args, apkbuild, arch, suffix) hostspec = pmb.parse.arch.alpine_to_hostspec(arch) diff --git a/pmb/chroot/binfmt.py b/pmb/chroot/binfmt.py index 4328e372..a2c3bd86 100644 --- a/pmb/chroot/binfmt.py +++ b/pmb/chroot/binfmt.py @@ -33,7 +33,7 @@ def register(args, arch): if is_registered(arch_qemu): return - info = pmb.parse.binfmt_info(args, arch_qemu) + info = pmb.parse.binfmt_info(arch_qemu) # Build registration string # https://en.wikipedia.org/wiki/Binfmt_misc diff --git a/pmb/chroot/zap.py b/pmb/chroot/zap.py index 63ddf3f5..0776661b 100644 --- a/pmb/chroot/zap.py +++ b/pmb/chroot/zap.py @@ -106,7 +106,7 @@ def zap_pkgs_local_mismatch(args, confirm=True, dry=False): pattern = f"{args.work}/packages/{channel}/*/APKINDEX.tar.gz" for apkindex_path in glob.glob(pattern): # Delete packages without same version in aports - blocks = pmb.parse.apkindex.parse_blocks(args, apkindex_path) + blocks = pmb.parse.apkindex.parse_blocks(apkindex_path) for block in blocks: pkgname = block["pkgname"] origin = block["origin"] diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index f66beb9f..c6f1498f 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -368,7 +368,7 @@ def kconfig(args): if args.action_kconfig == "check": # Handle passing a file directly if args.file: - if pmb.parse.kconfig.check_file(args, args.package, + if pmb.parse.kconfig.check_file(args.package, anbox=args.anbox, nftables=args.nftables, containers=args.containers, diff --git a/pmb/helpers/git.py b/pmb/helpers/git.py index 8559b432..103098be 100644 --- a/pmb/helpers/git.py +++ b/pmb/helpers/git.py @@ -229,7 +229,7 @@ def pull(args, name_repo): return 0 -def is_outdated(args, path): +def is_outdated(path): # FETCH_HEAD always exists in repositories cloned by pmbootstrap. # Usually it does not (before first git fetch/pull), but there is no good # fallback. For exampe, getting the _creation_ date of .git/HEAD is non- diff --git a/pmb/helpers/other.py b/pmb/helpers/other.py index 7991e821..9b309782 100644 --- a/pmb/helpers/other.py +++ b/pmb/helpers/other.py @@ -29,7 +29,7 @@ def folder_size(args, path): return ret -def check_grsec(args): +def check_grsec(): """ Check if the current kernel is based on the grsec patchset, and if the chroot_deny_chmod option is enabled. Raise an exception in that diff --git a/pmb/helpers/status.py b/pmb/helpers/status.py index a925b715..3e3ec304 100644 --- a/pmb/helpers/status.py +++ b/pmb/helpers/status.py @@ -92,7 +92,7 @@ def print_checks_git_repo(args, repo, details=True): log_ok("up to date with remote branch") # Outdated remote information - if pmb.helpers.git.is_outdated(args, path): + if pmb.helpers.git.is_outdated(path): return log_nok_ret(-5, "outdated remote information", "update with 'pmbootstrap pull'") log_ok("remote information updated recently (via git fetch/pull)") diff --git a/pmb/parse/apkindex.py b/pmb/parse/apkindex.py index da328048..0d138ffc 100644 --- a/pmb/parse/apkindex.py +++ b/pmb/parse/apkindex.py @@ -9,7 +9,7 @@ import pmb.helpers.repo import pmb.parse.version -def parse_next_block(args, path, lines, start): +def parse_next_block(path, lines, start): """ Parse the next block in an APKINDEX. @@ -200,7 +200,7 @@ def parse(args, path, multiple_providers=True): ret = collections.OrderedDict() start = [0] while True: - block = parse_next_block(args, path, lines, start) + block = parse_next_block(path, lines, start) if not block: break @@ -223,7 +223,7 @@ def parse(args, path, multiple_providers=True): return ret -def parse_blocks(args, path): +def parse_blocks(path): """ Read all blocks from an APKINDEX.tar.gz into a list. @@ -244,7 +244,7 @@ def parse_blocks(args, path): ret = [] start = [0] while True: - block = pmb.parse.apkindex.parse_next_block(args, path, lines, start) + block = pmb.parse.apkindex.parse_next_block(path, lines, start) if not block: return ret ret.append(block) diff --git a/pmb/parse/binfmt_info.py b/pmb/parse/binfmt_info.py index 5af0f3b9..8bd5ac56 100644 --- a/pmb/parse/binfmt_info.py +++ b/pmb/parse/binfmt_info.py @@ -7,7 +7,7 @@ import pmb.config # Return: {magic: ..., mask: ...} -def binfmt_info(args, arch_qemu): +def binfmt_info(arch_qemu): # Parse the info file full = {} info = pmb.config.pmb_src + "/pmb/data/qemu-user-binfmt.txt" diff --git a/pmb/parse/kconfig.py b/pmb/parse/kconfig.py index 74551c1e..e5d36020 100644 --- a/pmb/parse/kconfig.py +++ b/pmb/parse/kconfig.py @@ -198,7 +198,7 @@ def extract_version(config_file): return "unknown" -def check_file(args, config_file, anbox=False, nftables=False, +def check_file(config_file, anbox=False, nftables=False, containers=False, zram=False, details=False): """ Check for necessary kernel config options in a kconfig file. diff --git a/test/test_envkernel.py b/test/test_envkernel.py index a9774e19..4f714be6 100644 --- a/test/test_envkernel.py +++ b/test/test_envkernel.py @@ -32,13 +32,12 @@ def test_package_kernel_args(args): str(e.value) -def test_find_kbuild_output_dir(args): +def test_find_kbuild_output_dir(): # Test parsing an APKBUILD pkgname = "linux-envkernel-test" path = pmb_test.const.testdata + "/apkbuild/APKBUILD." + pkgname function_body = pmb.parse.function_body(path, "package") - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert kbuild_out == "build" # Test full function body @@ -59,8 +58,7 @@ def test_find_kbuild_output_dir(args): " KBUILD_BUILD_VERSION=\"$((pkgrel + 1))-Alpine\" ", " INSTALL_MOD_PATH=\"$pkgdir\" modules_install", ] - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert kbuild_out == "build" # Test no kbuild out dir @@ -70,8 +68,7 @@ def test_find_kbuild_output_dir(args): " install -D \"$srcdir\"/include/config/kernel.release ", " \"$pkgdir\"/usr/share/kernel/$_flavor/kernel.release", ] - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert kbuild_out == "" # Test curly brackets around srcdir @@ -81,8 +78,7 @@ def test_find_kbuild_output_dir(args): " install -D \"${srcdir}\"/build/include/config/kernel.release ", " \"$pkgdir\"/usr/share/kernel/$_flavor/kernel.release", ] - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert kbuild_out == "build" # Test multiple sub directories @@ -92,8 +88,7 @@ def test_find_kbuild_output_dir(args): " install -D \"${srcdir}\"/sub/dir/include/config/kernel.release ", " \"$pkgdir\"/usr/share/kernel/$_flavor/kernel.release", ] - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert kbuild_out == "sub/dir" # Test no kbuild out dir found @@ -104,8 +99,7 @@ def test_find_kbuild_output_dir(args): " \"$pkgdir\"/usr/share/kernel/$_flavor/kernel.release", ] with pytest.raises(RuntimeError) as e: - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert ("Couldn't find a kbuild out directory. Is your APKBUILD messed up?" " If not, then consider adjusting the patterns in " "pmb/build/envkernel.py to work with your APKBUILD, or submit an " @@ -119,8 +113,7 @@ def test_find_kbuild_output_dir(args): " \"$pkgdir\"/usr/share/kernel/$_flavor/kernel.release", ] with pytest.raises(RuntimeError) as e: - kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(args, - function_body) + kbuild_out = pmb.build.envkernel.find_kbuild_output_dir(function_body) assert ("Multiple kbuild out directories found. Can you modify your " "APKBUILD so it only has one output path? If you can't resolve it," " please open an issue.") in str(e.value) diff --git a/test/test_helpers_git.py b/test/test_helpers_git.py index 8ad79eab..2c9bdfda 100644 --- a/test/test_helpers_git.py +++ b/test/test_helpers_git.py @@ -168,7 +168,7 @@ def test_pull(args, monkeypatch, tmpdir): assert func(args, name_repo) == 0 -def test_is_outdated(args, tmpdir, monkeypatch): +def test_is_outdated(tmpdir, monkeypatch): func = pmb.helpers.git.is_outdated # Override time.time(): now is "100" @@ -187,8 +187,8 @@ def test_is_outdated(args, tmpdir, monkeypatch): # Outdated (date_outdated: 90) monkeypatch.setattr(pmb.config, "git_repo_outdated", 10) - assert func(args, path) is True + assert func(path) is True # Not outdated (date_outdated: 89) monkeypatch.setattr(pmb.config, "git_repo_outdated", 11) - assert func(args, path) is False + assert func(path) is False diff --git a/test/test_helpers_status.py b/test/test_helpers_status.py index 1b1a00ae..ba835024 100644 --- a/test/test_helpers_status.py +++ b/test/test_helpers_status.py @@ -85,7 +85,7 @@ def test_print_checks_git_repo(args, monkeypatch, tmpdir): assert status == 0 # Outdated remote information - def is_outdated(args, path): + def is_outdated(path): return True monkeypatch.setattr(pmb.helpers.git, "is_outdated", is_outdated) status, _ = func(args, name_repo) diff --git a/test/test_kconfig_check.py b/test/test_kconfig_check.py index 0fa32ec4..688ed76a 100644 --- a/test/test_kconfig_check.py +++ b/test/test_kconfig_check.py @@ -23,20 +23,20 @@ def args(tmpdir, request): def test_kconfig_check(args): # basic checks, from easiers to hard-ish dir = f"{pmb_test.const.testdata}/kconfig_check/" - assert not pmb.parse.kconfig.check_file(args, dir + + assert not pmb.parse.kconfig.check_file(dir + "bad-missing-required-option") - assert pmb.parse.kconfig.check_file(args, dir + "good") - assert not pmb.parse.kconfig.check_file(args, dir + "bad-wrong-option-set") - assert pmb.parse.kconfig.check_file(args, dir + "good-anbox", + assert pmb.parse.kconfig.check_file(dir + "good") + assert not pmb.parse.kconfig.check_file(dir + "bad-wrong-option-set") + assert pmb.parse.kconfig.check_file(dir + "good-anbox", anbox=True) - assert not pmb.parse.kconfig.check_file(args, dir + + assert not pmb.parse.kconfig.check_file(dir + "bad-array-missing-some-options", anbox=True) - assert pmb.parse.kconfig.check_file(args, dir + "good-nftables", + assert pmb.parse.kconfig.check_file(dir + "good-nftables", nftables=True) - assert not pmb.parse.kconfig.check_file(args, dir + "bad-nftables", + assert not pmb.parse.kconfig.check_file(dir + "bad-nftables", nftables=True) - assert pmb.parse.kconfig.check_file(args, dir + "good-zram", + assert pmb.parse.kconfig.check_file(dir + "good-zram", zram=True) # tests on real devices diff --git a/test/test_parse_apkindex.py b/test/test_parse_apkindex.py index b5ae4dc7..6cf9d569 100644 --- a/test/test_parse_apkindex.py +++ b/test/test_parse_apkindex.py @@ -23,7 +23,7 @@ def args(tmpdir, request): return args -def test_parse_next_block_exceptions(args): +def test_parse_next_block_exceptions(): # Mapping of input files (inside the /test/testdata/apkindex) to # error message substrings mapping = {"key_twice": "specified twice", @@ -37,11 +37,11 @@ def test_parse_next_block_exceptions(args): lines = handle.readlines() with pytest.raises(RuntimeError) as e: - pmb.parse.apkindex.parse_next_block(args, path, lines, [0]) + pmb.parse.apkindex.parse_next_block(path, lines, [0]) assert error_substr in str(e.value) -def test_parse_next_block_no_error(args): +def test_parse_next_block_no_error(): # Read the file func = pmb.parse.apkindex.parse_next_block path = pmb.config.pmb_src + "/test/testdata/apkindex/no_error" @@ -57,7 +57,7 @@ def test_parse_next_block_no_error(args): 'provides': ['so:libc.musl-x86_64.so.1'], 'timestamp': '1515217616', 'version': '1.1.18-r5'} - assert func(args, path, lines, start) == block + assert func(path, lines, start) == block assert start == [24] # Second block @@ -71,15 +71,15 @@ def test_parse_next_block_no_error(args): 'provides': ['cmd:curl'], 'timestamp': '1512030418', 'version': '7.57.0-r0'} - assert func(args, path, lines, start) == block + assert func(path, lines, start) == block assert start == [45] # No more blocks - assert func(args, path, lines, start) is None + assert func(path, lines, start) is None assert start == [45] -def test_parse_next_block_virtual(args): +def test_parse_next_block_virtual(): """ Test parsing a virtual package from an APKINDEX. """ @@ -98,7 +98,7 @@ def test_parse_next_block_virtual(args): 'provides': ['cmd:hello-world'], 'timestamp': '1500000000', 'version': '2-r0'} - assert func(args, path, lines, start) == block + assert func(path, lines, start) == block assert start == [20] # Second block: virtual package @@ -107,11 +107,11 @@ def test_parse_next_block_virtual(args): 'pkgname': '.pmbootstrap', 'provides': [], 'version': '0'} - assert func(args, path, lines, start) == block + assert func(path, lines, start) == block assert start == [31] # No more blocks - assert func(args, path, lines, start) is None + assert func(path, lines, start) is None assert start == [31]