forked from Mirror/pmbootstrap
* change "pmbootstrap kconfig_check" to "pmbootstrap kconfig check" * change "pmbootstrap menuconfig" to "pmbootstrap kconfig edit [-x|-g]" (with legacy alias, because the first syntax was referenced to a lot) * enable X11 interfaces: -x: xconfig, -g: gconfig * new function to copy the xauthority file: pmb.chroot.other.copy_xauthority() * remove menufconfig() function from the kernel template and all kernel aports ([skip ci] because it would rebuild all kernels and run out of time). Alpine has dropped this as well, and it wouldn't work with the new code anyway.
124 lines
4.3 KiB
Python
124 lines
4.3 KiB
Python
"""
|
|
Copyright 2018 Oliver Smith
|
|
|
|
This file is part of pmbootstrap.
|
|
|
|
pmbootstrap is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
pmbootstrap is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
import os
|
|
import logging
|
|
|
|
import pmb.build
|
|
import pmb.build.autodetect
|
|
import pmb.build.checksum
|
|
import pmb.chroot
|
|
import pmb.chroot.apk
|
|
import pmb.chroot.other
|
|
import pmb.helpers.run
|
|
import pmb.parse
|
|
|
|
|
|
def get_arch(args, apkbuild):
|
|
"""
|
|
Get the architecture, that the user wants to run menuconfig on, depending on
|
|
the APKBUILD and on the --arch parameter.
|
|
|
|
:param apkbuild: looks like: {"pkgname": "linux-...",
|
|
"arch": ["x86_64", "armhf", "aarch64"]}
|
|
or: {"pkgname": "linux-...", "arch": ["armhf"]}
|
|
"""
|
|
pkgname = apkbuild["pkgname"]
|
|
|
|
# Multiple architectures (requires --arch)
|
|
if len(apkbuild["arch"]) > 1:
|
|
if args.arch is None:
|
|
raise RuntimeError("Package '" + pkgname + "' supports multiple"
|
|
" architectures, please use '--arch' to specify"
|
|
" the desired architecture.")
|
|
return args.arch
|
|
|
|
# Single architecture (--arch must be unset or match)
|
|
if args.arch is None or args.arch == apkbuild["arch"][0]:
|
|
return apkbuild["arch"][0]
|
|
raise RuntimeError("Package '" + pkgname + "' only supports the '" +
|
|
apkbuild["arch"][0] + "' architecture.")
|
|
|
|
|
|
def menuconfig(args, pkgname):
|
|
# Pkgname: allow omitting "linux-" prefix
|
|
if pkgname.startswith("linux-"):
|
|
pkgname_ = pkgname.split("linux-")[1]
|
|
logging.info("PROTIP: You can simply do 'pmbootstrap kconfig edit " +
|
|
pkgname_ + "'")
|
|
else:
|
|
pkgname = "linux-" + pkgname
|
|
|
|
# Read apkbuild
|
|
aport = pmb.build.find_aport(args, pkgname)
|
|
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
|
|
arch = get_arch(args, apkbuild)
|
|
kopt = "menuconfig"
|
|
|
|
# Set up build tools and makedepends
|
|
pmb.build.init(args)
|
|
depends = apkbuild["makedepends"]
|
|
kopt = "menuconfig"
|
|
copy_xauth = False
|
|
if args.xconfig:
|
|
depends += ["qt-dev", "font-noto"]
|
|
kopt = "xconfig"
|
|
copy_xauth = True
|
|
elif args.gconfig:
|
|
depends += ["gtk+2.0-dev", "glib-dev", "libglade-dev", "font-noto"]
|
|
kopt = "gconfig"
|
|
copy_xauth = True
|
|
else:
|
|
depends += ["ncurses-dev"]
|
|
pmb.chroot.apk.install(args, depends)
|
|
|
|
# Copy host's .xauthority into native
|
|
if copy_xauth:
|
|
pmb.chroot.other.copy_xauthority(args)
|
|
|
|
# Patch and extract sources
|
|
pmb.build.copy_to_buildpath(args, pkgname)
|
|
logging.info("(native) extract kernel source")
|
|
pmb.chroot.user(args, ["abuild", "unpack"], "native", "/home/pmos/build")
|
|
logging.info("(native) apply patches")
|
|
pmb.chroot.user(args, ["abuild", "prepare"], "native",
|
|
"/home/pmos/build", log=False, env={"CARCH": arch})
|
|
|
|
# Run make menuconfig
|
|
srcdir = "/home/pmos/build/src"
|
|
logging.info("(native) make " + kopt)
|
|
pmb.chroot.user(args, ["make", kopt], "native",
|
|
srcdir + "/build", log=False,
|
|
env={"ARCH": pmb.parse.arch.alpine_to_kernel(arch),
|
|
"DISPLAY": os.environ.get("DISPLAY"),
|
|
"XAUTHORITY": "/home/pmos/.Xauthority"})
|
|
|
|
# Find the updated config
|
|
source = args.work + "/chroot_native" + srcdir + "/build/.config"
|
|
if not os.path.exists(source):
|
|
raise RuntimeError("No kernel config generated: " + source)
|
|
|
|
# Update the aport (config and checksum)
|
|
logging.info("Copy kernel config back to aport-folder")
|
|
config = "config-" + apkbuild["_flavor"] + "." + arch
|
|
target = aport + "/" + config
|
|
pmb.helpers.run.user(args, ["cp", source, target])
|
|
pmb.build.checksum(args, pkgname)
|
|
|
|
# Check config
|
|
pmb.parse.kconfig.check(args, apkbuild["_flavor"], details=True)
|