Changeset - fba0ea9be9f7
[Not reviewed]
default
0 1 0
Dennis Fink (metalgamer) - 6 years ago 2014-03-20 01:32:47
dennis.fink@c3l.lu
easier associative array
1 file changed with 39 insertions and 48 deletions:
yaah
39
48
0 comments (0 inline, 0 general)
yaah
Show inline comments
...
 
@@ -271,72 +271,64 @@ check_version () {
 
#=== FUNCTION =================================================================
 
#        Name: query_online_version
 
# Description: Querying online packages version
 
# Parameter 1: A bash array with the packagenames and versions to check
 
#==============================================================================
 

	
 
query_online_version () {
 

	
 
    if [[ "$#" -eq 1 ]]; then
 
    msg "Getting version of online packages."
 

	
 
        msg "Getting version of online packages."
 
    local arguments=""
 

	
 
        eval "declare -p packages" >/dev/null
 
        local arguments=""
 
    msg_verbose2 "Creating argument list."
 

	
 
        msg_verbose2 "Creating argument list."
 
    for package in "${!packages[@]}"; do
 
        arguments+="&arg\[\]=${package}"
 
    done
 

	
 
        for package in "${!packages[@]}"; do
 
            arguments+="&arg\[\]=${package}"
 
        done
 

	
 
        msg_verbose1 "Sending query to AUR."
 
    msg_verbose1 "Sending query to AUR."
 

	
 
        local url="${AURURL}rpc.php?type=multiinfo${arguments}"
 
    local url="${AURURL}rpc.php?type=multiinfo${arguments}"
 

	
 
        msg_verbose2 "URL is: ${url}"
 
    msg_verbose2 "URL is: ${url}"
 

	
 
        local aur_response=$(curl "${url}")
 
    local aur_response=$(curl "${url}")
 

	
 
        if [[ $? -ne 0 ]]; then
 
            error "Packages infos could not be loaded!"
 
            return 2
 
        fi
 
        msg_verbose2 "Getting number of objects in json array!"
 
        local resultcount=$(jshon -e resultcount <<< "$aur_response")
 
        aur_response=$(jshon -e results <<< "$aur_response")
 
        msg_verbose2 "Looping over json array!"
 
    if [[ $? -ne 0 ]]; then
 
        error "Packages infos could not be loaded!"
 
        return 2
 
    fi
 
    msg_verbose2 "Getting number of objects in json array!"
 
    local resultcount=$(jshon -e resultcount <<< "$aur_response")
 
    aur_response=$(jshon -e results <<< "$aur_response")
 
    msg_verbose2 "Looping over json array!"
 

	
 
        for i in $(seq 0 $((resultcount-1))); do
 

	
 
            msg_verbose2 "Extracting package name."
 
    for i in $(seq 0 $((resultcount-1))); do
 

	
 
            local package=$(jshon -e "$i" <<< "$aur_response")
 
            local package_name=$(jshon -e Name <<< "$package")
 
            package_name=${package_name//\"}
 
        msg_verbose2 "Extracting package name."
 

	
 
            msg_verbose2 "Extracting old package version."
 

	
 
            local old_package_version=${packages[$package_name]}
 
        local package=$(jshon -e "$i" <<< "$aur_response")
 
        local package_name=$(jshon -e Name <<< "$package")
 
        package_name=${package_name//\"}
 

	
 
            msg_verbose2 "Extracting new package version."
 
        msg_verbose2 "Extracting old package version."
 

	
 
            local new_package_version=$(jshon -e Version \ <<< "$package")
 
        local old_package_version=${packages[$package_name]}
 

	
 
        msg_verbose2 "Extracting new package version."
 

	
 
            new_package_version=${new_package_version//\"}
 
        local new_package_version=$(jshon -e Version \ <<< "$package")
 

	
 
            check_version "$package_name" "$old_package_version" "$new_package_version"
 
            unset packages[$package_name]
 
        done
 

	
 
        msg_verbose2 "Check for missing packages."
 
        new_package_version=${new_package_version//\"}
 

	
 
        for package in "${!packages[@]}"; do
 
            msg "$package was not found."
 
        done
 
    else
 
        error "Not enough parameters supplied"
 
        return 1
 
    fi
 
        check_version "$package_name" "$old_package_version" "$new_package_version"
 
        unset packages[$package_name]
 
    done
 

	
 
    msg_verbose2 "Check for missing packages."
 

	
 
    for package in "${!packages[@]}"; do
 
        msg "$package was not found."
 
    done
 

	
 
}
 

	
...
 
@@ -363,8 +355,7 @@ query_local_version () {
 

	
 
    if [[ $? -eq 0 ]]; then
 
        msg "There are ${#packages[@]} foreign packages to check."
 

	
 
        query_online_version "$(declare -p packages)"
 
        query_online_version
 
    else
 
        error "Packages could not be loaded!"
 
        return 2
0 comments (0 inline, 0 general)