aboutsummaryrefslogtreecommitdiffstats
path: root/packages-svn
blob: ce40bd92c845f6f7bfbc51ab26a9da1de9a82c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/perl -w

use strict;

use SVN::Core;
use SVN::Ra;
use MDK::Common;
use Data::Dumper;

# autoflush output
$| = 1;

my $repo_url = 'svn://svn.mageia.org/svn/packages';

sub path_rev
{
    my ($ra, $path) = @_;
    if ($ra->check_path($path, $SVN::Core::INVALID_REVNUM)
	== $SVN::Node::none) {
	return 0;
    } else {
	return ($ra->get_dir($path,
	    $SVN::Core::INVALID_REVNUM))[2]{'svn:entry:committed-rev'};
    }
}

sub package_revs
{
    my ($ra, $pkgname) = @_;

    (
	path_rev($ra, "cauldron/$pkgname/current"),
	path_rev($ra, "cauldron/$pkgname/pristine"),
    )
}

sub package_diff
{
    my $pkgname = shift;
    my $ctx = SVN::Client->new();
    print '-' x 67, "\n";
    print "- $pkgname -", '-' x (63 - length $pkgname), "\n";
    print '-' x 67, "\n\n";
    print "svn diff $pkgname/pristine $pkgname/current\n";
    $ctx->diff([], "$repo_url/cauldron/$pkgname/pristine", 'HEAD', 
	"$repo_url/cauldron/$pkgname/current", 'HEAD', 1, 0, 0,
	\*STDOUT, \*STDOUT);
}

sub modified_packages
{
    my ($pkg_list) = @_;
    my $ra = SVN::Ra->new($repo_url);
    my %modpkg;

    for my $pkg (@$pkg_list) {
	my @revs = package_revs($ra, $pkg);
	if ($revs[0] > $revs[1]) {
	    $modpkg{$pkg} = \@revs;
	}
    }
    \%modpkg;
}

sub list_cauldron_packages
{
    my $ctx = SVN::Client->new();
    my @l = keys $ctx->ls("$repo_url/cauldron", 'HEAD', 0);
    \@l;
}

sub list_from_file
{
    my @res = cat_($_[0]);
    chomp @res;
    return @res;
}

sub print_branch_packages
{
    my ($distrorelease, $pkglist) = @_;
    my $ra = SVN::Ra->new($repo_url);
    for my $pkgname (@$pkglist) {
	my $rev = path_rev($ra, "cauldron/$pkgname/pristine");
	print "cp $repo_url/cauldron/$pkgname\@$rev ",
		"$repo_url/updates/$distrorelease/$pkgname \\\n",

    }
}

sub print_modified_packages
{
    my ($pkglist) = @_;

    my $modpkg = modified_packages(@$pkglist);

    print join "\n", sort keys %$modpkg;
    print "\n\n";
    for my $pkg (sort keys %$modpkg) {
	if ($modpkg->{$pkg}[0] && $modpkg->{$pkg}[1]) {
	    package_diff($pkg);
	    print "\n\n\n";
	}
    }
}

my $packages_list_file = $ARGV[0];
my @packages_list = list_from_file($packages_list_file);
print_branch_packages('2', \@packages_list);
#print_modified_packages(\@packages_list);