aboutsummaryrefslogtreecommitdiff
path: root/sbocheck
blob: 18c3e7c30bfa53d23ec90b3261be009a88319bc4 (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
#!/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.12.3;
use SBO::Lib;
use File::Basename;
use Getopt::Std;
use Text::Tabulate;
use warnings FATAL => 'all';
use strict;

my %config = %SBO::Lib::config;
my $self = basename ($0);

my %options;
getopts ('v',\%options);

show_version && exit 0 if exists $options{v};

update_tree;

say "Checking for updated SlackBuilds...";
my $updates = get_available_updates;

# pretty formatting.
my @listing;
for my $up (@$updates) {
	my $string = "$$up{name}-$$up{installed}";
	$string .= "        <   needs updating (SBo has $$up{update})\n";
	push @listing, $string;
}

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.";
}

exit 0;