You are not logged in.

#1 2004-02-20 12:30:39

tehdely
Member
Registered: 2004-02-20
Posts: 148
Website

Arch packagers - find dependencies easy with this handy tool

I posted this in General Discussion by mistake... Here it is in the proper place. :idea:

I was making my first arch package (toshutils... a bunch of stuff for working with the BIOS on toshiba laptops), and I realized there's no handy little script to check the dependencies of your new package before releasing it into the wild.

Well now there is.

Please critique... it's a dirty hack, but I like it  :twisted:

#!/usr/bin/perl

# finddeps.pl - a nice little hack to figure out all the dependencies
# for an arch linux package... prints verbose info to stderr, and the names
# of the dependencies to stdout.
#
# Run it in a directory full of binaries that you want to check for deps, ex: 
#    cd /var/abs/local/mypackage/pkg/usr/bin
#    finddeps.pl
#
# Copyright 2004 Michael Baehr
#
#  * This program is free software; you can redistribute it and/or modify
#   * it under the terms of the GNU General Public License as published by
#    * the Free Software Foundation; either version 2 of the License, or
#     * (at your option) any later version.
#
     
use warnings;
use strict;

my %libs;
my %deps;

open (LS,"ls |");
my @binaries = <LS>;
close (LS);

sub color {
        my ($h,$b,$f) = @_;
        print STDERR "33[$h;$b;$f"."m";
}
sub color_off {
        print STDERR "33[0m";
}
while (@binaries != 0) {
        chomp (my $bin = pop(@binaries));
        print STDERR "Finding dependencies for: ";
        &color(1,1,34);
        print STDERR "$binn";
        &color_off;
        open (AWK,"ldd $bin|awk '{print $3}'|");
        my @libs = <AWK>;
        close (AWK);

        while (@libs !=0) {
                chomp (my $lib = pop(@libs));
                if (!defined($libs{$lib})) {
                        open (PACMAN,"pacman -Qo $lib|awk '{print $5}'|");
                        chomp ($libs{$lib} = <PACMAN>);
                        close (PACMAN);
                }
                if ($libs{$lib} ne "") {
                        print STDERR "t$lib => ";
                        &color(1,1,31);
                        print STDERR "$libs{$lib}n";
                        &color_off;
                        if (!defined($deps{$libs{$lib}})) {
                                $deps{$libs{$lib}} = "";
                        }
                }
        }
}

print "Done calculating dependencies.n";

foreach my $dep (keys %deps) {
        &color(1,1,31);
        print STDERR "Dependency: ";
        &color_off;
        print "$depn";
}

[Arch GNUstep Repository] [ PKGBUILDS ]
[code][gnustep]
Server = ftp://blkwidow.lerp.com/pub/mirror/arch/gnustep[/code]

Offline

#2 2004-02-20 14:15:46

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: Arch packagers - find dependencies easy with this handy tool

namcap already does this and more


AKA uknowme

I am not your friend

Offline

#3 2004-02-20 18:56:39

tehdely
Member
Registered: 2004-02-20
Posts: 148
Website

Re: Arch packagers - find dependencies easy with this handy tool

sarah31 wrote:

namcap already does this and more

Looks cool.  Thanks for the heads up  8)


[Arch GNUstep Repository] [ PKGBUILDS ]
[code][gnustep]
Server = ftp://blkwidow.lerp.com/pub/mirror/arch/gnustep[/code]

Offline

#4 2004-10-19 02:48:31

rjs
Member
Registered: 2004-04-20
Posts: 23

Re: Arch packagers - find dependencies easy with this handy tool

Just trying out this script and everytime that I run it, i get the following error:

sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `pacman -Qo (0xffffe000)|awk '{print $5}''
Use of uninitialized value in chomp at ../finddeps.pl line 50.
Use of uninitialized value in string ne at ../finddeps.pl line 53.
Done calculating dependencies.

I am running current as of today, and have perl 5.8.5-2 installed.

Any ideas why, and yes I know namcap isavailable, just trying to figure out what went wrong.

Offline

Board footer

Powered by FluxBB