blob: ccbbe243e6c0047f570d67ff67993e927c4988d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/usr/bin/env perl
#
# vim: set ts=4:noet
#
# sbocheck
# script to update the local sbo tree and check for updates
#
# author: Jacob Pipkin <j@dawnrazor.net>
# date: Sweetmorn, the 38th day of Discord in the YOLD 3178
# license: WTFPL <http://sam.zoy.org/wtfpl/COPYING>
use 5.16.0;
use strict;
use warnings FATAL => 'all';
use SBO::Lib;
use Getopt::Long;
use Text::Tabulate;
use File::Basename;
my $self = basename ($0);
sub show_usage () {
print <<EOF
Usage: $self
Options:
-h|--help:
this screen.
-v|--version:
version information.
EOF
}
my ($help, $vers);
GetOptions ('help|h' => \$help, 'version|v' => \$vers);
show_usage && exit 0 if $help;
show_version && exit 0 if $vers;
update_tree;
# retrieve and format list of available updates
sub get_update_list () {
print "Checking for updated SlackBuilds...\n";
my $updates = get_available_updates;
# pretty formatting.
my @listing;
for my $update (@$updates) {
my $string = "$$update{name}-$$update{installed}";
$string .= " < needs updating (SBo has $$update{update})\n";
push @listing, $string;
}
return \@listing;
}
# Text::Tabulate and print list of updates
sub print_output ($) {
exists $_[0] or script_error 'print_output requires an argument';
my $listing = shift;
if (exists $$listing[0]) {
my $tab = new Text::Tabulate ();
$tab->configure (tab => '\s');
my $output = $tab->format (@$listing);
say "\n". $output;
} else {
say "\nNo updates available.";
}
}
my $output = get_update_list;
print_output $output;
exit 0;
|