diff --git a/lib.sh b/lib.sh index fd7764d..daa554e 100755 --- a/lib.sh +++ b/lib.sh @@ -99,57 +99,11 @@ function get_normalized_package_list { # Remove commas, and block scalar folded backslashes, # extraneous spaces at the middle, beginning and end # then sort. - packages=$(echo "${1}" \ + local packages=$(echo "${1}" \ | sed 's/[,\]/ /g; s/\s\+/ /g; s/^\s\+//g; s/\s\+$//g' \ | sort -t' ') - - # Validate package names and get versions. - log_err "resolving package versions..." - data=$(apt-cache --quiet=0 --no-all-versions show ${packages} 2>&1 | \ - grep -E '^(Package|Version|N):') - log_err "resolved" - - local ORIG_IFS="${IFS}" - IFS=$'\n' - declare -A missing - local package_versions='' - local package='' separator='' - for key_value in ${data}; do - local key="${key_value%%: *}" - local value="${key_value##*: }" - - case $key in - Package) - package=$value - ;; - Version) - package_versions="${package_versions}${separator}"${package}=${value}"" - separator=' ' - ;; - N) - # Warning messages. - case $value in - 'Unable to locate package '*) - package="${value#'Unable to locate package '}" - # Avoid duplicate messages. - if [ -z "${missing[$package]}" ]; then - package="${value#'Unable to locate package '}" - log_err "Package '${package}' not found." - missing[$package]=1 - fi - ;; - esac - ;; - esac - done - IFS="${ORIG_IFS}" - - if [ ${#missing[@]} -gt 0 ]; then - echo "aborted" - exit 5 - fi - - echo "${package_versions}" + local script_dir="$(dirname -- "$(realpath -- "${0}")")" + go ${script_dir}/apt_query.go normalized-list ${packages} } ###############################################################################