Changeset 1523 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder
- Timestamp:
- May 12, 2012, 2:22:11 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r1521 r1523 132 132 $pbos->{'family'} = pb_distro_get_param($pbos,pb_conf_get("osfamily")); 133 133 $pbos->{'type'} = pb_distro_get_param($pbos,pb_conf_get("ostype")); 134 ($pbos->{'os'},$pbos->{'install'},$pbos->{'suffix'},$pbos->{'nover'},$pbos->{'rmdot'},$pbos->{'update'} ) = pb_distro_get_param($pbos,pb_conf_get("os","osins","ossuffix","osnover","osremovedotinver","osupd"));134 ($pbos->{'os'},$pbos->{'install'},$pbos->{'suffix'},$pbos->{'nover'},$pbos->{'rmdot'},$pbos->{'update'},$pbos->{'useminor'}) = pb_distro_get_param($pbos,pb_conf_get("os","osins","ossuffix","osnover","osremovedotinver","osupd","osuseminorrel")); 135 135 #($pbos->{'family'},$pbos->{'type'},$pbos->{'os'},$pbos->{'install'},$pbos->{'suffix'},$pbos->{'nover'},$pbos->{'rmdot'},$pbos->{'update'}) = pb_distro_get_param($pbos,pb_conf_get("osfamily","ostype","os","osins","ossuffix","osnover","osremovedotinver","osupd")); 136 136 … … 594 594 } 595 595 596 =item B<pb_pbos_to_keylist> 597 598 Given a pbos object and the generic key, get the list of possible keys for looking up variable for 599 filter names. The list will be sorted most-specific to least specific. 600 601 =cut 602 603 sub pb_pbos_to_keylist ($$) { 604 605 my ($pbos, $generic) = @_; 606 607 foreach my $key (qw/name version arch family type os/) { 608 confess "missing pbos key $key" unless defined $pbos->{$key}; 609 } 610 611 my @keylist = ("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}", "$pbos->{'name'}-$pbos->{'version'}"); 612 613 # Loop to include also previous minor versions 614 # if configured so 615 if (($pbos{'useminor'} eq "true") && ($pbos->{version} =~ /^(\d+)\.(\d+)$/o)) { 616 my ($major, $minor) = ($1, $2); 617 while ($minor > 0) { 618 $minor--; 619 push (@keylist, "$pbos->{name}-${major}.$minor"); 620 } 621 push (@keylist, "$pbos->{name}-$major"); 622 } 623 624 push (@keylist, $pbos->{name}, $pbos->{family}, $pbos->{type}, $pbos->{os}, $generic); 625 return @keylist; 626 } 627 596 628 =item B<pb_distro_get_param> 597 629 … … 603 635 604 636 my @param; 605 my $param;606 637 my $pbos = shift; 607 638 639 my @keylist = pb_pbos_to_keylist($pbos,"default"); 608 640 pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} for ".Dumper(@_)."\n"); 609 641 foreach my $opt (@_) { 610 if (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) { 611 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}; 612 } elsif (defined $opt->{"$pbos->{'name'}-$pbos->{'version'}"}) { 613 $param = $opt->{"$pbos->{'name'}-$pbos->{'version'}"}; 614 } elsif (defined $opt->{"$pbos->{'name'}"}) { 615 $param = $opt->{"$pbos->{'name'}"}; 616 } elsif (defined $opt->{$pbos->{'family'}}) { 617 $param = $opt->{$pbos->{'family'}}; 618 } elsif (defined $opt->{$pbos->{'type'}}) { 619 $param = $opt->{$pbos->{'type'}}; 620 } elsif (defined $opt->{$pbos->{'os'}}) { 621 $param = $opt->{$pbos->{'os'}}; 622 } elsif (defined $opt->{"default"}) { 623 $param = $opt->{"default"}; 624 } else { 625 $param = ""; 626 } 627 642 my $param = ""; 643 foreach my $key (@keylist) { 644 if (defined $opt->{$key}) { 645 $param = $opt->{$key}; 646 last; 647 } 648 } 628 649 # Allow replacement of variables inside the parameter such as name, version, arch for rpmbootstrap 629 650 # but not shell variable which are backslashed … … 637 658 pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} returns ==".Dumper(@param)."==\n"); 638 659 639 # Return one param i n scalar context, an array if not.660 # Return one param if user only asked for one lookup, an array if not. 640 661 my $nb = @param; 641 662 if ($nb eq 1) { 642 return($param );663 return($param[0]); 643 664 } else { 644 665 return(@param);
Note:
See TracChangeset
for help on using the changeset viewer.