LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-07-2012, 07:51 PM   #16
mariostg
Member
 
Registered: Apr 2011
Location: Gatineau, Quebec
Distribution: OpenBSD
Posts: 80

Rep: Reputation: 5

Indeed an interesting tool.
I was playing around and wrote a couple of function that help identifying dependencies and nothing else. Maybe there is already something similar. I just felt like doing some bash. The output gives an idea of the workload ahead

Code:
#!/bin/bash

#set -x
set -o nounset
REPO="/var/lib/sbopkg/SBo/14.0/"
REPOTXT="SLACKBUILDS.TXT"
SCRIPT=${0##*/}

if [[ $# -lt 1 ]]; then
    echo "$SCRIPT usage : SCRIPT <packagename>"
    exit 0
fi

SEARCHPACKAGE=$1
FOUNDPACKAGE="NOT FOUND" #No package found yet...

find_repository(){
    #Parse SLACKBUILD.TXT for SEARCHPACKAGE to find repository name
    #where package info file is found.
    STATE=0 #State machine 0 since no package found yet.
    if [[ $# -eq 0 ]]; then
        echo "Nothing to do"
        exit 0
    fi
    SEARCHPACKAGE=$1 #The package we are searching
    RESULT=`grep -A1 "SLACKBUILD NAME: $SEARCHPACKAGE" $REPO$REPOTXT|cut -d':' -f2`
    for line in $RESULT
    do
        if [[ $line = $SEARCHPACKAGE ]]; then
            FOUNDPACKAGE=$line
            STATE=1
            continue #read next line to get pkgdir
        fi
        if [[ $STATE = 1 ]]; then
            STATE=0
            PKGDIR=`echo $line|sed s#\.\/##`
            infofile="$REPO$PKGDIR/$FOUNDPACKAGE.info"
            find_package_dependency $infofile $FOUNDPACKAGE
            break
        fi
    done
}

find_package_dependency(){
    #Search the string that begins with REQUIRES in infofile argument
    #provided in function call.
    infofile=$1 # Such as /var/lib/sbopkg/SBo/14.0/academic
    ParentPackage=$2
    SEARCHPACKAGE=""
    #echo "Search Requires in $infofile"
    while read line
    do
        if [[ "$line" =~ ^REQUIRES.* ]]; then
            SEARCHPACKAGE=${line#REQUIRES=}
            SEARCHPACKAGE=${SEARCHPACKAGE//\"/}
            if [[ "$SEARCHPACKAGE" != '' ]]; then
                echo "  $ParentPackage requires $SEARCHPACKAGE"
            else
                echo "  $ParentPackage no dependency found"
            fi

            for item in $SEARCHPACKAGE
            do
                find_repository $item
            done
            break
        fi
    done <$infofile
}
find_repository $SEARCHPACKAGE
Sample output
Quote:
marst@hplaptop(20:23 Sunday 07 - October 2012)
[~/bin]
>>>./sbodep.sh gparted
gparted requires gtkmm
gtkmm requires atkmm mm-common
atkmm requires pangomm
pangomm requires cairomm
cairomm requires glibmm
glibmm requires libsigc++
libsigc++ no dependency found
mm-common no dependency found

Last edited by mariostg; 10-08-2012 at 02:05 PM. Reason: Used code tag instead of quote tag
 
Old 10-07-2012, 11:23 PM   #17
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Original Poster
Rep: Reputation: Disabled
General thanks again - glad to see so many people enjoying it.

Quote:
Originally Posted by mrclisdue View Post
sbopkg+queuefiles=dependency resolution in the church of the subgenious

praise bob,
Amen.

Quote:
Originally Posted by lopid View Post
Thank you.

When viewing the queue, since it shows the installed version, consider showing the newer version as well. If one of the packages would be downgraded, it's impossible to tell on that screen.

Could you please remove the 'clear' from line 4440?
I will consider that, but how often does it happen and what would be the problem when it does? As far as the clear, what's the problem with that?

Quote:
Originally Posted by kikinovak View Post
OK, upgraded here. Except you modified some keyboard shortcuts, and now I can't build a package using the left hand only on the keyboard with "B" for "Build". I also have to use the right hand to activate "P" for "Process".
Sorry about that. It wasn't entirely accurate even before and now that you can download, build, and/or install, "processing" just seemed to make more sense where "build" was misleading. If you have gpm or are using an xterm, the ui responds to the mouse so you can still do it one-handed that way.
 
Old 10-08-2012, 02:20 AM   #18
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
@mariostg - I too felt the urge to play around with the "requires" field. My humble effort is written in Python, and it simply generates the SQF files.

I'll post it below in quoted format, but i'm not sure if the indentation will be respected. As that's critical to Python, it's kinda make-or-break !
Code:
#!/usr/bin/python

import sys, os

topdir = "/var/lib/sbopkg/SBo/14.0"
sqfdir = "/tmp/sqf"

deps = {}

def get_requires(filnam):
    for ln in open(filnam,"r"):
        if not ln.startswith("REQUIRES"): continue
        return ln.split('"')[1].split()
    return []

def process(arg, dirname, names):
    for fn in names:
        if not fn.endswith(".info"): continue
        pkg = fn.strip().replace(".info","")
        reqs = get_requires(os.path.join(dirname,fn))
        deps[pkg] = reqs

try:
    os.chdir(topdir)
except:
    print "Failed to find SlackBuilds dir '%s'" % topdir
    sys.exit(1)

os.path.walk(".",process,True)

try:
    os.mkdirs(sqfdir)
except:
    pass 

try:
    os.chdir(sqfdir)
except:
    print "Failed to get to SQF dir '%s'" % sqfdir
    sys.exit(2)

pkgs = deps.keys()
for p in pkgs:
    pdeps = deps[p]
    if '%README%' in pdeps:
        print "%s - complex build - see readme" % p
        continue
    if not pdeps: 
        continue
    try:
        f = open(p+".sqf","w")
        for d in pdeps:
            f.write("@" + d + "\n")
        f.write(p+"\n")
    except:
        print "Error while creating SQF (%s) ... continuing ..." % p
Simply copy+paste that into a file, say "generate_sqf.py", chmod it to be executable and run it.
 
Old 10-08-2012, 11:42 AM   #19
jtsn
Member
 
Registered: Sep 2011
Posts: 922

Rep: Reputation: 480Reputation: 480Reputation: 480Reputation: 480Reputation: 480
Quote:
Originally Posted by mrclisdue View Post
sbopkg+queuefiles=dependency resolution in the church of the subgenious
The queue files only help with bootstrapping SlackBuilds from scratch in the correct order.

The dependencies of the resulting binaries are a complete different, way more complex story.

Last edited by jtsn; 10-08-2012 at 11:43 AM.
 
Old 10-08-2012, 12:33 PM   #20
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
Quote:
Originally Posted by jtsn View Post
The queue files only help with bootstrapping SlackBuilds from scratch in the correct order.

The dependencies of the resulting binaries are a complete different, way more complex story.
Hmmm - I'm not sure what you mean by that. Can you be a bit more clearer please ? Maybe supply an example !
 
Old 10-08-2012, 02:08 PM   #21
mariostg
Member
 
Registered: Apr 2011
Location: Gatineau, Quebec
Distribution: OpenBSD
Posts: 80

Rep: Reputation: 5
Quote:
Originally Posted by Mark Pettit View Post
Hmmm - I'm not sure what you mean by that. Can you be a bit more clearer please ? Maybe supply an example !
Yes pls elaborate...

@Mark, I am too new with Slackware et al. Did not know anything about sqf file until after I wrote the script. And yet, I did not check yet how it is used.
 
Old 10-08-2012, 05:57 PM   #22
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Original Poster
Rep: Reputation: Disabled
He may mean that queuefiles list SBo build requirements but that the actual dependencies of a package may also include any of the things shipping with a default Slackware. IOW, if you remove icu4c from your Slackware and try to install dwdiff with internationalization enabled, the SlackBuild will fail (with or without sbopkg) and no REQUIRES list will help with that. Also, required or not, if a variety of non-Slackware packages are installed, certain packages may pick up certain deps that are not part of Slackware or listed in the REQUIRES field and may break if some of them are removed or altered. If he means something else, he'll have to clarify.

Also, queuefiles are not simple lists. They can include comments, can have programs present but disabled, can load other queuefiles recursively, and can include build options for each package. For more details, see /usr/doc/sbopkg-$your_version/README-queuefiles or http://www.sbopkg.org/queues.php.

Finally, unless they changed it, it was my understanding that the REQUIRES list is either unsorted or alphabetical and not in required build order. Let's pretend you could build libsigc++ and mm-common without each other so that they are not dependent on one another. But let's pretend that, for the purposes of building gtkmm, the order they were installed mattered (and it may, for all I know) - which comes first, atkmm or mm-common? And what about circular dependencies, if any? And what about optional dependencies that aren't listed in the REQUIRES field at all, but are still in the README? If someone builds with that option enabled, you'll still need to parse the README file to find the optional dep so you can include it and its now-no-longer optional deps from the REQUIRES fields, assuming the optional dep's deps are even available from SBo. And don't forget about the possibility of the %README% value in the REQUIRES assignment. And don't forget that you should read the READMEs anyway.

Arch has dependency resolution. Ubuntu has dependency resolution. Red Hat has dependency resolution. That particular wheel has been reinvented hundreds of times for every other distro but Slackware (and, via Slapt and such like, even for Slackware). If you really want it, there are easy ways to get it. Why people want to have gnome installed when they try to install fvwm or have seamonkey uninstalled when they try to remove wget or want to experience the joys of "wedged databases" I just don't know, but there are already a lot of ways to find those thrills.

But this isn't to discourage people from developing ways to generate queuefiles - any contributions to the ecosystem of Slackware, SBo, and sbopkg can be helpful - and the interest shown is inspiring, either way - I'm just underscoring some of the headaches that have already been "solved" for certain other systems (and the new headaches you get with the "solutions") and expressing part of why Slackware/pkgtools (and slackpkg) and SBo/sbopkg don't do this directly.
 
1 members found this post helpful.
Old 10-09-2012, 01:43 AM   #23
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
@slakmagik - thank you for that post. I'm not convinced about the "binaries" part still - and my assumption is that the SlackBuilds always works off a full Slackware install. So you remove packages or do a partial install at your own peril. I've just rebuilt my entire system from a brand new install and then an aggressive use of the SlackBuilds. I hit quite a few frustrations. Then I saw the "requires" field and wrote a small python script to generate SQF's. That helped a bit. Until I hit "mythtv" - brick wall ! So I wrote another script to generate the full dependency list based off the SQF's. And lo and behold - it worked perfectly. I must tell you that the mythtb-plugins have about 100 perl module dependencies, in a complex tree, sort of messy - just like perl :-) The good news is that it did in fact work. I have noticed the %README% files. So far I've been lucky not to need them. But my script does print a warning anyway.
 
Old 10-09-2012, 03:09 PM   #24
Chelyuk
LQ Newbie
 
Registered: Sep 2012
Posts: 15

Rep: Reputation: Disabled
New release is very nice, but I can't see where is lists of dependencies. May be I've blinded, so please point me on it. Cause it's uncomfortable to see dependencies in browser.
 
Old 10-09-2012, 03:11 PM   #25
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
For each SlackBuild, you get the ability to look at the README and Info files. That's where the dependencies are listed.
 
Old 10-09-2012, 04:20 PM   #26
gauchao
Member
 
Registered: Dec 2009
Location: Veneto
Distribution: Slackware64
Posts: 366

Rep: Reputation: 143Reputation: 143
Thank you! Great tool.
 
Old 10-21-2012, 09:24 AM   #27
lopid
Member
 
Registered: Jun 2008
Posts: 156

Rep: Reputation: Disabled
Quote:
Originally Posted by slakmagik View Post
I will consider that, but how often does it happen and what would be the problem when it does? As far as the clear, what's the problem with that?
For example, I have EasyTag 2.1.7 installed. The version in the SB repo. is 2.1.6. Every time I "List potential updates", this shows up ("INSTALLED PACKAGE IS NEWER THAN REPO"). Of course, I don't want to downgrade to 2.1.6. When I then "View the queue" that was automatically created from that list, "easytag" shows up, "Installed 2.1.7". Any other potential upgrades (actual version upgrades) also show up, and they also say "Installed <version>", but there's no way to differentiate between the ones that are potential upgrades and the ones that are already newer on the system.

<rant attribute="apology">
Regarding the screen clearing, I like to see what is on my terminal after doing something on it. I don't like things that clear it for me. If I wanted to clear it, I'd press ctrl-l. It annoys me when distros put "clear" in their .bash_logout. When I SSH into a system, do something, and leave, I want what I did to remain so I have an easy reference or reminder. Maybe I want to copy some of the text. Clearing the console like that might have had some use back in the day when people didn't have a screensaver or couldn't close the window (or didn't have ctrl-l!), but these days it's only an annoyance, at least to me. So I think the question is rather: Why is it there?
</rant>

I'd actually recommend using the alternate screen for any full-screen script, so the state of the terminal is restored once the script exits, but one can still see that the script was run. "tput smcup" before going full screen, and "tput rmcup" after.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] sbopkg 0.35.0 is released slakmagik Slackware 5 04-29-2011 01:53 PM
[ANN] sbopkg 0.34.1 is released slakmagik Slackware 3 02-06-2011 02:57 PM
[ANN] sbopkg 0.34.0 is released slakmagik Slackware 14 11-16-2010 09:11 PM
[ANN] sbopkg 0.33.2 is released slakmagik Slackware 13 07-22-2010 12:47 PM
[ANN] sbopkg 0.33.1 released slakmagik Slackware 6 05-27-2010 10:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration