Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13282
Modified Files:
PkgVersion.pm Engine.pm ChangeLog
Log Message:
Use get_source_count accessor method instead of _sourcecount instance var.
Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -d -r1.232 -r1.233
--- PkgVersion.pm 1 Mar 2004 09:46:39 -0000 1.232
+++ PkgVersion.pm 2 Mar 2004 19:46:35 -0000 1.233
@@ -239,17 +239,14 @@
$version =~ /(^[0-9]+\.[0-9]+)\.*/;
$source = "mirror:gnome:sources/\%n/$1/\%n-\%v.tar.gz";
}
-
$self->{source} = $source;
+
$self->expand_percent_if_available("Source");
- $self->{_sourcecount} = 1;
-
$self->expand_percent_if_available('SourceRename');
- for ($i = 2; $self->has_param('source'.$i); $i++) {
+ for ($i = 2; $i<=$self->get_source_count; $i++) {
$self->expand_percent_if_available('Source'.$i);
$self->expand_percent_if_available('Source'.$i.'Rename');
- $self->{_sourcecount} = $i;
}
# handle splitoff(s)
@@ -555,9 +552,35 @@
### other accessors
-sub is_multisource {
+# Returns the number of source tarballs for the package. Actually it
+# gives the highest *consecutive* N of SourceN, or 1 if no SourceN
+# (even if no Source either). FIXME: that's pretty weird.
+#
+# Results are cached in a package global (class variable) hash using
+# the object ref as the key. NB: perl hash keys get stringified so
+# cannot use the key as a ref.
+
+sub get_source_count {
my $self = shift;
- return $self->{_sourcecount} > 1;
+
+ our %source_count_cache;
+
+ if (exists $self->{_parent}) {
+ # SplitOff packages have no sources of their own
+ return 0;
+ }
+
+ if (!exists $source_count_cache{$self}) {
+ # not found is cache, so calculate it
+ my $count = 1;
+ while ($self->has_param('source'.($count+1))) {
+ $count++;
+ }
+ # cache the result
+ $source_count_cache{$self} = $count;
+ }
+
+ return $source_count_cache{$self};
}
sub get_source {
@@ -565,7 +588,7 @@
my $index = shift || 1;
if ($index < 2) {
return $self->param("Source") unless ($self->is_type('bundle') ||
$self->is_type('nosource'));
- } elsif ($index <= $self->{_sourcecount}) {
+ } elsif ($index <= $self->get_source_count) {
return $self->param("Source".$index);
}
return "none";
@@ -574,7 +597,7 @@
sub get_source_list {
my $self = shift;
my @list = ();
- for (my $index = 1; $index<=$self->{_sourcecount}; $index++) {
+ for (my $index = 1; $index<=$self->get_source_count; $index++) {
my $source = get_source($self, $index);
push(@list, $source) unless $source eq "none";
}
@@ -589,7 +612,7 @@
return $self->param("SourceRename");
}
return &filename($self->param("Source")) unless
($self->is_type('bundle') || $self->is_type('nosource'));
- } elsif ($index <= $self->{_sourcecount}) {
+ } elsif ($index <= $self->get_source_count) {
if ($self->has_param("Source".$index."Rename")) {
return $self->param("Source".$index."Rename");
}
@@ -601,7 +624,7 @@
sub get_tarball_list {
my $self = shift;
my @list = ();
- for (my $index = 1; $index<=$self->{_sourcecount}; $index++) {
+ for (my $index = 1; $index<=$self->get_source_count; $index++) {
my $tarball = get_tarball($self, $index);
push(@list, $tarball) unless $tarball eq "none";
}
@@ -615,7 +638,7 @@
if ($self->has_param("Source-MD5")) {
return $self->param("Source-MD5");
}
- } elsif ($index >= 2 and $index <= $self->{_sourcecount}) {
+ } elsif ($index >= 2 and $index <= $self->get_source_count) {
if ($self->has_param("Source".$index."-MD5")) {
return $self->param("Source".$index."-MD5");
}
@@ -837,7 +860,7 @@
return 1;
}
- for ($i = 1; $i <= $self->{_sourcecount}; $i++) {
+ for ($i = 1; $i <= $self->get_source_count; $i++) {
if (not defined $self->find_tarball($i)) {
return 0;
}
@@ -1207,7 +1230,7 @@
return;
}
- for ($i = 1; $i <= $self->{_sourcecount}; $i++) {
+ for ($i = 1; $i <= $self->get_source_count; $i++) {
if (not $conditional or not defined $self->find_tarball($i)) {
$self->fetch_source($i,0,0,0,$dryrun);
}
@@ -1354,7 +1377,7 @@
}
$tries = 0;
- for ($i = 1; $i <= $self->{_sourcecount}; $i++) {
+ for ($i = 1; $i <= $self->get_source_count; $i++) {
$archive = $self->get_tarball($i);
# search for archive, try fetching if not found
Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- Engine.pm 27 Feb 2004 10:04:48 -0000 1.160
+++ Engine.pm 2 Mar 2004 19:46:35 -0000 1.161
@@ -824,11 +824,11 @@
$package = Fink::Package->package_by_name($pname);
foreach $vo ($package->get_all_versions()) {
# Skip packages that do not have source files
- next if not defined $vo->{_sourcecount};
+ next unless $vo->get_source_count;
# For each tar ball, if a checksum was specified, locate it and
# verify the checksum.
- for ($i = 1; $i <= $vo->{_sourcecount}; $i++) {
+ for ($i = 1; $i <= $vo->get_source_count; $i++) {
$chk = $vo->get_checksum($i);
if ($chk ne "-") {
$file = $vo->find_tarball($i);
@@ -895,8 +895,8 @@
$deb_list{$file} = 1;
# all source files
- if (defined $vo->{_sourcecount}) {
- for ($i = 1; $i <= $vo->{_sourcecount}; $i++) {
+ if ($vo->get_source_count}) {
+ for ($i = 1; $i <= $vo->get_source_count; $i++) {
$file = $vo->find_tarball($i);
$src_list{$file} = 1 if defined($file);
}
Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.560
retrieving revision 1.561
diff -u -d -r1.560 -r1.561
--- ChangeLog 2 Mar 2004 01:26:11 -0000 1.560
+++ ChangeLog 2 Mar 2004 19:46:35 -0000 1.561
@@ -1,3 +1,10 @@
+2004-03-02 Daniel Macks <[EMAIL PROTECTED]>
+
+ * PkgVersion.pm: Implement get_source_count() accessor. Remove
+ is_multisource() accessor (leftover from long-gone SourceItems).
+ * Engine.pm, PkgVersion.pm: abolish _sourcecount instance
+ variable; useg get_source_count() instead.
+
2004-03-01 Daniel Macks <[EMAIL PROTECTED]>
* Validation.pm: Took out parsing of Type into %type_*[] b/c don't
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits