bsp-cli/distro-agnostic: introduce KEEP_ORIGINAL_OS_RELEASE=yes so Debian/Ubuntu PRETTY_NAME is left unchanged in /etc/os-release

- useful when downstream software wants exact Debian OS
This commit is contained in:
Ricardo Pardini
2023-04-06 16:20:17 +02:00
parent c30a907e47
commit 0d276c93e9
3 changed files with 42 additions and 16 deletions

View File

@@ -43,6 +43,7 @@ function artifact_armbian-bsp-cli_prepare_version() {
"${bootscript_info[has_bootscript]}"
"${bootscript_info[has_extlinux]}"
"${UBOOT_FW_ENV}" # not included in bootscript
"${KEEP_ORIGINAL_OS_RELEASE:-"no"}" # /etc/os-release
"${BOARDFAMILY}" # /etc/armbian-release
"${LINUXFAMILY}" # /etc/armbian-release
"${IMAGE_TYPE}" # /etc/armbian-release

View File

@@ -108,6 +108,13 @@ function compile_armbian-bsp-cli() {
postinst_functions+=(board_side_bsp_cli_postinst_update_uboot_bootscript)
fi
if [[ "${KEEP_ORIGINAL_OS_RELEASE:-"no"}" != "yes" ]]; then
# add to postinst, to change PRETTY_NAME to Armbian's
postinst_functions+=(board_side_bsp_cli_postinst_os_release_armbian)
else
display_alert "bsp-cli: KEEP_ORIGINAL_OS_RELEASE" "Keeping original /etc/os-release's PRETTY_NAME as original" "info"
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"))
@@ -321,10 +328,11 @@ 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"
# Read release value from lsb-release and set it separately as ARMBIAN_PRETTY_NAME
# More is done, actually taking over PRETTY_NAME, in separate board_side_bsp_cli_postinst_os_release_armbian()
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 "ARMBIAN_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
@@ -345,6 +353,17 @@ function board_side_bsp_cli_postinst_base() {
fi
}
function board_side_bsp_cli_postinst_os_release_armbian() {
# 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
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

View File

@@ -148,7 +148,13 @@ function install_distribution_agnostic() {
# change console welcome text
echo -e "${VENDOR} ${IMAGE_VERSION:-"${REVISION}"} ${RELEASE^} \\l \n" > "${SDCARD}"/etc/issue
echo "${VENDOR} ${IMAGE_VERSION:-"${REVISION}"} ${RELEASE^}" > "${SDCARD}"/etc/issue.net
# Keep, or change to Armbian's PRETTY_NAME in /etc/os-release (this is also done in the bsp-cli postinst)
if [[ "${KEEP_ORIGINAL_OS_RELEASE:-"no"}" != "yes" ]]; then
sed -i "s/^PRETTY_NAME=.*/PRETTY_NAME=\"${VENDOR} ${IMAGE_VERSION:-"${REVISION}"} ${RELEASE^}\"/" "${SDCARD}"/etc/os-release
else
display_alert "distro-agnostic: KEEP_ORIGINAL_OS_RELEASE" "Keeping original /etc/os-release's PRETTY_NAME as original" "warn"
fi
# enable few bash aliases enabled in Ubuntu by default to make it even
sed "s/#alias ll='ls -l'/alias ll='ls -l'/" -i "${SDCARD}"/etc/skel/.bashrc