Changeset 1177 for devel/pb/bin/pb


Ignore:
Timestamp:
02/07/11 14:24:17 (2 years ago)
Author:
bruno
Message:

r4161@eelzbach2: bruno | 2011-02-06 21:07:30 +0100

  • Introduction of a new hash $pbos to manage all os related info through a single data structure. All functions reviewed accordingly. Externally transparent, hopefully, but much cleaner code as a consequence. VM/VE/RM remains to be tested.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1176 r1177  
    842842        # We want to at least build for the underlying distro 
    843843        # except if a target was given, in which case we only build for it 
    844         my ($tdir,$tver,$tarch); 
    845         ($tdir,$tver,$tarch) = split(/-/,$pbtarget) if (defined ($pbtarget)); 
    846  
    847         my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init($tdir,$tver,$tarch); 
    848         my $tmpl = "$ddir-$dver-$arch,"; 
     844        my $pbos = pb_distro_get_context($pbtarget); 
     845        my $tmpl = "$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'},"; 
    849846 
    850847        # Get list of distributions for which we need to generate build files if no target 
     
    869866        $pb{'pkg'} = $pbpkg; 
    870867        $pb{'realpkg'} = $pbpkg; 
     868        $pb{'suf'} = $pbos->{'suffix'}; 
    871869        $pb{'date'} = $pbdate; 
    872870        $pb{'defpkgdir'} = $defpkgdir; 
     
    895893            $pm = new Parallel::ForkManager($pbparallel) if (defined $pbparallel); 
    896894 
    897             foreach my $d (keys %virt) { 
     895            foreach my $v (keys %virt) { 
    898896                $pm->start and next if (defined $pbparallel); 
    899                 my ($name,$ver,$arch) = split(/-/,$d); 
    900                 pb_log(0,"Bad format for $d") if ((not defined $name) || (not defined $ver) || (not defined $arch)) ; 
    901                 chomp($arch); 
    902                 my ($ddir, $dver, $dfam); 
    903                 ($ddir, $dver, $dfam, $pb{'dtype'}, $pb{'os'}, $pb{'suf'}, $pb{'upd'}, $pb{'arch'}) = pb_distro_init($name,$ver,$arch); 
    904                 pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $pb{'dtype'}, $pb{'suf'})."\n"); 
     897 
     898                # Distro context 
     899                my $pbos = pb_distro_get_context($v); 
    905900                pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n"); 
    906901     
    907902                # We need to compute the real name of the package 
    908                 my $pbrealpkg = pb_cms_get_real_pkg($pbpkg,$pb{'dtype'}); 
     903                my $pbrealpkg = pb_cms_get_real_pkg($pbpkg,$pbos->{'type'}); 
    909904                $pb{'realpkg'} = $pbrealpkg; 
    910                 pb_log(1,"Virtual package $pbpkg has a real package name of $pbrealpkg on $ddir-$dver\n") if ($pbrealpkg ne $pbpkg); 
     905                pb_log(1,"Virtual package $pbpkg has a real package name of $pbrealpkg on $pbos->{'name'}-$pbos->{'version'}\n") if ($pbrealpkg ne $pbpkg); 
    911906     
    912907                # Filter build files from the less precise up to the most with overloading 
     
    917912                my %bfiles = (); 
    918913                my %pkgfiles = (); 
    919                 $build{"$ddir-$dver-$arch"} = "yes"; 
     914                $build{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = "yes"; 
    920915     
    921                 if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pb{'dtype'}") { 
    922                     pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pb{'dtype'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
    923                 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$dfam") { 
    924                     pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
    925                 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir") { 
    926                     pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
    927                 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver") { 
    928                     pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
    929                 } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver-$arch") { 
    930                     pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$ddir-$dver-$arch",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
     916                if (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'type'}") { 
     917                    pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'type'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
     918                } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'family'}") { 
     919                    pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'family'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
     920                } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}") { 
     921                    pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
     922                } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}") { 
     923                    pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
     924                } elsif (-d "$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}") { 
     925                    pb_list_bfiles("$ENV{'PBROOTDIR'}/$pbpkg/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}",$pbpkg,\%bfiles,\%pkgfiles,$supfiles); 
    931926                } else { 
    932                     $build{"$ddir-$dver-$arch"} = "no"; 
     927                    $build{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} = "no"; 
    933928                    next; 
    934929                } 
     
    936931     
    937932                # Get all filters to apply 
    938                 my $ptr = pb_get_filters($pbpkg, $pb{'dtype'}, $dfam, $ddir, $dver); 
     933                my $ptr = pb_get_filters($pbpkg,$pbos); 
    939934     
    940935                # Apply now all the filters on all the files concerned 
     
    942937                if (defined $ptr) { 
    943938                    # For patch support 
    944                     $pb{'tuple'} = "$ddir-$dver-$arch"; 
     939                    $pb{'tuple'} = "$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 
    945940                    foreach my $f (values %bfiles,values %pkgfiles) { 
    946                         pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$ddir-$dver-$arch/".basename($f),\%pb); 
     941                        pb_filter_file("$ENV{'PBROOTDIR'}/$f",$ptr,"$dest/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/".basename($f),\%pb); 
    947942                    } 
    948943                } 
    949                 pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbpatch", \%patches, $pb{'dtype'}, $dfam, $ddir, $dver, $arch, "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch"); 
    950                 pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbsrc", \%sources, $pb{'dtype'}, $dfam, $ddir, $dver, $arch, "$ENV{'PBROOTDIR'}/$pbpkg/pbextsrc"); 
     944                pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbpatch", \%patches, $pbos, "$ENV{'PBROOTDIR'}/$pbpkg/pbextpatch"); 
     945                pb_list_sfiles("$ENV{'PBROOTDIR'}/$pbpkg/pbsrc", \%sources, $pbos, "$ENV{'PBROOTDIR'}/$pbpkg/pbextsrc"); 
    951946 
    952947                $pm->finish if (defined $pbparallel); 
     
    11021097sub pb_test2pkg { 
    11031098    # Get the running distro to test on 
    1104     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init(); 
    1105     pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n"); 
     1099    my $pbos = pb_distro_get_context(); 
    11061100 
    11071101    # Get list of packages to test 
     
    11111105 
    11121106    # Additional potential repo 
    1113     pb_distro_setuprepo($ddir,$dver,$arch,$dtype,$dfam,$dos); 
     1107    pb_distro_setuprepo($pbos); 
    11141108    foreach my $pbpkg (@pkgs) { 
    11151109        # We need to install the package to test, and deps brought with it 
    1116         pb_distro_installdeps(undef,$dtype,$pbins,$pbpkg); 
     1110        pb_distro_installdeps(undef,$pbos,$pbpkg); 
    11171111        pb_system("$ENV{'PBDESTDIR'}/pbtest","Launching test for $pbpkg","verbose"); 
    11181112    } 
     
    11221116 
    11231117    # Get the running distro to build on 
    1124     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $arch) = pb_distro_init(); 
    1125     pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $arch))."\n"); 
     1118    my $pbos = pb_distro_get_context(); 
    11261119 
    11271120    # If needed we may add repository to the build env 
    1128     pb_distro_setuprepo($ddir,$dver,$arch,$dtype,$dfam,$dos); 
     1121    pb_distro_setuprepo($pbos); 
    11291122 
    11301123    # Get list of packages to build 
     
    11581151 
    11591152        pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n"); 
    1160         if ($dtype eq "rpm") { 
     1153        if ($pbos->{'type'} eq "rpm") { 
    11611154            foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') { 
    11621155                if (! -d "$ENV{'PBBUILDDIR'}/$d") { 
     
    11691162            symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES"; 
    11701163            # We need to first extract the spec file 
    1171             my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver-$arch/","$ENV{'PBBUILDDIR'}/SPECS","spec"); 
     1164            my @specfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/","$ENV{'PBBUILDDIR'}/SPECS","spec"); 
    11721165 
    11731166            # We need to handle potential patches to upstream sources 
    1174             pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver-$arch/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES","patch"); 
     1167            pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbpatch/","$ENV{'PBBUILDDIR'}/SOURCES","patch"); 
    11751168 
    11761169            pb_log(2,"specfile: ".Dumper(\@specfile)."\n"); 
     
    11791172            # Older Redhat use _target_platform in %configure incorrectly 
    11801173            my $specialdef = ""; 
    1181             if (($ddir eq "redhat") || (($ddir eq "rhel") && ($dver eq "2.1"))) { 
     1174            if (($pbos->{'name'} eq "redhat") || (($pbos->{'name'} eq "rhel") && ($pbos->{'version'} eq "2.1"))) { 
    11821175                $specialdef = "--define \'_target_platform \"\"\'"; 
    11831176            } 
     
    11861179                if ($f =~ /\.spec$/) { 
    11871180                    # This could cause an issue in // mode 
    1188                     pb_distro_installdeps($f,$dtype,$pbins); 
     1181                    pb_distro_installdeps($f,$pbos); 
    11891182                    pb_system("rpmbuild $specialdef --define \"packager $ENV{'PBPACKAGER'}\" --define \"_topdir $ENV{'PBBUILDDIR'}\" -ba $f","Building package with $f under $ENV{'PBBUILDDIR'}","verbose"); 
    11901183                    last; 
     
    12011194            close(LOG); 
    12021195 
    1203         } elsif ($dtype eq "deb") { 
     1196        } elsif ($pbos->{'type'} eq "deb") { 
    12041197            chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}"; 
    12051198            pb_system("tar xfz $src","Extracting sources"); 
     
    12081201            chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver"; 
    12091202            pb_rm_rf("debian"); 
    1210             symlink "pbconf/$ddir-$dver-$arch","debian" || die "Unable to symlink to pbconf/$ddir-$dver-$arch"; 
     1203            symlink "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}","debian" || die "Unable to symlink to pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 
    12111204            chmod 0755,"debian/rules"; 
    12121205 
    1213             pb_distro_installdeps("debian/control",$dtype,$pbins); 
     1206            pb_distro_installdeps("debian/control",$pbos); 
    12141207            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose"); 
    12151208            # Get the name of the generated packages 
     
    12231216            } 
    12241217            close(LOG); 
    1225         } elsif ($dtype eq "ebuild") { 
     1218        } elsif ($pbos->{'type'} eq "ebuild") { 
    12261219            my @ebuildfile; 
    12271220            # For gentoo we need to take pb as subsystem name 
     
    12331226 
    12341227            # We need to first extract the ebuild file  
    1235             @ebuildfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$ddir-$dver-$arch/","$tmpd","ebuild"); 
     1228            @ebuildfile = pb_extract_build_files($src2,"$pbpkg-$pbver/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/","$tmpd","ebuild"); 
    12361229 
    12371230            # Prepare the build env for gentoo 
     
    12641257            foreach my $f (@ebuildfile) { 
    12651258                if ($f =~ /\.ebuild$/) { 
    1266                     pb_distro_installdeps($f,$dtype,$pbins); 
     1259                    pb_distro_installdeps($f,$pbos); 
    12671260                    move($f,"$tmpd/$pbpkg-$pbver.ebuild"); 
    12681261                    pb_system("cd $tmpd ; ebuild $pbpkg-$pbver.ebuild clean ; ebuild $pbpkg-$pbver.ebuild digest ; ebuild $pbpkg-$pbver.ebuild package","verbose"); 
     
    12821275            } 
    12831276 
    1284         } elsif ($dtype eq "tgz") { 
     1277        } elsif ($pbos->{'type'} eq "tgz") { 
    12851278            # Slackware family 
    12861279            $made="$made $pbpkg/$pbpkg-$pbver-*-$pbtag.tgz"; 
     
    12901283            pb_system("tar xfz $src2","Extracting pbconf"); 
    12911284            chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver"; 
    1292             symlink "pbconf/$ddir-$dver-$arch","install" || die "Unable to symlink to pbconf/$ddir-$dver-$arch"; 
     1285            symlink "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}","install" || die "Unable to symlink to pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"; 
    12931286            if (-x "install/pbslack") { 
    1294                 pb_distro_installdeps("./install/pbslack",$dtype,$pbins); 
     1287                pb_distro_installdeps("./install/pbslack",$pbos); 
    12951288                pb_system("./install/pbslack","Building software"); 
    12961289                pb_system("sudo /sbin/makepkg -p -l y -c y $pbpkg","Packaging $pbpkg","verbose"); 
    12971290            } 
    1298         } elsif ($dtype eq "pkg") { 
     1291        } elsif ($pbos->{'type'} eq "pkg") { 
    12991292            # Solaris 
    13001293            $made="$made $pbpkg-$pbver-$pbtag.pkg.gz"; 
     
    13031296            chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}"; 
    13041297            # Will host resulting packages 
    1305             pb_mkdir_p("$dtype"); 
     1298            pb_mkdir_p("$pbos->{'type'}"); 
    13061299            pb_mkdir_p("$pkgdestdir/delivery"); 
    13071300            pb_system("tar xfz $src","Extracting sources under $ENV{'PBBUILDDIR'}"); 
    13081301            pb_system("tar xfz $src2","Extracting pbconf under $ENV{'PBBUILDDIR'}"); 
    13091302            chdir "$pbpkg-$pbver" || die "Unable to chdir to $pbpkg-$pbver"; 
    1310             if (-f "pbconf/$ddir-$dver-$arch/pbbuild") { 
    1311                 chmod 0755,"pbconf/$ddir-$dver-$arch/pbbuild"; 
     1303            if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild") { 
     1304                chmod 0755,"pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild"; 
    13121305                # pkginfo file is mandatory 
    1313                 die "Unable to find pkginfo file in pbconf/$ddir-$dver-$arch" if (! -f "pbconf/$ddir-$dver-$arch/pkginfo"); 
     1306                die "Unable to find pkginfo file in pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}" if (! -f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pkginfo"); 
    13141307                # Build 
    1315                 pb_system("pbconf/$ddir-$dver-$arch/pbbuild $pkgdestdir/delivery","Building software and installing under $pkgdestdir/delivery"); 
     1308                pb_system("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild $pkgdestdir/delivery","Building software and installing under $pkgdestdir/delivery"); 
    13161309                # Copy complementary files 
    1317                 if (-f "pbconf/$ddir-$dver-$arch/prototype") { 
    1318                     copy("pbconf/$ddir-$dver-$arch/prototype", $pkgdestdir)  
     1310                if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/prototype") { 
     1311                    copy("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/prototype", $pkgdestdir)  
    13191312                } else { 
    13201313                    # No prototype provided, calculating it 
    13211314                    open(PROTO,"> $pkgdestdir/prototype") || die "Unable to create prototype file"; 
    13221315                    print PROTO "i pkginfo\n"; 
    1323                     print PROTO "i depend\n" if (-f "pbconf/$ddir-$dver-$arch/depend"); 
     1316                    print PROTO "i depend\n" if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/depend"); 
    13241317                    $ENV{'PBSOLDESTDIR'} = "$pkgdestdir/delivery"; 
    13251318                    find(\&create_solaris_prototype, "$pkgdestdir/delivery"); 
    13261319                } 
    1327                 copy("pbconf/$ddir-$dver-$arch/depend", $pkgdestdir) if (-f "pbconf/$ddir-$dver-$arch/depend"); 
    1328                 copy("pbconf/$ddir-$dver-$arch/pkginfo", $pkgdestdir); 
    1329                 pb_system("cd $pkgdestdir/delivery ; pkgmk -o -f ../prototype -r $pkgdestdir/delivery -d $ENV{'PBBUILDDIR'}/$dtype","Packaging $pbpkg","verbose"); 
    1330                 pb_system("cd $ENV{'PBBUILDDIR'}/$dtype ;  echo \"\" | pkgtrans -o -n -s $ENV{'PBBUILDDIR'}/$dtype $ENV{'PBBUILDDIR'}/$pbpkg-$pbver-$pbtag.pkg all","Transforming $pbpkg","verbose"); 
     1320                copy("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/depend", $pkgdestdir) if (-f "pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/depend"); 
     1321                copy("pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pkginfo", $pkgdestdir); 
     1322                pb_system("cd $pkgdestdir/delivery ; pkgmk -o -f ../prototype -r $pkgdestdir/delivery -d $ENV{'PBBUILDDIR'}/$pbos->{'type'}","Packaging $pbpkg","verbose"); 
     1323                pb_system("cd $ENV{'PBBUILDDIR'}/$pbos->{'type'} ;  echo \"\" | pkgtrans -o -n -s $ENV{'PBBUILDDIR'}/$pbos->{'type'} $ENV{'PBBUILDDIR'}/$pbpkg-$pbver-$pbtag.pkg all","Transforming $pbpkg","verbose"); 
    13311324                pb_system("cd $ENV{'PBBUILDDIR'} ;  gzip -9f $pbpkg-$pbver-$pbtag.pkg","Compressing $pbpkg-$pbver-$pbtag.pkg","verbose"); 
    13321325            } else { 
    1333                 pb_log(0,"No pbconf/$ddir-$dver-$arch/pbbuild file found for $pbpkg-$pbver in \n"); 
     1326                pb_log(0,"No pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbbuild file found for $pbpkg-$pbver in \n"); 
    13341327            } 
    13351328            chdir ".." || die "Unable to chdir to parent dir"; 
    1336             pb_system("rm -rf $pbpkg-$pbver $ENV{'PBBUILDDIR'}/$dtype $pkgdestdir", "Cleanup"); 
    1337         } elsif ($dtype eq "hpux") { 
     1329            pb_system("rm -rf $pbpkg-$pbver $ENV{'PBBUILDDIR'}/$pbos->{'type'} $pkgdestdir", "Cleanup"); 
     1330        } elsif ($pbos->{'type'} eq "hpux") { 
    13381331            # HP-UX 
    13391332            chdir "$ENV{'PBBUILDDIR'}" || die "Unable to chdir to $ENV{'PBBUILDDIR'}"; 
     
    13571350            pb_system("rm -rf $pbpkg-$pbver", "Cleanup"); 
    13581351        } else { 
    1359             die "Unknown dtype format $dtype"; 
     1352            die "Unknown OS type format $pbos->{'type'}"; 
    13601353        } 
    13611354        if (defined $pbparallel) { 
     
    13751368 
    13761369    # Find the appropriate check cmd/opts 
    1377     my ($oschkcmd,$oschkopt) = pb_conf_get_if("oschkcmd","oschkopt"); 
    1378     my $chkcmd .= pb_distro_get_param($ddir,$dver,$arch,$oschkcmd,$dtype,$dfam,$dos); 
    1379     my $chkopt .= pb_distro_get_param($ddir,$dver,$arch,$oschkopt,$dtype,$dfam,$dos); 
     1370    my ($chkcmd,$chkopt) = pb_distro_get_param($pbos,pb_conf_get_if("oschkcmd","oschkopt")); 
    13801371 
    13811372    # Packages check if needed 
    1382     if ($dtype eq "rpm") { 
    1383         if (-x $chkcmd) { 
    1384             pb_system("$chkcmd $chkopt $made","Checking validity of rpms with $chkcmd","verbose"); 
     1373    if ($pbos->{'type'} eq "rpm") { 
     1374        if ((defined  $chkcmd) && (-x $chkcmd)) { 
     1375            my $cmd = "$chkcmd"; 
     1376            $cmd .= " $chkopt" if (defined $chkopt); 
     1377            $cmd .= " $made"; 
     1378            pb_system("$cmd","Checking validity of rpms with $chkcmd","verbose"); 
    13851379        } 
    13861380        my $rpms =""; 
     
    13921386        pb_log(0,"SRPM packages generated: $srpms\n"); 
    13931387        pb_log(0,"RPM packages generated: $rpms\n"); 
    1394     } elsif ($dtype eq "deb") { 
     1388    } elsif ($pbos->{'type'} eq "deb") { 
    13951389        my $made2 = ""; 
    13961390        foreach my $f (split(/ /,$made)) { 
     
    14031397        } 
    14041398    } else { 
    1405         pb_log(0,"No check done for $dtype yet\n"); 
     1399        pb_log(0,"No check done for $pbos->{'type'} yet\n"); 
    14061400        pb_log(0,"Packages generated: $made\n"); 
    14071401    } 
     
    14901484    my $cmd = ""; 
    14911485    my $src = ""; 
    1492     my ($odir,$over,$oarch) = (undef, undef, undef); 
    1493     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch); 
     1486    my $pbos; 
    14941487 
    14951488    if ($cmt ne "Announce") { 
     
    14991492 
    15001493        # Get the running distro to consider 
    1501         if (defined $v) { 
    1502             ($odir,$over,$oarch) = split(/-/,$v); 
    1503         } 
    1504         ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch) = pb_distro_init($odir,$over,$oarch); 
    1505         pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $darch))."\n"); 
     1494        $pbos = pb_distro_get_context($v); 
    15061495 
    15071496        # Get list of packages to build 
     
    15711560    if ($cmt =~ /^RM/) { 
    15721561        # In that case our real host is in the rmhost with the OS as key, not project as above 
    1573         $sshmachine = pb_distro_get_param($ddir,$dver,$darch,$sshhost,$dfam,$dtype,$dos); 
     1562        $sshmachine = pb_distro_get_param($pbos,$sshhost); 
    15741563    } 
    15751564    pb_log(2,"ssh: ".Dumper(($sshhost,$sshlogin,$sshdir,$sshport,$vtmout,$vepath,$rbsconf))."\n"); 
     
    16021591        $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}"; 
    16031592    } elsif ($cmt eq "Packages") { 
    1604         $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch"; 
     1593        $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$delivery->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"; 
    16051594 
    16061595        my $repodir = $tdir; 
     
    16111600        # Repository management 
    16121601        open(PBS,"> $ENV{'PBBUILDDIR'}/pbscript") || die "Unable to create $ENV{'PBBUILDDIR'}/pbscript"; 
    1613         if ($dtype eq "rpm") { 
     1602        if ($pbos->{'type'} eq "rpm") { 
    16141603            # Also make a pbscript to generate yum/urpmi bases 
    16151604            print PBS << "EOF"; 
     
    16181607cat > $ENV{'PBPROJ'}.repo << EOT 
    16191608[$ENV{'PBPROJ'}] 
    1620 name=$ddir $dver $darch - $ENV{'PBPROJ'} Vanilla Packages 
     1609name=$pbos->{'name'} $pbos->{'version'} $pbos->{'arch'} - $ENV{'PBPROJ'} Vanilla Packages 
    16211610baseurl=$pbrepo->{$ENV{'PBPROJ'}}/$repodir 
    16221611enabled=1 
     
    16341623createrepo . 
    16351624EOF 
    1636             if ($dfam eq "md") { 
     1625            if ($pbos->{'family'} eq "md") { 
    16371626                # For Mandriva add urpmi management 
    16381627                print PBS << "EOF"; 
     
    16521641EOF 
    16531642            } 
    1654             if ($ddir eq "fedora") { 
     1643            if ($pbos->{'name'} eq "fedora") { 
    16551644                # Extract the spec file to please Fedora maintainers :-( 
    16561645                print PBS << "EOF"; 
     
    16631652EOF 
    16641653            } 
    1665             if ($dfam eq "novell") { 
     1654            if ($pbos->{'family'} eq "novell") { 
    16661655                # Add ymp scripts for one-click install on SuSE 
    16671656                print PBS << "EOF"; 
     
    17121701EOF 
    17131702            } 
    1714         } elsif ($dtype eq "deb") { 
     1703        } elsif ($pbos->{'type'} eq "deb") { 
    17151704            # Also make a pbscript to generate apt bases 
    17161705            # Cf: http://www.debian.org/doc/manuals/repository-howto/repository-howto.fr.html 
     
    17231712# Prepare a script to ease apt setup 
    17241713cat > $ENV{'PBPROJ'}.sources.list << EOT 
    1725 deb $rpd $dver contrib 
    1726 deb-src $rpd $dver contrib 
     1714deb $rpd $pbos->{'version'} contrib 
     1715deb-src $rpd $pbos->{'version'} contrib 
    17271716EOT 
    17281717chmod 644 $ENV{'PBPROJ'}.sources.list 
     
    17301719# Up two levels to deal with the dist dir cross versions 
    17311720cd ../.. 
    1732 mkdir -p dists/$dver/contrib/binary-$darch dists/$dver/contrib/source 
     1721mkdir -p dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'} dists/$pbos->{'version'}/contrib/source 
    17331722 
    17341723# Prepare a script to create apt info file 
     
    17421731EOT 
    17431732 
    1744 echo "Creating Packages metadata ($darch)" 
    1745 dpkg-scanpackages -a$darch $dver/$darch /dev/null | gzip -c9 > dists/$dver/contrib/binary-$darch/Packages.gz 
    1746 dpkg-scanpackages -a$darch $dver/$darch /dev/null | bzip2 -c9 > dists/$dver/contrib/binary-$darch/Packages.bz2 
    1747 echo "Creating Contents metadata ($darch)" 
    1748 apt-ftparchive contents $dver | gzip -c9 > dists/$dver/Contents-$darch.gz 
    1749 echo "Creating Release metadata ($darch)" 
    1750 cat \$TMPD/Release > dists/$dver/contrib/binary-$darch/Release 
    1751 echo "Architecture: $darch" >> dists/$dver/contrib/binary-$darch/Release 
     1733echo "Creating Packages metadata ($pbos->{'arch'})" 
     1734dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.gz 
     1735dpkg-scanpackages -a$pbos->{'arch'} $pbos->{'version'}/$pbos->{'arch'} /dev/null | bzip2 -c9 > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Packages.bz2 
     1736echo "Creating Contents metadata ($pbos->{'arch'})" 
     1737apt-ftparchive contents $pbos->{'version'} | gzip -c9 > dists/$pbos->{'version'}/Contents-$pbos->{'arch'}.gz 
     1738echo "Creating Release metadata ($pbos->{'arch'})" 
     1739cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release 
     1740echo "Architecture: $pbos->{'arch'}" >> dists/$pbos->{'version'}/contrib/binary-$pbos->{'arch'}/Release 
    17521741echo "Creating Source metadata" 
    1753 dpkg-scansources $dver/$darch /dev/null | gzip -c9 > dists/$dver/contrib/source/Sources.gz 
    1754 cat \$TMPD/Release > dists/$dver/contrib/source/Release 
    1755 echo "Architecture: Source" >> dists/$dver/contrib/source/Release 
     1742dpkg-scansources $pbos->{'version'}/$pbos->{'arch'} /dev/null | gzip -c9 > dists/$pbos->{'version'}/contrib/source/Sources.gz 
     1743cat \$TMPD/Release > dists/$pbos->{'version'}/contrib/source/Release 
     1744echo "Architecture: Source" >> dists/$pbos->{'version'}/contrib/source/Release 
    17561745echo "Creating Release metadata" 
    1757 apt-ftparchive release dists/$dver > dists/$dver/Release 
     1746apt-ftparchive release dists/$pbos->{'version'} > dists/$pbos->{'version'}/Release 
    17581747rm -rf \$TMPD 
    17591748EOF 
    1760         } elsif ($dtype eq "ebuild") { 
     1749        } elsif ($pbos->{'type'} eq "ebuild") { 
    17611750            # make a pbscript to generate links to latest version 
    17621751            print PBS << "EOF"; 
     
    17931782    # should use a hash instead... 
    17941783    my ($shcmd,$cpcmd,$cptarget,$cp2target); 
     1784    my ($odir,$over,$oarch); 
    17951785    if ($cmt !~ /^VE/) { 
    17961786        my $keyfile = pb_ssh_get(0); 
     
    18841874                my $j = basename($p); 
    18851875                pb_system("$cpcmd $cp2target/$delim$p$delim $ENV{'PBBUILDDIR'}/$odir/$over/$oarch 2> /dev/null","Recovery of package $j in $ENV{'PBBUILDDIR'}/$odir/$over/$oarch"); 
    1886                 $made="$made $odir/$over/$oarch/$j"; # if (($dtype ne "rpm") || ($j !~ /.src.rpm$/)); 
     1876                $made="$made $odir/$over/$oarch/$j"; # if (($pbos->{'type'} ne "rpm") || ($j !~ /.src.rpm$/)); 
    18871877            } 
    18881878            print KEEP "$made\n"; 
     
    18911881 
    18921882            # Sign packages locally 
    1893             if ($dtype eq "rpm") { 
     1883            if ($pbos->{'type'} eq "rpm") { 
    18941884                #pb_system("rpm --addsign --define \"_signature gpg\" --define \"_gpg_name $ENV{'PBPACKAGER'}\" --define \"__gpg_sign_cmd /usr/bin/gpg --batch --no-verbose --no-armor --no-tty --no-secmem-warning -sbo %{__signature_filename} %{__plaintext_filename} --use-agent\" $made","Signing RPM packages packages"); 
    1895             } elsif ($dtype eq "deb") { 
     1885            } elsif ($pbos->{'type'} eq "deb") { 
    18961886                #pb_system("debsign $made","Signing DEB packages"); 
    18971887            } else { 
    1898                 pb_log(0,"I don't know yet how to sign packages for type $dtype.\nPlease give feedback to dev team\n"); 
     1888                pb_log(0,"I don't know yet how to sign packages for type $pbos->{'type'}.\nPlease give feedback to dev team\n"); 
    18991889            } 
    19001890 
     
    19391929        my $hpath = "/sbin"; 
    19401930        # Solaris doesn't support -h and has halt elsewhere 
    1941         if ($dtype eq "pkg") { 
     1931        if ($pbos->{'type'} eq "pkg") { 
    19421932            $hoption = "" ; 
    19431933            $hpath = "/usr/sbin"; 
     
    21502140        # VE here 
    21512141        # Get distro context 
    2152         my ($name,$ver,$darch) = split(/-/,$v); 
    2153         chomp($darch); 
    2154         my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch); 
     2142        my $pbos = pb_distro_get_context($v); 
    21552143 
    21562144        # Get VE context 
     
    21662154        if (($vetype eq "chroot") || ($vetype eq "schroot")) { 
    21672155            # Architecture consistency 
    2168             if ($arch ne $darch) { 
    2169                 die "Unable to launch a VE of architecture $darch on a $arch platform" if (($darch eq "x86_64") && ($arch =~ /i?86/)); 
     2156            if ($arch ne $pbos->{'arch'}) { 
     2157                die "Unable to launch a VE of architecture $pbos->{'arch'} on a $arch platform" if (($pbos->{'arch'} eq "x86_64") && ($arch =~ /i?86/)); 
    21702158            } 
    21712159 
     
    21752163 
    21762164                # We have to rebuild the chroot 
    2177                 if ($dtype eq "rpm") { 
     2165                if ($pbos->{'type'} eq "rpm") { 
    21782166 
    21792167                    # Which tool is used 
     
    21922180                    } 
    21932181 
    2194                     my $postinstall = pb_get_postinstall($ddir,$dver,$darch,$rbspi,$verpmstyle); 
     2182                    my $postinstall = pb_get_postinstall($pbos,$rbspi,$verpmstyle); 
    21952183                    if ($verpmstyle eq "rinse") { 
    21962184                        # Need to reshape the mirrors generated with local before-post-install script 
    21972185                        my $b4post = "--before-post-install "; 
    2198                         my $postparam = pb_distro_get_param($ddir,$dver,$darch,$rbsb4pi); 
     2186                        my $postparam = pb_distro_get_param($pbos,$rbsb4pi); 
    21992187                        if ($postparam eq "") { 
    22002188                            $b4post = ""; 
     
    22062194                        my $addpkgs; 
    22072195                        $postparam = ""; 
    2208                         $postparam .= pb_distro_get_param($ddir,$dver,$darch,$osmindep); 
     2196                        $postparam .= pb_distro_get_param($pbos,$osmindep); 
    22092197                        if ($postparam eq "") { 
    22102198                            $addpkgs = ""; 
     
    22242212 
    22252213                        my $command = pb_check_req("rinse",0); 
    2226                         pb_system("sudo $command --directory \"$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch\" --arch \"$darch\" --distribution \"$ddir-$dver\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $ddir-$dver ($darch)", "verbose"); 
     2214                        pb_system("sudo $command --directory \"$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" --arch \"$pbos->{'arch'}\" --distribution \"$pbos->{'name'}-$pbos->{'version'}\" --config \"$rbsconf->{$ENV{'PBPROJ'}}\" $b4post $postinstall $rbsopt $addpkgs $rinseverb","Creating the rinse VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
    22272215                    } elsif ($verpmstyle eq "rpmbootstrap") { 
    22282216                        my $rbsverb = ""; 
     
    22322220                        my $addpkgs = ""; 
    22332221                        my $postparam = ""; 
    2234                         $postparam .= pb_distro_get_param($ddir,$dver,$darch,$osmindep); 
     2222                        $postparam .= pb_distro_get_param($pbos,$osmindep); 
    22352223                        if ($postparam eq "") { 
    22362224                            $addpkgs = ""; 
     
    22392227                        } 
    22402228                        my $command = pb_check_req("rpmbootstrap",0); 
    2241                         pb_system("sudo $command $rbsopt $postinstall $addpkgs $ddir-$dver-$darch $rbsverb","Creating the rpmbootstrap VE for $ddir-$dver ($darch)", "verbose"); 
     2229                        pb_system("sudo $command $rbsopt $postinstall $addpkgs $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'} $rbsverb","Creating the rpmbootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
    22422230                    } elsif ($verpmstyle eq "mock") { 
    22432231                        my ($rbsconf) = pb_conf_get("rbsconf"); 
    22442232                        my $command = pb_check_req("mock",0); 
    2245                         pb_system("sudo $command --init --resultdir=\"/tmp\" --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v $rbsopt","Creating the mock VE for $ddir-$dver ($darch)"); 
     2233                        pb_system("sudo $command --init --resultdir=\"/tmp\" --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v $rbsopt","Creating the mock VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})"); 
    22462234                        # Once setup we need to install some packages, the pb account, ... 
    22472235                        pb_system("sudo $command --install --configdir=\"$rbsconf->{$ENV{'PBPROJ'}}\" -r $v su","Configuring the mock VE"); 
     
    22492237                        die "Unknown verpmtype type $verpmstyle. Report to dev team"; 
    22502238                    } 
    2251                 } elsif ($dtype eq "deb") { 
     2239                } elsif ($pbos->{'type'} eq "deb") { 
    22522240                    my $vedebstyle = $vedebtype->{$ENV{'PBPROJ'}}; 
    22532241 
    2254                     my $codename = pb_distro_get_param($ddir,$dver,$darch,$oscodename); 
     2242                    my $codename = pb_distro_get_param($pbos,$oscodename); 
    22552243                    my $postparam = ""; 
    22562244                    my $addpkgs; 
    2257                     $postparam .= pb_distro_get_param($ddir,$dver,$darch,$osmindep); 
     2245                    $postparam .= pb_distro_get_param($pbos,$osmindep); 
    22582246                    if ($postparam eq "") { 
    22592247                        $addpkgs = ""; 
     
    22622250                    } 
    22632251                    my $debmir = ""; 
    2264                     $debmir .= pb_distro_get_param($ddir,$dver,$darch,$rbsmirrorsrv); 
     2252                    $debmir .= pb_distro_get_param($pbos,$rbsmirrorsrv); 
    22652253 
    22662254                    # Get potential rbs option 
     
    22772265     
    22782266                    # debootstrap works with amd64 not x86_64 
    2279                     my $debarch = $darch; 
    2280                     $debarch = "amd64" if ($darch eq "x86_64"); 
     2267                    my $debarch = $pbos->{'arch'}; 
     2268                    $debarch = "amd64" if ($pbos->{'arch'} eq "x86_64"); 
    22812269                    if ($vedebstyle eq "debootstrap") { 
    22822270                        my $dbsverb = ""; 
     
    22842272 
    22852273                        # Some perl modules are in Universe on Ubuntu 
    2286                         $rbsopt .= " --components=main,universe" if ($ddir eq "ubuntu"); 
    2287  
    2288                         pb_system("sudo /usr/sbin/debootstrap $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch\" $debmir","Creating the debootstrap VE for $ddir-$dver ($darch)", "verbose"); 
     2274                        $rbsopt .= " --components=main,universe" if ($pbos->{'name'} eq "ubuntu"); 
     2275 
     2276                        pb_system("sudo /usr/sbin/debootstrap $dbsverb $rbsopt --arch=$debarch $addpkgs $codename \"$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}\" $debmir","Creating the debootstrap VE for $pbos->{'name'}-$pbos->{'version'} ($pbos->{'arch'})", "verbose"); 
    22892277                        # debootstrap doesn't create an /etc/hosts file 
    2290                         if (! -f "$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch/etc/hosts" ) { 
    2291                             pb_system("sudo cp /etc/hosts $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch/etc/hosts"); 
     2278                        if (! -f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts" ) { 
     2279                            pb_system("sudo cp /etc/hosts $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/etc/hosts"); 
    22922280                        } 
    22932281                    } else { 
    22942282                        die "Unknown vedebtype type $vedebstyle. Report to dev team"; 
    22952283                    } 
    2296                 } elsif ($dtype eq "ebuild") { 
     2284                } elsif ($pbos->{'type'} eq "ebuild") { 
    22972285                    die "Please teach the dev team how to build gentoo chroot"; 
    22982286                } else { 
    2299                     die "Unknown distribution type $dtype. Report to dev team"; 
     2287                    die "Unknown distribution type $pbos->{'type'}. Report to dev team"; 
    23002288                } 
    23012289            } 
    23022290            # Fix modes to allow access to the VE for pb user 
    2303             pb_system("sudo chmod 755 $vepath->{$ENV{'PBPROJ'}}/$ddir $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch","Fixing permissions"); 
     2291            pb_system("sudo chmod 755 $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'} $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'} $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}","Fixing permissions"); 
    23042292 
    23052293            # Test if an existing snapshot exists and use it if appropriate 
    23062294            # And also use it of no local extracted VE is present 
    2307             if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz") && 
     2295            if ((-f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") && 
    23082296                (((defined $vesnap->{$v}) && ($vesnap->{$v} =~ /true/i)) || 
    23092297                    ((defined $vesnap->{$ENV{'PBPROJ'}}) && ($vesnap->{$ENV{'PBPROJ'}} =~ /true/i)) || 
    23102298                    ($pbsnap eq 1) || 
    2311                     (! -d "$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch"))) { 
    2312                         pb_system("sudo rm -rf $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch ; sudo mkdir -p $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch ; sudo tar xz  -C $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Extracting snapshot of $ddir-$dver-$darch.tar.gz under $vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch"); 
     2299                    (! -d "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"))) { 
     2300                        pb_system("sudo rm -rf $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; sudo mkdir -p $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} ; sudo tar xz  -C $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'} -f $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Extracting snapshot of $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz under $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}"); 
    23132301            } 
    23142302            # Nothing more to do for VE. No real launch 
     
    23192307        # RM here 
    23202308        # Get distro context 
    2321         my ($name,$ver,$darch) = split(/-/,$v); 
    2322         chomp($darch); 
    2323         my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch); 
     2309        my $pbos = pb_distro_get_context($v); 
    23242310 
    23252311        # Get RM context 
     
    26792665 
    26802666    # Get distro context 
    2681     my ($name,$ver,$darch) = split(/-/,$v); 
    2682     chomp($darch); 
    2683     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch); 
     2667    my $pbos = pb_distro_get_context($v); 
    26842668     
    26852669    # Name of the account to deal with for VM/VE/RM 
     
    28002784my $home = "/home"; 
    28012785# Solaris doesn't like that we use /home 
    2802 $home = "/export/home" if ($dtype eq "pkg"); 
     2786$home = "/export/home" if ($pbos->{'type'} eq "pkg"); 
    28032787 
    28042788    print SCRIPT << "EOF"; 
     
    28832867# pb has to be added to portage group on gentoo 
    28842868 
    2885 # We need to have that pb_distro_init function 
     2869# We need to have that pb_distro_get_context function 
    28862870# Get it from Project-Builder::Distribution 
    28872871# And we now need the conf file required for this to work created above 
    28882872 
    2889 my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins, $darch) = pb_distro_init();  
    2890 print "distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd, $pbins, $darch))."\n"; 
     2873my $pbos = pb_distro_get_context();  
     2874print "distro tuple: ".Dumper($pbos)."\n"; 
    28912875 
    28922876# Adapt sudoers 
    28932877# sudo is not default on Solaris and needs to be installed first 
    28942878# from http://www.sunfreeware.com/programlistsparc10.html#sudo 
    2895 if ($dtype eq "pkg") { 
     2879if ($pbos->{'type'} eq "pkg") { 
    28962880    $file="/usr/local/etc/sudoers"; 
    28972881} else { 
     
    29402924     
    29412925# Suse wants sudoers as 640 
    2942 if ((($ddir eq "sles") && (($dver =~ /10/) || ($dver =~ /9/))) || (($ddir eq "opensuse") && ($dver =~ /10.[012]/))) { 
     2926if ((($pbos->{'name'} eq "sles") && (($pbos->{'version'} =~ /10/) || ($pbos->{'version'} =~ /9/))) || (($pbos->{'name'} eq "opensuse") && ($pbos->{'version'} =~ /10.[012]/))) { 
    29432927    chmod 0640,$file; 
    29442928} 
    29452929 
    29462930# First install all required packages 
    2947 pb_system("yum clean all","Cleaning yum env") if (($ddir eq "fedora") || ($ddir eq "asianux") || ($ddir eq "rhel")); 
     2931pb_system("yum clean all","Cleaning yum env") if (($pbos->{'name'} eq "fedora") || ($pbos->{'name'} eq "asianux") || ($pbos->{'name'} eq "rhel")); 
    29482932my ($ospkgdep) = pb_conf_get_if("ospkgdep"); 
    29492933     
    2950 my $pkgdep = pb_distro_get_param($ddir,$dver,$darch,$ospkgdep,$dfam,$dtype,$dos); 
    2951 pb_distro_installdeps(undef,$dtype,$pbins,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgdep)))); 
    2952  
    2953 EOF 
    2954     my ($instype) = pb_conf_get("pbinstalltype"); 
    2955     my $itype = pb_distro_get_param($ddir,$dver,$darch,$instype,$dfam,$dtype,$dos); 
     2934my $pkgdep = pb_distro_get_param($pbos,$ospkgdep); 
     2935pb_distro_installdeps(undef,$pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgdep)))); 
     2936 
     2937EOF 
     2938    my $itype = pb_distro_get_param($pbos,pb_conf_get("pbinstalltype")); 
    29562939    # Install from sandbox mean a file base install 
    29572940    $itype = "file" if (defined $sbx); 
     
    29732956            if ($vtype eq "ve") { 
    29742957                my ($vepath) = pb_conf_get("vepath"); 
    2975                 copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch/tmp"); 
    2976                 copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch/tmp"); 
     2958                copy("$ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/tmp"); 
     2959                copy("$ENV{'PBDESTDIR'}/project-builder-$pbver2.tar.gz","$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}/tmp"); 
    29772960            } else { 
    29782961                pb_system("scp -i $keyfile -p -o UserKnownHostsFile=/dev/null -P $nport $ENV{'PBDESTDIR'}/ProjectBuilder-$pbver1.tar.gz $ENV{'PBDESTDIR'}/project-builder-$pbver2.tar.gz root\@$vmhost->{$ENV{'PBPROJ'}}:/tmp","Copying local project files to $vtype."); 
     
    29862969my ($osperldep,$osperlver) = pb_conf_get_if("osperldep","osperlver"); 
    29872970     
    2988 my $perldep = pb_distro_get_param($ddir,$dver,$darch,$osperldep,$dfam,$dtype,$dos); 
     2971my $perldep = pb_distro_get_param($pbos,$osperldep); 
    29892972foreach my $m (split(/,/,$perldep)) { 
    29902973    # Skip empty deps 
     
    30022985        # pkg based install. We need to point to the project-builder.org repository 
    30032986        print SCRIPT << 'EOF'; 
    3004 my ($ospkg) = pb_conf_get_if("ospkg"); 
    3005  
    3006 my $pkgforpb = pb_distro_get_param($ddir,$dver,$darch,$ospkg,$dfam,$dtype,$dos); 
    3007 pb_distro_setuposrepo($ddir,$dver,$darch,$dtype,$dfam,$dos); 
    3008 pb_distro_installdeps(undef,$dtype,$pbins,pb_distro_only_deps_needed($dtype,join(' ',split(/,/,$pkgforpb)))); 
     2987my $pkgforpb = pb_distro_get_param($pbos,pb_conf_get_if("ospkg")); 
     2988pb_distro_setuposrepo($pbos); 
     2989pb_distro_installdeps(undef,$pbos,pb_distro_only_deps_needed($pbos,join(' ',split(/,/,$pkgforpb)))); 
    30092990EOF 
    30102991    } else { 
     
    30243005 
    30253006my $nf="/etc/sysconfig/network"; 
    3026 if ((! -f $nf) && ($dtype eq "rpm")) { 
     3007if ((! -f $nf) && ($pbos->{'type'} eq "rpm")) { 
    30273008    open(NF,"> $nf") || die "Unable to create $nf"; 
    30283009    print NF "NETWORKING=yes\n"; 
     
    30343015    } 
    30353016 
    3036     # Adds pb_distro_init and all functions needed from ProjectBuilder::Distribution, Conf and Base 
     3017    # Adds pb_distro_get_context and all functions needed from ProjectBuilder::Distribution, Conf and Base 
    30373018    foreach my $d (@INC) { 
    30383019        my @f = ("$d/ProjectBuilder/Base.pm","$d/ProjectBuilder/Distribution.pm","$d/ProjectBuilder/Conf.pm"); 
     
    30933074    if ($vtype eq "ve") { 
    30943075        # Get distro context 
    3095         my ($name,$ver,$darch) = split(/-/,$v); 
    3096         chomp($darch); 
    3097         my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf) = pb_distro_init($name,$ver,$darch); 
     3076        my $pbos = pb_distro_get_context($v); 
    30983077        my ($vepath) = pb_conf_get("vepath"); 
    30993078 
    31003079        # Test if an existing snapshot exists and remove it if there is a VE 
    3101         if ((-f "$vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz") && 
    3102             (! -d "$vepath->{$ENV{'PBPROJ'}}/$ddir/$dver/$darch")) { 
    3103                 pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$ddir-$dver-$darch.tar.gz","Removing previous snapshot $ddir-$dver-$darch.tar.gz"); 
     3080        if ((-f "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz") && 
     3081            (! -d "$vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}/$pbos->{'version'}/$pbos->{'arch'}")) { 
     3082                pb_system("sudo rm -f $vepath->{$ENV{'PBPROJ'}}/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz","Removing previous snapshot $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.tar.gz"); 
    31043083        } 
    31053084    } 
     
    31353114foreach my $v (@$vm) { 
    31363115    # Get distro context 
    3137     my ($name,$ver,$darch) = split(/-/,$v); 
    3138     chomp($darch); 
    3139     my ($ddir, $dver, $dfam, $dtype, $dos, $pbsuf, $pbupd, $pbins) = pb_distro_init($name,$ver,$darch); 
     3116    my $pbos = pb_distro_get_context($v); 
    31403117 
    31413118    # Prepare the script to be executed on the VM/VE/RM 
     
    31513128        print SCRIPT "sudo mount -t proc /proc /proc\n"; 
    31523129    } 
    3153     print SCRIPT "$pbupd\n"; 
     3130    print SCRIPT "$pbos->{'update'}\n"; 
    31543131    if ($vtype eq "ve") { 
    31553132        print SCRIPT "sudo umount /proc\n"; 
     
    32083185        open(OUT,"> $ENV{'PBTMP'}/$pbpkg.ann") || die "Unable to create $ENV{'PBTMP'}/$pbpkg.ann: $!"; 
    32093186        my %pb; 
    3210         $pb{'dtype'} = "announce"; 
    32113187        $pb{'realpkg'} = $pbpkg; 
    32123188        $pb{'ver'} = $pbver; 
    32133189        $pb{'tag'} = $pbtag; 
    3214         $pb{'suf'} = "N/A";     # Should not be empty even if unused 
    32153190        $pb{'date'} = $pbdate; 
    32163191        $pb{'chglog'} = $chglog; 
     
    35383513my $sdir = shift; 
    35393514my $sources = shift; 
    3540 my $dtype = shift; 
    3541 my $dfam = shift; 
    3542 my $ddir = shift; 
    3543 my $dver = shift; 
    3544 my $arch = shift; 
     3515my $pbos = shift; 
    35453516my $extdir = shift; 
    35463517 
     
    35483519# This function works for both patches and additional sources 
    35493520foreach my $p (sort(<$sdir/*>)) { 
    3550     $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.all$/)); 
    3551     $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.all$/); 
    3552     $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$dtype$/)); 
    3553     $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dtype$/); 
    3554     $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$dfam$/)); 
    3555     $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$dfam$/); 
    3556     $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir$/)); 
    3557     $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir$/); 
    3558     $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver$/)); 
    3559     $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver$/); 
    3560     $sources->{"$ddir-$dver-$arch"} .= "," if ((defined $sources->{"$ddir-$dver-$arch"}) and ($p =~ /\.$ddir-$dver-$arch$/)); 
    3561     $sources->{"$ddir-$dver-$arch"} .= "file://$p" if ($p =~ /\.$ddir-$dver-$arch$/); 
     3521    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.all$/)); 
     3522    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.all$/); 
     3523    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'type'}$/)); 
     3524    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'type'}$/); 
     3525    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'family'}$/)); 
     3526    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'family'}$/); 
     3527    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'name'}$/)); 
     3528    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'name'}$/); 
     3529    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}$/)); 
     3530    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}$/); 
     3531    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if ((defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}) and ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}$/)); 
     3532    $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "file://$p" if ($p =~ /\.$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}$/); 
    35623533} 
    35633534 
    35643535# Prepare also remote sources to be included - Applied after the local ones 
    3565 foreach my $p ("all","$dtype","$dfam","$ddir","$ddir-$dver","$ddir-$dver-$arch") { 
     3536foreach my $p ("all","$pbos->{'type'}","$pbos->{'family'}","$pbos->{'name'}","$pbos->{'name'}-$pbos->{'version'}","$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}") { 
    35663537    my $f = "$extdir.".".$p"; 
    35673538    next if (not -f $f); 
     
    35723543    while (<PATCH>) { 
    35733544        chomp(); 
    3574         $sources->{"$ddir-$dver-$arch"} .= "," if (defined $sources->{"$ddir-$dver-$arch"}); 
    3575         $sources->{"$ddir-$dver-$arch"} .= "$_"; 
     3545        $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "," if (defined $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"}); 
     3546        $sources->{"$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}"} .= "$_"; 
    35763547    } 
    35773548    close(PATCH); 
     
    36003571sub pb_get_postinstall { 
    36013572 
    3602 my $ddir = shift; 
    3603 my $dver = shift; 
    3604 my $darch = shift; 
     3573my $pbos = shift; 
    36053574my $rbspi = shift; 
    36063575my $vestyle = shift; 
     
    36143583} 
    36153584 
    3616 my $postparam = pb_distro_get_param($ddir,$dver,$darch,$rbspi); 
     3585my $postparam = pb_distro_get_param($pbos,$rbspi); 
    36173586if ($postparam eq "") { 
    36183587    $post = ""; 
Note: See TracChangeset for help on using the changeset viewer.