run shellfmt on all of lib

This commit is contained in:
Ricardo Pardini
2022-10-08 13:17:30 +02:00
parent 76dac6f428
commit 85c8cbf15d
45 changed files with 1723 additions and 1829 deletions

View File

@@ -13,26 +13,26 @@
# daily beta build contains date in subrevision
#if [[ $BETA == yes && -z $SUBREVISION ]]; then SUBREVISION="."$(date --date="tomorrow" +"%j"); fi
if [ -f $USERPATCHES_PATH/VERSION ]; then
REVISION=$(cat "${USERPATCHES_PATH}"/VERSION)"$SUBREVISION" # all boards have same revision
REVISION=$(cat "${USERPATCHES_PATH}"/VERSION)"$SUBREVISION" # all boards have same revision
else
REVISION=$(cat "${SRC}"/VERSION)"$SUBREVISION" # all boards have same revision
REVISION=$(cat "${SRC}"/VERSION)"$SUBREVISION" # all boards have same revision
fi
[[ -z $VENDOR ]] && VENDOR="Armbian"
[[ -z $ROOTPWD ]] && ROOTPWD="1234" # Must be changed @first login
[[ -z $MAINTAINER ]] && MAINTAINER="Igor Pecovnik" # deb signature
[[ -z $ROOTPWD ]] && ROOTPWD="1234" # Must be changed @first login
[[ -z $MAINTAINER ]] && MAINTAINER="Igor Pecovnik" # deb signature
[[ -z $MAINTAINERMAIL ]] && MAINTAINERMAIL="igor.pecovnik@****l.com" # deb signature
[[ -z $DEB_COMPRESS ]] && DEB_COMPRESS="xz" # compress .debs with XZ by default. Use 'none' for faster/larger builds
TZDATA=$(cat /etc/timezone) # Timezone for target is taken from host or defined here.
USEALLCORES=yes # Use all CPU cores for compiling
[[ -z $DEB_COMPRESS ]] && DEB_COMPRESS="xz" # compress .debs with XZ by default. Use 'none' for faster/larger builds
TZDATA=$(cat /etc/timezone) # Timezone for target is taken from host or defined here.
USEALLCORES=yes # Use all CPU cores for compiling
HOSTRELEASE=$(cat /etc/os-release | grep VERSION_CODENAME | cut -d"=" -f2)
[[ -z $HOSTRELEASE ]] && HOSTRELEASE=$(cut -d'/' -f1 /etc/debian_version)
[[ -z $EXIT_PATCHING_ERROR ]] && EXIT_PATCHING_ERROR="" # exit patching if failed
[[ -z $HOST ]] && HOST="$BOARD" # set hostname to the board
[[ -z $HOST ]] && HOST="$BOARD" # set hostname to the board
cd "${SRC}" || exit
[[ -z "${CHROOT_CACHE_VERSION}" ]] && CHROOT_CACHE_VERSION=7
BUILD_REPOSITORY_URL=$(improved_git remote get-url $(improved_git remote 2>/dev/null | grep origin) 2>/dev/null)
BUILD_REPOSITORY_COMMIT=$(improved_git describe --match=d_e_a_d_b_e_e_f --always --dirty 2>/dev/null)
BUILD_REPOSITORY_URL=$(improved_git remote get-url $(improved_git remote 2> /dev/null | grep origin) 2> /dev/null)
BUILD_REPOSITORY_COMMIT=$(improved_git describe --match=d_e_a_d_b_e_e_f --always --dirty 2> /dev/null)
ROOTFS_CACHE_MAX=200 # max number of rootfs cache, older ones will be cleaned up
if [[ $BETA == yes ]]; then
@@ -54,7 +54,6 @@ if [[ -n "${MAKE_FOLDERS}" ]]; then
fi
# TODO: fixed name can't be used for parallel image building
ROOT_MAPPER="armbian-root"
@@ -87,8 +86,8 @@ case $REGIONAL_MIRROR in
[[ -z $GITHUB_MIRROR ]] && GITHUB_MIRROR=gitclone
[[ -z $DOWNLOAD_MIRROR ]] && DOWNLOAD_MIRROR=china
;;
*)
;;
*) ;;
esac
# used by multiple sources - reduce code duplication
@@ -167,7 +166,7 @@ ATF_COMPILE=yes
# single ext4 partition is the default and preferred configuration
#BOOTFS_TYPE=''
[[ ! -f ${SRC}/config/sources/families/$LINUXFAMILY.conf ]] && \
[[ ! -f ${SRC}/config/sources/families/$LINUXFAMILY.conf ]] &&
exit_with_error "Sources configuration not found" "$LINUXFAMILY"
source "${SRC}/config/sources/families/${LINUXFAMILY}.conf"
@@ -212,7 +211,7 @@ show_menu() {
#echo "Provided options : " "${@:4}"
#echo "TTY X: $TTY_X Y: $TTY_Y"
dialog --stdout --title "$provided_title" --backtitle "${provided_backtitle}" \
--menu "$provided_menuname" $TTY_Y $TTY_X $((TTY_Y - 8)) "${@:4}"
--menu "$provided_menuname" $TTY_Y $TTY_X $((TTY_Y - 8)) "${@:4}"
}
# Myy : FIXME Factorize
@@ -221,7 +220,7 @@ show_select_menu() {
provided_backtitle=$2
provided_menuname=$3
dialog --stdout --title "${provided_title}" --backtitle "${provided_backtitle}" \
--checklist "${provided_menuname}" $TTY_Y $TTY_X $((TTY_Y - 8)) "${@:4}"
--checklist "${provided_menuname}" $TTY_Y $TTY_X $((TTY_Y - 8)) "${@:4}"
}
# Myy : Once we got a list of selected groups, parse the PACKAGE_LIST inside configuration.sh
@@ -371,12 +370,13 @@ if [[ $BUILD_DESKTOP == "yes" && -z ${DESKTOP_APPGROUPS_SELECTED+x} ]]; then
options+=("${appgroup}" "${appgroup^}" off)
done
DESKTOP_APPGROUPS_SELECTED=$(\
DESKTOP_APPGROUPS_SELECTED=$(
show_select_menu \
"Choose desktop softwares to add" \
"$backtitle" \
"Select which kind of softwares you'd like to add to your build" \
"${options[@]}")
"Choose desktop softwares to add" \
"$backtitle" \
"Select which kind of softwares you'd like to add to your build" \
"${options[@]}"
)
unset options
fi
@@ -398,8 +398,8 @@ aggregate_content() {
echo -e "${filepath/"$SRC"\//} yes" >> "${LOG_OUTPUT_FILE}"
aggregated_content+=$(cat "${filepath}")
aggregated_content+="${separator}"
# else
# echo -e "${filepath/"$SRC"\//} no\n" >> "${LOG_OUTPUT_FILE}"
# else
# echo -e "${filepath/"$SRC"\//} no\n" >> "${LOG_OUTPUT_FILE}"
fi
done
@@ -425,9 +425,9 @@ BOOTCONFIG_VAR_NAME=BOOTCONFIG_${BRANCH^^}
[[ -z $KERNELPATCHDIR ]] && KERNELPATCHDIR="$LINUXFAMILY-$BRANCH"
if [[ "$RELEASE" =~ ^(focal|jammy)$ ]]; then
DISTRIBUTION="Ubuntu"
else
DISTRIBUTION="Debian"
DISTRIBUTION="Ubuntu"
else
DISTRIBUTION="Debian"
fi
CLI_CONFIG_PATH="${SRC}/config/cli/${RELEASE}"
@@ -582,24 +582,24 @@ unset LOG_OUTPUT_FILE
DEBIAN_MIRROR='deb.debian.org/debian'
DEBIAN_SECURTY='security.debian.org/'
[[ "${ARCH}" == "amd64" ]] \
&& UBUNTU_MIRROR='archive.ubuntu.com/ubuntu/' \
|| UBUNTU_MIRROR='ports.ubuntu.com/'
[[ "${ARCH}" == "amd64" ]] &&
UBUNTU_MIRROR='archive.ubuntu.com/ubuntu/' ||
UBUNTU_MIRROR='ports.ubuntu.com/'
if [[ $DOWNLOAD_MIRROR == "china" ]] ; then
if [[ $DOWNLOAD_MIRROR == "china" ]]; then
DEBIAN_MIRROR='mirrors.tuna.tsinghua.edu.cn/debian'
DEBIAN_SECURTY='mirrors.tuna.tsinghua.edu.cn/debian-security'
[[ "${ARCH}" == "amd64" ]] \
&& UBUNTU_MIRROR='mirrors.tuna.tsinghua.edu.cn/ubuntu/' \
|| UBUNTU_MIRROR='mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/'
[[ "${ARCH}" == "amd64" ]] &&
UBUNTU_MIRROR='mirrors.tuna.tsinghua.edu.cn/ubuntu/' ||
UBUNTU_MIRROR='mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/'
fi
if [[ $DOWNLOAD_MIRROR == "bfsu" ]] ; then
if [[ $DOWNLOAD_MIRROR == "bfsu" ]]; then
DEBIAN_MIRROR='mirrors.bfsu.edu.cn/debian'
DEBIAN_SECURTY='mirrors.bfsu.edu.cn/debian-security'
[[ "${ARCH}" == "amd64" ]] \
&& UBUNTU_MIRROR='mirrors.bfsu.edu.cn/ubuntu/' \
|| UBUNTU_MIRROR='mirrors.bfsu.edu.cn/ubuntu-ports/'
[[ "${ARCH}" == "amd64" ]] &&
UBUNTU_MIRROR='mirrors.bfsu.edu.cn/ubuntu/' ||
UBUNTU_MIRROR='mirrors.bfsu.edu.cn/ubuntu-ports/'
fi
[[ -z $DISABLE_IPV6 ]] && DISABLE_IPV6="true"
@@ -654,7 +654,6 @@ aggregate_all_desktop "packages.uninstall" " "
PACKAGE_LIST_UNINSTALL="$(cleanup_list aggregated_content)"
unset aggregated_content
if [[ -n $PACKAGE_LIST_RM ]]; then
display_alert "Package remove list ${PACKAGE_LIST_RM}"
# Turns out that \b can be tricked by dashes.
@@ -680,9 +679,8 @@ if [[ -n $PACKAGE_LIST_RM ]]; then
PACKAGE_MAIN_LIST="$(echo ${PACKAGE_MAIN_LIST})"
fi
LOG_OUTPUT_FILE="$SRC/output/${LOG_SUBPATH}/debootstrap-list.log"
echo -e "\nVariables after manual configuration" >>$LOG_OUTPUT_FILE
echo -e "\nVariables after manual configuration" >> $LOG_OUTPUT_FILE
show_checklist_variables "DEBOOTSTRAP_COMPONENTS DEBOOTSTRAP_LIST PACKAGE_LIST PACKAGE_MAIN_LIST"
unset LOG_OUTPUT_FILE
@@ -697,51 +695,51 @@ to confirm or change any packages.
POST_AGGREGATE_PACKAGES
# debug
cat <<-EOF >> "${DEST}"/${LOG_SUBPATH}/output.log
cat <<- EOF >> "${DEST}"/${LOG_SUBPATH}/output.log
## BUILD SCRIPT ENVIRONMENT
## BUILD SCRIPT ENVIRONMENT
Repository: $REPOSITORY_URL
Version: $REPOSITORY_COMMIT
Repository: $REPOSITORY_URL
Version: $REPOSITORY_COMMIT
Host OS: $HOSTRELEASE
Host arch: $(dpkg --print-architecture)
Host system: $(uname -a)
Virtualization type: $(systemd-detect-virt)
Host OS: $HOSTRELEASE
Host arch: $(dpkg --print-architecture)
Host system: $(uname -a)
Virtualization type: $(systemd-detect-virt)
## Build script directories
Build directory is located on:
$(findmnt -o TARGET,SOURCE,FSTYPE,AVAIL -T "${SRC}")
## Build script directories
Build directory is located on:
$(findmnt -o TARGET,SOURCE,FSTYPE,AVAIL -T "${SRC}")
Build directory permissions:
$(getfacl -p "${SRC}")
Build directory permissions:
$(getfacl -p "${SRC}")
Temp directory permissions:
$(getfacl -p "${SRC}"/.tmp 2> /dev/null)
Temp directory permissions:
$(getfacl -p "${SRC}"/.tmp 2> /dev/null)
## BUILD CONFIGURATION
## BUILD CONFIGURATION
Build target:
Board: $BOARD
Branch: $BRANCH
Minimal: $BUILD_MINIMAL
Desktop: $BUILD_DESKTOP
Desktop Environment: $DESKTOP_ENVIRONMENT
Software groups: $DESKTOP_APPGROUPS_SELECTED
Build target:
Board: $BOARD
Branch: $BRANCH
Minimal: $BUILD_MINIMAL
Desktop: $BUILD_DESKTOP
Desktop Environment: $DESKTOP_ENVIRONMENT
Software groups: $DESKTOP_APPGROUPS_SELECTED
Kernel configuration:
Repository: $KERNELSOURCE
Branch: $KERNELBRANCH
Config file: $LINUXCONFIG
Kernel configuration:
Repository: $KERNELSOURCE
Branch: $KERNELBRANCH
Config file: $LINUXCONFIG
U-boot configuration:
Repository: $BOOTSOURCE
Branch: $BOOTBRANCH
Config file: $BOOTCONFIG
U-boot configuration:
Repository: $BOOTSOURCE
Branch: $BOOTBRANCH
Config file: $BOOTCONFIG
Partitioning configuration: $IMAGE_PARTITION_TABLE offset: $OFFSET
Boot partition type: ${BOOTFS_TYPE:-(none)} ${BOOTSIZE:+"(${BOOTSIZE} MB)"}
Root partition type: $ROOTFS_TYPE ${FIXED_IMAGE_SIZE:+"(${FIXED_IMAGE_SIZE} MB)"}
Partitioning configuration: $IMAGE_PARTITION_TABLE offset: $OFFSET
Boot partition type: ${BOOTFS_TYPE:-(none)} ${BOOTSIZE:+"(${BOOTSIZE} MB)"}
Root partition type: $ROOTFS_TYPE ${FIXED_IMAGE_SIZE:+"(${FIXED_IMAGE_SIZE} MB)"}
CPU configuration: $CPUMIN - $CPUMAX with $GOVERNOR
CPU configuration: $CPUMIN - $CPUMAX with $GOVERNOR
EOF

View File

@@ -35,7 +35,7 @@ call_extension_method() {
# Then call the hooks, if they are defined.
for hook_name in "$@"; do
echo "-- Extension Method being called: ${hook_name}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "-- Extension Method being called: ${hook_name}" >> "${EXTENSION_MANAGER_LOG_FILE}"
# shellcheck disable=SC2086
[[ $(type -t ${hook_name}) == function ]] && { ${hook_name}; }
done
@@ -66,13 +66,13 @@ initialize_extension_manager() {
# Log destination.
export EXTENSION_MANAGER_LOG_FILE="${EXTENSION_MANAGER_TMP_DIR}/extensions.log"
echo -n "" >"${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt"
echo -n "" > "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt"
# globally initialize the extensions log.
echo "-- lib/extensions.sh included. logs will be below, followed by the debug generated by the initialize_extension_manager() function." >"${EXTENSION_MANAGER_LOG_FILE}"
echo "-- lib/extensions.sh included. logs will be below, followed by the debug generated by the initialize_extension_manager() function." > "${EXTENSION_MANAGER_LOG_FILE}"
# log whats happening.
echo "-- initialize_extension_manager() called." >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "-- initialize_extension_manager() called." >> "${EXTENSION_MANAGER_LOG_FILE}"
# this is the all-important separator.
local hook_extension_delimiter="__"
@@ -87,13 +87,13 @@ initialize_extension_manager() {
# initialize the cleanups file.
fragment_manager_cleanup_file="${SRC}"/.tmp/extension_function_cleanup.sh
echo "# cleanups: " >"${fragment_manager_cleanup_file}"
echo "# cleanups: " > "${fragment_manager_cleanup_file}"
local FUNCTION_SORT_OPTIONS="--general-numeric-sort --ignore-case" # --random-sort could be used to introduce chaos
local hook_point=""
# now loop over the hook_points.
for hook_point in ${all_hook_points}; do
echo "-- hook_point ${hook_point}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "-- hook_point ${hook_point}" >> "${EXTENSION_MANAGER_LOG_FILE}"
# check if the hook point is already defined as a function.
# that can happen for example with user_config(), that can be implemented itself directly by a userpatches config.
@@ -102,7 +102,7 @@ initialize_extension_manager() {
local existing_hook_point_function
existing_hook_point_function="$(compgen -A function | grep "^${hook_point}\$")"
if [[ "${existing_hook_point_function}" == "${hook_point}" ]]; then
echo "--- hook_point_functions (final sorted realnames): ${hook_point_functions}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "--- hook_point_functions (final sorted realnames): ${hook_point_functions}" >> "${EXTENSION_MANAGER_LOG_FILE}"
display_alert "Extension conflict" "function ${hook_point} already defined! ignoring functions: $(compgen -A function | grep "^${hook_point}${hook_extension_delimiter}")" "wrn"
continue
fi
@@ -125,7 +125,7 @@ initialize_extension_manager() {
# gather the real names of the functions (after the delimiter).
hook_point_functions_pre_sort="$(compgen -A function | grep "^${hook_point}${hook_extension_delimiter}" | awk -F "${hook_extension_delimiter}" '{print $2}' | xargs echo -n)"
echo "--- hook_point_functions_pre_sort: ${hook_point_functions_pre_sort}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "--- hook_point_functions_pre_sort: ${hook_point_functions_pre_sort}" >> "${EXTENSION_MANAGER_LOG_FILE}"
# add "500_" to the names of function that do NOT start with a number.
# keep a reference from the new names to the old names (we'll sort on the new, but invoke the old)
@@ -141,7 +141,7 @@ initialize_extension_manager() {
# actually sort the sort_id's...
# shellcheck disable=SC2086
hook_point_functions_sorted_by_sort_id="$(echo "${hook_point_functions_realname_to_sortname[*]}" | tr " " "\n" | LC_ALL=C sort ${FUNCTION_SORT_OPTIONS} | xargs echo -n)"
echo "--- hook_point_functions_sorted_by_sort_id: ${hook_point_functions_sorted_by_sort_id}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "--- hook_point_functions_sorted_by_sort_id: ${hook_point_functions_sorted_by_sort_id}" >> "${EXTENSION_MANAGER_LOG_FILE}"
# then map back to the real names, keeping the order..
hook_point_functions=""
@@ -150,7 +150,7 @@ initialize_extension_manager() {
done
# shellcheck disable=SC2086
hook_point_functions="$(echo -n ${hook_point_functions})"
echo "--- hook_point_functions (final sorted realnames): ${hook_point_functions}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "--- hook_point_functions (final sorted realnames): ${hook_point_functions}" >> "${EXTENSION_MANAGER_LOG_FILE}"
hook_point_functions_counter=0
hook_points_counter=$((hook_points_counter + 1))
@@ -167,13 +167,13 @@ initialize_extension_manager() {
done
common_function_vars="${common_function_vars} HOOK_POINT_TOTAL_FUNCS=\"${hook_point_functions_counter}\""
echo "-- hook_point: ${hook_point} will run ${hook_point_functions_counter} functions: ${hook_point_functions}" >>"${EXTENSION_MANAGER_LOG_FILE}"
echo "-- hook_point: ${hook_point} will run ${hook_point_functions_counter} functions: ${hook_point_functions}" >> "${EXTENSION_MANAGER_LOG_FILE}"
local temp_source_file_for_hook_point="${EXTENSION_MANAGER_TMP_DIR}/extension_function_definition.sh"
hook_point_functions_loop_counter=0
# prepare the cleanup for the function, so we can remove our mess at the end of the build.
cat <<-FUNCTION_CLEANUP_FOR_HOOK_POINT >>"${fragment_manager_cleanup_file}"
cat <<- FUNCTION_CLEANUP_FOR_HOOK_POINT >> "${fragment_manager_cleanup_file}"
unset ${hook_point}
FUNCTION_CLEANUP_FOR_HOOK_POINT
@@ -181,7 +181,7 @@ initialize_extension_manager() {
# theres a lot of opportunities here, but for now I keep it simple:
# - execute functions in the order defined by ${hook_point_functions} above
# - define call-specific environment variables, to help extension authors to write portable extensions (eg: EXTENSION_DIR)
cat <<-FUNCTION_DEFINITION_HEADER >"${temp_source_file_for_hook_point}"
cat <<- FUNCTION_DEFINITION_HEADER > "${temp_source_file_for_hook_point}"
${hook_point}() {
echo "*** Extension-managed hook starting '${hook_point}': will run ${hook_point_functions_counter} functions: '${hook_point_functions}'" >>"\${EXTENSION_MANAGER_LOG_FILE}"
FUNCTION_DEFINITION_HEADER
@@ -205,7 +205,7 @@ initialize_extension_manager() {
# output the call, passing arguments, and also logging the output to the extensions log.
# attention: don't pipe here (eg, capture output), otherwise hook function cant modify the environment (which is mostly the point)
# @TODO: better error handling. we have a good opportunity to 'set -e' here, and 'set +e' after, so that extension authors are encouraged to write error-free handling code
cat <<-FUNCTION_DEFINITION_CALLSITE >>"${temp_source_file_for_hook_point}"
cat <<- FUNCTION_DEFINITION_CALLSITE >> "${temp_source_file_for_hook_point}"
hook_point_function_trace_sources["${hook_point}${hook_extension_delimiter}${hook_point_function}"]="\${BASH_SOURCE[*]}"
hook_point_function_trace_lines["${hook_point}${hook_extension_delimiter}${hook_point_function}"]="\${BASH_LINENO[*]}"
[[ "\${DEBUG_EXTENSION_CALLS}" == "yes" ]] && display_alert "---> Extension Method ${hook_point}" "${hook_point_functions_loop_counter}/${hook_point_functions_counter} (ext:${EXTENSION:-built-in}) ${hook_point_function}" ""
@@ -215,7 +215,7 @@ initialize_extension_manager() {
FUNCTION_DEFINITION_CALLSITE
# output the cleanup for the implementation as well.
cat <<-FUNCTION_CLEANUP_FOR_HOOK_POINT_IMPLEMENTATION >>"${fragment_manager_cleanup_file}"
cat <<- FUNCTION_CLEANUP_FOR_HOOK_POINT_IMPLEMENTATION >> "${fragment_manager_cleanup_file}"
unset ${hook_point}${hook_extension_delimiter}${hook_point_function}
FUNCTION_CLEANUP_FOR_HOOK_POINT_IMPLEMENTATION
@@ -223,7 +223,7 @@ initialize_extension_manager() {
unset EXTENSION EXTENSION_DIR EXTENSION_FILE EXTENSION_ADDED_BY
done
cat <<-FUNCTION_DEFINITION_FOOTER >>"${temp_source_file_for_hook_point}"
cat <<- FUNCTION_DEFINITION_FOOTER >> "${temp_source_file_for_hook_point}"
echo "*** Extension-managed hook ending '${hook_point}': completed." >>"\${EXTENSION_MANAGER_LOG_FILE}"
} # end ${hook_point}() function
FUNCTION_DEFINITION_FOOTER
@@ -232,8 +232,8 @@ initialize_extension_manager() {
unset hook_point_functions hook_point_functions_sortname_to_realname hook_point_functions_realname_to_sortname
# log what was produced in our own debug logfile
cat "${temp_source_file_for_hook_point}" >>"${EXTENSION_MANAGER_LOG_FILE}"
cat "${fragment_manager_cleanup_file}" >>"${EXTENSION_MANAGER_LOG_FILE}"
cat "${temp_source_file_for_hook_point}" >> "${EXTENSION_MANAGER_LOG_FILE}"
cat "${fragment_manager_cleanup_file}" >> "${EXTENSION_MANAGER_LOG_FILE}"
# source the generated function.
# shellcheck disable=SC1090
@@ -268,7 +268,7 @@ run_after_build__999_finish_extension_manager() {
export defined_hook_point_functions hook_point_function_trace_sources
# eat our own dog food, pt2.
call_extension_method "extension_metadata_ready" <<'EXTENSION_METADATA_READY'
call_extension_method "extension_metadata_ready" << 'EXTENSION_METADATA_READY'
*meta-Meta time!*
Implement this hook to work with/on the meta-data made available by the extension manager.
Interesting stuff to process:
@@ -297,14 +297,14 @@ write_hook_point_metadata() {
local main_hook_point_name="$1"
[[ ! -d "${EXTENSION_MANAGER_TMP_DIR}" ]] && mkdir -p "${EXTENSION_MANAGER_TMP_DIR}"
cat - >"${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.orig.md" # Write the hook point documentation received via stdin to a tmp file for later processing.
cat - > "${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.orig.md" # Write the hook point documentation received via stdin to a tmp file for later processing.
shift
echo -n "$@" >"${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.compat" # log the 2nd+ arguments too (those are the alternative/compatibility names), separate file.
compgen -A export >"${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.exports" # capture the exported env vars.
compgen -A variable >"${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.vars" # capture all env vars.
echo -n "$@" > "${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.compat" # log the 2nd+ arguments too (those are the alternative/compatibility names), separate file.
compgen -A export > "${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.exports" # capture the exported env vars.
compgen -A variable > "${EXTENSION_MANAGER_TMP_DIR}/${main_hook_point_name}.vars" # capture all env vars.
# add to the list of hook points called, in order.
echo "${main_hook_point_name}" >>"${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt"
echo "${main_hook_point_name}" >> "${EXTENSION_MANAGER_TMP_DIR}/hook_point_calls.txt"
}
# Helper function, to get clean "stack traces" that do not include the hook/extension infrastructure code.
@@ -312,8 +312,8 @@ get_extension_hook_stracktrace() {
local sources_str="$1" # Give this ${BASH_SOURCE[*]} - expanded
local lines_str="$2" # And this # Give this ${BASH_LINENO[*]} - expanded
local sources lines index final_stack=""
IFS=' ' read -r -a sources <<<"${sources_str}"
IFS=' ' read -r -a lines <<<"${lines_str}"
IFS=' ' read -r -a sources <<< "${sources_str}"
IFS=' ' read -r -a lines <<< "${lines_str}"
for index in "${!sources[@]}"; do
local source="${sources[index]}" line="${lines[((index - 1))]}"
# skip extension infrastructure sources, these only pollute the trace and add no insight to users

View File

@@ -13,8 +13,7 @@
# unless you want to kill your /etc/fstab and share your rootfs on NFS
# without any access control
fel_prepare_host()
{
fel_prepare_host() {
# Start rpcbind for NFS if inside docker container
[ "$(systemd-detect-virt)" == 'docker' ] && service rpcbind start
@@ -27,8 +26,7 @@ fel_prepare_host()
exportfs -ra
}
fel_prepare_target()
{
fel_prepare_target() {
if [[ -f $USERPATCHES_PATH/fel-boot.cmd ]]; then
display_alert "Using custom boot script" "userpatches/fel-boot.cmd" "info"
cp "$USERPATCHES_PATH"/fel-boot.cmd "${FEL_ROOTFS}"/boot/boot.cmd
@@ -49,8 +47,7 @@ fel_prepare_target()
echo "tmpfs /tmp tmpfs defaults,nosuid 0 0" >> "${FEL_ROOTFS}"/etc/fstab
}
fel_load()
{
fel_load() {
# update each time in case boot/script.bin link was changed in multi-board images
local dtb_file
if [[ -n $FEL_DTB_FILE ]]; then

View File

@@ -1,5 +1,4 @@
create_board_package()
{
create_board_package() {
display_alert "Creating board support package for CLI" "$CHOSEN_ROOTFS" "info"
bsptempdir=$(mktemp -d)
@@ -43,201 +42,201 @@ create_board_package()
# (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}
Version: $REVISION
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
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~)
Recommends: bsdutils, parted, util-linux, toilet
Description: Armbian board support files for $BOARD
cat <<- EOF > "${destination}"/DEBIAN/control
Package: ${BSP_CLI_PACKAGE_NAME}
Version: $REVISION
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
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~)
Recommends: bsdutils, parted, util-linux, toilet
Description: Armbian board support files for $BOARD
EOF
# set up pre install script
cat <<-EOF > "${destination}"/DEBIAN/preinst
#!/bin/sh
cat <<- EOF > "${destination}"/DEBIAN/preinst
#!/bin/sh
# tell people to reboot at next login
[ "\$1" = "upgrade" ] && touch /var/run/.reboot_required
# tell people to reboot at next login
[ "\$1" = "upgrade" ] && touch /var/run/.reboot_required
# convert link to file
if [ -L "/etc/network/interfaces" ]; then
# 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
cp /etc/network/interfaces /etc/network/interfaces.tmp
rm /etc/network/interfaces
mv /etc/network/interfaces.tmp /etc/network/interfaces
fi
fi
# fixing ramdisk corruption when using lz4 compression method
sed -i "s/^COMPRESS=.*/COMPRESS=gzip/" /etc/initramfs-tools/initramfs.conf
# 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
# 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
# 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
# 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
EOF
chmod 755 "${destination}"/DEBIAN/preinst
# postrm script
cat <<-EOF > "${destination}"/DEBIAN/postrm
#!/bin/sh
if [ remove = "\$1" ] || [ abort-install = "\$1" ]; then
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
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
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
#
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
[ -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
# 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
sed -i "s/^ENABLED=.*/ENABLED=false/" /etc/default/armbian-ramlog
fi
fi
# fix boot delay "waiting for suspend/resume device"
if [ -f "/etc/initramfs-tools/initramfs.conf" ]; then
# 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
if ! grep --quiet "RESUME=none" /etc/initramfs-tools/initramfs.conf; then
echo "RESUME=none" >> /etc/initramfs-tools/initramfs.conf
fi
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
cat <<- EOF >> "${destination}"/DEBIAN/postinst
if [ true ]; then
# this package recreate boot scripts
EOF
# this package recreate boot scripts
EOF
else
cat <<-EOF >> "${destination}"/DEBIAN/postinst
if [ ! -f /boot/$bootscript_dst ]; then
cat <<- EOF >> "${destination}"/DEBIAN/postinst
if [ ! -f /boot/$bootscript_dst ]; then
# if boot script does not exits its recreated
EOF
# 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
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 --
# 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)
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
# 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
[ -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
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
[ ! -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 [ ! -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
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
# 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
# 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
@@ -252,32 +251,31 @@ fi
# trigger uInitrd creation after installation, to apply
# /etc/initramfs/post-update.d/99-uboot
cat <<-EOF > "${destination}"/DEBIAN/triggers
activate update-initramfs
cat <<- EOF > "${destination}"/DEBIAN/triggers
activate update-initramfs
EOF
# copy distribution support status
local releases=($(find ${SRC}/config/distributions -mindepth 1 -maxdepth 1 -type d))
for i in ${releases[@]}
do
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
# PLEASE DO NOT EDIT THIS FILE
BOARD=$BOARD
BOARD_NAME="$BOARD_NAME"
BOARDFAMILY=${BOARDFAMILY}
BUILD_REPOSITORY_URL=${BUILD_REPOSITORY_URL}
BUILD_REPOSITORY_COMMIT=${BUILD_REPOSITORY_COMMIT}
VERSION=$REVISION
LINUXFAMILY=$LINUXFAMILY
ARCH=$ARCHITECTURE
IMAGE_TYPE=$IMAGE_TYPE
BOARD_TYPE=$BOARD_TYPE
INITRD_ARCH=$INITRD_ARCH
KERNEL_IMAGE_TYPE=$KERNEL_IMAGE_TYPE
cat <<- EOF > "${destination}"/etc/armbian-release
# PLEASE DO NOT EDIT THIS FILE
BOARD=$BOARD
BOARD_NAME="$BOARD_NAME"
BOARDFAMILY=${BOARDFAMILY}
BUILD_REPOSITORY_URL=${BUILD_REPOSITORY_URL}
BUILD_REPOSITORY_COMMIT=${BUILD_REPOSITORY_COMMIT}
VERSION=$REVISION
LINUXFAMILY=$LINUXFAMILY
ARCH=$ARCHITECTURE
IMAGE_TYPE=$IMAGE_TYPE
BOARD_TYPE=$BOARD_TYPE
INITRD_ARCH=$INITRD_ARCH
KERNEL_IMAGE_TYPE=$KERNEL_IMAGE_TYPE
EOF
# this is required for NFS boot to prevent deconfiguring the network on shutdown
@@ -295,8 +293,8 @@ POST_FAMILY_TWEAKS_BSP
fingerprint_image "${destination}/etc/armbian.txt"
# fixing permissions (basic), reference: dh_fixperms
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'
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 -b -Z${DEB_COMPRESS} "${destination}" "${destination}.deb" >> "${DEST}"/${LOG_SUBPATH}/output.log 2>&1

View File

@@ -1,5 +1,4 @@
create_desktop_package ()
{
create_desktop_package() {
echo "Showing PACKAGE_LIST_DESKTOP before postprocessing" >> "${DEST}"/${LOG_SUBPATH}/output.log
# Use quotes to show leading and trailing spaces
@@ -10,14 +9,14 @@ create_desktop_package ()
DEBIAN_RECOMMENDS="${PACKAGE_LIST_DESKTOP#"${PACKAGE_LIST_DESKTOP%%[![:space:]]*}"}"
DEBIAN_RECOMMENDS="${DEBIAN_RECOMMENDS%"${DEBIAN_RECOMMENDS##*[![:space:]]}"}"
# Replace whitespace characters by commas
DEBIAN_RECOMMENDS=${DEBIAN_RECOMMENDS// /,};
DEBIAN_RECOMMENDS=${DEBIAN_RECOMMENDS// /,}
# Remove others 'spacing characters' (like tabs)
DEBIAN_RECOMMENDS=${DEBIAN_RECOMMENDS//[[:space:]]/}
echo "DEBIAN_RECOMMENDS : ${DEBIAN_RECOMMENDS}" >> "${DEST}"/${LOG_SUBPATH}/output.log
# Replace whitespace characters by commas
PACKAGE_LIST_PREDEPENDS=${PACKAGE_LIST_PREDEPENDS// /,};
PACKAGE_LIST_PREDEPENDS=${PACKAGE_LIST_PREDEPENDS// /,}
# Remove others 'spacing characters' (like tabs)
PACKAGE_LIST_PREDEPENDS=${PACKAGE_LIST_PREDEPENDS//[[:space:]]/}
@@ -30,19 +29,19 @@ create_desktop_package ()
echo "${PACKAGE_LIST_PREDEPENDS}" >> "${DEST}"/${LOG_SUBPATH}/output.log
# set up control file
cat <<-EOF > "${destination}"/DEBIAN/control
Package: ${CHOSEN_DESKTOP}
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Section: xorg
Priority: optional
Recommends: ${DEBIAN_RECOMMENDS//[:space:]+/,}, armbian-bsp-desktop
Provides: ${CHOSEN_DESKTOP}, armbian-${RELEASE}-desktop
Conflicts: gdm3
Pre-Depends: ${PACKAGE_LIST_PREDEPENDS//[:space:]+/,}
Description: Armbian desktop for ${DISTRIBUTION} ${RELEASE}
cat <<- EOF > "${destination}"/DEBIAN/control
Package: ${CHOSEN_DESKTOP}
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Section: xorg
Priority: optional
Recommends: ${DEBIAN_RECOMMENDS//[:space:]+/,}, armbian-bsp-desktop
Provides: ${CHOSEN_DESKTOP}, armbian-${RELEASE}-desktop
Conflicts: gdm3
Pre-Depends: ${PACKAGE_LIST_PREDEPENDS//[:space:]+/,}
Description: Armbian desktop for ${DISTRIBUTION} ${RELEASE}
EOF
# Recreating the DEBIAN/postinst file
@@ -73,8 +72,9 @@ create_desktop_package ()
display_alert "Building desktop package" "${CHOSEN_DESKTOP}_${REVISION}_all" "info"
mkdir -p "${DEB_STORAGE}/${RELEASE}"
cd "${destination}"; cd ..
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${destination}" "${DEB_STORAGE}/${RELEASE}/${CHOSEN_DESKTOP}_${REVISION}_all.deb" >/dev/null
cd "${destination}"
cd ..
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${destination}" "${DEB_STORAGE}/${RELEASE}/${CHOSEN_DESKTOP}_${REVISION}_all.deb" > /dev/null
# cleanup
rm -rf "${tmp_dir}"
@@ -83,8 +83,7 @@ create_desktop_package ()
}
create_bsp_desktop_package ()
{
create_bsp_desktop_package() {
display_alert "Creating board support package for desktop" "${package_name}" "info"
@@ -99,17 +98,17 @@ create_bsp_desktop_package ()
copy_all_packages_files_for "bsp-desktop"
# set up control file
cat <<-EOF > "${destination}"/DEBIAN/control
Package: armbian-bsp-desktop-${BOARD}
Version: $REVISION
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
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
cat <<- EOF > "${destination}"/DEBIAN/control
Package: armbian-bsp-desktop-${BOARD}
Version: $REVISION
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
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
EOF
# Recreating the DEBIAN/postinst file
@@ -135,8 +134,9 @@ create_bsp_desktop_package ()
[[ $? -ne 0 ]] && display_alert "prepare.sh exec error" "" "wrn"
mkdir -p "${DEB_STORAGE}/${RELEASE}"
cd "${destination}"; cd ..
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${destination}" "${DEB_STORAGE}/${RELEASE}/${package_name}.deb" >/dev/null
cd "${destination}"
cd ..
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${destination}" "${DEB_STORAGE}/${RELEASE}/${package_name}.deb" > /dev/null
# cleanup
rm -rf "${tmp_dir}"

View File

@@ -1,13 +1,10 @@
# copy_all_packages_files_for <folder> to package
#
copy_all_packages_files_for()
{
copy_all_packages_files_for() {
local package_name="${1}"
for package_src_dir in ${PACKAGES_SEARCH_ROOT_ABSOLUTE_DIRS};
do
for package_src_dir in ${PACKAGES_SEARCH_ROOT_ABSOLUTE_DIRS}; do
local package_dirpath="${package_src_dir}/${package_name}"
if [ -d "${package_dirpath}" ];
then
if [ -d "${package_dirpath}" ]; then
cp -r "${package_dirpath}/"* "${destination}/" 2> /dev/null
display_alert "Adding files from" "${package_dirpath}"
fi

View File

@@ -1,8 +1,10 @@
compile_atf()
{
compile_atf() {
if [[ $CLEAN_LEVEL == *make* ]]; then
display_alert "Cleaning" "$ATFSOURCEDIR" "info"
(cd "${SRC}/cache/sources/${ATFSOURCEDIR}"; make distclean > /dev/null 2>&1)
(
cd "${SRC}/cache/sources/${ATFSOURCEDIR}"
make distclean > /dev/null 2>&1
)
fi
if [[ $USE_OVERLAYFS == yes ]]; then
@@ -15,24 +17,24 @@ compile_atf()
display_alert "Compiling ATF" "" "info"
# build aarch64
if [[ $(dpkg --print-architecture) == amd64 ]]; then
# build aarch64
if [[ $(dpkg --print-architecture) == amd64 ]]; then
local toolchain
toolchain=$(find_toolchain "$ATF_COMPILER" "$ATF_USE_GCC")
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${ATF_COMPILER}gcc $ATF_USE_GCC"
local toolchain
toolchain=$(find_toolchain "$ATF_COMPILER" "$ATF_USE_GCC")
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${ATF_COMPILER}gcc $ATF_USE_GCC"
if [[ -n $ATF_TOOLCHAIN2 ]]; then
local toolchain2_type toolchain2_ver toolchain2
toolchain2_type=$(cut -d':' -f1 <<< "${ATF_TOOLCHAIN2}")
toolchain2_ver=$(cut -d':' -f2 <<< "${ATF_TOOLCHAIN2}")
toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver")
[[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver"
if [[ -n $ATF_TOOLCHAIN2 ]]; then
local toolchain2_type toolchain2_ver toolchain2
toolchain2_type=$(cut -d':' -f1 <<< "${ATF_TOOLCHAIN2}")
toolchain2_ver=$(cut -d':' -f2 <<< "${ATF_TOOLCHAIN2}")
toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver")
[[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver"
fi
# build aarch64
fi
# build aarch64
fi
display_alert "Compiler version" "${ATF_COMPILER}gcc $(eval env PATH="${toolchain}:${PATH}" "${ATF_COMPILER}gcc" -dumpversion)" "info"
local target_make target_patchdir target_files
@@ -50,10 +52,10 @@ compile_atf()
# Check: https://github.com/armbian/build/issues/1157
eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${toolchain2}:${PATH}" \
'make ENABLE_BACKTRACE="0" $target_make $CTHREADS \
CROSS_COMPILE="$CCACHE $ATF_COMPILER"' 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log \
CROSS_COMPILE="$CCACHE $ATF_COMPILER"' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling ATF..." $TTY_Y $TTY_X'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log
[[ ${PIPESTATUS[0]} -ne 0 ]] && exit_with_error "ATF compilation failed"

View File

@@ -1,5 +1,4 @@
compile_firmware()
{
compile_firmware() {
display_alert "Merging and packaging linux firmware" "@host" "info"
local firmwaretempdir plugin_dir
@@ -27,16 +26,16 @@ compile_firmware()
# set up control file
mkdir -p DEBIAN
cat <<-END > DEBIAN/control
Package: armbian-firmware${FULL}
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Replaces: linux-firmware, firmware-brcm80211, firmware-ralink, firmware-samsung, firmware-realtek, armbian-firmware${REPLACE}
Section: kernel
Priority: optional
Description: Linux firmware${FULL}
cat <<- END > DEBIAN/control
Package: armbian-firmware${FULL}
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Replaces: linux-firmware, firmware-brcm80211, firmware-ralink, firmware-samsung, firmware-realtek, armbian-firmware${REPLACE}
Section: kernel
Priority: optional
Description: Linux firmware${FULL}
END
cd "${firmwaretempdir}" || exit
@@ -51,8 +50,7 @@ compile_firmware()
rm -rf "${firmwaretempdir}"
}
compile_armbian-zsh()
{
compile_armbian-zsh() {
local tmp_dir armbian_zsh_dir
tmp_dir=$(mktemp -d)
@@ -67,32 +65,32 @@ compile_armbian-zsh()
mkdir -p "${tmp_dir}/${armbian_zsh_dir}"/{DEBIAN,etc/skel/,etc/oh-my-zsh/,/etc/skel/.oh-my-zsh/cache}
# set up control file
cat <<-END > "${tmp_dir}/${armbian_zsh_dir}"/DEBIAN/control
Package: armbian-zsh
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Depends: zsh, tmux
Section: utils
Priority: optional
Description: Armbian improved ZShell
cat <<- END > "${tmp_dir}/${armbian_zsh_dir}"/DEBIAN/control
Package: armbian-zsh
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Depends: zsh, tmux
Section: utils
Priority: optional
Description: Armbian improved ZShell
END
# set up post install script
cat <<-END > "${tmp_dir}/${armbian_zsh_dir}"/DEBIAN/postinst
#!/bin/sh
cat <<- END > "${tmp_dir}/${armbian_zsh_dir}"/DEBIAN/postinst
#!/bin/sh
# copy cache directory if not there yet
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$6"/.oh-my-zsh"}' /etc/passwd | xargs -i sh -c 'test ! -d {} && cp -R --attributes-only /etc/skel/.oh-my-zsh {}'
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$6"/.zshrc"}' /etc/passwd | xargs -i sh -c 'test ! -f {} && cp -R /etc/skel/.zshrc {}'
# copy cache directory if not there yet
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$6"/.oh-my-zsh"}' /etc/passwd | xargs -i sh -c 'test ! -d {} && cp -R --attributes-only /etc/skel/.oh-my-zsh {}'
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$6"/.zshrc"}' /etc/passwd | xargs -i sh -c 'test ! -f {} && cp -R /etc/skel/.zshrc {}'
# fix owner permissions in home directory
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$1":"\$3" "\$6"/.oh-my-zsh"}' /etc/passwd | xargs -n2 chown -R
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$1":"\$3" "\$6"/.zshrc"}' /etc/passwd | xargs -n2 chown -R
# fix owner permissions in home directory
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$1":"\$3" "\$6"/.oh-my-zsh"}' /etc/passwd | xargs -n2 chown -R
awk -F'[:]' '{if (\$3 >= 1000 && \$3 != 65534 || \$3 == 0) print ""\$1":"\$3" "\$6"/.zshrc"}' /etc/passwd | xargs -n2 chown -R
# add support for bash profile
! grep emulate /etc/zsh/zprofile >/dev/null && echo "emulate sh -c 'source /etc/profile'" >> /etc/zsh/zprofile
exit 0
# add support for bash profile
! grep emulate /etc/zsh/zprofile >/dev/null && echo "emulate sh -c 'source /etc/profile'" >> /etc/zsh/zprofile
exit 0
END
cp -R "${SRC}"/cache/sources/oh-my-zsh "${tmp_dir}/${armbian_zsh_dir}"/etc/
@@ -124,8 +122,7 @@ compile_armbian-zsh()
}
compile_armbian-config()
{
compile_armbian-config() {
local tmp_dir armbian_config_dir
tmp_dir=$(mktemp -d)
@@ -141,19 +138,19 @@ compile_armbian-config()
mkdir -p "${tmp_dir}/${armbian_config_dir}"/{DEBIAN,usr/bin/,usr/sbin/,usr/lib/armbian-config/}
# set up control file
cat <<-END > "${tmp_dir}/${armbian_config_dir}"/DEBIAN/control
Package: armbian-config
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Replaces: armbian-bsp, neofetch
Depends: bash, iperf3, psmisc, curl, bc, expect, dialog, pv, zip, \
debconf-utils, unzip, build-essential, html2text, html2text, dirmngr, software-properties-common, debconf, jq
Recommends: armbian-bsp
Suggests: libpam-google-authenticator, qrencode, network-manager, sunxi-tools
Section: utils
Priority: optional
Description: Armbian configuration utility
cat <<- END > "${tmp_dir}/${armbian_config_dir}"/DEBIAN/control
Package: armbian-config
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Replaces: armbian-bsp, neofetch
Depends: bash, iperf3, psmisc, curl, bc, expect, dialog, pv, zip, \
debconf-utils, unzip, build-essential, html2text, html2text, dirmngr, software-properties-common, debconf, jq
Recommends: armbian-bsp
Suggests: libpam-google-authenticator, qrencode, network-manager, sunxi-tools
Section: utils
Priority: optional
Description: Armbian configuration utility
END
install -m 755 "${SRC}"/cache/sources/neofetch/neofetch "${tmp_dir}/${armbian_config_dir}"/usr/bin/neofetch
@@ -172,13 +169,12 @@ compile_armbian-config()
ln -sf /usr/sbin/armbian-config "${tmp_dir}/${armbian_config_dir}"/usr/bin/armbian-config
ln -sf /usr/sbin/softy "${tmp_dir}/${armbian_config_dir}"/usr/bin/softy
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${tmp_dir}/${armbian_config_dir}" >/dev/null
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${tmp_dir}/${armbian_config_dir}" > /dev/null
rsync --remove-source-files -rq "${tmp_dir}/${armbian_config_dir}.deb" "${DEB_STORAGE}/"
rm -rf "${tmp_dir}"
}
compile_xilinx_bootgen()
{
compile_xilinx_bootgen() {
# Source code checkout
(fetch_from_repo "$GITHUB_SOURCE/Xilinx/bootgen.git" "xilinx-bootgen" "branch:master")
@@ -186,20 +182,19 @@ compile_xilinx_bootgen()
# Compile and install only if git commit hash changed
# need to check if /usr/local/bin/bootgen to detect new Docker containers with old cached sources
if [[ ! -f .commit_id || $(improved_git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/bootgen ]]; then
if [[ ! -f .commit_id || $(improved_git rev-parse @ 2> /dev/null) != $(< .commit_id) || ! -f /usr/local/bin/bootgen ]]; then
display_alert "Compiling" "xilinx-bootgen" "info"
make -s clean >/dev/null
make -s -j$(nproc) bootgen >/dev/null
make -s clean > /dev/null
make -s -j$(nproc) bootgen > /dev/null
mkdir -p /usr/local/bin/
install bootgen /usr/local/bin >/dev/null 2>&1
improved_git rev-parse @ 2>/dev/null > .commit_id
install bootgen /usr/local/bin > /dev/null 2>&1
improved_git rev-parse @ 2> /dev/null > .commit_id
fi
popd
}
compile_plymouth-theme-armbian()
{
compile_plymouth-theme-armbian() {
local tmp_dir work_dir
tmp_dir=$(mktemp -d)
@@ -211,15 +206,15 @@ compile_plymouth-theme-armbian()
mkdir -p "${tmp_dir}/${plymouth_theme_armbian_dir}"/{DEBIAN,usr/share/plymouth/themes/armbian}
# set up control file
cat <<-END > "${tmp_dir}/${plymouth_theme_armbian_dir}"/DEBIAN/control
Package: armbian-plymouth-theme
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Depends: plymouth, plymouth-themes
Section: universe/x11
Priority: optional
Description: boot animation, logger and I/O multiplexer - armbian theme
cat <<- END > "${tmp_dir}/${plymouth_theme_armbian_dir}"/DEBIAN/control
Package: armbian-plymouth-theme
Version: $REVISION
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Depends: plymouth, plymouth-themes
Section: universe/x11
Priority: optional
Description: boot animation, logger and I/O multiplexer - armbian theme
END
cp "${SRC}"/packages/plymouth-theme-armbian/debian/{postinst,prerm,postrm} \
@@ -247,7 +242,7 @@ compile_plymouth-theme-armbian()
cp "${SRC}"/packages/plymouth-theme-armbian/armbian.plymouth \
"${tmp_dir}/${plymouth_theme_armbian_dir}"/usr/share/plymouth/themes/armbian/
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${tmp_dir}/${plymouth_theme_armbian_dir}" >/dev/null
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${tmp_dir}/${plymouth_theme_armbian_dir}" > /dev/null
rsync --remove-source-files -rq "${tmp_dir}/${plymouth_theme_armbian_dir}.deb" "${DEB_STORAGE}/"
rm -rf "${tmp_dir}"
}

View File

@@ -1,5 +1,4 @@
create_linux-source_package ()
{
create_linux-source_package() {
ts=$(date +%s)
local sources_pkg_dir tmp_src_dir
tmp_src_dir=$(mktemp -d)
@@ -13,22 +12,22 @@ create_linux-source_package ()
xz < .config > "${sources_pkg_dir}/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz"
display_alert "Compressing sources for the linux-source package"
tar cp --directory="$kerneldir" --exclude='.git' --owner=root . \
| pv -p -b -r -s "$(du -sb "$kerneldir" --exclude=='.git' | cut -f1)" \
| pixz -4 > "${sources_pkg_dir}/usr/src/linux-source-${version}-${LINUXFAMILY}.tar.xz"
tar cp --directory="$kerneldir" --exclude='.git' --owner=root . |
pv -p -b -r -s "$(du -sb "$kerneldir" --exclude=='.git' | cut -f1)" |
pixz -4 > "${sources_pkg_dir}/usr/src/linux-source-${version}-${LINUXFAMILY}.tar.xz"
cp COPYING "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}/LICENSE"
cat <<-EOF > "${sources_pkg_dir}"/DEBIAN/control
Package: linux-source-${version}-${BRANCH}-${LINUXFAMILY}
Version: ${version}-${BRANCH}-${LINUXFAMILY}+${REVISION}
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Section: kernel
Priority: optional
Depends: binutils, coreutils
Provides: linux-source, linux-source-${version}-${LINUXFAMILY}
Recommends: gcc, make
Description: This package provides the source code for the Linux kernel $version
cat <<- EOF > "${sources_pkg_dir}"/DEBIAN/control
Package: linux-source-${version}-${BRANCH}-${LINUXFAMILY}
Version: ${version}-${BRANCH}-${LINUXFAMILY}+${REVISION}
Architecture: all
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Section: kernel
Priority: optional
Depends: binutils, coreutils
Provides: linux-source, linux-source-${version}-${LINUXFAMILY}
Recommends: gcc, make
Description: This package provides the source code for the Linux kernel $version
EOF
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} -z0 "${sources_pkg_dir}" "${sources_pkg_dir}.deb"

View File

@@ -1,8 +1,10 @@
compile_kernel()
{
compile_kernel() {
if [[ $CLEAN_LEVEL == *make* ]]; then
display_alert "Cleaning" "$LINUXSOURCEDIR" "info"
(cd "${SRC}/cache/sources/${LINUXSOURCEDIR}"; make ARCH="${ARCHITECTURE}" clean >/dev/null 2>&1)
(
cd "${SRC}/cache/sources/${LINUXSOURCEDIR}"
make ARCH="${ARCHITECTURE}" clean > /dev/null 2>&1
)
fi
if [[ $USE_OVERLAYFS == yes ]]; then
@@ -80,7 +82,6 @@ Before any olddefconfig any Kconfig make is called.
A good place to customize the .config directly.
CUSTOM_KERNEL_CONFIG
# hack for OdroidXU4. Copy firmare files
if [[ $BOARD == odroidxu4 ]]; then
mkdir -p "${kerneldir}/firmware/edid"
@@ -175,14 +176,14 @@ CUSTOM_KERNEL_CONFIG
# store git hash to the file and create a change log
HASHTARGET="${SRC}/cache/hash"$([[ ${BETA} == yes ]] && echo "-beta")"/linux-image-${BRANCH}-${LINUXFAMILY}"
OLDHASHTARGET=$(head -1 "${HASHTARGET}.githash" 2>/dev/null)
OLDHASHTARGET=$(head -1 "${HASHTARGET}.githash" 2> /dev/null)
# check if OLDHASHTARGET commit exists otherwise use oldest
if [[ -z ${KERNEL_VERSION_LEVEL} ]]; then
git -C ${kerneldir} cat-file -t ${OLDHASHTARGET} >/dev/null 2>&1
if [[ -z ${KERNEL_VERSION_LEVEL} ]]; then
git -C ${kerneldir} cat-file -t ${OLDHASHTARGET} > /dev/null 2>&1
[[ $? -ne 0 ]] && OLDHASHTARGET=$(git -C ${kerneldir} show HEAD~199 --pretty=format:"%H" --no-patch)
else
git -C ${kerneldir} cat-file -t ${OLDHASHTARGET} >/dev/null 2>&1
git -C ${kerneldir} cat-file -t ${OLDHASHTARGET} > /dev/null 2>&1
[[ $? -ne 0 ]] && OLDHASHTARGET=$(git -C ${kerneldir} rev-list --max-parents=0 HEAD)
fi

View File

@@ -1,5 +1,4 @@
compilation_prepare()
{
compilation_prepare() {
# Packaging patch for modern kernels should be one for all.
# Currently we have it per kernel family since we can't have one
@@ -8,8 +7,7 @@ compilation_prepare()
if linux-version compare "${version}" ge 5.10; then
if test -d ${kerneldir}/debian
then
if test -d ${kerneldir}/debian; then
rm -rf ${kerneldir}/debian/*
fi
sed -i -e '
@@ -23,12 +21,12 @@ compilation_prepare()
chmod 755 ${kerneldir}/scripts/package/{builddeb,mkdebian}
elif linux-version compare "${version}" ge 5.8.17 \
&& linux-version compare "${version}" le 5.9 \
|| linux-version compare "${version}" ge 5.9.2; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-5.8-9.y.patch" "applying"
elif linux-version compare "${version}" ge 5.8.17 &&
linux-version compare "${version}" le 5.9 ||
linux-version compare "${version}" ge 5.9.2; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-5.8-9.y.patch" "applying"
elif linux-version compare "${version}" ge 5.6; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
@@ -39,35 +37,35 @@ compilation_prepare()
process_patch_file "${SRC}/patch/misc/general-packaging-5.3.y.patch" "applying"
fi
if [[ "${version}" == "4.19."* ]] && [[ "$LINUXFAMILY" == sunxi* || "$LINUXFAMILY" == meson64 || \
"$LINUXFAMILY" == mvebu64 || "$LINUXFAMILY" == mt7623 || "$LINUXFAMILY" == mvebu ]]; then
if [[ "${version}" == "4.19."* ]] && [[ "$LINUXFAMILY" == sunxi* || "$LINUXFAMILY" == meson64 ||
"$LINUXFAMILY" == mvebu64 || "$LINUXFAMILY" == mt7623 || "$LINUXFAMILY" == mvebu ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.19.y.patch" "applying"
fi
if [[ "${version}" == "4.19."* ]] && [[ "$LINUXFAMILY" == rk35xx ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.19.y-rk35xx.patch" "applying"
fi
if [[ "${version}" == "4.19."* ]] && [[ "$LINUXFAMILY" == rk35xx ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.19.y-rk35xx.patch" "applying"
fi
if [[ "${version}" == "4.14."* ]] && [[ "$LINUXFAMILY" == s5p6818 || "$LINUXFAMILY" == mvebu64 || \
"$LINUXFAMILY" == imx7d || "$LINUXFAMILY" == odroidxu4 || "$LINUXFAMILY" == mvebu ]]; then
if [[ "${version}" == "4.14."* ]] && [[ "$LINUXFAMILY" == s5p6818 || "$LINUXFAMILY" == mvebu64 ||
"$LINUXFAMILY" == imx7d || "$LINUXFAMILY" == odroidxu4 || "$LINUXFAMILY" == mvebu ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.14.y.patch" "applying"
fi
if [[ "${version}" == "4.4."* || "${version}" == "4.9."* ]] && \
[[ "$LINUXFAMILY" == rockpis || "$LINUXFAMILY" == rk3399 ]]; then
if [[ "${version}" == "4.4."* || "${version}" == "4.9."* ]] &&
[[ "$LINUXFAMILY" == rockpis || "$LINUXFAMILY" == rk3399 ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.4.y-rk3399.patch" "applying"
fi
if [[ "${version}" == "4.4."* ]] && \
[[ "$LINUXFAMILY" == rockchip64 || "$LINUXFAMILY" == media* ]]; then
if [[ "${version}" == "4.4."* ]] &&
[[ "$LINUXFAMILY" == rockchip64 || "$LINUXFAMILY" == media* ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
if [[ $BOARD == nanopct4 ]]; then
@@ -78,10 +76,10 @@ compilation_prepare()
fi
if [[ "${version}" == "4.4."* ]] && [[ "$LINUXFAMILY" == rockchip || "$LINUXFAMILY" == rk322x ]]; then
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.4.y.patch" "applying"
fi
display_alert "Adjusting" "packaging" "info"
cd "$kerneldir" || exit
process_patch_file "${SRC}/patch/misc/general-packaging-4.4.y.patch" "applying"
fi
if [[ "${version}" == "4.9."* ]] && [[ "$LINUXFAMILY" == meson64 || "$LINUXFAMILY" == odroidc4 ]]; then
display_alert "Adjusting" "packaging" "info"
@@ -92,7 +90,7 @@ compilation_prepare()
# After the patches have been applied,
# check and add debian package compression if required.
#
if [ "$(awk '/dpkg --build/{print $1}' $kerneldir/scripts/package/builddeb)" == "dpkg" ];then
if [ "$(awk '/dpkg --build/{print $1}' $kerneldir/scripts/package/builddeb)" == "dpkg" ]; then
sed -i -e '
s/dpkg --build/dpkg-deb \${KDEB_COMPRESS:+-Z\$KDEB_COMPRESS} --build/
' "$kerneldir"/scripts/package/builddeb
@@ -109,8 +107,8 @@ compilation_prepare()
display_alert "Adding" "Kernel splash file" "info"
if linux-version compare "${version}" ge 5.19.6 \
|| ( linux-version compare "${version}" ge 5.15.64 && linux-version compare "${version}" lt 5.16 ) ; then
if linux-version compare "${version}" ge 5.19.6 ||
(linux-version compare "${version}" ge 5.15.64 && linux-version compare "${version}" lt 5.16); then
process_patch_file "${SRC}/patch/misc/0001-Revert-fbdev-fbcon-Properly-revert-changes-when-vc_r.patch" "applying"
fi
@@ -178,17 +176,17 @@ compilation_prepare()
aufstag=$(echo "${version}" | cut -f 1-2 -d ".")
# manual overrides
if linux-version compare "${version}" ge 5.10.82 && linux-version compare "${version}" le 5.11 ; then aufstag="5.10.82"; fi
if linux-version compare "${version}" ge 5.15.41 && linux-version compare "${version}" le 5.16 ; then aufstag="5.15.41"; fi
if linux-version compare "${version}" ge 5.17.3 && linux-version compare "${version}" le 5.18 ; then aufstag="5.17.3"; fi
if linux-version compare "${version}" ge 5.10.82 && linux-version compare "${version}" le 5.11; then aufstag="5.10.82"; fi
if linux-version compare "${version}" ge 5.15.41 && linux-version compare "${version}" le 5.16; then aufstag="5.15.41"; fi
if linux-version compare "${version}" ge 5.17.3 && linux-version compare "${version}" le 5.18; then aufstag="5.17.3"; fi
# check if Mr. Okajima already made a branch for this version
improved_git ls-remote --exit-code --heads $GITHUB_SOURCE/sfjro/aufs5-standalone "aufs${aufstag}" >/dev/null
improved_git ls-remote --exit-code --heads $GITHUB_SOURCE/sfjro/aufs5-standalone "aufs${aufstag}" > /dev/null
if [ "$?" -ne "0" ]; then
# then use rc branch
aufstag="5.x-rcN"
improved_git ls-remote --exit-code --heads $GITHUB_SOURCE/sfjro/aufs5-standalone "aufs${aufstag}" >/dev/null
improved_git ls-remote --exit-code --heads $GITHUB_SOURCE/sfjro/aufs5-standalone "aufs${aufstag}" > /dev/null
fi
if [ "$?" -eq "0" ]; then
@@ -207,9 +205,6 @@ compilation_prepare()
fi
fi
# WireGuard VPN for Linux 3.10 - 5.5
if linux-version compare "${version}" ge 3.10 && linux-version compare "${version}" le 5.5 && [ "${WIREGUARD}" == yes ]; then
@@ -223,23 +218,22 @@ compilation_prepare()
rm -rf "$kerneldir/net/wireguard"
cp -R "${SRC}/cache/sources/wireguard/${wirever#*:}/src/" "$kerneldir/net/wireguard"
sed -i "/^obj-\\\$(CONFIG_NETFILTER).*+=/a obj-\$(CONFIG_WIREGUARD) += wireguard/" \
"$kerneldir/net/Makefile"
"$kerneldir/net/Makefile"
sed -i "/^if INET\$/a source \"net/wireguard/Kconfig\"" \
"$kerneldir/net/Kconfig"
"$kerneldir/net/Kconfig"
# remove duplicates
[[ $(grep -c wireguard "$kerneldir/net/Makefile") -gt 1 ]] && \
sed -i '0,/wireguard/{/wireguard/d;}' "$kerneldir/net/Makefile"
[[ $(grep -c wireguard "$kerneldir/net/Kconfig") -gt 1 ]] && \
sed -i '0,/wireguard/{/wireguard/d;}' "$kerneldir/net/Kconfig"
[[ $(grep -c wireguard "$kerneldir/net/Makefile") -gt 1 ]] &&
sed -i '0,/wireguard/{/wireguard/d;}' "$kerneldir/net/Makefile"
[[ $(grep -c wireguard "$kerneldir/net/Kconfig") -gt 1 ]] &&
sed -i '0,/wireguard/{/wireguard/d;}' "$kerneldir/net/Kconfig"
# headers workaround
display_alert "Patching WireGuard" "Applying workaround for headers compilation" "info"
sed -i '/mkdir -p "$destdir"/a mkdir -p "$destdir"/net/wireguard; \
touch "$destdir"/net/wireguard/{Kconfig,Makefile} # workaround for Wireguard' \
"$kerneldir/scripts/package/builddeb"
"$kerneldir/scripts/package/builddeb"
fi
# Updated USB network drivers for RTL8152/RTL8153 based dongles that also support 2.5Gbs variants
if linux-version compare "${version}" ge 5.4 && linux-version compare "${version}" le 5.12 && [ $LINUXFAMILY != mvebu64 ] && [ $LINUXFAMILY != rk322x ] && [ $LINUXFAMILY != odroidxu4 ] && [ $EXTRAWIFI == yes ]; then
@@ -250,7 +244,7 @@ compilation_prepare()
display_alert "Adding" "Drivers for 2.5Gb RTL8152/RTL8153 USB dongles ${rtl8152ver}" "info"
fetch_from_repo "$GITHUB_SOURCE/igorpecovnik/realtek-r8152-linux" "rtl8152" "${rtl8152ver}" "yes"
cp -R "${SRC}/cache/sources/rtl8152/${rtl8152ver#*:}"/{r8152.c,compatibility.h} \
"$kerneldir/drivers/net/usb/"
"$kerneldir/drivers/net/usb/"
fi
@@ -268,27 +262,24 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8189es"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8189es/"
cp -R "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8189es"
"$kerneldir/drivers/net/wireless/rtl8189es"
# Makefile
cp "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8189es/Makefile"
"$kerneldir/drivers/net/wireless/rtl8189es/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8189es/${rtl8189esver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8189es/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8189es/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8189ES) += rtl8189es/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8189es\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
fi
# Wireless drivers for Realtek 8189FS chipsets
if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then
@@ -303,27 +294,24 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8189fs"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8189fs/"
cp -R "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8189fs"
"$kerneldir/drivers/net/wireless/rtl8189fs"
# Makefile
cp "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8189fs/Makefile"
"$kerneldir/drivers/net/wireless/rtl8189fs/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8189fs/${rtl8189fsver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8189fs/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8189fs/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8189FS) += rtl8189fs/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8189fs\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
fi
# Wireless drivers for Realtek 8192EU chipsets
if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then
@@ -338,27 +326,24 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8192eu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8192eu/"
cp -R "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8192eu"
"$kerneldir/drivers/net/wireless/rtl8192eu"
# Makefile
cp "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8192eu/Makefile"
"$kerneldir/drivers/net/wireless/rtl8192eu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8192eu/${rtl8192euver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8192eu/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8192eu/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8192EU) += rtl8192eu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8192eu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
fi
# Wireless drivers for Realtek 8811, 8812, 8814 and 8821 chipsets
if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then
@@ -373,31 +358,28 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8812au"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8812au/"
cp -R "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8812au"
"$kerneldir/drivers/net/wireless/rtl8812au"
# Makefile
cp "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8812au/Makefile"
"$kerneldir/drivers/net/wireless/rtl8812au/Makefile"
# Kconfig
cp "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8812au/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8812au/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_88XXAU) += rtl8812au/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8812au\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
# add support for 5.19.2
process_patch_file "${SRC}/patch/misc/wireless-rtl8812au-5.19.2.patch" "applying"
# add support for 5.19.2
process_patch_file "${SRC}/patch/misc/wireless-rtl8812au-5.19.2.patch" "applying"
fi
# Wireless drivers for Xradio XR819 chipsets
if linux-version compare "${version}" ge 4.19 && linux-version compare "${version}" le 5.19 && \
if linux-version compare "${version}" ge 4.19 && linux-version compare "${version}" le 5.19 &&
[[ "$LINUXFAMILY" == sunxi* ]] && [[ "$EXTRAWIFI" == yes ]]; then
display_alert "Adding" "Wireless drivers for Xradio XR819 chipsets" "info"
@@ -407,36 +389,33 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/xradio"
mkdir -p "$kerneldir/drivers/net/wireless/xradio/"
cp "${SRC}"/cache/sources/xradio/karabek_rebase/*.{h,c} \
"$kerneldir/drivers/net/wireless/xradio/"
"$kerneldir/drivers/net/wireless/xradio/"
# Makefile
cp "${SRC}/cache/sources/xradio/karabek_rebase/Makefile" \
"$kerneldir/drivers/net/wireless/xradio/Makefile"
"$kerneldir/drivers/net/wireless/xradio/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/xradio/karabek_rebase/Kconfig"
cp "${SRC}/cache/sources/xradio/karabek_rebase/Kconfig" \
"$kerneldir/drivers/net/wireless/xradio/Kconfig"
"$kerneldir/drivers/net/wireless/xradio/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_WLAN_VENDOR_XRADIO) += xradio/" \
>> "$kerneldir/drivers/net/wireless/Makefile"
>> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/xradio\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
# add support for K5.13+
process_patch_file "${SRC}/patch/misc/wireless-xradio-5.13.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-xradio-5.13.patch" "applying"
# add support for aarch64
if [[ $ARCH == arm64 ]]; then
process_patch_file "${SRC}/patch/misc/wireless-xradio-aarch64.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-xradio-aarch64.patch" "applying"
fi
fi
# Wireless drivers for Realtek RTL8811CU and RTL8821C chipsets
if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then
@@ -451,46 +430,43 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8811cu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8811cu/"
cp -R "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}"/{core,hal,include,os_dep,platform,rtl8821c.mk} \
"$kerneldir/drivers/net/wireless/rtl8811cu"
"$kerneldir/drivers/net/wireless/rtl8811cu"
# Makefile
cp "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8811cu/${rtl8811cuver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8811cu/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
# Address ARM related bug $GITHUB_SOURCE/aircrack-ng/rtl8812au/issues/233
sed -i "s/^CONFIG_MP_VHT_HW_TX_MODE.*/CONFIG_MP_VHT_HW_TX_MODE = n/" \
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
"$kerneldir/drivers/net/wireless/rtl8811cu/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8821CU) += rtl8811cu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8811cu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
# add support for 5.18.y
process_patch_file "${SRC}/patch/misc/wireless-rtl8821cu.patch" "applying"
# add support for 5.19.2
process_patch_file "${SRC}/patch/misc/wireless-rtl8811cu-5.19.2.patch" "applying"
process_patch_file "${SRC}/patch/misc/wireless-rtl8811cu-5.19.2.patch" "applying"
fi
# Wireless drivers for Realtek 8188EU 8188EUS and 8188ETV chipsets
if linux-version compare "${version}" ge 3.14 \
&& linux-version compare "${version}" lt 5.15 \
&& [ "$EXTRAWIFI" == yes ]; then
if linux-version compare "${version}" ge 3.14 &&
linux-version compare "${version}" lt 5.15 &&
[ "$EXTRAWIFI" == yes ]; then
# attach to specifics tag or branch
local rtl8188euver="branch:v5.7.6.1"
@@ -502,25 +478,25 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8188eu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8188eu/"
cp -R "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8188eu"
"$kerneldir/drivers/net/wireless/rtl8188eu"
# Makefile
cp "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8188eu/Makefile"
"$kerneldir/drivers/net/wireless/rtl8188eu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8188eu/${rtl8188euver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8188eu/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8188eu/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8188eu/Makefile"
"$kerneldir/drivers/net/wireless/rtl8188eu/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8188EU) += rtl8188eu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8188eu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8188eu.patch" "applying"
@@ -529,9 +505,6 @@ compilation_prepare()
fi
# Wireless drivers for Realtek 88x2bu chipsets
if linux-version compare "${version}" ge 5.0 && [ "$EXTRAWIFI" == yes ]; then
@@ -546,29 +519,28 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl88x2bu"
mkdir -p "$kerneldir/drivers/net/wireless/rtl88x2bu/"
cp -R "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}"/{core,hal,include,os_dep,platform,halmac.mk,rtl8822b.mk} \
"$kerneldir/drivers/net/wireless/rtl88x2bu"
"$kerneldir/drivers/net/wireless/rtl88x2bu"
# Makefile
cp "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl88x2bu/Makefile"
"$kerneldir/drivers/net/wireless/rtl88x2bu/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl88x2bu/Kconfig"
"$kerneldir/drivers/net/wireless/rtl88x2bu/Kconfig"
# Adjust path
sed -i 's/include $(src)\/rtl8822b.mk /include $(TopDIR)\/drivers\/net\/wireless\/rtl88x2bu\/rtl8822b.mk/' \
"$kerneldir/drivers/net/wireless/rtl88x2bu/Makefile"
"$kerneldir/drivers/net/wireless/rtl88x2bu/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8822BU) += rtl88x2bu/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl88x2bu\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
fi
# Wireless drivers for Realtek 88x2cs chipsets
if linux-version compare "${version}" ge 5.9 && [ "$EXTRAWIFI" == yes ]; then
@@ -583,35 +555,34 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl88x2cs"
mkdir -p "$kerneldir/drivers/net/wireless/rtl88x2cs/"
cp -R "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}"/{core,hal,include,os_dep,platform,halmac.mk,ifcfg-wlan0,rtl8822c.mk,runwpa,wlan0dhcp} \
"$kerneldir/drivers/net/wireless/rtl88x2cs"
"$kerneldir/drivers/net/wireless/rtl88x2cs"
# Makefile
cp "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl88x2cs/${rtl88x2csver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Kconfig"
"$kerneldir/drivers/net/wireless/rtl88x2cs/Kconfig"
# Adjust path
sed -i 's/include $(src)\/rtl8822c.mk/include $(TopDIR)\/drivers\/net\/wireless\/rtl88x2cs\/rtl8822c.mk/' \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
"$kerneldir/drivers/net/wireless/rtl88x2cs/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8822CS) += rtl88x2cs/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl88x2cs\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
echo "obj-\$(CONFIG_RTL8822CS) += rtl88x2cs/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl88x2cs\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
fi
# Bluetooth support for Realtek 8822CS (hci_ver 0x8) chipsets
# For sunxi, these two patches are applied in a series.
if linux-version compare "${version}" ge 5.11 && [[ "$LINUXFAMILY" != sunxi* ]] ; then
if linux-version compare "${version}" ge 5.11 && [[ "$LINUXFAMILY" != sunxi* ]]; then
display_alert "Adding" "Bluetooth support for Realtek 8822CS (hci_ver 0x8) chipsets" "info"
@@ -620,7 +591,6 @@ compilation_prepare()
fi
# Wireless drivers for Realtek 8723DS chipsets
if linux-version compare "${version}" ge 5.0 && [ "$EXTRAWIFI" == yes ]; then
@@ -635,33 +605,30 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8723ds"
mkdir -p "$kerneldir/drivers/net/wireless/rtl8723ds/"
cp -R "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}"/{core,hal,include,os_dep,platform} \
"$kerneldir/drivers/net/wireless/rtl8723ds"
"$kerneldir/drivers/net/wireless/rtl8723ds"
# Makefile
cp "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}/Makefile" \
"$kerneldir/drivers/net/wireless/rtl8723ds/Makefile"
"$kerneldir/drivers/net/wireless/rtl8723ds/Makefile"
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8723ds/${rtl8723dsver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8723ds/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8723ds/Kconfig"
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
"$kerneldir/drivers/net/wireless/rtl8723ds/Makefile"
"$kerneldir/drivers/net/wireless/rtl8723ds/Makefile"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8723DS) += rtl8723ds/" >> "$kerneldir/drivers/net/wireless/Makefile"
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8723ds\/Kconfig"' \
"$kerneldir/drivers/net/wireless/Kconfig"
"$kerneldir/drivers/net/wireless/Kconfig"
process_patch_file "${SRC}/patch/misc/wireless-rtl8723ds-5.19.2.patch" "applying"
fi
# Wireless drivers for Realtek 8723DU chipsets
if linux-version compare $version ge 5.0 && [ "$EXTRAWIFI" == yes ]; then
@@ -675,25 +642,24 @@ compilation_prepare()
rm -rf $kerneldir/drivers/net/wireless/rtl8723du
mkdir -p $kerneldir/drivers/net/wireless/rtl8723du/
cp -R ${SRC}/cache/sources/rtl8723du/${rtl8723duver#*:}/{core,hal,include,os_dep,platform} \
$kerneldir/drivers/net/wireless/rtl8723du
$kerneldir/drivers/net/wireless/rtl8723du
# Makefile
cp ${SRC}/cache/sources/rtl8723du/${rtl8723duver#*:}/Makefile \
$kerneldir/drivers/net/wireless/rtl8723du/Makefile
$kerneldir/drivers/net/wireless/rtl8723du/Makefile
# Disable debug
sed -i "s/^CONFIG_RTW_DEBUG.*/CONFIG_RTW_DEBUG = n/" \
$kerneldir/drivers/net/wireless/rtl8723du/Makefile
$kerneldir/drivers/net/wireless/rtl8723du/Makefile
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8723DU) += rtl8723du/" >> $kerneldir/drivers/net/wireless/Makefile
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8723du\/Kconfig"' \
$kerneldir/drivers/net/wireless/Kconfig
$kerneldir/drivers/net/wireless/Kconfig
process_patch_file "${SRC}/patch/misc/wireless-rtl8723du-5.19.2.patch" "applying"
fi
# Wireless drivers for Realtek 8822BS chipsets
if linux-version compare "${version}" ge 4.4 && linux-version compare "${version}" le 5.16 && [ "$EXTRAWIFI" == yes ]; then
@@ -707,21 +673,21 @@ compilation_prepare()
rm -rf "$kerneldir/drivers/net/wireless/rtl8822bs"
mkdir -p $kerneldir/drivers/net/wireless/rtl8822bs/
cp -R "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}"/{core,hal,include,os_dep,platform,bluetooth,getAP,rtl8822b.mk} \
$kerneldir/drivers/net/wireless/rtl8822bs
$kerneldir/drivers/net/wireless/rtl8822bs
# Makefile
cp "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}/Makefile" \
$kerneldir/drivers/net/wireless/rtl8822bs/Makefile
$kerneldir/drivers/net/wireless/rtl8822bs/Makefile
# Kconfig
sed -i 's/---help---/help/g' "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}/Kconfig"
cp "${SRC}/cache/sources/rtl8822bs/${rtl8822bsver#*:}/Kconfig" \
"$kerneldir/drivers/net/wireless/rtl8822bs/Kconfig"
"$kerneldir/drivers/net/wireless/rtl8822bs/Kconfig"
# Add to section Makefile
echo "obj-\$(CONFIG_RTL8822BS) += rtl8822bs/" >> $kerneldir/drivers/net/wireless/Makefile
sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8822bs\/Kconfig"' \
$kerneldir/drivers/net/wireless/Kconfig
$kerneldir/drivers/net/wireless/Kconfig
fi
@@ -737,25 +703,25 @@ compilation_prepare()
cd "$kerneldir" || exit
mkdir -p $kerneldir/fs/exfat/
cp -R "${SRC}/cache/sources/exfat/${exfatsver#*:}"/{*.c,*.h} \
$kerneldir/fs/exfat/
$kerneldir/fs/exfat/
# Add to section Makefile
echo "obj-\$(CONFIG_EXFAT_FS) += exfat/" >> $kerneldir/fs/Makefile
# Makefile
cat <<-EOF > "$kerneldir/fs/exfat/Makefile"
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Makefile for the linux exFAT filesystem support.
#
obj-\$(CONFIG_EXFAT_FS) += exfat.o
exfat-y := inode.o namei.o dir.o super.o fatent.o cache.o nls.o misc.o file.o balloc.o xattr.o
cat <<- EOF > "$kerneldir/fs/exfat/Makefile"
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Makefile for the linux exFAT filesystem support.
#
obj-\$(CONFIG_EXFAT_FS) += exfat.o
exfat-y := inode.o namei.o dir.o super.o fatent.o cache.o nls.o misc.o file.o balloc.o xattr.o
EOF
# Kconfig
sed -i '$i\source "fs\/exfat\/Kconfig"' $kerneldir/fs/Kconfig
sed -i '$i\source "fs\/exfat\/Kconfig"' $kerneldir/fs/Kconfig
cp "${SRC}/cache/sources/exfat/${exfatsver#*:}/Kconfig" \
"$kerneldir/fs/exfat/Kconfig"
"$kerneldir/fs/exfat/Kconfig"
fi

View File

@@ -17,8 +17,7 @@
# $SRC/patch/<dest>/<family>/branch_<branch>
# $SRC/patch/<dest>/<family>
#
advanced_patch()
{
advanced_patch() {
local dest=$1
local family=$2
local board=$3
@@ -39,7 +38,7 @@ advanced_patch()
"$SRC/patch/$dest/$family/board_${board}:[\e[32ml\e[0m][\e[35mb\e[0m]"
"$SRC/patch/$dest/$family/branch_${branch}:[\e[32ml\e[0m][\e[33mb\e[0m]"
"$SRC/patch/$dest/$family:[\e[32ml\e[0m][\e[32mc\e[0m]"
)
)
local links=()
# required for "for" command
@@ -81,8 +80,7 @@ advanced_patch()
# <file>: path to patch file
# <status>: additional status text
#
process_patch_file()
{
process_patch_file() {
local patch=$1
local status=$2
@@ -101,10 +99,8 @@ process_patch_file()
echo >> "${DEST}"/${LOG_SUBPATH}/patching.log
}
# apply_patch_series <target dir> <full path to series file>
apply_patch_series ()
{
apply_patch_series() {
local t_dir="${1}"
local series="${2}"
local bzdir="$(dirname $series)"
@@ -118,41 +114,39 @@ apply_patch_series ()
display_alert "skip [$(echo $skiplist | wc -w)] patches"
cd "${t_dir}" || exit 1
for p in $list
do
for p in $list; do
# Detect and remove files as '*.patch' which patch will create.
# So we need to delete the file before applying the patch if it exists.
lsdiff -s --strip=1 "$bzdir/$p" | \
awk '$0 ~ /^+.*patch$/{print $2}' | \
xargs -I % sh -c 'rm -f %'
lsdiff -s --strip=1 "$bzdir/$p" |
awk '$0 ~ /^+.*patch$/{print $2}' |
xargs -I % sh -c 'rm -f %'
patch --batch --silent --no-backup-if-mismatch -p1 -N < $bzdir/"$p" >>$err_pt 2>&1
patch --batch --silent --no-backup-if-mismatch -p1 -N < $bzdir/"$p" >> $err_pt 2>&1
flag=$?
case $flag in
0) printf "[\033[32m done \033[0m] %s\n" "${p}"
0)
printf "[\033[32m done \033[0m] %s\n" "${p}"
printf "[ done ] %s\n" "${p}" >> "${DEST}"/debug/patching.log
;;
1)
printf "[\033[33m FAILED \033[0m] %s\n" "${p}"
echo -e "[ FAILED ] For ${p} \t\tprocess exit [ $flag ]" >>"${DEST}"/debug/patching.log
cat $err_pt >>"${DEST}"/debug/patching.log
echo -e "[ FAILED ] For ${p} \t\tprocess exit [ $flag ]" >> "${DEST}"/debug/patching.log
cat $err_pt >> "${DEST}"/debug/patching.log
;;
2)
printf "[\033[31m Patch wrong \033[0m] %s\n" "${p}"
echo -e "Patch wrong ${p}\t\tprocess exit [ $flag ]" >>"${DEST}"/debug/patching.log
cat $err_pt >>"${DEST}"/debug/patching.log
echo -e "Patch wrong ${p}\t\tprocess exit [ $flag ]" >> "${DEST}"/debug/patching.log
cat $err_pt >> "${DEST}"/debug/patching.log
;;
esac
echo "" >$err_pt
echo "" > $err_pt
done
echo "" >>"${DEST}"/debug/patching.log
echo "" >> "${DEST}"/debug/patching.log
rm $err_pt
}
userpatch_create()
{
userpatch_create() {
# create commit to start from clean source
git add .
git -c user.name='Armbian User' -c user.email='user@example.org' commit -q -m "Cleaning working copy"
@@ -172,7 +166,7 @@ userpatch_create()
# prompt to alter source
display_alert "Make your changes in this directory:" "$(pwd)" "wrn"
display_alert "Press <Enter> after you are done" "waiting" "wrn"
read -r </dev/tty
read -r < /dev/tty
tput cuu1
git add .
# create patch out of changes

View File

@@ -1,9 +1,11 @@
compile_uboot()
{
compile_uboot() {
# not optimal, but extra cleaning before overlayfs_wrapper should keep sources directory clean
if [[ $CLEAN_LEVEL == *make* ]]; then
display_alert "Cleaning" "$BOOTSOURCEDIR" "info"
(cd "${SRC}/cache/sources/${BOOTSOURCEDIR}"; make clean > /dev/null 2>&1)
(
cd "${SRC}/cache/sources/${BOOTSOURCEDIR}"
make clean > /dev/null 2>&1
)
fi
if [[ $USE_OVERLAYFS == yes ]]; then
@@ -21,24 +23,24 @@ compile_uboot()
display_alert "Compiling u-boot" "$version" "info"
# build aarch64
if [[ $(dpkg --print-architecture) == amd64 ]]; then
# build aarch64
if [[ $(dpkg --print-architecture) == amd64 ]]; then
local toolchain
toolchain=$(find_toolchain "$UBOOT_COMPILER" "$UBOOT_USE_GCC")
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${UBOOT_COMPILER}gcc $UBOOT_USE_GCC"
local toolchain
toolchain=$(find_toolchain "$UBOOT_COMPILER" "$UBOOT_USE_GCC")
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${UBOOT_COMPILER}gcc $UBOOT_USE_GCC"
if [[ -n $UBOOT_TOOLCHAIN2 ]]; then
local toolchain2_type toolchain2_ver toolchain2
toolchain2_type=$(cut -d':' -f1 <<< "${UBOOT_TOOLCHAIN2}")
toolchain2_ver=$(cut -d':' -f2 <<< "${UBOOT_TOOLCHAIN2}")
toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver")
[[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver"
if [[ -n $UBOOT_TOOLCHAIN2 ]]; then
local toolchain2_type toolchain2_ver toolchain2
toolchain2_type=$(cut -d':' -f1 <<< "${UBOOT_TOOLCHAIN2}")
toolchain2_ver=$(cut -d':' -f2 <<< "${UBOOT_TOOLCHAIN2}")
toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver")
[[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver"
fi
# build aarch64
fi
# build aarch64
fi
display_alert "Compiler version" "${UBOOT_COMPILER}gcc $(eval env PATH="${toolchain}:${toolchain2}:${PATH}" "${UBOOT_COMPILER}gcc" -dumpversion)" "info"
[[ -n $toolchain2 ]] && display_alert "Additional compiler version" "${toolchain2_type}gcc $(eval env PATH="${toolchain}:${toolchain2}:${PATH}" "${toolchain2_type}gcc" -dumpversion)" "info"
@@ -63,7 +65,10 @@ compile_uboot()
if [[ $CLEAN_LEVEL == *make* ]]; then
display_alert "Cleaning" "$BOOTSOURCEDIR" "info"
(cd "${SRC}/cache/sources/${BOOTSOURCEDIR}"; make clean > /dev/null 2>&1)
(
cd "${SRC}/cache/sources/${BOOTSOURCEDIR}"
make clean > /dev/null 2>&1
)
fi
advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "$target_patchdir" "$BRANCH" "${LINUXFAMILY}-${BOARD}-${BRANCH}"
@@ -72,8 +77,8 @@ compile_uboot()
[[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot"
if [[ -n $ATFSOURCE ]]; then
cp -Rv "${atftempdir}"/*.bin . 2>/dev/null || \
cp -Rv "${atftempdir}"/*.elf . 2>/dev/null
cp -Rv "${atftempdir}"/*.bin . 2> /dev/null ||
cp -Rv "${atftempdir}"/*.elf . 2> /dev/null
[[ $? -ne 0 ]] && exit_with_error "ATF binary not found"
rm -rf "${atftempdir}"
fi
@@ -81,9 +86,9 @@ compile_uboot()
echo -e "\n\t== u-boot make $BOOTCONFIG ==\n" >> "${DEST}"/${LOG_SUBPATH}/compilation.log
eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${toolchain2}:${PATH}" \
'make $CTHREADS $BOOTCONFIG \
CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"' 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log \
CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/compilation.log'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log
# armbian specifics u-boot settings
[[ -f .config ]] && sed -i 's/CONFIG_LOCALVERSION=""/CONFIG_LOCALVERSION="-armbian"/g' .config
@@ -96,7 +101,7 @@ compile_uboot()
sed -i 's/^.*CONFIG_ENV_IS_IN_EXT4.*/CONFIG_ENV_IS_IN_EXT4=y/g' .config
sed -i 's/^.*CONFIG_ENV_IS_IN_MMC.*/# CONFIG_ENV_IS_IN_MMC is not set/g' .config
sed -i 's/^.*CONFIG_ENV_IS_NOWHERE.*/# CONFIG_ENV_IS_NOWHERE is not set/g' .config | echo \
"# CONFIG_ENV_IS_NOWHERE is not set" >> .config
"# CONFIG_ENV_IS_NOWHERE is not set" >> .config
echo 'CONFIG_ENV_EXT4_INTERFACE="mmc"' >> .config
echo 'CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"' >> .config
echo 'CONFIG_ENV_EXT4_FILE="/boot/boot.env"' >> .config
@@ -111,16 +116,16 @@ compile_uboot()
[[ -n $BOOTDELAY ]] && sed -i "s/^CONFIG_BOOTDELAY=.*/CONFIG_BOOTDELAY=${BOOTDELAY}/" .config || [[ -f .config ]] && echo "CONFIG_BOOTDELAY=${BOOTDELAY}" >> .config
# workaround when two compilers are needed
cross_compile="CROSS_COMPILE=$CCACHE $UBOOT_COMPILER";
[[ -n $UBOOT_TOOLCHAIN2 ]] && cross_compile="ARMBIAN=foe"; # empty parameter is not allowed
cross_compile="CROSS_COMPILE=$CCACHE $UBOOT_COMPILER"
[[ -n $UBOOT_TOOLCHAIN2 ]] && cross_compile="ARMBIAN=foe" # empty parameter is not allowed
echo -e "\n\t== u-boot make $target_make ==\n" >> "${DEST}"/${LOG_SUBPATH}/compilation.log
eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${toolchain2}:${PATH}" \
'make $target_make $CTHREADS \
"${cross_compile}"' 2>>"${DEST}"/${LOG_SUBPATH}/compilation.log \
"${cross_compile}"' \
${PROGRESS_LOG_TO_FILE:+' | tee -a "${DEST}"/${LOG_SUBPATH}/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." $TTY_Y $TTY_X'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} ';EVALPIPE=(${PIPESTATUS[@]})'
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} ';EVALPIPE=(${PIPESTATUS[@]})' 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log
[[ ${EVALPIPE[0]} -ne 0 ]] && exit_with_error "U-boot compilation failed"
@@ -144,50 +149,50 @@ compile_uboot()
# set up postinstall script
if [[ $BOARD == tinkerboard ]]; then
cat <<-EOF > "$uboottempdir/${uboot_name}/DEBIAN/postinst"
#!/bin/bash
source /usr/lib/u-boot/platform_install.sh
[[ \$DEVICE == /dev/null ]] && exit 0
if [[ -z \$DEVICE ]]; then
DEVICE="/dev/mmcblk0"
# proceed to other options.
[ ! -b \$DEVICE ] && DEVICE="/dev/mmcblk1"
[ ! -b \$DEVICE ] && DEVICE="/dev/mmcblk2"
fi
[[ \$(type -t setup_write_uboot_platform) == function ]] && setup_write_uboot_platform
if [[ -b \$DEVICE ]]; then
echo "Updating u-boot on \$DEVICE" >&2
write_uboot_platform \$DIR \$DEVICE
sync
else
echo "Device \$DEVICE does not exist, skipping" >&2
fi
exit 0
cat <<- EOF > "$uboottempdir/${uboot_name}/DEBIAN/postinst"
#!/bin/bash
source /usr/lib/u-boot/platform_install.sh
[[ \$DEVICE == /dev/null ]] && exit 0
if [[ -z \$DEVICE ]]; then
DEVICE="/dev/mmcblk0"
# proceed to other options.
[ ! -b \$DEVICE ] && DEVICE="/dev/mmcblk1"
[ ! -b \$DEVICE ] && DEVICE="/dev/mmcblk2"
fi
[[ \$(type -t setup_write_uboot_platform) == function ]] && setup_write_uboot_platform
if [[ -b \$DEVICE ]]; then
echo "Updating u-boot on \$DEVICE" >&2
write_uboot_platform \$DIR \$DEVICE
sync
else
echo "Device \$DEVICE does not exist, skipping" >&2
fi
exit 0
EOF
chmod 755 "$uboottempdir/${uboot_name}/DEBIAN/postinst"
fi
# declare -f on non-defined function does not do anything
cat <<-EOF > "$uboottempdir/${uboot_name}/usr/lib/u-boot/platform_install.sh"
DIR=/usr/lib/$uboot_name
$(declare -f write_uboot_platform)
$(declare -f write_uboot_platform_mtd)
$(declare -f setup_write_uboot_platform)
cat <<- EOF > "$uboottempdir/${uboot_name}/usr/lib/u-boot/platform_install.sh"
DIR=/usr/lib/$uboot_name
$(declare -f write_uboot_platform)
$(declare -f write_uboot_platform_mtd)
$(declare -f setup_write_uboot_platform)
EOF
# set up control file
cat <<-EOF > "$uboottempdir/${uboot_name}/DEBIAN/control"
Package: linux-u-boot-${BOARD}-${BRANCH}
Version: $REVISION
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Section: kernel
Priority: optional
Provides: armbian-u-boot
Replaces: armbian-u-boot
Conflicts: armbian-u-boot, u-boot-sunxi
Description: Uboot loader $version
cat <<- EOF > "$uboottempdir/${uboot_name}/DEBIAN/control"
Package: linux-u-boot-${BOARD}-${BRANCH}
Version: $REVISION
Architecture: $ARCH
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Installed-Size: 1
Section: kernel
Priority: optional
Provides: armbian-u-boot
Replaces: armbian-u-boot
Conflicts: armbian-u-boot, u-boot-sunxi
Description: Uboot loader $version
EOF
# copy config file to the package

View File

@@ -1,5 +1,4 @@
grab_version()
{
grab_version() {
local ver=()
ver[0]=$(grep "^VERSION" "${1}"/Makefile | head -1 | awk '{print $(NF)}' | grep -oE '^[[:digit:]]+')
ver[1]=$(grep "^PATCHLEVEL" "${1}"/Makefile | head -1 | awk '{print $(NF)}' | grep -oE '^[[:digit:]]+')
@@ -12,9 +11,11 @@ grab_version()
#
# returns path to toolchain that satisfies <expression>
#
find_toolchain()
{
[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && { echo "/usr/bin"; return; }
find_toolchain() {
[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && {
echo "/usr/bin"
return
}
local compiler=$1
local expression=$2
local dist=10
@@ -29,14 +30,14 @@ find_toolchain()
local gcc_ver
gcc_ver=$("${dir}bin/${compiler}gcc" -dumpversion | grep -oE "^[[:digit:]]+\.[[:digit:]]")
# check if toolchain version satisfies requirement
awk "BEGIN{exit ! ($gcc_ver $expression)}" >/dev/null || continue
awk "BEGIN{exit ! ($gcc_ver $expression)}" > /dev/null || continue
# check if found version is the closest to target
# may need different logic here with more than 1 digit minor version numbers
# numbers: 3.9 > 3.10; versions: 3.9 < 3.10
# dpkg --compare-versions can be used here if operators are changed
local d
d=$(awk '{x = $1 - $2}{printf "%.1f\n", (x > 0) ? x : -x}' <<< "$target_ver $gcc_ver")
if awk "BEGIN{exit ! ($d < $dist)}" >/dev/null ; then
if awk "BEGIN{exit ! ($d < $dist)}" > /dev/null; then
dist=$d
toolchain=${dir}bin
fi
@@ -45,10 +46,10 @@ find_toolchain()
# logging a stack of used compilers.
if [[ -f "${DEST}"/${LOG_SUBPATH}/compiler.log ]]; then
if ! grep -q "$toolchain" "${DEST}"/${LOG_SUBPATH}/compiler.log; then
echo "$toolchain" >> "${DEST}"/${LOG_SUBPATH}/compiler.log;
echo "$toolchain" >> "${DEST}"/${LOG_SUBPATH}/compiler.log
fi
else
echo "$toolchain" >> "${DEST}"/${LOG_SUBPATH}/compiler.log;
echo "$toolchain" >> "${DEST}"/${LOG_SUBPATH}/compiler.log
fi
}
@@ -66,8 +67,7 @@ find_toolchain()
# - UB if running multiple compilation tasks in parallel
# - should not be used with CREATE_PATCHES=yes
#
overlayfs_wrapper()
{
overlayfs_wrapper() {
local operation="$1"
if [[ $operation == wrap ]]; then
local srcdir="$2"
@@ -87,12 +87,12 @@ overlayfs_wrapper()
fi
if [[ $operation == cleanup ]]; then
if [[ -f /tmp/.overlayfs_wrapper_umount ]]; then
for dir in $(</tmp/.overlayfs_wrapper_umount); do
for dir in $(< /tmp/.overlayfs_wrapper_umount); do
[[ $dir == /tmp/* ]] && umount -l "$dir" > /dev/null 2>&1
done
fi
if [[ -f /tmp/.overlayfs_wrapper_cleanup ]]; then
for dir in $(</tmp/.overlayfs_wrapper_cleanup); do
for dir in $(< /tmp/.overlayfs_wrapper_cleanup); do
[[ $dir == /tmp/* ]] && rm -rf "$dir"
done
fi

View File

@@ -1,6 +1,5 @@
function distro_menu ()
{
# create a select menu for choosing a distribution based EXPERT status
function distro_menu() {
# create a select menu for choosing a distribution based EXPERT status
local distrib_dir="${1}"
@@ -25,12 +24,11 @@ function distros_options() {
done
}
show_developer_warning()
{
show_developer_warning() {
local temp_rc
temp_rc=$(mktemp)
cat <<-'EOF' > "${temp_rc}"
screen_color = (WHITE,RED,ON)
cat <<- 'EOF' > "${temp_rc}"
screen_color = (WHITE,RED,ON)
EOF
local warn_text="You are switching to the \Z1EXPERT MODE\Zn

View File

@@ -1,7 +1,6 @@
# create_chroot <target_dir> <release> <arch>
#
create_chroot()
{
create_chroot() {
local target_dir="$1"
local release=$2
local arch=$3
@@ -22,9 +21,9 @@ create_chroot()
# perhaps a temporally workaround
case $release in
bullseye|focal|jammy|sid)
bullseye | focal | jammy | sid)
includes=${includes}",perl-openssl-defaults,libnet-ssleay-perl"
;;
;;
esac
if [[ $NO_APT_CACHER != yes ]]; then
@@ -37,45 +36,45 @@ create_chroot()
cd "${target_dir}"
debootstrap --variant=buildd \
--components="${components[${release}]}" \
--arch="${arch}" $DEBOOTSTRAP_OPTION \
--foreign \
--include="${includes}" "${release}" "${target_dir}" "${mirror_addr}"
--components="${components[${release}]}" \
--arch="${arch}" $DEBOOTSTRAP_OPTION \
--foreign \
--include="${includes}" "${release}" "${target_dir}" "${mirror_addr}"
[[ $? -ne 0 || ! -f "${target_dir}"/debootstrap/debootstrap ]] && \
[[ $? -ne 0 || ! -f "${target_dir}"/debootstrap/debootstrap ]] &&
exit_with_error "Create chroot first stage failed"
cp /usr/bin/${qemu_binary[$arch]} "${target_dir}"/usr/bin/
[[ ! -f "${target_dir}"/usr/share/keyrings/debian-archive-keyring.gpg ]] && \
mkdir -p "${target_dir}"/usr/share/keyrings/ && \
[[ ! -f "${target_dir}"/usr/share/keyrings/debian-archive-keyring.gpg ]] &&
mkdir -p "${target_dir}"/usr/share/keyrings/ &&
cp /usr/share/keyrings/debian-archive-keyring.gpg "${target_dir}"/usr/share/keyrings/
eval 'LC_ALL=C LANG=C chroot "${target_dir}" \
/bin/bash -c "/debootstrap/debootstrap --second-stage"'
[[ $? -ne 0 || ! -f "${target_dir}"/bin/bash ]] && exit_with_error "Create chroot second stage failed"
[[ -f "${target_dir}"/etc/locale.gen ]] && \
[[ -f "${target_dir}"/etc/locale.gen ]] &&
sed -i '/en_US.UTF-8/s/^# //g' "${target_dir}"/etc/locale.gen
eval 'LC_ALL=C LANG=C chroot "${target_dir}" \
/bin/bash -c "locale-gen; update-locale --reset LANG=en_US.UTF-8"'
create_sources_list "$release" "${target_dir}"
[[ $NO_APT_CACHER != yes ]] && \
[[ $NO_APT_CACHER != yes ]] &&
echo 'Acquire::http { Proxy "http://localhost:3142"; };' > "${target_dir}"/etc/apt/apt.conf.d/02proxy
cat <<-EOF > "${target_dir}"/etc/apt/apt.conf.d/71-no-recommends
APT::Install-Recommends "0";
APT::Install-Suggests "0";
cat <<- EOF > "${target_dir}"/etc/apt/apt.conf.d/71-no-recommends
APT::Install-Recommends "0";
APT::Install-Suggests "0";
EOF
printf '#!/bin/sh\nexit 101' > "${target_dir}"/usr/sbin/policy-rc.d
chmod 755 "${target_dir}"/usr/sbin/policy-rc.d
rm "${target_dir}"/etc/resolv.conf 2>/dev/null
rm "${target_dir}"/etc/resolv.conf 2> /dev/null
echo "nameserver $NAMESERVER" > "${target_dir}"/etc/resolv.conf
rm "${target_dir}"/etc/hosts 2>/dev/null
rm "${target_dir}"/etc/hosts 2> /dev/null
echo "127.0.0.1 localhost" > "${target_dir}"/etc/hosts
mkdir -p "${target_dir}"/root/{build,overlay,sources} "${target_dir}"/selinux
if [[ -L "${target_dir}"/var/lock ]]; then
rm -rf "${target_dir}"/var/lock 2>/dev/null
rm -rf "${target_dir}"/var/lock 2> /dev/null
mkdir -p "${target_dir}"/var/lock
fi
eval 'LC_ALL=C LANG=C chroot "${target_dir}" \
@@ -84,7 +83,7 @@ create_chroot()
display_alert "Upgrading packages in" "${target_dir}" "info"
eval 'LC_ALL=C LANG=C chroot "${target_dir}" \
/bin/bash -c "apt-get -q update; apt-get -q -y upgrade; apt-get clean"'
date +%s >"$target_dir/root/.update-timestamp"
date +%s > "$target_dir/root/.update-timestamp"
# Install some packages with a large list of dependencies after the update.
# This optimizes the process and eliminates looping when calculating
@@ -93,12 +92,11 @@ create_chroot()
/bin/bash -c "apt-get install \
-q -y --no-install-recommends debhelper devscripts"'
case $release in
bullseye|focal|hirsute|sid)
eval 'LC_ALL=C LANG=C chroot "${target_dir}" \
bullseye | focal | hirsute | sid)
eval 'LC_ALL=C LANG=C chroot "${target_dir}" \
/bin/bash -c "apt-get install python-is-python3"'
;;
;;
esac
touch "${target_dir}"/root/.debootstrap-complete
@@ -107,8 +105,7 @@ create_chroot()
# chroot_prepare_distccd <release> <arch>
#
chroot_prepare_distccd()
{
chroot_prepare_distccd() {
local release=$1
local arch=$2
local dest=/tmp/distcc/${release}-${arch}
@@ -142,8 +139,7 @@ chroot_prepare_distccd()
# chroot_build_packages
#
chroot_build_packages()
{
chroot_build_packages() {
local built_ok=()
local failed=()
mkdir -p ${SRC}/cache/buildpkg
@@ -171,9 +167,9 @@ chroot_build_packages()
create_chroot "${tmp_dir}/${t_name}" "${release}" "${arch}"
display_alert "Create a clean Environment archive" "${t_name}.tar.xz" "info"
(
tar -cp --directory="${tmp_dir}/" ${t_name} \
| pv -p -b -r -s "$(du -sb "${tmp_dir}/${t_name}" | cut -f1)" \
| pixz -4 >"${SRC}/cache/buildpkg/${t_name}.tar.xz"
tar -cp --directory="${tmp_dir}/" ${t_name} |
pv -p -b -r -s "$(du -sb "${tmp_dir}/${t_name}" | cut -f1)" |
pixz -4 > "${SRC}/cache/buildpkg/${t_name}.tar.xz"
)
rm -rf $tmp_dir
fi
@@ -181,10 +177,11 @@ chroot_build_packages()
# Unpack the clean environment archive, if it exists.
if [ -f "${SRC}/cache/buildpkg/${t_name}.tar.xz" ]; then
local tmp_dir=$(mktemp -d "${SRC}"/.tmp/build-XXXXX)
( cd $tmp_dir
(
cd $tmp_dir
display_alert "Unpack the clean environment" "${t_name}.tar.xz" "info"
tar -xJf "${SRC}/cache/buildpkg/${t_name}.tar.xz" || \
exit_with_error "Is not extracted" "${SRC}/cache/buildpkg/${t_name}.tar.xz"
tar -xJf "${SRC}/cache/buildpkg/${t_name}.tar.xz" ||
exit_with_error "Is not extracted" "${SRC}/cache/buildpkg/${t_name}.tar.xz"
)
target_dir="$tmp_dir/${t_name}"
else
@@ -192,7 +189,7 @@ chroot_build_packages()
fi
[[ -f /var/run/distcc/"${release}-${arch}".pid ]] &&
kill "$(<"/var/run/distcc/${release}-${arch}.pid")" > /dev/null 2>&1
kill "$(< "/var/run/distcc/${release}-${arch}.pid")" > /dev/null 2>&1
chroot_prepare_distccd "${release}" "${arch}"
@@ -207,16 +204,16 @@ chroot_build_packages()
exit_with_error "Clean Environment is not visible" "$target_dir"
local t=$target_dir/root/.update-timestamp
if [[ ! -f ${t} || $(( ($(date +%s) - $(<"${t}")) / 86400 )) -gt 7 ]]; then
if [[ ! -f ${t} || $((($(date +%s) - $(< "${t}")) / 86400)) -gt 7 ]]; then
display_alert "Upgrading packages" "$release/$arch" "info"
systemd-nspawn -a -q -D "${target_dir}" /bin/bash -c "apt-get -q update; apt-get -q -y upgrade; apt-get clean"
date +%s > "${t}"
display_alert "Repack a clean Environment archive after upgrading" "${t_name}.tar.xz" "info"
rm "${SRC}/cache/buildpkg/${t_name}.tar.xz"
(
tar -cp --directory="${tmp_dir}/" ${t_name} \
| pv -p -b -r -s "$(du -sb "${tmp_dir}/${t_name}" | cut -f1)" \
| pixz -4 >"${SRC}/cache/buildpkg/${t_name}.tar.xz"
tar -cp --directory="${tmp_dir}/" ${t_name} |
pv -p -b -r -s "$(du -sb "${tmp_dir}/${t_name}" | cut -f1)" |
pixz -4 > "${SRC}/cache/buildpkg/${t_name}.tar.xz"
)
fi
@@ -256,10 +253,11 @@ chroot_build_packages()
if [[ -f "${target_dir}"/root/build.sh ]] && [[ -d $tmp_dir ]]; then
rm -rf $tmp_dir
local tmp_dir=$(mktemp -d "${SRC}"/.tmp/build-XXXXX)
( cd $tmp_dir
(
cd $tmp_dir
display_alert "Unpack the clean environment" "${t_name}.tar.xz" "info"
tar -xJf "${SRC}/cache/buildpkg/${t_name}.tar.xz" || \
exit_with_error "Is not extracted" "${SRC}/cache/buildpkg/${t_name}.tar.xz"
tar -xJf "${SRC}/cache/buildpkg/${t_name}.tar.xz" ||
exit_with_error "Is not extracted" "${SRC}/cache/buildpkg/${t_name}.tar.xz"
)
target_dir="$tmp_dir/${t_name}"
fi
@@ -281,23 +279,23 @@ chroot_build_packages()
--tmpfs=/root/build \
--tmpfs=/tmp:mode=777 \
--bind-ro "${SRC}"/packages/extras-buildpkgs/:/root/overlay \
--bind-ro "${SRC}"/cache/sources/extra/:/root/sources /bin/bash -c "/root/build.sh" 2>&1 \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/buildpkg.log'}
--bind-ro "${SRC}"/cache/sources/extra/:/root/sources /bin/bash -c "/root/build.sh" \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/buildpkg.log'} 2>&1
if [[ ${PIPESTATUS[0]} -eq 2 ]]; then
failed+=("$package_name:$release/$arch")
else
built_ok+=("$package_name:$release/$arch")
fi
mv "${target_dir}"/root/*.deb "${plugin_target_dir}" 2>/dev/null
mv "${target_dir}"/root/*.deb "${plugin_target_dir}" 2> /dev/null
mv "${target_dir}"/root/*.log "$DEST/${LOG_SUBPATH}/"
te=$(date +%s)
display_alert "Build time $package_name " " $(($te - $ts)) sec." "info"
done
# Delete a temporary directory
if [ -d $tmp_dir ]; then rm -rf $tmp_dir;fi
if [ -d $tmp_dir ]; then rm -rf $tmp_dir; fi
# cleanup for distcc
kill $(</var/run/distcc/${release}-${arch}.pid)
kill $(< /var/run/distcc/${release}-${arch}.pid)
done
done
if [[ ${#built_ok[@]} -gt 0 ]]; then
@@ -315,75 +313,74 @@ chroot_build_packages()
}
# create build script
create_build_script ()
{
cat <<-EOF > "${target_dir}"/root/build.sh
#!/bin/bash
export PATH="/usr/lib/ccache:\$PATH"
export HOME="/root"
export DEBIAN_FRONTEND="noninteractive"
export DEB_BUILD_OPTIONS="nocheck noautodbgsym"
export CCACHE_TEMPDIR="/tmp"
# distcc is disabled to prevent compilation issues due
# to different host and cross toolchain configurations
#export CCACHE_PREFIX="distcc"
# uncomment for debug
#export CCACHE_RECACHE="true"
#export CCACHE_DISABLE="true"
export DISTCC_HOSTS="$distcc_bindaddr"
export DEBFULLNAME="$MAINTAINER"
export DEBEMAIL="$MAINTAINERMAIL"
$(declare -f display_alert)
create_build_script() {
cat <<- EOF > "${target_dir}"/root/build.sh
#!/bin/bash
export PATH="/usr/lib/ccache:\$PATH"
export HOME="/root"
export DEBIAN_FRONTEND="noninteractive"
export DEB_BUILD_OPTIONS="nocheck noautodbgsym"
export CCACHE_TEMPDIR="/tmp"
# distcc is disabled to prevent compilation issues due
# to different host and cross toolchain configurations
#export CCACHE_PREFIX="distcc"
# uncomment for debug
#export CCACHE_RECACHE="true"
#export CCACHE_DISABLE="true"
export DISTCC_HOSTS="$distcc_bindaddr"
export DEBFULLNAME="$MAINTAINER"
export DEBEMAIL="$MAINTAINERMAIL"
$(declare -f display_alert)
LOG_OUTPUT_FILE=$LOG_OUTPUT_FILE
$(declare -f install_pkg_deb)
LOG_OUTPUT_FILE=$LOG_OUTPUT_FILE
$(declare -f install_pkg_deb)
cd /root/build
display_alert "Copying sources"
rsync -aq /root/sources/"${package_name}" /root/build/
cd /root/build/"${package_name}"
# copy overlay / "debianization" files
[[ -d "/root/overlay/${package_name}/" ]] && rsync -aq /root/overlay/"${package_name}" /root/build/
package_builddeps="$package_builddeps"
if [ -z "\$package_builddeps" ]; then
# Calculate build dependencies by a standard dpkg function
package_builddeps="\$(dpkg-checkbuilddeps |& awk -F":" '{print \$NF}')"
fi
if [[ -n "\${package_builddeps}" ]]; then
install_pkg_deb \${package_builddeps}
fi
# set upstream version
[[ -n "${package_upstream_version}" ]] && debchange --preserve --newversion "${package_upstream_version}" "Import from upstream"
# set local version
# debchange -l~armbian${REVISION}-${builddate}+ "Custom $VENDOR release"
debchange -l~armbian"${REVISION}"+ "Custom $VENDOR release"
display_alert "Building package"
# Set the number of build threads and certainly send
# the standard error stream to the log file.
dpkg-buildpackage -b -us -j${NCPU_CHROOT:-2} 2>>\$LOG_OUTPUT_FILE
if [[ \$? -eq 0 ]]; then
cd /root/build
# install in chroot if other libraries depend on them
if [[ -n "$package_install_chroot" ]]; then
display_alert "Installing packages"
for p in $package_install_chroot; do
dpkg -i \${p}_*.deb
done
display_alert "Copying sources"
rsync -aq /root/sources/"${package_name}" /root/build/
cd /root/build/"${package_name}"
# copy overlay / "debianization" files
[[ -d "/root/overlay/${package_name}/" ]] && rsync -aq /root/overlay/"${package_name}" /root/build/
package_builddeps="$package_builddeps"
if [ -z "\$package_builddeps" ]; then
# Calculate build dependencies by a standard dpkg function
package_builddeps="\$(dpkg-checkbuilddeps |& awk -F":" '{print \$NF}')"
fi
if [[ -n "\${package_builddeps}" ]]; then
install_pkg_deb \${package_builddeps}
fi
# set upstream version
[[ -n "${package_upstream_version}" ]] && debchange --preserve --newversion "${package_upstream_version}" "Import from upstream"
# set local version
# debchange -l~armbian${REVISION}-${builddate}+ "Custom $VENDOR release"
debchange -l~armbian"${REVISION}"+ "Custom $VENDOR release"
display_alert "Building package"
# Set the number of build threads and certainly send
# the standard error stream to the log file.
dpkg-buildpackage -b -us -j${NCPU_CHROOT:-2} 2>>\$LOG_OUTPUT_FILE
if [[ \$? -eq 0 ]]; then
cd /root/build
# install in chroot if other libraries depend on them
if [[ -n "$package_install_chroot" ]]; then
display_alert "Installing packages"
for p in $package_install_chroot; do
dpkg -i \${p}_*.deb
done
fi
display_alert "Done building" "$package_name $release/$arch" "ext"
ls *.deb 2>/dev/null
mv *.deb /root 2>/dev/null
exit 0
else
display_alert "Failed building" "$package_name $release/$arch" "err"
exit 2
fi
display_alert "Done building" "$package_name $release/$arch" "ext"
ls *.deb 2>/dev/null
mv *.deb /root 2>/dev/null
exit 0
else
display_alert "Failed building" "$package_name $release/$arch" "err"
exit 2
fi
EOF
chmod +x "${target_dir}"/root/build.sh
@@ -391,8 +388,7 @@ create_build_script ()
# chroot_installpackages_local
#
chroot_installpackages_local()
{
chroot_installpackages_local() {
local conf="${SRC}"/config/aptly-temp.conf
rm -rf /tmp/aptly-temp/
mkdir -p /tmp/aptly-temp/
@@ -402,17 +398,17 @@ chroot_installpackages_local()
aptly -config="${conf}" repo add temp "${DEB_STORAGE}/extra/${RELEASE}-utils/" >> "${DEST}"/${LOG_SUBPATH}/install.log
# -gpg-key="925644A6"
aptly -keyring="${SRC}/packages/extras-buildpkgs/buildpkg-public.gpg" -secret-keyring="${SRC}/packages/extras-buildpkgs/buildpkg.gpg" -batch=true -config="${conf}" \
-gpg-key="925644A6" -passphrase="testkey1234" -component=temp -distribution="${RELEASE}" publish repo temp >> "${DEST}"/${LOG_SUBPATH}/install.log
-gpg-key="925644A6" -passphrase="testkey1234" -component=temp -distribution="${RELEASE}" publish repo temp >> "${DEST}"/${LOG_SUBPATH}/install.log
aptly -config="${conf}" -listen=":8189" serve &
local aptly_pid=$!
cp "${SRC}"/packages/extras-buildpkgs/buildpkg.key "${SDCARD}"/tmp/buildpkg.key
cat <<-'EOF' > "${SDCARD}"/etc/apt/preferences.d/90-armbian-temp.pref
Package: *
Pin: origin "localhost"
Pin-Priority: 550
cat <<- 'EOF' > "${SDCARD}"/etc/apt/preferences.d/90-armbian-temp.pref
Package: *
Pin: origin "localhost"
Pin-Priority: 550
EOF
cat <<-EOF > "${SDCARD}"/etc/apt/sources.list.d/armbian-temp.list
deb http://localhost:8189/ $RELEASE temp
cat <<- EOF > "${SDCARD}"/etc/apt/sources.list.d/armbian-temp.list
deb http://localhost:8189/ $RELEASE temp
EOF
chroot_installpackages
kill "${aptly_pid}"
@@ -420,8 +416,7 @@ chroot_installpackages_local()
# chroot_installpackages <remote_only>
#
chroot_installpackages()
{
chroot_installpackages() {
local remote_only=$1
local install_list=""
for plugin in "${SRC}"/packages/extras-buildpkgs/*.conf; do
@@ -432,31 +427,31 @@ chroot_installpackages()
unset package_install_target package_checkinstall
done
if [[ -n $PACKAGE_LIST_RM ]]; then
install_list=$(sed -r "s/\W($(tr ' ' '|' <<< ${PACKAGE_LIST_RM}))\W/ /g" <<< " ${install_list} ")
install_list="$(echo ${install_list})"
install_list=$(sed -r "s/\W($(tr ' ' '|' <<< ${PACKAGE_LIST_RM}))\W/ /g" <<< " ${install_list} ")
install_list="$(echo ${install_list})"
fi
display_alert "Installing extras-buildpkgs" "$install_list"
[[ $NO_APT_CACHER != yes ]] && local apt_extra="-o Acquire::http::Proxy=\"http://${APT_PROXY_ADDR:-localhost:3142}\" -o Acquire::http::Proxy::localhost=\"DIRECT\""
cat <<-EOF > "${SDCARD}"/tmp/install.sh
#!/bin/bash
[[ "$remote_only" != yes ]] && apt-key add /tmp/buildpkg.key
apt-get ${apt_extra} -q update
# uncomment to debug
# /bin/bash
# TODO: check if package exists in case new config was added
#if [[ -n "$remote_only" == yes ]]; then
# for p in ${install_list}; do
# if grep -qE "apt.armbian.com|localhost" <(apt-cache madison \$p); then
# if apt-get -s -qq install \$p; then
#fi
apt-get -q ${apt_extra} --show-progress -o DPKG::Progress-Fancy=1 install -y ${install_list}
apt-get clean
[[ "${remote_only}" != yes ]] && apt-key del "925644A6"
rm /etc/apt/sources.list.d/armbian-temp.list 2>/dev/null
rm /etc/apt/preferences.d/90-armbian-temp.pref 2>/dev/null
rm /tmp/buildpkg.key 2>/dev/null
rm -- "\$0"
cat <<- EOF > "${SDCARD}"/tmp/install.sh
#!/bin/bash
[[ "$remote_only" != yes ]] && apt-key add /tmp/buildpkg.key
apt-get ${apt_extra} -q update
# uncomment to debug
# /bin/bash
# TODO: check if package exists in case new config was added
#if [[ -n "$remote_only" == yes ]]; then
# for p in ${install_list}; do
# if grep -qE "apt.armbian.com|localhost" <(apt-cache madison \$p); then
# if apt-get -s -qq install \$p; then
#fi
apt-get -q ${apt_extra} --show-progress -o DPKG::Progress-Fancy=1 install -y ${install_list}
apt-get clean
[[ "${remote_only}" != yes ]] && apt-key del "925644A6"
rm /etc/apt/sources.list.d/armbian-temp.list 2>/dev/null
rm /etc/apt/preferences.d/90-armbian-temp.pref 2>/dev/null
rm /tmp/buildpkg.key 2>/dev/null
rm -- "\$0"
EOF
chmod +x "${SDCARD}"/tmp/install.sh
chroot "${SDCARD}" /bin/bash -c "/tmp/install.sh" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1

View File

@@ -17,8 +17,7 @@
# The LOG_OUTPUT_FILE variable must be defined in the calling function
# before calling the install_pkg_deb function and unset after.
#
install_pkg_deb ()
{
install_pkg_deb() {
local list=""
local listdeb=""
local log_file
@@ -40,38 +39,53 @@ install_pkg_deb ()
log_file="${SRC}/output/${LOG_SUBPATH}/install.log"
fi
for p in $*;do
for p in $*; do
case $p in
autoupdate) need_autoup=true; continue ;;
upgrade) need_upgrade=true; continue ;;
clean) need_clean=true; continue ;;
verbose) need_verbose=true; continue ;;
\||\(*|*\)) continue ;;
*[.]deb) listdeb+=" $p"; continue ;;
autoupdate)
need_autoup=true
continue
;;
upgrade)
need_upgrade=true
continue
;;
clean)
need_clean=true
continue
;;
verbose)
need_verbose=true
continue
;;
\| | \(* | *\)) continue ;;
*[.]deb)
listdeb+=" $p"
continue
;;
*) list+=" $p" ;;
esac
done
# This is necessary first when there is no apt cache.
if $need_upgrade; then
apt-get -q update || echo "apt cannot update" >>$tmp_file
apt-get -y upgrade || echo "apt cannot upgrade" >>$tmp_file
apt-get -q update || echo "apt cannot update" >> $tmp_file
apt-get -y upgrade || echo "apt cannot upgrade" >> $tmp_file
fi
# Install debian package files
if [ -n "$listdeb" ];then
for f in $listdeb;do
if [ -n "$listdeb" ]; then
for f in $listdeb; do
# Calculate dependencies for installing the package file
add_for_install=" $(
dpkg-deb -f $f Depends | awk '{gsub(/[,]/, "", $0); print $0}'
)"
echo -e "\nfile $f depends on:\n$add_for_install" >>$log_file
echo -e "\nfile $f depends on:\n$add_for_install" >> $log_file
install_pkg_deb $add_for_install
dpkg -i $f 2>>$log_file
dpkg -i $f 2>> $log_file
dpkg-query -W \
-f '${binary:Package;-27} ${Version;-23}\n' \
$(dpkg-deb -f $f Package) >>$log_file
-f '${binary:Package;-27} ${Version;-23}\n' \
$(dpkg-deb -f $f Package) >> $log_file
done
fi
@@ -79,23 +93,23 @@ install_pkg_deb ()
# up-to-date version in the apt cache.
# Exclude bad package names and send a message to the log.
for_install=$(
for p in $list;do
if $(dpkg-query -W -f '${db:Status-Abbrev}' $p |& awk '/ii/{exit 1}');then
apt-cache show $p -o APT::Cache::AllVersions=no |& \
awk -v p=$p -v tmp_file=$tmp_file \
'/^Package:/{print $2} /^E:/{print "Bad package name: ",p >>tmp_file}'
fi
done
for p in $list; do
if $(dpkg-query -W -f '${db:Status-Abbrev}' $p |& awk '/ii/{exit 1}'); then
apt-cache show $p -o APT::Cache::AllVersions=no |&
awk -v p=$p -v tmp_file=$tmp_file \
'/^Package:/{print $2} /^E:/{print "Bad package name: ",p >>tmp_file}'
fi
done
)
# This information should be logged.
if [ -s $tmp_file ]; then
echo -e "\nInstalling packages in function: $_function" "[$_file:$_line]" \
>>$log_file
echo -e "\nIncoming list:" >>$log_file
printf "%-30s %-30s %-30s %-30s\n" $list >>$log_file
echo "" >>$log_file
cat $tmp_file >>$log_file
>> $log_file
echo -e "\nIncoming list:" >> $log_file
printf "%-30s %-30s %-30s %-30s\n" $list >> $log_file
echo "" >> $log_file
cat $tmp_file >> $log_file
fi
if [ -n "$for_install" ]; then
@@ -104,21 +118,21 @@ install_pkg_deb ()
apt-get -y upgrade
fi
apt-get install -qq -y --no-install-recommends $for_install
echo -e "\nPackages installed:" >>$log_file
echo -e "\nPackages installed:" >> $log_file
dpkg-query -W \
-f '${binary:Package;-27} ${Version;-23}\n' \
$for_install >>$log_file
-f '${binary:Package;-27} ${Version;-23}\n' \
$for_install >> $log_file
fi
# We will show the status after installation all listed
if $need_verbose; then
echo -e "\nstatus after installation:" >>$log_file
echo -e "\nstatus after installation:" >> $log_file
dpkg-query -W \
-f '${binary:Package;-27} ${Version;-23} [ ${Status} ]\n' \
$list >>$log_file
-f '${binary:Package;-27} ${Version;-23} [ ${Status} ]\n' \
$list >> $log_file
fi
if $need_clean;then apt-get clean; fi
if $need_clean; then apt-get clean; fi
rm $tmp_file
}

View File

@@ -2,8 +2,7 @@
#
# helper to reduce code duplication
#
mount_chroot()
{
mount_chroot() {
local target=$1
mount -t tmpfs tmpfs "${target}/tmp"
@@ -18,17 +17,15 @@ mount_chroot()
#
# helper to reduce code duplication
#
umount_chroot()
{
umount_chroot() {
local target=$1
display_alert "Unmounting" "$target" "info"
while grep -Eq "${target}/*(dev|proc|sys|tmp)" /proc/mounts
do
umount -l --recursive "${target}"/dev >/dev/null 2>&1
umount -l "${target}"/proc >/dev/null 2>&1
umount -l "${target}"/sys >/dev/null 2>&1
umount -l "${target}"/tmp >/dev/null 2>&1
while grep -Eq "${target}/*(dev|proc|sys|tmp)" /proc/mounts; do
umount -l --recursive "${target}"/dev > /dev/null 2>&1
umount -l "${target}"/proc > /dev/null 2>&1
umount -l "${target}"/sys > /dev/null 2>&1
umount -l "${target}"/tmp > /dev/null 2>&1
sleep 5
done

View File

@@ -13,64 +13,69 @@
# "sources" - delete output/sources
#
cleaning()
{
cleaning() {
case $1 in
debs) # delete ${DEB_STORAGE} for current branch and family
if [[ -d "${DEB_STORAGE}" ]]; then
display_alert "Cleaning ${DEB_STORAGE} for" "$BOARD $BRANCH" "info"
# easier than dealing with variable expansion and escaping dashes in file names
find "${DEB_STORAGE}" -name "${CHOSEN_UBOOT}_*.deb" -delete
find "${DEB_STORAGE}" \( -name "${CHOSEN_KERNEL}_*.deb" -o \
-name "armbian-*.deb" -o \
-name "plymouth-theme-armbian_*.deb" -o \
-name "${CHOSEN_KERNEL/image/dtb}_*.deb" -o \
-name "${CHOSEN_KERNEL/image/headers}_*.deb" -o \
-name "${CHOSEN_KERNEL/image/source}_*.deb" -o \
-name "${CHOSEN_KERNEL/image/firmware-image}_*.deb" \) -delete
[[ -n $RELEASE ]] && rm -f "${DEB_STORAGE}/${RELEASE}/${CHOSEN_ROOTFS}"_*.deb
[[ -n $RELEASE ]] && rm -f "${DEB_STORAGE}/${RELEASE}/armbian-desktop-${RELEASE}"_*.deb
fi
;;
if [[ -d "${DEB_STORAGE}" ]]; then
display_alert "Cleaning ${DEB_STORAGE} for" "$BOARD $BRANCH" "info"
# easier than dealing with variable expansion and escaping dashes in file names
find "${DEB_STORAGE}" -name "${CHOSEN_UBOOT}_*.deb" -delete
find "${DEB_STORAGE}" \( -name "${CHOSEN_KERNEL}_*.deb" -o \
-name "armbian-*.deb" -o \
-name "plymouth-theme-armbian_*.deb" -o \
-name "${CHOSEN_KERNEL/image/dtb}_*.deb" -o \
-name "${CHOSEN_KERNEL/image/headers}_*.deb" -o \
-name "${CHOSEN_KERNEL/image/source}_*.deb" -o \
-name "${CHOSEN_KERNEL/image/firmware-image}_*.deb" \) -delete
[[ -n $RELEASE ]] && rm -f "${DEB_STORAGE}/${RELEASE}/${CHOSEN_ROOTFS}"_*.deb
[[ -n $RELEASE ]] && rm -f "${DEB_STORAGE}/${RELEASE}/armbian-desktop-${RELEASE}"_*.deb
fi
;;
ubootdebs) # delete ${DEB_STORAGE} for uboot, current branch and family
if [[ -d "${DEB_STORAGE}" ]]; then
display_alert "Cleaning ${DEB_STORAGE} for u-boot" "$BOARD $BRANCH" "info"
# easier than dealing with variable expansion and escaping dashes in file names
find "${DEB_STORAGE}" -name "${CHOSEN_UBOOT}_*.deb" -delete
fi
;;
if [[ -d "${DEB_STORAGE}" ]]; then
display_alert "Cleaning ${DEB_STORAGE} for u-boot" "$BOARD $BRANCH" "info"
# easier than dealing with variable expansion and escaping dashes in file names
find "${DEB_STORAGE}" -name "${CHOSEN_UBOOT}_*.deb" -delete
fi
;;
extras) # delete ${DEB_STORAGE}/extra/$RELEASE for all architectures
if [[ -n $RELEASE && -d ${DEB_STORAGE}/extra/$RELEASE ]]; then
display_alert "Cleaning ${DEB_STORAGE}/extra for" "$RELEASE" "info"
rm -rf "${DEB_STORAGE}/extra/${RELEASE}"
fi
;;
if [[ -n $RELEASE && -d ${DEB_STORAGE}/extra/$RELEASE ]]; then
display_alert "Cleaning ${DEB_STORAGE}/extra for" "$RELEASE" "info"
rm -rf "${DEB_STORAGE}/extra/${RELEASE}"
fi
;;
alldebs) # delete output/debs
[[ -d "${DEB_STORAGE}" ]] && display_alert "Cleaning" "${DEB_STORAGE}" "info" && rm -rf "${DEB_STORAGE}"/*
;;
[[ -d "${DEB_STORAGE}" ]] && display_alert "Cleaning" "${DEB_STORAGE}" "info" && rm -rf "${DEB_STORAGE}"/*
;;
cache) # delete output/cache
[[ -d "${SRC}"/cache/rootfs ]] && display_alert "Cleaning" "rootfs cache (all)" "info" && find "${SRC}"/cache/rootfs -type f -delete
;;
[[ -d "${SRC}"/cache/rootfs ]] && display_alert "Cleaning" "rootfs cache (all)" "info" && find "${SRC}"/cache/rootfs -type f -delete
;;
images) # delete output/images
[[ -d "${DEST}"/images ]] && display_alert "Cleaning" "output/images" "info" && rm -rf "${DEST}"/images/*
;;
[[ -d "${DEST}"/images ]] && display_alert "Cleaning" "output/images" "info" && rm -rf "${DEST}"/images/*
;;
sources) # delete output/sources and output/buildpkg
[[ -d "${SRC}"/cache/sources ]] && display_alert "Cleaning" "sources" "info" && rm -rf "${SRC}"/cache/sources/* "${DEST}"/buildpkg/*
;;
[[ -d "${SRC}"/cache/sources ]] && display_alert "Cleaning" "sources" "info" && rm -rf "${SRC}"/cache/sources/* "${DEST}"/buildpkg/*
;;
oldcache) # remove old `cache/rootfs` except for the newest 8 files
if [[ -d "${SRC}"/cache/rootfs && $(ls -1 "${SRC}"/cache/rootfs/*.zst* 2> /dev/null | wc -l) -gt "${ROOTFS_CACHE_MAX}" ]]; then
display_alert "Cleaning" "rootfs cache (old)" "info"
(cd "${SRC}"/cache/rootfs; ls -t *.lz4 | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f)
# Remove signatures if they are present. We use them for internal purpose
(cd "${SRC}"/cache/rootfs; ls -t *.asc | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f)
fi
;;
if [[ -d "${SRC}"/cache/rootfs && $(ls -1 "${SRC}"/cache/rootfs/*.zst* 2> /dev/null | wc -l) -gt "${ROOTFS_CACHE_MAX}" ]]; then
display_alert "Cleaning" "rootfs cache (old)" "info"
(
cd "${SRC}"/cache/rootfs
ls -t *.lz4 | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f
)
# Remove signatures if they are present. We use them for internal purpose
(
cd "${SRC}"/cache/rootfs
ls -t *.asc | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f
)
fi
;;
esac
}

View File

@@ -1,5 +1,4 @@
function get_urls()
{
function get_urls() {
local catalog=$1
local filename=$2
@@ -9,22 +8,24 @@ function get_urls()
local urls=(
# "https://dl.armbian.com/_toolchain/${filename}"
$( curl --silent --fail "https://dl.armbian.com/mirrors" \
| jq -r "(${CCODE:+.${CCODE} // } .default) | .[]" \
| sed "s#\$#/_toolchain/${filename}#"
$(
curl --silent --fail "https://dl.armbian.com/mirrors" |
jq -r "(${CCODE:+.${CCODE} // } .default) | .[]" |
sed "s#\$#/_toolchain/${filename}#"
)
)
;;
rootfs)
local CCODE=$(curl --silent --fail https://cache.armbian.com/geoip | jq '.continent.code' -r)
local CCODE=$(curl --silent --fail https://cache.armbian.com/geoip | jq '.continent.code' -r)
local urls=(
# "https://cache.armbian.com/rootfs/${ROOTFSCACHE_VERSION}/${filename}"
"https://github.com/armbian/cache/releases/download/${ROOTFSCACHE_VERSION}/${filename}"
$( curl --silent --fail "https://cache.armbian.com/mirrors" \
| jq -r "(${CCODE:+.${CCODE} // } .default) | .[]" \
| sed "s#\$#/rootfs/${ROOTFSCACHE_VERSION}/${filename}#"
$(
curl --silent --fail "https://cache.armbian.com/mirrors" |
jq -r "(${CCODE:+.${CCODE} // } .default) | .[]" |
sed "s#\$#/rootfs/${ROOTFSCACHE_VERSION}/${filename}#"
)
)
;;
@@ -38,8 +39,7 @@ function get_urls()
echo "${urls[@]}"
}
download_and_verify()
{
download_and_verify() {
local catalog=$1
local filename=$2
@@ -100,8 +100,8 @@ download_and_verify()
return $rc
fi
[[ ${USE_TORRENT} == "yes" ]] \
&& local torrent="$(get_urls "${catalog}" "${filename}.torrent")"
[[ ${USE_TORRENT} == "yes" ]] &&
local torrent="$(get_urls "${catalog}" "${filename}.torrent")"
fi
# download torrent first
@@ -118,7 +118,6 @@ download_and_verify()
fi
# direct download if torrent fails
if [[ $direct != "no" ]]; then
display_alert "downloading using http(s) network" "$filename"
@@ -149,12 +148,12 @@ download_and_verify()
for key in "${keys[@]}"; do
gpg --homedir "${SRC}/cache/.gpg" --no-permission-warning \
--list-keys "${key}" >> "${DEST}/${LOG_SUBPATH}/output.log" 2>&1 \
|| gpg --homedir "${SRC}/cache/.gpg" --no-permission-warning \
${http_proxy:+--keyserver-options http-proxy="${http_proxy}"} \
--keyserver "hkp://keyserver.ubuntu.com:80" \
--recv-keys "${key}" >> "${DEST}/${LOG_SUBPATH}/output.log" 2>&1 \
|| exit_with_error "Failed to recieve key" "${key}"
--list-keys "${key}" >> "${DEST}/${LOG_SUBPATH}/output.log" 2>&1 ||
gpg --homedir "${SRC}/cache/.gpg" --no-permission-warning \
${http_proxy:+--keyserver-options http-proxy="${http_proxy}"} \
--keyserver "hkp://keyserver.ubuntu.com:80" \
--recv-keys "${key}" >> "${DEST}/${LOG_SUBPATH}/output.log" 2>&1 ||
exit_with_error "Failed to recieve key" "${key}"
done
gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning --trust-model always \
@@ -163,9 +162,8 @@ download_and_verify()
else
[[ "$(md5sum "${localdir}/${filename}" | awk '{printf $1}')" \
== "$(awk '{printf $1}' ${localdir}/${filename}.asc)" \
]] && verified=true && display_alert "Verified" "MD5" "info"
[[ "$(md5sum "${localdir}/${filename}" | awk '{printf $1}')" == "$(awk '{printf $1}' ${localdir}/${filename}.asc)" ]] &&
verified=true && display_alert "Verified" "MD5" "info"
fi

View File

@@ -2,8 +2,7 @@
# This function retries Git operations to avoid failure in case remote is borked
# If the git team needs to call a remote server, use this function.
#
improved_git()
{
improved_git() {
local realgit=$(command -v git)
local retries=3
@@ -15,14 +14,13 @@ improved_git()
retries=0
break
fi
let count=$count+1
sleep $delay
let count=$count+1
sleep $delay
done
}
clean_up_git ()
{
clean_up_git() {
local target_dir=$1
# Files that are not tracked by git and were added
@@ -49,16 +47,18 @@ clean_up_git ()
# The settings for the kernel variables of the original kernel
# VAR_SHALLOW_ORIGINAL=var_origin_kernel must be in the main script
# before calling the function
waiter_local_git ()
{
for arg in $@;do
waiter_local_git() {
for arg in $@; do
case $arg in
url=*|https://*|git://*) eval "local url=${arg/url=/}"
url=* | https://* | git://*)
eval "local url=${arg/url=/}"
;;
dir=*|/*/*/*) eval "local dir=${arg/dir=/}"
dir=* | /*/*/*)
eval "local dir=${arg/dir=/}"
;;
*=*|*:*) eval "local ${arg/:/=}"
*=* | *:*)
eval "local ${arg/:/=}"
;;
esac
@@ -84,35 +84,34 @@ waiter_local_git ()
display_alert "Checking git sources" "$dir $url$name/$branch" "info"
if [ "$(git rev-parse --git-dir 2>/dev/null)" != ".git" ]; then
if [ "$(git rev-parse --git-dir 2> /dev/null)" != ".git" ]; then
git init -q .
# Run in the sub shell to avoid mixing environment variables.
if [ -n "$VAR_SHALLOW_ORIGINAL" ]; then
(
$VAR_SHALLOW_ORIGINAL
$VAR_SHALLOW_ORIGINAL
display_alert "Add original git sources" "$dir $name/$branch" "info"
if [ "$(improved_git ls-remote -h $url $branch | \
awk -F'/' '{if (NR == 1) print $NF}')" != "$branch" ];then
display_alert "Bad $branch for $url in $VAR_SHALLOW_ORIGINAL"
exit 177
fi
display_alert "Add original git sources" "$dir $name/$branch" "info"
if [ "$(improved_git ls-remote -h $url $branch |
awk -F'/' '{if (NR == 1) print $NF}')" != "$branch" ]; then
display_alert "Bad $branch for $url in $VAR_SHALLOW_ORIGINAL"
exit 177
fi
git remote add -t $branch $name $url
git remote add -t $branch $name $url
# Handle an exception if the initial tag is the top of the branch
# As v5.16 == HEAD
if [ "${start_tag}.1" == "$(improved_git ls-remote -t $url ${start_tag}.1 | \
awk -F'/' '{ print $NF }')" ]
then
improved_git fetch --shallow-exclude=$start_tag $name
else
improved_git fetch --depth 1 $name
fi
improved_git fetch --deepen=1 $name
# For a shallow clone, this works quickly and saves space.
git gc
# Handle an exception if the initial tag is the top of the branch
# As v5.16 == HEAD
if [ "${start_tag}.1" == "$(improved_git ls-remote -t $url ${start_tag}.1 |
awk -F'/' '{ print $NF }')" ]; then
improved_git fetch --shallow-exclude=$start_tag $name
else
improved_git fetch --depth 1 $name
fi
improved_git fetch --deepen=1 $name
# For a shallow clone, this works quickly and saves space.
git gc
)
[ "$?" == "177" ] && exit
@@ -120,17 +119,17 @@ waiter_local_git ()
fi
files_for_clean="$(git status -s | wc -l)"
if [ "$files_for_clean" != "0" ];then
if [ "$files_for_clean" != "0" ]; then
display_alert " Cleaning .... " "$files_for_clean files"
clean_up_git $work_dir
fi
if [ "$name" != "$(git remote show | grep $name)" ];then
if [ "$name" != "$(git remote show | grep $name)" ]; then
git remote add -t $branch $name $url
fi
if ! $offline; then
for t_name in $(git remote show);do
for t_name in $(git remote show); do
improved_git fetch $t_name
done
fi
@@ -141,16 +140,16 @@ waiter_local_git ()
# We do not use variables that characterize the current state of the git,
# such as `HEAD` and `FETCH_HEAD`.
reachability=false
for var in obj tag commit branch;do
for var in obj tag commit branch; do
eval pval=\$$var
if [ -n "$pval" ] && [ "$pval" != *HEAD ]; then
case $var in
obj|tag|commit) obj=$pval ;;
obj | tag | commit) obj=$pval ;;
branch) obj=${name}/$branch ;;
esac
if t_hash=$(git rev-parse $obj 2>/dev/null);then
if t_hash=$(git rev-parse $obj 2> /dev/null); then
reachability=true
break
else
@@ -159,7 +158,7 @@ waiter_local_git ()
fi
done
if $reachability && [ "$t_hash" != "$(git rev-parse @ 2>/dev/null)" ];then
if $reachability && [ "$t_hash" != "$(git rev-parse @ 2> /dev/null)" ]; then
# Switch "detached branch" as hash
display_alert "Switch $obj = $t_hash"
git checkout -qf $t_hash
@@ -183,8 +182,7 @@ waiter_local_git ()
#
# <ref_subdir>: "yes" to create subdirectory for tag or branch name
#
fetch_from_repo()
{
fetch_from_repo() {
local url=$1
local dir=$2
local ref=$3
@@ -200,7 +198,7 @@ fetch_from_repo()
local offline=false
fi
[[ -z $ref || ( $ref != tag:* && $ref != branch:* && $ref != head && $ref != commit:* ) ]] && exit_with_error "Error in configuration"
[[ -z $ref || ($ref != tag:* && $ref != branch:* && $ref != head && $ref != commit:*) ]] && exit_with_error "Error in configuration"
local ref_type=${ref%%:*}
if [[ $ref_type == head ]]; then
local ref_name=HEAD
@@ -220,7 +218,7 @@ fetch_from_repo()
local workdir=$dir
fi
mkdir -p "${SRC}/cache/sources/${workdir}" 2>/dev/null || \
mkdir -p "${SRC}/cache/sources/${workdir}" 2> /dev/null ||
exit_with_error "No path or no write permission" "${SRC}/cache/sources/${workdir}"
cd "${SRC}/cache/sources/${workdir}" || exit
@@ -230,13 +228,13 @@ fetch_from_repo()
# Check the folder as a git repository.
# Then the target URL matches the local URL.
if [[ "$(git rev-parse --git-dir 2>/dev/null)" == ".git" && \
"$url" != *"$(git remote get-url origin | sed 's/^.*@//' | sed 's/^.*\/\///' 2>/dev/null)" ]]; then
if [[ "$(git rev-parse --git-dir 2> /dev/null)" == ".git" &&
"$url" != *"$(git remote get-url origin | sed 's/^.*@//' | sed 's/^.*\/\///' 2> /dev/null)" ]]; then
display_alert "Remote URL does not match, removing existing local copy"
rm -rf .git ./*
fi
if [[ "$(git rev-parse --git-dir 2>/dev/null)" != ".git" ]]; then
if [[ "$(git rev-parse --git-dir 2> /dev/null)" != ".git" ]]; then
display_alert "Creating local copy"
git init -q .
git remote add origin "${url}"
@@ -249,34 +247,34 @@ fetch_from_repo()
# when we work offline we simply return the sources to their original state
if ! $offline; then
local local_hash
local_hash=$(git rev-parse @ 2>/dev/null)
local_hash=$(git rev-parse @ 2> /dev/null)
case $ref_type in
branch)
# TODO: grep refs/heads/$name
local remote_hash
remote_hash=$(improved_git ls-remote -h "${url}" "$ref_name" | head -1 | cut -f1)
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
;;
# TODO: grep refs/heads/$name
local remote_hash
remote_hash=$(improved_git ls-remote -h "${url}" "$ref_name" | head -1 | cut -f1)
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
;;
tag)
local remote_hash
remote_hash=$(improved_git ls-remote -t "${url}" "$ref_name" | cut -f1)
if [[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]]; then
remote_hash=$(improved_git ls-remote -t "${url}" "$ref_name^{}" | cut -f1)
[[ -z $remote_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
fi
;;
local remote_hash
remote_hash=$(improved_git ls-remote -t "${url}" "$ref_name" | cut -f1)
if [[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]]; then
remote_hash=$(improved_git ls-remote -t "${url}" "$ref_name^{}" | cut -f1)
[[ -z $remote_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
fi
;;
head)
local remote_hash
remote_hash=$(improved_git ls-remote "${url}" HEAD | cut -f1)
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
;;
local remote_hash
remote_hash=$(improved_git ls-remote "${url}" HEAD | cut -f1)
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
;;
commit)
[[ -z $local_hash || $local_hash == "@" ]] && changed=true
;;
[[ -z $local_hash || $local_hash == "@" ]] && changed=true
;;
esac
fi # offline

View File

@@ -1,30 +1,27 @@
adding_packages()
{
# add deb files to repository if they are not already there
adding_packages() {
# add deb files to repository if they are not already there
display_alert "Checking and adding to repository $release" "$3" "ext"
for f in "${DEB_STORAGE}${2}"/*.deb
do
for f in "${DEB_STORAGE}${2}"/*.deb; do
local name version arch
name=$(dpkg-deb -I "${f}" | grep Package | awk '{print $2}')
version=$(dpkg-deb -I "${f}" | grep Version | awk '{print $2}')
arch=$(dpkg-deb -I "${f}" | grep Architecture | awk '{print $2}')
# add if not already there
aptly repo search -architectures="${arch}" -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${1}" 'Name (% '${name}'), $Version (='${version}'), $Architecture (='${arch}')' &>/dev/null
aptly repo search -architectures="${arch}" -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${1}" 'Name (% '${name}'), $Version (='${version}'), $Architecture (='${arch}')' &> /dev/null
if [[ $? -ne 0 ]]; then
display_alert "Adding ${1}" "$name" "info"
aptly repo add -force-replace=true -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${1}" "${f}" &>/dev/null
aptly repo add -force-replace=true -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${1}" "${f}" &> /dev/null
fi
done
}
addtorepo()
{
# create repository
# parameter "remove" dumps all and creates new
# parameter "delete" remove incoming directory if publishing is succesful
# function: cycle trough distributions
addtorepo() {
# create repository
# parameter "remove" dumps all and creates new
# parameter "delete" remove incoming directory if publishing is succesful
# function: cycle trough distributions
local distributions=("stretch" "bionic" "buster" "bullseye" "focal" "hirsute" "impish" "jammy" "sid")
#local distributions=($(grep -rw config/distributions/*/ -e 'supported' | cut -d"/" -f3))
@@ -34,7 +31,7 @@ addtorepo()
ADDING_PACKAGES="false"
if [[ -d "config/distributions/${release}/" ]]; then
[[ -n "$(cat config/distributions/${release}/support | grep "csc\|supported" 2>/dev/null)" ]] && ADDING_PACKAGES="true"
[[ -n "$(cat config/distributions/${release}/support | grep "csc\|supported" 2> /dev/null)" ]] && ADDING_PACKAGES="true"
else
display_alert "Skipping adding packages (not supported)" "$release" "wrn"
continue
@@ -51,54 +48,53 @@ addtorepo()
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}") ]]; then
display_alert "Creating section" "main" "info"
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="main" \
-comment="Armbian main repository" "${release}" >/dev/null
-comment="Armbian main repository" "${release}" > /dev/null
fi
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "^utils") ]]; then
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="utils" \
-comment="Armbian utilities (backwards compatibility)" utils >/dev/null
-comment="Armbian utilities (backwards compatibility)" utils > /dev/null
fi
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}-utils") ]]; then
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="${release}-utils" \
-comment="Armbian ${release} utilities" "${release}-utils" >/dev/null
-comment="Armbian ${release} utilities" "${release}-utils" > /dev/null
fi
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}-desktop") ]]; then
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="${release}-desktop" \
-comment="Armbian ${release} desktop" "${release}-desktop" >/dev/null
-comment="Armbian ${release} desktop" "${release}-desktop" > /dev/null
fi
# adding main
if find "${DEB_STORAGE}"/ -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
if find "${DEB_STORAGE}"/ -maxdepth 1 -type f -name "*.deb" 2> /dev/null | grep -q .; then
[[ "${ADDING_PACKAGES}" == true ]] && adding_packages "$release" "" "main"
else
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "${SCRIPTPATH}config/templates/example.deb" > /dev/null
fi
local COMPONENTS="main"
# adding main distribution packages
if find "${DEB_STORAGE}/${release}" -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
if find "${DEB_STORAGE}/${release}" -maxdepth 1 -type f -name "*.deb" 2> /dev/null | grep -q .; then
[[ "${ADDING_PACKAGES}" == true ]] && adding_packages "${release}-utils" "/${release}" "release packages"
else
# workaround - add dummy package to not trigger error
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "${SCRIPTPATH}config/templates/example.deb" > /dev/null
fi
# adding release-specific utils
if find "${DEB_STORAGE}/extra/${release}-utils" -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
if find "${DEB_STORAGE}/extra/${release}-utils" -maxdepth 1 -type f -name "*.deb" 2> /dev/null | grep -q .; then
[[ "${ADDING_PACKAGES}" == true ]] && adding_packages "${release}-utils" "/extra/${release}-utils" "release utils"
else
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-utils" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-utils" "${SCRIPTPATH}config/templates/example.deb" > /dev/null
fi
COMPONENTS="${COMPONENTS} ${release}-utils"
# adding desktop
if find "${DEB_STORAGE}/extra/${release}-desktop" -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
if find "${DEB_STORAGE}/extra/${release}-desktop" -maxdepth 1 -type f -name "*.deb" 2> /dev/null | grep -q .; then
[[ "${ADDING_PACKAGES}" == true ]] && adding_packages "${release}-desktop" "/extra/${release}-desktop" "desktop"
else
# workaround - add dummy package to not trigger error
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" "${SCRIPTPATH}config/templates/example.deb" > /dev/null
fi
COMPONENTS="${COMPONENTS} ${release}-desktop"
@@ -111,21 +107,21 @@ addtorepo()
# publish
aptly publish \
-acquire-by-hash \
-passphrase="${GPG_PASS}" \
-origin="Armbian" \
-label="Armbian" \
-config="${SCRIPTPATH}config/${REPO_CONFIG}" \
-component="${COMPONENTS// /,}" \
-distribution="${release}" repo "${release}" ${COMPONENTS//main/} >/dev/null
-acquire-by-hash \
-passphrase="${GPG_PASS}" \
-origin="Armbian" \
-label="Armbian" \
-config="${SCRIPTPATH}config/${REPO_CONFIG}" \
-component="${COMPONENTS// /,}" \
-distribution="${release}" repo "${release}" ${COMPONENTS//main/} > /dev/null
if [[ $? -ne 0 ]]; then
display_alert "Publishing failed" "${release}" "err"
errors=$((errors+1))
errors=$((errors + 1))
exit 0
fi
else
errors=$((errors+1))
errors=$((errors + 1))
local err_txt=": All components must be present: main, utils and desktop for first build"
fi
@@ -152,14 +148,13 @@ addtorepo()
}
repo-manipulate()
{
# repository manipulation
# "show" displays packages in each repository
# "server" serve repository - useful for local diagnostics
# "unique" manually select which package should be removed from all repositories
# "update" search for new files in output/debs* to add them to repository
# "purge" leave only last 5 versions
repo-manipulate() {
# repository manipulation
# "show" displays packages in each repository
# "server" serve repository - useful for local diagnostics
# "unique" manually select which package should be removed from all repositories
# "update" search for new files in output/debs* to add them to repository
# "purge" leave only last 5 versions
local DISTROS=("stretch" "bionic" "buster" "bullseye" "focal" "hirsute" "impish" "jammy" "sid")
#local DISTROS=($(grep -rw config/distributions/*/ -e 'supported' | cut -d"/" -f3))
@@ -192,28 +187,27 @@ repo-manipulate()
while true; do
LIST=()
for release in "${DISTROS[@]}"; do
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" | tail -n +7) )
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" | tail -n +7) )
LIST+=($(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" | tail -n +7))
LIST+=($(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" | tail -n +7))
done
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" utils | tail -n +7) )
LIST=( $(echo "${LIST[@]}" | tr ' ' '\n' | sort -u))
LIST+=($(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" utils | tail -n +7))
LIST=($(echo "${LIST[@]}" | tr ' ' '\n' | sort -u))
new_list=()
# create a human readable menu
for ((n=0;n<$((${#LIST[@]}));n++));
do
new_list+=( "${LIST[$n]}" )
new_list+=( "" )
for ((n = 0; n < $((${#LIST[@]})); n++)); do
new_list+=("${LIST[$n]}")
new_list+=("")
done
LIST=("${new_list[@]}")
LIST_LENGTH=$((${#LIST[@]}/2));
LIST_LENGTH=$((${#LIST[@]} / 2))
exec 3>&1
TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "BACKTITLE" --no-collapse --title "Remove packages from repositories" --clear --menu "Delete" $((9+${LIST_LENGTH})) 82 65 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?;
TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "BACKTITLE" --no-collapse --title "Remove packages from repositories" --clear --menu "Delete" $((9 + ${LIST_LENGTH})) 82 65 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?
exec 3>&-
if [[ $exitstatus -eq 0 ]]; then
for release in "${DISTROS[@]}"; do
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "$TARGET_VERSION"
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" "$TARGET_VERSION"
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "$TARGET_VERSION"
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" "$TARGET_VERSION"
done
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "utils" "$TARGET_VERSION"
else
@@ -243,22 +237,22 @@ repo-manipulate()
exit 0
;;
purgeedge)
for release in "${DISTROS[@]}"; do
purgeedge)
for release in "${DISTROS[@]}"; do
repo-remove-old-packages "$release" "armhf" "3" "edge"
repo-remove-old-packages "$release" "arm64" "3" "edge"
repo-remove-old-packages "$release" "amd64" "3" "edge"
repo-remove-old-packages "$release" "all" "3" "edge"
aptly -config="${SCRIPTPATH}config/${REPO_CONFIG}" -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
done
exit 0
;;
done
exit 0
;;
purgesource)
\
purgesource)
for release in "${DISTROS[@]}"; do
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" 'Name (% *-source*)'
aptly -config="${SCRIPTPATH}config/${REPO_CONFIG}" -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
aptly -config="${SCRIPTPATH}config/${REPO_CONFIG}" -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
done
aptly db cleanup -config="${SCRIPTPATH}config/${REPO_CONFIG}" > /dev/null 2>&1
exit 0
@@ -294,12 +288,12 @@ repo-remove-old-packages() {
local pkg_name
count=0
pkg_name=$(echo "${pkg}" | cut -d_ -f1)
for subpkg in $(aptly repo search -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${repo}" "Name ($pkg_name)" | grep -v "ERROR: no results" | sort -rt '.' -nk4); do
((count+=1))
for subpkg in $(aptly repo search -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${repo}" "Name ($pkg_name)" | grep -v "ERROR: no results" | sort -rt '.' -nk4); do
((count += 1))
if [[ $count -gt $keep ]]; then
pkg_version=$(echo "${subpkg}" | cut -d_ -f2)
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${repo}" "Name ($pkg_name), Version (= $pkg_version)"
pkg_version=$(echo "${subpkg}" | cut -d_ -f2)
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${repo}" "Name ($pkg_name), Version (= $pkg_version)"
fi
done
done
done
}

View File

@@ -2,24 +2,23 @@
#
# * installs only basic packages
#
prepare_host_basic()
{
prepare_host_basic() {
# command:package1 package2 ...
# list of commands that are neeeded:packages where this command is
local check_pack install_pack
local checklist=(
"dialog:dialog"
"fuser:psmisc"
"getfacl:acl"
"uuid:uuid uuid-runtime"
"curl:curl"
"gpg:gnupg"
"gawk:gawk"
)
"dialog:dialog"
"fuser:psmisc"
"getfacl:acl"
"uuid:uuid uuid-runtime"
"curl:curl"
"gpg:gnupg"
"gawk:gawk"
)
for check_pack in "${checklist[@]}"; do
if ! which ${check_pack%:*} >/dev/null; then local install_pack+=${check_pack#*:}" "; fi
if ! which ${check_pack%:*} > /dev/null; then local install_pack+=${check_pack#*:}" "; fi
done
if [[ -n $install_pack ]]; then

View File

@@ -2,15 +2,20 @@
#
# * installation will break if we try to install when package manager is running
#
wait_for_package_manager()
{
wait_for_package_manager() {
# exit if package manager is running in the back
while true; do
if [[ "$(fuser /var/lib/dpkg/lock 2>/dev/null; echo $?)" != 1 && "$(fuser /var/lib/dpkg/lock-frontend 2>/dev/null; echo $?)" != 1 ]]; then
display_alert "Package manager is running in the background." "Please wait! Retrying in 30 sec" "wrn"
sleep 30
else
break
if [[ "$(
fuser /var/lib/dpkg/lock 2> /dev/null
echo $?
)" != 1 && "$(
fuser /var/lib/dpkg/lock-frontend 2> /dev/null
echo $?
)" != 1 ]]; then
display_alert "Package manager is running in the background." "Please wait! Retrying in 30 sec" "wrn"
sleep 30
else
break
fi
done
}

View File

@@ -4,8 +4,7 @@
# * creates directory structure
# * changes system settings
#
prepare_host()
{
prepare_host() {
display_alert "Preparing" "host" "info"
# The 'offline' variable must always be set to 'true' or 'false'
@@ -43,22 +42,22 @@ prepare_host()
systemd-container u-boot-tools udev unzip uuid-dev wget whiptail zip \
zlib1g-dev zstd fdisk"
if [[ $(dpkg --print-architecture) == amd64 ]]; then
if [[ $(dpkg --print-architecture) == amd64 ]]; then
hostdeps+=" distcc lib32ncurses-dev lib32stdc++6 libc6-i386"
grep -q i386 <(dpkg --print-foreign-architectures) || dpkg --add-architecture i386
hostdeps+=" distcc lib32ncurses-dev lib32stdc++6 libc6-i386"
grep -q i386 <(dpkg --print-foreign-architectures) || dpkg --add-architecture i386
elif [[ $(dpkg --print-architecture) == arm64 ]]; then
elif [[ $(dpkg --print-architecture) == arm64 ]]; then
hostdeps+="gcc-arm-none-eabi libc6 libc6-amd64-cross qemu"
hostdeps+="gcc-arm-none-eabi libc6 libc6-amd64-cross qemu"
else
else
display_alert "Please read documentation to set up proper compilation environment"
display_alert "https://www.armbian.com/using-armbian-tools/"
exit_with_error "Running this tool on non x86_64 build host is not supported"
display_alert "Please read documentation to set up proper compilation environment"
display_alert "https://www.armbian.com/using-armbian-tools/"
exit_with_error "Running this tool on non x86_64 build host is not supported"
fi
fi
# Add support for Ubuntu 20.04, 21.04 and Mint 20.x
if [[ $HOSTRELEASE =~ ^(focal|impish|hirsute|jammy|ulyana|ulyssa|bullseye|uma|una)$ ]]; then
@@ -109,128 +108,126 @@ prepare_host()
SYNC_CLOCK=no
fi
# Skip verification if you are working offline
if ! $offline; then
# warning: apt-cacher-ng will fail if installed and used both on host and in
# container/chroot environment with shared network
# set NO_APT_CACHER=yes to prevent installation errors in such case
if [[ $NO_APT_CACHER != yes ]]; then hostdeps+=" apt-cacher-ng"; fi
# warning: apt-cacher-ng will fail if installed and used both on host and in
# container/chroot environment with shared network
# set NO_APT_CACHER=yes to prevent installation errors in such case
if [[ $NO_APT_CACHER != yes ]]; then hostdeps+=" apt-cacher-ng"; fi
export EXTRA_BUILD_DEPS=""
call_extension_method "add_host_dependencies" <<- 'ADD_HOST_DEPENDENCIES'
*run before installing host dependencies*
you can add packages to install, space separated, to ${EXTRA_BUILD_DEPS} here.
ADD_HOST_DEPENDENCIES
export EXTRA_BUILD_DEPS=""
call_extension_method "add_host_dependencies" <<- 'ADD_HOST_DEPENDENCIES'
*run before installing host dependencies*
you can add packages to install, space separated, to ${EXTRA_BUILD_DEPS} here.
ADD_HOST_DEPENDENCIES
if [ -n "${EXTRA_BUILD_DEPS}" ]; then hostdeps+=" ${EXTRA_BUILD_DEPS}"; fi
if [ -n "${EXTRA_BUILD_DEPS}" ]; then hostdeps+=" ${EXTRA_BUILD_DEPS}"; fi
display_alert "Installing build dependencies"
# don't prompt for apt cacher selection
sudo echo "apt-cacher-ng apt-cacher-ng/tunnelenable boolean false" | sudo debconf-set-selections
display_alert "Installing build dependencies"
# don't prompt for apt cacher selection
sudo echo "apt-cacher-ng apt-cacher-ng/tunnelenable boolean false" | sudo debconf-set-selections
LOG_OUTPUT_FILE="${DEST}"/${LOG_SUBPATH}/hostdeps.log
install_pkg_deb "autoupdate $hostdeps"
unset LOG_OUTPUT_FILE
LOG_OUTPUT_FILE="${DEST}"/${LOG_SUBPATH}/hostdeps.log
install_pkg_deb "autoupdate $hostdeps"
unset LOG_OUTPUT_FILE
update-ccache-symlinks
update-ccache-symlinks
export FINAL_HOST_DEPS="$hostdeps ${EXTRA_BUILD_DEPS}"
call_extension_method "host_dependencies_ready" <<- 'HOST_DEPENDENCIES_READY'
*run after all host dependencies are installed*
At this point we can read `${FINAL_HOST_DEPS}`, but changing won't have any effect.
All the dependencies, including the default/core deps and the ones added via `${EXTRA_BUILD_DEPS}`
are installed at this point. The system clock has not yet been synced.
HOST_DEPENDENCIES_READY
export FINAL_HOST_DEPS="$hostdeps ${EXTRA_BUILD_DEPS}"
call_extension_method "host_dependencies_ready" <<- 'HOST_DEPENDENCIES_READY'
*run after all host dependencies are installed*
At this point we can read `${FINAL_HOST_DEPS}`, but changing won't have any effect.
All the dependencies, including the default/core deps and the ones added via `${EXTRA_BUILD_DEPS}`
are installed at this point. The system clock has not yet been synced.
HOST_DEPENDENCIES_READY
# sync clock
if [[ $SYNC_CLOCK != no ]]; then
display_alert "Syncing clock" "host" "info"
ntpdate -s "${NTP_SERVER:-pool.ntp.org}"
fi
# sync clock
if [[ $SYNC_CLOCK != no ]]; then
display_alert "Syncing clock" "host" "info"
ntpdate -s "${NTP_SERVER:-pool.ntp.org}"
fi
# create directory structure
mkdir -p "${SRC}"/{cache,output} "${USERPATCHES_PATH}"
if [[ -n $SUDO_USER ]]; then
chgrp --quiet sudo cache output "${USERPATCHES_PATH}"
# SGID bit on cache/sources breaks kernel dpkg packaging
chmod --quiet g+w,g+s output "${USERPATCHES_PATH}"
# fix existing permissions
find "${SRC}"/output "${USERPATCHES_PATH}" -type d ! -group sudo -exec chgrp --quiet sudo {} \;
find "${SRC}"/output "${USERPATCHES_PATH}" -type d ! -perm -g+w,g+s -exec chmod --quiet g+w,g+s {} \;
fi
mkdir -p "${DEST}"/debs-beta/extra "${DEST}"/debs/extra "${DEST}"/{config,debug,patch} "${USERPATCHES_PATH}"/overlay "${SRC}"/cache/{sources,hash,hash-beta,toolchain,utility,rootfs} "${SRC}"/.tmp
# create directory structure
mkdir -p "${SRC}"/{cache,output} "${USERPATCHES_PATH}"
if [[ -n $SUDO_USER ]]; then
chgrp --quiet sudo cache output "${USERPATCHES_PATH}"
# SGID bit on cache/sources breaks kernel dpkg packaging
chmod --quiet g+w,g+s output "${USERPATCHES_PATH}"
# fix existing permissions
find "${SRC}"/output "${USERPATCHES_PATH}" -type d ! -group sudo -exec chgrp --quiet sudo {} \;
find "${SRC}"/output "${USERPATCHES_PATH}" -type d ! -perm -g+w,g+s -exec chmod --quiet g+w,g+s {} \;
fi
mkdir -p "${DEST}"/debs-beta/extra "${DEST}"/debs/extra "${DEST}"/{config,debug,patch} "${USERPATCHES_PATH}"/overlay "${SRC}"/cache/{sources,hash,hash-beta,toolchain,utility,rootfs} "${SRC}"/.tmp
# build aarch64
if [[ $(dpkg --print-architecture) == amd64 ]]; then
if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" != "yes" ]]; then
# build aarch64
if [[ $(dpkg --print-architecture) == amd64 ]]; then
if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" != "yes" ]]; then
# bind mount toolchain if defined
if [[ -d "${ARMBIAN_CACHE_TOOLCHAIN_PATH}" ]]; then
mountpoint -q "${SRC}"/cache/toolchain && umount -l "${SRC}"/cache/toolchain
mount --bind "${ARMBIAN_CACHE_TOOLCHAIN_PATH}" "${SRC}"/cache/toolchain
fi
# bind mount toolchain if defined
if [[ -d "${ARMBIAN_CACHE_TOOLCHAIN_PATH}" ]]; then
mountpoint -q "${SRC}"/cache/toolchain && umount -l "${SRC}"/cache/toolchain
mount --bind "${ARMBIAN_CACHE_TOOLCHAIN_PATH}" "${SRC}"/cache/toolchain
fi
display_alert "Checking for external GCC compilers" "" "info"
# download external Linaro compiler and missing special dependencies since they are needed for certain sources
display_alert "Checking for external GCC compilers" "" "info"
# download external Linaro compiler and missing special dependencies since they are needed for certain sources
local toolchains=(
"gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz"
"gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz"
"gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz"
"gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi.tar.xz"
"gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz"
"gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz"
"gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz"
"gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz"
"gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"
"gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz"
"gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz"
local toolchains=(
"gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz"
"gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz"
"gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz"
"gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi.tar.xz"
"gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz"
"gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz"
"gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz"
"gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz"
"gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"
"gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz"
"gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz"
)
USE_TORRENT_STATUS=${USE_TORRENT}
USE_TORRENT="no"
for toolchain in ${toolchains[@]}; do
local toolchain_zip="${SRC}/cache/toolchain/${toolchain}"
local toolchain_dir="${toolchain_zip%.tar.*}"
if [[ ! -f "${toolchain_dir}/.download-complete" ]]; then
download_and_verify "toolchain" "${toolchain}" \
|| exit_with_error "Failed to download toolchain" "${toolchain}"
display_alert "decompressing"
pv -p -b -r -c -N "[ .... ] ${toolchain}" "${toolchain_zip}" \
| xz -dc \
| tar xp --xattrs --no-same-owner --overwrite -C "${SRC}/cache/toolchain/"
if [[ $? -ne 0 ]]; then
rm -rf "${toolchain_dir}"
exit_with_error "Failed to decompress toolchain" "${toolchain}"
fi
touch "${toolchain_dir}/.download-complete"
rm -rf "${toolchain_zip}"* # Also delete asc file
fi
done
USE_TORRENT=${USE_TORRENT_STATUS}
local existing_dirs=( $(ls -1 "${SRC}"/cache/toolchain) )
for dir in ${existing_dirs[@]}; do
local found=no
USE_TORRENT_STATUS=${USE_TORRENT}
USE_TORRENT="no"
for toolchain in ${toolchains[@]}; do
[[ $dir == ${toolchain%.tar.*} ]] && found=yes
done
if [[ $found == no ]]; then
display_alert "Removing obsolete toolchain" "$dir"
rm -rf "${SRC}/cache/toolchain/${dir}"
fi
done
else
display_alert "Ignoring toolchains" "SKIP_EXTERNAL_TOOLCHAINS: ${SKIP_EXTERNAL_TOOLCHAINS}" "info"
fi
fi
local toolchain_zip="${SRC}/cache/toolchain/${toolchain}"
local toolchain_dir="${toolchain_zip%.tar.*}"
if [[ ! -f "${toolchain_dir}/.download-complete" ]]; then
download_and_verify "toolchain" "${toolchain}" ||
exit_with_error "Failed to download toolchain" "${toolchain}"
fi # check offline
display_alert "decompressing"
pv -p -b -r -c -N "[ .... ] ${toolchain}" "${toolchain_zip}" |
xz -dc |
tar xp --xattrs --no-same-owner --overwrite -C "${SRC}/cache/toolchain/"
if [[ $? -ne 0 ]]; then
rm -rf "${toolchain_dir}"
exit_with_error "Failed to decompress toolchain" "${toolchain}"
fi
touch "${toolchain_dir}/.download-complete"
rm -rf "${toolchain_zip}"* # Also delete asc file
fi
done
USE_TORRENT=${USE_TORRENT_STATUS}
local existing_dirs=($(ls -1 "${SRC}"/cache/toolchain))
for dir in ${existing_dirs[@]}; do
local found=no
for toolchain in ${toolchains[@]}; do
[[ $dir == ${toolchain%.tar.*} ]] && found=yes
done
if [[ $found == no ]]; then
display_alert "Removing obsolete toolchain" "$dir"
rm -rf "${SRC}/cache/toolchain/${dir}"
fi
done
else
display_alert "Ignoring toolchains" "SKIP_EXTERNAL_TOOLCHAINS: ${SKIP_EXTERNAL_TOOLCHAINS}" "info"
fi
fi
fi # check offline
# enable arm binary format so that the cross-architecture chroot environment will work
if [[ $KERNEL_ONLY != yes ]]; then
@@ -254,9 +251,9 @@ prepare_host()
fi
# check free space (basic)
local freespace=$(findmnt --target "${SRC}" -n -o AVAIL -b 2>/dev/null) # in bytes
if [[ -n $freespace && $(( $freespace / 1073741824 )) -lt 10 ]]; then
display_alert "Low free space left" "$(( $freespace / 1073741824 )) GiB" "wrn"
local freespace=$(findmnt --target "${SRC}" -n -o AVAIL -b 2> /dev/null) # in bytes
if [[ -n $freespace && $(($freespace / 1073741824)) -lt 10 ]]; then
display_alert "Low free space left" "$(($freespace / 1073741824)) GiB" "wrn"
# pause here since dialog-based menu will hide this message otherwise
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
read

View File

@@ -2,48 +2,47 @@
# fingerprint_image <out_txt_file> [image_filename]
# Saving build summary to the image
#--------------------------------------------------------------------------------------------------------------------------------
fingerprint_image()
{
cat <<-EOF > "${1}"
--------------------------------------------------------------------------------
Title: ${VENDOR} $REVISION ${BOARD^} $BRANCH
Kernel: Linux $VER
Build date: $(date +'%d.%m.%Y')
Builder rev: $BUILD_REPOSITORY_COMMIT
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Authors: https://www.armbian.com/authors
Sources: https://github.com/armbian/
Support: https://forum.armbian.com/
Changelog: https://www.armbian.com/logbook/
Documantation: https://docs.armbian.com/
fingerprint_image() {
cat <<- EOF > "${1}"
--------------------------------------------------------------------------------
Title: ${VENDOR} $REVISION ${BOARD^} $BRANCH
Kernel: Linux $VER
Build date: $(date +'%d.%m.%Y')
Builder rev: $BUILD_REPOSITORY_COMMIT
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
Authors: https://www.armbian.com/authors
Sources: https://github.com/armbian/
Support: https://forum.armbian.com/
Changelog: https://www.armbian.com/logbook/
Documantation: https://docs.armbian.com/
EOF
if [ -n "$2" ]; then
cat <<-EOF >> "${1}"
--------------------------------------------------------------------------------
Partitioning configuration: $IMAGE_PARTITION_TABLE offset: $OFFSET
Boot partition type: ${BOOTFS_TYPE:-(none)} ${BOOTSIZE:+"(${BOOTSIZE} MB)"}
Root partition type: $ROOTFS_TYPE ${FIXED_IMAGE_SIZE:+"(${FIXED_IMAGE_SIZE} MB)"}
cat <<- EOF >> "${1}"
--------------------------------------------------------------------------------
Partitioning configuration: $IMAGE_PARTITION_TABLE offset: $OFFSET
Boot partition type: ${BOOTFS_TYPE:-(none)} ${BOOTSIZE:+"(${BOOTSIZE} MB)"}
Root partition type: $ROOTFS_TYPE ${FIXED_IMAGE_SIZE:+"(${FIXED_IMAGE_SIZE} MB)"}
CPU configuration: $CPUMIN - $CPUMAX with $GOVERNOR
--------------------------------------------------------------------------------
Verify GPG signature:
gpg --verify $2.img.xz.asc
CPU configuration: $CPUMIN - $CPUMAX with $GOVERNOR
--------------------------------------------------------------------------------
Verify GPG signature:
gpg --verify $2.img.xz.asc
Verify image file integrity:
sha256sum --check $2.img.xz.sha
Verify image file integrity:
sha256sum --check $2.img.xz.sha
Prepare SD card (four methods):
xzcat $2.img.xz | pv | dd of=/dev/mmcblkX bs=1M
dd if=$2.img of=/dev/mmcblkX bs=1M
balena-etcher $2.img.xz -d /dev/mmcblkX
balena-etcher $2.img -d /dev/mmcblkX
Prepare SD card (four methods):
xzcat $2.img.xz | pv | dd of=/dev/mmcblkX bs=1M
dd if=$2.img of=/dev/mmcblkX bs=1M
balena-etcher $2.img.xz -d /dev/mmcblkX
balena-etcher $2.img -d /dev/mmcblkX
EOF
fi
cat <<-EOF >> "${1}"
--------------------------------------------------------------------------------
$(cat "${SRC}"/LICENSE)
--------------------------------------------------------------------------------
cat <<- EOF >> "${1}"
--------------------------------------------------------------------------------
$(cat "${SRC}"/LICENSE)
--------------------------------------------------------------------------------
EOF
}

View File

@@ -12,8 +12,7 @@
# path instead of $SDCARD (which can be a tmpfs and breaks cryptsetup-initramfs).
# see: https://github.com/armbian/build/issues/1584
#
update_initramfs()
{
update_initramfs() {
local chroot_target=$1
local target_dir=$(
find ${chroot_target}/lib/modules/ -maxdepth 1 -type d -name "*${VER}*"

View File

@@ -1,7 +1,6 @@
# check_loop_device <device_node>
#
check_loop_device()
{
check_loop_device() {
local device=$1
if [[ ! -b $device ]]; then
@@ -17,8 +16,7 @@ check_loop_device()
# write_uboot <loopdev>
#
write_uboot()
{
write_uboot() {
local loop=$1 revision
display_alert "Writing U-boot bootloader" "$loop" "info"

View File

@@ -4,8 +4,7 @@
# and mounts it to local dir
# FS-dependent stuff (boot and root fs partition types) happens here
#
prepare_partitions()
{
prepare_partitions() {
display_alert "Preparing image file for rootfs" "$BOARD $RELEASE" "info"
# possible partition combinations
@@ -32,7 +31,7 @@ prepare_partitions()
# create bigger number for desktop builds
if [[ $BUILD_DESKTOP == yes ]]; then local node_number=4096; else local node_number=1024; fi
if [[ $HOSTRELEASE =~ buster|bullseye|focal|jammy|sid ]]; then
mkopts[ext4]="-q -m 2 -O ^64bit,^metadata_csum -N $((128*${node_number}))"
mkopts[ext4]="-q -m 2 -O ^64bit,^metadata_csum -N $((128 * ${node_number}))"
fi
# mkopts[fat] is empty
mkopts[ext2]='-q'
@@ -66,7 +65,7 @@ prepare_partitions()
# mountopts[nfs] is empty
# default BOOTSIZE to use if not specified
DEFAULT_BOOTSIZE=256 # MiB
DEFAULT_BOOTSIZE=256 # MiB
# size of UEFI partition. 0 for no UEFI. Don't mix UEFISIZE>0 and BOOTSIZE>0
UEFISIZE=${UEFISIZE:-0}
BIOSSIZE=${BIOSSIZE:-0}
@@ -75,7 +74,7 @@ prepare_partitions()
ROOT_FS_LABEL="${ROOT_FS_LABEL:-armbi_root}"
BOOT_FS_LABEL="${BOOT_FS_LABEL:-armbi_boot}"
call_extension_method "pre_prepare_partitions" "prepare_partitions_custom" <<'PRE_PREPARE_PARTITIONS'
call_extension_method "pre_prepare_partitions" "prepare_partitions_custom" << 'PRE_PREPARE_PARTITIONS'
*allow custom options for mkfs*
Good time to change stuff like mkfs opts, types etc.
PRE_PREPARE_PARTITIONS
@@ -89,20 +88,20 @@ PRE_PREPARE_PARTITIONS
# Check if we need BIOS partition
[[ $BIOSSIZE -gt 0 ]] && local biospart=14
else
local uefipart=$(( next++ ))
local uefipart=$((next++))
fi
fi
# Check if we need boot partition
if [[ -n $BOOTFS_TYPE || $ROOTFS_TYPE != ext4 || $CRYPTROOT_ENABLE == yes ]]; then
local bootpart=$(( next++ ))
local bootpart=$((next++))
local bootfs=${BOOTFS_TYPE:-ext4}
[[ -z $BOOTSIZE || $BOOTSIZE -le 8 ]] && BOOTSIZE=${DEFAULT_BOOTSIZE}
else
BOOTSIZE=0
fi
# Check if we need root partition
[[ $ROOTFS_TYPE != nfs ]] \
&& local rootpart=$(( next++ ))
[[ $ROOTFS_TYPE != nfs ]] &&
local rootpart=$((next++))
# stage: calculate rootfs size
export rootfs_size=$(du -sm $SDCARD/ | cut -f1) # MiB
@@ -124,7 +123,7 @@ PREPARE_IMAGE_SIZE
exit_with_error "User defined image size is too small" "$sdsize <= $rootfs_size"
fi
else
local imagesize=$(( $rootfs_size + $OFFSET + $BOOTSIZE + $UEFISIZE + $EXTRA_ROOTFS_MIB_SIZE)) # MiB
local imagesize=$(($rootfs_size + $OFFSET + $BOOTSIZE + $UEFISIZE + $EXTRA_ROOTFS_MIB_SIZE)) # MiB
# Hardcoded overhead +25% is needed for desktop images,
# for CLI it could be lower. Align the size up to 4MiB
if [[ $BUILD_DESKTOP == yes ]]; then
@@ -140,54 +139,54 @@ PREPARE_IMAGE_SIZE
truncate --size=${sdsize}M ${SDCARD}.raw # sometimes results in fs corruption, revert to previous know to work solution
sync
else
dd if=/dev/zero bs=1M status=none count=$sdsize | pv -p -b -r -s $(( $sdsize * 1024 * 1024 )) -N "[ .... ] dd" | dd status=none of=${SDCARD}.raw
dd if=/dev/zero bs=1M status=none count=$sdsize | pv -p -b -r -s $(($sdsize * 1024 * 1024)) -N "[ .... ] dd" | dd status=none of=${SDCARD}.raw
fi
# stage: create partition table
display_alert "Creating partitions" "${bootfs:+/boot: $bootfs }root: $ROOTFS_TYPE" "info"
if [[ "${USE_HOOK_FOR_PARTITION}" == "yes" ]]; then
{
[[ "$IMAGE_PARTITION_TABLE" == "msdos" ]] \
&& echo "label: dos" \
|| echo "label: $IMAGE_PARTITION_TABLE"
} | sfdisk ${SDCARD}.raw >>"${DEST}/${LOG_SUBPATH}/install.log" 2>&1 \
|| exit_with_error "Create partition table fail. Please check" "${DEST}/${LOG_SUBPATH}/install.log"
[[ "$IMAGE_PARTITION_TABLE" == "msdos" ]] &&
echo "label: dos" ||
echo "label: $IMAGE_PARTITION_TABLE"
} | sfdisk ${SDCARD}.raw >> "${DEST}/${LOG_SUBPATH}/install.log" 2>&1 ||
exit_with_error "Create partition table fail. Please check" "${DEST}/${LOG_SUBPATH}/install.log"
call_extension_method "create_partition_table" <<- 'CREATE_PARTITION_TABLE'
*only called when USE_HOOK_FOR_PARTITION=yes to create the complete partition table*
Finally, we can get our own partition table. You have to partition ${SDCARD}.raw
yourself. Good luck.
*only called when USE_HOOK_FOR_PARTITION=yes to create the complete partition table*
Finally, we can get our own partition table. You have to partition ${SDCARD}.raw
yourself. Good luck.
CREATE_PARTITION_TABLE
else
{
[[ "$IMAGE_PARTITION_TABLE" == "msdos" ]] \
&& echo "label: dos" \
|| echo "label: $IMAGE_PARTITION_TABLE"
[[ "$IMAGE_PARTITION_TABLE" == "msdos" ]] &&
echo "label: dos" ||
echo "label: $IMAGE_PARTITION_TABLE"
local next=$OFFSET
if [[ -n "$biospart" ]]; then
# gpt: BIOS boot
local type="21686148-6449-6E6F-744E-656564454649"
echo "$biospart : name=\"bios\", start=${next}MiB, size=${BIOSSIZE}MiB, type=${type}"
local next=$(( $next + $BIOSSIZE ))
local next=$(($next + $BIOSSIZE))
fi
if [[ -n "$uefipart" ]]; then
# dos: EFI (FAT-12/16/32)
# gpt: EFI System
[[ "$IMAGE_PARTITION_TABLE" != "gpt" ]] \
&& local type="ef" \
|| local type="C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
[[ "$IMAGE_PARTITION_TABLE" != "gpt" ]] &&
local type="ef" ||
local type="C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
echo "$uefipart : name=\"efi\", start=${next}MiB, size=${UEFISIZE}MiB, type=${type}"
local next=$(( $next + $UEFISIZE ))
local next=$(($next + $UEFISIZE))
fi
if [[ -n "$bootpart" ]]; then
# Linux extended boot
[[ "$IMAGE_PARTITION_TABLE" != "gpt" ]] \
&& local type="ea" \
|| local type="BC13C2FF-59E6-4262-A352-B275FD6F7172"
[[ "$IMAGE_PARTITION_TABLE" != "gpt" ]] &&
local type="ea" ||
local type="BC13C2FF-59E6-4262-A352-B275FD6F7172"
if [[ -n "$rootpart" ]]; then
echo "$bootpart : name=\"bootfs\", start=${next}MiB, size=${BOOTSIZE}MiB, type=${type}"
local next=$(( $next + $BOOTSIZE ))
local next=$(($next + $BOOTSIZE))
else
# no `size` argument mean "as much as possible"
echo "$bootpart : name=\"bootfs\", start=${next}MiB, type=${type}"
@@ -196,23 +195,23 @@ PREPARE_IMAGE_SIZE
if [[ -n "$rootpart" ]]; then
# dos: Linux
# gpt: Linux filesystem
[[ "$IMAGE_PARTITION_TABLE" != "gpt" ]] \
&& local type="83" \
|| local type="0FC63DAF-8483-4772-8E79-3D69D8477DE4"
[[ "$IMAGE_PARTITION_TABLE" != "gpt" ]] &&
local type="83" ||
local type="0FC63DAF-8483-4772-8E79-3D69D8477DE4"
# no `size` argument mean "as much as possible"
echo "$rootpart : name=\"rootfs\", start=${next}MiB, type=${type}"
fi
} | sfdisk ${SDCARD}.raw >>"${DEST}/${LOG_SUBPATH}/install.log" 2>&1 \
|| exit_with_error "Partition fail. Please check" "${DEST}/${LOG_SUBPATH}/install.log"
} | sfdisk ${SDCARD}.raw >> "${DEST}/${LOG_SUBPATH}/install.log" 2>&1 ||
exit_with_error "Partition fail. Please check" "${DEST}/${LOG_SUBPATH}/install.log"
fi
call_extension_method "post_create_partitions" <<- 'POST_CREATE_PARTITIONS'
*called after all partitions are created, but not yet formatted*
*called after all partitions are created, but not yet formatted*
POST_CREATE_PARTITIONS
# stage: mount image
# lock access to loop devices
exec {FD}>/var/lock/armbian-debootstrap-losetup
exec {FD}> /var/lock/armbian-debootstrap-losetup
flock -x $FD
LOOP=$(losetup -f)
@@ -274,16 +273,16 @@ PREPARE_IMAGE_SIZE
if [[ -n $uefipart ]]; then
display_alert "Creating EFI partition" "FAT32 ${UEFI_MOUNT_POINT} on ${LOOP}p${uefipart} label ${UEFI_FS_LABEL}"
check_loop_device "${LOOP}p${uefipart}"
mkfs.fat -F32 -n "${UEFI_FS_LABEL}" ${LOOP}p${uefipart} >>"${DEST}"/debug/install.log 2>&1
mkfs.fat -F32 -n "${UEFI_FS_LABEL}" ${LOOP}p${uefipart} >> "${DEST}"/debug/install.log 2>&1
mkdir -p "${MOUNT}${UEFI_MOUNT_POINT}"
mount ${LOOP}p${uefipart} "${MOUNT}${UEFI_MOUNT_POINT}"
echo "UUID=$(blkid -s UUID -o value ${LOOP}p${uefipart}) ${UEFI_MOUNT_POINT} vfat defaults 0 2" >>$SDCARD/etc/fstab
echo "UUID=$(blkid -s UUID -o value ${LOOP}p${uefipart}) ${UEFI_MOUNT_POINT} vfat defaults 0 2" >> $SDCARD/etc/fstab
fi
echo "tmpfs /tmp tmpfs defaults,nosuid 0 0" >> $SDCARD/etc/fstab
call_extension_method "format_partitions" <<- 'FORMAT_PARTITIONS'
*if you created your own partitions, this would be a good time to format them*
The loop device is mounted, so ${LOOP}p1 is it's first partition etc.
*if you created your own partitions, this would be a good time to format them*
The loop device is mounted, so ${LOOP}p1 is it's first partition etc.
FORMAT_PARTITIONS
# stage: adjust boot script or boot environment
@@ -310,7 +309,7 @@ PREPARE_IMAGE_SIZE
else
sed -i 's/^setenv rootdev .*/setenv rootdev "'$rootfs'"/' $SDCARD/boot/boot.ini
fi
if [[ $LINUXFAMILY != meson64 ]]; then
if [[ $LINUXFAMILY != meson64 ]]; then
[[ -f $SDCARD/boot/armbianEnv.txt ]] && rm $SDCARD/boot/armbianEnv.txt
fi
fi
@@ -321,7 +320,7 @@ PREPARE_IMAGE_SIZE
sed -i "s/^console=.*/console=$DEFAULT_CONSOLE/" $SDCARD/boot/armbianEnv.txt
else
echo "console=$DEFAULT_CONSOLE" >> $SDCARD/boot/armbianEnv.txt
fi
fi
fi
# recompile .cmd to .scr if boot.cmd exists
@@ -331,7 +330,6 @@ PREPARE_IMAGE_SIZE
mkimage -C none -A arm -T script -d $SDCARD/boot/boot.cmd $SDCARD/boot/$BOOTSCRIPT_OUTPUT > /dev/null 2>&1
fi
# create extlinux config
if [[ -f $SDCARD/boot/extlinux/extlinux.conf ]]; then
echo " append root=$rootfs $SRC_CMDLINE $MAIN_CMDLINE" >> $SDCARD/boot/extlinux/extlinux.conf

View File

@@ -2,8 +2,7 @@
#
# finishes creation of image from cached rootfs
#
create_image()
{
create_image() {
# create DESTIMG, hooks might put stuff there early.
mkdir -p $DESTIMG
@@ -15,15 +14,15 @@ create_image()
if [[ $ROOTFS_TYPE != nfs ]]; then
display_alert "Copying files to" "/"
echo -e "\nCopying files to [/]" >>"${DEST}"/${LOG_SUBPATH}/install.log
echo -e "\nCopying files to [/]" >> "${DEST}"/${LOG_SUBPATH}/install.log
rsync -aHWXh \
--exclude="/boot/*" \
--exclude="/dev/*" \
--exclude="/proc/*" \
--exclude="/run/*" \
--exclude="/tmp/*" \
--exclude="/sys/*" \
--info=progress0,stats1 $SDCARD/ $MOUNT/ >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
--exclude="/boot/*" \
--exclude="/dev/*" \
--exclude="/proc/*" \
--exclude="/run/*" \
--exclude="/tmp/*" \
--exclude="/sys/*" \
--info=progress0,stats1 $SDCARD/ $MOUNT/ >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
else
display_alert "Creating rootfs archive" "rootfs.tgz" "info"
tar cp --xattrs --directory=$SDCARD/ --exclude='./boot/*' --exclude='./dev/*' --exclude='./proc/*' --exclude='./run/*' --exclude='./tmp/*' \
@@ -32,17 +31,17 @@ create_image()
# stage: rsync /boot
display_alert "Copying files to" "/boot"
echo -e "\nCopying files to [/boot]" >>"${DEST}"/${LOG_SUBPATH}/install.log
echo -e "\nCopying files to [/boot]" >> "${DEST}"/${LOG_SUBPATH}/install.log
if [[ $(findmnt --target $MOUNT/boot -o FSTYPE -n) == vfat ]]; then
# fat32
rsync -rLtWh \
--info=progress0,stats1 \
--log-file="${DEST}"/${LOG_SUBPATH}/install.log $SDCARD/boot $MOUNT
--info=progress0,stats1 \
--log-file="${DEST}"/${LOG_SUBPATH}/install.log $SDCARD/boot $MOUNT
else
# ext4
rsync -aHWXh \
--info=progress0,stats1 \
--log-file="${DEST}"/${LOG_SUBPATH}/install.log $SDCARD/boot $MOUNT
--info=progress0,stats1 \
--log-file="${DEST}"/${LOG_SUBPATH}/install.log $SDCARD/boot $MOUNT
fi
call_extension_method "pre_update_initramfs" "config_pre_update_initramfs" << 'PRE_UPDATE_INITRAMFS'
@@ -64,9 +63,9 @@ PRE_UPDATE_INITRAMFS
# stage: write u-boot, unless the deb is not there, which would happen if BOOTCONFIG=none
# exception: if we use the one from repository, install version which was downloaded from repo
if [[ -f "${DEB_STORAGE}"/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
write_uboot $LOOP
write_uboot $LOOP
elif [[ "${UPSTREM_VER}" ]]; then
write_uboot $LOOP
write_uboot $LOOP
fi
# fix wrong / permissions
@@ -79,8 +78,8 @@ PRE_UMOUNT_FINAL_IMAGE
# Check the partition table after the uboot code has been written
# and print to the log file.
echo -e "\nPartition table after write_uboot $LOOP" >>$DEST/${LOG_SUBPATH}/debootstrap.log
sfdisk -l $LOOP >>$DEST/${LOG_SUBPATH}/debootstrap.log
echo -e "\nPartition table after write_uboot $LOOP" >> $DEST/${LOG_SUBPATH}/debootstrap.log
sfdisk -l $LOOP >> $DEST/${LOG_SUBPATH}/debootstrap.log
# unmount /boot/efi first, then /boot, rootfs third, image file last
sync
@@ -95,8 +94,7 @@ Called after unmounting both `/root` and `/boot`.
POST_UMOUNT_FINAL_IMAGE
# to make sure its unmounted
while grep -Eq '(${MOUNT}|${DESTIMG})' /proc/mounts
do
while grep -Eq '(${MOUNT}|${DESTIMG})' /proc/mounts; do
display_alert "Wait for unmount" "${MOUNT}" "info"
sleep 5
done
@@ -129,7 +127,7 @@ POST_UMOUNT_FINAL_IMAGE
display_alert "Compressing" "${DESTIMG}/${version}.img.xz" "info"
# compressing consumes a lot of memory we don't have. Waiting for previous packing job to finish helps to run a lot more builds in parallel
available_cpu=$(grep -c 'processor' /proc/cpuinfo)
[[ ${available_cpu} -gt 16 ]] && available_cpu=16 # using more cpu cores for compressing is pointless
[[ ${available_cpu} -gt 16 ]] && available_cpu=16 # using more cpu cores for compressing is pointless
available_mem=$(LC_ALL=c free | grep Mem | awk '{print $4/$2 * 100.0}' | awk '{print int($1)}') # in percentage
# build optimisations when memory drops below 5%
pixz -7 -p ${available_cpu} -f $(expr ${available_cpu} + 2) < $DESTIMG/${version}.img > ${DESTIMG}/${version}.img.xz
@@ -137,7 +135,7 @@ POST_UMOUNT_FINAL_IMAGE
fi
if [[ $COMPRESS_OUTPUTIMAGE == *img* || $COMPRESS_OUTPUTIMAGE == *7z* ]]; then
# mv $DESTIMG/${version}.img ${FINALDEST}/${version}.img || exit 1
# mv $DESTIMG/${version}.img ${FINALDEST}/${version}.img || exit 1
compression_type=""
fi
@@ -168,10 +166,10 @@ POST_UMOUNT_FINAL_IMAGE
if [[ $COMPRESS_OUTPUTIMAGE == *7z* ]]; then
display_alert "Compressing" "${DESTIMG}/${version}.7z" "info"
7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on \
${DESTIMG}/${version}.7z ${version}.key ${version}.img* >/dev/null 2>&1
${DESTIMG}/${version}.7z ${version}.key ${version}.img* > /dev/null 2>&1
find ${DESTIMG}/ -type \
f \( -name "${version}.img" -o -name "${version}.img.asc" -o -name "${version}.img.txt" -o -name "${version}.img.sha" \) -print0 \
| xargs -0 rm >/dev/null 2>&1
f \( -name "${version}.img" -o -name "${version}.img.asc" -o -name "${version}.img.txt" -o -name "${version}.img.sha" \) -print0 |
xargs -0 rm > /dev/null 2>&1
fi
fi
@@ -179,7 +177,7 @@ POST_UMOUNT_FINAL_IMAGE
# Previously, post_build_image passed the .img path as an argument to the hook. Now its an ENV var.
export FINAL_IMAGE_FILE="${DESTIMG}/${version}.img"
call_extension_method "post_build_image" << 'POST_BUILD_IMAGE'
call_extension_method "post_build_image" << 'POST_BUILD_IMAGE'
*custom post build hook*
Called after the final .img file is built, before it is (possibly) written to an SD writer.
- *NOTE*: this hook used to take an argument ($1) for the final image produced.
@@ -193,7 +191,7 @@ POST_BUILD_IMAGE
rm -rf --one-file-system $DESTIMG
# write image to SD card
if [[ $(lsblk "$CARD_DEVICE" 2>/dev/null) && -f ${FINALDEST}/${version}.img ]]; then
if [[ $(lsblk "$CARD_DEVICE" 2> /dev/null) && -f ${FINALDEST}/${version}.img ]]; then
# make sha256sum if it does not exists. we need it for comparisson
if [[ -f "${FINALDEST}/${version}".img.sha ]]; then
@@ -207,10 +205,10 @@ POST_BUILD_IMAGE
# write to SD card
pv -p -b -r -c -N "[ .... ] dd" ${FINALDEST}/${version}.img | dd of=$CARD_DEVICE bs=1M iflag=fullblock oflag=direct status=none
call_extension_method "post_write_sdcard" <<- 'POST_BUILD_IMAGE'
*run after writing img to sdcard*
After the image is written to `$CARD_DEVICE`, but before verifying it.
You can still set SKIP_VERIFY=yes to skip verification.
call_extension_method "post_write_sdcard" <<- 'POST_BUILD_IMAGE'
*run after writing img to sdcard*
After the image is written to `$CARD_DEVICE`, but before verifying it.
You can still set SKIP_VERIFY=yes to skip verification.
POST_BUILD_IMAGE
if [[ "${SKIP_VERIFY}" != "yes" ]]; then
@@ -223,7 +221,7 @@ POST_BUILD_IMAGE
display_alert "Writing failed" "${version}.img" "err"
fi
fi
elif [[ `systemd-detect-virt` == 'docker' && -n $CARD_DEVICE ]]; then
elif [[ $(systemd-detect-virt) == 'docker' && -n $CARD_DEVICE ]]; then
# display warning when we want to write sd card under Docker
display_alert "Can't write to $CARD_DEVICE" "Enable docker privileged mode in config-docker.conf" "wrn"
fi

View File

@@ -1,8 +1,7 @@
#--------------------------------------------------------------------------------------------------------------------------------
# Let's have unique way of displaying alerts
#--------------------------------------------------------------------------------------------------------------------------------
display_alert()
{
display_alert() {
# log function parameters to install.log
[[ -n "${DEST}" ]] && echo "Displaying message: $@" >> "${DEST}"/${LOG_SUBPATH}/output.log
@@ -11,24 +10,24 @@ display_alert()
case $3 in
err)
echo -e "[\e[0;31m error \x1B[0m] $1 $tmp"
;;
echo -e "[\e[0;31m error \x1B[0m] $1 $tmp"
;;
wrn)
echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp"
;;
echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp"
;;
ext)
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp"
;;
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp"
;;
info)
echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp"
;;
echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp"
;;
*)
echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp"
;;
echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp"
;;
esac
}
@@ -38,8 +37,7 @@ display_alert()
# The LOG_OUTPUT_FILE variable must be defined in the calling function
# before calling the `show_checklist_variables` function and unset after.
#
show_checklist_variables ()
{
show_checklist_variables() {
local checklist=$*
local var pval
local log_file=${LOG_OUTPUT_FILE:-"${SRC}"/output/${LOG_SUBPATH}/trash.log}
@@ -47,15 +45,15 @@ show_checklist_variables ()
local _function=${FUNCNAME[1]}
local _file=$(basename "${BASH_SOURCE[1]}")
echo -e "Show variables in function: $_function" "[$_file:$_line]\n" >>$log_file
echo -e "Show variables in function: $_function" "[$_file:$_line]\n" >> $log_file
for var in $checklist;do
for var in $checklist; do
eval pval=\$$var
echo -e "\n$var =:" >>$log_file
if [ $(echo "$pval" | awk -F"/" '{print NF}') -ge 4 ];then
printf "%s\n" $pval >>$log_file
echo -e "\n$var =:" >> $log_file
if [ $(echo "$pval" | awk -F"/" '{print NF}') -ge 4 ]; then
printf "%s\n" $pval >> $log_file
else
printf "%-30s %-30s %-30s %-30s\n" $pval >>$log_file
printf "%-30s %-30s %-30s %-30s\n" $pval >> $log_file
fi
done
}

View File

@@ -1,5 +1,4 @@
run_on_sdcard()
{
run_on_sdcard() {
# Lack of quotes allows for redirections and pipes easily.
chroot "${SDCARD}" /bin/bash -c "${@}" >> "${DEST}"/${LOG_SUBPATH}/install.log

View File

@@ -4,8 +4,7 @@
# with verbose error message
#
exit_with_error()
{
exit_with_error() {
local _file
local _line=${BASH_LINENO[0]}
local _function=${FUNCNAME[1]}
@@ -28,7 +27,7 @@ exit_with_error()
# TODO: execute run_after_build here?
overlayfs_wrapper "cleanup"
# unlock loop device access in case of starvation
exec {FD}>/var/lock/armbian-debootstrap-losetup
exec {FD}> /var/lock/armbian-debootstrap-losetup
flock -u "${FD}"
exit 255

View File

@@ -1,7 +1,6 @@
# unmount_on_exit
#
unmount_on_exit()
{
unmount_on_exit() {
trap - INT TERM EXIT
local stacktrace="$(get_extension_hook_stracktrace "${BASH_SOURCE[*]}" "${BASH_LINENO[*]}")"
@@ -17,12 +16,12 @@ unmount_on_exit()
umount_chroot "${SDCARD}/"
mountpoint -q "${SRC}"/cache/toolchain && umount -l "${SRC}"/cache/toolchain
mountpoint -q "${SRC}"/cache/rootfs && umount -l "${SRC}"/cache/rootfs
umount -l "${SDCARD}"/tmp >/dev/null 2>&1
umount -l "${SDCARD}" >/dev/null 2>&1
umount -l "${MOUNT}"/boot >/dev/null 2>&1
umount -l "${MOUNT}" >/dev/null 2>&1
umount -l "${SDCARD}"/tmp > /dev/null 2>&1
umount -l "${SDCARD}" > /dev/null 2>&1
umount -l "${MOUNT}"/boot > /dev/null 2>&1
umount -l "${MOUNT}" > /dev/null 2>&1
[[ $CRYPTROOT_ENABLE == yes ]] && cryptsetup luksClose "${ROOT_MAPPER}"
losetup -d "${LOOP}" >/dev/null 2>&1
losetup -d "${LOOP}" > /dev/null 2>&1
rm -rf --one-file-system "${SDCARD}"
exit_with_error "debootstrap-ng was interrupted" || true # don't trigger again
@@ -30,8 +29,7 @@ unmount_on_exit()
# debootstrap_ng
#
debootstrap_ng()
{
debootstrap_ng() {
display_alert "Checking for rootfs cache" "$(echo "${BRANCH} ${BOARD} ${RELEASE} ${DESKTOP_APPGROUPS_SELECTED} ${DESKTOP_ENVIRONMENT} ${BUILD_MINIMAL}" | tr -s " ")" "info"
[[ $ROOTFS_TYPE != ext4 ]] && display_alert "Assuming $BOARD $BRANCH kernel supports $ROOTFS_TYPE" "" "wrn"
@@ -52,9 +50,10 @@ debootstrap_ng()
# stage: verify tmpfs configuration and mount
# CLI needs ~1.5GiB, desktop - ~3.5GiB
# calculate and set tmpfs mount to use 9/10 of available RAM+SWAP
local phymem=$(( (($(awk '/MemTotal/ {print $2}' /proc/meminfo) + $(awk '/SwapTotal/ {print $2}' /proc/meminfo))) / 1024 * 9 / 10 )) # MiB
if [[ $BUILD_DESKTOP == yes ]]; then local tmpfs_max_size=3500; else local tmpfs_max_size=1500; fi # MiB
if [[ $FORCE_USE_RAMDISK == no ]]; then local use_tmpfs=no
local phymem=$(((($(awk '/MemTotal/ {print $2}' /proc/meminfo) + $(awk '/SwapTotal/ {print $2}' /proc/meminfo))) / 1024 * 9 / 10)) # MiB
if [[ $BUILD_DESKTOP == yes ]]; then local tmpfs_max_size=3500; else local tmpfs_max_size=1500; fi # MiB
if [[ $FORCE_USE_RAMDISK == no ]]; then
local use_tmpfs=no
elif [[ $FORCE_USE_RAMDISK == yes || $phymem -gt $tmpfs_max_size ]]; then
local use_tmpfs=yes
fi
@@ -88,11 +87,11 @@ PRE_INSTALL_DISTRIBUTION_SPECIFIC
# remove packages that are no longer needed. Since we have intrudoced uninstall feature, we might want to clean things that are no longer needed
display_alert "No longer needed packages" "purge" "info"
chroot $SDCARD /bin/bash -c "apt-get autoremove -y" >/dev/null 2>&1
chroot $SDCARD /bin/bash -c "apt-get autoremove -y" > /dev/null 2>&1
# create list of all installed packages for debug purposes
chroot $SDCARD /bin/bash -c "dpkg -l | grep ^ii | awk '{ print \$2\",\"\$3 }'" > $DEST/${LOG_SUBPATH}/installed-packages-${RELEASE}$([[ ${BUILD_MINIMAL} == yes ]] \
&& echo "-minimal")$([[ ${BUILD_DESKTOP} == yes ]] && echo "-desktop").list 2>&1
chroot $SDCARD /bin/bash -c "dpkg -l | grep ^ii | awk '{ print \$2\",\"\$3 }'" > $DEST/${LOG_SUBPATH}/installed-packages-${RELEASE}$([[ ${BUILD_MINIMAL} == yes ]] &&
echo "-minimal")$([[ ${BUILD_DESKTOP} == yes ]] && echo "-desktop").list 2>&1
# clean up / prepare for making the image
umount_chroot "$SDCARD"
@@ -110,8 +109,7 @@ PRE_INSTALL_DISTRIBUTION_SPECIFIC
# stage: unmount tmpfs
umount $SDCARD 2>&1
if [[ $use_tmpfs = yes ]]; then
while grep -qs "$SDCARD" /proc/mounts
do
while grep -qs "$SDCARD" /proc/mounts; do
umount $SDCARD
sleep 5
done

View File

@@ -1,5 +1,4 @@
install_deb_chroot()
{
install_deb_chroot() {
local package=$1
local variant=$2

View File

@@ -40,14 +40,14 @@ add_apt_sources() {
display_alert "Adding APT Source ${new_apt_source}"
if [[ "${new_apt_source}" == ppa* ]] ; then
if [[ "${new_apt_source}" == ppa* ]]; then
# ppa with software-common-properties
run_on_sdcard "add-apt-repository -y -n \"${new_apt_source}\""
# add list with apt-add
# -y -> Assumes yes to all queries
# -n -> Do not update package cache after adding
if [[ -f "${apt_source_gpg_filepath}" ]]; then
display_alert "Adding GPG Key ${apt_source_gpg_filepath}"
display_alert "Adding GPG Key ${apt_source_gpg_filepath}"
cp "${apt_source_gpg_filepath}" "${SDCARD}/tmp/${apt_source_gpg_filename}"
run_on_sdcard "apt-key add \"/tmp/${apt_source_gpg_filename}\""
echo "APT Key returned : $?"
@@ -57,7 +57,7 @@ add_apt_sources() {
echo "${new_apt_source}" > "${SDCARD}/etc/apt/sources.list.d/${apt_source_filename}"
if [[ -f "${apt_source_gpg_filepath}" ]]; then
display_alert "Adding GPG Key ${apt_source_gpg_filepath}"
# local apt_source_gpg_filename="$(basename ${apt_source_gpg_filepath})"
# local apt_source_gpg_filename="$(basename ${apt_source_gpg_filepath})"
mkdir -p "${SDCARD}"/usr/share/keyrings/
cp "${apt_source_gpg_filepath}" "${SDCARD}"/usr/share/keyrings/
fi

View File

@@ -2,9 +2,8 @@
# Create kernel boot logo from packages/blobs/splash/logo.png and packages/blobs/splash/spinner.gif (animated)
# and place to the file /lib/firmware/bootsplash
#--------------------------------------------------------------------------------------------------------------------------------
function boot_logo ()
{
display_alert "Building kernel splash logo" "$RELEASE" "info"
function boot_logo() {
display_alert "Building kernel splash logo" "$RELEASE" "info"
LOGO=${SRC}/packages/blobs/splash/logo.png
LOGO_WIDTH=$(identify $LOGO | cut -d " " -f 3 | cut -d x -f 1)
@@ -12,105 +11,105 @@ display_alert "Building kernel splash logo" "$RELEASE" "info"
THROBBER=${SRC}/packages/blobs/splash/spinner.gif
THROBBER_WIDTH=$(identify $THROBBER | head -1 | cut -d " " -f 3 | cut -d x -f 1)
THROBBER_HEIGHT=$(identify $THROBBER | head -1 | cut -d " " -f 3 | cut -d x -f 2)
convert -alpha remove -background "#000000" $LOGO "${SDCARD}"/tmp/logo.rgb
convert -alpha remove -background "#000000" $LOGO "${SDCARD}"/tmp/logo.rgb
convert -alpha remove -background "#000000" $THROBBER "${SDCARD}"/tmp/throbber%02d.rgb
$PKG_PREFIX${SRC}/packages/blobs/splash/bootsplash-packer \
--bg_red 0x00 \
--bg_green 0x00 \
--bg_blue 0x00 \
--frame_ms 48 \
--picture \
--pic_width $LOGO_WIDTH \
--pic_height $LOGO_HEIGHT \
--pic_position 0 \
--blob "${SDCARD}"/tmp/logo.rgb \
--picture \
--pic_width $THROBBER_WIDTH \
--pic_height $THROBBER_HEIGHT \
--pic_position 0x05 \
--pic_position_offset 200 \
--pic_anim_type 1 \
--pic_anim_loop 0 \
--blob "${SDCARD}"/tmp/throbber00.rgb \
--blob "${SDCARD}"/tmp/throbber01.rgb \
--blob "${SDCARD}"/tmp/throbber02.rgb \
--blob "${SDCARD}"/tmp/throbber03.rgb \
--blob "${SDCARD}"/tmp/throbber04.rgb \
--blob "${SDCARD}"/tmp/throbber05.rgb \
--blob "${SDCARD}"/tmp/throbber06.rgb \
--blob "${SDCARD}"/tmp/throbber07.rgb \
--blob "${SDCARD}"/tmp/throbber08.rgb \
--blob "${SDCARD}"/tmp/throbber09.rgb \
--blob "${SDCARD}"/tmp/throbber10.rgb \
--blob "${SDCARD}"/tmp/throbber11.rgb \
--blob "${SDCARD}"/tmp/throbber12.rgb \
--blob "${SDCARD}"/tmp/throbber13.rgb \
--blob "${SDCARD}"/tmp/throbber14.rgb \
--blob "${SDCARD}"/tmp/throbber15.rgb \
--blob "${SDCARD}"/tmp/throbber16.rgb \
--blob "${SDCARD}"/tmp/throbber17.rgb \
--blob "${SDCARD}"/tmp/throbber18.rgb \
--blob "${SDCARD}"/tmp/throbber19.rgb \
--blob "${SDCARD}"/tmp/throbber20.rgb \
--blob "${SDCARD}"/tmp/throbber21.rgb \
--blob "${SDCARD}"/tmp/throbber22.rgb \
--blob "${SDCARD}"/tmp/throbber23.rgb \
--blob "${SDCARD}"/tmp/throbber24.rgb \
--blob "${SDCARD}"/tmp/throbber25.rgb \
--blob "${SDCARD}"/tmp/throbber26.rgb \
--blob "${SDCARD}"/tmp/throbber27.rgb \
--blob "${SDCARD}"/tmp/throbber28.rgb \
--blob "${SDCARD}"/tmp/throbber29.rgb \
--blob "${SDCARD}"/tmp/throbber30.rgb \
--blob "${SDCARD}"/tmp/throbber31.rgb \
--blob "${SDCARD}"/tmp/throbber32.rgb \
--blob "${SDCARD}"/tmp/throbber33.rgb \
--blob "${SDCARD}"/tmp/throbber34.rgb \
--blob "${SDCARD}"/tmp/throbber35.rgb \
--blob "${SDCARD}"/tmp/throbber36.rgb \
--blob "${SDCARD}"/tmp/throbber37.rgb \
--blob "${SDCARD}"/tmp/throbber38.rgb \
--blob "${SDCARD}"/tmp/throbber39.rgb \
--blob "${SDCARD}"/tmp/throbber40.rgb \
--blob "${SDCARD}"/tmp/throbber41.rgb \
--blob "${SDCARD}"/tmp/throbber42.rgb \
--blob "${SDCARD}"/tmp/throbber43.rgb \
--blob "${SDCARD}"/tmp/throbber44.rgb \
--blob "${SDCARD}"/tmp/throbber45.rgb \
--blob "${SDCARD}"/tmp/throbber46.rgb \
--blob "${SDCARD}"/tmp/throbber47.rgb \
--blob "${SDCARD}"/tmp/throbber48.rgb \
--blob "${SDCARD}"/tmp/throbber49.rgb \
--blob "${SDCARD}"/tmp/throbber50.rgb \
--blob "${SDCARD}"/tmp/throbber51.rgb \
--blob "${SDCARD}"/tmp/throbber52.rgb \
--blob "${SDCARD}"/tmp/throbber53.rgb \
--blob "${SDCARD}"/tmp/throbber54.rgb \
--blob "${SDCARD}"/tmp/throbber55.rgb \
--blob "${SDCARD}"/tmp/throbber56.rgb \
--blob "${SDCARD}"/tmp/throbber57.rgb \
--blob "${SDCARD}"/tmp/throbber58.rgb \
--blob "${SDCARD}"/tmp/throbber59.rgb \
--blob "${SDCARD}"/tmp/throbber60.rgb \
--blob "${SDCARD}"/tmp/throbber61.rgb \
--blob "${SDCARD}"/tmp/throbber62.rgb \
--blob "${SDCARD}"/tmp/throbber63.rgb \
--blob "${SDCARD}"/tmp/throbber64.rgb \
--blob "${SDCARD}"/tmp/throbber65.rgb \
--blob "${SDCARD}"/tmp/throbber66.rgb \
--blob "${SDCARD}"/tmp/throbber67.rgb \
--blob "${SDCARD}"/tmp/throbber68.rgb \
--blob "${SDCARD}"/tmp/throbber69.rgb \
--blob "${SDCARD}"/tmp/throbber70.rgb \
--blob "${SDCARD}"/tmp/throbber71.rgb \
--blob "${SDCARD}"/tmp/throbber72.rgb \
--blob "${SDCARD}"/tmp/throbber73.rgb \
--blob "${SDCARD}"/tmp/throbber74.rgb \
"${SDCARD}"/lib/firmware/bootsplash.armbian >/dev/null 2>&1
--bg_red 0x00 \
--bg_green 0x00 \
--bg_blue 0x00 \
--frame_ms 48 \
--picture \
--pic_width $LOGO_WIDTH \
--pic_height $LOGO_HEIGHT \
--pic_position 0 \
--blob "${SDCARD}"/tmp/logo.rgb \
--picture \
--pic_width $THROBBER_WIDTH \
--pic_height $THROBBER_HEIGHT \
--pic_position 0x05 \
--pic_position_offset 200 \
--pic_anim_type 1 \
--pic_anim_loop 0 \
--blob "${SDCARD}"/tmp/throbber00.rgb \
--blob "${SDCARD}"/tmp/throbber01.rgb \
--blob "${SDCARD}"/tmp/throbber02.rgb \
--blob "${SDCARD}"/tmp/throbber03.rgb \
--blob "${SDCARD}"/tmp/throbber04.rgb \
--blob "${SDCARD}"/tmp/throbber05.rgb \
--blob "${SDCARD}"/tmp/throbber06.rgb \
--blob "${SDCARD}"/tmp/throbber07.rgb \
--blob "${SDCARD}"/tmp/throbber08.rgb \
--blob "${SDCARD}"/tmp/throbber09.rgb \
--blob "${SDCARD}"/tmp/throbber10.rgb \
--blob "${SDCARD}"/tmp/throbber11.rgb \
--blob "${SDCARD}"/tmp/throbber12.rgb \
--blob "${SDCARD}"/tmp/throbber13.rgb \
--blob "${SDCARD}"/tmp/throbber14.rgb \
--blob "${SDCARD}"/tmp/throbber15.rgb \
--blob "${SDCARD}"/tmp/throbber16.rgb \
--blob "${SDCARD}"/tmp/throbber17.rgb \
--blob "${SDCARD}"/tmp/throbber18.rgb \
--blob "${SDCARD}"/tmp/throbber19.rgb \
--blob "${SDCARD}"/tmp/throbber20.rgb \
--blob "${SDCARD}"/tmp/throbber21.rgb \
--blob "${SDCARD}"/tmp/throbber22.rgb \
--blob "${SDCARD}"/tmp/throbber23.rgb \
--blob "${SDCARD}"/tmp/throbber24.rgb \
--blob "${SDCARD}"/tmp/throbber25.rgb \
--blob "${SDCARD}"/tmp/throbber26.rgb \
--blob "${SDCARD}"/tmp/throbber27.rgb \
--blob "${SDCARD}"/tmp/throbber28.rgb \
--blob "${SDCARD}"/tmp/throbber29.rgb \
--blob "${SDCARD}"/tmp/throbber30.rgb \
--blob "${SDCARD}"/tmp/throbber31.rgb \
--blob "${SDCARD}"/tmp/throbber32.rgb \
--blob "${SDCARD}"/tmp/throbber33.rgb \
--blob "${SDCARD}"/tmp/throbber34.rgb \
--blob "${SDCARD}"/tmp/throbber35.rgb \
--blob "${SDCARD}"/tmp/throbber36.rgb \
--blob "${SDCARD}"/tmp/throbber37.rgb \
--blob "${SDCARD}"/tmp/throbber38.rgb \
--blob "${SDCARD}"/tmp/throbber39.rgb \
--blob "${SDCARD}"/tmp/throbber40.rgb \
--blob "${SDCARD}"/tmp/throbber41.rgb \
--blob "${SDCARD}"/tmp/throbber42.rgb \
--blob "${SDCARD}"/tmp/throbber43.rgb \
--blob "${SDCARD}"/tmp/throbber44.rgb \
--blob "${SDCARD}"/tmp/throbber45.rgb \
--blob "${SDCARD}"/tmp/throbber46.rgb \
--blob "${SDCARD}"/tmp/throbber47.rgb \
--blob "${SDCARD}"/tmp/throbber48.rgb \
--blob "${SDCARD}"/tmp/throbber49.rgb \
--blob "${SDCARD}"/tmp/throbber50.rgb \
--blob "${SDCARD}"/tmp/throbber51.rgb \
--blob "${SDCARD}"/tmp/throbber52.rgb \
--blob "${SDCARD}"/tmp/throbber53.rgb \
--blob "${SDCARD}"/tmp/throbber54.rgb \
--blob "${SDCARD}"/tmp/throbber55.rgb \
--blob "${SDCARD}"/tmp/throbber56.rgb \
--blob "${SDCARD}"/tmp/throbber57.rgb \
--blob "${SDCARD}"/tmp/throbber58.rgb \
--blob "${SDCARD}"/tmp/throbber59.rgb \
--blob "${SDCARD}"/tmp/throbber60.rgb \
--blob "${SDCARD}"/tmp/throbber61.rgb \
--blob "${SDCARD}"/tmp/throbber62.rgb \
--blob "${SDCARD}"/tmp/throbber63.rgb \
--blob "${SDCARD}"/tmp/throbber64.rgb \
--blob "${SDCARD}"/tmp/throbber65.rgb \
--blob "${SDCARD}"/tmp/throbber66.rgb \
--blob "${SDCARD}"/tmp/throbber67.rgb \
--blob "${SDCARD}"/tmp/throbber68.rgb \
--blob "${SDCARD}"/tmp/throbber69.rgb \
--blob "${SDCARD}"/tmp/throbber70.rgb \
--blob "${SDCARD}"/tmp/throbber71.rgb \
--blob "${SDCARD}"/tmp/throbber72.rgb \
--blob "${SDCARD}"/tmp/throbber73.rgb \
--blob "${SDCARD}"/tmp/throbber74.rgb \
"${SDCARD}"/lib/firmware/bootsplash.armbian > /dev/null 2>&1
if [[ $BOOT_LOGO == yes || $BOOT_LOGO == desktop && $BUILD_DESKTOP == yes ]]; then
[[ -f "${SDCARD}"/boot/armbianEnv.txt ]] && grep -q '^bootlogo' "${SDCARD}"/boot/armbianEnv.txt && \
sed -i 's/^bootlogo.*/bootlogo=true/' "${SDCARD}"/boot/armbianEnv.txt || echo 'bootlogo=true' >> "${SDCARD}"/boot/armbianEnv.txt
[[ -f "${SDCARD}"/boot/boot.ini ]] && sed -i 's/^setenv bootlogo.*/setenv bootlogo "true"/' "${SDCARD}"/boot/boot.ini
[[ -f "${SDCARD}"/boot/armbianEnv.txt ]] && grep -q '^bootlogo' "${SDCARD}"/boot/armbianEnv.txt &&
sed -i 's/^bootlogo.*/bootlogo=true/' "${SDCARD}"/boot/armbianEnv.txt || echo 'bootlogo=true' >> "${SDCARD}"/boot/armbianEnv.txt
[[ -f "${SDCARD}"/boot/boot.ini ]] && sed -i 's/^setenv bootlogo.*/setenv bootlogo "true"/' "${SDCARD}"/boot/boot.ini
fi
# enable additional services
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable bootsplash-ask-password-console.path >/dev/null 2>&1"

View File

@@ -2,8 +2,7 @@
#
# returns md5 hash for current package list and rootfs cache version
get_package_list_hash()
{
get_package_list_hash() {
local package_arr exclude_arr
local list_content
read -ra package_arr <<< "${DEBOOTSTRAP_LIST} ${PACKAGE_LIST}"
@@ -17,8 +16,7 @@ get_package_list_hash()
# get_rootfs_cache_list <cache_type> <packages_hash>
#
# return a list of versions of all avaiable cache from remote and local.
get_rootfs_cache_list()
{
get_rootfs_cache_list() {
local cache_type=$1
local packages_hash=$2
@@ -28,10 +26,10 @@ get_rootfs_cache_list()
# || curl --silent --fail -L https://cache.armbian.com/rootfs/list
curl --silent --fail -L https://cache.armbian.com/rootfs/list
find ${SRC}/cache/rootfs/ -mtime -7 -name "${ARCH}-${RELEASE}-${cache_type}-${packages_hash}-*.tar.zst" \
| sed -e 's#^.*/##' \
| sed -e 's#\..*$##' \
| awk -F'-' '{print $5}'
find ${SRC}/cache/rootfs/ -mtime -7 -name "${ARCH}-${RELEASE}-${cache_type}-${packages_hash}-*.tar.zst" |
sed -e 's#^.*/##' |
sed -e 's#\..*$##' |
awk -F'-' '{print $5}'
} | sort | uniq
}
@@ -39,8 +37,7 @@ get_rootfs_cache_list()
#
# unpacks cached rootfs for $RELEASE or creates one
#
create_rootfs_cache()
{
create_rootfs_cache() {
local packages_hash=$(get_package_list_hash)
local packages_hash=${packages_hash:0:8}
@@ -51,7 +48,7 @@ create_rootfs_cache()
# seek last cache, proceed to previous otherwise build it
local cache_list
readarray -t cache_list <<<"$(get_rootfs_cache_list "$cache_type" "$packages_hash" | sort -r)"
readarray -t cache_list <<< "$(get_rootfs_cache_list "$cache_type" "$packages_hash" | sort -r)"
for ROOTFSCACHE_VERSION in "${cache_list[@]}"; do
local cache_name=${ARCH}-${RELEASE}-${cache_type}-${packages_hash}-${ROOTFSCACHE_VERSION}.tar.zst
@@ -64,8 +61,8 @@ create_rootfs_cache()
# if aria2 file exists download didn't succeeded
if [[ ! -f $cache_fname || -f ${cache_fname}.aria2 ]]; then
display_alert "Downloading from servers"
download_and_verify "rootfs" "$cache_name" \
|| continue
download_and_verify "rootfs" "$cache_name" ||
continue
fi
[[ -f $cache_fname && ! -f ${cache_fname}.aria2 ]] && break
@@ -74,7 +71,7 @@ create_rootfs_cache()
# if aria2 file exists download didn't succeeded
if [[ "$ROOT_FS_CREATE_ONLY" != "yes" && -f $cache_fname && ! -f $cache_fname.aria2 ]]; then
local date_diff=$(( ($(date +%s) - $(stat -c %Y $cache_fname)) / 86400 ))
local date_diff=$((($(date +%s) - $(stat -c %Y $cache_fname)) / 86400))
display_alert "Extracting $cache_name" "$date_diff days old" "info"
pv -p -b -r -c -N "[ .... ] $cache_name" "$cache_fname" | zstdmt -dc | tar xp --xattrs -C $SDCARD/
[[ $? -ne 0 ]] && rm $cache_fname && exit_with_error "Cache $cache_fname is corrupted and was deleted. Restart."
@@ -301,7 +298,7 @@ create_rootfs_cache()
rm -rf $SDCARD
# remove exit trap
trap - INT TERM EXIT
exit
exit
fi
mount_chroot "$SDCARD"

View File

@@ -1,5 +1,4 @@
customize_image()
{
customize_image() {
# for users that need to prepare files at host
[[ -f $USERPATCHES_PATH/customize-image-host.sh ]] && source "$USERPATCHES_PATH"/customize-image-host.sh
@@ -18,7 +17,7 @@ PRE_CUSTOMIZE_IMAGE
display_alert "Calling image customization script" "customize-image.sh" "info"
chroot "${SDCARD}" /bin/bash -c "/tmp/customize-image.sh $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP $ARCH"
CUSTOMIZE_IMAGE_RC=$?
umount -i "${SDCARD}"/tmp/overlay >/dev/null 2>&1
umount -i "${SDCARD}"/tmp/overlay > /dev/null 2>&1
mountpoint -q "${SDCARD}"/tmp/overlay || rm -r "${SDCARD}"/tmp/overlay
if [[ $CUSTOMIZE_IMAGE_RC != 0 ]]; then
exit_with_error "customize-image.sh exited with error (rc: $CUSTOMIZE_IMAGE_RC)"

View File

@@ -1,16 +1,15 @@
install_common()
{
install_common() {
display_alert "Applying common tweaks" "" "info"
# install rootfs encryption related packages separate to not break packages cache
if [[ $CRYPTROOT_ENABLE == yes ]]; then
display_alert "Installing rootfs encryption related packages" "cryptsetup" "info"
chroot "${SDCARD}" /bin/bash -c "apt-get -y -qq --no-install-recommends install cryptsetup" \
>> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
>> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
if [[ $CRYPTROOT_SSH_UNLOCK == yes ]]; then
display_alert "Installing rootfs encryption related packages" "dropbear-initramfs" "info"
chroot "${SDCARD}" /bin/bash -c "apt-get -y -qq --no-install-recommends install dropbear-initramfs cryptsetup-initramfs" \
>> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
>> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
fi
fi
@@ -25,9 +24,9 @@ install_common()
if [[ $CRYPTROOT_ENABLE == yes && $CRYPTROOT_SSH_UNLOCK == yes ]]; then
# Set the port of the dropbear ssh daemon in the initramfs to a different one if configured
# this avoids the typical 'host key changed warning' - `WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!`
[[ -f "${SDCARD}"/etc/dropbear-initramfs/config ]] && \
sed -i 's/^#DROPBEAR_OPTIONS=/DROPBEAR_OPTIONS="-p '"${CRYPTROOT_SSH_UNLOCK_PORT}"'"/' \
"${SDCARD}"/etc/dropbear-initramfs/config
[[ -f "${SDCARD}"/etc/dropbear-initramfs/config ]] &&
sed -i 's/^#DROPBEAR_OPTIONS=/DROPBEAR_OPTIONS="-p '"${CRYPTROOT_SSH_UNLOCK_PORT}"'"/' \
"${SDCARD}"/etc/dropbear-initramfs/config
# setup dropbear authorized_keys, either provided by userpatches or generated
if [[ -f $USERPATCHES_PATH/dropbear_authorized_keys ]]; then
@@ -37,7 +36,7 @@ install_common()
# this key should be changed by the user on first login
display_alert "Generating a new SSH key pair for dropbear (initramfs)" "" ""
ssh-keygen -t ecdsa -f "${SDCARD}"/etc/dropbear-initramfs/id_ecdsa \
-N '' -O force-command=cryptroot-unlock -C 'AUTOGENERATED_BY_ARMBIAN_BUILD' >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
-N '' -O force-command=cryptroot-unlock -C 'AUTOGENERATED_BY_ARMBIAN_BUILD' >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
# /usr/share/initramfs-tools/hooks/dropbear will automatically add 'id_ecdsa.pub' to authorized_keys file
# during mkinitramfs of update-initramfs
@@ -46,7 +45,7 @@ install_common()
# copy dropbear ssh key to image output dir for convenience
cp "${SDCARD}"/etc/dropbear-initramfs/id_ecdsa "${DEST}/images/${CRYPTROOT_SSH_UNLOCK_KEY_NAME}"
display_alert "SSH private key for dropbear (initramfs) has been copied to:" \
"$DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME" "info"
"$DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME" "info"
fi
fi
@@ -67,11 +66,11 @@ install_common()
fi
# configure MIN / MAX speed for cpufrequtils
cat <<-EOF > "${SDCARD}"/etc/default/cpufrequtils
ENABLE=true
MIN_SPEED=$CPUMIN
MAX_SPEED=$CPUMAX
GOVERNOR=$GOVERNOR
cat <<- EOF > "${SDCARD}"/etc/default/cpufrequtils
ENABLE=true
MIN_SPEED=$CPUMIN
MAX_SPEED=$CPUMAX
GOVERNOR=$GOVERNOR
EOF
# remove default interfaces file if present
@@ -113,12 +112,12 @@ install_common()
# enable automated login to console(s)
mkdir -p "${SDCARD}"/etc/systemd/system/getty@.service.d/
mkdir -p "${SDCARD}"/etc/systemd/system/serial-getty@.service.d/
cat <<-EOF > "${SDCARD}"/etc/systemd/system/serial-getty@.service.d/override.conf
[Service]
ExecStartPre=/bin/sh -c 'exec /bin/sleep 10'
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin root %I \$TERM
Type=idle
cat <<- EOF > "${SDCARD}"/etc/systemd/system/serial-getty@.service.d/override.conf
[Service]
ExecStartPre=/bin/sh -c 'exec /bin/sleep 10'
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin root %I \$TERM
Type=idle
EOF
cp "${SDCARD}"/etc/systemd/system/serial-getty@.service.d/override.conf "${SDCARD}"/etc/systemd/system/getty@.service.d/override.conf
@@ -158,10 +157,10 @@ install_common()
else
bootpart_prefix=/boot/
fi
cat <<-EOF > "$SDCARD/boot/extlinux/extlinux.conf"
label ${VENDOR}
kernel ${bootpart_prefix}$NAME_KERNEL
initrd ${bootpart_prefix}$NAME_INITRD
cat <<- EOF > "$SDCARD/boot/extlinux/extlinux.conf"
label ${VENDOR}
kernel ${bootpart_prefix}$NAME_KERNEL
initrd ${bootpart_prefix}$NAME_INITRD
EOF
if [[ -n $BOOT_FDT_FILE ]]; then
if [[ $BOOT_FDT_FILE != "none" ]]; then
@@ -199,13 +198,13 @@ install_common()
fi
fi
[[ -n $OVERLAY_PREFIX && -f "${SDCARD}"/boot/armbianEnv.txt ]] && \
[[ -n $OVERLAY_PREFIX && -f "${SDCARD}"/boot/armbianEnv.txt ]] &&
echo "overlay_prefix=$OVERLAY_PREFIX" >> "${SDCARD}"/boot/armbianEnv.txt
[[ -n $DEFAULT_OVERLAYS && -f "${SDCARD}"/boot/armbianEnv.txt ]] && \
[[ -n $DEFAULT_OVERLAYS && -f "${SDCARD}"/boot/armbianEnv.txt ]] &&
echo "overlays=${DEFAULT_OVERLAYS//,/ }" >> "${SDCARD}"/boot/armbianEnv.txt
[[ -n $BOOT_FDT_FILE && -f "${SDCARD}"/boot/armbianEnv.txt ]] && \
[[ -n $BOOT_FDT_FILE && -f "${SDCARD}"/boot/armbianEnv.txt ]] &&
echo "fdtfile=${BOOT_FDT_FILE}" >> "${SDCARD}/boot/armbianEnv.txt"
fi
@@ -216,14 +215,14 @@ install_common()
echo "${HOST}" > "${SDCARD}"/etc/hostname
# set hostname in hosts file
cat <<-EOF > "${SDCARD}"/etc/hosts
127.0.0.1 localhost
127.0.1.1 $HOST
::1 localhost $HOST ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
cat <<- EOF > "${SDCARD}"/etc/hosts
127.0.0.1 localhost
127.0.1.1 $HOST
::1 localhost $HOST ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
cd $SRC
@@ -250,7 +249,10 @@ install_common()
# install board packages
if [[ -n ${PACKAGE_LIST_BOARD} ]]; then
display_alert "Installing PACKAGE_LIST_BOARD packages" "${PACKAGE_LIST_BOARD}"
chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get ${APT_EXTRA_DIST_PARAMS} -yqq --no-install-recommends install $PACKAGE_LIST_BOARD" >> "${DEST}"/${LOG_SUBPATH}/install.log || { display_alert "Failed to install PACKAGE_LIST_BOARD" "${PACKAGE_LIST_BOARD}" "err"; exit 2; }
chroot "${SDCARD}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get ${APT_EXTRA_DIST_PARAMS} -yqq --no-install-recommends install $PACKAGE_LIST_BOARD" >> "${DEST}"/${LOG_SUBPATH}/install.log || {
display_alert "Failed to install PACKAGE_LIST_BOARD" "${PACKAGE_LIST_BOARD}" "err"
exit 2
}
fi
# remove family packages
@@ -279,7 +281,7 @@ install_common()
fi
}
call_extension_method "pre_install_kernel_debs" << 'PRE_INSTALL_KERNEL_DEBS'
call_extension_method "pre_install_kernel_debs" << 'PRE_INSTALL_KERNEL_DEBS'
*called before installing the Armbian-built kernel deb packages*
It is not too late to `unset KERNELSOURCE` here and avoid kernel install.
PRE_INSTALL_KERNEL_DEBS
@@ -427,18 +429,18 @@ FAMILY_TWEAKS
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable armbian-led-state.service >/dev/null 2>&1"
# copy "first run automated config, optional user configured"
cp "${SRC}"/packages/bsp/armbian_first_run.txt.template "${SDCARD}"/boot/armbian_first_run.txt.template
cp "${SRC}"/packages/bsp/armbian_first_run.txt.template "${SDCARD}"/boot/armbian_first_run.txt.template
# switch to beta repository at this stage if building nightly images
[[ $IMAGE_TYPE == nightly ]] && sed -i 's/apt/beta/' "${SDCARD}"/etc/apt/sources.list.d/armbian.list
# Cosmetic fix [FAILED] Failed to start Set console font and keymap at first boot
[[ -f "${SDCARD}"/etc/console-setup/cached_setup_font.sh ]] \
&& sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" "${SDCARD}"/etc/console-setup/cached_setup_font.sh
[[ -f "${SDCARD}"/etc/console-setup/cached_setup_terminal.sh ]] \
&& sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" "${SDCARD}"/etc/console-setup/cached_setup_terminal.sh
[[ -f "${SDCARD}"/etc/console-setup/cached_setup_keyboard.sh ]] \
&& sed -i "s/-u/-x'/g" "${SDCARD}"/etc/console-setup/cached_setup_keyboard.sh
[[ -f "${SDCARD}"/etc/console-setup/cached_setup_font.sh ]] &&
sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" "${SDCARD}"/etc/console-setup/cached_setup_font.sh
[[ -f "${SDCARD}"/etc/console-setup/cached_setup_terminal.sh ]] &&
sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" "${SDCARD}"/etc/console-setup/cached_setup_terminal.sh
[[ -f "${SDCARD}"/etc/console-setup/cached_setup_keyboard.sh ]] &&
sed -i "s/-u/-x'/g" "${SDCARD}"/etc/console-setup/cached_setup_keyboard.sh
# fix for https://bugs.launchpad.net/ubuntu/+source/blueman/+bug/1542723
chroot "${SDCARD}" /bin/bash -c "chown root:messagebus /usr/lib/dbus-1.0/dbus-daemon-launch-helper"
@@ -453,12 +455,12 @@ FAMILY_TWEAKS
fi
# disable repeated messages due to xconsole not being installed.
[[ -f "${SDCARD}"/etc/rsyslog.d/50-default.conf ]] && \
sed '/daemon\.\*\;mail.*/,/xconsole/ s/.*/#&/' -i "${SDCARD}"/etc/rsyslog.d/50-default.conf
[[ -f "${SDCARD}"/etc/rsyslog.d/50-default.conf ]] &&
sed '/daemon\.\*\;mail.*/,/xconsole/ s/.*/#&/' -i "${SDCARD}"/etc/rsyslog.d/50-default.conf
# disable deprecated parameter
[[ -f "${SDCARD}"/etc/rsyslog.conf ]] && \
sed '/.*$KLogPermitNonKernelFacility.*/,// s/.*/#&/' -i "${SDCARD}"/etc/rsyslog.conf
[[ -f "${SDCARD}"/etc/rsyslog.conf ]] &&
sed '/.*$KLogPermitNonKernelFacility.*/,// s/.*/#&/' -i "${SDCARD}"/etc/rsyslog.conf
# enable getty on multiple serial consoles
# and adjust the speed if it is defined and different than 115200
@@ -466,29 +468,28 @@ FAMILY_TWEAKS
# example: SERIALCON="ttyS0:15000000,ttyGS1"
#
ifs=$IFS
for i in $(echo "${SERIALCON:-'ttyS0'}" | sed "s/,/ /g")
do
for i in $(echo "${SERIALCON:-'ttyS0'}" | sed "s/,/ /g"); do
IFS=':' read -r -a array <<< "$i"
[[ "${array[0]}" == "tty1" ]] && continue # Don't enable tty1 as serial console.
display_alert "Enabling serial console" "${array[0]}" "info"
# add serial console to secure tty list
[ -z "$(grep -w '^${array[0]}' "${SDCARD}"/etc/securetty 2> /dev/null)" ] && \
echo "${array[0]}" >> "${SDCARD}"/etc/securetty
[ -z "$(grep -w '^${array[0]}' "${SDCARD}"/etc/securetty 2> /dev/null)" ] &&
echo "${array[0]}" >> "${SDCARD}"/etc/securetty
if [[ ${array[1]} != "115200" && -n ${array[1]} ]]; then
# make a copy, fix speed and enable
cp "${SDCARD}"/lib/systemd/system/serial-getty@.service \
"${SDCARD}/lib/systemd/system/serial-getty@${array[0]}.service"
"${SDCARD}/lib/systemd/system/serial-getty@${array[0]}.service"
sed -i "s/--keep-baud 115200/--keep-baud ${array[1]},115200/" \
"${SDCARD}/lib/systemd/system/serial-getty@${array[0]}.service"
"${SDCARD}/lib/systemd/system/serial-getty@${array[0]}.service"
fi
chroot "${SDCARD}" /bin/bash -c "systemctl daemon-reload" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable serial-getty@${array[0]}.service" \
>> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
>> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
if [[ "${array[0]}" == "ttyGS0" && $LINUXFAMILY == sun8i && $BRANCH == default ]]; then
mkdir -p "${SDCARD}"/etc/systemd/system/serial-getty@ttyGS0.service.d
cat <<-EOF > "${SDCARD}"/etc/systemd/system/serial-getty@ttyGS0.service.d/10-switch-role.conf
[Service]
ExecStartPre=-/bin/sh -c "echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role"
cat <<- EOF > "${SDCARD}"/etc/systemd/system/serial-getty@ttyGS0.service.d/10-switch-role.conf
[Service]
ExecStartPre=-/bin/sh -c "echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role"
EOF
fi
done
@@ -533,9 +534,9 @@ FAMILY_TWEAKS
sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf
if [[ -n $NM_IGNORE_DEVICES ]]; then
mkdir -p "${SDCARD}"/etc/NetworkManager/conf.d/
cat <<-EOF > "${SDCARD}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
[keyfile]
unmanaged-devices=$NM_IGNORE_DEVICES
cat <<- EOF > "${SDCARD}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
[keyfile]
unmanaged-devices=$NM_IGNORE_DEVICES
EOF
fi
@@ -547,32 +548,32 @@ FAMILY_TWEAKS
# enable services
chroot "${SDCARD}" /bin/bash -c "systemctl enable systemd-networkd.service systemd-resolved.service" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
if [ -e /etc/systemd/timesyncd.conf ]; then
if [ -e /etc/systemd/timesyncd.conf ]; then
chroot "${SDCARD}" /bin/bash -c "systemctl enable systemd-timesyncd.service" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
fi
umask 022
cat > "${SDCARD}"/etc/systemd/network/eth0.network <<- __EOF__
[Match]
Name=eth0
[Match]
Name=eth0
[Network]
#MACAddress=
DHCP=ipv4
LinkLocalAddressing=ipv4
#Address=192.168.1.100/24
#Gateway=192.168.1.1
#DNS=192.168.1.1
#Domains=example.com
NTP=0.pool.ntp.org 1.pool.ntp.org
[Network]
#MACAddress=
DHCP=ipv4
LinkLocalAddressing=ipv4
#Address=192.168.1.100/24
#Gateway=192.168.1.1
#DNS=192.168.1.1
#Domains=example.com
NTP=0.pool.ntp.org 1.pool.ntp.org
__EOF__
fi
# avahi daemon defaults if exists
[[ -f "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service ]] && \
cp "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service "${SDCARD}"/etc/avahi/services/
[[ -f "${SDCARD}"/usr/share/doc/avahi-daemon/examples/ssh.service ]] && \
cp "${SDCARD}"/usr/share/doc/avahi-daemon/examples/ssh.service "${SDCARD}"/etc/avahi/services/
[[ -f "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service ]] &&
cp "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service "${SDCARD}"/etc/avahi/services/
[[ -f "${SDCARD}"/usr/share/doc/avahi-daemon/examples/ssh.service ]] &&
cp "${SDCARD}"/usr/share/doc/avahi-daemon/examples/ssh.service "${SDCARD}"/etc/avahi/services/
# nsswitch settings for sane DNS behavior: remove resolve, assure libnss-myhostname support
sed "s/hosts\:.*/hosts: files mymachines dns myhostname/g" -i "${SDCARD}"/etc/nsswitch.conf
@@ -583,12 +584,12 @@ FAMILY_TWEAKS
# Show logo
if [[ $PLYMOUTH == yes ]]; then
if [[ $BOOT_LOGO == yes || $BOOT_LOGO == desktop && $BUILD_DESKTOP == yes ]]; then
[[ -f "${SDCARD}"/boot/armbianEnv.txt ]] && grep -q '^bootlogo' "${SDCARD}"/boot/armbianEnv.txt \
&& sed -i 's/^bootlogo.*/bootlogo=true/' "${SDCARD}"/boot/armbianEnv.txt \
|| echo 'bootlogo=true' >> "${SDCARD}"/boot/armbianEnv.txt
[[ -f "${SDCARD}"/boot/armbianEnv.txt ]] && grep -q '^bootlogo' "${SDCARD}"/boot/armbianEnv.txt &&
sed -i 's/^bootlogo.*/bootlogo=true/' "${SDCARD}"/boot/armbianEnv.txt ||
echo 'bootlogo=true' >> "${SDCARD}"/boot/armbianEnv.txt
[[ -f "${SDCARD}"/boot/boot.ini ]] \
&& sed -i 's/^setenv bootlogo.*/setenv bootlogo "true"/' "${SDCARD}"/boot/boot.ini
[[ -f "${SDCARD}"/boot/boot.ini ]] &&
sed -i 's/^setenv bootlogo.*/setenv bootlogo "true"/' "${SDCARD}"/boot/boot.ini
fi
fi
@@ -597,10 +598,9 @@ FAMILY_TWEAKS
}
install_rclocal()
{
install_rclocal() {
cat <<-EOF > "${SDCARD}"/etc/rc.local
cat <<- EOF > "${SDCARD}"/etc/rc.local
#!/bin/sh -e
#
# rc.local
@@ -615,7 +615,7 @@ install_rclocal()
# By default this script does nothing.
exit 0
EOF
chmod +x "${SDCARD}"/etc/rc.local
EOF
chmod +x "${SDCARD}"/etc/rc.local
}

View File

@@ -1,18 +1,17 @@
install_distribution_specific()
{
install_distribution_specific() {
display_alert "Applying distribution specific tweaks for" "$RELEASE" "info"
case $RELEASE in
sid)
sid)
# (temporally) disable broken service
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload disable smartmontools.service >/dev/null 2>&1"
;;
;;
focal|jammy)
focal | jammy)
# by using default lz4 initrd compression leads to corruption, go back to proven method
sed -i "s/^COMPRESS=.*/COMPRESS=gzip/" "${SDCARD}"/etc/initramfs-tools/initramfs.conf
@@ -42,7 +41,7 @@ install_distribution_specific()
# disable conflicting services
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload mask ondemand.service >/dev/null 2>&1"
;;
;;
esac
@@ -58,10 +57,10 @@ install_distribution_specific()
"update-locale --reset LANG=$DEST_LANG LANGUAGE=$DEST_LANG LC_ALL=$DEST_LANG"' ${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
# Basic Netplan config. Let NetworkManager/networkd manage all devices on this system
[[ -d "${SDCARD}"/etc/netplan ]] && cat <<-EOF > "${SDCARD}"/etc/netplan/armbian-default.yaml
network:
version: 2
renderer: $RENDERER
[[ -d "${SDCARD}"/etc/netplan ]] && cat <<- EOF > "${SDCARD}"/etc/netplan/armbian-default.yaml
network:
version: 2
renderer: $RENDERER
EOF
# cleanup motd services and related files
@@ -90,67 +89,66 @@ install_distribution_specific()
# <release>: bullseye|focal|jammy|sid
# <basedir>: path to root directory
#
create_sources_list()
{
create_sources_list() {
local release=$1
local basedir=$2
[[ -z $basedir ]] && exit_with_error "No basedir passed to create_sources_list"
case $release in
buster)
cat <<-EOF > "${basedir}"/etc/apt/sources.list
deb http://${DEBIAN_MIRROR} $release main contrib non-free
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
buster)
cat <<- EOF > "${basedir}"/etc/apt/sources.list
deb http://${DEBIAN_MIRROR} $release main contrib non-free
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
deb http://${DEBIAN_SECURTY} ${release}/updates main contrib non-free
#deb-src http://${DEBIAN_SECURTY} ${release}/updates main contrib non-free
EOF
;;
deb http://${DEBIAN_SECURTY} ${release}/updates main contrib non-free
#deb-src http://${DEBIAN_SECURTY} ${release}/updates main contrib non-free
EOF
;;
bullseye|bookworm|trixie)
cat <<-EOF > "${basedir}"/etc/apt/sources.list
deb http://${DEBIAN_MIRROR} $release main contrib non-free
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
bullseye | bookworm | trixie)
cat <<- EOF > "${basedir}"/etc/apt/sources.list
deb http://${DEBIAN_MIRROR} $release main contrib non-free
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-updates main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
deb http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
#deb-src http://${DEBIAN_MIRROR} ${release}-backports main contrib non-free
deb http://${DEBIAN_SECURTY} ${release}-security main contrib non-free
#deb-src http://${DEBIAN_SECURTY} ${release}-security main contrib non-free
EOF
;;
deb http://${DEBIAN_SECURTY} ${release}-security main contrib non-free
#deb-src http://${DEBIAN_SECURTY} ${release}-security main contrib non-free
EOF
;;
sid) # sid is permanent unstable development and has no such thing as updates or security
cat <<-EOF > "${basedir}"/etc/apt/sources.list
deb http://${DEBIAN_MIRROR} $release main contrib non-free
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
EOF
;;
sid) # sid is permanent unstable development and has no such thing as updates or security
cat <<- EOF > "${basedir}"/etc/apt/sources.list
deb http://${DEBIAN_MIRROR} $release main contrib non-free
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
EOF
;;
focal|jammy)
cat <<-EOF > "${basedir}"/etc/apt/sources.list
deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse
focal | jammy)
cat <<- EOF > "${basedir}"/etc/apt/sources.list
deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse
deb http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
deb http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse
deb http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
deb http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse
deb http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
EOF
;;
deb http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
#deb-src http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse
EOF
;;
esac
display_alert "Adding Armbian repository and authentication key" "/etc/apt/sources.list.d/armbian.list" "info"
@@ -173,9 +171,9 @@ create_sources_list()
if [[ $DOWNLOAD_MIRROR == "china" ]]; then
echo "deb ${SIGNED_BY}https://mirrors.tuna.tsinghua.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${basedir}"/etc/apt/sources.list.d/armbian.list
elif [[ $DOWNLOAD_MIRROR == "bfsu" ]]; then
echo "deb ${SIGNED_BY}http://mirrors.bfsu.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${basedir}"/etc/apt/sources.list.d/armbian.list
echo "deb ${SIGNED_BY}http://mirrors.bfsu.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${basedir}"/etc/apt/sources.list.d/armbian.list
else
echo "deb ${SIGNED_BY}http://"$([[ $BETA == yes ]] && echo "beta" || echo "apt" )".armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${basedir}"/etc/apt/sources.list.d/armbian.list
echo "deb ${SIGNED_BY}http://"$([[ $BETA == yes ]] && echo "beta" || echo "apt")".armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${basedir}"/etc/apt/sources.list.d/armbian.list
fi
# replace local package server if defined. Suitable for development

View File

@@ -1,5 +1,4 @@
post_debootstrap_tweaks()
{
post_debootstrap_tweaks() {
# remove service start blockers and QEMU binary
rm -f "${SDCARD}"/sbin/initctl "${SDCARD}"/sbin/start-stop-daemon

View File

@@ -1,5 +1,4 @@
desktop_postinstall ()
{
desktop_postinstall() {
# disable display manager for the first run
run_on_sdcard "systemctl --no-reload disable lightdm.service >/dev/null 2>&1"

View File

@@ -3,4 +3,4 @@
while read -r file; do
# shellcheck source=/dev/null
source "$file"
done <<<"$(find "${SRC}/lib/functions" -name "*.sh")"
done <<< "$(find "${SRC}/lib/functions" -name "*.sh")"

View File

@@ -9,9 +9,6 @@
# This file is a part of the Armbian build script
# https://github.com/armbian/build/
cleanup_list() {
local varname="${1}"
local list_to_clean="${!varname}"
@@ -20,9 +17,6 @@ cleanup_list() {
echo ${list_to_clean}
}
if [[ $(basename "$0") == main.sh ]]; then
echo "Please use compile.sh to start the build process"
@@ -30,9 +24,6 @@ if [[ $(basename "$0") == main.sh ]]; then
fi
# default umask for root is 022 so parent directories won't be group writeable without this
# this is used instead of making the chmod in prepare_host() recursive
umask 002
@@ -48,17 +39,16 @@ if [[ -z $ROOT_FS_CREATE_ONLY ]]; 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
TTY_X=$(($(stty size | awk '{print $2}') - 6)) # determine terminal width
TTY_Y=$(($(stty size | awk '{print $1}') - 6)) # determine terminal height
fi
# We'll use this title on all menus
backtitle="Armbian building script, https://www.armbian.com | https://docs.armbian.com | (c) 2013-2021 Igor Pecovnik "
# Warnings mitigation
[[ -z $LANGUAGE ]] && export LANGUAGE="en_US:en" # set to english if not set
[[ -z $CONSOLE_CHAR ]] && export CONSOLE_CHAR="UTF-8" # set console to UTF-8 if not set
[[ -z $LANGUAGE ]] && export LANGUAGE="en_US:en" # set to english if not set
[[ -z $CONSOLE_CHAR ]] && export CONSOLE_CHAR="UTF-8" # set console to UTF-8 if not set
# Libraries include
# shellcheck source=import-functions.sh
@@ -69,7 +59,7 @@ LOG_SUBPATH=${LOG_SUBPATH:=debug}
# compress and remove old logs
mkdir -p "${DEST}"/${LOG_SUBPATH}
(cd "${DEST}"/${LOG_SUBPATH} && tar -czf logs-"$(<timestamp)".tgz ./*.log) > /dev/null 2>&1
(cd "${DEST}"/${LOG_SUBPATH} && tar -czf logs-"$(< timestamp)".tgz ./*.log) > /dev/null 2>&1
rm -f "${DEST}"/${LOG_SUBPATH}/*.log > /dev/null 2>&1
date +"%d_%m_%Y-%H_%M_%S" > "${DEST}"/${LOG_SUBPATH}/timestamp
@@ -88,12 +78,8 @@ fi
if [[ $PROGRESS_LOG_TO_FILE != yes ]]; then unset PROGRESS_LOG_TO_FILE; fi
SHOW_WARNING=yes
if [[ $USE_CCACHE != no ]]; then
CCACHE=ccache
@@ -108,42 +94,37 @@ else
fi
if [[ -n $REPOSITORY_UPDATE ]]; then
# select stable/beta configuration
if [[ $BETA == yes ]]; then
DEB_STORAGE=$DEST/debs-beta
REPO_STORAGE=$DEST/repository-beta
REPO_CONFIG="aptly-beta.conf"
else
DEB_STORAGE=$DEST/debs
REPO_STORAGE=$DEST/repository
REPO_CONFIG="aptly.conf"
fi
# select stable/beta configuration
if [[ $BETA == yes ]]; then
DEB_STORAGE=$DEST/debs-beta
REPO_STORAGE=$DEST/repository-beta
REPO_CONFIG="aptly-beta.conf"
else
DEB_STORAGE=$DEST/debs
REPO_STORAGE=$DEST/repository
REPO_CONFIG="aptly.conf"
fi
# For user override
if [[ -f "${USERPATCHES_PATH}"/lib.config ]]; then
display_alert "Using user configuration override" "userpatches/lib.config" "info"
source "${USERPATCHES_PATH}"/lib.config
fi
# For user override
if [[ -f "${USERPATCHES_PATH}"/lib.config ]]; then
display_alert "Using user configuration override" "userpatches/lib.config" "info"
source "${USERPATCHES_PATH}"/lib.config
fi
repo-manipulate "$REPOSITORY_UPDATE"
exit
repo-manipulate "$REPOSITORY_UPDATE"
exit
fi
# if KERNEL_ONLY, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu
if [[ -z $KERNEL_ONLY ]]; then
options+=("yes" "U-boot and kernel packages")
options+=("no" "Full OS image for flashing")
KERNEL_ONLY=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags \
--menu "Select what to build" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
--menu "Select what to build" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $KERNEL_ONLY ]] && exit_with_error "No option selected"
@@ -155,7 +136,7 @@ if [[ -z $KERNEL_CONFIGURE ]]; then
options+=("yes" "Show a kernel configuration menu before compilation")
options+=("prebuilt" "Use precompiled packages from Armbian repository")
KERNEL_CONFIGURE=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags \
--menu "Select the kernel configuration" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
--menu "Select the kernel configuration" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $KERNEL_CONFIGURE ]] && exit_with_error "No option selected"
@@ -194,13 +175,13 @@ if [[ -z $BOARD ]]; then
fi
if [[ $WIP_STATE != supported ]]; then
cat <<-'EOF' > "${temp_rc}"
dialog_color = (RED,WHITE,OFF)
screen_color = (WHITE,RED,ON)
tag_color = (RED,WHITE,ON)
item_selected_color = (WHITE,RED,ON)
tag_selected_color = (WHITE,RED,ON)
tag_key_selected_color = (WHITE,RED,ON)
cat <<- 'EOF' > "${temp_rc}"
dialog_color = (RED,WHITE,OFF)
screen_color = (WHITE,RED,ON)
tag_color = (RED,WHITE,ON)
item_selected_color = (WHITE,RED,ON)
tag_selected_color = (WHITE,RED,ON)
tag_key_selected_color = (WHITE,RED,ON)
EOF
else
echo > "${temp_rc}"
@@ -236,9 +217,6 @@ if [[ -z $BOARD ]]; then
done
fi
if [[ -f $SRC/config/boards/${BOARD}.conf ]]; then
BOARD_TYPE='conf'
elif [[ -f $SRC/config/boards/${BOARD}.csc ]]; then
@@ -251,9 +229,6 @@ elif [[ -f $SRC/config/boards/${BOARD}.tvb ]]; then
BOARD_TYPE='tvb'
fi
# shellcheck source=/dev/null
source "${SRC}/config/boards/${BOARD}.${BOARD_TYPE}"
LINUXFAMILY="${BOARDFAMILY}"
@@ -288,8 +263,6 @@ else
fi
if [[ $KERNEL_ONLY != yes && -z $RELEASE ]]; then
options=()
@@ -297,7 +270,7 @@ if [[ $KERNEL_ONLY != yes && -z $RELEASE ]]; then
distros_options
RELEASE=$(dialog --stdout --title "Choose a release package base" --backtitle "$backtitle" \
--menu "Select the target OS release package base" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
--menu "Select the target OS release package base" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
[[ -z $RELEASE ]] && exit_with_error "No release selected"
unset options
@@ -315,7 +288,7 @@ elif [[ $KERNEL_ONLY != yes && -z $BUILD_DESKTOP ]]; then
options+=("no" "Image with console interface (server)")
options+=("yes" "Image with desktop environment")
BUILD_DESKTOP=$(dialog --stdout --title "Choose image type" --backtitle "$backtitle" --no-tags \
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"
if [[ ${BUILD_DESKTOP} == "yes" ]]; then
@@ -331,7 +304,7 @@ if [[ $KERNEL_ONLY != yes && $BUILD_DESKTOP == no && -z $BUILD_MINIMAL ]]; then
options+=("no" "Standard image with console interface")
options+=("yes" "Minimal image with console interface")
BUILD_MINIMAL=$(dialog --stdout --title "Choose image type" --backtitle "$backtitle" --no-tags \
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
--menu "Select the target image type" $TTY_Y $TTY_X $((TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $BUILD_MINIMAL ]] && exit_with_error "No option selected"
if [[ $BUILD_MINIMAL == "yes" ]]; then
@@ -355,9 +328,8 @@ elif [[ $BUILD_MINIMAL == "yes" ]]; then
SELECTED_CONFIGURATION="cli_minimal"
fi
[[ ${KERNEL_CONFIGURE} == prebuilt ]] && [[ -z ${REPOSITORY_INSTALL} ]] && \
REPOSITORY_INSTALL="u-boot,kernel,bsp,armbian-zsh,armbian-config,armbian-bsp-cli,armbian-firmware${BUILD_DESKTOP:+,armbian-desktop,armbian-bsp-desktop}"
[[ ${KERNEL_CONFIGURE} == prebuilt ]] && [[ -z ${REPOSITORY_INSTALL} ]] &&
REPOSITORY_INSTALL="u-boot,kernel,bsp,armbian-zsh,armbian-config,armbian-bsp-cli,armbian-firmware${BUILD_DESKTOP:+,armbian-desktop,armbian-bsp-desktop}"
#shellcheck source=configuration.sh
source "${SRC}"/lib/configuration.sh
@@ -366,7 +338,7 @@ source "${SRC}"/lib/configuration.sh
CPUS=$(grep -c 'processor' /proc/cpuinfo)
if [[ $USEALLCORES != no ]]; then
CTHREADS="-j$((CPUS + CPUS/2))"
CTHREADS="-j$((CPUS + CPUS / 2))"
else
@@ -408,164 +380,158 @@ CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}
do_default() {
start=$(date +%s)
start=$(date +%s)
# Check and install dependencies, directory structure and settings
# The OFFLINE_WORK variable inside the function
prepare_host
# Check and install dependencies, directory structure and settings
# The OFFLINE_WORK variable inside the function
prepare_host
[[ "${JUST_INIT}" == "yes" ]] && exit 0
[[ "${JUST_INIT}" == "yes" ]] && exit 0
[[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"
[[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"
# fetch_from_repo <url> <dir> <ref> <subdir_flag>
# fetch_from_repo <url> <dir> <ref> <subdir_flag>
# ignore updates help on building all images - for internal purposes
if [[ $IGNORE_UPDATES != yes ]]; then
display_alert "Downloading sources" "" "info"
[[ -n $BOOTSOURCE ]] && fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"
[[ -n $ATFSOURCE ]] && fetch_from_repo "$ATFSOURCE" "$ATFDIR" "$ATFBRANCH" "yes"
# ignore updates help on building all images - for internal purposes
if [[ $IGNORE_UPDATES != yes ]]; then
display_alert "Downloading sources" "" "info"
[[ -n $BOOTSOURCE ]] && fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"
[[ -n $ATFSOURCE ]] && fetch_from_repo "$ATFSOURCE" "$ATFDIR" "$ATFBRANCH" "yes"
if [[ -n $KERNELSOURCE ]]; then
if $(declare -f var_origin_kernel >/dev/null); then
unset LINUXSOURCEDIR
LINUXSOURCEDIR="linux-mainline/$KERNEL_VERSION_LEVEL"
VAR_SHALLOW_ORIGINAL=var_origin_kernel
waiter_local_git "url=$KERNELSOURCE $KERNELSOURCENAME $KERNELBRANCH dir=$LINUXSOURCEDIR $KERNELSWITCHOBJ"
unset VAR_SHALLOW_ORIGINAL
else
fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"
if [[ -n $KERNELSOURCE ]]; then
if $(declare -f var_origin_kernel > /dev/null); then
unset LINUXSOURCEDIR
LINUXSOURCEDIR="linux-mainline/$KERNEL_VERSION_LEVEL"
VAR_SHALLOW_ORIGINAL=var_origin_kernel
waiter_local_git "url=$KERNELSOURCE $KERNELSOURCENAME $KERNELBRANCH dir=$LINUXSOURCEDIR $KERNELSWITCHOBJ"
unset VAR_SHALLOW_ORIGINAL
else
fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"
fi
fi
call_extension_method "fetch_sources_tools" <<- 'FETCH_SOURCES_TOOLS'
*fetch host-side sources needed for tools and build*
Run early to fetch_from_repo or otherwise obtain sources for needed tools.
FETCH_SOURCES_TOOLS
call_extension_method "build_host_tools" <<- 'BUILD_HOST_TOOLS'
*build needed tools for the build, host-side*
After sources are fetched, build host-side tools needed for the build.
BUILD_HOST_TOOLS
for option in $(tr ',' ' ' <<< "$CLEAN_LEVEL"); do
[[ $option != sources ]] && cleaning "$option"
done
fi
call_extension_method "fetch_sources_tools" <<- 'FETCH_SOURCES_TOOLS'
*fetch host-side sources needed for tools and build*
Run early to fetch_from_repo or otherwise obtain sources for needed tools.
FETCH_SOURCES_TOOLS
call_extension_method "build_host_tools" <<- 'BUILD_HOST_TOOLS'
*build needed tools for the build, host-side*
After sources are fetched, build host-side tools needed for the build.
BUILD_HOST_TOOLS
for option in $(tr ',' ' ' <<< "$CLEAN_LEVEL"); do
[[ $option != sources ]] && cleaning "$option"
done
fi
# Don't build at all if the BOOTCONFIG is 'none'.
[[ "${BOOTCONFIG}" != "none" ]] && {
# 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
# Don't build at all if the BOOTCONFIG is 'none'.
[[ "${BOOTCONFIG}" != "none" ]] && {
# 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
[[ "${REPOSITORY_INSTALL}" != *u-boot* ]] && compile_uboot
fi
[[ "${REPOSITORY_INSTALL}" != *u-boot* ]] && compile_uboot
fi
}
}
# Compile kernel if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
# 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
[[ -n $KERNELSOURCE ]] && [[ "${REPOSITORY_INSTALL}" != *kernel* ]] && compile_kernel
fi
# 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
[[ "${REPOSITORY_INSTALL}" != *armbian-config* ]] && compile_armbian-config
fi
# Compile armbian-zsh if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/armbian-zsh_${REVISION}_all.deb ]]; then
[[ "${REPOSITORY_INSTALL}" != *armbian-zsh* ]] && compile_armbian-zsh
fi
# Compile plymouth-theme-armbian if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/plymouth-theme-armbian_${REVISION}_all.deb ]]; then
[[ "${REPOSITORY_INSTALL}" != *plymouth-theme-armbian* ]] && compile_plymouth-theme-armbian
fi
# Compile armbian-firmware if packed .deb does not exist or use the one from repository
if ! ls "${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb" 1> /dev/null 2>&1 || ! ls "${DEB_STORAGE}/armbian-firmware-full_${REVISION}_all.deb" 1> /dev/null 2>&1; then
if [[ "${REPOSITORY_INSTALL}" != *armbian-firmware* ]]; then
[[ "${INSTALL_ARMBIAN_FIRMWARE:-yes}" == "yes" ]] && { # Build firmware by default.
FULL=""
REPLACE="-full"
compile_firmware
FULL="-full"
REPLACE=""
compile_firmware
}
KDEB_CHANGELOG_DIST=$RELEASE
[[ -n $KERNELSOURCE ]] && [[ "${REPOSITORY_INSTALL}" != *kernel* ]] && compile_kernel
fi
fi
# 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
overlayfs_wrapper "cleanup"
[[ "${REPOSITORY_INSTALL}" != *armbian-config* ]] && compile_armbian-config
fi
# Compile armbian-zsh if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/armbian-zsh_${REVISION}_all.deb ]]; then
[[ "${REPOSITORY_INSTALL}" != *armbian-zsh* ]] && compile_armbian-zsh
# create board support package
[[ -n "${RELEASE}" && ! -f "${DEB_STORAGE}/${BSP_CLI_PACKAGE_FULLNAME}.deb" && "${REPOSITORY_INSTALL}" != *armbian-bsp-cli* ]] && create_board_package
fi
# Compile plymouth-theme-armbian if packed .deb does not exist or use the one from repository
if [[ ! -f ${DEB_STORAGE}/plymouth-theme-armbian_${REVISION}_all.deb ]]; then
[[ "${REPOSITORY_INSTALL}" != *plymouth-theme-armbian* ]] && compile_plymouth-theme-armbian
# create desktop package
[[ -n "${RELEASE}" && "${DESKTOP_ENVIRONMENT}" && ! -f "${DEB_STORAGE}/$RELEASE/${CHOSEN_DESKTOP}_${REVISION}_all.deb" && "${REPOSITORY_INSTALL}" != *armbian-desktop* ]] && create_desktop_package
[[ -n "${RELEASE}" && "${DESKTOP_ENVIRONMENT}" && ! -f "${DEB_STORAGE}/${RELEASE}/${BSP_DESKTOP_PACKAGE_FULLNAME}.deb" && "${REPOSITORY_INSTALL}" != *armbian-bsp-desktop* ]] && create_bsp_desktop_package
fi
# skip image creation if exists. useful for CI when making a lot of images
if [ "$IMAGE_PRESENT" == yes ] && ls "${FINALDEST}/${VENDOR}_${REVISION}_${BOARD^}_${RELEASE}_${BRANCH}_${VER/-$LINUXFAMILY/}${DESKTOP_ENVIRONMENT:+_$DESKTOP_ENVIRONMENT}"*.xz 1> /dev/null 2>&1; then
display_alert "Skipping image creation" "image already made - IMAGE_PRESENT is set" "wrn"
exit
fi
# Compile armbian-firmware if packed .deb does not exist or use the one from repository
if ! ls "${DEB_STORAGE}/armbian-firmware_${REVISION}_all.deb" 1> /dev/null 2>&1 || ! ls "${DEB_STORAGE}/armbian-firmware-full_${REVISION}_all.deb" 1> /dev/null 2>&1; then
# build additional packages
[[ $EXTERNAL_NEW == compile ]] && chroot_build_packages
if [[ "${REPOSITORY_INSTALL}" != *armbian-firmware* ]]; then
[[ "${INSTALL_ARMBIAN_FIRMWARE:-yes}" == "yes" ]] && { # Build firmware by default.
FULL=""
REPLACE="-full"
compile_firmware
FULL="-full"
REPLACE=""
compile_firmware
}
if [[ $KERNEL_ONLY != yes ]]; then
fi
[[ $BSP_BUILD != yes ]] && debootstrap_ng
fi
else
overlayfs_wrapper "cleanup"
display_alert "Kernel build done" "@host" "info"
display_alert "Target directory" "${DEB_STORAGE}/" "info"
display_alert "File name" "${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" "info"
# create board support package
[[ -n "${RELEASE}" && ! -f "${DEB_STORAGE}/${BSP_CLI_PACKAGE_FULLNAME}.deb" && "${REPOSITORY_INSTALL}" != *armbian-bsp-cli* ]] && create_board_package
fi
# create desktop package
[[ -n "${RELEASE}" && "${DESKTOP_ENVIRONMENT}" && ! -f "${DEB_STORAGE}/$RELEASE/${CHOSEN_DESKTOP}_${REVISION}_all.deb" && "${REPOSITORY_INSTALL}" != *armbian-desktop* ]] && create_desktop_package
[[ -n "${RELEASE}" && "${DESKTOP_ENVIRONMENT}" && ! -f "${DEB_STORAGE}/${RELEASE}/${BSP_DESKTOP_PACKAGE_FULLNAME}.deb" && "${REPOSITORY_INSTALL}" != *armbian-bsp-desktop* ]] && create_bsp_desktop_package
call_extension_method "run_after_build" << 'RUN_AFTER_BUILD'
# skip image creation if exists. useful for CI when making a lot of images
if [ "$IMAGE_PRESENT" == yes ] && ls "${FINALDEST}/${VENDOR}_${REVISION}_${BOARD^}_${RELEASE}_${BRANCH}_${VER/-$LINUXFAMILY/}${DESKTOP_ENVIRONMENT:+_$DESKTOP_ENVIRONMENT}"*.xz 1> /dev/null 2>&1; then
display_alert "Skipping image creation" "image already made - IMAGE_PRESENT is set" "wrn"
exit
fi
# build additional packages
[[ $EXTERNAL_NEW == compile ]] && chroot_build_packages
if [[ $KERNEL_ONLY != yes ]]; then
[[ $BSP_BUILD != yes ]] && debootstrap_ng
else
display_alert "Kernel build done" "@host" "info"
display_alert "Target directory" "${DEB_STORAGE}/" "info"
display_alert "File name" "${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb" "info"
fi
call_extension_method "run_after_build" << 'RUN_AFTER_BUILD'
*hook for function to run after build, i.e. to change owner of `$SRC`*
Really one of the last hooks ever called. The build has ended. Congratulations.
- *NOTE:* this will run only if there were no errors during build process.
RUN_AFTER_BUILD
end=$(date +%s)
runtime=$(((end - start) / 60))
display_alert "Runtime" "$runtime min" "info"
end=$(date +%s)
runtime=$(((end-start)/60))
display_alert "Runtime" "$runtime min" "info"
# Make it easy to repeat build by displaying build options used
[ "$(systemd-detect-virt)" == 'docker' ] && BUILD_CONFIG='docker'
display_alert "Repeat Build Options" "./compile.sh ${BUILD_CONFIG} BOARD=${BOARD} BRANCH=${BRANCH} \
# Make it easy to repeat build by displaying build options used
[ "$(systemd-detect-virt)" == 'docker' ] && BUILD_CONFIG='docker'
display_alert "Repeat Build Options" "./compile.sh ${BUILD_CONFIG} BOARD=${BOARD} BRANCH=${BRANCH} \
$([[ -n $RELEASE ]] && echo "RELEASE=${RELEASE} ")\
$([[ -n $BUILD_MINIMAL ]] && echo "BUILD_MINIMAL=${BUILD_MINIMAL} ")\
$([[ -n $BUILD_DESKTOP ]] && echo "BUILD_DESKTOP=${BUILD_DESKTOP} ")\
$([[ -n $KERNEL_ONLY ]] && echo "KERNEL_ONLY=${KERNEL_ONLY} ")\
$([[ -n $KERNEL_CONFIGURE ]] && echo "KERNEL_CONFIGURE=${KERNEL_CONFIGURE} ")\
$([[ -n $DESKTOP_ENVIRONMENT ]] && echo "DESKTOP_ENVIRONMENT=${DESKTOP_ENVIRONMENT} ")\
$([[ -n $DESKTOP_ENVIRONMENT_CONFIG_NAME ]] && echo "DESKTOP_ENVIRONMENT_CONFIG_NAME=${DESKTOP_ENVIRONMENT_CONFIG_NAME} ")\
$([[ -n $DESKTOP_ENVIRONMENT_CONFIG_NAME ]] && echo "DESKTOP_ENVIRONMENT_CONFIG_NAME=${DESKTOP_ENVIRONMENT_CONFIG_NAME} ")\
$([[ -n $DESKTOP_APPGROUPS_SELECTED ]] && echo "DESKTOP_APPGROUPS_SELECTED=\"${DESKTOP_APPGROUPS_SELECTED}\" ")\
$([[ -n $DESKTOP_APT_FLAGS_SELECTED ]] && echo "DESKTOP_APT_FLAGS_SELECTED=\"${DESKTOP_APT_FLAGS_SELECTED}\" ")\
$([[ -n $COMPRESS_OUTPUTIMAGE ]] && echo "COMPRESS_OUTPUTIMAGE=${COMPRESS_OUTPUTIMAGE} ")\