aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MgaRelease/Common.pm99
-rw-r--r--config12
-rwxr-xr-xdiff-release-current10
-rwxr-xr-xprepare-new-release-branch12
4 files changed, 133 insertions, 0 deletions
diff --git a/MgaRelease/Common.pm b/MgaRelease/Common.pm
new file mode 100644
index 0000000..bd84df8
--- /dev/null
+++ b/MgaRelease/Common.pm
@@ -0,0 +1,99 @@
+package MgaRelease::Common;
+
+use FindBin;
+use YAML qw/LoadFile DumpFile/;
+use URPM;
+use SVN::Core;
+use SVN::Ra;
+
+my $c;
+my $srpms_list;
+
+sub config {
+ $c ? $c : $c = LoadFile($FindBin::Bin. '/config');
+}
+
+sub config_path {
+ my $file = config()->{$_[0]};
+ $file =~ m|^/| ? $file : config()->{datadir} . '/' . $file;
+}
+
+sub make_srpms_list_from_synthesis {
+ my $urpm = URPM->new;
+ $srpms_list = {};
+ foreach my $srpms_synthesis (@{config()->{srpms_synthesis}}) {
+ $urpm->parse_synthesis($srpms_synthesis)
+ or die "Error reading $srpms_synthesis\n";
+ }
+ $urpm->traverse(sub {
+ $srpms_list->{$_[0]->name}->{version} = $_[0]->version;
+ $srpms_list->{$_[0]->name}->{release} = $_[0]->release;
+ });
+}
+
+sub save_srpms_list {
+ DumpFile(config_path('srpms_list_file'), $srpms_list);
+}
+
+sub load_srpms_list {
+ $srpms_list = LoadFile(config_path('srpms_list_file'), $srpms_list);
+}
+
+sub path_rev
+{
+ my ($ra, $path) = @_;
+ if ($ra->check_path($path, $SVN::Core::INVALID_REVNUM)
+ == $SVN::Node::none) {
+ return undef;
+ } else {
+ return ($ra->get_dir($path,
+ $SVN::Core::INVALID_REVNUM))[2]{'svn:entry:committed-rev'};
+ }
+}
+
+sub get_srpms_rev {
+ my $ra = SVN::Ra->new(config()->{svn_repourl});
+ foreach my $pkg (keys %$srpms_list) {
+ my ($ver, $rel) = @{$srpms_list->{$pkg}}{qw/version release/};
+ $svnrev = path_rev($ra, "cauldron/$pkg/releases/$ver/$rel");
+ $srpms_list->{$pkg}->{svnrev} = $svnrev if $svnrev;
+ }
+}
+
+sub get_svn_branch_cmds {
+ my $ci_msg = config()->{svn_branch_commit_msg};
+ my $repo_url = config()->{svn_repourl};
+ my $branch_path = config()->{svn_branch_path};
+ open(my $branch, '>', config_path('branch_cmds_file'))
+ or die "Error opening " . config_path('branch_cmds_file') . "\n";
+ open(my $nobranch, '>', config_path('nobranch_file'))
+ or die "Error opening " . config_path('nobranch_file') . "\n";
+ print $branch "#!/bin/sh\n";
+ foreach my $pkg (keys %$srpms_list) {
+ if ($srpms_list->{$pkg}->{svnrev}) {
+ print $branch "svn cp -m '$ci_msg' $repo_url/cauldron/$pkg\@$srpms_list->{$pkg}->{svnrev} $repo_url/$branch_path/$pkg\n";
+ } else {
+ print $nobranch "$pkg\n";
+ }
+ }
+}
+
+sub get_current_diff {
+ my $ra = SVN::Ra->new(config()->{svn_repourl});
+ my $ctx = SVN::Client->new();
+ my $diffdir = config_path('diffdir');
+ my $repo_url = config()->{svn_repourl};
+ foreach my $pkg (keys %$srpms_list) {
+ next unless $srpms_list->{$pkg}->{svnrev}
+ && $srpms_list->{$pkg}->{svnrev} != path_rev($ra, "cauldron/$pkg");
+
+ my $difffile = config_path('diffdir') . '/' . $pkg;
+ open(my $diffout, '>', $difffile) or die "Error opening file $difffile\n";
+ $ctx->diff([], "$repo_url/cauldron/$pkg/current", $srpms_list->{$pkg}->{svnrev},
+ "$repo_url/cauldron/$pkg/current", 'HEAD', 1, 0, 0,
+ $diffout, $diffout);
+ close $diffout;
+ }
+}
+
+1;
diff --git a/config b/config
new file mode 100644
index 0000000..8d567bd
--- /dev/null
+++ b/config
@@ -0,0 +1,12 @@
+datadir: data/mga3
+srpms_list_file: srpms_list
+srpms_synthesis:
+ - /distrib/bootstrap/distrib/3/SRPMS/core/release/media_info/synthesis.hdlist.cz
+ - /distrib/bootstrap/distrib/3/SRPMS/nonfree/release/media_info/synthesis.hdlist.cz
+ - /distrib/bootstrap/distrib/3/SRPMS/tainted/release/media_info/synthesis.hdlist.cz
+svn_repourl: file:///svn/packages
+svn_branch_path: updates/3
+svn_branch_commit_msg: SILENT Branching for Mageia 3
+branch_cmds_file: branch_cmds
+nobranch_file: not_branched
+diffdir: diff
diff --git a/diff-release-current b/diff-release-current
new file mode 100755
index 0000000..c0d7cf2
--- /dev/null
+++ b/diff-release-current
@@ -0,0 +1,10 @@
+#!/usr/bin/perl -w
+
+use strict;
+use FindBin;
+use lib $FindBin::Bin;
+use MgaRelease::Common;
+
+MgaRelease::Common::load_srpms_list;
+MgaRelease::Common::get_current_diff;
+
diff --git a/prepare-new-release-branch b/prepare-new-release-branch
new file mode 100755
index 0000000..4cbdda1
--- /dev/null
+++ b/prepare-new-release-branch
@@ -0,0 +1,12 @@
+#!/usr/bin/perl -w
+
+use strict;
+use FindBin;
+use lib $FindBin::Bin;
+use MgaRelease::Common;
+
+MgaRelease::Common::make_srpms_list_from_synthesis;
+MgaRelease::Common::get_srpms_rev;
+MgaRelease::Common::save_srpms_list;
+MgaRelease::Common::get_svn_branch_cmds;
+