From 4e33412ec29d09f8f23ab97d6a11ce81e91ce085 Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 20 Jan 2025 14:23:28 +0100 Subject: [PATCH] Refactor armbian-config into install as external package (#7716) * Refactor armbian-config into install as external package - https://github.armbian.com/configng repository is always present - package can still be removed from the install list Since this tool will have deeper integration with Armbian, we should probably drop possibility to remove the tool from the list. * Enable armbian-config as extension --- extensions/armbian-config.sh | 12 +++ .../artifacts/artifact-armbian-config.sh | 96 ------------------- lib/functions/artifacts/artifacts-registry.sh | 1 - lib/functions/cli/commands.sh | 2 - .../packages/armbian-config-deb.sh | 75 --------------- .../compilation/utils-compilation.sh | 1 - lib/functions/configuration/main-config.sh | 3 + lib/functions/main/build-packages.sh | 4 - lib/functions/rootfs/distro-agnostic.sh | 5 - lib/library-functions.sh | 54 ++++------- 10 files changed, 33 insertions(+), 220 deletions(-) create mode 100644 extensions/armbian-config.sh delete mode 100644 lib/functions/artifacts/artifact-armbian-config.sh delete mode 100644 lib/functions/compilation/packages/armbian-config-deb.sh diff --git a/extensions/armbian-config.sh b/extensions/armbian-config.sh new file mode 100644 index 000000000..f9cbaa21a --- /dev/null +++ b/extensions/armbian-config.sh @@ -0,0 +1,12 @@ +# Install armbian config from repo. Now it is producing externally https://github.com/armbian/configng +# and they are moved to main armbian repo periodically + + +function custom_apt_repo__add_armbian-github-repo(){ + echo "deb ${SIGNED_BY}https://github.armbian.com/configng stable main" > "${SDCARD}"/etc/apt/sources.list.d/armbian-config.list +} + + +function post_armbian_repo_customize_image__install_armbian-config() { + chroot_sdcard_apt_get_install "armbian-config" +} diff --git a/lib/functions/artifacts/artifact-armbian-config.sh b/lib/functions/artifacts/artifact-armbian-config.sh deleted file mode 100644 index aa5e03a4c..000000000 --- a/lib/functions/artifacts/artifact-armbian-config.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env bash -# -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com -# -# This file is a part of the Armbian Build Framework -# https://github.com/armbian/build/ - -function artifact_armbian-config_config_dump() { - artifact_input_variables[BUILD_MINIMAL]="${BUILD_MINIMAL}" -} - -function artifact_armbian-config_prepare_version() { - artifact_version="undetermined" # outer scope - artifact_version_reason="undetermined" # outer scope - - local ARMBIAN_CONFIG_SOURCE="${ARMBIAN_CONFIG_SOURCE:-"https://github.com/armbian/configng"}" - local ARMBIAN_CONFIG_BRANCH="branch:${ARMBIAN_CONFIG_BRANCH:-"main"}" - - debug_var ARMBIAN_CONFIG_SOURCE - debug_var ARMBIAN_CONFIG_BRANCH - - declare short_hash_size=4 - - declare -A GIT_INFO_ARMBIAN_CONFIG=([GIT_SOURCE]="${ARMBIAN_CONFIG_SOURCE}" [GIT_REF]="${ARMBIAN_CONFIG_BRANCH}") - run_memoized GIT_INFO_ARMBIAN_CONFIG "git2info" memoized_git_ref_to_info - debug_dict GIT_INFO_ARMBIAN_CONFIG - - # Sanity check, the SHA1 gotta be sane. - [[ "${GIT_INFO_ARMBIAN_CONFIG[SHA1]}" =~ ^[0-9a-f]{40}$ ]] || exit_with_error "SHA1 is not sane: '${GIT_INFO_ARMBIAN_CONFIG[SHA1]}'" - - declare fake_unchanging_base_version="1" - - declare short_sha1="${GIT_INFO_ARMBIAN_CONFIG[SHA1]:0:${short_hash_size}}" - - # get the hashes of the lib/ bash sources involved... - declare hash_files="undetermined" - calculate_hash_for_bash_deb_artifact "compilation/packages/armbian-config-deb.sh" - declare bash_hash="${hash_files}" - declare bash_hash_short="${bash_hash:0:${short_hash_size}}" - - # outer scope - artifact_version="${fake_unchanging_base_version}-SA${short_sha1}-B${bash_hash_short}" - - declare -a reasons=( - "Armbian armbian-config git revision \"${GIT_INFO_ARMBIAN_CONFIG[SHA1]}\"" - "framework bash hash \"${bash_hash}\"" - ) - - artifact_version_reason="${reasons[*]}" # outer scope - - artifact_map_packages=(["armbian-config"]="armbian-config") - - artifact_name="armbian-config" - artifact_type="deb" - artifact_deb_repo="global" - artifact_deb_arch="all" - - return 0 -} - -function artifact_armbian-config_build_from_sources() { - LOG_SECTION="compile_armbian-config" do_with_logging compile_armbian-config -} - -function artifact_armbian-config_cli_adapter_pre_run() { - declare -g ARMBIAN_COMMAND_REQUIRE_BASIC_DEPS="yes" # Require prepare_host_basic to run before the command. - - # "gimme root on a Linux machine" - cli_standard_relaunch_docker_or_sudo -} - -function artifact_armbian-config_cli_adapter_config_prep() { - use_board="no" prep_conf_main_minimal_ni < /dev/null # no stdin for this, so it bombs if tries to be interactive. -} - -function artifact_armbian-config_get_default_oci_target() { - artifact_oci_target_base="${GHCR_SOURCE}/armbian/os/" -} - -function artifact_armbian-config_is_available_in_local_cache() { - is_artifact_available_in_local_cache -} - -function artifact_armbian-config_is_available_in_remote_cache() { - is_artifact_available_in_remote_cache -} - -function artifact_armbian-config_obtain_from_remote_cache() { - obtain_artifact_from_remote_cache -} - -function artifact_armbian-config_deploy_to_remote_cache() { - upload_artifact_to_oci -} diff --git a/lib/functions/artifacts/artifacts-registry.sh b/lib/functions/artifacts/artifacts-registry.sh index 7fdb7e30e..9c2e4c213 100644 --- a/lib/functions/artifacts/artifacts-registry.sh +++ b/lib/functions/artifacts/artifacts-registry.sh @@ -19,7 +19,6 @@ function armbian_register_artifacts() { ["firmware"]="firmware" ["full_firmware"]="full_firmware" ["fake_ubuntu_advantage_tools"]="fake_ubuntu_advantage_tools" - ["armbian-config"]="armbian-config" ["armbian-zsh"]="armbian-zsh" ["armbian-plymouth-theme"]="armbian-plymouth-theme" ["armbian-base-files"]="armbian-base-files" diff --git a/lib/functions/cli/commands.sh b/lib/functions/cli/commands.sh index 2c544601a..6345ef4e6 100644 --- a/lib/functions/cli/commands.sh +++ b/lib/functions/cli/commands.sh @@ -83,7 +83,6 @@ function armbian_register_commands() { ["firmware"]="artifact" ["firmware-full"]="artifact" - ["armbian-config"]="artifact" ["armbian-zsh"]="artifact" ["armbian-plymouth-theme"]="artifact" ["fake-ubuntu-advantage-tools"]="artifact" @@ -144,7 +143,6 @@ function armbian_register_commands() { ["firmware"]="WHAT='firmware' ${common_cli_artifact_vars}" ["firmware-full"]="WHAT='full_firmware' ${common_cli_artifact_vars}" - ["armbian-config"]="WHAT='armbian-config' ${common_cli_artifact_vars}" ["armbian-zsh"]="WHAT='armbian-zsh' ${common_cli_artifact_vars}" ["armbian-plymouth-theme"]="WHAT='armbian-plymouth-theme' ${common_cli_artifact_vars}" ["fake-ubuntu-advantage-tools"]="WHAT='fake_ubuntu_advantage_tools' ${common_cli_artifact_vars}" diff --git a/lib/functions/compilation/packages/armbian-config-deb.sh b/lib/functions/compilation/packages/armbian-config-deb.sh deleted file mode 100644 index e932293cb..000000000 --- a/lib/functions/compilation/packages/armbian-config-deb.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -# -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com -# -# This file is a part of the Armbian Build Framework -# https://github.com/armbian/build/ - -compile_armbian-config() { - : "${artifact_version:?artifact_version is not set}" - - display_alert "Generating armbian-config package" "@host" "info" - - declare cleanup_id="" tmp_dir="" - prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-armbian-config" cleanup_id tmp_dir # namerefs - - declare armbian_config_dir="armbian-config" - mkdir -p "${tmp_dir}/${armbian_config_dir}" - - local ARMBIAN_CONFIG_GIT_SOURCE="${ARMBIAN_FIRMWARE_GIT_SOURCE:-"https://github.com/armbian/configng"}" - local ARMBIAN_CONFIG_GIT_BRANCH="${ARMBIAN_FIRMWARE_GIT_BRANCH:-"main"}" - - # this is also not getting any updates - fetch_from_repo "$GITHUB_SOURCE/dylanaraps/neofetch" "neofetch" "tag:7.1.0" - fetch_from_repo "$GITHUB_SOURCE/armbian/configng" "armbian-config" "branch:main" - fetch_from_repo "$GITHUB_SOURCE/complexorganizations/wireguard-manager" "wireguard-manager" "branch:main" - - # Fetch Armbian config from git. - declare fetched_revision - do_checkout="no" fetch_from_repo "${ARMBIAN_CONFIG_GIT_SOURCE}" "armbian-config-git" "branch:${ARMBIAN_CONFIG_GIT_BRANCH}" - declare -r armbian_firmware_git_sha1="${fetched_revision}" - - # Compile Armbian config - ${SRC}/cache/sources/armbian-config/tools/config-assemble.sh -p - - # @TODO: move this to where it is actually used; not everyone needs to pull this in - fetch_from_repo "$GITHUB_SOURCE/complexorganizations/wireguard-manager" "wireguard-manager" "branch:main" - - mkdir -p "${tmp_dir}/${armbian_config_dir}"/{DEBIAN,bin/,lib/armbian-config/,usr/bin/,/etc/apt/sources.list.d/} - - cd "${tmp_dir}/${armbian_config_dir}" || exit_with_error "can't change directory" - - # set up control file - cat <<- END > DEBIAN/control - Package: armbian-config - Version: ${artifact_version} - Architecture: all - Maintainer: $MAINTAINER <$MAINTAINERMAIL> - Depends: debconf, iproute2, jq, libtext-iconv-perl, procps, sudo, systemd, whiptail - Section: utils - Priority: optional - Description: Armbian configuration utility - The new generation - END - - install -m 755 "${SRC}"/cache/sources/neofetch/neofetch "${tmp_dir}/${armbian_config_dir}"/usr/bin/neofetch - cd "${tmp_dir}/${armbian_config_dir}"/usr/bin/ || exit_with_error "Failed to cd to ${tmp_dir}/${armbian_config_dir}/usr/bin/" - process_patch_file "${SRC}/patch/misc/add-armbian-neofetch.patch" "applying" - - # 3rd party utilities - install -m 755 "${SRC}"/cache/sources/wireguard-manager/wireguard-manager.sh "${tmp_dir}/${armbian_config_dir}"/usr/bin/wireguard-manager - - # Armbian config parts - install -m 755 "${SRC}"/cache/sources/armbian-config/bin/armbian-config "${tmp_dir}/${armbian_config_dir}"/bin/armbian-config - cp -R "${SRC}"/cache/sources/armbian-config/lib/armbian-config/ "${tmp_dir}/${armbian_config_dir}"/lib/ - - # Add development repository to keep rooling release of this tool - cat <<- END > ${tmp_dir}/${armbian_config_dir}/etc/apt/sources.list.d/armbian-config.list - deb [signed-by=/usr/share/keyrings/armbian.gpg] https://github.armbian.com/configng stable main - END - - dpkg_deb_build "${tmp_dir}/${armbian_config_dir}" "armbian-config" - done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early - -} diff --git a/lib/functions/compilation/utils-compilation.sh b/lib/functions/compilation/utils-compilation.sh index 7648966a8..dd4842f25 100644 --- a/lib/functions/compilation/utils-compilation.sh +++ b/lib/functions/compilation/utils-compilation.sh @@ -13,7 +13,6 @@ # compile_uboot # compile_kernel # compile_firmware -# compile_armbian-config # compile_xilinx_bootgen # grab_version # find_toolchain diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index 87e505e50..a2c5878fa 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -61,6 +61,9 @@ function do_main_configuration() { declare -g SKIP_EXTERNAL_TOOLCHAINS="${SKIP_EXTERNAL_TOOLCHAINS:-yes}" # don't use any external toolchains, by default. + # Armbian config is central tool used in all builds. As its build externally, we have moved it to extension. Enable it here. + enable_extension "armbian-config" + # Network stack to use, default to network-manager; configuration can override this. # Will be made read-only further down. declare -g NETWORKING_STACK="${NETWORKING_STACK}" diff --git a/lib/functions/main/build-packages.sh b/lib/functions/main/build-packages.sh index f3f0a6fde..1a1f53b4c 100644 --- a/lib/functions/main/build-packages.sh +++ b/lib/functions/main/build-packages.sh @@ -31,10 +31,6 @@ function determine_artifacts_to_build_for_image() { artifacts_to_build+=("fake_ubuntu_advantage_tools") fi - if [[ "${PACKAGE_LIST_RM}" != *armbian-config* ]]; then - artifacts_to_build+=("armbian-config") - fi - if [[ "${PACKAGE_LIST_RM}" != *armbian-zsh* ]]; then if [[ $BUILD_MINIMAL != yes ]]; then artifacts_to_build+=("armbian-zsh") diff --git a/lib/functions/rootfs/distro-agnostic.sh b/lib/functions/rootfs/distro-agnostic.sh index 07b538c3e..83361914a 100644 --- a/lib/functions/rootfs/distro-agnostic.sh +++ b/lib/functions/rootfs/distro-agnostic.sh @@ -331,11 +331,6 @@ function install_distribution_agnostic() { desktop_postinstall fi - # install armbian-config - if [[ "${PACKAGE_LIST_RM}" != *armbian-config* ]]; then - install_artifact_deb_chroot "armbian-config" - fi - # install armbian-zsh if [[ "${PACKAGE_LIST_RM}" != *armbian-zsh* ]]; then if [[ $BUILD_MINIMAL != yes ]]; then diff --git a/lib/library-functions.sh b/lib/library-functions.sh index da459ea79..7dfcaeea7 100644 --- a/lib/library-functions.sh +++ b/lib/library-functions.sh @@ -28,15 +28,6 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/artifacts/artifact-armbian-bsp-desktop.sh source "${SRC}"/lib/functions/artifacts/artifact-armbian-bsp-desktop.sh -# no errors tolerated. invoked before each sourced file to make sure. -#set -o pipefail # trace ERR through pipes - will be enabled "soon" -#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled -set -o errtrace # trace ERR through - enabled -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/artifacts/artifact-armbian-config.sh -# shellcheck source=lib/functions/artifacts/artifact-armbian-config.sh -source "${SRC}"/lib/functions/artifacts/artifact-armbian-config.sh - # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -109,15 +100,6 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/artifacts/artifact-rootfs.sh source "${SRC}"/lib/functions/artifacts/artifact-rootfs.sh -# no errors tolerated. invoked before each sourced file to make sure. -#set -o pipefail # trace ERR through pipes - will be enabled "soon" -#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled -set -o errtrace # trace ERR through - enabled -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/artifacts/artifact-uboot.sh -# shellcheck source=lib/functions/artifacts/artifact-uboot.sh -source "${SRC}"/lib/functions/artifacts/artifact-uboot.sh - # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -145,6 +127,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/artifacts/artifacts-reversion.sh source "${SRC}"/lib/functions/artifacts/artifacts-reversion.sh +# no errors tolerated. invoked before each sourced file to make sure. +#set -o pipefail # trace ERR through pipes - will be enabled "soon" +#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled +set -o errtrace # trace ERR through - enabled +set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled +### lib/functions/artifacts/artifact-uboot.sh +# shellcheck source=lib/functions/artifacts/artifact-uboot.sh +source "${SRC}"/lib/functions/artifacts/artifact-uboot.sh + # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -424,15 +415,6 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/compilation/kernel.sh source "${SRC}"/lib/functions/compilation/kernel.sh -# no errors tolerated. invoked before each sourced file to make sure. -#set -o pipefail # trace ERR through pipes - will be enabled "soon" -#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled -set -o errtrace # trace ERR through - enabled -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/compilation/packages/armbian-config-deb.sh -# shellcheck source=lib/functions/compilation/packages/armbian-config-deb.sh -source "${SRC}"/lib/functions/compilation/packages/armbian-config-deb.sh - # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -694,6 +676,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/general/extensions.sh source "${SRC}"/lib/functions/general/extensions.sh +# no errors tolerated. invoked before each sourced file to make sure. +#set -o pipefail # trace ERR through pipes - will be enabled "soon" +#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled +set -o errtrace # trace ERR through - enabled +set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled +### lib/functions/general/github-actions.sh +# shellcheck source=lib/functions/general/github-actions.sh +source "${SRC}"/lib/functions/general/github-actions.sh + # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled @@ -712,15 +703,6 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/general/git.sh source "${SRC}"/lib/functions/general/git.sh -# no errors tolerated. invoked before each sourced file to make sure. -#set -o pipefail # trace ERR through pipes - will be enabled "soon" -#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled -set -o errtrace # trace ERR through - enabled -set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled -### lib/functions/general/github-actions.sh -# shellcheck source=lib/functions/general/github-actions.sh -source "${SRC}"/lib/functions/general/github-actions.sh - # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled