mirror of
https://github.com/DrHo1y/orangepi-build.git
synced 2026-11-05 15:27:21 +07:00
Bump to next branch
Host: Ubuntu 21.04
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
# Functions:
|
||||
|
||||
# compile_atf
|
||||
# compile_uboot
|
||||
# compile_kernel
|
||||
@@ -22,6 +23,9 @@
|
||||
# userpatch_create
|
||||
# overlayfs_wrapper
|
||||
|
||||
|
||||
|
||||
|
||||
compile_atf()
|
||||
{
|
||||
if [[ $CLEAN_LEVEL == *make* ]]; then
|
||||
@@ -39,6 +43,9 @@ compile_atf()
|
||||
|
||||
display_alert "Compiling ATF" "" "info"
|
||||
|
||||
# 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"
|
||||
@@ -51,6 +58,9 @@ compile_atf()
|
||||
[[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver"
|
||||
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
|
||||
@@ -63,13 +73,13 @@ compile_atf()
|
||||
# create patch for manual source changes
|
||||
[[ $CREATE_PATCHES == yes ]] && userpatch_create "atf"
|
||||
|
||||
echo -e "\n\t== atf ==\n" >> "${DEST}"/debug/compilation.log
|
||||
echo -e "\n\t== atf ==\n" >> "${DEST}"/${LOG_SUBPATH}/compilation.log
|
||||
# ENABLE_BACKTRACE="0" has been added to workaround a regression in 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}"/debug/compilation.log \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
|
||||
CROSS_COMPILE="$CCACHE $ATF_COMPILER"' 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log \
|
||||
${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'}
|
||||
|
||||
@@ -77,8 +87,9 @@ compile_atf()
|
||||
|
||||
[[ $(type -t atf_custom_postprocess) == function ]] && atf_custom_postprocess
|
||||
|
||||
local atftempdir=$SRC/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH}
|
||||
mkdir -p "${atftempdir}"
|
||||
atftempdir=$(mktemp -d)
|
||||
chmod 700 ${atftempdir}
|
||||
trap "rm -rf \"${atftempdir}\" ; exit 0" 0 1 2 3 15
|
||||
|
||||
# copy files to temp directory
|
||||
for f in $target_files; do
|
||||
@@ -121,10 +132,13 @@ compile_uboot()
|
||||
# read uboot version
|
||||
local version hash
|
||||
version=$(grab_version "$ubootdir")
|
||||
hash=$(git --git-dir="$ubootdir"/.git rev-parse HEAD)
|
||||
hash=$(improved_git --git-dir="$ubootdir"/.git rev-parse HEAD)
|
||||
|
||||
display_alert "Compiling u-boot" "v$version" "info"
|
||||
|
||||
# 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"
|
||||
@@ -137,13 +151,19 @@ compile_uboot()
|
||||
[[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver"
|
||||
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"
|
||||
|
||||
# create directory structure for the .deb package
|
||||
uboottempdir=$(mktemp -d)
|
||||
chmod 700 ${uboottempdir}
|
||||
trap "rm -rf \"${uboottempdir}\" ; exit 0" 0 1 2 3 15
|
||||
local uboot_name=${CHOSEN_UBOOT}_${REVISION}_${ARCH}
|
||||
rm -rf $SRC/.tmp/{$uboot_name,packout}
|
||||
mkdir -p $SRC/.tmp/$uboot_name/usr/lib/{u-boot,$uboot_name} $SRC/.tmp/$uboot_name/DEBIAN $SRC/.tmp/packout
|
||||
rm -rf $uboottempdir/$uboot_name
|
||||
mkdir -p $uboottempdir/$uboot_name/usr/lib/{u-boot,$uboot_name} $uboottempdir/$uboot_name/DEBIAN
|
||||
|
||||
# process compilation for one or multiple targets
|
||||
while read -r target; do
|
||||
@@ -152,9 +172,13 @@ compile_uboot()
|
||||
target_patchdir=$(cut -d';' -f2 <<< "${target}")
|
||||
target_files=$(cut -d';' -f3 <<< "${target}")
|
||||
|
||||
# needed for multiple targets and for calling compile_uboot directly
|
||||
#display_alert "Checking out to clean sources"
|
||||
#improved_git checkout -f -q HEAD
|
||||
|
||||
if [[ $CLEAN_LEVEL == *make* ]]; then
|
||||
display_alert "Cleaning" "$BOOTSOURCEDIR" "info"
|
||||
(cd "$BOOTSOURCEDIR"; make clean > /dev/null 2>&1)
|
||||
(cd "${BOOTSOURCEDIR}"; make clean > /dev/null 2>&1)
|
||||
fi
|
||||
|
||||
advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "$target_patchdir" "$BRANCH" "${LINUXFAMILY}-${BOARD}-${BRANCH}"
|
||||
@@ -163,15 +187,15 @@ compile_uboot()
|
||||
[[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot"
|
||||
|
||||
if [[ -n $ATFSOURCE ]]; then
|
||||
local atftempdir=$SRC/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH}
|
||||
cp -Rv "${atftempdir}"/*.bin .
|
||||
rm -rf "${atftempdir}"
|
||||
fi
|
||||
|
||||
echo -e "\n\t== u-boot ==\n" >> "${DEST}"/debug/compilation.log
|
||||
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}"/debug/compilation.log \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
|
||||
CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"' 2>> "${DEST}"/${LOG_SUBPATH}/compilation.log \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/compilation.log'} \
|
||||
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
|
||||
|
||||
if [[ "${version}" != 2014.07 ]]; then
|
||||
@@ -207,14 +231,15 @@ compile_uboot()
|
||||
cross_compile="CROSS_COMPILE=$CCACHE $UBOOT_COMPILER";
|
||||
[[ -n $UBOOT_TOOLCHAIN2 ]] && cross_compile="ORANGEPI=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}"/debug/compilation.log \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a "${DEST}"/debug/compilation.log'} \
|
||||
"${cross_compile}"' 2>>"${DEST}"/${LOG_SUBPATH}/compilation.log \
|
||||
${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'}
|
||||
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} ';EVALPIPE=(${PIPESTATUS[@]})'
|
||||
|
||||
[[ ${PIPESTATUS[0]} -ne 0 ]] && exit_with_error "U-boot compilation failed"
|
||||
[[ ${EVALPIPE[0]} -ne 0 ]] && exit_with_error "U-boot compilation failed"
|
||||
|
||||
[[ $(type -t uboot_custom_postprocess) == function ]] && uboot_custom_postprocess
|
||||
|
||||
@@ -231,9 +256,9 @@ compile_uboot()
|
||||
fi
|
||||
[[ ! -f $f_src ]] && exit_with_error "U-boot file not found" "$(basename "${f_src}")"
|
||||
if [[ "${version}" =~ 2014.07|2011.09 ]]; then
|
||||
cp "${f_src}" "${SRC}/.tmp/packout/${f_dst}"
|
||||
cp "${f_src}" "$uboottempdir/packout/${f_dst}"
|
||||
else
|
||||
cp "${f_src}" "${SRC}/.tmp/${uboot_name}/usr/lib/${uboot_name}/${f_dst}"
|
||||
cp "${f_src}" "$uboottempdir/${uboot_name}/usr/lib/${uboot_name}/${f_dst}"
|
||||
fi
|
||||
done
|
||||
done <<< "$UBOOT_TARGET_MAP"
|
||||
@@ -247,14 +272,14 @@ compile_uboot()
|
||||
fi
|
||||
else
|
||||
pack_uboot
|
||||
cp ${SRC}/.tmp/packout/{boot0_sdcard.fex,boot_package.fex} "${SRC}/.tmp/${uboot_name}/usr/lib/${uboot_name}/"
|
||||
cp ${SRC}/.tmp/packout/dts/${BOARD}-u-boot.dts "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/"
|
||||
cp $uboottempdir/packout/{boot0_sdcard.fex,boot_package.fex} "${SRC}/.tmp/${uboot_name}/usr/lib/${uboot_name}/"
|
||||
cp $uboottempdir/packout/dts/${BOARD}-u-boot.dts "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/"
|
||||
fi
|
||||
cd "${ubootdir}" || exit
|
||||
fi
|
||||
|
||||
# declare -f on non-defined function does not do anything
|
||||
cat <<-EOF > "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/platform_install.sh"
|
||||
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)
|
||||
@@ -262,7 +287,7 @@ compile_uboot()
|
||||
EOF
|
||||
|
||||
# set up control file
|
||||
cat <<-EOF > "${SRC}/.tmp/${uboot_name}/DEBIAN/control"
|
||||
cat <<-EOF > "$uboottempdir/${uboot_name}/DEBIAN/control"
|
||||
Package: linux-u-boot-${BOARD}-${BRANCH}
|
||||
Version: $REVISION
|
||||
Architecture: $ARCH
|
||||
@@ -278,20 +303,62 @@ compile_uboot()
|
||||
|
||||
# copy config file to the package
|
||||
# useful for FEL boot with overlayfs_wrapper
|
||||
[[ -f .config && -n $BOOTCONFIG ]] && cp .config "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/${BOOTCONFIG}"
|
||||
[[ -f .config && -n $BOOTCONFIG ]] && cp .config "$uboottempdir/${uboot_name}/usr/lib/u-boot/${BOOTCONFIG}"
|
||||
# copy license files from typical locations
|
||||
[[ -f COPYING ]] && cp COPYING "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/LICENSE"
|
||||
[[ -f Licenses/README ]] && cp Licenses/README "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/LICENSE"
|
||||
[[ -n $atftempdir && -f $atftempdir/license.md ]] && cp "${atftempdir}/license.md" "${SRC}/.tmp/${uboot_name}/usr/lib/u-boot/LICENSE.atf"
|
||||
[[ -f COPYING ]] && cp COPYING "$uboottempdir/${uboot_name}/usr/lib/u-boot/LICENSE"
|
||||
[[ -f Licenses/README ]] && cp Licenses/README "$uboottempdir/${uboot_name}/usr/lib/u-boot/LICENSE"
|
||||
[[ -n $atftempdir && -f $atftempdir/license.md ]] && cp "${atftempdir}/license.md" "$uboottempdir/${uboot_name}/usr/lib/u-boot/LICENSE.atf"
|
||||
|
||||
display_alert "Building deb" "${uboot_name}.deb" "info"
|
||||
fakeroot dpkg-deb -b "${SRC}/.tmp/${uboot_name}" "${SRC}/.tmp/${uboot_name}.deb" >> "${DEST}"/debug/output.log 2>&1
|
||||
rm -rf "${SRC}/.tmp/${uboot_name}"
|
||||
fakeroot dpkg-deb -b "$uboottempdir/${uboot_name}" "$uboottempdir/${uboot_name}.deb" >> "${DEST}"/${LOG_SUBPATH}/output.log 2>&1
|
||||
rm -rf "$uboottempdir/${uboot_name}"
|
||||
[[ -n $atftempdir ]] && rm -rf "${atftempdir}"
|
||||
|
||||
[[ ! -f $SRC/.tmp/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed"
|
||||
[[ ! -f $uboottempdir/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed"
|
||||
|
||||
mv "${SRC}/.tmp/${uboot_name}.deb" "${DEB_STORAGE}/u-boot/"
|
||||
rsync --remove-source-files -rq "$uboottempdir/${uboot_name}.deb" "${DEB_STORAGE}/u-boot/"
|
||||
rm -rf "$uboottempdir"
|
||||
}
|
||||
|
||||
create_linux-source_package ()
|
||||
{
|
||||
ts=$(date +%s)
|
||||
local sources_pkg_dir tmp_src_dir
|
||||
tmp_src_dir=$(mktemp -d)
|
||||
trap "rm -rf \"${tmp_src_dir}\" ; exit 0" 0 1 2 3 15
|
||||
sources_pkg_dir=${tmp_src_dir}/${CHOSEN_KSRC}_${REVISION}_all
|
||||
mkdir -p "${sources_pkg_dir}"/usr/src/ \
|
||||
"${sources_pkg_dir}"/usr/share/doc/linux-source-${version}-${LINUXFAMILY} \
|
||||
"${sources_pkg_dir}"/DEBIAN
|
||||
|
||||
cp "${EXTER}/config/kernel/${LINUXCONFIG}.config" "default_${LINUXCONFIG}.config"
|
||||
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"
|
||||
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
|
||||
EOF
|
||||
|
||||
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} -z0 "${sources_pkg_dir}" "${sources_pkg_dir}.deb"
|
||||
rsync --remove-source-files -rq "${sources_pkg_dir}.deb" "${DEB_STORAGE}/"
|
||||
|
||||
te=$(date +%s)
|
||||
display_alert "Make the linux-source package" "$(($te - $ts)) sec." "info"
|
||||
rm -rf "${tmp_src_dir}"
|
||||
}
|
||||
|
||||
compile_kernel()
|
||||
@@ -309,9 +376,6 @@ compile_kernel()
|
||||
fi
|
||||
cd "${kerneldir}" || exit
|
||||
|
||||
if ! grep -qoE '^-rc[[:digit:]]+' <(grep "^EXTRAVERSION" Makefile | head -1 | awk '{print $(NF)}'); then
|
||||
sed -i 's/EXTRAVERSION = .*/EXTRAVERSION = /' Makefile
|
||||
fi
|
||||
rm -f localversion
|
||||
|
||||
# read kernel version
|
||||
@@ -319,60 +383,69 @@ compile_kernel()
|
||||
version=$(grab_version "$kerneldir")
|
||||
|
||||
# read kernel git hash
|
||||
hash=$(git --git-dir="$kerneldir"/.git rev-parse HEAD)
|
||||
hash=$(improved_git --git-dir="$kerneldir"/.git rev-parse HEAD)
|
||||
|
||||
# Apply a series of patches if a series file exists
|
||||
if test -f "${EXTER}"/patch/kernel/${KERNELPATCHDIR}/series.conf; then
|
||||
display_alert "series.conf file visible. Apply"
|
||||
series_conf="${SRC}"/patch/kernel/${KERNELPATCHDIR}/series.conf
|
||||
|
||||
# apply_patch_series <target dir> <full path to series file>
|
||||
apply_patch_series "${kerneldir}" "$series_conf"
|
||||
fi
|
||||
|
||||
# build 3rd party drivers
|
||||
# compilation_prepare
|
||||
|
||||
advanced_patch "kernel" "$KERNELPATCHDIR" "$BOARD" "" "$BRANCH" "$LINUXFAMILY-$BRANCH"
|
||||
|
||||
# create patch for manual source changes in debug mode
|
||||
[[ $CREATE_PATCHES == yes ]] && userpatch_create "kernel"
|
||||
# create patch for manual source changes in debug mode
|
||||
[[ $CREATE_PATCHES == yes ]] && userpatch_create "kernel"
|
||||
|
||||
# re-read kernel version after patching
|
||||
local version
|
||||
version=$(grab_version "$kerneldir")
|
||||
|
||||
# create linux-source package - with already patched sources
|
||||
local sources_pkg_dir=$SRC/.tmp/${CHOSEN_KSRC}_${REVISION}_all
|
||||
rm -rf "${sources_pkg_dir}"
|
||||
mkdir -p "${sources_pkg_dir}"/usr/src/ "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}" "${sources_pkg_dir}"/DEBIAN $SRC/.tmp/gpu_modules_${LINUXFAMILY}
|
||||
|
||||
if [[ $BUILD_KSRC == yes ]]; then
|
||||
display_alert "Cleaning" "$LINUXSOURCEDIR" "info"
|
||||
(cd $LINUXSOURCEDIR; make ARCH=$ARCHITECTURE clean >/dev/null 2>&1)
|
||||
|
||||
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"
|
||||
cp COPYING "${sources_pkg_dir}/usr/share/doc/linux-source-${version}-${LINUXFAMILY}/LICENSE"
|
||||
fi
|
||||
# re-read kernel version after patching
|
||||
local version
|
||||
version=$(grab_version "$kerneldir")
|
||||
|
||||
display_alert "Compiling $BRANCH kernel" "$version" "info"
|
||||
|
||||
local toolchain
|
||||
toolchain=$(find_toolchain "$KERNEL_COMPILER" "$KERNEL_USE_GCC")
|
||||
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${KERNEL_COMPILER}gcc $KERNEL_USE_GCC"
|
||||
# compare with the architecture of the current Debian node
|
||||
# if it matches we use the system compiler
|
||||
if $(dpkg-architecture -e "${ARCH}"); then
|
||||
display_alert "Native compilation"
|
||||
elif [[ $(dpkg --print-architecture) == amd64 ]]; then
|
||||
local toolchain
|
||||
toolchain=$(find_toolchain "$KERNEL_COMPILER" "$KERNEL_USE_GCC")
|
||||
[[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${KERNEL_COMPILER}gcc $KERNEL_USE_GCC"
|
||||
else
|
||||
exit_with_error "Architecture [$ARCH] is not supported"
|
||||
fi
|
||||
|
||||
display_alert "Compiler version" "${KERNEL_COMPILER}gcc $(eval env PATH="${toolchain}:${PATH}" "${KERNEL_COMPILER}gcc" -dumpversion)" "info"
|
||||
|
||||
# copy kernel config
|
||||
if [[ $KERNEL_KEEP_CONFIG == yes && -f "${DEST}"/config/$LINUXCONFIG.config ]]; then
|
||||
display_alert "Using previous kernel config" "${DEST}/config/$LINUXCONFIG.config" "info"
|
||||
cp "${DEST}/config/${LINUXCONFIG}.config" .config
|
||||
cp -p "${DEST}/config/${LINUXCONFIG}.config" .config
|
||||
else
|
||||
if [[ -f $USERPATCHES_PATH/$LINUXCONFIG.config ]]; then
|
||||
display_alert "Using kernel config provided by user" "userpatches/$LINUXCONFIG.config" "info"
|
||||
cp "${USERPATCHES_PATH}/${LINUXCONFIG}.config" .config
|
||||
cp -p "${USERPATCHES_PATH}/${LINUXCONFIG}.config" .config
|
||||
else
|
||||
display_alert "Using kernel config file" "config/kernel/$LINUXCONFIG.config" "info"
|
||||
cp "${EXTER}/config/kernel/${LINUXCONFIG}.config" .config
|
||||
display_alert "Using kernel config file" "${EXTER}/config/kernel/$LINUXCONFIG.config" "info"
|
||||
cp -p "${EXTER}/config/kernel/${LINUXCONFIG}.config" .config
|
||||
fi
|
||||
fi
|
||||
|
||||
call_extension_method "custom_kernel_config" << 'CUSTOM_KERNEL_CONFIG'
|
||||
*Kernel .config is in place, still clean from git version*
|
||||
Called after ${LINUXCONFIG}.config is put in place (.config).
|
||||
Before any olddefconfig any Kconfig make is called.
|
||||
A good place to customize the .config directly.
|
||||
CUSTOM_KERNEL_CONFIG
|
||||
|
||||
|
||||
# hack for deb builder. To pack what's missing in headers pack.
|
||||
cp $EXTER/patch/misc/headers-debian-byteshift.patch /tmp
|
||||
cp "$EXTER"/patch/misc/headers-debian-byteshift.patch /tmp
|
||||
|
||||
if [[ $KERNEL_CONFIGURE != yes ]]; then
|
||||
if [[ $BRANCH == legacy ]]; then
|
||||
@@ -403,16 +476,20 @@ compile_kernel()
|
||||
fi
|
||||
fi
|
||||
|
||||
xz < .config > "${sources_pkg_dir}/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz"
|
||||
# create linux-source package - with already patched sources
|
||||
# We will build this package first and clear the memory.
|
||||
if [[ $BUILD_KSRC != no ]]; then
|
||||
create_linux-source_package
|
||||
fi
|
||||
|
||||
echo -e "\n\t== kernel ==\n" >> "${DEST}"/debug/compilation.log
|
||||
echo -e "\n\t== kernel ==\n" >> "${DEST}"/${LOG_SUBPATH}/compilation.log
|
||||
eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${PATH}" \
|
||||
'make $CTHREADS ARCH=$ARCHITECTURE \
|
||||
CROSS_COMPILE="$CCACHE $KERNEL_COMPILER" \
|
||||
$SRC_LOADADDR \
|
||||
LOCALVERSION="-$LINUXFAMILY" \
|
||||
$KERNEL_IMAGE_TYPE modules dtbs 2>>$DEST/debug/compilation.log' \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
|
||||
$KERNEL_IMAGE_TYPE ${KERNEL_EXTRA_TARGETS:-modules dtbs} 2>>$DEST/${LOG_SUBPATH}/compilation.log' \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/compilation.log'} \
|
||||
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" \
|
||||
--progressbox "Compiling kernel..." $TTY_Y $TTY_X'} \
|
||||
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
|
||||
@@ -435,52 +512,61 @@ compile_kernel()
|
||||
display_alert "Creating packages"
|
||||
|
||||
# produce deb packages: image, headers, firmware, dtb
|
||||
echo -e "\n\t== deb packages: image, headers, firmware, dtb ==\n" >> "${DEST}"/debug/compilation.log
|
||||
echo -e "\n\t== deb packages: image, headers, firmware, dtb ==\n" >> "${DEST}"/${LOG_SUBPATH}/compilation.log
|
||||
eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${PATH}" \
|
||||
'make -j1 $kernel_packing \
|
||||
'make $CTHREADS $kernel_packing \
|
||||
KDEB_PKGVERSION=$REVISION \
|
||||
KDEB_COMPRESS=${DEB_COMPRESS} \
|
||||
BRANCH=$BRANCH \
|
||||
LOCALVERSION="-${LINUXFAMILY}" \
|
||||
KBUILD_DEBARCH=$ARCH \
|
||||
ARCH=$ARCHITECTURE \
|
||||
DEBFULLNAME="$MAINTAINER" \
|
||||
DEBEMAIL="$MAINTAINERMAIL" \
|
||||
CROSS_COMPILE="$CCACHE $KERNEL_COMPILER" 2>>$DEST/debug/compilation.log' \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
|
||||
CROSS_COMPILE="$CCACHE $KERNEL_COMPILER" 2>>$DEST/${LOG_SUBPATH}/compilation.log' \
|
||||
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/${LOG_SUBPATH}/compilation.log'} \
|
||||
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Creating kernel packages..." $TTY_Y $TTY_X'} \
|
||||
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
|
||||
|
||||
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
|
||||
|
||||
if [[ $BUILD_KSRC == yes ]]; then
|
||||
fakeroot dpkg-deb -z0 -b "${sources_pkg_dir}" "${sources_pkg_dir}.deb"
|
||||
mv "${sources_pkg_dir}.deb" "${DEB_STORAGE}/"
|
||||
fi
|
||||
rm -rf "${sources_pkg_dir}"
|
||||
|
||||
cd .. || exit
|
||||
# remove firmare image packages here - easier than patching ~40 packaging scripts at once
|
||||
rm -f linux-firmware-image-*.deb
|
||||
mv ./*.deb "${DEB_STORAGE}/" || exit_with_error "Failed moving kernel DEBs"
|
||||
|
||||
# store git hash to the file
|
||||
echo "${hash}" > "${EXTER}/cache/hash/linux-image-${BRANCH}-${LINUXFAMILY}.githash"
|
||||
[[ -z ${KERNELPATCHDIR} ]] && KERNELPATCHDIR=$LINUXFAMILY-$BRANCH
|
||||
[[ -z ${LINUXCONFIG} ]] && LINUXCONFIG=linux-$LINUXFAMILY-$BRANCH
|
||||
hash_watch_1=$(find "${EXTER}/patch/kernel/${KERNELPATCHDIR}" -maxdepth 1 -printf '%s %P\n' 2> /dev/null | sort)
|
||||
hash_watch_2=$(cat "${EXTER}/config/kernel/${LINUXCONFIG}.config")
|
||||
echo "${hash_watch_1}${hash_watch_2}" | git hash-object --stdin >> "${EXTER}/cache/hash/linux-image-${BRANCH}-${LINUXFAMILY}.githash"
|
||||
rsync --remove-source-files -rq ./*.deb "${DEB_STORAGE}/" || exit_with_error "Failed moving kernel DEBs"
|
||||
|
||||
# store git hash to the file and create a change log
|
||||
#HASHTARGET="${EXTER}/cache/hash"$([[ ${BETA} == yes ]] && echo "-beta")"/linux-image-${BRANCH}-${LINUXFAMILY}"
|
||||
#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
|
||||
# [[ $? -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
|
||||
# [[ $? -ne 0 ]] && OLDHASHTARGET=$(git -C ${kerneldir} rev-list --max-parents=0 HEAD)
|
||||
#fi
|
||||
|
||||
#[[ -z ${KERNELPATCHDIR} ]] && KERNELPATCHDIR=$LINUXFAMILY-$BRANCH
|
||||
#[[ -z ${LINUXCONFIG} ]] && LINUXCONFIG=linux-$LINUXFAMILY-$BRANCH
|
||||
|
||||
# calculate URL
|
||||
#if [[ "$KERNELSOURCE" == *"github.com"* ]]; then
|
||||
# URL="${KERNELSOURCE/git:/https:}/commit/${HASH}"
|
||||
#elif [[ "$KERNELSOURCE" == *"kernel.org"* ]]; then
|
||||
# URL="${KERNELSOURCE/git:/https:}/commit/?h=$(echo $KERNELBRANCH | cut -d":" -f2)&id=${HASH}"
|
||||
#else
|
||||
# URL="${KERNELSOURCE}/+/$HASH"
|
||||
#fi
|
||||
|
||||
# create change log
|
||||
#git --no-pager -C ${kerneldir} log --abbrev-commit --oneline --no-patch --no-merges --date-order --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%C(black bold)%ad%Creset%C(auto) | %s | <%an> | <a href='$URL'%H>%H</a>' ${OLDHASHTARGET}..${hash} > "${HASHTARGET}.gitlog"
|
||||
|
||||
#echo "${hash}" > "${HASHTARGET}.githash"
|
||||
#hash_watch_1=$(LC_COLLATE=C find -L "${EXTER}/patch/kernel/${KERNELPATCHDIR}"/ -name '*.patch' -mindepth 1 -maxdepth 1 -printf '%s %P\n' 2> /dev/null | LC_COLLATE=C sort -n)
|
||||
#hash_watch_2=$(cat "${EXTER}/config/kernel/${LINUXCONFIG}.config")
|
||||
#echo "${hash_watch_1}${hash_watch_2}" | improved_git hash-object --stdin >> "${HASHTARGET}.githash"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -488,39 +574,32 @@ compile_kernel()
|
||||
|
||||
compile_firmware()
|
||||
{
|
||||
display_alert "Merging and packaging linux firmware" "@host" "info"
|
||||
if [[ $USE_MAINLINE_GOOGLE_MIRROR == yes ]]; then
|
||||
plugin_repo="https://kernel.googlesource.com/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
|
||||
else
|
||||
plugin_repo="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
|
||||
[[ $DOWNLOAD_MIRROR == china ]] && plugin_repo="${GIT_SERVER}/linux-firmware.git"
|
||||
fi
|
||||
local plugin_dir="orangepi-firmware${FULL}"
|
||||
[[ -d "${EXTER}/cache/sources/${plugin_dir}" ]] && rm -rf "${EXTER}/cache/sources/${plugin_dir}"
|
||||
mkdir -p "${EXTER}/cache/sources/${plugin_dir}/lib/firmware"
|
||||
display_alert "Merging and packaging linux firmware" "@host" "info"
|
||||
|
||||
[[ $IGNORE_UPDATES != yes ]] && fetch_from_repo "${GIT_SERVER}/firmware" "${EXTER}/cache/sources/orangepi-firmware-git" "branch:master"
|
||||
local firmwaretempdir plugin_dir
|
||||
|
||||
if [[ -n $FULL ]]; then
|
||||
[[ $IGNORE_UPDATES != yes ]] && fetch_from_repo "$plugin_repo" "${EXTER}/cache/sources/linux-firmware-git" "branch:master"
|
||||
# cp : create hardlinks
|
||||
#cp -alf "${EXTER}"/cache/sources/linux-firmware-git/* "${EXTER}/cache/sources/${plugin_dir}/lib/firmware/"
|
||||
fi
|
||||
|
||||
# overlay our firmware
|
||||
# cp : create hardlinks
|
||||
if [[ -n $FULL ]]; then
|
||||
cp -alf "${EXTER}"/cache/sources/linux-firmware-git/* "${EXTER}/cache/sources/${plugin_dir}/lib/firmware/"
|
||||
else
|
||||
cp -alf "${EXTER}"/cache/sources/orangepi-firmware-git/* "${EXTER}/cache/sources/${plugin_dir}/lib/firmware/"
|
||||
firmwaretempdir=$(mktemp -d)
|
||||
chmod 700 ${firmwaretempdir}
|
||||
trap "rm -rf \"${firmwaretempdir}\" ; exit 0" 0 1 2 3 15
|
||||
plugin_dir="orangepi-firmware${FULL}"
|
||||
mkdir -p "${firmwaretempdir}/${plugin_dir}/lib/firmware"
|
||||
|
||||
[[ $IGNORE_UPDATES != yes ]] && fetch_from_repo "https://github.com/orangepi-xunlong/firmware" "${EXTER}/cache/sources/orangepi-firmware-git" "branch:master"
|
||||
if [[ -n $FULL ]]; then
|
||||
[[ $IGNORE_UPDATES != yes ]] && fetch_from_repo "$MAINLINE_FIRMWARE_SOURCE" "${EXTER}/cache/sources/linux-firmware-git" "branch:master"
|
||||
# cp : create hardlinks
|
||||
cp -af --reflink=auto "${EXTER}"/cache/sources/linux-firmware-git/* "${firmwaretempdir}/${plugin_dir}/lib/firmware/"
|
||||
fi
|
||||
# overlay our firmware
|
||||
# cp : create hardlinks
|
||||
cp -af --reflink=auto "${EXTER}"/cache/sources/orangepi-firmware-git/* "${firmwaretempdir}/${plugin_dir}/lib/firmware/"
|
||||
|
||||
# cleanup what's not needed for sure
|
||||
rm -rf "${EXTER}/cache/sources/${plugin_dir}"/lib/firmware/{amdgpu,amd-ucode,radeon,nvidia,matrox,.git}
|
||||
cd "${EXTER}/cache/sources/${plugin_dir}" || exit
|
||||
# cleanup what's not needed for sure
|
||||
rm -rf "${firmwaretempdir}/${plugin_dir}"/lib/firmware/{amdgpu,amd-ucode,radeon,nvidia,matrox,.git}
|
||||
cd "${firmwaretempdir}/${plugin_dir}" || exit
|
||||
|
||||
# set up control file
|
||||
mkdir -p DEBIAN
|
||||
# set up control file
|
||||
mkdir -p DEBIAN
|
||||
cat <<-END > DEBIAN/control
|
||||
Package: orangepi-firmware${FULL}
|
||||
Version: $REVISION
|
||||
@@ -533,12 +612,95 @@ compile_firmware()
|
||||
Description: Linux firmware${FULL}
|
||||
END
|
||||
|
||||
cd "${EXTER}"/cache/sources || exit
|
||||
# pack
|
||||
mv "orangepi-firmware${FULL}" "orangepi-firmware${FULL}_${REVISION}_all"
|
||||
fakeroot dpkg -b "orangepi-firmware${FULL}_${REVISION}_all" >> "${DEST}"/debug/install.log 2>&1
|
||||
mv "orangepi-firmware${FULL}_${REVISION}_all" "orangepi-firmware${FULL}"
|
||||
mv "orangepi-firmware${FULL}_${REVISION}_all.deb" "${DEB_STORAGE}/"
|
||||
cd "${firmwaretempdir}" || exit
|
||||
# pack
|
||||
mv "orangepi-firmware${FULL}" "orangepi-firmware${FULL}_${REVISION}_all"
|
||||
display_alert "Building firmware package" "orangepi-firmware${FULL}_${REVISION}_all" "info"
|
||||
fakeroot dpkg -b "orangepi-firmware${FULL}_${REVISION}_all" >> "${DEST}"/${LOG_SUBPATH}/install.log 2>&1
|
||||
mv "orangepi-firmware${FULL}_${REVISION}_all" "orangepi-firmware${FULL}"
|
||||
rsync -rq "orangepi-firmware${FULL}_${REVISION}_all.deb" "${DEB_STORAGE}/"
|
||||
|
||||
# remove temp directory
|
||||
rm -rf "${firmwaretempdir}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
compile_orangepi-zsh()
|
||||
{
|
||||
|
||||
local tmp_dir orangepi_zsh_dir
|
||||
tmp_dir=$(mktemp -d)
|
||||
chmod 700 ${tmp_dir}
|
||||
trap "rm -rf \"${tmp_dir}\" ; exit 0" 0 1 2 3 15
|
||||
orangepi_zsh_dir=orangepi-zsh_${REVISION}_all
|
||||
display_alert "Building deb" "orangepi-zsh" "info"
|
||||
|
||||
[[ $IGNORE_UPDATES != yes ]] && fetch_from_repo "https://github.com/robbyrussell/oh-my-zsh" "${EXTER}/cache/sources/oh-my-zsh" "branch:master"
|
||||
[[ $IGNORE_UPDATES != yes ]] && fetch_from_repo "https://github.com/mroth/evalcache" "${EXTER}/cache/sources/evalcache" "branch:master"
|
||||
|
||||
mkdir -p "${tmp_dir}/${orangepi_zsh_dir}"/{DEBIAN,etc/skel/,etc/oh-my-zsh/,/etc/skel/.oh-my-zsh/cache}
|
||||
|
||||
# set up control file
|
||||
cat <<-END > "${tmp_dir}/${orangepi_zsh_dir}"/DEBIAN/control
|
||||
Package: orangepi-zsh
|
||||
Version: $REVISION
|
||||
Architecture: all
|
||||
Maintainer: $MAINTAINER <$MAINTAINERMAIL>
|
||||
Depends: zsh, tmux
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Description: Orange Pi improved ZShell
|
||||
END
|
||||
|
||||
# set up post install script
|
||||
cat <<-END > "${tmp_dir}/${orangepi_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 {}'
|
||||
|
||||
# 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
|
||||
END
|
||||
|
||||
cp -R "${EXTER}"/cache/sources/oh-my-zsh "${tmp_dir}/${orangepi_zsh_dir}"/etc/
|
||||
cp -R "${EXTER}"/cache/sources/evalcache "${tmp_dir}/${orangepi_zsh_dir}"/etc/oh-my-zsh/plugins
|
||||
cp "${tmp_dir}/${orangepi_zsh_dir}"/etc/oh-my-zsh/templates/zshrc.zsh-template "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
chmod -R g-w,o-w "${tmp_dir}/${orangepi_zsh_dir}"/etc/oh-my-zsh/
|
||||
|
||||
# we have common settings
|
||||
sed -i "s/^export ZSH=.*/export ZSH=\/etc\/oh-my-zsh/" "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
# user cache
|
||||
sed -i "/^export ZSH=.*/a export ZSH_CACHE_DIR=~\/.oh-my-zsh\/cache" "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
# define theme
|
||||
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="mrtazz"/' "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
# disable prompt while update
|
||||
sed -i 's/# DISABLE_UPDATE_PROMPT="true"/DISABLE_UPDATE_PROMPT="true"/g' "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
# disable auto update since we provide update via package
|
||||
sed -i 's/# DISABLE_AUTO_UPDATE="true"/DISABLE_AUTO_UPDATE="true"/g' "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
# define default plugins
|
||||
sed -i 's/^plugins=.*/plugins=(evalcache git git-extras debian tmux screen history extract colorize web-search docker)/' "${tmp_dir}/${orangepi_zsh_dir}"/etc/skel/.zshrc
|
||||
|
||||
chmod 755 "${tmp_dir}/${orangepi_zsh_dir}"/DEBIAN/postinst
|
||||
|
||||
fakeroot dpkg-deb -b -Z${DEB_COMPRESS} "${tmp_dir}/${orangepi_zsh_dir}" >> "${DEST}"/${LOG_SUBPATH}/output.log 2>&1
|
||||
rsync --remove-source-files -rq "${tmp_dir}/${orangepi_zsh_dir}.deb" "${DEB_STORAGE}/"
|
||||
rm -rf "${tmp_dir}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -581,7 +743,7 @@ compile_orangepi-config()
|
||||
ln -sf /usr/sbin/softy "${tmpdir}"/usr/bin/softy
|
||||
|
||||
fakeroot dpkg -b "${tmpdir}" >/dev/null
|
||||
mv "${tmpdir}.deb" "${DEB_STORAGE}/"
|
||||
rsync --remove-source-files -rq "${tmpdir}.deb" "${DEB_STORAGE}/"
|
||||
rm -rf "${tmpdir}"
|
||||
}
|
||||
|
||||
@@ -593,13 +755,13 @@ compile_sunxi_tools()
|
||||
# Compile and install only if git commit hash changed
|
||||
cd $EXTER/cache/sources/sunxi-tools || exit
|
||||
# need to check if /usr/local/bin/sunxi-fexc to detect new Docker containers with old cached sources
|
||||
if [[ ! -f .commit_id || $(git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/sunxi-fexc ]]; then
|
||||
if [[ ! -f .commit_id || $(improved_git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/sunxi-fexc ]]; then
|
||||
display_alert "Compiling" "sunxi-tools" "info"
|
||||
make -s clean >/dev/null
|
||||
make -s tools >/dev/null
|
||||
mkdir -p /usr/local/bin/
|
||||
make install-tools >/dev/null 2>&1
|
||||
git rev-parse @ 2>/dev/null > .commit_id
|
||||
improved_git rev-parse @ 2>/dev/null > .commit_id
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -608,12 +770,12 @@ install_rkbin_tools()
|
||||
# install only if git commit hash changed
|
||||
cd "${EXTER}"/cache/sources/rkbin-tools || exit
|
||||
# need to check if /usr/local/bin/sunxi-fexc to detect new Docker containers with old cached sources
|
||||
if [[ ! -f .commit_id || $(git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/loaderimage ]]; then
|
||||
if [[ ! -f .commit_id || $(improved_git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/loaderimage ]]; then
|
||||
display_alert "Installing" "rkbin-tools" "info"
|
||||
mkdir -p /usr/local/bin/
|
||||
install -m 755 tools/loaderimage /usr/local/bin/
|
||||
install -m 755 tools/trust_merger /usr/local/bin/
|
||||
git rev-parse @ 2>/dev/null > .commit_id
|
||||
improved_git rev-parse @ 2>/dev/null > .commit_id
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -633,6 +795,7 @@ grab_version()
|
||||
#
|
||||
find_toolchain()
|
||||
{
|
||||
[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && { echo "/usr/bin"; return; }
|
||||
local compiler=$1
|
||||
local expression=$2
|
||||
local dist=10
|
||||
@@ -661,12 +824,12 @@ find_toolchain()
|
||||
done
|
||||
echo "$toolchain"
|
||||
# logging a stack of used compilers.
|
||||
if [[ -f "${DEST}"/debug/compiler.log ]]; then
|
||||
if ! grep -q "$toolchain" "${DEST}"/debug/compiler.log; then
|
||||
echo "$toolchain" >> "${DEST}"/debug/compiler.log;
|
||||
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;
|
||||
fi
|
||||
else
|
||||
echo "$toolchain" >> "${DEST}"/debug/compiler.log;
|
||||
echo "$toolchain" >> "${DEST}"/${LOG_SUBPATH}/compiler.log;
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -761,8 +924,8 @@ process_patch_file()
|
||||
# detect and remove files which patch will create
|
||||
lsdiff -s --strip=1 "${patch}" | grep '^+' | awk '{print $2}' | xargs -I % sh -c 'rm -f %'
|
||||
|
||||
echo "Processing file $patch" >> "${DEST}"/debug/patching.log
|
||||
patch --batch --silent -p1 -N < "${patch}" >> "${DEST}"/debug/patching.log 2>&1
|
||||
echo "Processing file $patch" >> "${DEST}"/${LOG_SUBPATH}/patching.log
|
||||
patch --batch --silent -p1 -N < "${patch}" >> "${DEST}"/${LOG_SUBPATH}/patching.log 2>&1
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_alert "* $status $(basename "${patch}")" "failed" "wrn"
|
||||
@@ -770,7 +933,7 @@ process_patch_file()
|
||||
else
|
||||
display_alert "* $status $(basename "${patch}")" "" "info"
|
||||
fi
|
||||
echo >> "${DEST}"/debug/patching.log
|
||||
echo >> "${DEST}"/${LOG_SUBPATH}/patching.log
|
||||
}
|
||||
|
||||
userpatch_create()
|
||||
@@ -805,7 +968,7 @@ userpatch_create()
|
||||
read -e -p "Patch description: " -i "$COMMIT_MESSAGE" COMMIT_MESSAGE
|
||||
[[ -z "$COMMIT_MESSAGE" ]] && COMMIT_MESSAGE="Patching something"
|
||||
git commit -s -m "$COMMIT_MESSAGE"
|
||||
git format-patch -1 HEAD --stdout --signature="Created with Armbian build tools https://github.com/armbian/build" > "${patch}"
|
||||
git format-patch -1 HEAD --stdout --signature="Created with orangepi build tools https://github.com/orangepi-xunlong/build" > "${patch}"
|
||||
PATCHFILE=$(git format-patch -1 HEAD)
|
||||
rm $PATCHFILE # delete the actual file
|
||||
# create a symlink to have a nice name ready
|
||||
@@ -838,44 +1001,34 @@ userpatch_create()
|
||||
#
|
||||
overlayfs_wrapper()
|
||||
{
|
||||
local operation="$1"
|
||||
|
||||
if [[ $operation == wrap ]]; then
|
||||
|
||||
local srcdir="$2"
|
||||
local description="$3"
|
||||
|
||||
mkdir -p /tmp/overlay_components/ /tmp/orangepi_build/
|
||||
local tempdir workdir mergeddir
|
||||
tempdir=$(mktemp -d --tmpdir="/tmp/overlay_components/")
|
||||
workdir=$(mktemp -d --tmpdir="/tmp/overlay_components/")
|
||||
mergeddir=$(mktemp -d --suffix="_$description" --tmpdir="/tmp/orangepi_build/")
|
||||
|
||||
mount -t overlay overlay -o lowerdir="$srcdir",upperdir="$tempdir",workdir="$workdir" "$mergeddir"
|
||||
# this is executed in a subshell, so use temp files to pass extra data outside
|
||||
|
||||
echo "$tempdir" >> /tmp/.overlayfs_wrapper_cleanup
|
||||
echo "$mergeddir" >> /tmp/.overlayfs_wrapper_umount
|
||||
echo "$mergeddir" >> /tmp/.overlayfs_wrapper_cleanup
|
||||
echo "$mergeddir"
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ $operation == cleanup ]]; then
|
||||
|
||||
if [[ -f /tmp/.overlayfs_wrapper_umount ]]; then
|
||||
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
|
||||
[[ $dir == /tmp/* ]] && rm -rf "$dir"
|
||||
done
|
||||
fi
|
||||
|
||||
rm -f /tmp/.overlayfs_wrapper_umount /tmp/.overlayfs_wrapper_cleanup
|
||||
fi
|
||||
local operation="$1"
|
||||
if [[ $operation == wrap ]]; then
|
||||
local srcdir="$2"
|
||||
local description="$3"
|
||||
mkdir -p /tmp/overlay_components/ /tmp/orangepi_build/
|
||||
local tempdir workdir mergeddir
|
||||
tempdir=$(mktemp -d --tmpdir="/tmp/overlay_components/")
|
||||
workdir=$(mktemp -d --tmpdir="/tmp/overlay_components/")
|
||||
mergeddir=$(mktemp -d --suffix="_$description" --tmpdir="/tmp/orangepi_build/")
|
||||
mount -t overlay overlay -o lowerdir="$srcdir",upperdir="$tempdir",workdir="$workdir" "$mergeddir"
|
||||
# this is executed in a subshell, so use temp files to pass extra data outside
|
||||
echo "$tempdir" >> /tmp/.overlayfs_wrapper_cleanup
|
||||
echo "$mergeddir" >> /tmp/.overlayfs_wrapper_umount
|
||||
echo "$mergeddir" >> /tmp/.overlayfs_wrapper_cleanup
|
||||
echo "$mergeddir"
|
||||
return
|
||||
fi
|
||||
if [[ $operation == cleanup ]]; then
|
||||
if [[ -f /tmp/.overlayfs_wrapper_umount ]]; then
|
||||
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
|
||||
[[ $dir == /tmp/* ]] && rm -rf "$dir"
|
||||
done
|
||||
fi
|
||||
rm -f /tmp/.overlayfs_wrapper_umount /tmp/.overlayfs_wrapper_cleanup
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user