Default config as symlink and better kernel package metadata (#1446)

* Default config as symlink for comfort switching between several custom boards.

* Better metadata for kernel packages.

* Local changes with detailed git diff.

* Support for gz and bz2 compression (supported by balenaEtcher).
Support for generation sha without 7z compression.
Bug fix for current directory changing in 7z compression.

* Remove bzip2 and use fast pigz for gziping.

* Deleted typo with "gz" in 7z section.
Separated parameter for gpg.

* Information about exit command.
This commit is contained in:
Przemysław Sztoch
2019-07-06 22:35:43 +02:00
committed by Igor Pečovnik
parent 605a7b8110
commit 31b56af49f
4 changed files with 65 additions and 19 deletions

View File

@@ -31,15 +31,21 @@ else
exit 255
fi
# copy default config from the template
[[ ! -f "${SRC}"/config-default.conf ]] && cp "${SRC}"/config/templates/config-example.conf "${SRC}"/config-default.conf
# source build configuration file
if [[ -n $1 && -f "${SRC}/config-$1.conf" ]]; then
display_alert "Using config file" "config-$1.conf" "info"
# shellcheck source=/dev/null
source "${SRC}/config-$1.conf"
else
# copy default config from the template
if [[ ! -f "${SRC}"/config-default.conf ]]; then
display_alert "Create example config file using template" "config-default.conf" "info"
if [[ ! -f "${SRC}"/config-example.conf ]]; then
cp "${SRC}"/config/templates/config-example.conf "${SRC}"/config-example.conf || exit 1
fi
ln -s config-example.conf "${SRC}"/config-default.conf || exit 1
fi
display_alert "Using config file" "config-default.conf" "info"
# shellcheck source=/dev/null
source "${SRC}"/config-default.conf
@@ -67,8 +73,19 @@ if [[ ! -f $SRC/.ignore_changes ]]; then
CHANGED_FILES=$(git diff --name-only)
if [[ -n $CHANGED_FILES ]]; then
echo -e "[\e[0;35m warn \x1B[0m] Can't update since you made changes to: \e[0;32m\n${CHANGED_FILES}\x1B[0m"
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
read -r
while true; do
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m or \e[0;33mexit\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue, \e[0;33mdiff\x1B[0m to display changes"
read -r
if [[ "$REPLY" == "diff" ]]; then
git diff
elif [[ "$REPLY" == "exit" ]]; then
exit 1
elif [[ "$REPLY" == "" ]]; then
break
else
echo "Unknown command!"
fi
done
else
git checkout "${LIB_TAG:-master}"
fi

View File

@@ -590,22 +590,49 @@ create_image()
cp $SDCARD/etc/armbian.txt $DESTIMG
mv ${SDCARD}.raw $DESTIMG/${version}.img
if [[ $COMPRESS_OUTPUTIMAGE == yes && $BUILD_ALL != yes ]]; then
[[ -f $DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME ]] && cp $DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME $DESTIMG/
# compress image
cd $DESTIMG
sha256sum -b ${version}.img > sha256sum.sha
if [[ -n $GPG_PASS ]]; then
echo $GPG_PASS | gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${version}.img
fi
display_alert "Compressing" "$DEST/images/${version}.img" "info"
7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $DEST/images/${version}.7z ${version}.key ${version}.img armbian.txt *.asc sha256sum.sha >/dev/null 2>&1
fi
#
if [[ $BUILD_ALL != yes ]]; then
if [[ $COMPRESS_OUTPUTIMAGE == yes ]]; then
COMPRESS_OUTPUTIMAGE="sha,gpg,7z"
fi
if [[ $COMPRESS_OUTPUTIMAGE == *sha* ]]; then
cd $DESTIMG
display_alert "SHA256 calculating" "${version}.img" "info"
sha256sum -b ${version}.img > sha256sum.sha
cp sha256sum.sha "$DEST/images/${version}.img.sha"
cd ..
fi
if [[ $COMPRESS_OUTPUTIMAGE == *gpg* ]]; then
cd $DESTIMG
if [[ -n $GPG_PASS ]]; then
display_alert "GPG signing" "${version}.img" "info"
echo $GPG_PASS | gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${version}.img || exit 1
cp ${version}.img.asc "$DEST/images/${version}.img.asc"
else
display_alert "GPG signing skipped - no GPG_PASS" "${version}.img" "wrn"
fi
cd ..
fi
if [[ $COMPRESS_OUTPUTIMAGE == *7z* ]]; then
[[ -f $DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME ]] && cp $DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME $DESTIMG/
# compress image
cd $DESTIMG
display_alert "Compressing" "$DEST/images/${version}.7z" "info"
7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $DEST/images/${version}.7z ${version}.key ${version}.img armbian.txt *.asc sha256sum.sha >/dev/null 2>&1
cd ..
fi
if [[ $COMPRESS_OUTPUTIMAGE == *gz* ]]; then
display_alert "Compressing" "$DEST/images/${version}.img.gz" "info"
pigz < $DESTIMG/${version}.img > $DEST/images/${version}.img.gz
fi
mv $DESTIMG/${version}.img $DEST/images/${version}.img
rm -rf $DESTIMG
fi
display_alert "Done building" "$DEST/images/${version}.img" "info"
# call custom post build hook
@@ -617,7 +644,7 @@ create_image()
balena-etcher $DEST/images/${version}.img -d $CARD_DEVICE -y
if [ $? -eq 0 ]; then
display_alert "Writing succeeded" "${version}.img" "info"
else
else
display_alert "Writing failed" "${version}.img" "err"
fi
fi

View File

@@ -546,7 +546,7 @@ prepare_host()
nfs-kernel-server btrfs-tools ncurses-term p7zip-full kmod dosfstools libc6-dev-armhf-cross \
curl patchutils python liblz4-tool libpython2.7-dev linux-base swig libpython-dev aptly acl \
locales ncurses-base pixz dialog systemd-container udev lib32stdc++6 libc6-i386 lib32ncurses5 lib32tinfo5 \
bison libbison-dev flex libfl-dev cryptsetup gpgv1 gnupg1 cpio aria2"
bison libbison-dev flex libfl-dev cryptsetup gpgv1 gnupg1 cpio aria2 pigz"
local codename=$(lsb_release -sc)
display_alert "Build host OS release" "${codename:-(unknown)}" "info"

View File

@@ -349,6 +349,7 @@ fi
# Compile kernel if packed .deb does not exist
if [[ ! -f ${DEST}/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
KDEB_CHANGELOG_DIST=$RELEASE
compile_kernel
fi
@@ -391,4 +392,5 @@ $([[ -n $RELEASE ]] && echo "RELEASE=${RELEASE} ")\
$([[ -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 $COMPRESS_OUTPUTIMAGE ]] && echo "COMPRESS_OUTPUTIMAGE=${COMPRESS_OUTPUTIMAGE} ")\
" "info"