mirror of
https://github.com/Fishwaldo/build.git
synced 2025-06-29 09:39:11 +00:00
Refactoring for overlayfs_wrapper
This commit is contained in:
parent
7d21b3a810
commit
a371bb6c5f
2 changed files with 34 additions and 36 deletions
50
common.sh
50
common.sh
|
@ -25,8 +25,11 @@
|
||||||
|
|
||||||
compile_uboot()
|
compile_uboot()
|
||||||
{
|
{
|
||||||
local ubootdir="$1"
|
if [[ $USE_OVERLAYFS == yes ]]; then
|
||||||
|
local ubootdir=$(overlayfs_wrapper "wrap" "$SOURCES/$BOOTSOURCEDIR" "u-boot_${LINUXFAMILY}_${BRANCH}")
|
||||||
|
else
|
||||||
|
local ubootdir="$SOURCES/$BOOTSOURCEDIR"
|
||||||
|
fi
|
||||||
cd "$ubootdir"
|
cd "$ubootdir"
|
||||||
|
|
||||||
[[ $FORCE_CHECKOUT == yes ]] && advanced_patch "u-boot" "$BOOTDIR-$BRANCH" "$BOARD" "$BOOTDIR-$BRANCH"
|
[[ $FORCE_CHECKOUT == yes ]] && advanced_patch "u-boot" "$BOOTDIR-$BRANCH" "$BOARD" "$BOOTDIR-$BRANCH"
|
||||||
|
@ -38,6 +41,11 @@ compile_uboot()
|
||||||
local version=$(grab_version "$ubootdir")
|
local version=$(grab_version "$ubootdir")
|
||||||
|
|
||||||
display_alert "Compiling uboot" "$version" "info"
|
display_alert "Compiling uboot" "$version" "info"
|
||||||
|
# if requires specific toolchain, check if default is suitable
|
||||||
|
if [[ -n $UBOOT_NEEDS_GCC ]] && ! check_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" ; then
|
||||||
|
# try to find suitable in $SRC/toolchains, exit if not found
|
||||||
|
find_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" "UBOOT_TOOLCHAIN"
|
||||||
|
fi
|
||||||
display_alert "Compiler version" "${UBOOT_COMPILER}gcc $(eval ${UBOOT_TOOLCHAIN:+env PATH=$UBOOT_TOOLCHAIN:$PATH} ${UBOOT_COMPILER}gcc -dumpversion)" "info"
|
display_alert "Compiler version" "${UBOOT_COMPILER}gcc $(eval ${UBOOT_TOOLCHAIN:+env PATH=$UBOOT_TOOLCHAIN:$PATH} ${UBOOT_COMPILER}gcc -dumpversion)" "info"
|
||||||
|
|
||||||
eval CCACHE_BASEDIR="$(pwd)" ${UBOOT_TOOLCHAIN:+env PATH=$UBOOT_TOOLCHAIN:$PATH} \
|
eval CCACHE_BASEDIR="$(pwd)" ${UBOOT_TOOLCHAIN:+env PATH=$UBOOT_TOOLCHAIN:$PATH} \
|
||||||
|
@ -67,10 +75,11 @@ compile_uboot()
|
||||||
|
|
||||||
# create .deb package
|
# create .deb package
|
||||||
local uboot_name=${CHOSEN_UBOOT}_${REVISION}_${ARCH}
|
local uboot_name=${CHOSEN_UBOOT}_${REVISION}_${ARCH}
|
||||||
mkdir -p $DEST/debs/$uboot_name/usr/lib/{u-boot,$uboot_name} $DEST/debs/$uboot_name/DEBIAN
|
rm -rf $uboot_name
|
||||||
|
mkdir -p $uboot_name/usr/lib/{u-boot,$uboot_name} $uboot_name/DEBIAN
|
||||||
|
|
||||||
# set up postinstall script
|
# set up postinstall script
|
||||||
cat <<-EOF > $DEST/debs/$uboot_name/DEBIAN/postinst
|
cat <<-EOF > $uboot_name/DEBIAN/postinst
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source /usr/lib/u-boot/platform_install.sh
|
source /usr/lib/u-boot/platform_install.sh
|
||||||
[[ \$DEVICE == /dev/null ]] && exit 0
|
[[ \$DEVICE == /dev/null ]] && exit 0
|
||||||
|
@ -81,17 +90,17 @@ compile_uboot()
|
||||||
sync
|
sync
|
||||||
exit 0
|
exit 0
|
||||||
EOF
|
EOF
|
||||||
chmod 755 $DEST/debs/$uboot_name/DEBIAN/postinst
|
chmod 755 $uboot_name/DEBIAN/postinst
|
||||||
|
|
||||||
# declare -f on non-defined function does not do anything
|
# declare -f on non-defined function does not do anything
|
||||||
cat <<-EOF > $DEST/debs/$uboot_name/usr/lib/u-boot/platform_install.sh
|
cat <<-EOF > $uboot_name/usr/lib/u-boot/platform_install.sh
|
||||||
DIR=/usr/lib/$uboot_name
|
DIR=/usr/lib/$uboot_name
|
||||||
$(declare -f write_uboot_platform)
|
$(declare -f write_uboot_platform)
|
||||||
$(declare -f setup_write_uboot_platform)
|
$(declare -f setup_write_uboot_platform)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# set up control file
|
# set up control file
|
||||||
cat <<-END > $DEST/debs/$uboot_name/DEBIAN/control
|
cat <<-END > $uboot_name/DEBIAN/control
|
||||||
Package: linux-u-boot-${BOARD}-${BRANCH}
|
Package: linux-u-boot-${BOARD}-${BRANCH}
|
||||||
Version: $REVISION
|
Version: $REVISION
|
||||||
Architecture: $ARCH
|
Architecture: $ARCH
|
||||||
|
@ -108,25 +117,25 @@ compile_uboot()
|
||||||
# copy files to build directory
|
# copy files to build directory
|
||||||
for f in $UBOOT_FILES; do
|
for f in $UBOOT_FILES; do
|
||||||
[[ ! -f $f ]] && exit_with_error "U-boot file not found" "$(basename $f)"
|
[[ ! -f $f ]] && exit_with_error "U-boot file not found" "$(basename $f)"
|
||||||
cp $f $DEST/debs/$uboot_name/usr/lib/$uboot_name
|
cp $f $uboot_name/usr/lib/$uboot_name
|
||||||
done
|
done
|
||||||
|
|
||||||
cd $DEST/debs
|
display_alert "Building deb" "${uboot_name}.deb" "info"
|
||||||
display_alert "Building deb" "$uboot_name.deb" "info"
|
|
||||||
eval 'dpkg -b $uboot_name 2>&1' ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'}
|
eval 'dpkg -b $uboot_name 2>&1' ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'}
|
||||||
rm -rf $uboot_name
|
rm -rf $uboot_name
|
||||||
|
|
||||||
local filesize=$(wc -c $DEST/debs/$uboot_name.deb | cut -f 1 -d ' ')
|
[[ ! -f ${uboot_name}.deb || $(stat -c '%s' "${uboot_name}.deb") -lt 5000 ]] && exit_with_error "Building u-boot failed"
|
||||||
|
|
||||||
if [[ $filesize -lt 50000 ]]; then
|
mv ${uboot_name}.deb $DEST/debs/
|
||||||
rm $DEST/debs/$uboot_name.deb
|
|
||||||
exit_with_error "Building u-boot failed, check configuration"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_kernel()
|
compile_kernel()
|
||||||
{
|
{
|
||||||
local kerneldir="$1"
|
if [[ $USE_OVERLAYFS == yes ]]; then
|
||||||
|
local kerneldir=$(overlayfs_wrapper "wrap" "$SOURCES/$LINUXSOURCEDIR" "kernel_${LINUXFAMILY}_${BRANCH}")
|
||||||
|
else
|
||||||
|
local kerneldir="$SOURCES/$LINUXSOURCEDIR"
|
||||||
|
fi
|
||||||
cd "$kerneldir"
|
cd "$kerneldir"
|
||||||
|
|
||||||
# this is a patch that Ubuntu Trusty compiler works
|
# this is a patch that Ubuntu Trusty compiler works
|
||||||
|
@ -145,6 +154,11 @@ compile_kernel()
|
||||||
local version=$(grab_version "$kerneldir")
|
local version=$(grab_version "$kerneldir")
|
||||||
|
|
||||||
display_alert "Compiling $BRANCH kernel" "$version" "info"
|
display_alert "Compiling $BRANCH kernel" "$version" "info"
|
||||||
|
# if requires specific toolchain, check if default is suitable
|
||||||
|
if [[ -n $KERNEL_NEEDS_GCC ]] && ! check_toolchain "$KERNEL" "$KERNEL_NEEDS_GCC" ; then
|
||||||
|
# try to find suitable in $SRC/toolchains, exit if not found
|
||||||
|
find_toolchain "KERNEL" "$KERNEL_NEEDS_GCC" "KERNEL_TOOLCHAIN"
|
||||||
|
fi
|
||||||
display_alert "Compiler version" "${KERNEL_COMPILER}gcc $(eval ${KERNEL_TOOLCHAIN:+env PATH=$KERNEL_TOOLCHAIN:$PATH} ${KERNEL_COMPILER}gcc -dumpversion)" "info"
|
display_alert "Compiler version" "${KERNEL_COMPILER}gcc $(eval ${KERNEL_TOOLCHAIN:+env PATH=$KERNEL_TOOLCHAIN:$PATH} ${KERNEL_COMPILER}gcc -dumpversion)" "info"
|
||||||
|
|
||||||
# use proven config
|
# use proven config
|
||||||
|
@ -441,10 +455,6 @@ userpatch_create()
|
||||||
#
|
#
|
||||||
overlayfs_wrapper()
|
overlayfs_wrapper()
|
||||||
{
|
{
|
||||||
if [[ $USE_OVERLAYFS != yes && -n $2 ]]; then
|
|
||||||
echo "$2"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local operation="$1"
|
local operation="$1"
|
||||||
if [[ $operation == wrap ]]; then
|
if [[ $operation == wrap ]]; then
|
||||||
local srcdir="$2"
|
local srcdir="$2"
|
||||||
|
|
20
main.sh
20
main.sh
|
@ -47,8 +47,8 @@ date +"%d_%m_%Y-%H_%M_%S" > $DEST/debug/timestamp
|
||||||
(cd $DEST/debug && find . -name '*.tgz' -atime +7 -delete) > /dev/null
|
(cd $DEST/debug && find . -name '*.tgz' -atime +7 -delete) > /dev/null
|
||||||
|
|
||||||
# compile.sh version checking
|
# compile.sh version checking
|
||||||
ver1=$(awk -F"=" '/^# VERSION/ {print $2}' <"$SRC/compile.sh")
|
ver1=$(awk -F"=" '/^# VERSION/ {print $2}' <$SRC/compile.sh )
|
||||||
ver2=$(awk -F"=" '/^# VERSION/ {print $2}' <"$SRC/lib/compile.sh" 2>/dev/null) || ver2=0
|
ver2=$(awk -F"=" '/^# VERSION/ {print $2}' <$SRC/lib/compile.sh 2>/dev/null) || ver2=0
|
||||||
if [[ -z $ver1 || $ver1 -lt $ver2 ]]; then
|
if [[ -z $ver1 || $ver1 -lt $ver2 ]]; then
|
||||||
display_alert "File $0 is outdated. Please overwrite it with an updated version from" "$SRC/lib" "wrn"
|
display_alert "File $0 is outdated. Please overwrite it with an updated version from" "$SRC/lib" "wrn"
|
||||||
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
|
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
|
||||||
|
@ -200,24 +200,12 @@ done
|
||||||
|
|
||||||
# Compile u-boot if packed .deb does not exist
|
# Compile u-boot if packed .deb does not exist
|
||||||
if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
|
if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
|
||||||
# if requires specific toolchain, check if default is suitable
|
compile_uboot
|
||||||
if [[ -n $UBOOT_NEEDS_GCC ]] && ! check_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" ; then
|
|
||||||
# try to find suitable in $SRC/toolchains, exit if not found
|
|
||||||
find_toolchain "UBOOT" "$UBOOT_NEEDS_GCC" "UBOOT_TOOLCHAIN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
compile_uboot $(overlayfs_wrapper "wrap" "$SOURCES/$BOOTSOURCEDIR" "u-boot_${LINUXFAMILY}_${BRANCH}")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compile kernel if packed .deb does not exist
|
# Compile kernel if packed .deb does not exist
|
||||||
if [[ ! -f $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
|
if [[ ! -f $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
|
||||||
# if requires specific toolchain, check if default is suitable
|
compile_kernel
|
||||||
if [[ -n $KERNEL_NEEDS_GCC ]] && ! check_toolchain "$KERNEL" "$KERNEL_NEEDS_GCC" ; then
|
|
||||||
# try to find suitable in $SRC/toolchains, exit if not found
|
|
||||||
find_toolchain "KERNEL" "$KERNEL_NEEDS_GCC" "KERNEL_TOOLCHAIN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
compile_kernel $(overlayfs_wrapper "wrap" "$SOURCES/$LINUXSOURCEDIR" "kernel_${LINUXFAMILY}_${BRANCH}")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
overlayfs_wrapper "cleanup"
|
overlayfs_wrapper "cleanup"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue