Merge remote-tracking branch 'thingos/dev' into dev

This commit is contained in:
Calin Crisan 2019-10-20 13:53:26 +03:00
commit 4b5e40d430
4 changed files with 107 additions and 127 deletions

View File

@ -25,6 +25,7 @@ rm -f ${TARGET}/etc/udev/hwdb.d/20-pci-vendor-model.hwdb
rm -f ${TARGET}/etc/hostname rm -f ${TARGET}/etc/hostname
rm -f ${TARGET}/etc/os-release rm -f ${TARGET}/etc/os-release
rm -f ${TARGET}/etc/hostapd.conf rm -f ${TARGET}/etc/hostapd.conf
rm -f ${TARGET}/etc/timezone
# /usr/share stuff # /usr/share stuff
rm -rf ${TARGET}/usr/share/bash-completion/ rm -rf ${TARGET}/usr/share/bash-completion/

View File

@ -15,12 +15,13 @@ function exit_usage() {
echo "" echo ""
echo "Statuses:" echo "Statuses:"
echo " idle" echo " idle"
echo " downloading <version>" echo " downloading [version]"
echo " downloaded <version>" echo " downloaded [version]"
echo " extracting <version>" echo " extracting [version]"
echo " extracted <version>" echo " extracted [version]"
echo " flashing boot <version>" echo " flashing boot [version]"
echo " boot ready <version>" echo " boot flashed [version]"
echo " rebooting [version]"
echo "" echo ""
exit 1 exit 1
@ -51,7 +52,14 @@ VER_FILE=${FW_DIR}/version
BOOT_INFO_FILE=${FW_DIR}/boot_info BOOT_INFO_FILE=${FW_DIR}/boot_info
ROOT_INFO_FILE=${FW_DIR}/root_info ROOT_INFO_FILE=${FW_DIR}/root_info
BOOT_READY_FILE=${FW_DIR}/boot_flash_ready
DOWNLOAD_STARTED_FILE=${FW_DIR}/download_started
DOWNLOAD_DONE_FILE=${FW_DIR}/download_done
EXTRACT_STARTED_FILE=${FW_DIR}/extract_started
EXTRACT_DONE_FILE=${FW_DIR}/extract_done
FLASH_BOOT_STARTED_FILE=${FW_DIR}/flash_boot_started
FLASH_BOOT_DONE_FILE=${FW_DIR}/flash_boot_done
FLASH_REBOOT_STARTED_FILE=${FW_DIR}/flash_reboot_started
TMP_BOOT_DIR=/tmp/fwupdate_boot TMP_BOOT_DIR=/tmp/fwupdate_boot
TMP_ROOT_DIR=/tmp/fwupdate_root TMP_ROOT_DIR=/tmp/fwupdate_root
@ -97,9 +105,16 @@ function cleanup_on_exit() {
#### disk & partition devices #### #### disk & partition devices ####
BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1) BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
ROOT_DEV=${BOOT_DEV:0:-1}2 if [[ -n "${BOOT_DEV}" ]]; then
DATA_DEV=${BOOT_DEV:0:-1}3 ROOT_DEV=${BOOT_DEV:0:-1}2
DISK_DEV=$(mount | grep /boot | cut -d ' ' -f 1) DATA_DEV=${BOOT_DEV:0:-1}3
else # boot partition not mounted, trying with data partition
DATA_DEV=$(mount | grep /data | cut -d ' ' -f 1)
BOOT_DEV=${DATA_DEV:0:-1}1
ROOT_DEV=${BOOT_DEV:0:-1}2
fi
DISK_DEV=${BOOT_DEV}
if [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2 if [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
DISK_DEV=${BASH_REMATCH[1]} DISK_DEV=${BASH_REMATCH[1]}
elif [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2 elif [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
@ -231,11 +246,19 @@ function show_current() {
#### download #### #### download ####
function do_download() { function do_download() {
echo "downloading..."
rm -rf ${FW_DIR}/* rm -rf ${FW_DIR}/*
mkdir -p ${FW_DIR} mkdir -p ${FW_DIR}
rm -f ${DOWNLOAD_DONE_FILE}
rm -f ${EXTRACT_STARTED_FILE}
rm -f ${EXTRACT_DONE_FILE}
rm -f ${FLASH_BOOT_STARTED_FILE}
rm -f ${FLASH_BOOT_DONE_FILE}
rm -f ${FLASH_REBOOT_STARTED_FILE}
touch ${DOWNLOAD_STARTED_FILE}
echo "downloading..."
# Look for local file first # Look for local file first
if [[ -f "$1" ]]; then if [[ -f "$1" ]]; then
version="custom" version="custom"
@ -300,23 +323,10 @@ function do_download() {
exit 1 exit 1
fi fi
touch ${DOWNLOAD_DONE_FILE}
set -e set -e
} }
function download_status() {
if [[ -f ${CURL_PID_FILE} ]]; then
pid=$(cat ${CURL_PID_FILE})
if kill -0 ${pid} &>/dev/null; then
echo "running"
return
fi
fi
if [[ -f ${FW_FILE_GZ} || -f ${FW_FILE_XZ} ]]; then
echo "done"
fi
}
#### extract #### #### extract ####
@ -354,13 +364,17 @@ function run_pre_upgrade() {
} }
function do_extract() { function do_extract() {
if ! [[ -f ${FW_FILE_GZ} || -f ${FW_FILE_XZ} ]]; then if ! [[ -f ${FW_FILE_GZ} || -f ${FW_FILE_XZ} ]] || ! [[ -f ${DOWNLOAD_DONE_FILE} ]]; then
echo "firmware file not downloaded" 1>&2 echo "firmware file not downloaded" 1>&2
exit 1 exit 1
fi fi
rm -f ${EXTRACT_DONE_FILE}
rm -f ${FLASH_BOOT_STARTED_FILE}
rm -f ${FLASH_BOOT_DONE_FILE}
rm -f ${FLASH_REBOOT_STARTED_FILE}
rm -f ${FW_FILE_EXTR} rm -f ${FW_FILE_EXTR}
rm -f ${BOOT_READY_FILE} touch ${EXTRACT_STARTED_FILE}
echo "extracting..." echo "extracting..."
@ -414,43 +428,27 @@ function do_extract() {
echo ${root_start} ${root_end} ${root_size} > ${ROOT_INFO_FILE} echo ${root_start} ${root_end} ${root_size} > ${ROOT_INFO_FILE}
run_pre_upgrade run_pre_upgrade
}
function extract_status() { touch ${EXTRACT_DONE_FILE}
if [[ -f ${XZCAT_PID_FILE} ]]; then
pid=$(cat ${XZCAT_PID_FILE})
if kill -0 ${pid} &>/dev/null; then
echo "running"
return
fi
elif [[ -f ${GUNZIP_PID_FILE} ]]; then
pid=$(cat ${GUNZIP_PID_FILE})
if kill -0 ${pid} &>/dev/null; then
echo "running"
return
fi
fi
if [[ -f ${FW_FILE_EXTR} && -f ${ROOT_INFO_FILE} ]]; then
echo "done"
fi
} }
#### flash boot #### #### flash boot ####
function do_flash_boot() { function do_flash_boot() {
if [[ ! -f ${FW_FILE_EXTR} ]]; then if ! [[ -f ${FW_FILE_EXTR} ]] || ! [[ -f ${EXTRACT_DONE_FILE} ]]; then
echo "extracted firmware not present" echo "extracted firmware not present"
return 1 return 1
fi fi
rm -f ${FLASH_BOOT_DONE_FILE}
rm -f ${FLASH_REBOOT_STARTED_FILE}
touch ${FLASH_BOOT_STARTED_FILE}
echo "flashing boot..." echo "flashing boot..."
trap cleanup_on_exit EXIT trap cleanup_on_exit EXIT
rm -f ${BOOT_READY_FILE}
board=$(cat ${SYS_BOARD_FILE}) board=$(cat ${SYS_BOARD_FILE})
boot_info=($(cat ${BOOT_INFO_FILE})) boot_info=($(cat ${BOOT_INFO_FILE}))
@ -464,7 +462,10 @@ function do_flash_boot() {
reallocate_boot_part reallocate_boot_part
dd if=${FW_FILE_EXTR} skip=$((boot_info[0] / 2048)) of=${BOOT_DEV} bs=1048576 count=$((boot_info[2] / 2048)) &>${DD_LOG_FILE} & dd if=${FW_FILE_EXTR} \
skip=$((boot_info[0] / 2048)) \
of=${BOOT_DEV} bs=1048576 \
count=$((boot_info[2] / 2048)) &>${DD_LOG_FILE} &
pid=$! pid=$!
echo ${pid} > ${DD_PID_FILE} echo ${pid} > ${DD_PID_FILE}
wait ${pid} wait ${pid}
@ -477,32 +478,21 @@ function do_flash_boot() {
if [[ -x /usr/libexec/fw-restore-boot-cfg ]]; then if [[ -x /usr/libexec/fw-restore-boot-cfg ]]; then
/usr/libexec/fw-restore-boot-cfg ${FW_DIR}/old_boot 2>/dev/null || true /usr/libexec/fw-restore-boot-cfg ${FW_DIR}/old_boot 2>/dev/null || true
fi fi
touch ${BOOT_READY_FILE}
}
function flash_boot_status() { touch ${FLASH_BOOT_DONE_FILE}
if [[ -f ${DD_PID_FILE} ]]; then
pid=$(cat ${DD_PID_FILE})
if kill -0 ${pid} &>/dev/null; then
echo "running"
return
fi
fi
if [[ -f ${BOOT_READY_FILE} ]]; then
echo "done"
fi
} }
#### flash reboot #### #### flash reboot ####
function do_flash_reboot() { function do_flash_reboot() {
if [[ ! -f ${ROOT_INFO_FILE} ]]; then if ! [[ -f ${ROOT_INFO_FILE} ]] || ! [[ -f ${FLASH_BOOT_DONE_FILE} ]]; then
echo "root partition info file not present" echo "root partition info file not present"
return 1 return 1
fi fi
touch ${FLASH_REBOOT_STARTED_FILE}
echo "preparing for reboot..." echo "preparing for reboot..."
trap cleanup_on_exit EXIT trap cleanup_on_exit EXIT
@ -530,39 +520,28 @@ function do_flash_reboot() {
#### status #### #### status ####
function new_version() {
cat ${VER_FILE}
}
function show_status() { function show_status() {
status=$(flash_boot_status) if [[ -f ${VER_FILE} ]]; then
if [[ "${status}" == "running" ]]; then new_version=$(cat ${VER_FILE})
echo "flashing boot $(new_version)"
return
elif [[ "${status}" == "done" ]]; then
echo "boot ready $(new_version)"
return
fi fi
status=$(extract_status) if [[ -f ${FLASH_REBOOT_STARTED_FILE} ]]; then
if [[ "${status}" == "running" ]]; then echo "rebooting [${new_version}]"
echo "extracting $(new_version)" elif [[ -f ${FLASH_BOOT_DONE_FILE} ]]; then
return echo "boot flashed [${new_version}]"
elif [[ "${status}" == "done" ]]; then elif [[ -f ${FLASH_BOOT_STARTED_FILE} ]]; then
echo "extracted $(new_version)" echo "flashing boot [${new_version}]"
return elif [[ -f ${EXTRACT_DONE_FILE} ]]; then
echo "extracted [${new_version}]"
elif [[ -f ${EXTRACT_STARTED_FILE} ]]; then
echo "extracting [${new_version}]"
elif [[ -f ${DOWNLOAD_DONE_FILE} ]]; then
echo "downloaded [${new_version}]"
elif [[ -f ${DOWNLOAD_STARTED_FILE} ]]; then
echo "downloading"
else
echo "idle"
fi fi
status=$(download_status)
if [[ "${status}" == "running" ]]; then
echo "downloading $(new_version)"
return
elif [[ -n "${status}" ]]; then
echo "downloaded $(new_version)"
return
fi
echo "idle"
} }

Binary file not shown.

View File

@ -1,6 +1,6 @@
config BR2_PACKAGE_PYTHON_PYHOCON config BR2_PACKAGE_PYTHON_PYHOCON
bool "python-pyhocon" bool "python-pyhocon"
depends on BR2_PACKAGE_PYTHON depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
select BR2_PACKAGE_PYTHON_PYPARSING select BR2_PACKAGE_PYTHON_PYPARSING
help help
HOCON parser for Python HOCON parser for Python