-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathosc_uploader.pl
91 lines (68 loc) · 2.09 KB
/
osc_uploader.pl
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
use common::sense;
use Cwd;
use File::Find::Rule;
use File::Slurper qw(write_text);
use Getopt::Long;
=head1 NAME
osc package uploader script.
=head1 DESCRIPTION
Commits packages downloaded with meta2rpm
semi automatically into your osc project.
=head2 Usage
1. Use meta2rpm to download all the desired modules.
2. Copy the modules into your local osc project folder.
3. Change directory into your local osc project folder.
4. Run this script.
=cut
__PACKAGE__->main( @ARGV ) unless caller();
sub parse_options {
my ($project, $usage);
GetOptions(
"project=s" => \$project,
"usage|help" => \$usage,
);
if ($usage) {
say "Run this script from within your local osc project folder.\n"
. "with parameter --project=PROJECT_NAME";
exit;
}
die 'No project was specified. Please use the --usage flag.'
if !$project;
return $project;
}
sub main {
my $project = parse_options;
my @directories = File::Find::Rule
->directory
->maxdepth(1)
->name('perl6*')
->in('.');
system "osc up";
for my $name (@directories) {
next if -d "$name/.osc";
my $title = $name;
$title =~ s/perl6-//;
$title =~ s/-/::/;
my $spec = (glob "$name/*.spec")[0];
open my $specfh, '<', $spec;
my $summary;
while (<$specfh>) {
last if ($summary) = /^Summary:\s+(.+)$/xm;
}
close $specfh;
my $meta_file = "<package name='$name'>\n"
. " <title>$title</title>\n"
. " <description>$summary</description>\n"
. "</package>";
write_text("$name/meta", $meta_file);
system "osc meta pkg -e $project $name -F $name/meta";
unlink "$name/meta";
system "osc co $project $name -M -c";
system "osc remove $name/_meta";
unlink "$name/_meta";
system 'osc add ' . join ' ', grep { not -d $_ } glob "$name/*";
chdir $name;
system "osc commit -m 'Adding $name'";
chdir "../"
}
}