Changeset 1192 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Feb 16, 2011, 12:17:55 PM (13 years ago)
Author:
Bruno Cornec
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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.