#!/usr/bin/env perl # # vim: set ts=4:noet # # sbocheck # script to update the local sbo tree and check for updates # # author: Jacob Pipkin # date: Sweetmorn, the 38th day of Discord in the YOLD 3178 # license: WTFPL use 5.16.0; use strict; use warnings FATAL => 'all'; use SBO::Lib; use Getopt::Std; use Text::Tabulate; my %options; getopts ('v',\%options); show_version && exit 0 if exists $options{v}; 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;