Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial bits to pull pkg list from the pkgdb

  • Loading branch information...
commit c16b9af773d90cfdcf6fd784068c7a8882f3d6d0 1 parent 1aa4960
@RsrchBoy authored
Showing with 41 additions and 0 deletions.
  1. +2 −0  Makefile.PL
  2. +39 −0 tools/update-from-repos
View
2  Makefile.PL
@@ -27,6 +27,8 @@ requires 'YUM::RepoQuery';
requires 'autodie';
requires 'IPC::System::Simple';
requires 'CPAN::SQLite';
+requires 'URI::Fetch';
+requires 'JSON::XS';
catalyst;
View
39 tools/update-from-repos
@@ -15,11 +15,14 @@ use lib "$FindBin::Bin/../lib";
use DateTime;
use DBI;
use File::Temp 'tempfile';
+use JSON::XS;
use Path::Class;
use Scope::Guard;
use YUM::RepoQuery;
#use TryCatch;
use Try::Tiny;
+use URI::Fetch;
+
use Fedora::App::Updates::Schema;
# debugging...
@@ -31,6 +34,8 @@ opts
my $do_cpan => { isa => 'Bool', default => 0, }, # FIXME tmp anyways
my $server => { isa => 'Str', default => '172.16.42.70' },
my $stage => { isa => 'Str', default => 'fedora_stage' },
+
+ my $do_pkgdb => { isa => 'Bool', default => 0 },
;
my ($TMPFH, $TMPFILE) = tempfile;
@@ -114,6 +119,40 @@ if ($do_cpan) {
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;
MAIN_LOOP:
Please sign in to comment.
Something went wrong with that request. Please try again.