Skip to content

Commit

Permalink
Merge branch 'release/v1.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
giterlizzi committed May 31, 2017
2 parents 77ae520 + 261de7e commit 7386c32
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 148 deletions.
2 changes: 1 addition & 1 deletion lib/Slackware/SlackMan.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BEGIN {

@ISA = qw(Exporter);

$VERSION = 'v1.0.3';
$VERSION = 'v1.0.4';

@EXPORT_OK = (
@Slackware::SlackMan::Utils::EXPORT_OK,
Expand Down
39 changes: 18 additions & 21 deletions lib/Slackware/SlackMan/Command.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN {

require Exporter;

$VERSION = 'v1.0.3';
$VERSION = 'v1.0.4';
@ISA = qw(Exporter);
@EXPORT_OK = qw(run);
%EXPORT_TAGS = (
Expand Down Expand Up @@ -75,7 +75,7 @@ sub run {

my @lock_commands = qw(update install upgrade remove reinstall clean);

logger->debug(sprintf('Call %s command (cmd: slackman %s)', $command, join(' ', @ARGV)));
logger->debug(sprintf('[CMD] Call "%s" command (cmd: %s, pid: %s)', $command, join( " ", $0, @ARGV ), $$));

# Check running slackman instance and block certain commands (only
# informational command are available)
Expand Down Expand Up @@ -395,17 +395,10 @@ sub _call_update_repo_gpg_key {

STDOUT->printflush(" * $repo... ");

my $gpg_key_url = $repo_data->{gpgkey};
my $gpg_key_path = sprintf('%s/%s/GPG-KEY', $slackman_conf->{directory}->{cache}, $repo);

unless (-e $gpg_key_path) {

make_path(dirname($gpg_key_path));

if (download_file($gpg_key_url, $gpg_key_path, "-s")) {
gpg_import_key($gpg_key_path) if (-e $gpg_key_path);
}

if (download_repository_metadata($repo, 'gpgkey')) {
gpg_import_key($gpg_key_path) if (-e $gpg_key_path);
}

STDOUT->printflush("done\n");
Expand Down Expand Up @@ -1058,19 +1051,23 @@ sub _call_changelog {
# Filter disabled repository
push(@filters, sprintf('repository NOT IN ("%s")', join('","', get_disabled_repositories())));

my $sth = $dbh->prepare(sprintf($query, join(' AND ', @filters), $slackman_opts->{'limit'}));
$query = sprintf($query, join(' AND ', @filters), $slackman_opts->{'limit'});

my $sth = $dbh->prepare($query);
$sth->execute();

print sprintf("%-60s %-20s %-10s %-20s %s\n", "Package", "Version", "Status", "Timestamp", "Repository");
print sprintf("%-60s %-20s %-1s %-10s %-20s %s\n", "Package", "Version", " ", "Status", "Timestamp", "Repository");
print sprintf("%s\n", "-"x132);

while (my $row = $sth->fetchrow_hashref()) {
print sprintf("%-60s %-20s %-10s %-20s %s\n",
($row->{'package'} || ''),
($row->{'version'} || ''),
($row->{'status'} || ''),
($row->{'timestamp'} || ''),
($row->{'repository'} || '')

print sprintf("%-60s %-20s %-1s %-10s %-20s %s\n",
($row->{'package'} || ''),
($row->{'version'} || ''),
($row->{'security_fix'} ? '!' : ''),
($row->{'status'} || ''),
($row->{'timestamp'} || ''),
($row->{'repository'} || '')
);
}

Expand Down Expand Up @@ -1111,7 +1108,7 @@ sub _call_repo_info {
}

my $package_nums = $dbh->selectrow_array('SELECT COUNT(*) AS packages FROM packages WHERE repository = ?', undef, $repo_id);
my $last_update = time_to_timestamp(db_meta_get("packages-last-update.$repo_id"));
my $last_update = time_to_timestamp(db_meta_get("last-update.$repo_id.packages"));

my @urls = qw/changelog packages manifest checksums gpgkey/;

Expand All @@ -1120,7 +1117,7 @@ sub _call_repo_info {
print sprintf("%-20s %s\n", "ID:", $repo_data->{id});
print sprintf("%-20s %s\n", "Mirror:", $repo_data->{mirror});
print sprintf("%-20s %s\n", "Status:", (($repo_data->{enabled}) ? 'enabled' : 'disabled'));
print sprintf("%-20s %s\n", "Last Update:", $last_update);
print sprintf("%-20s %s\n", "Last Update:", ($last_update || ''));
print sprintf("%-20s %s\n", "Priority:", $repo_data->{priority});
print sprintf("%-20s %s\n", "Packages:", $package_nums);

Expand Down
2 changes: 1 addition & 1 deletion lib/Slackware/SlackMan/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN {

require Exporter;

$VERSION = 'v1.0.3';
$VERSION = 'v1.0.4';
@ISA = qw(Exporter);

@EXPORT_OK = qw{
Expand Down
40 changes: 21 additions & 19 deletions lib/Slackware/SlackMan/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN {

require Exporter;

$VERSION = 'v1.0.3';
$VERSION = 'v1.0.4';
@ISA = qw(Exporter);

@EXPORT_OK = qw{
Expand Down Expand Up @@ -103,7 +103,9 @@ use constant SLACKMAN_CHANGELOGS_TABLE => qq/CREATE TABLE IF NOT EXISTS "changel
"arch" VARCHAR,
"build" INTEGER,
"tag" VARCHAR,
"category" VARCHAR,
"status" VARCHAR,
"description" VARCHAR,
"security_fix" BOOL)/;

use constant SLACKMAN_METADATA_TABLE => qq/CREATE TABLE IF NOT EXISTS "metadata" (
Expand Down Expand Up @@ -156,12 +158,12 @@ sub dbh {
sub db_init {

foreach (SLACKMAN_TABLES) {
logger->debug(qq/Init table "$_"/);
logger->debug(qq/[DB] Init table "$_"/);
$dbh->do(SLACKMAN_SCHEMA->{$_});
}

foreach (SLACKMAN_INDEXES) {
logger->debug(qq/Init index "$_"/);
logger->debug(qq/[DB] Init index "$_"/);
$dbh->do(SLACKMAN_SCHEMA->{$_});
}

Expand All @@ -177,7 +179,7 @@ sub db_wipe_tables {
}

sub db_wipe_table {
logger->debug(qq/Wipe "$_" table/);
logger->debug(qq/[DB] Wipe "$_" table/);
$dbh->do("DELETE FROM $_");
}

Expand All @@ -196,35 +198,35 @@ sub db_insert {
}

sub db_compact {
logger->debug('Compact database');
logger->debug('[DB] Compact database');
$dbh->do('PRAGMA VACUUM');
}

sub db_reindex {

foreach (SLACKMAN_TABLES) {
logger->debug(qq/Reindex "$_" table/);
logger->debug(qq/[DB] Reindex "$_" table/);
$dbh->do("REINDEX $_");
}

foreach (SLACKMAN_INDEXES) {
logger->debug(qq/Reindex "$_" index/);
logger->debug(qq/[DB] Reindex "$_" index/);
$dbh->do("REINDEX $_");
}

}

sub db_bulk_insert {

my ($data) = @_;
my (%params) = @_;

my $table = $data->{'table'};
my $columns = $data->{'columns'};
my $values = $data->{'values'};
my $table = $params{'table'};
my $columns = $params{'columns'};
my $values = $params{'values'};

my $n_rows = scalar(@$values);

logger->debug(qq/Insert $n_rows rows into "$table" table/);
logger->debug(qq/[DB] Insert $n_rows rows into "$table" table/);

my $query = sprintf("INSERT INTO %s(%s) VALUES(%s)",
$table,
Expand All @@ -236,6 +238,8 @@ sub db_bulk_insert {

my $sth = $dbh->prepare($query);

logger->debug(qq/[DB] $query/);

foreach my $row (@$values) {
$sth->execute(@$row);
}
Expand All @@ -247,8 +251,7 @@ sub db_bulk_insert {
sub db_meta_get {

my ($key) = @_;

logger->debug(qq/Get key "$key" value/);
logger->debug(qq/[DB] Get key "$key" value/);

return $dbh->selectrow_array(qq/SELECT value FROM metadata WHERE key = ?/, undef, $key);

Expand All @@ -257,8 +260,7 @@ sub db_meta_get {
sub db_meta_set {

my ($key, $value) = @_;

logger->debug(qq/Set key "$key" value "$value"/);
logger->debug(qq/[DB] Set key "$key" value "$value"/);

$dbh->do(qq/DELETE FROM metadata WHERE key = ?/, undef, $key);
$dbh->do(qq/INSERT INTO metadata(key, value) VALUES(?, ?)/, undef, $key, $value);
Expand All @@ -271,7 +273,7 @@ sub db_meta_delete {

my ($key) = @_;

logger->debug(qq/Delete key "$key"/);
logger->debug(qq/[DB] Delete key "$key"/);

return $dbh->selectrow_array(qq/DELETE FROM metadata WHERE key = ?/, undef, $key);

Expand All @@ -288,14 +290,14 @@ Slackware::SlackMan::DB - SlackMan DB module
use Slackware::SlackMan::DB qw(:all);
db_bulk_insert({
db_bulk_insert(
'table' => 'foo',
'columns' => [ 'foo', 'bar', 'baz' ],
'values' => [
[1,2,3],
[4,5,6]
],
})
)
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Slackware/SlackMan/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN {

require Exporter;

$VERSION = 'v1.0.3';
$VERSION = 'v1.0.4';
@ISA = qw(Exporter);
@EXPORT_OK = qw{}

Expand Down
2 changes: 1 addition & 1 deletion lib/Slackware/SlackMan/Package.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN {

require Exporter;

$VERSION = 'v1.0.3';
$VERSION = 'v1.0.4';
@ISA = qw(Exporter);

@EXPORT_OK = qw{
Expand Down
Loading

0 comments on commit 7386c32

Please sign in to comment.