Added check_atbqt_version plus helper functions

This commit is contained in:
Gerhard Hoffmann 2022-06-02 22:24:11 +02:00
parent d3f59af6ec
commit c428602aa8

84
opkg.sh
View File

@ -148,12 +148,8 @@ write_config() {
echo "$data" > "${path}/$2"
# echo $(cat "/tmp/test.txt" | jq -C --indent 4 '.') > /tmp/test2.txt
}
# write_config "/home/root/szeged/customer_281/szeged/1/1/" "test.txt"
# x=$(cat "/home/root/szeged/customer_281/szeged/1/1/test.txt" | jq .opkg.atbqt)
#echo $x
# Download opkg-package. After the download, extract data.tar.gz to
# access e.g. atbqt.
download_opkg_package () {
@ -201,3 +197,83 @@ download_opkg_package () {
}
# download_opkg_package "atbqt" "atbqt_1.0.0-r1_cortexa9t2hf-neon.ipk"
ar_extract_opkg_package_data () {
return 0
cp $1 "/tmp"
# mv $1 "/tmp"
cd /tmp
# ar -x $1
#if [ $? ne 0 ]; then
data_file="data.tar.xz"
if ! [ -f "$data_file" ]; then
printf "ERROR %s does not exist\n" "$data_file" >&2
return 1
fi
cd -
return 0
tar -qxvf $data_file
echo $pwd
}
# ar_extract_opkg_package_data "atbqt_1.0.0-r1_cortexa9t2hf-neon.ipk"
tar_extract_opkg_package_data () {
exec {ftar}< <(tar -xvf "$2" -C "$1") # use process substitution
cs_pid=$!
exec {ftar}>&-
wait $cs_pid
binary="$1/$3"
if ! [ -f "$binary" ]; then
printf "ERROR %s does not exist\n" "$binary" >&2
return 1
fi
return 0
}
# tar_extract_opkg_package_data "/tmp" "data.tar.xz" "opt/app/ATBAPP/ATBQT"
read_atbqt_version () {
version=$(/tmp/opt/app/ATBAPP/ATBQT -v)
version=(${version// / })
if [ ${#version[@]} -lt 7 ]; then
printf "ERROR %s has wrong format\n" "${version[@]}" >&2
return 1
fi
version=("${version[3]}" "${version[6]}")
echo ${version[@]}
}
# xxx=`read_atbqt_version`
# echo $xxx
check_atbqt_version () {
if `download_opkg_package "atbqt" "atbqt_1.0.0-r1_cortexa9t2hf-neon.ipk"`; then
return 1
fi
if `ar_extract_opkg_package_data "atbqt_1.0.0-r1_cortexa9t2hf-neon.ipk"`; then
return 1
fi
if `tar_extract_opkg_package_data "/tmp" "data.tar.xz" "opt/app/ATBAPP/ATBQT"`; then
return 1
fi
version=`read_atbqt_version`
version=(${version// / })
if [ "${version[0]}" = "$1" ] && [ "${version[1]}" = "$2" ]; then
return 0
fi
return 1
}
check_atbqt_version "20221220_1038_00318q" "4.5.2-65-gf1799aa3_00318/Nexobility_dev"