[sbopkg-users] Show requirements in -g option

Nick Coleman ncoleman at internode.on.net
Tue Dec 16 02:45:58 UTC 2014


On Mon, 15 Dec 2014 22:35:49 +0000
sbopkg-users-request at sbopkg.org wrote:

> Date: Sun, 20 Apr 2014 15:32:30 -0300
> From: Alexandre Souza <aesouza.jvm at gmail.com>
> Subject: [sbopkg-users] Show requirements in -g option
> hi everyone...
> I'm think that can be useful when we use "sbopkg -g <pack/program>"
> show the requirements file.(e.g pip needs pysetuptools) What do you
> thinks?

Co-incidentally, I had been writing something for my own use.  This
shell function will do what you want.  I intended to release it to this
list soon, but was working to tidy it up to ignore already-installed
packages.  

Currently it produces a list including packages already
installed.  The list is in order of requirements; in other words it can
simply be cut and pasted after "sbopkg -i ".

Usage: sbodeps pip
Output:: "pysetuptools pip"

Put this function in .bashrc or similar.

If you change the name of the function, you also need to change the
name of function call 'get_dep "$dep"'.

For software engineers: WITNESS THE POWER OF THIS FULLY FUNCTIONAL AND
OPERATIONAL battle station... oops, recursive function. ;-0

#  Written by Nick Coleman  22/10/14
#  Licence:  "X11" 
#
#  Find all requirements, recursively all
#  deps on deps, for a SBo package.
#   Find path of package.
#   Find all requirements for that package.
#   If "" return.
#   Store values.
#   Recurse.

function get_dep () {
    if [ ! $1 ] ; then return ; fi
    dir=$(find /var/lib/sbopkg/SBo/14.1 -type d -iname $1)
    if [ -s "$dir" ] ; then
        deps=($(sed -n 's/^REQUIRES="\(.*\)"$/\1/p' "$dir/${1}.info"))
        for dep in ${deps[@]}  ; do
            echo "$dep "
            get_dep "$dep"
        done
    else
        echo "Can't find $1"
        return 1
    fi
}

# Copyright (c) Nick Coleman 2014
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# 
# Except as contained in this notice, the name of the X Consortium shall
# not be used in advertising or otherwise to promote the sale, use or
# other dealings in this Software without prior written authorization
# from the X Consortium.


More information about the sbopkg-users mailing list