Changeset 1192


Ignore:
Timestamp:
02/16/11 12:17:55 (2 years ago)
Author:
bruno
Message:
  • Fix pb_get_filters to also support filter based on os name and os-ver-arch as well to be coherent, and also fix bugs in the tests made for filter exitence.
  • Fix pb_changelog with test for correct pb hash values which were changed previously
  • Revert back using no arch subdir for deb based repo
  • Introduce new parameter oscmdpath to support external commands full path name easier (could also be very useful for MondoRescue?)
  • Another set of fixes for sudo comands support: no parameter taken in account, replace localhost by ALL to avoid nightmares with VMs naming
Location:
devel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf

    r1191 r1192  
    463463# 
    464464 
     465# Some path for commands may defer from one system to another 
     466ospathcmd-halt default = /sbin/halt 
     467ospathcmd-halt solaris = /usr/sbin/halt 
     468 
    465469# How do you want to install pb in your VM/VE (pkg or file) 
    466470pbinstalltype default = pkg 
  • devel/pb-modules/etc/pb.conf.pod

    r1176 r1192  
    142142 Conffile: pb 
    143143 Example: osnover gentoo = true 
     144 
     145=item B<ospathcmd-*> 
     146 
     147 Nature: Optional 
     148 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). 
     149 Value: Full path name of the command mentioned after the '-' for the relative OS 
     150 Conffile: pb 
     151 Example: ospathcmd-halt solaris = /usr/sbin/halt, ospathcmd-halt default = /sbin/halt 
    144152 
    145153=item B<osperldep> 
  • devel/pb/bin/pb

    r1190 r1192  
    872872        $pb->{'ver'} = $pbver; 
    873873        $pb->{'pkg'} = $pbpkg; 
     874        $pb->{'suf'} = $pbos->{'suffix'}; 
    874875        $pb->{'realpkg'} = $pbpkg; 
    875         $pb->{'suf'} = $pbos->{'suffix'}; 
    876876        $pb->{'date'} = $pbdate; 
    877877        $pb->{'defpkgdir'} = $defpkgdir; 
     
    923923 
    924924                # Get all filters to apply 
    925                 my $ptr = pb_get_filters($pbpkg,$pbos); 
     925                $ptr = pb_get_filters($pbpkg,$pbos); 
    926926     
    927927                pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n"); 
     
    16501650        $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}"; 
    16511651    } elsif ($cmt eq "Packages") { 
    1652         $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"; 
     1652        if (($pbos->{'type'} eq "rpm") || ($pbos->{'type'} eq "pkg") || ($pbos->{'type'} eq "hpux") || ($pbos->{'type'} eq "tgz")) { 
     1653            # put packages under an arch subdir 
     1654            $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"; 
     1655        } elsif (($pbos->{'type'} eq "deb") || ($pbos->{'type'} eq "ebuild")) { 
     1656            # No need for an arch subdir 
     1657            $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}"; 
     1658        } else { 
     1659            die "Please teach the dev team where to deliver ($pbos->{'type'} type of packages\n"; 
     1660        } 
    16531661 
    16541662        my $repodir = $tdir; 
     
    17771785 
    17781786# Up two levels to deal with the dist dir cross versions 
    1779 cd ../.. 
     1787cd .. 
    17801788mkdir -p dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'} dists/$pbos->{'version'}/contrib/source 
    17811789 
    17821790# Prepare a script to create apt info file 
     1791# Reuse twice after 
    17831792TMPD=`mktemp -d /tmp/pb.XXXXXXXXXX` || exit 1 
    17841793mkdir -p \$TMPD 
     
    17911800 
    17921801echo "Creating Packages metadata ($pbos->{'arch'})" 
    1793 dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.gz 
    1794 dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | bzip2 -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.bz2 
    1795 echo "Creating Contents metadata ($pbos->{'arch'})" 
    1796 apt-ftparchive contents $pbos->{'version'} | gzip -c9 > dists/$pbos->{'version'}/Contents-$pbos->{'arch'}.gz 
     1802dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.gz 
     1803dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'} /dev/null | bzip2 -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.bz2 
     1804echo "Creating Contents metadata" 
     1805apt-ftparchive contents $pbos->{'version'} | gzip -c9 > dists/$pbos->{'version'}/Contents.gz 
    17971806echo "Creating Release metadata ($pbos->{'arch'})" 
    17981807cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release 
    17991808echo "Architecture: $pbos->{'arch'}" >> dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release 
    18001809echo "Creating Source metadata" 
    1801 dpkg-scansources $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/source/Sources.gz 
     1810dpkg-scansources $pbos->{'version'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/source/Sources.gz 
    18021811cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/source/Release 
    18031812echo "Architecture: Source" >> dists/$pbos->{'version'}/contrib/source/Release 
     
    19841993        } 
    19851994        my $hoption = "-p"; 
    1986         my $hpath = "/sbin"; 
    1987         # Solaris doesn't support -h and has halt elsewhere 
     1995        my $hpath = pb_distro_get_param($pbos,pb_conf_get("oscmdpath-halt")); 
     1996        # Solaris doesn't support -p and has halt elsewhere 
    19881997        if ($pbos->{'type'} eq "pkg") { 
    19891998            $hoption = "" ; 
    1990             $hpath = "/usr/sbin"; 
    19911999        } 
    19922000        pb_system("$shcmd \"sudo $hpath/halt $hoption \"; sleep $tm ; echo \'if [ -d /proc/$vmpid ]; then kill -9 $vmpid; fi \' | bash ; sleep 10","VM $v halt (pid $vmpid)"); 
     
    29572965    # Try to restrict security to what is really needed 
    29582966    if ($vtype =~ /^vm/) { 
    2959         my $hpath = "/sbin"; 
    2960         # TODO: make that an external variable ! 
    2961         # Solaris has halt elsewhere 
    2962         if ($pbos->{'type'} eq "pkg") { 
    2963             $hpath = "/usr/sbin"; 
    2964         } 
     2967        my $hpath = pb_distro_get_param($pbos,pb_conf_get("oscmdpath-halt")); 
    29652968        my @sudocmds = pb_get_sudocmds($pbos,$ntpline,"$hpath/halt"); 
    29662969        print SCRIPT << "EOF"; 
     
    29702973EOF 
    29712974        foreach my $c (@sudocmds) { 
    2972             print SCRIPT "print PBOUT \"$pbac->{$ENV{'PBPROJ'}}   localhost = NOPASSWD: $c\n\";"; 
     2975            print SCRIPT "print PBOUT \"$pbac->{$ENV{'PBPROJ'}}   ALL = NOPASSWD: $c\n\";"; 
    29732976        } 
    29742977    } elsif ($vtype =~ /^rm/) { 
     
    29782981EOF 
    29792982        foreach my $c (@sudocmds) { 
    2980             print SCRIPT "print PBOUT \"$pbac->{$ENV{'PBPROJ'}}   localhost = NOPASSWD: $c\n\";"; 
     2983            print SCRIPT "print PBOUT \"$pbac->{$ENV{'PBPROJ'}}   ALL = NOPASSWD: $c\n\";"; 
    29812984        } 
    29822985    } else { 
     
    37683771foreach my $c (split(/;/,$pbos->{'update'}),split(/;/,$pbos->{'install'}),@lines) { 
    37693772    next if ($c !~ /^sudo/); 
     3773    # remove sudo 
    37703774    $c =~ s/^sudo\s+//; 
     3775    # remove leading spaces 
    37713776    $c =~ s/^\s+//; 
     3777    # remove ending spaces 
    37723778    $c =~ s/\s+$//; 
     3779    # keep only the command, not the params 
     3780    $c =~ s/([^\s]+)\s.*$/$1/; 
    37733781    $sudocmds{$c} = ""; 
    37743782} 
  • devel/pb/lib/ProjectBuilder/Changelog.pm

    r1156 r1192  
    6161 
    6262my $pb = shift; 
    63 my $dtype = $pb->{'dtype'}; 
     63 
     64my $dtype = $pb->{'pbos'}->{'type'}; 
    6465my $pbrealpkg = $pb->{'realpkg'}; 
    6566my $pbver = $pb->{'ver'}; 
    6667my $pbtag = $pb->{'tag'}; 
    67 my $pbsuf = $pb->{'suf'}; 
     68my $pbsuf = $pb->{'pbos'}->{'suffix'}; 
    6869my $OUTPUT = shift; 
    6970my $doit = shift; 
     
    7273my $log = ""; 
    7374 
     75pb_log(2,"Entering pb_changelog - pb: ".Dumper($pb)."\n"); 
     76pb_log(2,"Entering pb_changelog - doit: $doit\n") if (defined $doit); 
     77pb_log(2,"Entering pb_changelog - OUTPUT: $OUTPUT\n") if (defined $OUTPUT); 
    7478# For date handling 
    7579$ENV{LANG}="C"; 
     
    8286        (not (defined $OUTPUT)) || ($OUTPUT eq "") || 
    8387        (not (defined $doit)) || ($doit eq "")) { 
    84     print $OUTPUT "\n"; 
    85     return; 
    86 } 
    87  
    88 if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) { 
    89     #pb_log(2,"No ChangeLog file ($chglog) for $pbrealpkg\n"; 
     88    pb_log(2,"Not enough input params\n"); 
    9089    print $OUTPUT "\n"; 
    9190    return; 
     
    106105# If we don't need to do it, or don't have it fake something 
    107106if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) { 
     107    pb_log(2,"No ChangeLog file for $pbrealpkg - faking one\n"); 
    108108    $date = strftime("%Y-%m-%d", @date); 
    109109    $ndate = &UnixDate($date,"%a", "%b", "%d", "%Y"); 
    110110    $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z"); 
    111     if (($dtype eq "rpm") || ($dtype eq "fc")) { 
     111    if ($dtype eq "rpm") { 
    112112        $ver2 = "$pbver-$pbtag"; 
    113113        print $OUTPUT "* $ndate $pbpackager->{$ENV{'PBPROJ'}} $ver2\n"; 
    114114        print $OUTPUT "- Updated to $pbver\n"; 
    115         } 
    116     if ($dtype eq "deb") { 
     115    } elsif ($dtype eq "deb") { 
    117116        if ($pbver !~ /^[0-9]/) { 
    118117            # dpkg-deb doesn't accept non digit versions.  
     
    123122        print $OUTPUT "  * Updated to $pbver\n"; 
    124123        print $OUTPUT " -- $pbpackager->{$ENV{'PBPROJ'}}  $n2date\n\n\n"; 
    125         } 
     124    } else { 
     125        pb_log(0,"No ChangeLog file for $pbrealpkg and no way faking one for type $dtype\n"); 
     126    } 
    126127    return; 
    127128} 
     
    208209} 
    209210close(INPUT); 
     211pb_log(2,"Exiting pb_changelog\n"); 
    210212} 
    211213 
  • devel/pb/lib/ProjectBuilder/Filter.pm

    r1186 r1192  
    6262 
    6363my @ffiles; 
    64 my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3); 
    65 my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3); 
     64my ($ffile00, $ffile0, $ffile1, $ffile2, $ffile3, $ffile4, $ffile5); 
     65my ($mfile00, $mfile0, $mfile1, $mfile2, $mfile3, $mfile4, $mfile5); 
    6666my $pbpkg = shift || die "No package specified"; 
    6767my $pbos = shift; 
     
    6969my %h; 
    7070 
     71pb_log(2,"Entering pb_get_filters - pbpkg: $pbpkg - pbos: ".Dumper($pbos)."\n"); 
    7172# Global filter files first, then package specificities 
    7273if (-d "$ENV{'PBROOTDIR'}/pbfilter") { 
    7374    $mfile00 = "$ENV{'PBROOTDIR'}/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/pbfilter/all.pbf"); 
    7475    if (defined $pbos) { 
    75         $mfile0 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf")); 
    76         $mfile1 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf")); 
    77         $mfile2 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf")); 
    78         $mfile3 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf")); 
     76        $mfile0 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'os'}.pbf" if ((defined $pbos->{'os'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'os'}.pbf")); 
     77        $mfile1 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'type'}.pbf")); 
     78        $mfile2 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'family'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'family'}.pbf")); 
     79        $mfile3 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'name'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}.pbf")); 
     80        $mfile4 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf")); 
     81        $mfile5 = "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (defined $pbos->{'arch'}) && (-f "$ENV{'PBROOTDIR'}/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf")); 
    7982    } 
    8083 
     
    8487    push @ffiles,$mfile2 if (defined $mfile2); 
    8588    push @ffiles,$mfile3 if (defined $mfile3); 
     89    push @ffiles,$mfile4 if (defined $mfile4); 
     90    push @ffiles,$mfile5 if (defined $mfile5); 
    8691} 
    8792 
     
    8994    $ffile00 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf" if (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/all.pbf"); 
    9095    if (defined $pbos) { 
    91         $ffile0 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf")); 
    92         $ffile1 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf")); 
    93         $ffile2 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf")); 
    94         $ffile3 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf")); 
     96        $ffile0 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'os'}.pbf" if ((defined $pbos->{'os'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'os'}.pbf")); 
     97        $ffile1 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf" if ((defined $pbos->{'type'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'type'}.pbf")); 
     98        $ffile2 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf" if ((defined $pbos->{'family'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'family'}.pbf")); 
     99        $ffile3 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf" if ((defined $pbos->{'name'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}.pbf")); 
     100        $ffile4 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}.pbf")); 
     101        $ffile5 = "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf" if ((defined $pbos->{'name'}) && (defined $pbos->{'version'}) && (defined $pbos->{'arch'}) && (-f "$ENV{'PBROOTDIR'}/$pbpkg/pbfilter/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.pbf")); 
    95102    } 
    96103    push @ffiles,$ffile00 if (defined $ffile00); 
     
    99106    push @ffiles,$ffile2 if (defined $ffile2); 
    100107    push @ffiles,$ffile3 if (defined $ffile3); 
     108    push @ffiles,$ffile4 if (defined $ffile4); 
     109    push @ffiles,$ffile5 if (defined $ffile5); 
    101110} 
    102111if (@ffiles) { 
     
    104113 
    105114    foreach my $f (@ffiles) { 
     115        pb_log(3,"DEBUG processing filter file $f\n"); 
    106116        open(CONF,$f) || next; 
    107117        while(<CONF>)  { 
    108118            if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) { 
     119                pb_log(3,"DEBUG creating entry $1, key $2, value $3\n"); 
    109120                $h{$1}{$2}=$3; 
    110121            } 
    111122        } 
    112123        close(CONF); 
    113  
    114         $ptr = $h{"filter"}; 
    115         pb_log(2,"DEBUG f:".Dumper($ptr)."\n"); 
    116     } 
    117 } 
     124    } 
     125    $ptr = $h{"filter"}; 
     126} 
     127pb_log(2,"DEBUG f:".Dumper($ptr)."\n") if (defined $ptr); 
    118128return($ptr); 
    119129} 
Note: See TracChangeset for help on using the changeset viewer.