mirror of
https://github.com/armbian/build.git
synced 2025-08-10 13:16:58 +02:00
- WiP: Python patching delusion, pt 1: finding & parsing patches; apply & git commit with pygit2; Markdown summaries (also for aggregation); git-to-patches tool - Python: Markdown aggregation and patching summaries; collapsible; SummarizedMarkdownWriter - Python: Markdown aggregation and patching summaries - Python: reorg a bit into common/armbian_utils; define the `ASSET_LOG_BASE` in preparation for Markdown delusion - Python patching: initial apply patches & initial commit patches to git (using pygit2) - Python patching: add basic `series.conf` support - Python patching: force use of utf-8; better error handling; use realpath of dirs - Python patching: `git-to-patches` initial hack. not proud. half-reused some of the patches-to-git - Python patching: "tag" the git commits with info for extracting later; introduce REWRITE_PATCHES/rewrite_patches_in_place - Python patching: commented-out, recover-bad-patches hacks - Python patching: shorten the signature - Python patching: allow BASE_GIT_TAG as well as BASE_GIT_REVISION - Python patching: git-archeology for patches missing descriptions; avoid UTF-8 in header/desc (not diff) - Python patching: use modern-er email.utils.parsedate_to_datetime to parse commit date - Python patching: unify PatchInPatchFile; better git-commiting; re-exporting patches from Git (directly) - Python patching: switch to GitPython - GitPython is like 100x slower than pygit2, but actually allows for date & committer - also allows to remove untracked files before starting - Python aggregation: fix missing `AGGREGATED_APT_SOURCES_DICT` - Python patching: add `unidecode` dependency to pip3 install - Python patching: don't try archeology if SRC is not a Git Repo (eg, in Docker) - Python patching: don't try archeology if not applying patches to git - WiP: Python patching delusion, pt2: actually use for u-boot & kernel patching - Python patching: much better problem handling/logging; lenient with recreations (kernel) - Python patching: don't force SHOW_LOG for u-boot patching - Python patching: don't bomb for no reason when there are no patches to apply - Python patching: fully (?) switch kernel patching to Python - Python patching: more logging fixups - Python patching: capture `kernel_git_revision` from `fetch_from_repo()`'s `checked_out_revision` - Python patching: fully switch u-boot patching to Python - Python aggregation/patching: colored logging; patching: always reset to git revision - Python aggregation/patching: better logging; introduce u-boot Python patching - Python patching pt3: recovers and better Markdown - Python patching: detect, and rescue, `wrong_strip_level` problem; don't try to export patches that didn't apply, bitch instead - Python patching: Markdown patching summary table, complete with emoji - Python patching: include the problem breakdown in Markdown summary - Python patching: sanity check against half-bare, half-mbox patches - Python patching: try to recover from 1) bad utf-8 encoded patches; 2) bad unidiff patches; add a few sanity checks - Python patching: try, and fail, to apply badly utf-8 encoded patches directly as bytes [reverted] - Python patching: try to recover from patch *parse* failures; show summary; better logging - set `GIT_ARCHEOLOGY=yes` to do archeology, default not - armbian-next: Python `pip` dependencies handling, similar to `hostdeps` - same scheme for Dockerfile caching - @TODO: still using global/shared environment; should move to a dir under `cache` or some kinda venv - WiP: add `python3-pip` to hostdeps; remove `python-setuptools` - remove `python-setuptools` (Python2, no longer exists in Sid) from hostdeps - add `python3-pip` to hostdeps; part of virtualenv saga - WiP: split `kernel.sh` a bit, into `kernel-patching.sh`, `kernel-config.sh` and `kernel-make.sh` - `advanced_patch()`: rename vars for clarity; no real changes - Python patching: introduce FAST_ARCHEOLOGY; still trying for Markdown links
108 lines
4.8 KiB
Bash
108 lines
4.8 KiB
Bash
function kernel_config_maybe_interactive() {
|
|
# Check if we're gonna do some interactive configuration; if so, don't run kernel_config under logging manager.
|
|
if [[ $KERNEL_CONFIGURE != yes ]]; then
|
|
LOG_SECTION="kernel_config" do_with_logging do_with_hooks kernel_config
|
|
else
|
|
LOG_SECTION="kernel_config_interactive" do_with_hooks kernel_config
|
|
fi
|
|
}
|
|
|
|
function kernel_config() {
|
|
# re-read kernel version after patching
|
|
version=$(grab_version "$kernel_work_dir")
|
|
|
|
display_alert "Compiling $BRANCH kernel" "$version" "info"
|
|
|
|
# compare with the architecture of the current Debian node
|
|
# if it matches we use the system compiler
|
|
if dpkg-architecture -e "${ARCH}"; then
|
|
display_alert "Native compilation" "target ${ARCH} on host $(dpkg --print-architecture)"
|
|
else
|
|
display_alert "Cross compilation" "target ${ARCH} on host $(dpkg --print-architecture)"
|
|
toolchain=$(find_toolchain "$KERNEL_COMPILER" "$KERNEL_USE_GCC")
|
|
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${KERNEL_COMPILER}gcc $KERNEL_USE_GCC"
|
|
fi
|
|
|
|
kernel_compiler_version="$(eval env PATH="${toolchain}:${PATH}" "${KERNEL_COMPILER}gcc" -dumpfullversion -dumpversion)"
|
|
display_alert "Compiler version" "${KERNEL_COMPILER}gcc ${kernel_compiler_version}" "info"
|
|
|
|
# copy kernel config
|
|
local COPY_CONFIG_BACK_TO=""
|
|
|
|
if [[ $KERNEL_KEEP_CONFIG == yes && -f "${DEST}"/config/$LINUXCONFIG.config ]]; then
|
|
display_alert "Using previous kernel config" "${DEST}/config/$LINUXCONFIG.config" "info"
|
|
run_host_command_logged cp -pv "${DEST}/config/${LINUXCONFIG}.config" .config
|
|
else
|
|
if [[ -f $USERPATCHES_PATH/$LINUXCONFIG.config ]]; then
|
|
display_alert "Using kernel config provided by user" "userpatches/$LINUXCONFIG.config" "info"
|
|
run_host_command_logged cp -pv "${USERPATCHES_PATH}/${LINUXCONFIG}.config" .config
|
|
elif [[ -f "${USERPATCHES_PATH}/config/kernel/${LINUXCONFIG}.config" ]]; then
|
|
display_alert "Using kernel config provided by user in config/kernel folder" "config/kernel/${LINUXCONFIG}.config" "info"
|
|
run_host_command_logged cp -pv "${USERPATCHES_PATH}/config/kernel/${LINUXCONFIG}.config" .config
|
|
else
|
|
display_alert "Using kernel config file" "config/kernel/$LINUXCONFIG.config" "info"
|
|
run_host_command_logged cp -pv "${SRC}/config/kernel/${LINUXCONFIG}.config" .config
|
|
COPY_CONFIG_BACK_TO="${SRC}/config/kernel/${LINUXCONFIG}.config"
|
|
fi
|
|
fi
|
|
|
|
# Store the .config modification date at this time, for restoring later. Otherwise rebuilds.
|
|
local kernel_config_mtime
|
|
kernel_config_mtime=$(get_file_modification_time ".config")
|
|
|
|
call_extension_method "custom_kernel_config" <<- 'CUSTOM_KERNEL_CONFIG'
|
|
*Kernel .config is in place, still clean from git version*
|
|
Called after ${LINUXCONFIG}.config is put in place (.config).
|
|
Before any olddefconfig any Kconfig make is called.
|
|
A good place to customize the .config directly.
|
|
CUSTOM_KERNEL_CONFIG
|
|
|
|
# hack for OdroidXU4. Copy firmare files
|
|
if [[ $BOARD == odroidxu4 ]]; then
|
|
mkdir -p "${kernel_work_dir}/firmware/edid"
|
|
cp -p "${SRC}"/packages/blobs/odroidxu4/*.bin "${kernel_work_dir}/firmware/edid"
|
|
fi
|
|
|
|
display_alert "Kernel configuration" "${LINUXCONFIG}" "info"
|
|
|
|
if [[ $KERNEL_CONFIGURE != yes ]]; then
|
|
run_kernel_make olddefconfig # @TODO: what is this? does it fuck up dates?
|
|
else
|
|
display_alert "Starting (non-interactive) kernel olddefconfig" "${LINUXCONFIG}" "debug"
|
|
|
|
run_kernel_make olddefconfig
|
|
|
|
# No logging for this. this is UI piece
|
|
display_alert "Starting (interactive) kernel ${KERNEL_MENUCONFIG:-menuconfig}" "${LINUXCONFIG}" "debug"
|
|
run_kernel_make_dialog "${KERNEL_MENUCONFIG:-menuconfig}"
|
|
|
|
# Capture new date. Otherwise changes not detected by make.
|
|
kernel_config_mtime=$(get_file_modification_time ".config")
|
|
|
|
# store kernel config in easily reachable place
|
|
mkdir -p "${DEST}"/config
|
|
display_alert "Exporting new kernel config" "$DEST/config/$LINUXCONFIG.config" "info"
|
|
run_host_command_logged cp -pv .config "${DEST}/config/${LINUXCONFIG}.config"
|
|
|
|
# store back into original LINUXCONFIG too, if it came from there, so it's pending commits when done.
|
|
[[ "${COPY_CONFIG_BACK_TO}" != "" ]] && run_host_command_logged cp -pv .config "${COPY_CONFIG_BACK_TO}"
|
|
|
|
# export defconfig too if requested
|
|
if [[ $KERNEL_EXPORT_DEFCONFIG == yes ]]; then
|
|
run_kernel_make savedefconfig
|
|
|
|
[[ -f defconfig ]] && run_host_command_logged cp -pv defconfig "${DEST}/config/${LINUXCONFIG}.defconfig"
|
|
fi
|
|
fi
|
|
|
|
call_extension_method "custom_kernel_config_post_defconfig" <<- 'CUSTOM_KERNEL_CONFIG_POST_DEFCONFIG'
|
|
*Kernel .config is in place, already processed by Armbian*
|
|
Called after ${LINUXCONFIG}.config is put in place (.config).
|
|
After all olddefconfig any Kconfig make is called.
|
|
A good place to customize the .config last-minute.
|
|
CUSTOM_KERNEL_CONFIG_POST_DEFCONFIG
|
|
|
|
# Restore the date of .config. Above delta is a pure function, theoretically.
|
|
set_files_modification_time "${kernel_config_mtime}" ".config"
|
|
}
|