artifacts: bsp-cli, bsp-desktop, desktop: rework, with @igorpec

- bsp-cli: does not require aggregation
- bsp-desktop / desktop: requires aggregation
- 'desktop' packaged moved out of 'bsp' folder, it is NOT a bsp
- make consistent naming/folders
- extract .sh generation workflow into 'declare -f' magic functions
- `SHOW_DEBIAN=yes` to bump most of `DEBIAN/xxx` stuff to screen
- artifact armbian-bsp-desktop: use aggregation, require certain vars, CLI forces `BUILD_DESKTOP=yes`; requires BOARD
- artifact armbian-desktop: use aggregation, require certain vars, CLI forces `BUILD_DESKTOP=yes`, not require `BOARD` anymore
- cli: commands: fix artifact aliases, reorder
- desktop/bsp-desktop: add `config_dump` method; fix `artifact_map_debs` ref subdir and name
- artifact bsps: require aggregation to build, not to list what needs to be built
- distro-agnostic: fix install of `armbian-bsp-cli` (not `armbian-bsp`)
- armbian-bsp-cli: add `_config_dump` method, use configuration with aggregation, add required vars check
- distro-specific: fix installation of `fake-ubuntu-advantage-tools`
This commit is contained in:
Ricardo Pardini 2023-03-28 14:36:11 +02:00 committed by Igor Pečovnik
parent 55ba084acc
commit d868d76182
13 changed files with 610 additions and 393 deletions

View File

@ -7,13 +7,52 @@
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
function artifact_armbian-bsp-cli_config_dump() {
artifact_input_variables[BOARD]="${BOARD}"
artifact_input_variables[BRANCH]="${BRANCH}"
artifact_input_variables[EXTRA_BSP_NAME]="${EXTRA_BSP_NAME}"
}
function artifact_armbian-bsp-cli_prepare_version() {
: "${artifact_prefix_version:?artifact_prefix_version is not set}"
: "${BRANCH:?BRANCH is not set}"
: "${BOARD:?BOARD is not set}"
artifact_version="undetermined" # outer scope
artifact_version_reason="undetermined" # outer scope
declare short_hash_size=4
declare fake_unchanging_base_version="1"
# @TODO: hash the contents of family_tweaks_bsp old-style hooks
# @TODO: hash the contents of post_family_tweaks_bsp extension hooks
# Hash variables/bootscripts that affect the contents of bsp-cli package
get_bootscript_info # get bootscript info, that is included in bsp-cli, hash it
declare -a vars_to_hash=(
"${bootscript_info[bootscript_file_contents]}"
"${bootscript_info[bootenv_file_contents]}"
"${bootscript_info[has_bootscript]}"
"${bootscript_info[has_extlinux]}"
"${UBOOT_FW_ENV}" # not included in bootscript
)
declare hash_vars="undetermined"
hash_vars="$(echo "${vars_to_hash[@]}" | sha256sum | cut -d' ' -f1)"
vars_config_hash="${hash_vars}"
declare var_config_hash_short="${vars_config_hash:0:${short_hash_size}}"
declare -a dirs_to_hash=(
"${SRC}/packages/bsp/common" # common stuff
"${SRC}/packages/bsp-cli"
"${SRC}/config/optional/_any_board/_packages/bsp-cli"
"${SRC}/config/optional/architectures/${ARCH}/_packages/bsp-cli"
"${SRC}/config/optional/families/${LINUXFAMILY}/_packages/bsp-cli"
"${SRC}/config/optional/boards/${BOARD}/_packages/bsp-cli"
)
declare hash_files="undetermined"
calculate_hash_for_all_files_in_dirs "${dirs_to_hash[@]}"
packages_config_hash="${hash_files}"
declare packages_config_hash_short="${packages_config_hash:0:${short_hash_size}}"
# get the hashes of the lib/ bash sources involved...
declare hash_files="undetermined"
@ -22,28 +61,33 @@ function artifact_armbian-bsp-cli_prepare_version() {
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}"
artifact_version="${artifact_prefix_version}${fake_unchanging_base_version}-PC${packages_config_hash_short}-V${var_config_hash_short}-B${bash_hash_short}"
declare -a reasons=(
"Armbian armbian-bsp-cli"
"Armbian package armbian-bsp-cli"
"BOARD \"${BOARD}\""
"BRANCH \"${BRANCH}\""
"EXTRA_BSP_NAME \"${EXTRA_BSP_NAME}\""
"Packages and config files hash \"${packages_config_hash}\""
"Variables/bootscripts hash \"${vars_config_hash}\""
"framework bash hash \"${bash_hash}\""
)
artifact_version_reason="${reasons[*]}" # outer scope
artifact_name="armbian-bsp-cli-${BOARD}-${BRANCH}${EXTRA_BSP_NAME}"
artifact_type="deb"
artifact_base_dir="${DEB_STORAGE}"
artifact_final_file="${DEB_STORAGE}/${artifact_name}_${artifact_version}_${ARCH}.deb"
artifact_map_packages=(
["armbian-bsp-cli"]="armbian-bsp-cli"
["armbian-bsp-cli"]="${artifact_name}"
)
artifact_map_debs=(
["armbian-bsp-cli"]="armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME}_${artifact_version}_${ARCH}.deb"
["armbian-bsp-cli"]="${artifact_name}_${artifact_version}_${ARCH}.deb"
)
artifact_name="armbian-bsp-cli"
artifact_type="deb"
artifact_base_dir="${DEB_STORAGE}"
artifact_final_file="${DEB_STORAGE}/armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME}_${artifact_version}_${ARCH}.deb"
return 0
}
@ -59,7 +103,8 @@ function artifact_armbian-bsp-cli_cli_adapter_pre_run() {
}
function artifact_armbian-bsp-cli_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.
# there is no need for aggregation here.
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-bsp-cli_get_default_oci_target() {

View File

@ -7,7 +7,26 @@
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
function artifact_armbian-bsp-desktop_config_dump() {
artifact_input_variables[RELEASE]="${RELEASE}"
artifact_input_variables[BOARD]="${BOARD}"
artifact_input_variables[BRANCH]="${BRANCH}"
# @TODO: this should not be true... but is.
artifact_input_variables[DESKTOP_ENVIRONMENT]="${DESKTOP_ENVIRONMENT}"
artifact_input_variables[DESKTOP_ENVIRONMENT_CONFIG_NAME]="${DESKTOP_ENVIRONMENT_CONFIG_NAME}"
}
function artifact_armbian-bsp-desktop_prepare_version() {
: "${artifact_prefix_version:?artifact_prefix_version is not set}"
: "${BRANCH:?BRANCH is not set}"
: "${BOARD:?BOARD is not set}"
: "${RELEASE:?RELEASE is not set}"
# @TODO: this should not be true... but is.
: "${DESKTOP_ENVIRONMENT:?DESKTOP_ENVIRONMENT is not set}"
: "${DESKTOP_ENVIRONMENT_CONFIG_NAME:?DESKTOP_ENVIRONMENT_CONFIG_NAME is not set}"
artifact_version="undetermined" # outer scope
artifact_version_reason="undetermined" # outer scope
@ -15,6 +34,8 @@ function artifact_armbian-bsp-desktop_prepare_version() {
declare fake_unchanging_base_version="1"
# @TODO: hash copy_all_packages_files_for "bsp-desktop"
# get the hashes of the lib/ bash sources involved...
declare hash_files="undetermined"
calculate_hash_for_files "${SRC}"/lib/functions/bsp/armbian-bsp-desktop-deb.sh
@ -31,19 +52,19 @@ function artifact_armbian-bsp-desktop_prepare_version() {
artifact_version_reason="${reasons[*]}" # outer scope
artifact_name="armbian-bsp-desktop-${BOARD}-${BRANCH}"
artifact_type="deb"
artifact_base_dir="${DEB_STORAGE}"
artifact_final_file="${DEB_STORAGE}/${RELEASE}/${artifact_name}_${artifact_version}_${ARCH}.deb"
artifact_map_packages=(
["armbian-bsp-desktop"]="armbian-bsp-desktop"
["armbian-bsp-desktop"]="${artifact_name}"
)
artifact_map_debs=(
["armbian-bsp-desktop"]="armbian-bsp-desktop-${BOARD}_${artifact_version}_${ARCH}.deb"
["armbian-bsp-desktop"]="${RELEASE}/${artifact_name}_${artifact_version}_${ARCH}.deb"
)
artifact_name="armbian-bsp-desktop"
artifact_type="deb"
artifact_base_dir="${DEB_STORAGE}"
artifact_final_file="${DEB_STORAGE}/${RELEASE}/armbian-bsp-desktop-${BOARD}_${artifact_version}_${ARCH}.deb"
return 0
}
@ -59,7 +80,15 @@ function artifact_armbian-bsp-desktop_cli_adapter_pre_run() {
}
function artifact_armbian-bsp-desktop_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.
: "${RELEASE:?RELEASE is not set}"
: "${BOARD:?BOARD is not set}"
# @TODO: this should not be true... but is.
: "${DESKTOP_ENVIRONMENT:?DESKTOP_ENVIRONMENT is not set}"
: "${DESKTOP_ENVIRONMENT_CONFIG_NAME:?DESKTOP_ENVIRONMENT_CONFIG_NAME is not set}"
# this requires aggregation, and thus RELEASE, but also everything else.
use_board="yes" allow_no_family="no" skip_kernel="no" prep_conf_main_only_rootfs_ni < /dev/null # no stdin for this, so it bombs if tries to be interactive.
}
function artifact_armbian-bsp-desktop_get_default_oci_target() {

View File

@ -7,7 +7,18 @@
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
function artifact_armbian-desktop_config_dump() {
artifact_input_variables[RELEASE]="${RELEASE}"
artifact_input_variables[DESKTOP_ENVIRONMENT]="${DESKTOP_ENVIRONMENT}"
}
function artifact_armbian-desktop_prepare_version() {
: "${artifact_prefix_version:?artifact_prefix_version is not set}"
: "${RELEASE:?RELEASE is not set}"
: "${DESKTOP_ENVIRONMENT:?DESKTOP_ENVIRONMENT is not set}"
: "${DESKTOP_ENVIRONMENT_CONFIG_NAME:?DESKTOP_ENVIRONMENT_CONFIG_NAME is not set}" # Not keyed, but required.
artifact_version="undetermined" # outer scope
artifact_version_reason="undetermined" # outer scope
@ -15,35 +26,47 @@ function artifact_armbian-desktop_prepare_version() {
declare fake_unchanging_base_version="1"
# Hash variables that affect the contents of desktop package
declare -a vars_to_hash=(
"${AGGREGATED_DESKTOP_POSTINST}"
"${AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE}"
"${AGGREGATED_PACKAGES_DESKTOP_COMMA}"
)
declare hash_vars="undetermined"
hash_vars="$(echo "${vars_to_hash[@]}" | sha256sum | cut -d' ' -f1)"
vars_config_hash="${hash_vars}"
declare var_config_hash_short="${vars_config_hash:0:${short_hash_size}}"
# get the hashes of the lib/ bash sources involved...
declare hash_files="undetermined"
calculate_hash_for_files "${SRC}"/lib/functions/bsp/armbian-desktop-deb.sh
calculate_hash_for_files "${SRC}"/lib/functions/compilation/packages/armbian-desktop-deb.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}"
artifact_version="${artifact_prefix_version}${fake_unchanging_base_version}-V${var_config_hash_short}-B${bash_hash_short}"
declare -a reasons=(
"Armbian armbian-desktop"
"vars hash \"${vars_config_hash}\""
"framework bash hash \"${bash_hash}\""
)
artifact_version_reason="${reasons[*]}" # outer scope
artifact_name="armbian-${RELEASE}-desktop-${DESKTOP_ENVIRONMENT}"
artifact_type="deb"
artifact_base_dir="${DEB_STORAGE}"
artifact_final_file="${DEB_STORAGE}/${RELEASE}/${artifact_name}_${artifact_version}_all.deb"
artifact_map_packages=(
["armbian-desktop"]="armbian-desktop"
["armbian-desktop"]="${artifact_name}"
)
artifact_map_debs=(
["armbian-desktop"]="armbian-desktop-${CHOSEN_DESKTOP}_${artifact_version}_all.deb"
["armbian-desktop"]="${RELEASE}/${artifact_name}_${artifact_version}_all.deb"
)
artifact_name="armbian-desktop"
artifact_type="deb"
artifact_base_dir="${DEB_STORAGE}"
artifact_final_file="${DEB_STORAGE}/${RELEASE}/${CHOSEN_DESKTOP}_${artifact_version}_all.deb"
return 0
}
@ -59,7 +82,12 @@ function artifact_armbian-desktop_cli_adapter_pre_run() {
}
function artifact_armbian-desktop_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.
: "${RELEASE:?RELEASE is not set}"
: "${DESKTOP_ENVIRONMENT:?DESKTOP_ENVIRONMENT is not set}"
: "${DESKTOP_ENVIRONMENT_CONFIG_NAME:?DESKTOP_ENVIRONMENT_CONFIG_NAME is not set}"
# this requires aggregation, and thus RELEASE, but also everything else.
use_board="yes" allow_no_family="no" skip_kernel="no" prep_conf_main_only_rootfs_ni < /dev/null # no stdin for this, so it bombs if tries to be interactive.
}
function artifact_armbian-desktop_get_default_oci_target() {

View File

@ -9,65 +9,30 @@
function compile_armbian-bsp-cli() {
: "${artifact_version:?artifact_version is not set}"
: "${artifact_name:?artifact_name is not set}"
: "${BOARD:?BOARD is not set}"
: "${BRANCH:?BRANCH is not set}"
declare -g BSP_CLI_PACKAGE_NAME="armbian-bsp-cli-${BOARD}${EXTRA_BSP_NAME}"
declare -g BSP_CLI_PACKAGE_FULLNAME="${BSP_CLI_PACKAGE_NAME}_${artifact_version}_${ARCH}"
display_alert "Creating board support package for CLI" "$CHOSEN_ROOTFS" "info"
declare cleanup_id="" bsptempdir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-bsp-cli" cleanup_id bsptempdir # namerefs
display_alert "Creating bsp-cli on board '${BOARD}' branch '${BRANCH}'" "${artifact_name} :: ${artifact_version}" "info"
# "destination" is used a lot in hooks already. keep this name, even if only for compatibility.
local destination=${bsptempdir}/${BSP_CLI_PACKAGE_FULLNAME}
declare cleanup_id="" destination=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-bsp-cli" cleanup_id destination # namerefs
mkdir -p "${destination}"/DEBIAN
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"
# array of code to be included in postinst (more than base and finish)
declare -a postinst_functions=()
# install copy of boot script & environment file
if [[ -n "${BOOTSCRIPT}" ]] && [[ $SRC_EXTLINUX != yes ]]; then
# @TODO: add extension method bsp_prepare_bootloader(), refactor into u-boot extension
local bootscript_src=${BOOTSCRIPT%%:*}
local bootscript_dst=${BOOTSCRIPT##*:}
mkdir -p "${destination}"/usr/share/armbian/
display_alert "BOOTSCRIPT" "${BOOTSCRIPT}" "debug"
display_alert "bootscript_src" "${bootscript_src}" "debug"
display_alert "bootscript_dst" "${bootscript_dst}" "debug"
# if not using extlinux, copy armbianEnv from template; prefer userpatches source
if [[ $SRC_EXTLINUX != yes ]]; then
if [ -f "${USERPATCHES_PATH}/bootscripts/${bootscript_src}" ]; then
run_host_command_logged cp -pv "${USERPATCHES_PATH}/bootscripts/${bootscript_src}" "${destination}/usr/share/armbian/${bootscript_dst}"
else
run_host_command_logged cp -pv "${SRC}/config/bootscripts/${bootscript_src}" "${destination}/usr/share/armbian/${bootscript_dst}"
fi
if [[ -n $BOOTENV_FILE && -f $SRC/config/bootenv/$BOOTENV_FILE ]]; then
run_host_command_logged cp -pv "${SRC}/config/bootenv/${BOOTENV_FILE}" "${destination}"/usr/share/armbian/armbianEnv.txt
fi
else
display_alert "Using extlinux, regular bootscripts ignored" "SRC_EXTLINUX=${SRC_EXTLINUX}" "warn"
fi
# add configuration for setting uboot environment from userspace with: fw_setenv fw_printenv
if [[ -n $UBOOT_FW_ENV ]]; then
UBOOT_FW_ENV=($(tr ',' ' ' <<< "$UBOOT_FW_ENV"))
mkdir -p "${destination}"/etc
echo "# Device to access offset env size" > "${destination}"/etc/fw_env.config
echo "/dev/mmcblk0 ${UBOOT_FW_ENV[0]} ${UBOOT_FW_ENV[1]}" >> "${destination}"/etc/fw_env.config
fi
fi
declare -a extra_description=()
[[ "${EXTRA_BSP_NAME}" != "" ]] && extra_description+=("(variant '${EXTRA_BSP_NAME}')")
# Replaces: base-files is needed to replace /etc/update-motd.d/ files on Xenial
# Replaces: unattended-upgrades may be needed to replace /etc/apt/apt.conf.d/50unattended-upgrades
# (distributions provide good defaults, so this is not needed currently)
# Depends: linux-base is needed for "linux-version" command in initrd cleanup script
# Depends: fping is needed for armbianmonitor to upload armbian-hardware-monitor.log
cat <<- EOF > "${destination}"/DEBIAN/control
Package: ${BSP_CLI_PACKAGE_NAME}
Package: ${artifact_name}
Version: ${artifact_version}
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
@ -75,227 +40,23 @@ function compile_armbian-bsp-cli() {
Section: kernel
Priority: optional
Depends: bash, linux-base, u-boot-tools, initramfs-tools, lsb-release, fping
Provides: linux-${RELEASE}-root-legacy-$BOARD, linux-${RELEASE}-root-current-$BOARD, linux-${RELEASE}-root-edge-$BOARD
Suggests: armbian-config
Replaces: zram-config, base-files, armbian-tools-$RELEASE, linux-${RELEASE}-root-legacy-$BOARD (<< $REVISION~), linux-${RELEASE}-root-current-$BOARD (<< $REVISION~), linux-${RELEASE}-root-edge-$BOARD (<< $REVISION~)
Breaks: linux-${RELEASE}-root-legacy-$BOARD (<< $REVISION~), linux-${RELEASE}-root-current-$BOARD (<< $REVISION~), linux-${RELEASE}-root-edge-$BOARD (<< $REVISION~)
Replaces: zram-config, base-files
Recommends: bsdutils, parted, util-linux, toilet
Description: Armbian board support files for $BOARD
Description: Armbian CLI BSP for board '${BOARD}' branch '${BRANCH}' ${extra_description[@]}
EOF
# set up pre install script
cat <<- EOF > "${destination}"/DEBIAN/preinst
#!/bin/sh
# generate minimal DEBIAN/changelog
cat <<- EOF > "${destination}"/DEBIAN/changelog
${artifact_name} (${artifact_version}) armbian-repo-name; urgency=low
# tell people to reboot at next login
[ "\$1" = "upgrade" ] && touch /var/run/.reboot_required
* A fake changelog entry.
# convert link to file
if [ -L "/etc/network/interfaces" ]; then
cp /etc/network/interfaces /etc/network/interfaces.tmp
rm /etc/network/interfaces
mv /etc/network/interfaces.tmp /etc/network/interfaces
fi
# fixing ramdisk corruption when using lz4 compression method
sed -i "s/^COMPRESS=.*/COMPRESS=gzip/" /etc/initramfs-tools/initramfs.conf
# swap
grep -q vm.swappiness /etc/sysctl.conf
case \$? in
0)
sed -i 's/vm\.swappiness.*/vm.swappiness=100/' /etc/sysctl.conf
;;
*)
echo vm.swappiness=100 >>/etc/sysctl.conf
;;
esac
sysctl -p >/dev/null 2>&1
# replace canonical advertisement
if [ -d "/var/lib/ubuntu-advantage/messages/" ]; then
echo "\nSupport Armbian! \nLearn more at https://armbian.com/donate" > /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status
cp /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status /var/lib/ubuntu-advantage/messages/apt-pre-invoke-no-packages-apps.tmpl
cp /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status /var/lib/ubuntu-advantage/messages/apt-pre-invoke-packages-apps
cp /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status /var/lib/ubuntu-advantage/messages/apt-pre-invoke-packages-apps.tmpl
fi
# disable deprecated services
[ -f "/etc/profile.d/activate_psd_user.sh" ] && rm /etc/profile.d/activate_psd_user.sh
[ -f "/etc/profile.d/check_first_login.sh" ] && rm /etc/profile.d/check_first_login.sh
[ -f "/etc/profile.d/check_first_login_reboot.sh" ] && rm /etc/profile.d/check_first_login_reboot.sh
[ -f "/etc/profile.d/ssh-title.sh" ] && rm /etc/profile.d/ssh-title.sh
[ -f "/etc/update-motd.d/10-header" ] && rm /etc/update-motd.d/10-header
[ -f "/etc/update-motd.d/30-sysinfo" ] && rm /etc/update-motd.d/30-sysinfo
[ -f "/etc/update-motd.d/35-tips" ] && rm /etc/update-motd.d/35-tips
[ -f "/etc/update-motd.d/40-updates" ] && rm /etc/update-motd.d/40-updates
[ -f "/etc/update-motd.d/98-autoreboot-warn" ] && rm /etc/update-motd.d/98-autoreboot-warn
[ -f "/etc/update-motd.d/99-point-to-faq" ] && rm /etc/update-motd.d/99-point-to-faq
[ -f "/etc/update-motd.d/80-esm" ] && rm /etc/update-motd.d/80-esm
[ -f "/etc/update-motd.d/80-livepatch" ] && rm /etc/update-motd.d/80-livepatch
[ -f "/etc/apt/apt.conf.d/02compress-indexes" ] && rm /etc/apt/apt.conf.d/02compress-indexes
[ -f "/etc/apt/apt.conf.d/02periodic" ] && rm /etc/apt/apt.conf.d/02periodic
[ -f "/etc/apt/apt.conf.d/no-languages" ] && rm /etc/apt/apt.conf.d/no-languages
[ -f "/etc/init.d/armhwinfo" ] && rm /etc/init.d/armhwinfo
[ -f "/etc/logrotate.d/armhwinfo" ] && rm /etc/logrotate.d/armhwinfo
[ -f "/etc/init.d/firstrun" ] && rm /etc/init.d/firstrun
[ -f "/etc/init.d/resize2fs" ] && rm /etc/init.d/resize2fs
[ -f "/lib/systemd/system/firstrun-config.service" ] && rm /lib/systemd/system/firstrun-config.service
[ -f "/lib/systemd/system/firstrun.service" ] && rm /lib/systemd/system/firstrun.service
[ -f "/lib/systemd/system/resize2fs.service" ] && rm /lib/systemd/system/resize2fs.service
[ -f "/usr/lib/armbian/apt-updates" ] && rm /usr/lib/armbian/apt-updates
[ -f "/usr/lib/armbian/firstrun-config.sh" ] && rm /usr/lib/armbian/firstrun-config.sh
# fix for https://bugs.launchpad.net/ubuntu/+source/lightdm-gtk-greeter/+bug/1897491
[ -d "/var/lib/lightdm" ] && (chown -R lightdm:lightdm /var/lib/lightdm ; chmod 0750 /var/lib/lightdm)
exit 0
-- $MAINTAINER <$MAINTAINERMAIL> $(date -R)
EOF
chmod 755 "${destination}"/DEBIAN/preinst
# postrm script
cat <<- EOF > "${destination}"/DEBIAN/postrm
#!/bin/sh
if [ remove = "\$1" ] || [ abort-install = "\$1" ]; then
systemctl disable armbian-hardware-monitor.service armbian-hardware-optimize.service >/dev/null 2>&1
systemctl disable armbian-zram-config.service armbian-ramlog.service >/dev/null 2>&1
fi
exit 0
EOF
chmod 755 "${destination}"/DEBIAN/postrm
# set up post install script
cat <<- EOF > "${destination}"/DEBIAN/postinst
#!/bin/sh
#
# ${BOARD} BSP post installation script
#
[ -f /etc/lib/systemd/system/armbian-ramlog.service ] && systemctl --no-reload enable armbian-ramlog.service
# check if it was disabled in config and disable in new service
if [ -n "\$(grep -w '^ENABLED=false' /etc/default/log2ram 2> /dev/null)" ]; then
sed -i "s/^ENABLED=.*/ENABLED=false/" /etc/default/armbian-ramlog
fi
# fix boot delay "waiting for suspend/resume device"
if [ -f "/etc/initramfs-tools/initramfs.conf" ]; then
if ! grep --quiet "RESUME=none" /etc/initramfs-tools/initramfs.conf; then
echo "RESUME=none" >> /etc/initramfs-tools/initramfs.conf
fi
fi
EOF
# install bootscripts if they are not present. Fix upgrades from old images
if [[ $FORCE_BOOTSCRIPT_UPDATE == yes ]]; then
cat <<- EOF >> "${destination}"/DEBIAN/postinst
if [ true ]; then
# this package recreate boot scripts
EOF
else
cat <<- EOF >> "${destination}"/DEBIAN/postinst
if [ ! -f /boot/$bootscript_dst ]; then
# if boot script does not exits its recreated
EOF
fi
cat <<- EOF >> "${destination}"/DEBIAN/postinst
# move bootscript to /usr/share/armbian
# create a backup
[ -f /etc/armbian-release ] && . /etc/armbian-release
[ -z \${VERSION} ] && VERSION=$(echo \`date +%s\`)
if [ -f /boot/$bootscript_dst ]; then
cp /boot/$bootscript_dst /usr/share/armbian/${bootscript_dst}-\${VERSION} >/dev/null 2>&1
echo "NOTE: You can find previous bootscript versions in /usr/share/armbian !"
fi
# cleanup old bootscript backup
ls /usr/share/armbian/boot.cmd-* >/dev/null 2>&1 | head -n -5 | xargs rm -f --
ls /usr/share/armbian/boot.ini-* >/dev/null 2>&1 | head -n -5 | xargs rm -f --
echo "Recreating boot script"
cp /usr/share/armbian/$bootscript_dst /boot >/dev/null 2>&1
rootdev=\$(sed -e 's/^.*root=//' -e 's/ .*\$//' < /proc/cmdline)
rootfstype=\$(sed -e 's/^.*rootfstype=//' -e 's/ .*$//' < /proc/cmdline)
# recreate armbianEnv.txt if it and extlinux does not exists
if [ ! -f /boot/armbianEnv.txt ] && [ ! -f /boot/extlinux/extlinux.conf ]; then
cp /usr/share/armbian/armbianEnv.txt /boot >/dev/null 2>&1
echo "rootdev="\$rootdev >> /boot/armbianEnv.txt
echo "rootfstype="\$rootfstype >> /boot/armbianEnv.txt
fi
[ -f /boot/boot.ini ] && sed -i "s/setenv rootdev.*/setenv rootdev \\"\$rootdev\\"/" /boot/boot.ini
[ -f /boot/boot.ini ] && sed -i "s/setenv rootfstype.*/setenv rootfstype \\"\$rootfstype\\"/" /boot/boot.ini
[ -f /boot/boot.cmd ] && mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr >/dev/null 2>&1
fi
[ ! -f "/etc/network/interfaces" ] && [ -f "/etc/network/interfaces.default" ] && cp /etc/network/interfaces.default /etc/network/interfaces
ln -sf /var/run/motd /etc/motd
rm -f /etc/update-motd.d/00-header /etc/update-motd.d/10-help-text
if [ ! -f "/etc/default/armbian-motd" ]; then
mv /etc/default/armbian-motd.dpkg-dist /etc/default/armbian-motd
fi
if [ ! -f "/etc/default/armbian-ramlog" ] && [ -f /etc/default/armbian-ramlog.dpkg-dist ]; then
mv /etc/default/armbian-ramlog.dpkg-dist /etc/default/armbian-ramlog
fi
if [ ! -f "/etc/default/armbian-zram-config" ] && [ -f /etc/default/armbian-zram-config.dpkg-dist ]; then
mv /etc/default/armbian-zram-config.dpkg-dist /etc/default/armbian-zram-config
fi
if [ -L "/usr/lib/chromium-browser/master_preferences.dpkg-dist" ]; then
mv /usr/lib/chromium-browser/master_preferences.dpkg-dist /usr/lib/chromium-browser/master_preferences
fi
# Read release value
if [ -f /etc/lsb-release ]; then
RELEASE=\$(cat /etc/lsb-release | grep CODENAME | cut -d"=" -f2 | sed 's/.*/\u&/')
sed -i "s/^PRETTY_NAME=.*/PRETTY_NAME=\"${VENDOR} $REVISION ${RELEASE}\"/" /etc/os-release
echo "${VENDOR} ${REVISION} \${RELEASE} \\l \n" > /etc/issue
echo "${VENDOR} ${REVISION} \${RELEASE}" > /etc/issue.net
fi
# Reload services
systemctl --no-reload enable armbian-hardware-monitor.service armbian-hardware-optimize.service armbian-zram-config.service armbian-led-state.service >/dev/null 2>&1
exit 0
EOF
chmod 755 "${destination}"/DEBIAN/postinst
# won't recreate files if they were removed by user
# 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
EOF
# copy common files from a premade directory structure
# @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
cat <<- EOF > "${destination}"/DEBIAN/triggers
activate update-initramfs
EOF
# 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
done
# armhwinfo, firstrun, armbianmonitor, etc. config file
# armhwinfo, firstrun, armbianmonitor, etc. config file; also sourced in postinst
mkdir -p "${destination}"/etc
cat <<- EOF > "${destination}"/etc/armbian-release
# PLEASE DO NOT EDIT THIS FILE
BOARD=$BOARD
@ -310,8 +71,85 @@ function compile_armbian-bsp-cli() {
BOARD_TYPE=$BOARD_TYPE
INITRD_ARCH=$INITRD_ARCH
KERNEL_IMAGE_TYPE=$KERNEL_IMAGE_TYPE
FORCE_BOOTSCRIPT_UPDATE=$FORCE_BOOTSCRIPT_UPDATE
VENDOR=$VENDOR
REVISION=$REVISION
EOF
# copy general overlay from packages/bsp-cli
# in practice: packages/bsp-cli and variations of config/optional/...
copy_all_packages_files_for "bsp-cli"
# copy common files from a premade directory structure
# @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}"
mkdir -p "${destination}"/usr/share/armbian/
# get bootscript information.
declare -A bootscript_info=()
get_bootscript_info
if [[ "${bootscript_info[has_bootscript]}" == "yes" ]]; then
# Append some of it to armbian-release
cat <<- EOF >> "${destination}"/etc/armbian-release
BOOTSCRIPT_FORCE_UPDATE="${bootscript_info[bootscript_force_update]}"
BOOTSCRIPT_DST="${bootscript_info[bootscript_dst]}"
EOF
# Using bootscript, copy it to /usr/share/armbian
run_host_command_logged cp -pv "${bootscript_info[bootscript_file_fullpath]}" "${destination}/usr/share/armbian/${bootscript_info[bootscript_dst]}"
if [[ "${bootscript_info[has_bootenv]}" == "yes" ]]; then
run_host_command_logged cp -pv "${bootscript_info[bootenv_file_fullpath]}" "${destination}"/usr/share/armbian/armbianEnv.txt
fi
# add to postinst, to update bootscript if forced or missing
postinst_functions+=(board_side_bsp_cli_postinst_update_uboot_bootscript)
fi
# add configuration for setting uboot environment from userspace with: fw_setenv fw_printenv
if [[ -n $UBOOT_FW_ENV ]]; then
UBOOT_FW_ENV=($(tr ',' ' ' <<< "$UBOOT_FW_ENV"))
echo "# Device to access offset env size" > "${destination}"/etc/fw_env.config
echo "/dev/mmcblk0 ${UBOOT_FW_ENV[0]} ${UBOOT_FW_ENV[1]}" >> "${destination}"/etc/fw_env.config
fi
# set up pre install script; use inline functions
# This is never run in build context; instead, it's source code is dumped inside a file that is packaged.
# It is done this way so we get shellcheck and formatting instead of a huge heredoc.
### preinst
artifact_package_hook_helper_board_side_functions "preinst" board_side_bsp_cli_preinst
unset board_side_bsp_cli_preinst
### postrm
artifact_package_hook_helper_board_side_functions "postrm" board_side_bsp_cli_postrm
unset board_side_bsp_cli_postrm
### postinst -- a bit more complex
artifact_package_hook_helper_board_side_functions "postinst" board_side_bsp_cli_postinst_base "${postinst_functions[@]}" board_side_bsp_cli_postinst_finish
unset board_side_bsp_cli_postinst_base board_side_bsp_cli_postinst_update_uboot_bootscript board_side_bsp_cli_postinst_finish
# won't recreate files if they were removed by user
# 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
EOF
# trigger uInitrd creation after installation, to apply
# /etc/initramfs/post-update.d/99-uboot
cat <<- EOF > "${destination}"/DEBIAN/triggers
activate update-initramfs
EOF
# 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
done
# this is required for NFS boot to prevent deconfiguring the network on shutdown
sed -i 's/#no-auto-down/no-auto-down/g' "${destination}"/etc/network/interfaces.default
@ -334,13 +172,198 @@ function compile_armbian-bsp-cli() {
find "${destination}" -print0 2> /dev/null | xargs -0r chown --no-dereference 0:0
find "${destination}" ! -type l -print0 2> /dev/null | xargs -0r chmod 'go=rX,u+rw,a-s'
# create board DEB file
fakeroot_dpkg_deb_build "${destination}" "${DEB_STORAGE}"
#"${destination}.deb"
# mkdir -p "${DEB_STORAGE}/"
# run_host_command_logged rsync --remove-source-files -r "${destination}.deb" "${DEB_STORAGE}/"
# Build / close the package. This will run shellcheck / show the generated files if debugging
fakeroot_dpkg_deb_build "${destination}" "${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"
}
function get_bootscript_info() {
bootscript_info[has_bootscript]="no"
bootscript_info[has_extlinux]="no"
if [[ -n "${BOOTSCRIPT}" ]] && [[ $SRC_EXTLINUX != yes ]]; then
bootscript_info[has_bootscript]="yes"
declare bootscript_source="${BOOTSCRIPT%%:*}"
declare bootscript_destination="${BOOTSCRIPT##*:}"
# outer scope
bootscript_info[bootscript_force_update]="${FORCE_BOOTSCRIPT_UPDATE:-"no"}"
bootscript_info[bootscript_src]="${bootscript_source}"
bootscript_info[bootscript_dst]="${bootscript_destination}"
bootscript_info[bootscript_file_contents]=""
bootscript_info[bootscript_file_fullpath]="${SRC}/config/bootscripts/${bootscript_source}"
if [ -f "${USERPATCHES_PATH}/bootscripts/${bootscript_source}" ]; then
bootscript_info[bootscript_file_fullpath]="${USERPATCHES_PATH}/bootscripts/${bootscript_source}"
fi
bootscript_info[bootscript_file_contents]="$(cat "${bootscript_info[bootscript_file_fullpath]}")"
bootscript_info[bootenv_file_fullpath]=""
bootscript_info[has_bootenv]="no"
bootscript_info[bootenv_file_contents]=""
if [[ -n $BOOTENV_FILE && -f $SRC/config/bootenv/$BOOTENV_FILE ]]; then
bootscript_info[has_bootenv]="yes"
bootscript_info[bootenv_file_fullpath]="${SRC}/config/bootenv/${BOOTENV_FILE}"
bootscript_info[bootenv_file_contents]="$(cat "${SRC}/config/bootenv/${BOOTENV_FILE}")"
fi
elif [[ $SRC_EXTLINUX == yes ]]; then
bootscript_info[has_extlinux]="yes"
display_alert "Using extlinux, regular bootscripts ignored" "SRC_EXTLINUX=${SRC_EXTLINUX}" "warn"
fi
debug_dict bootscript_info
}
function board_side_bsp_cli_postinst_update_uboot_bootscript() {
if [[ ${BOOTSCRIPT_FORCE_UPDATE} == yes || ! -f /boot/${BOOTSCRIPT_DST} ]]; then
[ -z ${BOOTSCRIPT_BACKUP_VERSION} ] && BOOTSCRIPT_BACKUP_VERSION="$(date +%s)"
if [ -f /boot/${BOOTSCRIPT_DST} ]; then
cp -v /boot/${BOOTSCRIPT_DST} /usr/share/armbian/${BOOTSCRIPT_DST}-${BOOTSCRIPT_BACKUP_VERSION}
echo "NOTE: You can find previous bootscript versions in /usr/share/armbian !"
fi
echo "Recreating boot script"
cp -v /usr/share/armbian/${BOOTSCRIPT_DST} /boot
rootdev=$(sed -e 's/^.*root=//' -e 's/ .*\$//' < /proc/cmdline)
rootfstype=$(sed -e 's/^.*rootfstype=//' -e 's/ .*$//' < /proc/cmdline)
# recreate armbianEnv.txt if it and extlinux does not exists
if [ ! -f /boot/armbianEnv.txt ] && [ ! -f /boot/extlinux/extlinux.conf ]; then
cp -v /usr/share/armbian/armbianEnv.txt /boot
echo "rootdev="\$rootdev >> /boot/armbianEnv.txt
echo "rootfstype="\$rootfstype >> /boot/armbianEnv.txt
fi
# update boot.ini if it exists? @TODO: why? who uses this?
[ -f /boot/boot.ini ] && sed -i "s/setenv rootdev.*/setenv rootdev \\"$rootdev\\"/" /boot/boot.ini
[ -f /boot/boot.ini ] && sed -i "s/setenv rootfstype.*/setenv rootfstype \\"$rootfstype\\"/" /boot/boot.ini
[ -f /boot/boot.cmd ] && mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr > /dev/null 2>&1
fi
}
function board_side_bsp_cli_preinst() {
# tell people to reboot at next login
[ "$1" = "upgrade" ] && touch /var/run/.reboot_required
# convert link to file
if [ -L "/etc/network/interfaces" ]; then
cp /etc/network/interfaces /etc/network/interfaces.tmp
rm /etc/network/interfaces
mv /etc/network/interfaces.tmp /etc/network/interfaces
fi
# fixing ramdisk corruption when using lz4 compression method
sed -i "s/^COMPRESS=.*/COMPRESS=gzip/" /etc/initramfs-tools/initramfs.conf
# swap
grep -q vm.swappiness /etc/sysctl.conf
case $? in
0)
sed -i 's/vm\.swappiness.*/vm.swappiness=100/' /etc/sysctl.conf
;;
*)
echo vm.swappiness=100 >> /etc/sysctl.conf
;;
esac
sysctl -p > /dev/null 2>&1
# replace canonical advertisement
if [ -d "/var/lib/ubuntu-advantage/messages/" ]; then
echo -e "\nSupport Armbian! \nLearn more at https://armbian.com/donate" > /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status
cp /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status /var/lib/ubuntu-advantage/messages/apt-pre-invoke-no-packages-apps.tmpl
cp /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status /var/lib/ubuntu-advantage/messages/apt-pre-invoke-packages-apps
cp /var/lib/ubuntu-advantage/messages/apt-pre-invoke-esm-service-status /var/lib/ubuntu-advantage/messages/apt-pre-invoke-packages-apps.tmpl
fi
# disable deprecated services
[ -f "/etc/profile.d/activate_psd_user.sh" ] && rm /etc/profile.d/activate_psd_user.sh
[ -f "/etc/profile.d/check_first_login.sh" ] && rm /etc/profile.d/check_first_login.sh
[ -f "/etc/profile.d/check_first_login_reboot.sh" ] && rm /etc/profile.d/check_first_login_reboot.sh
[ -f "/etc/profile.d/ssh-title.sh" ] && rm /etc/profile.d/ssh-title.sh
[ -f "/etc/update-motd.d/10-header" ] && rm /etc/update-motd.d/10-header
[ -f "/etc/update-motd.d/30-sysinfo" ] && rm /etc/update-motd.d/30-sysinfo
[ -f "/etc/update-motd.d/35-tips" ] && rm /etc/update-motd.d/35-tips
[ -f "/etc/update-motd.d/40-updates" ] && rm /etc/update-motd.d/40-updates
[ -f "/etc/update-motd.d/98-autoreboot-warn" ] && rm /etc/update-motd.d/98-autoreboot-warn
[ -f "/etc/update-motd.d/99-point-to-faq" ] && rm /etc/update-motd.d/99-point-to-faq
[ -f "/etc/update-motd.d/80-esm" ] && rm /etc/update-motd.d/80-esm
[ -f "/etc/update-motd.d/80-livepatch" ] && rm /etc/update-motd.d/80-livepatch
[ -f "/etc/apt/apt.conf.d/02compress-indexes" ] && rm /etc/apt/apt.conf.d/02compress-indexes
[ -f "/etc/apt/apt.conf.d/02periodic" ] && rm /etc/apt/apt.conf.d/02periodic
[ -f "/etc/apt/apt.conf.d/no-languages" ] && rm /etc/apt/apt.conf.d/no-languages
[ -f "/etc/init.d/armhwinfo" ] && rm /etc/init.d/armhwinfo
[ -f "/etc/logrotate.d/armhwinfo" ] && rm /etc/logrotate.d/armhwinfo
[ -f "/etc/init.d/firstrun" ] && rm /etc/init.d/firstrun
[ -f "/etc/init.d/resize2fs" ] && rm /etc/init.d/resize2fs
[ -f "/lib/systemd/system/firstrun-config.service" ] && rm /lib/systemd/system/firstrun-config.service
[ -f "/lib/systemd/system/firstrun.service" ] && rm /lib/systemd/system/firstrun.service
[ -f "/lib/systemd/system/resize2fs.service" ] && rm /lib/systemd/system/resize2fs.service
[ -f "/usr/lib/armbian/apt-updates" ] && rm /usr/lib/armbian/apt-updates
[ -f "/usr/lib/armbian/firstrun-config.sh" ] && rm /usr/lib/armbian/firstrun-config.sh
# fix for https://bugs.launchpad.net/ubuntu/+source/lightdm-gtk-greeter/+bug/1897491
[ -d "/var/lib/lightdm" ] && (
chown -R lightdm:lightdm /var/lib/lightdm
chmod 0750 /var/lib/lightdm
)
}
function board_side_bsp_cli_postrm() { # not run here
if [[ remove == "$1" ]] || [[ abort-install == "$1" ]]; then
systemctl disable armbian-hardware-monitor.service armbian-hardware-optimize.service > /dev/null 2>&1
systemctl disable armbian-zram-config.service armbian-ramlog.service > /dev/null 2>&1
fi
}
function board_side_bsp_cli_postinst_base() {
# Source the armbian-release information file
[ -f /etc/armbian-release ] && . /etc/armbian-release
# Read release value from lsb-release, so deploying a bsp-cli package on top of "X" makes it "Armbian X"
if [ -f /etc/lsb-release ]; then
ORIGINAL_DISTRO_RELEASE="$(cat /etc/lsb-release | grep CODENAME | cut -d"=" -f2 | sed 's/.*/\u&/')"
sed -i "s/^PRETTY_NAME=.*/PRETTY_NAME=\"${VENDOR} $REVISION ${ORIGINAL_DISTRO_RELEASE}\"/" /etc/os-release
echo -e "${VENDOR} ${REVISION} ${ORIGINAL_DISTRO_RELEASE} \\l \n" > /etc/issue
echo -e "${VENDOR} ${REVISION} ${ORIGINAL_DISTRO_RELEASE}" > /etc/issue.net
fi
# Force ramlog to be enabled if it exists. @TODO: why?
[ -f /etc/lib/systemd/system/armbian-ramlog.service ] && systemctl --no-reload enable armbian-ramlog.service
# check if it was disabled in config and disable in new service
if [ -n "$(grep -w '^ENABLED=false' /etc/default/log2ram 2> /dev/null)" ]; then
sed -i "s/^ENABLED=.*/ENABLED=false/" /etc/default/armbian-ramlog
fi
# fix boot delay "waiting for suspend/resume device"
if [ -f "/etc/initramfs-tools/initramfs.conf" ]; then
if ! grep --quiet "RESUME=none" /etc/initramfs-tools/initramfs.conf; then
echo "RESUME=none" >> /etc/initramfs-tools/initramfs.conf
fi
fi
}
function board_side_bsp_cli_postinst_finish() {
[ ! -f "/etc/network/interfaces" ] && [ -f "/etc/network/interfaces.default" ] && cp /etc/network/interfaces.default /etc/network/interfaces
ln -sf /var/run/motd /etc/motd
rm -f /etc/update-motd.d/00-header /etc/update-motd.d/10-help-text
if [ ! -f "/etc/default/armbian-motd" ]; then
mv /etc/default/armbian-motd.dpkg-dist /etc/default/armbian-motd
fi
if [ ! -f "/etc/default/armbian-ramlog" ] && [ -f /etc/default/armbian-ramlog.dpkg-dist ]; then
mv /etc/default/armbian-ramlog.dpkg-dist /etc/default/armbian-ramlog
fi
if [ ! -f "/etc/default/armbian-zram-config" ] && [ -f /etc/default/armbian-zram-config.dpkg-dist ]; then
mv /etc/default/armbian-zram-config.dpkg-dist /etc/default/armbian-zram-config
fi
if [ -L "/usr/lib/chromium-browser/master_preferences.dpkg-dist" ]; then
mv /usr/lib/chromium-browser/master_preferences.dpkg-dist /usr/lib/chromium-browser/master_preferences
fi
# Reload services
systemctl --no-reload enable armbian-hardware-monitor.service armbian-hardware-optimize.service armbian-zram-config.service armbian-led-state.service > /dev/null 2>&1
}

View File

@ -7,24 +7,41 @@
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
# bsp-desktop should be like bsp-cli
# it is keyed by RELEASE/BOARD/BRANCH, thus "a common package for all desktops with the same board/branch in a given release"
# # @TODO: it should NOT be dependendent on a specific (xfce/mate/etc) desktop environment
# but right now it is, since aggregation depends on it, and needs further changes @TODO: we should split.
# main use case to include vendor wallpaper, etc
function compile_armbian-bsp-desktop() {
: "${artifact_name:?artifact_name is not set}"
: "${artifact_version:?artifact_version is not set}"
: "${RELEASE:?RELEASE is not set}"
: "${BOARD:?BOARD is not set}"
: "${BRANCH:?BRANCH is not set}"
: "${DISTRIBUTION:?DISTRIBUTION is not set}"
display_alert "Creating board support package for desktop" "${package_name}" "info"
: "${DESKTOP_ENVIRONMENT:?DESKTOP_ENVIRONMENT is not set}"
: "${DESKTOP_ENVIRONMENT_CONFIG_NAME:?DESKTOP_ENVIRONMENT_CONFIG_NAME is not set}"
local package_name="${BSP_DESKTOP_PACKAGE_FULLNAME}"
declare cleanup_id="" tmp_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "bsp-desktop2" cleanup_id tmp_dir # namerefs
assert_requires_aggregation # this requires aggregation to have been run
: "${AGGREGATED_DESKTOP_BSP_PREPARE:?AGGREGATED_DESKTOP_BSP_PREPARE is not set}"
: "${AGGREGATED_DESKTOP_BSP_POSTINST:?AGGREGATED_DESKTOP_BSP_POSTINST is not set}"
local destination=${tmp_dir}/${BOARD}/${BSP_DESKTOP_PACKAGE_FULLNAME}
rm -rf "${destination}"
# @TODO: this is not true, as you can see; this is specific per-desktop due to aggregation
display_alert "Creating bsp-desktop for release '${RELEASE}' common to all desktops on board '${BOARD}' branch '${BRANCH}'" "${artifact_name} :: ${artifact_version}" "info"
declare cleanup_id="" destination=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "bsp-desktop" cleanup_id destination # namerefs
mkdir -p "${destination}"/etc/armbian
mkdir -p "${destination}"/DEBIAN
copy_all_packages_files_for "bsp-desktop"
# set up control file
cat <<- EOF > "${destination}"/DEBIAN/control
Package: armbian-bsp-desktop-${BOARD}
Package: ${artifact_name}
Version: ${artifact_version}
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
@ -32,24 +49,18 @@ function compile_armbian-bsp-desktop() {
Section: xorg
Priority: optional
Provides: armbian-bsp-desktop, armbian-bsp-desktop-${BOARD}
Depends: ${BSP_CLI_PACKAGE_NAME}
Description: Armbian Board Specific Packages for desktop users using $ARCH ${BOARD} machines
Description: Armbian bsp-desktop for release ${RELEASE}, common for all desktop environments on ${ARCH} ${BOARD} machines on ${BRANCH} branch
EOF
# Recreating the DEBIAN/postinst file
echo "#!/bin/bash -e" > "${destination}/DEBIAN/postinst"
echo "${AGGREGATED_DESKTOP_BSP_POSTINST}" >> "${destination}/DEBIAN/postinst"
echo "exit 0" >> "${destination}/DEBIAN/postinst"
chmod 755 "${destination}"/DEBIAN/postinst
# postinst. generated script, gathered from scripts in files in configuration. # @TODO: extensions could do this much better
generic_artifact_package_hook_helper "postinst" "${AGGREGATED_DESKTOP_BSP_POSTINST}"
# Armbian create_desktop_package scripts
mkdir -p "${destination}"/etc/armbian
# @TODO: error information? This is very likely to explode....
# @TODO: error information? This is very likely to explode, and a bad implementation of extensibility.
display_alert "Running bsp-desktop -specific aggregated prepare script" "AGGREGATED_DESKTOP_BSP_PREPARE" "debug"
eval "${AGGREGATED_DESKTOP_BSP_PREPARE}"
display_alert "Done with bsp-desktop -specific aggregated prepare script" "AGGREGATED_DESKTOP_BSP_PREPARE" "debug"
mkdir -p "${DEB_STORAGE}/${RELEASE}"
cd "${destination}" || exit_with_error "Failed to cd to ${destination}"
cd ..
fakeroot_dpkg_deb_build "${destination}" "${DEB_STORAGE}/${RELEASE}"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early

View File

@ -1,57 +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 compile_armbian-desktop() {
: "${artifact_version:?artifact_version is not set}"
# produced by aggregation.py
display_alert "bsp-desktop: AGGREGATED_PACKAGES_DESKTOP_COMMA" "'${AGGREGATED_PACKAGES_DESKTOP_COMMA}'" "debug"
declare cleanup_id="" tmp_dir=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "bsp-desktop" cleanup_id tmp_dir # namerefs
declare destination="${tmp_dir}/${BOARD}/${CHOSEN_DESKTOP}_${artifact_version}_all"
rm -rf "${destination}"
mkdir -p "${destination}"/DEBIAN
# set up control file
cat <<- EOF > "${destination}"/DEBIAN/control
Package: ${CHOSEN_DESKTOP}
Version: ${artifact_version}
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Section: xorg
Priority: optional
Recommends: ${AGGREGATED_PACKAGES_DESKTOP_COMMA}, armbian-bsp-desktop
Provides: ${CHOSEN_DESKTOP}, armbian-${RELEASE}-desktop
Conflicts: gdm3
Description: Armbian desktop for ${DISTRIBUTION} ${RELEASE}
EOF
# Recreating the DEBIAN/postinst file
echo "#!/bin/bash -e" > "${destination}/DEBIAN/postinst"
echo "${AGGREGATED_DESKTOP_POSTINST}" >> "${destination}/DEBIAN/postinst"
echo "exit 0" >> "${destination}/DEBIAN/postinst"
chmod 755 "${destination}"/DEBIAN/postinst
# Armbian create_desktop_package scripts
mkdir -p "${destination}"/etc/armbian
# @TODO: error information? This is very likely to explode....
eval "${AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE}"
display_alert "Building desktop package" "${CHOSEN_DESKTOP}_${artifact_version}_all" "info"
mkdir -p "${DEB_STORAGE}/${RELEASE}"
#cd "${destination}" || exit_with_error "Failed to cd to ${destination}"
#cd ..
fakeroot_dpkg_deb_build "${destination}" "${DEB_STORAGE}/${RELEASE}"
done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
}

View File

@ -9,6 +9,8 @@
# copy_all_packages_files_for <folder> to package
copy_all_packages_files_for() {
: "${destination:?destination is not set}"
local package_name="${1}"
# @TODO: rpardini: this was recovered after being assassinated by some insane person who rewrote aggregation in Python

View File

@ -39,20 +39,23 @@ function armbian_register_commands() {
# shortcuts, see vars set below. the use legacy single build, and try to control it via variables
["rootfs"]="artifact"
["kernel"]="artifact"
["kernel-config"]="artifact"
["u-boot"]="artifact"
["uboot"]="artifact"
["firmware"]="artifact"
["firmware-full"]="artifact"
["armbian-config"]="artifact"
["armbian-zsh"]="artifact"
["armbian-plymouth-theme"]="artifact"
["fake-ubuntu-advantage-tools"]="artifact"
["armbian-bsp-cli"]="artifact"
["armbian-bsp-desktop"]="artifact"
["armbian-desktop"]="artifact"
["kernel"]="artifact"
["kernel-config"]="artifact"
["u-boot"]="artifact"
["uboot"]="artifact"
["fake_ubuntu_advantage_tools"]="fake_ubuntu_advantage_tools"
["undecided"]="undecided" # implemented in cli_undecided_pre_run and cli_undecided_run - relaunches either build or docker
)
@ -70,20 +73,24 @@ function armbian_register_commands() {
["generate-dockerfile"]="DOCKERFILE_GENERATE_ONLY='yes'"
# artifact shortcuts
["rootfs"]="WHAT='rootfs' ${common_cli_artifact_vars}"
["kernel-config"]="WHAT='kernel' KERNEL_CONFIGURE='yes' ARTIFACT_BUILD_INTERACTIVE='yes' ARTIFACT_IGNORE_CACHE='yes' ${common_cli_artifact_vars}"
["kernel"]="WHAT='kernel' ${common_cli_artifact_vars}"
["uboot"]="WHAT='uboot' ${common_cli_artifact_vars}"
["u-boot"]="WHAT='uboot' ${common_cli_artifact_vars}"
["firmware"]="WHAT='firmware' ${common_cli_artifact_vars}"
["firmware-full"]="WHAT='full_firmware' ${common_cli_artifact_vars}"
["fake-ubuntu-advantage-tools"]="WHAT='fake-ubuntu-advantage-tools' ${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}"
["armbian-bsp-cli"]="WHAT='armbian-bsp-cli' ${common_cli_artifact_vars}"
["armbian-bsp-desktop"]="WHAT='armbian-bsp-desktop' ${common_cli_artifact_vars}"
["armbian-desktop"]="WHAT='armbian-desktop' ${common_cli_artifact_vars}"
["rootfs"]="WHAT='rootfs' ${common_cli_artifact_vars}"
["armbian-bsp-desktop"]="WHAT='armbian-bsp-desktop' BUILD_DESKTOP='yes' ${common_cli_artifact_vars}"
["armbian-desktop"]="WHAT='armbian-desktop' BUILD_DESKTOP='yes' ${common_cli_artifact_vars}"
["oras-upload"]="ORAS_OPERATION='upload'"

View File

@ -0,0 +1,66 @@
#!/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/
# keyed by RELEASE/DESKTOP_ENVIRONMENT
# not by BOARD, nor BRANCH
# use case "metapackage for installing a minimal xfce" on any board
function compile_armbian-desktop() {
: "${artifact_name:?artifact_name is not set}"
: "${artifact_version:?artifact_version is not set}"
: "${RELEASE:?RELEASE is not set}"
: "${DISTRIBUTION:?DISTRIBUTION is not set}"
: "${DESKTOP_ENVIRONMENT:?DESKTOP_ENVIRONMENT is not set}"
: "${DESKTOP_ENVIRONMENT_CONFIG_NAME:?DESKTOP_ENVIRONMENT_CONFIG_NAME is not set}"
assert_requires_aggregation # this requires aggregation to have been run
: "${AGGREGATED_DESKTOP_POSTINST:?AGGREGATED_DESKTOP_POSTINST is not set}"
: "${AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE:?AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE is not set}"
: "${AGGREGATED_PACKAGES_DESKTOP_COMMA:?AGGREGATED_PACKAGES_DESKTOP_COMMA is not set}"
# produced by aggregation.py
display_alert "bsp-desktop: AGGREGATED_PACKAGES_DESKTOP_COMMA" "'${AGGREGATED_PACKAGES_DESKTOP_COMMA}'" "debug"
# @TODO: AGGREGATED_PACKAGES_DESKTOP_COMMA includes appgroups, which can vary.
display_alert "Creating common package for '${DESKTOP_ENVIRONMENT}' desktops" "${artifact_name} :: ${artifact_version}" "info"
declare cleanup_id="" destination=""
prepare_temp_dir_in_workdir_and_schedule_cleanup "bsp-desktop" cleanup_id destination # namerefs
mkdir -p "${destination}"/DEBIAN
mkdir -p "${destination}"/etc/armbian
# set up control file
cat <<- EOF > "${destination}"/DEBIAN/control
Package: ${artifact_name}
Version: ${artifact_version}
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Section: xorg
Priority: optional
Recommends: ${AGGREGATED_PACKAGES_DESKTOP_COMMA}, armbian-bsp-desktop
Provides: armbian-${RELEASE}-desktop
Conflicts: gdm3
Description: Armbian desktop for ${DISTRIBUTION} ${RELEASE} ${DESKTOP_ENVIRONMENT}
EOF
# postinst. generated script, gathered from scripts in files in configuration. # @TODO: extensions could do this much better
generic_artifact_package_hook_helper "postinst" "${AGGREGATED_DESKTOP_POSTINST}"
# @TODO: error information? This is very likely to explode, and a bad implementation of extensibility.
display_alert "Running desktop-specific aggregated prepare script" "AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE" "debug"
eval "${AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE}"
display_alert "Running desktop-specific aggregated prepare script" "AGGREGATED_DESKTOP_CREATE_DESKTOP_PACKAGE" "debug"
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
}

View File

@ -9,7 +9,10 @@
# for deb building.
function fakeroot_dpkg_deb_build() {
display_alert "Building .deb package" "$*" "debug"
# check artifact_name is set otherwise exit_with_error
[[ -z "${artifact_name}" ]] && exit_with_error "fakeroot_dpkg_deb_build: artifact_name is not set"
display_alert "Building .deb package" "${artifact_name}: $*" "debug"
declare -a orig_args=("$@")
# find the first non-option argument
@ -34,9 +37,27 @@ function fakeroot_dpkg_deb_build() {
# find the DEBIAN scripts (postinst, prerm, etc) and run shellcheck on them.
dpkg_deb_run_shellcheck_on_scripts "${first_arg}"
# Dump the CONTROL file to the log.
display_alert "Showing DEBIAN/control file" "${pkg_name}/DEBIAN/control" "info"
run_tool_batcat --file-name "${pkg_name}/DEBIAN/control" "${first_arg}/DEBIAN/control"
# Debug, dump the generated postrm/preinst/postinst
if [[ "${SHOW_DEBUG}" == "yes" || "${SHOW_DEBIAN}" == "yes" ]]; then
# Dump the CONTROL file to the log (always, @TODO later under debugging)
run_tool_batcat --file-name "${artifact_name}/DEBIAN/control" "${first_arg}/DEBIAN/control"
if [[ -f "${first_arg}/DEBIAN/changelog" ]]; then
run_tool_batcat --file-name "${artifact_name}/DEBIAN/changelog" "${first_arg}/DEBIAN/changelog"
fi
if [[ -f "${first_arg}/DEBIAN/postrm" ]]; then
run_tool_batcat --file-name "${artifact_name}/DEBIAN/postrm.sh" "${first_arg}/DEBIAN/postrm"
fi
if [[ -f "${first_arg}/DEBIAN/preinst" ]]; then
run_tool_batcat --file-name "${artifact_name}/DEBIAN/preinst.sh" "${first_arg}/DEBIAN/preinst"
fi
if [[ -f "${first_arg}/DEBIAN/postinst" ]]; then
run_tool_batcat --file-name "${artifact_name}/DEBIAN/postinst.sh" "${first_arg}/DEBIAN/postinst"
fi
fi
run_host_command_logged_raw fakeroot dpkg-deb -b "-Z${DEB_COMPRESS}" "${orig_args[@]}"
}
@ -69,3 +90,44 @@ function dpkg_deb_run_shellcheck_on_scripts() {
display_alert "shellcheck found no problems in package scripts" "no scripts found for '${pkg_name}'" "info"
fi
}
function artifact_package_hook_helper_board_side_functions() {
declare script="${1}"
shift
# each remaining arg is a function name; for each, run 'declare -f', remove the first, second and last line (function declaration, open brace, close brac, and add it to contents.
declare -a functions=("$@")
declare contents=""
declare newline=$'\n'
for function in "${functions[@]}"; do
contents+="${newline}## begin contents of '${function}'${newline}"
contents+="$(declare -f "${function}" | sed -e '2d' -e '1d' -e '$d')"
contents+="${newline}## end contents of '${function}'${newline}"
done
generic_artifact_package_hook_helper "${script}" "${contents}"
}
function generic_artifact_package_hook_helper() {
# check '$destination' is set
[[ -z "${destination}" ]] && exit_with_error "generic_artifact_package_hook_helper: destination not set"
declare script="${1}"
declare contents="${2}"
declare package_DEBIAN_dir="${destination}"/DEBIAN
[[ ! -d "${package_DEBIAN_dir}" ]] && exit_with_error "generic_artifact_package_hook_helper: package DEBIAN dir '${package_DEBIAN_dir}' doesn't exist"
cat >> "${package_DEBIAN_dir}/${script}" <<- EOT
#!/bin/bash
echo "Armbian '${artifact_name:?}' for '${artifact_version:?}': '${script}' starting."
set +e # NO ERROR CONTROL, for compatibility with legacy Armbian scripts.
set -x # Debugging
$(echo "${contents}")
set +x # Disable debugging
echo "Armbian '${artifact_name:?}' for '${artifact_version:?}': '${script}' finishing."
true
EOT
chmod 755 "${package_DEBIAN_dir}/${script}"
# produce log asset for script (@TODO: batcat?)
LOG_ASSET="deb-${artifact_name:?}-${script}.sh" do_with_log_asset run_host_command_logged cat "${package_DEBIAN_dir}/${script}"
}

View File

@ -43,15 +43,15 @@ function determine_artifacts_to_build_for_image() {
artifacts_to_build+=("armbian-plymouth-theme")
fi
if [[ -n "${RELEASE}" ]]; then
# Further packages require aggregation
assert_requires_aggregation
# Userspace, BOARD+BRANCH specific (not RELEASE)
artifacts_to_build+=("armbian-bsp-cli")
artifacts_to_build+=("armbian-bsp-cli")
if [[ -n "${DESKTOP_ENVIRONMENT}" ]]; then
artifacts_to_build+=("armbian-desktop")
artifacts_to_build+=("armbian-bsp-desktop")
fi
# Userspace, RELEASE-specific artifacts.
if [[ -n "${RELEASE}" ]]; then
if [[ -n "${DESKTOP_ENVIRONMENT}" ]]; then
artifacts_to_build+=("armbian-desktop")
artifacts_to_build+=("armbian-bsp-desktop")
fi
fi
}

View File

@ -361,7 +361,7 @@ function install_distribution_agnostic() {
fi
# install board support packages
install_deb_chroot "${DEB_STORAGE}/${image_artifacts_debs["armbian-bsp"]}"
install_deb_chroot "${DEB_STORAGE}/${image_artifacts_debs["armbian-bsp-cli"]}"
# install armbian-desktop
if [[ $BUILD_DESKTOP == yes ]]; then

View File

@ -51,7 +51,8 @@ function install_distribution_specific() {
disable_systemd_service_sdcard ondemand.service
# Remove Ubuntu APT spamming
install_deb_chroot "${DEB_STORAGE}/${image_artifacts_debs["fake_ubuntu_advantage_tools"]}"
declare -g -A image_artifacts_debs
install_deb_chroot "${DEB_STORAGE}/${image_artifacts_debs["fake-ubuntu-advantage-tools"]}"
truncate --size=0 "${SDCARD}"/etc/apt/apt.conf.d/20apt-esm-hook.conf
;;