armbian-next: bsp: use prepare_temp_dir_in_workdir_and_schedule_cleanup(); bring back PACKAGES_SEARCH_ROOT_ABSOLUTE_DIRS

This commit is contained in:
Ricardo Pardini
2023-01-21 05:12:33 +01:00
parent 90c46e0215
commit 486ba2953c
2 changed files with 28 additions and 11 deletions

View File

@@ -1,15 +1,17 @@
#!/usr/bin/env bash
create_board_package() {
function create_board_package() {
display_alert "Creating board support package for CLI" "$CHOSEN_ROOTFS" "info"
bsptempdir=$(mktemp -d) # subject to TMPDIR/WORKDIR, so is protected by single/common error trapmanager to clean-up.
chmod 700 ${bsptempdir}
declare cleanup_id="" bsptempdir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-bsp-cli" cleanup_id bsptempdir # namerefs
# "destination" is used a lot in hooks already. keep this name, even if only for compatibility.
local destination=${bsptempdir}/${BSP_CLI_PACKAGE_FULLNAME}
mkdir -p "${destination}"/DEBIAN
cd $destination
cd "${destination}" || exit_with_error "Failed to cd to ${destination}"
# copy general overlay from packages/bsp-cli
# in practice: packages/bsp-cli and variations of config/optional/...
copy_all_packages_files_for "bsp-cli"
# install copy of boot script & environment file
@@ -260,12 +262,13 @@ create_board_package() {
# TODO: Add proper handling for updated conffiles
# We are runing this script each time apt runs. If this package is removed, file is removed and error is triggered.
# Keeping armbian-apt-updates as a configuration, solve the problem
cat <<-EOF > "${destination}"/DEBIAN/conffiles
/usr/lib/armbian/armbian-apt-updates
cat <<- EOF > "${destination}"/DEBIAN/conffiles
/usr/lib/armbian/armbian-apt-updates
EOF
# copy common files from a premade directory structure
run_host_command_logged rsync -a ${SRC}/packages/bsp/common/* ${destination}
# @TODO this includes systemd config, assumes things about serial console, etc, that need dynamism or just to not exist with modern systemd
run_host_command_logged rsync -a "${SRC}"/packages/bsp/common/* "${destination}"
# trigger uInitrd creation after installation, to apply
# /etc/initramfs/post-update.d/99-uboot
@@ -273,7 +276,7 @@ create_board_package() {
activate update-initramfs
EOF
# copy distribution support status
# copy distribution support status # @TODO: why? this changes over time and will be out of date
local releases=($(find ${SRC}/config/distributions -mindepth 1 -maxdepth 1 -type d))
for i in "${releases[@]}"; do
echo "$(echo $i | sed 's/.*\///')=$(cat $i/support)" >> "${destination}"/etc/armbian-distribution-status
@@ -311,7 +314,7 @@ create_board_package() {
This should be implemented by the config to tweak the BSP, after the board or family has had the chance to.
POST_FAMILY_TWEAKS_BSP
# add some summary to the image
# add some summary to the image # @TODO: another?
fingerprint_image "${destination}/etc/armbian.txt"
# fixing permissions (basic), reference: dh_fixperms
@@ -323,5 +326,7 @@ create_board_package() {
mkdir -p "${DEB_STORAGE}/"
run_host_command_logged rsync --remove-source-files -r "${destination}.deb" "${DEB_STORAGE}/"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
display_alert "Done building BSP CLI package" "${destination}" "debug"
}

View File

@@ -3,11 +3,23 @@
#
copy_all_packages_files_for() {
local package_name="${1}"
# @TODO: rpardini: this was recovered after being assassinated by some insane person who rewrote aggregation in Python
declare PACKAGES_SEARCH_ROOT_ABSOLUTE_DIRS="
${SRC}/packages
${SRC}/config/optional/_any_board/_packages
${SRC}/config/optional/architectures/${ARCH}/_packages
${SRC}/config/optional/families/${LINUXFAMILY}/_packages
${SRC}/config/optional/boards/${BOARD}/_packages
"
for package_src_dir in ${PACKAGES_SEARCH_ROOT_ABSOLUTE_DIRS}; do
local package_dirpath="${package_src_dir}/${package_name}"
if [ -d "${package_dirpath}" ]; then
cp -r "${package_dirpath}/"* "${destination}/" 2> /dev/null
display_alert "Adding files from" "${package_dirpath}"
display_alert "Adding found files" "${package_dirpath} for '${package_name}'" "debug"
run_host_command_logged cp -r "${package_dirpath}/"* "${destination}/"
else
display_alert "No files found in" "${package_dirpath} for '${package_name}'" "debug"
fi
done
}