Changeset - 48dc373f9a02
[Not reviewed]
default
0 2 0
Dennis Fink - 7 years ago 2013-03-04 21:27:13
the_metalgamer@hackerspace.lu
updated documentation and usage function
2 files changed with 37 insertions and 14 deletions:
yaah
31
8
0 comments (0 inline, 0 general)
yaah
Show inline comments
 
#!/bin/bash -
 

	
 
#:        Title: yaah - Yet another AUR helper
 
#:     Synopsis:
 
#:      Options:
 
#:     Synopsis: yaah [options] [packages]
 
#:               yaah (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
 
#:               -v, --verbose                         Be more verbose, can be
 
#:                                                     supplied at  maximum 2
 
#:                                                     times
 
#:               -q, --quiet                           Be less verbose. Takes
 
#:                                                     precedence over -v and
 
#:                                                     --verbose
 
#: Requirements: jshon <http://kmkeen.com/jshon/>
 
#:      Version: 0.1-alpha
 
#:      Created: 2013-02-26
 
#:     Revision: 2013-02-26
 
#:     Revision: 2013-03-04
 
#:       Author: Dennis Fink <the_metalgamer@hackerspace.lu>
 

	
 
## Security
 
# Unalias everything
 
\unalias -a
 
# Secure PATH
 
PATH='/bin:/usr/bin'
 
export PATH
 
# Clearing the Command hash
 
hash -r
 
# Setting secure IFS
 
IFS=$' \t\n'
...
 
@@ -214,25 +226,25 @@ query_online_version () {
 
query_local_version () {
 

	
 
    msg "Getting version of installed packages."
 

	
 
    local packages=()
 

	
 
    local IFS=$'\n'
 
    while read -r; do
 
        packages+=("$REPLY")
 
    done < <(pacman -Qm $@)
 
    if [[ $? -eq 0 ]]; then
 
        msg "There are ${#packages[@]} foreign packages to check."
 
        
 

 
        if [[ $verbose -ge 2 ]]; then
 
            msg "Sorting package array!"
 
        fi
 
        sorted_packages=($(sort <<<"${packages[*]}"))
 
        query_online_version sorted_packages[@]
 
    else
 
        error "Packages could not be loaded!"
 
        return 1
 
    fi
 

	
 
}
 

	
...
 
@@ -241,25 +253,25 @@ query_local_version () {
 
# Description: Extracting a tar.gz file and remove the archive file
 
# Parameter 1: File to extract
 
#==============================================================================
 

	
 
extract_and_remove () {
 

	
 
    if [[ $# -eq 1 ]]; then
 
        if [[ -f $1 ]]; then
 

	
 
            msg "Extracting '$1'"
 

	
 
            tar xzf $1 -C $downloaddir
 
            
 

 
            if [[ $verbose -ge 1 ]]; then
 
                msg "Removing '$1'"
 
            fi
 
            rm $1
 
        else
 
            error "'$1' is not a file"
 
            return 1
 
        fi
 
    else
 
        error "Not enough parameters supplied"
 
        return 1
 
    fi
...
 
@@ -297,27 +309,38 @@ download () {
 
        return 1
 
    fi
 

	
 
}
 

	
 
#=== FUNCTION =================================================================
 
#        Name: usage
 
# Description: Prints the usage
 
#==============================================================================
 

	
 
usage() {
 
    printf "$SCRIPTNAME - $DESCRIPTION
 
    -h, --help Display help
 
    -c, --check Check installed packages if there are updates
 
    -d, --downloaddir <directory> Download packages to the specified directory\n"
 

	
 
    Download packages from AUR or check installed, foreign packages, if there are updates available.
 

	
 
    Usage: $SCRIPTNAME [options] [packages]
 
           $SCRIPTNAME (packages)
 

	
 
    Options:
 
    -h, --help                              Display help
 
    -c, --check                             Check installed packages if there are updates
 
    -d directory, --downloaddir=directory   Download packages to the specified directory
 
    -v, --verbose                           Be more verbose, can be supplied at maximum 2 times
 
    -q, --quiet                             Be less verbose. Takes precedence over -v and --verbose
 

	
 
    For complete documentation, run: man 8 yaah\n"
 
}
 

	
 

	
 
check_flag=
 
verbose=0
 
quiet=0
 
downloaddir="$PWD"
 

	
 

	
 
while true; do
 
    case $1 in
 
        -h|--help|-\?)
yaah.rst
Show inline comments
 
====
 
yaah
 
====
 

	
 
----------------------
 
Yet another AUR helper
 
----------------------
 

	
 
:Author:         Dennis Fink <the_metalgamer@hackerspace.lu>
 
:Date:           2013-02-26
 
:Date:           2013-03-04
 
:Copyright:      GPLv3+
 
:Version:        Yaah 0.1-alpha
 
:Manual section: 8
 
:Manual group:   Yaah Manual
 

	
 
SYNOPSIS
 
========
 

	
 
yaah [options] [packages]
 

	
 
yaah (packages)
 

	
 
DESCRIPTION
 
===========
 

	
 
Yaah is a helper for the Archlinux User Repository (AUR). It has two main
 
functions. First of all, it can download packages, from the AUR by their
 
package name. The second function is to check installed foreign packages, if
 
there are updates available.
 

	
 
OPTIONS
 
=======
 

	
 
-h, --help                              Display help
 
-c, --check                             Check installed packages if there are updates available
 
-d directory, --downloaddir=directory   Download packages to the specified directory
 
-v, --verbose                           Be more verbose, can be supplied at maximum 2 times
 
-q, --quiet                             Be less verbose. Takes precedence over -v and --verbose
 
-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.
 
-v, --verbose                           Be more verbose, can be supplied at maximum 2 times.
 
-q, --quiet                             Be less verbose. Takes precedence over -v and --verbose.
 

	
 
EXAMPLES
 
========
 

	
 
yaah task-git
 
    Download the package task-git and extract it to the current directory.
 

	
 
yaah -d ~/Packages/ task-git
 
    Download the pacakge task-git and extract it to the ~/Packages/ folder.
 

	
 
yaah -c
 
    Check all installed, foreign packages if there are updates available.
0 comments (0 inline, 0 general)