From 310495ddf18920ed0e989fd3f46601e917789472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Thu, 6 Jan 2022 11:50:24 +0100 Subject: [PATCH] Refactor armbian-bsp-cli package creation (#3378) * Refactor armbian-bsp-cli package creation - added general distro status for all in separate file inside BSP - remove branch and distro specifics * Looking for prebuild pack * Small fixes --- lib/distributions.sh | 2 +- lib/general.sh | 2 +- lib/main.sh | 2 +- lib/makeboarddeb.sh | 35 ++++++++++--------- .../etc/update-motd.d/10-armbian-header | 6 ++-- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/distributions.sh b/lib/distributions.sh index 82d7923e74..785f266d78 100644 --- a/lib/distributions.sh +++ b/lib/distributions.sh @@ -327,7 +327,7 @@ POST_INSTALL_KERNEL_DEBS # install board support packages if [[ "${REPOSITORY_INSTALL}" != *bsp* ]]; then - install_deb_chroot "${DEB_STORAGE}/$RELEASE/${BSP_CLI_PACKAGE_FULLNAME}.deb" | tee "${DEST}"/${LOG_SUBPATH}/install.log 2>&1 + install_deb_chroot "${DEB_STORAGE}/${BSP_CLI_PACKAGE_FULLNAME}.deb" | tee "${DEST}"/${LOG_SUBPATH}/install.log 2>&1 else install_deb_chroot "${CHOSEN_ROOTFS}" "remote" fi diff --git a/lib/general.sh b/lib/general.sh index 7e79abaa73..41413c442c 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -640,7 +640,7 @@ fingerprint_image() { cat <<-EOF > "${1}" -------------------------------------------------------------------------------- - Title: ${VENDOR} $REVISION ${BOARD^} $DISTRIBUTION $RELEASE $BRANCH + Title: ${VENDOR} $REVISION ${BOARD^} $BRANCH Kernel: Linux $VER Build date: $(date +'%d.%m.%Y') Maintainer: $MAINTAINER <$MAINTAINERMAIL> diff --git a/lib/main.sh b/lib/main.sh index 4db70312a7..70e963e716 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -517,7 +517,7 @@ overlayfs_wrapper "cleanup" # create board support package -[[ -n "${RELEASE}" && ! -f "${DEB_STORAGE}/$RELEASE/${BSP_CLI_PACKAGE_FULLNAME}.deb" && "${REPOSITORY_INSTALL}" != *armbian-bsp-cli* ]] && create_board_package +[[ -n "${RELEASE}" && ! -f "${DEB_STORAGE}/${BSP_CLI_PACKAGE_FULLNAME}.deb" && "${REPOSITORY_INSTALL}" != *armbian-bsp-cli* ]] && create_board_package diff --git a/lib/makeboarddeb.sh b/lib/makeboarddeb.sh index f14eadfa6c..15747b1be6 100644 --- a/lib/makeboarddeb.sh +++ b/lib/makeboarddeb.sh @@ -23,7 +23,7 @@ create_board_package() bsptempdir=$(mktemp -d) chmod 700 ${bsptempdir} trap "rm -rf \"${bsptempdir}\" ; exit 0" 0 1 2 3 15 - local destination=${bsptempdir}/${RELEASE}/${BSP_CLI_PACKAGE_FULLNAME} + local destination=${bsptempdir}/${BSP_CLI_PACKAGE_FULLNAME} mkdir -p "${destination}"/DEBIAN cd $destination @@ -76,7 +76,7 @@ create_board_package() 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~) Recommends: bsdutils, parted, util-linux, toilet - Description: Tweaks for Armbian $RELEASE on $BOARD + Description: Armbian board support files for $BOARD EOF # set up pre install script @@ -246,10 +246,15 @@ fi mv /usr/lib/chromium-browser/master_preferences.dpkg-dist /usr/lib/chromium-browser/master_preferences fi - 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 + # 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 >/dev/null 2>&1 exit 0 EOF @@ -270,8 +275,12 @@ fi activate update-initramfs EOF - # read distribution support status - set_distribution_status + # copy distribution support status + 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 cat <<-EOF > "${destination}"/etc/armbian-release @@ -281,8 +290,6 @@ fi BOARDFAMILY=${BOARDFAMILY} BUILD_REPOSITORY_URL=${BUILD_REPOSITORY_URL} BUILD_REPOSITORY_COMMIT=${BUILD_REPOSITORY_COMMIT} - DISTRIBUTION_CODENAME=${RELEASE} - DISTRIBUTION_STATUS=${DISTRIBUTION_STATUS} VERSION=$REVISION LINUXFAMILY=$LINUXFAMILY ARCH=$ARCHITECTURE @@ -292,12 +299,6 @@ fi KERNEL_IMAGE_TYPE=$KERNEL_IMAGE_TYPE EOF - if [[ $BUILD_DESKTOP == yes ]]; then - cat <<-EOF >> "${destination}"/etc/armbian-release - DESKTOP=$DESKTOP_ENVIRONMENT - EOF - fi - # 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 @@ -318,8 +319,8 @@ POST_FAMILY_TWEAKS_BSP # create board DEB file fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${destination}" "${destination}.deb" >> "${DEST}"/${LOG_SUBPATH}/output.log 2>&1 - mkdir -p "${DEB_STORAGE}/${RELEASE}/" - rsync --remove-source-files -rq "${destination}.deb" "${DEB_STORAGE}/${RELEASE}/" + mkdir -p "${DEB_STORAGE}/" + rsync --remove-source-files -rq "${destination}.deb" "${DEB_STORAGE}/" # cleanup rm -rf ${bsptempdir} diff --git a/packages/bsp/common/etc/update-motd.d/10-armbian-header b/packages/bsp/common/etc/update-motd.d/10-armbian-header index e5fa4d4d83..8dde67186d 100755 --- a/packages/bsp/common/etc/update-motd.d/10-armbian-header +++ b/packages/bsp/common/etc/update-motd.d/10-armbian-header @@ -12,14 +12,16 @@ THIS_SCRIPT="header" MOTD_DISABLE="" -. /etc/armbian-release - +[[ -f /etc/armbian-release ]] && . /etc/armbian-release +[[ -f /etc/armbian-distribution-status ]] && . /etc/armbian-distribution-status +[[ -f /etc/lsb-release && -f /etc/armbian-distribution-status ]] && DISTRIBUTION_CODENAME=$(cat /etc/lsb-release | grep CODENAME | cut -d"=" -f2) && DISTRIBUTION_STATUS=$(cat /etc/armbian-distribution-status | grep $DISTRIBUTION_CODENAME | cut -d"=" -f2) [[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd for f in $MOTD_DISABLE; do [[ $f == $THIS_SCRIPT ]] && exit 0 done + KERNELID=$(uname -r) # Odroid N2 exception