Changeset - 713d461c655b
[Not reviewed]
default
0 1 0
Dennis Fink (metalgamer) - 6 years ago 2014-03-19 23:54:02
dennis.fink@c3l.lu
security checker
1 file changed with 26 insertions and 27 deletions:
yaah
26
27
0 comments (0 inline, 0 general)
yaah
Show inline comments
...
 
@@ -59,7 +59,6 @@ if tput setaf 0 $>/dev/null; then
 
    BLUE="${BOLD}$(tput setaf 4)"
 
    PURPLE="${BOLD}$(tput setaf 5)"
 
    CYAN="${BOLD}$(tput setaf 6)"
 
    WHITE="${BOLD}$(tput setaf 7)"
 
else
 
    ALL_OFF="\e[1;0m"
 
    BOLD="\[1;1m"
...
 
@@ -69,11 +68,10 @@ else
 
    BLUE="${BOLD}\e[1;34m"
 
    PURPLE="${BOLD}\e[1:35m"
 
    CYAN="${BOLD}\e[1:36m"
 
    WHITE="${BOLD}\e[1:37m"
 
fi
 
COLS="$(tput cols)"
 

	
 
readonly ALL_OFF BOLD RED GREEN YELLOW BLUE PURPLE CYAN WHITE COLS
 
readonly ALL_OFF BOLD RED GREEN YELLOW BLUE PURPLE CYAN COLS
 

	
 
# Alias jshon to jshon -Q
 
alias jshon='jshon -Q'
...
 
@@ -187,7 +185,11 @@ search() {
 

	
 
    msg_verbose2 "URL is: ${url}"
 

	
 
    aur_response=$(jshon -e results <<< $(curl "${url}"))
 
    local aur_response=$(curl "${url}")
 

	
 
    local resultcount=$(jshon -e resultcount <<< "$aur_response")
 
    aur_response=$(jshon -e results <<< "$aur_response")
 

	
 

	
 
    if [[ $? -ne 0 ]]; then
 
        error "Packages infos could not be loaded!"
...
 
@@ -196,25 +198,24 @@ search() {
 

	
 
    msg_verbose2 "Getting number of objects in json array!"
 

	
 
    local number=$(jshon -l <<< "$aur_response")
 

	
 
    msg_verbose1 "There are $number packages found."
 
    msg_verbose1 "There are $resultcount packages found."
 
    msg_verbose2 "Looping over json array!"
 

	
 
    if [[ "$quiet" -eq 0 ]]; then
 
        printf "\n"
 
    fi
 

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

	
 
        local package=$(jshon -e $i <<< "$aur_response")
 
        local package=$(jshon -e "$i" <<< "$aur_response")
 

	
 
        local package_name=$(jshon -e Name <<< "$package")
 
        local package_version=$(jshon -e Version <<< "$package")
 
        local package_description=$(fold -sw $COLS <<< $(jshon -e Description <<< "$package"))
 
        local package_description=$(fold -sw "$COLS" <<< "$(jshon -e Description <<< "$package")")
 
        local out_of_date=$(jshon -e OutOfDate <<< "$package")
 
        local num_votes=$(jshon -e NumVotes <<< "$package")
 
        local category=${CATEGORIES[$(expr $(jshon -e CategoryID <<< "$package") - 1)]}
 
        local category=${CATEGORIES[$(($(jshon -e CategoryID <<< "$package")-1))]}
 
        local maintainer=$(jshon -e Maintainer <<< "$package")
 
        local last_modified=$(jshon -e LastModified <<< "$package")
 

	
...
 
@@ -223,7 +224,7 @@ search() {
 
        package_version=${package_version//\"}
 
        package_description=${package_description//\"}
 
        maintainer=${maintainer//\"}
 
        last_modified=$(date -d @$last_modified)
 
        last_modified=$(date -d @"$last_modified")
 

	
 
        if [[ $out_of_date -eq 0 ]]; then
 
            local color="${GREEN}"
...
 
@@ -250,13 +251,13 @@ check_version () {
 
    if [[ $# -eq 3 ]]; then
 

	
 
        if [[ "$parseable_flag" ]]; then
 
            if [[ $(vercmp $2 $3) -eq -1 ]]; then
 
            if [[ $(vercmp "$2" "$3") -eq -1 ]]; then
 
                printf "$1 ${GREEN}$3${ALL_OFF}\n"
 
            fi
 
        else
 
            msg "Checking version for '$1'"
 

	
 
            if [[ $(vercmp $2 $3) -eq -1 ]]; then
 
            if [[ $(vercmp "$2" "$3") -eq -1 ]]; then
 
                msg2 "New version for '$1': $2 -> $3"
 
            fi
 
        fi
...
 
@@ -294,24 +295,22 @@ query_online_version () {
 

	
 
        msg_verbose2 "URL is: ${url}"
 

	
 
        local aur_response=$(jshon -e results <<< $(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 number=$(jshon -l <<< "$aur_response")
 

	
 
        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 $(( $number -1 )) ); do
 
        for i in $(seq 0 $((resultcount-1))); do
 

	
 
            msg_verbose2 "Extracting package name."
 

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

	
...
 
@@ -325,7 +324,7 @@ query_online_version () {
 

	
 
            new_package_version=${new_package_version//\"}
 

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

	
...
 
@@ -355,7 +354,7 @@ query_local_version () {
 
    declare -A packages
 

	
 
    local IFS=$'\n'
 
    for package in $(pacman -Qm $@); do
 
    for package in $(pacman -Qm "$@"); do
 
        local package_name=${package%\ *}
 
        local package_version=${package#*\ }
 
        packages[$package_name]=$package_version
...
 
@@ -389,7 +388,7 @@ extract_and_remove () {
 
            tar xzf "$1" -C "$downloaddir"
 

	
 
            msg_verbose2 "Setting trap to remove archive and extracted directory"
 
            trap "rm -rf $1 $downloaddir/${1%.tar.gz}" EXIT
 
            trap "rm -rf '$1' '$downloaddir/${1%.tar.gz}'" EXIT
 

	
 
            msg_verbose1 "Removing '$1'"
 
            rm "$1"
...
 
@@ -422,7 +421,7 @@ download () {
 
            curl -o "$downloaddir/$filename" "${AURURL}packages/$start/$1/$filename"
 

	
 
            msg_verbose2 "Setting trap to remove downloaded file"
 
            trap "rm -f $downloaddir/$filename" EXIT
 
            trap "rm -f '$downloaddir/$filename'" EXIT
 

	
 
            if [[ $? -eq 0 ]]; then
 
                extract_and_remove "$downloaddir/$filename"
...
 
@@ -567,9 +566,9 @@ else
 
fi
 

	
 
if [[ "$check_flag" ]]; then
 
    query_local_version $@
 
    query_local_version "$@"
 
elif [[ "$search_flag" ]]; then
 
    search $@
 
    search "$@"
 
else
 
    download $@
 
    download "$@"
 
fi
0 comments (0 inline, 0 general)