line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Arch Perl library, Copyright (C) 2005 Enno Cramer |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
4
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
5
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
6
|
|
|
|
|
|
|
# (at your option) any later version. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
9
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11
|
|
|
|
|
|
|
# GNU General Public License for more details. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
14
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
15
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
25
|
use 5.005; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
38
|
|
18
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package Arch::Test::Archive; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Arch::Backend qw(has_archive_setup_cmd); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1088
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new ($$$) { |
25
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
26
|
0
|
|
|
|
|
|
my ($fw, $name) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $self = { |
29
|
|
|
|
|
|
|
name => $name, |
30
|
|
|
|
|
|
|
framework => $fw, |
31
|
|
|
|
|
|
|
structure => { |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub name ($) { |
41
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $self->{name}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub framework ($) { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $self->{framework}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub run_tla ($@) { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$self->framework->run_tla(@_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# name generation |
59
|
|
|
|
|
|
|
sub gen_id ($;@) { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my @tree = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
die "gen_id is private" |
64
|
|
|
|
|
|
|
if caller ne __PACKAGE__; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $ref = $self->{structure}; |
67
|
0
|
|
|
|
|
|
foreach my $key (@tree) { |
68
|
0
|
0
|
|
|
|
|
$ref->{$key} = { '=count' => 0 } |
69
|
|
|
|
|
|
|
unless exists $ref->{$key}; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$ref = $ref->{$key}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $ref->{'=count'}++; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub split_arch_name ($$$) { |
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
79
|
0
|
|
0
|
|
|
|
my $name = shift || ''; |
80
|
0
|
|
0
|
|
|
|
my $maxlen = shift || 3; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if ($name =~ s,^(.+)/,,) { |
83
|
0
|
0
|
|
|
|
|
die "Prefix from different archive: $1\n" |
84
|
|
|
|
|
|
|
if $1 ne $self->name; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
my @parts = $name ? split /--/, $name : (); |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
die "Arch name $name too long\n" |
90
|
|
|
|
|
|
|
if @parts > $maxlen; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return @parts; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub join_arch_name ($@) { |
96
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return join '--', @_; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub make_category ($;$) { |
103
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
my @prefix = @_; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
unshift @prefix, $self->split_arch_name(shift @prefix, 1); |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
if (@prefix < 1) { |
109
|
0
|
|
|
|
|
|
push @prefix, "category-" . $self->gen_id(@prefix); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $name = $self->join_arch_name(@prefix); |
113
|
0
|
0
|
|
|
|
|
$self->run_tla('archive-setup', '-A', $self->name, $name) |
114
|
|
|
|
|
|
|
if has_archive_setup_cmd(); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return $self->name . "/$name"; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub make_branch ($;$$) { |
120
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
121
|
0
|
|
|
|
|
|
my @prefix = @_; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
unshift @prefix, $self->split_arch_name(shift @prefix, 2); |
124
|
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
if (@prefix < 2) { |
126
|
0
|
0
|
|
|
|
|
@prefix = $self->split_arch_name($self->make_category(@prefix), 1) |
127
|
|
|
|
|
|
|
if @prefix < 1; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
push @prefix, 'branch-' . $self->gen_id(@prefix); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $name = $self->join_arch_name(@prefix); |
133
|
0
|
0
|
|
|
|
|
$self->run_tla('archive-setup', '-A', $self->name, $name) |
134
|
|
|
|
|
|
|
if has_archive_setup_cmd(); |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
return $self->name . "/$name"; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub make_version ($;$$$) { |
140
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
my @prefix = @_; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
unshift @prefix, $self->split_arch_name(shift @prefix, 3); |
144
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
if (@prefix < 3) { |
146
|
0
|
0
|
|
|
|
|
@prefix = $self->split_arch_name($self->make_branch(@prefix), 2) |
147
|
|
|
|
|
|
|
if @prefix < 2; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
push @prefix, $self->gen_id(@prefix); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
my $name = $self->join_arch_name(@prefix); |
153
|
0
|
0
|
|
|
|
|
$self->run_tla('archive-setup', '-A', $self->name, $name) |
154
|
|
|
|
|
|
|
if has_archive_setup_cmd(); |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
return $self->name . "/$name"; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
__END__ |