diff --git a/opkg.sh b/opkg.sh index 19d60bf..62ef5b9 100755 --- a/opkg.sh +++ b/opkg.sh @@ -3,7 +3,7 @@ # set -x compute_md5 () { - exec {fd}< <(md5sum "$1") # open fd readable for P.S. + execdownload_opkg {fd}< <(md5sum "$1") # open fd readable for P.S. cs_pid=$! # remember pid of P.S. md5="" while read t <&$fd; do @@ -149,7 +149,55 @@ write_config() { # echo $(cat "/tmp/test.txt" | jq -C --indent 4 '.') > /tmp/test2.txt } -write_config "/home/root/szeged/customer_281/szeged/1/1/" "test.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 () { + + case "$1" in + atbqt) # hier weitere packete eintragen + ;; + + *) + printf "ERROR $1 has wrong format\n" >&2 + return 1 + ;; + esac + + exec {fdd}< <(opkg --download-only download "$1") # open fd readable for P.S. + cs_pid=$! # remember pid of P.S. + + opkg_result="" + while read result <&$fdd; do + if ! [ -z "$result" ]; then + opkg_result+="$result" + fi + done + + exec {fdd}>&- # close fd (i.e. process substitution) + wait $cs_pid # wait for the subshell to finish + + if [ -z "$opkg_result" ]; then + printf "ERROR empty opkg_result\n" >&2 + return 1 + fi + + if ! grep -qF "$1" <<< $opkg_result; then + printf "ERROR opkg_result [$opkg_result] does not contain $1\n" >&2 + return 1 + fi + + if ! grep -qF "$2" <<< $opkg_result; then + printf "ERROR opkg_result [$opkg_result] does not contain $2\n" >&2 + return 1 + fi + + # printf "%s\n" $opkg_result + return 0 +} +# download_opkg_package "atbqt" "atbqt_1.0.0-r1_cortexa9t2hf-neon.ipk"