armbian-next: use unified methods for tmp dir handling all around (except ATF, which is special)

This commit is contained in:
Ricardo Pardini
2023-01-22 23:19:40 +01:00
parent d17157885c
commit f43732a8e9
8 changed files with 61 additions and 35 deletions

View File

@@ -78,9 +78,8 @@ function create_kernel_deb() {
declare deb_output_dir="${2}"
declare callback_function="${3}"
declare package_directory
package_directory=$(mktemp -d "${WORKDIR}/${package_name}.XXXXXXXXX") # explicitly created in WORKDIR, so is protected by that cleanup trap already
#display_alert "package_directory" "${package_directory}" "debug"
declare cleanup_id="" package_directory=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-k-${package_name}" cleanup_id package_directory # namerefs
declare package_DEBIAN_dir="${package_directory}/DEBIAN" # DEBIAN dir
mkdir -p "${package_DEBIAN_dir}" # maintainer scripts et al
@@ -129,6 +128,8 @@ function create_kernel_deb() {
#run_host_command_logged tree -C -h -d --du "${package_directory}"
run_host_command_logged dpkg-deb ${DEB_COMPRESS:+-Z$DEB_COMPRESS} --build "${package_directory}" "${deb_output_dir}" # not KDEB compress, we're not under a Makefile
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}
function kernel_package_hook_helper() {

View File

@@ -92,8 +92,9 @@ function kernel_package_source() {
display_alert "Creating kernel source package" "${LINUXCONFIG}" "info"
local ts=${SECONDS}
local sources_pkg_dir tmp_src_dir tarball_size package_size
tmp_src_dir=$(mktemp -d) # subject to TMPDIR/WORKDIR, so is protected by single/common error trapmanager to clean-up.
local sources_pkg_dir tarball_size package_size
declare cleanup_id="" tmp_src_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "ksrc" cleanup_id tmp_src_dir # namerefs
sources_pkg_dir="${tmp_src_dir}/${CHOSEN_KSRC}_${REVISION}_all"
@@ -128,9 +129,14 @@ function kernel_package_source() {
EOF
fakeroot_dpkg_deb_build -Znone -z0 "${sources_pkg_dir}" "${sources_pkg_dir}.deb" # do not compress .deb, it already contains a zstd compressed tarball! ignores ${KDEB_COMPRESS} on purpose
package_size="$(du -h -s "${sources_pkg_dir}.deb" | awk '{print $1}')"
run_host_command_logged rsync --remove-source-files -r "${sources_pkg_dir}.deb" "${DEB_STORAGE}/"
display_alert "$(basename "${sources_pkg_dir}.deb" ".deb") packaged" "$((SECONDS - ts)) seconds, ${tarball_size} tarball, ${package_size} .deb" "info"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}
function kernel_prepare_build_and_package() {
@@ -139,8 +145,9 @@ function kernel_prepare_build_and_package() {
declare -a install_make_params_quoted
declare -A kernel_install_dirs
build_targets=("all") # "All" builds the vmlinux/Image/Image.gz default for the ${ARCH}
kernel_dest_install_dir=$(mktemp -d "${WORKDIR}/kernel.XXXXXXXXX") # subject to TMPDIR/WORKDIR, so is protected by single/common error trapmanager to clean-up.
build_targets=("all") # "All" builds the vmlinux/Image/Image.gz default for the ${ARCH}
declare cleanup_id="" kernel_dest_install_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "k" cleanup_id kernel_dest_install_dir # namerefs
# define dict with vars passed and target directories
declare -A kernel_install_dirs=(
@@ -169,6 +176,8 @@ function kernel_prepare_build_and_package() {
LOG_SECTION="kernel_build" do_with_logging do_with_hooks kernel_build
LOG_SECTION="kernel_package" do_with_logging do_with_hooks kernel_package
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}
function kernel_build() {

View File

@@ -1,10 +1,9 @@
compile_armbian-config() {
local tmp_dir armbian_config_dir
tmp_dir=$(mktemp -d) # subject to TMPDIR/WORKDIR, so is protected by single/common error trapmanager to clean-up.
chmod 700 "${tmp_dir}"
declare cleanup_id="" tmp_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-armbian-config" cleanup_id tmp_dir # namerefs
armbian_config_dir=armbian-config_${REVISION}_all
declare armbian_config_dir="armbian-config_${REVISION}_all"
display_alert "Building deb" "armbian-config" "info"
fetch_from_repo "https://github.com/armbian/config" "armbian-config" "branch:master"
@@ -48,5 +47,9 @@ compile_armbian-config() {
ln -sf /usr/sbin/softy "${tmp_dir}/${armbian_config_dir}"/usr/bin/softy
fakeroot_dpkg_deb_build "${tmp_dir}/${armbian_config_dir}"
run_host_command_logged rsync --remove-source-files -r "${tmp_dir}/${armbian_config_dir}.deb" "${DEB_STORAGE}/"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}

View File

@@ -1,9 +1,9 @@
compile_plymouth_theme_armbian() {
local tmp_dir plymouth_theme_armbian_dir
tmp_dir=$(mktemp -d)
chmod 700 "${tmp_dir}"
plymouth_theme_armbian_dir=armbian-plymouth-theme_${REVISION}_all
declare cleanup_id="" tmp_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-armbian-plymouth-theme" cleanup_id tmp_dir # namerefs
declare plymouth_theme_armbian_dir=armbian-plymouth-theme_${REVISION}_all
display_alert "Building deb" "armbian-plymouth-theme" "info"
run_host_command_logged mkdir -p "${tmp_dir}/${plymouth_theme_armbian_dir}"/{DEBIAN,usr/share/plymouth/themes/armbian}
@@ -44,7 +44,8 @@ compile_plymouth_theme_armbian() {
"${tmp_dir}/${plymouth_theme_armbian_dir}"/usr/share/plymouth/themes/armbian/
fakeroot_dpkg_deb_build "${tmp_dir}/${plymouth_theme_armbian_dir}"
run_host_command_logged rsync --remove-source-files -rq "${tmp_dir}/${plymouth_theme_armbian_dir}.deb" "${DEB_STORAGE}/"
# does not remove the tmpdir; it's under TMPDIR anyway
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}

View File

@@ -1,9 +1,8 @@
compile_armbian-zsh() {
local tmp_dir armbian_zsh_dir
tmp_dir=$(mktemp -d) # subject to TMPDIR/WORKDIR, so is protected by single/common error trapmanager to clean-up.
chmod 700 "${tmp_dir}"
declare cleanup_id="" tmp_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-zsh" cleanup_id tmp_dir # namerefs
armbian_zsh_dir=armbian-zsh_${REVISION}_all
declare armbian_zsh_dir="armbian-zsh_${REVISION}_all"
display_alert "Building deb" "armbian-zsh" "info"
fetch_from_repo "$GITHUB_SOURCE/ohmyzsh/ohmyzsh" "oh-my-zsh" "branch:master"
@@ -68,5 +67,8 @@ compile_armbian-zsh() {
chmod 755 "${tmp_dir}/${armbian_zsh_dir}"/DEBIAN/postinst
fakeroot_dpkg_deb_build "${tmp_dir}/${armbian_zsh_dir}"
run_host_command_logged rsync --remove-source-files -r "${tmp_dir}/${armbian_zsh_dir}.deb" "${DEB_STORAGE}/"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}

View File

@@ -263,8 +263,9 @@ function compile_uboot() {
local uboot_name="${CHOSEN_UBOOT}_${REVISION}_${ARCH}"
# create directory structure for the .deb package
uboottempdir="$(mktemp -d)" # subject to TMPDIR/WORKDIR, so is protected by single/common error trapmanager to clean-up.
chmod 700 "${uboottempdir}"
declare cleanup_id="" uboottempdir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "uboot" cleanup_id uboottempdir # namerefs
mkdir -p "$uboottempdir/$uboot_name/usr/lib/u-boot" "$uboottempdir/$uboot_name/usr/lib/$uboot_name" "$uboottempdir/$uboot_name/DEBIAN"
# Allow extension-based u-boot bulding. We call the hook, and if EXTENSION_BUILT_UBOOT="yes" afterwards, we skip our own compilation.
@@ -350,6 +351,8 @@ function compile_uboot() {
run_host_command_logged rsync --remove-source-files -r "$uboottempdir/${uboot_name}.deb" "${DEB_STORAGE}/"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
display_alert "Built u-boot deb OK" "${uboot_name}.deb" "info"
return 0 # success
}