7 use Fedora
::Rebuild
::Set
::Package
;
8 use Fedora
::Rebuild
::Package
;
9 use Fedora
::Rebuild
::Package
::Config
;
10 use Fedora
::Rebuild
::Scheduler
;
11 use Fedora
::Rebuild
::Package
::ListLog
;
20 rebuildedit - Mass edit source repositories
24 rebuildedit [--config FILE]
28 This tool clones source repositories for all packages sepcified in I<all>
29 list, executes an I<editor> command there and if the repository is changed,
30 commits and pushed the changes back to the server.
32 Packages without changes or successfully changed ones will be logged into
33 I<done> list. Packages that encountered an error will be logged into <failed>
36 The I<editor> is a list consisting of command name folloed by optional
37 positional arguments. When executing the editor command, a spec file will be
38 appended as a last argument. The editor will be executed in the git repository
43 my $cfgfile = File
::Spec
->catfile($ENV{HOME
}, '.rebuildperlrc');
62 =head2 --config I<FILE>
64 Read configuration from I<FILE>, or F<~/.rebuildperlrc> if not specified.
68 =head2 F<~/.rebuildperlrc>
70 Configuration is in L<Config::Tiny> format. Following options are needed:
76 editor = [ 'program', 'argument' ]
77 message = A commit mesage
79 Additional possible options:
89 'config=s' => \
$cfgfile,
90 ) or die "Could not parse program options\n";
94 my $cfg = Config
::Tiny
->new->read($cfgfile);
96 print STDERR
"Could not parse `" . $cfgfile .
97 "' configuration file: " . $Config::Tiny
::errstr
. "\n";
100 foreach (keys %{$cfg->{_
}}) {
101 $config{$_} = $cfg->{_
}->{$_};
102 $config{$_} = eval $config{$_} if $_ eq 'editor';
106 # Load list of packages
108 my ($file_name) = @_;
109 my $packages = Fedora
::Rebuild
::Set
::Package
->new();
112 if (not -e
$file_name) {
116 open($file, '<', $file_name) or
117 croak
"Could not open `" . $file_name . "': $!";
118 while (local $_ = <$file>) {
120 if (m/^\s*$/) { next; }
121 if ($packages->contains($_)) {
122 warn "Duplicate name `$_'.\n";
126 my $package = Fedora
::Rebuild
::Package
->new(name
=> $_,
127 workdir
=> $config{workdir
}, dist
=> $config{dist
},
128 pkgdist
=> $config{pkgdist
}, target
=> $config{target
},
129 message
=> $config{message
});
130 $packages->insert($package);
133 croak
"Could not read list of package names from file `" .
134 $file_name . "': $!";
143 my $build_config = Fedora
::Rebuild
::Package
::Config
->new(
144 mode
=> $config{mode
},
145 pyrpkg
=> $config{pyrpkg
},
148 architecture
=> 'x86_64',
149 mock_install_packages
=> '',
154 print "Loading list of all package names...\n";
155 my $packages = load_list
($config{all
});
156 print "Number of all packages: " . $packages->size() . "\n";
158 print "Loading list of done package names...\n";
159 my $done = load_list
($config{done
});
160 print "Number of done packages: " . $done->size() . "\n";
162 print "Loading list of failed package names...\n";
163 my $failed = load_list
($config{failed
});
164 print "Number of failed packages: " . $failed->size() . "\n";
166 # Strip done and failed packages
167 for ($done->packages, $failed->packages) {
168 $packages->delete($_);
172 my $scheduler = Fedora
::Rebuild
::Scheduler
->new(
173 limit
=> $config{loadthreads
},
174 name
=> 'Editing repository',
175 total
=> $packages->size
180 for my $package ($packages->packages) {
181 my $job = $scheduler->schedule($package->can('cloneeditpush'), $package,
182 $build_config, $config{anonymous
}, $config{editor
});
183 if (! defined $job) {
186 $jobs{$job} = $package;
187 my %finished = $scheduler->finish(++$i < $packages->size);
189 while (my ($job, $status) = each %finished) {
190 my $package = $jobs{$job};
193 print "Could not edit repository for package `",
194 $package->name, "'.\n";
195 Fedora
::Rebuild
::Package
::ListLog
->new(
196 file
=> $config{failed
})->log($package);
198 Fedora
::Rebuild
::Package
::ListLog
->new(
199 file
=> $config{done
})->log($package);