mirror of
https://github.com/armbian/build.git
synced 2025-09-17 03:31:39 +02:00
- bsp-cli: now depends on `base-files (>= ${REVISION})`, this way upgrading the bsp-cli causes our base-files to be installed - bsp-cli no longer does gymnastics with /etc/os-release et al, all done in armbian-base-files now - general/apt-utils.sh: introduce `apt_find_upstream_package_version_and_download_url()` - base-files: add release to version, in order to comply with repo restrictions (valid repos can't have two different debs with same name and version, md5 must match)
196 lines
8.8 KiB
Bash
196 lines
8.8 KiB
Bash
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (c) 2023 Ricardo Pardini <ricardo@pardini.net>
|
|
# This file is a part of the Armbian Build Framework https://github.com/armbian/build/
|
|
#
|
|
|
|
# tl;dr: this artifact is a replacement for the original distro's base-files.
|
|
# We find what is the latest version of the original distro's base-files.
|
|
# Then we download it, and we modify it to suit our needs.
|
|
# The artifact is named "armbian-base-files".
|
|
# But the package is still named "base-files"; its version is bumped to ${REVISION}
|
|
# This is similar to what Linux Mint does for the same purpose.
|
|
|
|
function artifact_armbian-base-files_config_dump() {
|
|
artifact_input_variables[RELEASE]="${RELEASE}"
|
|
artifact_input_variables[ARCH]="${ARCH}"
|
|
}
|
|
|
|
function artifact_armbian-base-files_prepare_version() {
|
|
: "${artifact_prefix_version:?artifact_prefix_version is not set}"
|
|
: "${RELEASE:?RELEASE is not set}"
|
|
: "${ARCH:?ARCH is not set}"
|
|
|
|
artifact_version="undetermined" # outer scope
|
|
artifact_version_reason="undetermined" # outer scope
|
|
|
|
declare short_hash_size=4
|
|
declare fake_unchanging_base_version="${RELEASE}-1armbian1"
|
|
|
|
declare found_package_version="undetermined" found_package_filename="undetermined" found_package_down_url="undetermined"
|
|
sleep_seconds="15" do_with_retries 10 apt_find_upstream_package_version_and_download_url "base-files"
|
|
|
|
# download the file, but write it to /dev/null (just for testing it is correct)
|
|
# wget --timeout=15 --output-document=/dev/null "${found_package_down_url}" || exit_with_error "Could not download '${found_package_down_url}'"
|
|
|
|
# Set readonly globals with the wanted info; will be used during the actual build of this artifact
|
|
declare -g -r base_files_wanted_upstream_version="${found_package_version}"
|
|
declare -g -r base_files_wanted_upstream_filename="${found_package_filename}"
|
|
declare -g -r base_files_wanted_deb_down_url="${found_package_down_url}"
|
|
|
|
# get the hashes of the lib/ bash sources involved.
|
|
declare hash_files="undetermined"
|
|
calculate_hash_for_bash_deb_artifact "artifacts/artifact-armbian-base-files.sh"
|
|
declare bash_hash="${hash_files}"
|
|
declare bash_hash_short="${bash_hash:0:${short_hash_size}}"
|
|
|
|
# outer scope
|
|
artifact_version="${artifact_prefix_version}${fake_unchanging_base_version}-B${bash_hash_short}"
|
|
|
|
declare -a reasons=("Armbian armbian-base-files" "original ${RELEASE} version \"${base_files_wanted_upstream_version}\"" "framework bash hash \"${bash_hash}\"")
|
|
|
|
artifact_version_reason="${reasons[*]}" # outer scope
|
|
|
|
artifact_name="armbian-base-files-${RELEASE}-${ARCH}"
|
|
declare deb_name="base-files" # the artifact_name is only Armbian's reference; the deb_name is still base_files
|
|
artifact_type="deb"
|
|
artifact_base_dir="${DEB_STORAGE}/${RELEASE}"
|
|
artifact_final_file="${DEB_STORAGE}/${RELEASE}/${deb_name}_${artifact_version}_${ARCH}.deb"
|
|
|
|
artifact_map_packages=(["armbian-base-files"]="${deb_name}")
|
|
|
|
artifact_map_debs=(["armbian-base-files"]="${RELEASE}/${deb_name}_${artifact_version}_${ARCH}.deb")
|
|
|
|
return 0
|
|
}
|
|
|
|
function artifact_armbian-base-files_build_from_sources() {
|
|
LOG_SECTION="compile_armbian-base-files" do_with_logging compile_armbian-base-files
|
|
}
|
|
|
|
# Dont' wanna use a separate file for this. Keep it in here.
|
|
function compile_armbian-base-files() {
|
|
: "${artifact_name:?artifact_name is not set}"
|
|
: "${artifact_version:?artifact_version is not set}"
|
|
: "${RELEASE:?RELEASE is not set}"
|
|
: "${ARCH:?ARCH is not set}"
|
|
: "${DISTRIBUTION:?DISTRIBUTION is not set}"
|
|
|
|
display_alert "Creating base-files for ${DISTRIBUTION} release '${RELEASE}' arch '${ARCH}'" "${artifact_name} :: ${artifact_version}" "info"
|
|
|
|
declare cleanup_id="" destination=""
|
|
prepare_temp_dir_in_workdir_and_schedule_cleanup "base-files" cleanup_id destination # namerefs
|
|
|
|
# Download the deb file
|
|
declare deb_file="${destination}/${base_files_wanted_upstream_filename}"
|
|
run_host_command_logged wget --no-verbose --timeout=60 --output-document="${deb_file}" "${base_files_wanted_deb_down_url}" || exit_with_error "Could not download '${base_files_wanted_deb_down_url}'"
|
|
|
|
# Raw-Extract (with DEBIAN dir) the contents of the deb file into "${destination}"
|
|
run_host_command_logged dpkg-deb --raw-extract "${deb_file}" "${destination}" || exit_with_error "Could not raw-extract '${deb_file}'"
|
|
|
|
# Remove the .deb file
|
|
rm -f "${deb_file}"
|
|
|
|
if [[ "${SHOW_DEBUG}" == "yes" ]]; then
|
|
# Show the tree
|
|
run_host_command_logged tree "${destination}"
|
|
wait_for_disk_sync "after tree base-files"
|
|
|
|
# Show the original control file, using batcat
|
|
run_tool_batcat --file-name "${artifact_name}/DEBIAN/control" "${destination}/DEBIAN/control"
|
|
|
|
# Show the original conffiles file, using batcat
|
|
run_tool_batcat --file-name "${artifact_name}/DEBIAN/conffiles" "${destination}/DEBIAN/conffiles"
|
|
fi
|
|
|
|
# Let's hack at it. New Maintainer and Version...
|
|
cat <<- EOD >> "${destination}/DEBIAN/control.new"
|
|
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
|
|
Version: ${artifact_version}
|
|
EOD
|
|
# Keep everything else from original
|
|
cat "${destination}/DEBIAN/control" | grep -vP '^(Maintainer|Version):' >> "${destination}/DEBIAN/control.new"
|
|
|
|
# Replace 'Debian' with 'Armbian'.
|
|
sed -i "s/Debian/${VENDOR}/g" "${destination}/DEBIAN/control.new"
|
|
|
|
mv "${destination}/DEBIAN/control.new" "${destination}/DEBIAN/control"
|
|
|
|
# Change etc/os-release, etc/issue, etc/issue.net, and DEBIAN/conffiles
|
|
|
|
# Keep copies so we can diff
|
|
cp "${destination}"/etc/os-release "${destination}"/etc/os-release.orig
|
|
cp "${destination}"/etc/issue "${destination}"/etc/issue.orig
|
|
cp "${destination}"/etc/issue.net "${destination}"/etc/issue.net.orig
|
|
cp "${destination}"/DEBIAN/conffiles "${destination}"/DEBIAN/conffiles.orig
|
|
|
|
# Change the PRETTY_NAME and add ARMBIAN_PRETTY_NAME in os-release, and change issue, issue.net
|
|
declare orig_distro_release="${RELEASE}"
|
|
echo "ARMBIAN_PRETTY_NAME=\"${VENDOR} ${REVISION} ${orig_distro_release}\"" >> "${destination}"/etc/os-release
|
|
echo -e "${VENDOR} ${REVISION} ${orig_distro_release} \\l \n" > "${destination}"/etc/issue
|
|
echo -e "${VENDOR} ${REVISION} ${orig_distro_release}" > "${destination}"/etc/issue.net
|
|
sed -i "s/^PRETTY_NAME=.*/PRETTY_NAME=\"${VENDOR} $REVISION ${orig_distro_release}\"/" "${destination}"/etc/os-release
|
|
|
|
# Remove /etc/issue and /etc/issue.net from the DEBIAN/conffiles file
|
|
sed -i '/^\/etc\/issue$/d' "${destination}"/DEBIAN/conffiles
|
|
sed -i '/^\/etc\/issue.net$/d' "${destination}"/DEBIAN/conffiles
|
|
|
|
if [[ "${SHOW_DEBUG}" == "yes" ]]; then
|
|
# Show the results of the changing...
|
|
run_tool_batcat --file-name "${artifact_name}/etc/os-release" "${destination}"/etc/os-release
|
|
run_tool_batcat --file-name "${artifact_name}/etc/issue" "${destination}"/etc/issue
|
|
run_tool_batcat --file-name "${artifact_name}/etc/issue.net" "${destination}"/etc/issue.net
|
|
run_tool_batcat --file-name "${artifact_name}/DEBIAN/conffiles" "${destination}"/DEBIAN/conffiles
|
|
|
|
# Show the diffs, use colors.
|
|
run_host_command_logged diff --color=always -u "${destination}"/etc/os-release.orig "${destination}"/etc/os-release "||" true
|
|
run_host_command_logged diff --color=always -u "${destination}"/etc/issue.orig "${destination}"/etc/issue "||" true
|
|
run_host_command_logged diff --color=always -u "${destination}"/etc/issue.net.orig "${destination}"/etc/issue.net "||" true
|
|
run_host_command_logged diff --color=always -u "${destination}"/DEBIAN/conffiles.orig "${destination}"/DEBIAN/conffiles "||" true
|
|
fi
|
|
|
|
# Remove the .orig files
|
|
rm -f "${destination}"/etc/os-release.orig "${destination}"/etc/issue.orig "${destination}"/etc/issue.net.orig "${destination}"/DEBIAN/conffiles.orig
|
|
|
|
# Done, pack it.
|
|
mkdir -p "${DEB_STORAGE}/${RELEASE}"
|
|
fakeroot_dpkg_deb_build "${destination}" "${DEB_STORAGE}/${RELEASE}"
|
|
|
|
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
|
|
}
|
|
|
|
function artifact_armbian-base-files_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-base-files_cli_adapter_config_prep() {
|
|
: "${RELEASE:?RELEASE is not set}"
|
|
: "${BOARD:?BOARD is not set}"
|
|
|
|
# there is no need for aggregation here, although RELEASE is required.
|
|
use_board="yes" allow_no_family="no" skip_kernel="no" prep_conf_main_minimal_ni < /dev/null # no stdin for this, so it bombs if tries to be interactive.
|
|
}
|
|
|
|
function artifact_armbian-base-files_get_default_oci_target() {
|
|
artifact_oci_target_base="${GHCR_SOURCE}/armbian/os/"
|
|
}
|
|
|
|
function artifact_armbian-base-files_is_available_in_local_cache() {
|
|
is_artifact_available_in_local_cache
|
|
}
|
|
|
|
function artifact_armbian-base-files_is_available_in_remote_cache() {
|
|
is_artifact_available_in_remote_cache
|
|
}
|
|
|
|
function artifact_armbian-base-files_obtain_from_remote_cache() {
|
|
obtain_artifact_from_remote_cache
|
|
}
|
|
|
|
function artifact_armbian-base-files_deploy_to_remote_cache() {
|
|
upload_artifact_to_oci
|
|
}
|