source: web/bin/sophie_fetch_maint

Last change on this file was 376, checked in by nanardon, 13 years ago
  • make fetch_maint silent
File size: 849 bytes
Line 
1#!/bin/env perl
2
3use strict;
4use warnings;
5use Sophie::Base;
6
7my $sophie = Sophie::Base->connect;
8
9foreach my $maintsource (
10    $sophie->resultset('MaintSources')
11    ->search->all) {
12
13    my $realclass = 'Sophie::Maint::' . $maintsource->accessor;
14    no strict qw(refs);
15    eval "require $realclass;";
16    next if($@);
17
18    my $fetcher = $realclass->new($maintsource);
19    if (my $list = $fetcher->fetch) {
20        $sophie->resultset('MaintRpm')->search(
21            {
22                sources => $maintsource->pkey,
23            }
24        )->delete;
25
26        foreach (@$list) {
27            $_->{sources} = $maintsource->pkey;
28        }
29
30        $sophie->txn_do(
31            sub {
32                $sophie->resultset('MaintRpm')->populate($list) &&
33                $maintsource->update({ lastupdated => 'now()' });
34            }
35        );
36    }
37}
Note: See TracBrowser for help on using the repository browser.