Changeset - 4c9b9897e934
[Not reviewed]
default
0 5 0
Dennis Fink - 7 years ago 2013-05-27 14:00:08
the_metalgamer@hackerspace.lu
updated to 0.4.1
5 files changed with 66 insertions and 51 deletions:
0 comments (0 inline, 0 general)
README.rst
Show inline comments
...
 
@@ -9,7 +9,7 @@ Yet another AUR helper
 
:Author:         Dennis Fink <the_metalgamer@hackerspace.lu>
 
:Date:           2013-05-19
 
:Copyright:      GPLv3+
 
:Version:        Yaah 0.3.4
 
:Version:        Yaah 0.4.1
 
:Manual section: 8
 
:Manual group:   Yaah Manual
 

	
...
 
@@ -17,6 +17,7 @@ SYNOPSIS
 
========
 

	
 
yaah <packages>...
 

	
 
yaah [options] [<packages>]...
 

	
 
DESCRIPTION
...
 
@@ -33,7 +34,7 @@ OPTIONS
 

	
 
-h, --help                              Display help.
 
-c, --check                             Check installed, foreign packages, if there are updates available.
 
-d DIRECTORY, --downloaddir=DIRECTORY   Download packages to the specified directory.
 
-d DIRECTORY, --downloaddir DIRECTORY   Download packages to the specified directory.
 
-s KEYWORD, --search KEYWORD            Search for packages containing specified keyword.
 
-v, --verbose                           Be more verbose, can be supplied at maximum 2 times.
 
-q, --quiet                             Be less verbose. Takes precedence over -v and --verbose.
man/man8/yaah.8.gz
Show inline comments
 
binary diff not shown
yaah
Show inline comments
...
 
@@ -5,15 +5,15 @@
 
#:               yaag [options] [<packages]...
 
#:      Options: -h, --help                             Display help
 
#:               -c, --check                            Check installed, foreign packages if there are updates available
 
#:               -d DIRECTORY, --downloaddir=DIRECTORY  Download packages to the specified directory
 
#:               -d DIRECTORY, --downloaddir DIRECTORY  Download packages to the specified directory
 
#:               -s KEYWORD, --search KEYWORD           Search for packages containing specified keyword
 
#:               -v, --verbose                          Be more verbose, can be supplied at  maximum 2 times
 
#:               -q, --quiet                            Be less verbose. Takes precedence over -v and --verbose
 
#:               --version                              Prints version and exits
 
#: Requirements: jshon <http://kmkeen.com/jshon/>, pacman, tar, curl
 
#:      Version: 0.3.4
 
#:      Version: 0.4.1
 
#:      Created: 2013-02-26
 
#:     Revision: 2013-05-19
 
#:     Revision: 2013-05-27
 
#:       Author: Dennis Fink <the_metalgamer@hackerspace.lu>
 

	
 
## Security
...
 
@@ -34,11 +34,11 @@ umask $UMASK
 
SCRIPTNAME=${0##*/}
 
DESCRIPTION="Yet another AUR helper"
 
DATE_OF_CREATION=2013-02-26
 
DATE_OF_REVISION=2013-05-19
 
VERSION=0.3.4
 
DATE_OF_REVISION=2013-05-27
 
VERSION=0.4.1
 
AUTHOR="Dennis Fink <the_metalgamer@hackerspace.lu>"
 

	
 
readonly SCRIPTNAME DESCRIPTION DATE_OF_CREATION VERSION AUTHOR
 
readonly SCRIPTNAME DESCRIPTION DATE_OF_CREATION DATE_OF_REVISION VERSION AUTHOR
 

	
 
## Constants
 
AURURL="http://aur.archlinux.org/"
...
 
@@ -54,6 +54,7 @@ if tput setaf 0 $>/dev/null; then
 
    GREEN="${BOLD}$(tput setaf 2)"
 
    RED="${BOLD}$(tput setaf 1)"
 
    YELLOW="${BOLD}$(tput setaf 3)"
 
    COLS="$(tput cols)"
 
else
 
    ALL_OFF="\e[1;0m"
 
    BOLD="\[1;1m"
...
 
@@ -61,10 +62,14 @@ else
 
    GREEN="${BOLD}\e[1;32m"
 
    RED="${BOLD}\e[1;31m"
 
    YELLOW="${BOLD}\e[1;33m"
 
    COLS="$COLUMNS"
 
fi
 

	
 
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
 
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW COLS
 

	
 
# Alias jshon to jshon -Q
 
alias jshon='jshon -Q'
 
alias curl='curl -s -fL'
 

	
 
#=== FUNCTION =================================================================
 
#        Name: msg
...
 
@@ -147,9 +152,11 @@ search() {
 

	
 
    msg "Searching AUR for $1"
 

	
 
    msg_verbose2 "URL is: ${AURURL}rpc.php?type=search&arg=$1"
 
    local url="${AURURL}rpc.php?type=search&arg=$1"
 

	
 
    aur_response=$(curl -s -fL "${AURURL}rpc.php?type=search&arg=$1")
 
    msg_verbose2 "URL is: ${url}"
 

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

	
 
    if [[ $? -ne 0 ]]; then
 
        error "Packages infos could not be loaded!"
...
 
@@ -158,30 +165,36 @@ search() {
 

	
 
    msg_verbose2 "Getting numbers of objects in json array!"
 

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

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

	
 
    printf "\n"
 
    for i in $(seq 0 $(( $number -1 )) ); do
 

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

	
 
        local package_name=$(jshon -Q -e Name <<< "$package")
 
        local package_version=$(jshon -Q -e Version <<< "$package")
 
        local package_description=$(jshon -Q -e Description <<< "$package")
 
        local out_of_date=$(jshon -Q -e OutOfDate <<< "$package")
 
        local package_name=$(jshon -e Name <<< "$package")
 
        local package_version=$(jshon -e Version <<< "$package")
 
        local package_description=$(jshon -e Description <<< "$package")
 
        local out_of_date=$(jshon -e OutOfDate <<< "$package")
 

	
 
        # removing quotes
 
        package_name=${package_name//\"}
 
        package_version=${package_version//\"}
 
        package_description=${package_description//\"}
 

	
 
        printf "$package_name "
 

	
 
        if [[ $out_of_date -eq 0 ]]; then
 
            printf "$package_name $package_version\n $package_description\n\n"
 
            printf "${GREEN}$package_version"
 
        else
 
            printf "${RED}$package_name $package_version${ALL_OFF}\n $package_description\n\n"
 
            printf "${RED}$package_version"
 
        fi
 
        description=$(fold -s -w $COLS <<< "$package_description")
 
        printf "${ALL_OFF}\n$description\n\n"
 

	
 
    done
 
}
...
 
@@ -235,9 +248,11 @@ query_online_version () {
 

	
 
        msg_verbose1 "Sending query to AUR."
 

	
 
        msg_verbose2 "URL is: ${AURURL}rpc.php?type=multiinfo$arguments"
 
        local url="${AURURL}rpc.php?type=multiinfo${arguments}"
 

	
 
        local aur_response=$(curl -s -fL "${AURURL}rpc.php?type=multiinfo$arguments")
 
        msg_verbose2 "URL is: ${url}"
 

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

	
 
        if [[ $? -ne 0 ]]; then
 
            error "Packages infos could not be loaded!"
...
 
@@ -246,7 +261,7 @@ query_online_version () {
 

	
 
        msg_verbose2 "Getting numbers of objects in json array!"
 

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

	
 
        msg_verbose2 "Looping over json array!"
 

	
...
 
@@ -254,8 +269,8 @@ query_online_version () {
 

	
 
            msg_verbose2 "Extracting package name."
 

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

	
 
            msg_verbose2 "Extracting old package version."
...
 
@@ -264,7 +279,7 @@ query_online_version () {
 

	
 
            msg_verbose2 "Extracting new package version."
 

	
 
            local new_package_version=$(jshon -Q -e Version \ <<< "$package")
 
            local new_package_version=$(jshon -e Version \ <<< "$package")
 

	
 
            new_package_version=${new_package_version//\"}
 

	
...
 
@@ -295,26 +310,21 @@ query_local_version () {
 

	
 
    msg "Getting version of installed packages."
 

	
 
    local packages=()
 
    #local packages=()
 
    declare -A packages
 

	
 
    local IFS=$'\n'
 
    while read -r; do
 
        packages+=("$REPLY")
 
    done < <(pacman -Qm $@)
 
    for package in $(pacman -Qm $@); do
 
        local package_name=${package%\ *}
 
        local package_version=${package#*\ }
 
        packages[$package_name]=$package_version
 
    done
 

	
 

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

	
 
        msg_verbose2 "Creating associative array!"
 

	
 
        declare -A associative_packages
 

	
 
        for package in "${packages[@]}"; do
 
            local package_name=${package%\ *}
 
            local package_version=${package#*\ }
 
            associative_packages[$package_name]=$package_version
 
        done
 

	
 
        query_online_version "$(declare -p associative_packages)"
 
        query_online_version "$(declare -p packages)"
 
    else
 
        error "Packages could not be loaded!"
 
        return 2
...
 
@@ -368,8 +378,7 @@ download () {
 

	
 
            msg "Downloading '$filename' to '$downloaddir'"
 

	
 
            curl -s -fL -o "$downloaddir/$filename" \
 
                "${AURURL}packages/$start/$1/$filename"
 
            curl -o "$downloaddir/$filename" "${AURURL}packages/$start/$1/$filename"
 

	
 
            msg_verbose2 "Setting trap to remove downloaded file"
 
            trap "rm -f $downloaddir/$filename" EXIT
...
 
@@ -423,7 +432,7 @@ usage() {
 
    Options:
 
      -h, --help                             Display help
 
      -c, --check                            Check installed, foreign packages if there are updates available
 
      -d DIRECTORY, --downloaddir=DIRECTORY  Download packages to the specified directory
 
      -d DIRECTORY, --downloaddir DIRECTORY  Download packages to the specified directory
 
      -s KEYWORD, --search KEYWORD           Search for packages containing specified keyword
 
      -v, --verbose                          Be more verbose, can be supplied at  maximum 2 times
 
      -q, --quiet                            Be less verbose. Takes precedence over -v and --verbose
...
 
@@ -461,14 +470,10 @@ while true; do
 
            check_flag=1
 
            shift
 
            ;;
 
        -d)
 
        -d|--downloaddir)
 
            downloaddir=$2
 
            shift 2
 
            ;;
 
        --downloaddir=*)
 
            downloaddir=${1#*=}
 
            shift
 
            ;;
 
        -v|--verbose)
 
            verbose=1
 
            shift
yaah.completion
Show inline comments
...
 
@@ -4,8 +4,16 @@
 
    COMPREPLY=()
 
    cur="${COMP_WORDS[COMP_CWORD]}"
 
    prev="${COMP_WORDS[COMP_CWORD-1]}"
 
    opts="-h --help -c --check -d --downloaddir -s --search -v --verbose -q --quiet --version"
 
    opts="-h --help -c --check -s --search -v --verbose -q --quiet --version --downloaddir -d"
 

	
 
    if [[ ${prev} == "-d" ]]; then
 
        COMPREPLY=( $(compgen -d -- ${cur}) )
 
        return 0
 
    fi
 
    if [[ ${prev} == "--downloaddir" ]]; then
 
        COMPREPLY=( $(compgen -d -- ${cur}) )
 
        return 0
 
    fi
 
    if [[ ${cur} == -* ]]; then
 
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
 
        return 0
yaah.rst
Show inline comments
...
 
@@ -9,7 +9,7 @@ Yet another AUR helper
 
:Author:         Dennis Fink <the_metalgamer@hackerspace.lu>
 
:Date:           2013-05-19
 
:Copyright:      GPLv3+
 
:Version:        Yaah 0.3.4
 
:Version:        Yaah 0.4.1
 
:Manual section: 8
 
:Manual group:   Yaah Manual
 

	
...
 
@@ -17,6 +17,7 @@ SYNOPSIS
 
========
 

	
 
yaah <packages>...
 

	
 
yaah [options] [<packages>]...
 

	
 
DESCRIPTION
...
 
@@ -33,7 +34,7 @@ OPTIONS
 

	
 
-h, --help                              Display help.
 
-c, --check                             Check installed, foreign packages, if there are updates available.
 
-d DIRECTORY, --downloaddir=DIRECTORY   Download packages to the specified directory.
 
-d DIRECTORY, --downloaddir DIRECTORY   Download packages to the specified directory.
 
-s KEYWORD, --search KEYWORD            Search for packages containing specified keyword.
 
-v, --verbose                           Be more verbose, can be supplied at maximum 2 times.
 
-q, --quiet                             Be less verbose. Takes precedence over -v and --verbose.
0 comments (0 inline, 0 general)