[sbopkg-users] Show requirements in -g option

Nick Coleman ncoleman at internode.on.net
Tue Dec 16 03:37:49 UTC 2014


On Tue, 16 Dec 2014 10:45:58 +0800
Nick Coleman <ncoleman at internode.on.net> wrote:

<some rubbish>

As is the nature of things, I pasted completely the wrong function.

Also, this requires the tac utility, which is part of the Slackware package "coreutils".  
You probably aready have it installed.

Here is the correct function:

function sbodeps () {
#   Find all requirements, recursively all deps on deps, for a SBo package
#   Written by Nick Coleman  22/10/14
#   Licence:  "X11" 
#
#   Usage:              sbodeps <package> [ char ]
#                       Output is in correct order to install, left to right, to paste after 'sbopkg [-k] -i '.
#                       Note: Duplicate deps aren't detected in this version.
#			[char] is an optional flag of any character(s) which outputs raw results.

#
#   The recursive functions aren't tail-call optimised, but it doesn't 
#   matter as most lists are only a few elements long.

    # Colour me surprised, Bash sub-functions are local.
    function get_deps () {
        if [ ! $1 ] ; then return ; fi
        echo "$1 "
        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
                	get_deps "$dep"
            	done
        else
            echo "can't find "
            return 1
        fi
    }
    # simple function to remove dups.  
    # Recursively iterate through all words and don't echo dups. 
    # TODO not working yet
    function remove_dups () {
        if [ ${#2[@]} ] ; then return ; fi          # end of list
        if [ $1 != ${2[0]} ] ; then echo $1 ; fi    # no dup
        remove_dups ${2[@]:1:1} ${2[@]:2}
    }
   
   #                       tac reverses lines, tr removes new lines,sed puts quotes around the lot. 
   { [ $2 ] && get_deps "$1" || tac <(get_deps "$1") ; } | tr -d '\n' | sed 's/^\(.*\) $/"\1"/g' ; echo 
}

#
# 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