Improve logging

This commit is contained in:
zador-blood-stained 2016-06-27 14:13:27 +03:00
parent 7f0a3e16d7
commit 1f44c77c6a
7 changed files with 32 additions and 21 deletions

View file

@ -66,11 +66,15 @@ compile_uboot()
mkdir -p $DEST/debs/$uboot_name/usr/lib/$uboot_name $DEST/debs/$uboot_name/DEBIAN
# set up postinstall script
printf '#!/bin/bash\nset -e\n[[ $DEVICE == /dev/null ]] && exit 0\n[[ -z $DEVICE ]] && DEVICE="/dev/mmcblk0"\n' > $DEST/debs/$uboot_name/DEBIAN/postinst
printf "DIR=/usr/lib/$uboot_name\n" >> $DEST/debs/$uboot_name/DEBIAN/postinst
declare -f write_uboot_platform >> $DEST/debs/$uboot_name/DEBIAN/postinst
printf 'write_uboot_platform $DIR $DEVICE\n' >> $DEST/debs/$uboot_name/DEBIAN/postinst
printf 'exit 0\n' >> $DEST/debs/$uboot_name/DEBIAN/postinst
cat <<-EOF > $DEST/debs/$uboot_name/DEBIAN/postinst
#!/bin/bash
[[ \$DEVICE == /dev/null ]] && exit 0
[[ -z \$DEVICE ]] && DEVICE="/dev/mmcblk0"
DIR=/usr/lib/$uboot_name
$(declare -f write_uboot_platform)
write_uboot_platform \$DIR \$DEVICE
exit 0
EOF
chmod 755 $DEST/debs/$uboot_name/DEBIAN/postinst
# set up control file
@ -94,7 +98,7 @@ compile_uboot()
cd $DEST/debs
display_alert "Target directory" "$DEST/debs/" "info"
display_alert "Building deb" "$uboot_name.deb" "info"
dpkg -b $uboot_name >> $DEST/debug/install.log 2>&1
dpkg -b $uboot_name >> $DEST/debug/compilation.log 2>&1
rm -rf $uboot_name
FILESIZE=$(wc -c $DEST/debs/$uboot_name.deb | cut -f 1 -d ' ')
@ -310,8 +314,7 @@ process_patch_file() {
| awk '{print $NF}' | sed -n 's/,//p' | xargs -I % sh -c 'rm %'
# main patch command
echo "$patch $description" >> $DEST/debug/install.log
patch --batch --silent -p1 -N < $patch >> $DEST/debug/install.log 2>&1
patch --batch --silent -p1 -N < $patch >> $DEST/debug/patching.log 2>&1
if [[ $? -ne 0 ]]; then
display_alert "... $(basename $patch)" "failed" "wrn";

View file

@ -157,8 +157,16 @@ PACKAGE_LIST="$PACKAGE_LIST $PACKAGE_LIST_RELEASE $PACKAGE_LIST_ADDITIONAL"
[[ $BUILD_DESKTOP == yes ]] && PACKAGE_LIST="$PACKAGE_LIST $PACKAGE_LIST_DESKTOP"
# debug
echo -e "Config: $LINUXCONFIG\nKernel source: $LINUXKERNEL\nBranch: $KERNELBRANCH" >> $DEST/debug/install.log
echo -e "linuxsource: $LINUXSOURCE\nOffset: $OFFSET\nbootsize: $BOOTSIZE" >> $DEST/debug/install.log
echo -e "bootloader: $BOOTLOADER\nbootsource: $BOOTSOURCE\nbootbranch: $BOOTBRANCH" >> $DEST/debug/install.log
echo -e "CPU $CPUMIN / $CPUMAX with $GOVERNOR" >> $DEST/debug/install.log
cat <<-EOF >> $DEST/debug/output.log
## BUILD CONFIGURATION
Config: $LINUXCONFIG
Kernel source: $LINUXKERNEL
Branch: $KERNELBRANCH
linuxsource: $LINUXSOURCE
Offset: $OFFSET
bootsize: $BOOTSIZE
bootloader: $BOOTLOADER
bootsource: $BOOTSOURCE
bootbranch: $BOOTBRANCH
CPU $CPUMIN / $CPUMAX with $GOVERNOR
EOF

View file

@ -203,7 +203,7 @@ losetup $LOOP $RAWIMAGE
PARTSTART=$(parted $LOOP unit s print -sm | tail -1 | cut -d: -f2 | sed 's/s//')
PARTEND=$(parted $LOOP unit s print -sm | head -3 | tail -1 | cut -d: -f3 | sed 's/s//') # end of first partition
PARTSTARTBLOCKS=$(($PARTSTART*512))
echo "PARTSTART $PARTSTART PARTEND $PARTEND PARTSTARTBLOCKS $PARTSTARTBLOCKS" >> $DEST/debug/install.log
echo "PARTSTART $PARTSTART PARTEND $PARTEND PARTSTARTBLOCKS $PARTSTARTBLOCKS" >> $DEST/debug/output.log
sleep 1; losetup -d $LOOP
# convert from EXT4 to EXT2
@ -215,7 +215,7 @@ resize2fs $LOOP -M >/dev/null 2>&1
BLOCKSIZE=$(LANGUAGE=english tune2fs -l $LOOP | grep "Block count" | awk '{ print $(NF)}')
RESERVEDBLOCKSIZE=$(LANGUAGE=english tune2fs -l $LOOP | grep "Reserved block count" | awk '{ print $(NF)}')
BLOCKSIZE=$(($PARTSTART+$BLOCKSIZE+50000)) # fixed reserve to be enough for swap file creation
echo "BLOCKSIZE $BLOCKSIZE RESERVEDBLOCKSIZE $RESERVEDBLOCKSIZE" >> $DEST/debug/install.log
echo "BLOCKSIZE $BLOCKSIZE RESERVEDBLOCKSIZE $RESERVEDBLOCKSIZE" >> $DEST/debug/output.log
resize2fs $LOOP $BLOCKSIZE >/dev/null 2>&1
tune2fs -O has_journal $LOOP >/dev/null 2>&1
tune2fs -o journal_data_writeback $LOOP >/dev/null 2>&1
@ -350,7 +350,7 @@ while [[ $i -lt $skupaj ]]; do
procent=$(echo "scale=2;($j/$skupaj)*100"|bc)
procent=${procent%.*}
x=${PACKETS[$i]}
chroot $CACHEDIR/sdcard /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -qq -y install $x --no-install-recommends" >> $DEST/debug/install.log 2>&1
chroot $CACHEDIR/sdcard /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -qq -y install $x --no-install-recommends" >> $DEST/debug/debootstrap.log 2>&1
if [ $? -ne 0 ]; then display_alert "Installation of package failed" "$INSTALL" "err"; exit 1; fi
printf '%.0f\n' $procent | dialog --backtitle "$backtitle" --title "$2" --gauge "\n\n$x" 9 70
i=$[$i+1]

View file

@ -48,4 +48,4 @@ build_firmware()
# install
display_alert "Installing linux firmware" "$REVISION" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/armbian-firmware_${REVISION}_all.deb" >> $DEST/debug/output.log
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/armbian-firmware_${REVISION}_all.deb" >> $DEST/debug/install.log

View file

@ -128,5 +128,5 @@ compile_hostapd()
[[ ! -f $DEST/debs/armbian-hostapd-${RELEASE}_${REVISION}_${ARCH}.deb ]] && compile_hostapd
display_alert "Installing" "armbian-hostapd-${RELEASE}_${REVISION}_${ARCH}.deb" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -r hostapd" >> $DEST/debug/output.log
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/armbian-hostapd-${RELEASE}_${REVISION}_${ARCH}.deb" >> $DEST/debug/output.log
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -r hostapd" >> $DEST/debug/install.log
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/armbian-hostapd-${RELEASE}_${REVISION}_${ARCH}.deb" >> $DEST/debug/install.log

View file

@ -179,7 +179,7 @@ display_alert()
#--------------------------------------------------------------------------------------------------------------------------------
{
# log function parameters to install.log
echo "Displaying message: $@" >> $DEST/debug/install.log
echo "Displaying message: $@" >> $DEST/debug/output.log
local tmp=""
[[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]"

View file

@ -155,7 +155,7 @@ source $SRC/lib/configuration.sh
# The name of the job
VERSION="Armbian $REVISION ${BOARD^} $DISTRIBUTION $RELEASE $BRANCH"
echo `date +"%d.%m.%Y %H:%M:%S"` $VERSION >> $DEST/debug/install.log
echo `date +"%d.%m.%Y %H:%M:%S"` $VERSION >> $DEST/debug/output.log
display_alert "Starting Armbian build script" "@host" "info"