aboutsummaryrefslogtreecommitdiff
path: root/SBO-Lib/lib
diff options
context:
space:
mode:
Diffstat (limited to 'SBO-Lib/lib')
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm71
1 files changed, 61 insertions, 10 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index f7b5c86..ed70fcd 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -27,7 +27,7 @@ our @EXPORT = qw(
slackbuilds_or_fetch
fetch_tree
update_tree
- get_installed_sbos
+ get_installed_packages
get_inst_names
get_available_updates
get_requires
@@ -42,6 +42,7 @@ our @EXPORT = qw(
get_arch
get_build_queue
merge_queues
+ get_installed_cpans
$tempdir
$conf_dir
$conf_file
@@ -200,19 +201,43 @@ sub slackbuilds_or_fetch() {
return 1;
}
-# pull an array of hashes, each hash containing the name and version of an sbo
-# currently installed.
-sub get_installed_sbos() {
+# pull an array of hashes, each hash containing the name and version of a
+# package currently installed. Gets filtered using STD, SBO or ALL.
+sub get_installed_packages($) {
+ exists $_[0] or script_error 'get_installed_packages requires an argument.';
+ my $filter = shift;
my @installed;
- # $1 == name, $2 == version
- my $regex = qr#/([^/]+)-([^-]+)-[^-]+-[^-]+$#;
- for my $path (<$pkg_db/*_SBo>) {
- my ($name, $version) = ($path =~ $regex)[0,1];
- push @installed, {name => $name, version => $version};
+
+ my $regex = qr#/([^/]+)-([^-]+)-[^-]+-([^-]+)$#;
+ for my $path (<$pkg_db/*>) {
+ my ($name, $version, $build) = ($path =~ $regex)[0,1,2];
+ # valid types: STD, SBO
+ my $type = 'STD';
+ if ($build =~ m/_SBo*/) {
+ my $sbo = $name;
+ $sbo =~ s/-compat32//g if $name =~ /-compat32$/;
+ $type = 'SBO' if get_sbo_location($sbo);
+ }
+ if ($filter eq $type or $filter eq 'ALL') {
+ push @installed, {name => $name, version => $version};
+ }
}
return \@installed;
}
+# pull an array of hashes, each hash containing the name and version of an sbo
+# currently installed.
+# sub get_installed_sbos() {
+# my @installed;
+# # $1 == name, $2 == version
+# my $regex = qr#/([^/]+)-([^-]+)-[^-]+-[^-]+$#;
+# for my $path (<$pkg_db/*_SBo>) {
+# my ($name, $version) = ($path =~ $regex)[0,1];
+# push @installed, {name => $name, version => $version};
+# }
+# return \@installed;
+# }
+
# for a ref to an array of hashes of installed packages, return an array ref
# consisting of just their names
sub get_inst_names($) {
@@ -304,7 +329,7 @@ sub get_sbo_version($) {
# newer, and compile an array of hashes containing those which are
sub get_available_updates() {
my @updates;
- my $pkg_list = get_installed_sbos;
+ my $pkg_list = get_installed_packages 'SBO';
FIRST: for my $key (keys @$pkg_list) {
my $location = get_sbo_location($$pkg_list[$key]{name});
# if we can't find a location, assume invalid and skip
@@ -862,3 +887,29 @@ sub get_readme_contents($) {
close $fh;
return $readme;
}
+
+# return a list of perl modules installed via the CPAN
+sub get_installed_cpans() {
+ my @locals;
+ for my $dir (@INC) {
+ push @locals, "$dir/perllocal.pod" if -f "$dir/perllocal.pod";
+ }
+ my @contents;
+ for my $file (@locals) {
+ my $fh = open_read $file;
+# push @contents, grep {/Module|VERSION/} <$fh>;
+ push @contents, grep {/Module/} <$fh>;
+ close $fh;
+ }
+ my $mod_regex = qr/C<Module>\s+L<([^\|]+)/;
+# my $ver_regex = qr/C<VERSION:\s+([^>]+)>/;
+ my (@mods, @vers);
+ for my $line (@contents) {
+ push @mods, ($line =~ $mod_regex)[0];
+# push @vers, ($line =~ $ver_regex)[0];
+ }
+ return \@mods;
+# my %cpans;
+# $cpans{$mods[$_]} = $vers[$_] for keys @mods;
+# return \%cpans;
+}