forked from Mirror/pmbootstrap
pmbootstrap kconfig edit: support $builddir and $srcdir/build (#1573)
The linux APKBUILDs write the kernel config either to `$builddir` (default from the template) or `$srcdir/build` (legacy, and I reverted to that in #1556, which was not the proper fix for this regression). With this commit, `pmbootstrap kconfig edit` is able to edit both versions, and prints a note when the APKBUILD is still using the old style.
This commit is contained in:
parent
de1f244917
commit
a4728124f0
2 changed files with 36 additions and 5 deletions
|
@ -110,9 +110,8 @@ def generate_apkbuild(args, pkgname, deviceinfo):
|
||||||
done
|
done
|
||||||
|
|
||||||
# Prepare kernel config ('yes ""' for kernels lacking olddefconfig)
|
# Prepare kernel config ('yes ""' for kernels lacking olddefconfig)
|
||||||
mkdir -p "$srcdir"/build
|
|
||||||
cp "$srcdir"/$_config "$builddir"/.config
|
cp "$srcdir"/$_config "$builddir"/.config
|
||||||
yes "" | make O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" oldconfig
|
yes "" | make ARCH="$_carch" HOSTCC="$HOSTCC" oldconfig
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {""" + build + """
|
build() {""" + build + """
|
||||||
|
|
|
@ -55,6 +55,38 @@ def get_arch(args, apkbuild):
|
||||||
apkbuild["arch"][0] + "' architecture.")
|
apkbuild["arch"][0] + "' architecture.")
|
||||||
|
|
||||||
|
|
||||||
|
def get_outputdir(args, pkgname):
|
||||||
|
"""
|
||||||
|
Get the folder for the kernel compilation output.
|
||||||
|
For most APKBUILDs, this is $builddir. But some older ones still use
|
||||||
|
$srcdir/build (see the discussion in #1551).
|
||||||
|
"""
|
||||||
|
# Old style ($srcdir/build)
|
||||||
|
ret = "/home/pmos/build/src/build"
|
||||||
|
chroot = args.work + "/chroot_native"
|
||||||
|
if os.path.exists(chroot + ret + "/.config"):
|
||||||
|
logging.warning("*****")
|
||||||
|
logging.warning("NOTE: The code in this linux APKBUILD is pretty old."
|
||||||
|
" Consider making a backup and migrating to a modern"
|
||||||
|
" version with: pmbootstrap aportgen " + pkgname)
|
||||||
|
logging.warning("*****")
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
# New style ($builddir)
|
||||||
|
cmd = "srcdir=/home/pmos/build/src source APKBUILD; echo $builddir"
|
||||||
|
ret = pmb.chroot.user(args, ["sh", "-c", cmd],
|
||||||
|
"native", "/home/pmos/build",
|
||||||
|
return_stdout=True).rstrip()
|
||||||
|
if os.path.exists(chroot + ret + "/.config"):
|
||||||
|
return ret
|
||||||
|
|
||||||
|
# Not found
|
||||||
|
raise RuntimeError("Could not find the kernel config. Consider making a"
|
||||||
|
" backup of your APKBUILD and recreating it from the"
|
||||||
|
" template with: pmbootstrap aportgen " + pkgname)
|
||||||
|
|
||||||
|
|
||||||
def menuconfig(args, pkgname):
|
def menuconfig(args, pkgname):
|
||||||
# Pkgname: allow omitting "linux-" prefix
|
# Pkgname: allow omitting "linux-" prefix
|
||||||
if pkgname.startswith("linux-"):
|
if pkgname.startswith("linux-"):
|
||||||
|
@ -100,16 +132,16 @@ def menuconfig(args, pkgname):
|
||||||
"/home/pmos/build", log=False, env={"CARCH": arch})
|
"/home/pmos/build", log=False, env={"CARCH": arch})
|
||||||
|
|
||||||
# Run make menuconfig
|
# Run make menuconfig
|
||||||
srcdir = "/home/pmos/build/src"
|
outputdir = get_outputdir(args, pkgname)
|
||||||
logging.info("(native) make " + kopt)
|
logging.info("(native) make " + kopt)
|
||||||
pmb.chroot.user(args, ["make", kopt], "native",
|
pmb.chroot.user(args, ["make", kopt], "native",
|
||||||
srcdir + "/build", log=False,
|
outputdir, log=False,
|
||||||
env={"ARCH": pmb.parse.arch.alpine_to_kernel(arch),
|
env={"ARCH": pmb.parse.arch.alpine_to_kernel(arch),
|
||||||
"DISPLAY": os.environ.get("DISPLAY"),
|
"DISPLAY": os.environ.get("DISPLAY"),
|
||||||
"XAUTHORITY": "/home/pmos/.Xauthority"})
|
"XAUTHORITY": "/home/pmos/.Xauthority"})
|
||||||
|
|
||||||
# Find the updated config
|
# Find the updated config
|
||||||
source = args.work + "/chroot_native" + srcdir + "/build/.config"
|
source = args.work + "/chroot_native" + outputdir + "/.config"
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
raise RuntimeError("No kernel config generated: " + source)
|
raise RuntimeError("No kernel config generated: " + source)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue