Changeset 1802 in ProjectBuilder for devel/rpmbootstrap


Ignore:
Timestamp:
Dec 23, 2013, 9:22:01 PM (10 years ago)
Author:
Bruno Cornec
Message:
  • Adds mageia 3 VE support
  • Adds rbsmirrorupd feature
  • No -s option for oppatchcmd by default now
  • Start to improve rpmbootstrap for new Fedora mirror
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/rpmbootstrap/bin/rpmbootstrap

    r1661 r1802  
    266266my ($rbscachedir) = pb_conf_get_if("cachedir");
    267267my ($pkgs,$mirror) = pb_distro_get_param($pbos,pb_conf_get("rbsmindep","rbsmirrorsrv"));
     268my ($updater) = pb_distro_get_param($pbos,pb_conf_get_if("rbsmirrorupd"));
    268269die "No packages defined for $pbos->{name}-$pbos->{version}-$pbos->{arch}" unless $pkgs =~ /\w/;
    269270
     
    283284
    284285die "No mirror defined for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}" if ((not defined $mirror) || ($mirror =~ /^\t*$/));
    285 pb_log(0,"Downloading package list from $mirror ...\n");
    286 my $response = $ua->get($mirror);
    287 if (! $response->is_success) {
    288     if ($mirror =~ /i386/) {
    289         # Some distro have an i586 or i686 mirror dir instead for i386
    290         warn "Unable to download package from $mirror for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.".$response->status_line;
    291         $mirror =~ s|/i386/|/i586/|;
    292         $response = $ua->get($mirror);
    293         if (! $response->is_success) {
    294             die "Unable to download package from $mirror for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}".$response->status_line;
    295         }
    296     }
    297 }
    298 pb_log(3,"Mirror $mirror gave answer: ".Dumper($response->dump(maxlength => 0))."\n");
    299 
    300 # Try to find where the repodata structure is for later usage
    301 my $repo = $mirror;
    302 my $found = 0;
    303 if ($pbos->{'install'} =~ /yum/) {
    304     my $response1;
    305     while ($found == 0) {
    306         $response1 = $ua->get("$repo/repodata");
    307         pb_log(2,"REPO analyzed: $repo\n");
    308         if (! $response1->is_success) {
    309             $repo = dirname($repo);
    310 
    311             # There is a limit to the loop, when / is reached and nothing found
    312             my ($scheme, $account, $host, $port, $path) = pb_get_uri($repo);
    313             die "Unable to find the repodata structure of the mirror $mirror\nPlease check the URL or warn the dev team.\n" if (($path =~ /^[\/]+$/) || ($path =~ /^$/));
    314        
    315             # / not reached, so looping
    316             next;
    317         } else {
    318             # repodata found $repo is correct
    319             $found = 1;
    320             pb_log(2,"REPO found: $repo\n");
    321             last;
    322         }
    323     }
     286my $resp;
     287my @list_pkg;
     288
     289$resp = rbs_mirror_response($mirror);
     290@list_pkg = split(/\n/,$resp->as_string());
     291
     292# If an update source is availble add it after so that these pkgs update the main ones
     293if (defined $updater) {
     294    $resp = rbs_mirror_response($mirror.$updater);
     295    push(@list_pkg,split(/\n/,$resp->as_string()));
    324296}
    325297
     
    327299my $parch = $pbos->{'arch'};
    328300$parch = "i[3456]86" if ($pbos->{'arch'} eq "i386");
     301my $repowithletter = 0;
    329302
    330303# Get the list of packages and their URL in this hash
    331304my %url;
    332 foreach my $l (split(/\n/,$response->as_string())) {
    333     # Find a href ref in first pos
    334     if ($l =~ /<a href="([^<>]*)">([^<>]*)<\/a>/i) {
    335         my $url = $1;
    336         my $pkg = $1;
    337         my $desc = $2;
    338         pb_log(3,"Found desc URL $desc: ");
    339         # find an rpm package ref name-ver-tag.arch.rpm
    340         if ($pkg =~ /(.+)-([^-]+)-([^-]+)\.(noarch|$parch)\.rpm$/) {
    341             pb_log(3,"package ($1 + $2 + $3 + $4)\n");
    342             $url{$1} = "$mirror/$url";
     305foreach my $l (@list_pkg) {
     306    my ($url,$desc) = rbs_find_pkg($l,$parch,"pkg");
     307    if (defined $url) {
     308        $url{$url} = "$mirror/$desc";
     309    } else {
     310        pb_log(3,"not a package, maybe a dir containing packages\n");
     311        my $response1 = $ua->get("$mirror/Packages");
     312        # Check if we have a fedora 17/18 type of repo
     313        if ($response1->is_success) {
     314            foreach my $d (split(/\n/,$response1->as_string())) {
     315                ($url,$desc) = rbs_find_pkg($d,$parch,"dir");
     316                if (defined $url) {
     317                    # Here we have the dir in which are packages
     318                    my $response2 = $ua->get("$mirror/Packages/$desc");
     319                    foreach my $p (split(/\n/,$response2->as_string())) {
     320                        ($url,$desc) = rbs_find_pkg($d,$parch,"dir");
     321                        if (defined $url) {
     322                            $url{$p} = "$mirror/$desc";
     323                        } else {
     324                            pb_log(3,"not a package, and not a dir containing packages\n");
     325                        }
     326                    }
     327                } else {
     328                }
     329            }
    343330        } else {
    344             pb_log(3,"not a package\n");
    345331        }
    346332    }
     
    508494        pb_system("sed -i -e 's/^mirrorlist/#mirrorlist/' $i","","quiet");
    509495        # rather use neutral separators here
    510         pb_system("sed -i -e 's|^#baseurl.*\$|baseurl=$repo|' $i","","quiet");
     496        pb_system("sed -i -e 's|^#baseurl.*\$|baseurl=$mirror|' $i","","quiet");
    511497    }
    512498    $minipkglist = "ldconfig yum passwd vim-minimal dhclient authconfig";
     
    637623    unlink($_) if ($_ =~ /\.rpmnew$/);
    638624}
     625
     626# Function to store packages found on Web pages
     627
     628sub rbs_find_pkg {
     629
     630my $l = shift;
     631my $parch = shift;
     632my $type = shift;
     633
     634pb_log(2,"Entering rbs_find_pkg with l=$l and parch=$parch\n");
     635# Find a href ref in first pos
     636if ($l =~ /<a href="([^<>]*)">([^<>]*)<\/a>/i) {
     637    my $pkg = $1;
     638    my $desc = $2;
     639    pb_log(3,"Found desc URL $desc: ");
     640    # find an rpm package ref name-ver-tag.arch.rpm
     641    if (($type eq "pkg") && ($pkg =~ /(.+)-([^-]+)-([^-]+)\.(noarch|$parch)\.rpm$/)) {
     642        pb_log(3,"package ($1 + $2 + $3 + $4)\n");
     643        my $url = $1;
     644        pb_log(2,"Exiting rbs_find_pkg with url=$url and desc=$desc\n");
     645        return($url,$desc);
     646    } elsif (($type eq "dir") && ($pkg =~ /([0-z])\//)) {
     647        my $url = $1;
     648        pb_log(3,"dir ($1)\n");
     649        return($url,$1);
     650    } else {
     651        pb_log(3,"not a package\n");
     652    }
     653}
     654pb_log(2,"Exiting rbs_find_pkg with undef\n");
     655return(undef,undef);
     656}
     657
     658sub rbs_mirror_response {
     659
     660my $mirror = shift;
     661
     662pb_log(0,"Downloading package list from $mirror ...\n");
     663my $response = $ua->get($mirror);
     664if (! $response->is_success) {
     665    if ($mirror =~ /i386/) {
     666        # Some distro have an i586 or i686 mirror dir instead for i386
     667        warn "Unable to download package from $mirror for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}.".$response->status_line;
     668        $mirror =~ s|/i386/|/i586/|;
     669        pb_log(0,"Downloading now package list from $mirror ...\n");
     670        $response = $ua->get($mirror);
     671        if (! $response->is_success) {
     672            die "Unable to download package from $mirror for $pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}".$response->status_line;
     673        }
     674    }
     675}
     676pb_log(3,"Mirror $mirror gave answer: ".Dumper($response->dump(maxlength => 0))."\n");
     677
     678# Try to find where the repodata structure is for later usage
     679my $repo = $mirror;
     680my $found = 0;
     681if ($pbos->{'install'} =~ /yum/) {
     682    my $response1;
     683    while ($found == 0) {
     684        $response1 = $ua->get("$repo/repodata");
     685        pb_log(2,"REPO analyzed: $repo\n");
     686        if (! $response1->is_success) {
     687            $repo = dirname($repo);
     688
     689            # There is a limit to the loop, when / is reached and nothing found
     690            my ($scheme, $account, $host, $port, $path) = pb_get_uri($repo);
     691            die "Unable to find the repodata structure of the mirror $mirror\nPlease check the URL or warn the dev team.\n" if (($path =~ /^[\/]+$/) || ($path =~ /^$/));
     692       
     693            # / not reached, so looping
     694            next;
     695        } else {
     696            # repodata found $repo is correct
     697            $found = 1;
     698            pb_log(2,"REPO found: $repo\n");
     699            last;
     700        }
     701    }
     702}
     703return($response);
     704}
     705
Note: See TracChangeset for help on using the changeset viewer.