check md5sums for opkg packages
This commit is contained in:
parent
fab081d212
commit
bc4977bf7f
@ -13,9 +13,12 @@ exec_opkg_command () {
|
|||||||
log_debug "$func:${LINENO} exec-ing [$*]"
|
log_debug "$func:${LINENO} exec-ing [$*]"
|
||||||
|
|
||||||
local __result=$(exec_process_substitution $*)
|
local __result=$(exec_process_substitution $*)
|
||||||
|
local __result_code=$?
|
||||||
|
|
||||||
log_debug "$func:${LINENO} result=$__result"
|
log_debug "$func:${LINENO} result=$__result"
|
||||||
|
|
||||||
printf '%s' "$__result"
|
printf '%s' "$__result"
|
||||||
|
return $__result_code
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fetch/merge updates from predefined repository using git.
|
# Fetch/merge updates from predefined repository using git.
|
||||||
@ -46,23 +49,34 @@ check_md5_for_opkg_packages () {
|
|||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
local -n opkg_output_ref=$1
|
local -n opkg_output_ref=$1
|
||||||
local package=""
|
local package=""
|
||||||
local md5sum=""
|
local md5sum_opkg_info=""
|
||||||
local filename=""
|
local filename=""
|
||||||
for line in ${opkg_output_ref[@]}; do
|
for line in ${opkg_output_ref[@]}; do
|
||||||
|
log_info "$func:${LINENO}: line=$line"
|
||||||
if grep -qE "^\s*Package\s*:.*?$" <<< "$line"; then
|
if grep -qE "^\s*Package\s*:.*?$" <<< "$line"; then
|
||||||
package=${line#*:* }
|
package=${line#*:* }
|
||||||
printf 'package=%s\n' "$package"
|
|
||||||
elif grep -qE "^\s*MD5Sum\s*:.*?$" <<< "$line"; then
|
elif grep -qE "^\s*MD5Sum\s*:.*?$" <<< "$line"; then
|
||||||
md5sum=${line#*:* }
|
md5sum_opkg_info=${line#*:* }
|
||||||
printf 'md5sum=%s\n' "$md5sum"
|
|
||||||
elif grep -qE "^\s*Filename\s*:.*?$" <<< "$line"; then
|
elif grep -qE "^\s*Filename\s*:.*?$" <<< "$line"; then
|
||||||
filename=${line#*:* }
|
filename=${line#*:* }
|
||||||
printf 'filename=%s\n' "$filename"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: $package | $md5sum | $filename"
|
local __update_conf="${customer_location_dir}/update.conf"
|
||||||
return 0
|
md5sum_repo=$(cat $__update_conf | jq -r .opkg.${package}.MD5Sum)
|
||||||
|
if ! [ -z $md5sum_repo ]; then
|
||||||
|
if [ "$md5sum_opkg_info" = "$md5sum_repo" ]; then
|
||||||
|
log_info "$func:${LINENO}: md5 $md5sum_repo OK for $package"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log_error "$func:${LINENO}: md5sum_repo [$md5sum_repo] "\
|
||||||
|
"!= md5sum_opkg_info [$md5sum_opkg_info] for $package"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
log_error "$func:${LINENO}: md5sum_repo empty"
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# In case the new checked-out files are not correct, revert the git
|
# In case the new checked-out files are not correct, revert the git
|
||||||
@ -82,37 +96,42 @@ backup_previous_version () {
|
|||||||
|
|
||||||
exec_opkg_info () {
|
exec_opkg_info () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
log_info "$func:${LINENO}: executing $opkg_command"
|
log_info "$func:${LINENO}: executing info $1"
|
||||||
|
|
||||||
opkg_result=$(exec_opkg_command "opkg info $1")
|
opkg_result=$(exec_opkg_command "opkg info $1")
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
# make sure the keywords start with '\n'
|
||||||
|
opkg_result=$(sed -E -e "s/(^.*)(Package)(.*$)/\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Version)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Depends)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Status)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Architecture)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Maintainer)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(MD5Sum)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Filename)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Source)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Description)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Installed-Size)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Section)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*[^-])(Size)(.*$)/\1\n\2\3/g"\
|
||||||
|
-e "s/(^.*)(Installed-Time)(.*$)/\1\n\2\3/g"
|
||||||
|
<<< "$opkg_result")
|
||||||
|
|
||||||
|
local -n output_ref=$2
|
||||||
|
|
||||||
|
readarray -d $'\n' output_ref < <(printf '%s' "$opkg_result")
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_error "$func:${LINENO}: readarray finished with error"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# make sure the keywords start with '\n'
|
log_info "$func:${LINENO}: ... done"
|
||||||
opkg_result=$(sed -E -e "s/(^.*)(Package)(.*$)/\n\2\3/g"\
|
# log_info "$func:${LINENO}: opkg_result=${output_ref[@]}"
|
||||||
-e "s/(^.*)(Version)(.*$)/\1\n\2\3/g"\
|
return 0
|
||||||
-e "s/(^.*)(Depends)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Status)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Architecture)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Maintainer)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(MD5Sum)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Filename)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Source)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Description)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Installed-Size)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Section)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*[^-])(Size)(.*$)/\1\n\2\3/g"\
|
|
||||||
-e "s/(^.*)(Installed-Time)(.*$)/\1\n\2\3/g" <<< "$opkg_result")
|
|
||||||
|
|
||||||
local -n output_ref=$2
|
|
||||||
|
|
||||||
readarray -d $'\n' output_ref < <(printf '%s' "$opkg_result")
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
log_error "$func:${LINENO}: readarray finished with error"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log_info "$func:${LINENO}: ... done"
|
log_error "$func:${LINENO}: executing info $1"
|
||||||
log_info "$func:${LINENO}: opkg_result=${output_ref[@]}"
|
return 1
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try to install new opkg-packages (in case the are some
|
# Try to install new opkg-packages (in case the are some
|
||||||
@ -129,11 +148,16 @@ exec_opkg_no_action() {
|
|||||||
#
|
#
|
||||||
exec_opkg () {
|
exec_opkg () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
log_info "$func:${LINENO}: executing $opkg_command"
|
log_debug "$func:${LINENO}: executing $1"
|
||||||
|
|
||||||
local opkg_result=$(exec_opkg_command "opkg $1")
|
local __opkg_result=$(exec_opkg_command "opkg $1")
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log_info "$func:${LINENO}: opkg_result=$__opkg_result"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
log_error "$func:${LINENO}: error executing $1"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# In case there was some error, re-install the previous package(s)
|
# In case there was some error, re-install the previous package(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user