Changeset 1523 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder


Ignore:
Timestamp:
May 12, 2012, 2:22:11 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • pb.conf: Add scilinux to list of OS's. Add case where centos versioning include minor since centos makes major changes in minor releases. Fix typo in oracle linux regex. Proposes min dependencies separately for centos-5.2, 5.6 others just match that set. Add next ubuntu codename. (Eric Anderson)
  • Distribution.pm: Add new pb_pbos_to_keylist function that generates the keys that should be used for looking up filter filenames or keys into the hash-maps. New function will generate 5.m, for all m in [0,n] for version 5.n of some OS. Useful because minor versions are usually similar. Use it in distro_get_param, simplifying the function and making it more powerful. Fix comment to be correct, you can check for scalar/list context if you want, but that's not what this code does.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r1521 r1523  
    132132$pbos->{'family'} = pb_distro_get_param($pbos,pb_conf_get("osfamily"));
    133133$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"));
    135135#($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"));
    136136
     
    594594}
    595595
     596=item B<pb_pbos_to_keylist>
     597
     598Given a pbos object and the generic key, get the list of possible keys for looking up variable for
     599filter names.  The list will be sorted most-specific to least specific.
     600
     601=cut
     602
     603sub pb_pbos_to_keylist ($$) {
     604
     605my ($pbos, $generic) = @_;
     606
     607foreach my $key (qw/name version arch family type os/) {
     608    confess "missing pbos key $key" unless defined $pbos->{$key};
     609}
     610
     611my @keylist = ("$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}", "$pbos->{'name'}-$pbos->{'version'}");
     612
     613# Loop to include also previous minor versions
     614# if configured so
     615if (($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
     624push (@keylist, $pbos->{name}, $pbos->{family}, $pbos->{type}, $pbos->{os}, $generic);
     625return @keylist;
     626}
     627
    596628=item B<pb_distro_get_param>
    597629
     
    603635
    604636my @param;
    605 my $param;
    606637my $pbos = shift;
    607638
     639my @keylist = pb_pbos_to_keylist($pbos,"default");
    608640pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} for ".Dumper(@_)."\n");
    609641foreach 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    }
    628649    # Allow replacement of variables inside the parameter such as name, version, arch for rpmbootstrap
    629650    # but not shell variable which are backslashed
     
    637658pb_log(2,"DEBUG: pb_distro_get_param on $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} returns ==".Dumper(@param)."==\n");
    638659
    639 # Return one param in scalar context, an array if not.
     660# Return one param if user only asked for one lookup, an array if not.
    640661my $nb = @param;
    641662if ($nb eq 1) {
    642     return($param);
     663    return($param[0]);
    643664} else {
    644665    return(@param);
Note: See TracChangeset for help on using the changeset viewer.