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/os-release
rm -f ${TARGET}/etc/hostapd.conf
rm -f ${TARGET}/etc/timezone
# /usr/share stuff
rm -rf ${TARGET}/usr/share/bash-completion/

View File

@ -15,12 +15,13 @@ function exit_usage() {
echo ""
echo "Statuses:"
echo " idle"
echo " downloading <version>"
echo " downloaded <version>"
echo " extracting <version>"
echo " extracted <version>"
echo " flashing boot <version>"
echo " boot ready <version>"
echo " downloading [version]"
echo " downloaded [version]"
echo " extracting [version]"
echo " extracted [version]"
echo " flashing boot [version]"
echo " boot flashed [version]"
echo " rebooting [version]"
echo ""
exit 1
@ -51,7 +52,14 @@ VER_FILE=${FW_DIR}/version
BOOT_INFO_FILE=${FW_DIR}/boot_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_ROOT_DIR=/tmp/fwupdate_root
@ -97,9 +105,16 @@ function cleanup_on_exit() {
#### disk & partition devices ####
BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
if [[ -n "${BOOT_DEV}" ]]; then
ROOT_DEV=${BOOT_DEV:0:-1}2
DATA_DEV=${BOOT_DEV:0:-1}3
DISK_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
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
DISK_DEV=${BASH_REMATCH[1]}
elif [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
@ -231,11 +246,19 @@ function show_current() {
#### download ####
function do_download() {
echo "downloading..."
rm -rf ${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
if [[ -f "$1" ]]; then
version="custom"
@ -300,23 +323,10 @@ function do_download() {
exit 1
fi
touch ${DOWNLOAD_DONE_FILE}
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 ####
@ -354,13 +364,17 @@ function run_pre_upgrade() {
}
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
exit 1
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 ${BOOT_READY_FILE}
touch ${EXTRACT_STARTED_FILE}
echo "extracting..."
@ -414,43 +428,27 @@ function do_extract() {
echo ${root_start} ${root_end} ${root_size} > ${ROOT_INFO_FILE}
run_pre_upgrade
}
function extract_status() {
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
touch ${EXTRACT_DONE_FILE}
}
#### 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"
return 1
fi
rm -f ${FLASH_BOOT_DONE_FILE}
rm -f ${FLASH_REBOOT_STARTED_FILE}
touch ${FLASH_BOOT_STARTED_FILE}
echo "flashing boot..."
trap cleanup_on_exit EXIT
rm -f ${BOOT_READY_FILE}
board=$(cat ${SYS_BOARD_FILE})
boot_info=($(cat ${BOOT_INFO_FILE}))
@ -464,7 +462,10 @@ function do_flash_boot() {
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=$!
echo ${pid} > ${DD_PID_FILE}
wait ${pid}
@ -477,32 +478,21 @@ function do_flash_boot() {
if [[ -x /usr/libexec/fw-restore-boot-cfg ]]; then
/usr/libexec/fw-restore-boot-cfg ${FW_DIR}/old_boot 2>/dev/null || true
fi
touch ${BOOT_READY_FILE}
}
function flash_boot_status() {
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
touch ${FLASH_BOOT_DONE_FILE}
}
#### 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"
return 1
fi
touch ${FLASH_REBOOT_STARTED_FILE}
echo "preparing for reboot..."
trap cleanup_on_exit EXIT
@ -530,39 +520,28 @@ function do_flash_reboot() {
#### status ####
function new_version() {
cat ${VER_FILE}
}
function show_status() {
status=$(flash_boot_status)
if [[ "${status}" == "running" ]]; then
echo "flashing boot $(new_version)"
return
elif [[ "${status}" == "done" ]]; then
echo "boot ready $(new_version)"
return
fi
status=$(extract_status)
if [[ "${status}" == "running" ]]; then
echo "extracting $(new_version)"
return
elif [[ "${status}" == "done" ]]; then
echo "extracted $(new_version)"
return
fi
status=$(download_status)
if [[ "${status}" == "running" ]]; then
echo "downloading $(new_version)"
return
elif [[ -n "${status}" ]]; then
echo "downloaded $(new_version)"
return
if [[ -f ${VER_FILE} ]]; then
new_version=$(cat ${VER_FILE})
fi
if [[ -f ${FLASH_REBOOT_STARTED_FILE} ]]; then
echo "rebooting [${new_version}]"
elif [[ -f ${FLASH_BOOT_DONE_FILE} ]]; then
echo "boot flashed [${new_version}]"
elif [[ -f ${FLASH_BOOT_STARTED_FILE} ]]; then
echo "flashing boot [${new_version}]"
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
}

Binary file not shown.

View File

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