aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2012-12-04 21:15:33 +0000
committerNicolas Vigier <boklm@mageia.org>2012-12-04 21:15:33 +0000
commitcec481c34a49016db97055b408c3c72a62d17766 (patch)
tree8fd099fda095deb8966df9f0ff2668d6c55da9fd
parent1cda71793f01cba9577d6c7925e6bc19024960bc (diff)
downloadrelease-cec481c34a49016db97055b408c3c72a62d17766.tar
release-cec481c34a49016db97055b408c3c72a62d17766.tar.gz
release-cec481c34a49016db97055b408c3c72a62d17766.tar.bz2
release-cec481c34a49016db97055b408c3c72a62d17766.tar.xz
release-cec481c34a49016db97055b408c3c72a62d17766.zip
Add script to rebuild a list of packages
-rwxr-xr-xrebuild-packages68
1 files changed, 68 insertions, 0 deletions
diff --git a/rebuild-packages b/rebuild-packages
new file mode 100755
index 0000000..1aa8862
--- /dev/null
+++ b/rebuild-packages
@@ -0,0 +1,68 @@
+#!/usr/bin/perl -w
+
+use strict;
+use File::Temp qw/tempfile/;
+use RPM4;
+use Youri::Package::RPM::Updater;
+use LWP::UserAgent;
+use MDK::Common;
+use Cwd;
+
+my $status_page = 'http://pkgsubmit.mageia.org/';
+my $svn_root = 'svn+ssh://svn.mageia.org/svn/packages/cauldron/';
+my $commit_msg = 'Distro Rebuild';
+my $bs_max_todo_queue = 5;
+my $updater = Youri::Package::RPM::Updater->new();
+
+my ($ci_fh, $ci_fname) = tempfile(UNLINK => 1);
+print $ci_fh $commit_msg;
+close $ci_fh;
+
+sub list_from_file
+{
+ my @res = cat_($_[0]);
+ chomp @res;
+ return @res;
+}
+
+sub get_bs_queue_todo
+{
+ my $ua = LWP::UserAgent->new;
+ my $req = HTTP::Request->new(HEAD => $status_page);
+ my $res = $ua->request($req);
+ return ($res->is_success) ? $res->header('X-BS-Queue-Todo') : 9999;
+}
+
+sub bump_release
+{
+ my ($pkgname) = @_;
+ my $oldcwd = getcwd;
+ my $tmpdir = File::Temp->newdir();
+ chdir $tmpdir->dirname;
+ system('svn', 'co', "${svn_root}/${pkgname}/current");
+ chdir 'current';
+ $updater->update_from_spec(glob('SPECS/*.spec'));
+ system('svn', 'ci', '--file', $ci_fname);
+ chdir $oldcwd;
+}
+
+sub submit_package
+{
+ my ($pkgname) = @_;
+ while (get_bs_queue_todo() > $bs_max_todo_queue) {
+ sleep 20;
+ }
+ system('mgarepo', 'submit', $pkgname);
+}
+
+sub rebuild_package
+{
+ my ($pkgname) = @_;
+ bump_release $pkgname;
+ submit_package $pkgname;
+}
+
+my @packages_list = list_from_file($ARGV[0]);
+foreach (@packages_list) {
+ rebuild_package($_);
+}