Changeset 702 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Distribution.pm
- Timestamp:
- Feb 19, 2009, 4:42:22 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r698 r702 11 11 use Data::Dumper; 12 12 use ProjectBuilder::Base; 13 use ProjectBuilder::Conf; 14 use File::Basename; 15 use File::Copy; 13 16 14 17 # Inherit from the "Exporter" module which handles exporting functions. … … 20 23 21 24 our @ISA = qw(Exporter); 22 our @EXPORT = qw(pb_distro_init pb_distro_get pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed );25 our @EXPORT = qw(pb_distro_init pb_distro_get pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_get_param); 23 26 24 27 =pod … … 469 472 } 470 473 474 =over 4 475 476 =item B<pb_distro_setuprepo> 477 478 This function sets up potential additional repository to the build environment 479 480 =cut 481 482 sub pb_distro_setuprepo { 483 484 my $ddir = shift || undef; 485 my $dver = shift; 486 my $darch = shift; 487 my $dtype = shift || undef; 488 489 my ($addrepo) = pb_conf_read("$ENV{'PBDESTDIR'}/pbrc","addrepo"); 490 return if (not defined $addrepo); 491 492 my $param = pb_distro_get_param($ddir,$dver,$darch,$addrepo); 493 return if ($param eq ""); 494 495 # Loop on the list of additional repo 496 foreach my $i (split(/,/,$param)) { 497 498 my ($scheme, $account, $host, $port, $path) = pb_get_uri($i); 499 my $bn = basename($i); 500 501 # The repo file can be local or remote. download or copy at the right place 502 if (($scheme eq "ftp") || ($scheme eq "http")) { 503 pb_system("wget -O $ENV{'PBTMP'}/$bn $i","Donwloading additional repository file $i"); 504 } else { 505 copy($i,$ENV{'PBTMP'}/$bn); 506 } 507 508 # The repo file can be a real file or a package 509 if ($dtype eq "rpm") { 510 if ($bn =~ /\.rpm$/) { 511 pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repostory"); 512 } elsif ($bn =~ /\.repo$/) { 513 # Yum repo 514 pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repo.d","Adding yum repository"); 515 } elsif ($bn =~ /\.addmedia/) { 516 # URPMI repo 517 pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository"); 518 } else { 519 pb_log(0,"Unable to deal with repository file $i on rpm distro ! Please report to dev team\n"); 520 } 521 } elsif ($dtype eq "deb") { 522 if ($bn =~ /\.sources.list$/) { 523 my $aptrepo = ""; 524 open(REPO,"$ENV{'PBTMP'}/$bn") || die "Unable to open $ENV{'PBTMP'}/$bn"; 525 while (my $repo=<REPO>) { 526 my $found = 0; 527 open(APT,"/etc/apt/sources.list") || die "Unable to open /etc/apt/sources.list"; 528 while (my $apt=<APT>) { 529 $found++ if ($apt =~ /$repo/); 530 } 531 close(APT); 532 $aptrepo .= "$repo\n" if ($found == 0); 533 } 534 close(REPO); 535 if ($aptrepo ne "") { 536 pb_system("sudo echo # Added by project-builder.org >> /etc/apt/sources.list"); 537 pb_system("sudo echo # >> /etc/apt/sources.list"); 538 pb_system("sudo echo \'$aptrepo\' >> /etc/apt/sources.list"); 539 } 540 pb_system("sudo apt-get update","Adding apt repository"); 541 } else { 542 pb_log(0,"Unable to deal with repository file $i on deb distro ! Please report to dev team\n"); 543 } 544 } else { 545 pb_log(0,"Unable to deal with repository file $i on that distro ! Please report to dev team\n"); 546 } 547 } 548 return; 549 } 550 551 =over 4 552 553 =item B<pb_distro_get_param> 554 555 This function gets the parameter in the conf file from the most precise tuple up to default 556 557 =cut 558 559 sub pb_distro_get_param { 560 561 my $param = ""; 562 my $ddir = shift; 563 my $dver = shift; 564 my $darch = shift; 565 my $opt = shift; 566 567 if (defined $opt->{"$ddir-$dver-$darch"}) { 568 $param = $opt->{"$ddir-$dver-$darch"}; 569 } elsif (defined $opt->{"$ddir-$dver"}) { 570 $param = $opt->{"$ddir-$dver"}; 571 } elsif (defined $opt->{"$ddir"}) { 572 $param = $opt->{"$ddir"}; 573 } elsif (defined $opt->{"default"}) { 574 $param = $opt->{"default"}; 575 } else { 576 $param = ""; 577 } 578 return($param); 579 580 } 471 581 =back 472 582
Note:
See TracChangeset
for help on using the changeset viewer.