Skip to content

Commit

Permalink
Adding new feature REPOSITORY_INSTALL (#1933)
Browse files Browse the repository at this point in the history
* Rework packages install that they can be installed from repository instead of local compile. Handy for making releases.
* Don't build ATF if you don't build u-boot
  • Loading branch information
igorpecovnik committed May 10, 2020
1 parent e57aaf6 commit 26d377c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 45 deletions.
4 changes: 4 additions & 0 deletions config/templates/config-example.conf
Expand Up @@ -9,6 +9,10 @@ CLEAN_LEVEL="make,debs,oldcache" # comma-separated list of clean targets: "make"
# "cache" = delete "./output/cache", "sources" = delete "./sources"
# "oldcache" = remove old cached rootfs except for the newest 8 files

REPOSITORY_INSTALL="" # comma-separated list of core modules which will be installed from repository
# "u-boot", "kernel", "bsp", "armbian-config", "armbian-firmware"
# leave empty to build from sources or use local cache

DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8

# advanced
Expand Down
2 changes: 1 addition & 1 deletion lib/build-all-ng.sh
Expand Up @@ -278,7 +278,7 @@ function build_all()

display_alert "Building ${n}."
(build_main) &
sleep $(( ( RANDOM % 10 ) + 10 ))
# sleep $(( ( RANDOM % 10 ) + 10 ))

# create BSP for all boards
elif [[ "${BSP_BUILD}" == yes ]]; then
Expand Down
1 change: 1 addition & 0 deletions lib/configuration.sh
Expand Up @@ -23,6 +23,7 @@ EXIT_PATCHING_ERROR="" # exit patching if failed
cd ${SRC}
ROOTFSCACHE_VERSION=24
CHROOT_CACHE_VERSION=7
cd ${SRC}
BUILD_REPOSITORY_URL=$(git remote get-url $(git remote 2>/dev/null) 2>/dev/null)
BUILD_REPOSITORY_COMMIT=$(git describe --match=d_e_a_d_b_e_e_f --always --dirty 2>/dev/null)
ROOTFS_CACHE_MAX=42 # max number of rootfs cache, older ones will be cleaned up
Expand Down
93 changes: 73 additions & 20 deletions lib/distributions.sh
Expand Up @@ -195,45 +195,98 @@ install_common()
ff02::2 ip6-allrouters
EOF

# install kernel and u-boot packages
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb"
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb"

# install u-boot
if [[ "${REPOSITORY_INSTALL}" != *u-boot* ]]; then
UBOOT_VER=$(dpkg --info "${DEB_STORAGE}/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb" | grep Descr | awk '{print $(NF)}')
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb"
else
UBOOT_VER=$(chroot "${SDCARD}" /bin/bash -c "apt-cache --names-only search ^linux-u-boot-${BOARD}-${BRANCH} | awk '{print \$(NF)}'")
display_alert "Installing from repository" "linux-u-boot-${BOARD}-${BRANCH} $UBOOT_VER"
chroot "${SDCARD}" /bin/bash -c "apt-get -y -qq install linux-u-boot-${BOARD}-${BRANCH}" >> "${DEST}"/debug/install.log 2>&1
# we need package later, move to output, apt-get must be here, apt deletes file
mv ${SDCARD}/var/cache/apt/archives/linux-u-boot-${BOARD}-${BRANCH}*_${ARCH}.deb ${DEB_STORAGE}
fi

if [[ $BUILD_DESKTOP == yes ]]; then
install_deb_chroot "${DEB_STORAGE}/$RELEASE/armbian-${RELEASE}-desktop_${REVISION}_all.deb"
# install display manager and PACKAGE_LIST_DESKTOP_FULL packages if enabled per board
desktop_postinstall
# install kernel
if [[ "${REPOSITORY_INSTALL}" != *kernel* ]]; then
VER=$(dpkg --info "${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" | grep Descr | awk '{print $(NF)}')
VER="${VER/-$LINUXFAMILY/}"
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb"
if [[ -f ${DEB_STORAGE}/${CHOSEN_KERNEL/image/dtb}_${REVISION}_${ARCH}.deb ]]; then
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KERNEL/image/dtb}_${REVISION}_${ARCH}.deb"
fi
if [[ $INSTALL_HEADERS == yes ]]; then
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KERNEL/image/headers}_${REVISION}_${ARCH}.deb"
fi
else
VER=$(chroot "${SDCARD}" /bin/bash -c "apt-cache --names-only search ^linux-image-${BRANCH}-${LINUXFAMILY} | awk '{print \$(NF)}'")
VER="${VER/-$LINUXFAMILY/}"
display_alert "Installing from repository" "linux-image-${BRANCH}-${LINUXFAMILY} $VER"
chroot "${SDCARD}" /bin/bash -c "apt -y -qq install linux-image-${BRANCH}-${LINUXFAMILY}" >> "${DEST}"/debug/install.log 2>&1
display_alert "Installing from repository" "linux-dtb-${BRANCH}-${LINUXFAMILY}"
chroot "${SDCARD}" /bin/bash -c "apt -y -qq install linux-dtb-${BRANCH}-${LINUXFAMILY}" >> "${DEST}"/debug/install.log 2>&1
if [[ $INSTALL_HEADERS == yes ]]; then
display_alert "Installing from repository" "armbian-headers"
chroot "${SDCARD}" /bin/bash -c "apt-get -y -qq install linux-headers-${BRANCH}-${LINUXFAMILY}" >> "${DEST}"/debug/install.log 2>&1
fi
fi

if [[ $INSTALL_HEADERS == yes ]]; then
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KERNEL/image/headers}_${REVISION}_${ARCH}.deb"
# install board support packages
if [[ "${REPOSITORY_INSTALL}" != *bsp* ]]; then
install_deb_chroot "${DEB_STORAGE}/$RELEASE/${CHOSEN_ROOTFS}_${REVISION}_${ARCH}.deb" >> "${DEST}"/debug/install.log 2>&1
else
display_alert "Installing from repository" "${CHOSEN_ROOTFS}"
chroot "${SDCARD}" /bin/bash -c "apt -y -qq install ${CHOSEN_ROOTFS}" >> "${DEST}"/debug/install.log 2>&1
fi

if [[ $BUILD_MINIMAL != yes ]]; then
install_deb_chroot "${DEB_STORAGE}/armbian-config_${REVISION}_all.deb"
# install armbian-desktop
if [[ "${REPOSITORY_INSTALL}" != *armbian-desktop* ]]; then
if [[ $BUILD_DESKTOP == yes ]]; then
install_deb_chroot "${DEB_STORAGE}/$RELEASE/armbian-${RELEASE}-desktop_${REVISION}_all.deb"
# install display manager and PACKAGE_LIST_DESKTOP_FULL packages if enabled per board
desktop_postinstall
fi
else
if [[ $BUILD_DESKTOP == yes ]]; then
display_alert "Installing from repository" "armbian-${RELEASE}-desktop"
chroot "${SDCARD}" /bin/bash -c "apt-get -y -qq install armbian-${RELEASE}-desktop" >> "${DEST}"/debug/install.log 2>&1
# install display manager and PACKAGE_LIST_DESKTOP_FULL packages if enabled per board
desktop_postinstall
fi
fi

if [[ -f ${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb ]]; then
install_deb_chroot "${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb"
# install armbian-firmware
if [[ "${REPOSITORY_INSTALL}" != *armbian-firmware* ]]; then
if [[ -f ${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb ]]; then
install_deb_chroot "${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb"
fi
else
display_alert "Installing from repository" "armbian-firmware"
chroot "${SDCARD}" /bin/bash -c "apt -y -qq install armbian-firmware" >> "${DEST}"/debug/install.log 2>&1
fi

if [[ -f ${DEB_STORAGE}/${CHOSEN_KERNEL/image/dtb}_${REVISION}_${ARCH}.deb ]]; then
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KERNEL/image/dtb}_${REVISION}_${ARCH}.deb"
# install armbian-config
if [[ "${REPOSITORY_INSTALL}" != *armbian-config* ]]; then
if [[ $BUILD_MINIMAL != yes ]]; then
install_deb_chroot "${DEB_STORAGE}/armbian-config_${REVISION}_all.deb"
fi
else
if [[ $BUILD_MINIMAL != yes ]]; then
display_alert "Installing from repository" "armbian-config"
chroot "${SDCARD}" /bin/bash -c "apt -y -qq install armbian-config" >> "${DEST}"/debug/install.log 2>&1
fi
fi

# install kernel sources
if [[ -f ${DEB_STORAGE}/${CHOSEN_KSRC}_${REVISION}_all.deb && $INSTALL_KSRC == yes ]]; then
install_deb_chroot "${DEB_STORAGE}/${CHOSEN_KSRC}_${REVISION}_all.deb"
fi

# install wireguard tools
if [[ $WIREGUARD == yes ]]; then
# install wireguard tools
chroot "${SDCARD}" /bin/bash -c "apt -y -qq install wireguard-tools --no-install-recommends" >> "${DEST}"/debug/install.log 2>&1
fi

# install board support package
install_deb_chroot "${DEB_STORAGE}/$RELEASE/${CHOSEN_ROOTFS}_${REVISION}_${ARCH}.deb" >> "${DEST}"/debug/install.log 2>&1

# freeze armbian packages
if [[ $BSPFREEZE == yes ]]; then
display_alert "Freezing Armbian packages" "$BOARD" "info"
Expand Down
56 changes: 32 additions & 24 deletions lib/main.sh
Expand Up @@ -26,11 +26,10 @@ umask 002
# destination
DEST=$SRC/output

# override stty size
[[ -n $COLUMNS ]] && stty cols $COLUMNS
[[ -n $LINES ]] && stty rows $LINES

if [[ $BUILD_ALL != "yes" ]]; then
# override stty size
[[ -n $COLUMNS ]] && stty cols $COLUMNS
[[ -n $LINES ]] && stty rows $LINES
TTY_X=$(($(stty size | awk '{print $2}')-6)) # determine terminal width
TTY_Y=$(($(stty size | awk '{print $1}')-6)) # determine terminal height
fi
Expand Down Expand Up @@ -420,39 +419,48 @@ for option in $(tr ',' ' ' <<< "$CLEAN_LEVEL"); do
[[ $option != sources ]] && cleaning "$option"
done

# Compile u-boot if packed .deb does not exist
if [[ ! -f ${DEB_STORAGE}/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
if [[ -n $ATFSOURCE ]]; then
# Compile u-boot if packed .deb does not exist or use the one from repository
if [[ ! -f "${DEB_STORAGE}"/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then

if [[ -n "${ATFSOURCE}" && "${REPOSITORY_INSTALL}" != *u-boot* ]]; then
compile_atf
fi
compile_uboot
[[ "${REPOSITORY_INSTALL}" != *u-boot* ]] && compile_uboot

fi

# Compile kernel if packed .deb does not exist
# Compile kernel if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then

KDEB_CHANGELOG_DIST=$RELEASE
compile_kernel
[[ "${REPOSITORY_INSTALL}" != *kernel* ]] && compile_kernel

fi

# Pack armbian-config and armbian-firmware
# Compile armbian-config if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/armbian-config_${REVISION}_all.deb ]]; then
compile_armbian-config

FULL=""
REPLACE="-full"
[[ ! -f $DEST/debs/armbian-firmware_${REVISION}_all.deb ]] && compile_firmware
FULL="-full"
REPLACE=""
[[ ! -f $DEST/debs/armbian-firmware${FULL}_${REVISION}_all.deb ]] && compile_firmware

[[ "${REPOSITORY_INSTALL}" != *armbian-config* ]] && compile_armbian-config

fi

overlayfs_wrapper "cleanup"
# Compile armbian-firmware if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb || ! -f $DEST/debs/armbian-firmware${FULL}_${REVISION}_all.deb ]]; then

if [[ "${REPOSITORY_INSTALL}" != *armbian-firmware* ]]; then

# extract kernel version from .deb package
VER=$(dpkg --info "${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" | grep Descr | awk '{print $(NF)}')
VER="${VER/-$LINUXFAMILY/}"
FULL=""
REPLACE="-full"
compile_firmware
FULL="-full"
REPLACE=""
compile_firmware

fi

UBOOT_VER=$(dpkg --info "${DEB_STORAGE}/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb" | grep Descr | awk '{print $(NF)}')
fi

overlayfs_wrapper "cleanup"

# create board support package
[[ -n $RELEASE && ! -f ${DEB_STORAGE}/$RELEASE/${CHOSEN_ROOTFS}_${REVISION}_${ARCH}.deb ]] && create_board_package
Expand Down

0 comments on commit 26d377c

Please sign in to comment.