remove unused args argument (MR 2130)
This commit is contained in:
parent
896879e89a
commit
a8d425554c
|
@ -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!")
|
||||
|
||||
|
|
|
@ -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:
|
||||
"<prefix>/<kbuild_out>/arch/<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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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-
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue