Skip to content

Commit

Permalink
initial bits to pull pkg list from the pkgdb
Browse files Browse the repository at this point in the history
  • Loading branch information
rsrchboy committed Feb 21, 2010
1 parent 1aa4960 commit c16b9af
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile.PL
Expand Up @@ -27,6 +27,8 @@ requires 'YUM::RepoQuery';
requires 'autodie'; requires 'autodie';
requires 'IPC::System::Simple'; requires 'IPC::System::Simple';
requires 'CPAN::SQLite'; requires 'CPAN::SQLite';
requires 'URI::Fetch';
requires 'JSON::XS';


catalyst; catalyst;


Expand Down
39 changes: 39 additions & 0 deletions tools/update-from-repos
Expand Up @@ -15,11 +15,14 @@ use lib "$FindBin::Bin/../lib";
use DateTime; use DateTime;
use DBI; use DBI;
use File::Temp 'tempfile'; use File::Temp 'tempfile';
use JSON::XS;
use Path::Class; use Path::Class;
use Scope::Guard; use Scope::Guard;
use YUM::RepoQuery; use YUM::RepoQuery;
#use TryCatch; #use TryCatch;
use Try::Tiny; use Try::Tiny;
use URI::Fetch;

use Fedora::App::Updates::Schema; use Fedora::App::Updates::Schema;


# debugging... # debugging...
Expand All @@ -31,6 +34,8 @@ opts
my $do_cpan => { isa => 'Bool', default => 0, }, # FIXME tmp anyways my $do_cpan => { isa => 'Bool', default => 0, }, # FIXME tmp anyways
my $server => { isa => 'Str', default => '172.16.42.70' }, my $server => { isa => 'Str', default => '172.16.42.70' },
my $stage => { isa => 'Str', default => 'fedora_stage' }, my $stage => { isa => 'Str', default => 'fedora_stage' },

my $do_pkgdb => { isa => 'Bool', default => 0 },
; ;


my ($TMPFH, $TMPFILE) = tempfile; my ($TMPFH, $TMPFILE) = tempfile;
Expand Down Expand Up @@ -114,6 +119,40 @@ if ($do_cpan) {
exit; exit;
} }


# NOTE: a lot of this code is more or less lifted straight out of the old
# "check-upstream" script. It, like these tables themselves, could use some
# serious attention.

if ($do_pkgdb) {

my $url =
'https://admin.fedoraproject.org/pkgdb/acls/bugzilla?tg_format=json';

# load the classes we need
#Class::MOP::load_class($_) for qw{ URI::Fetch JSON::XS };

### fetching the raw data...
# FIXME I know, "not optimal"
my $data =
decode_json(URI::Fetch->fetch($url)->content)
->{bugzillaAcls}->{Fedora}
;

### now, load into db...
my $user_rs = $fu->resultset('Users');
my $pkg_rs = $fu->resultset('Packages');
my %seen;

for my $name (keys %$data) {

my $owner = $data->{$name}->{owner};
$user_rs->find_or_create({ id => $owner }) unless $seen{$owner}++;
$pkg_rs->update_or_create({ owner_id => $owner, name => $name });
}

exit;
}

my $try = 0; my $try = 0;


MAIN_LOOP: MAIN_LOOP:
Expand Down

0 comments on commit c16b9af

Please sign in to comment.