Changeset 984 in ProjectBuilder for devel/rpmbootstrap/bin
- Timestamp:
- Feb 20, 2010, 5:33:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/rpmbootstrap/bin/rpmbootstrap
r983 r984 15 15 use English; 16 16 use LWP::UserAgent; 17 #use File::Basename; 18 #use File::Copy; 17 use File::Basename; 18 use File::Copy; 19 use File::Find; 19 20 use ProjectBuilder::Version; 20 21 use ProjectBuilder::Base; … … 82 83 83 84 Name of the script you want to execute on the related VEs after the installation. 85 It is executed in host environment. You can use the chroot command to execute actions in the VE. 84 86 85 87 =item B<-i|--iso iso_image> … … 138 140 139 141 pb_syntax_init("$appname Version $projectbuilderver-$projectbuilderrev\n"); 142 pb_temp_init(); 140 143 141 144 GetOptions("help|?|h" => \$opts{'h'}, … … 188 191 # Initialize distribution info from pb conf file 189 192 # 193 pb_log(0,"Starting VE build for $ENV{'PBV'}\n"); 190 194 my ($name,$ver,$darch) = split(/-/,$ENV{'PBV'}); 191 195 chomp($darch); 192 my ($ddir, $dver, $dfam, $dtype, $pbsuf, $ dsuf, $dupd) = pb_distro_init($name,$ver,$darch);196 my ($ddir, $dver, $dfam, $dtype, $pbsuf, $pbupd) = pb_distro_init($name,$ver,$darch); 193 197 194 198 # … … 238 242 $ua->env_proxy; 239 243 244 pb_log(0,"Downloading package list from $mirror ...\n"); 240 245 my $response = $ua->get($mirror); 241 246 if (! $response->is_success) { … … 267 272 } 268 273 274 # 275 # Prepare early the yum cache env for the VE in order to copy in it packages on the fly 276 # 277 if ($pbupd =~ /yum/) { 278 pb_log(1,"Setting up YUM cache in VE\n"); 279 pb_mkdir_p("$vepath/var/cache/yum/core/packages/"); 280 pb_mkdir_p("$vepath/var/cache/yum/updates-released/packages/"); 281 } 269 282 270 283 # For each package to process, get it, put it in the cache dir … … 277 290 pb_log(1,"Processing package $p ...\n"); 278 291 # Just print packages names if asked so. 279 if ( $opts{'p'}) {280 if ( defined $url{$p}) {292 if (defined $url{$p}) { 293 if ($opts{'p'}) { 281 294 pb_log(0,"$url{$p}\n"); 295 next; 282 296 } else { 283 pb_log(0,"WARNING: unable to find URL for $p\n"); 284 $warning++; 285 $lwpkg .= " $p"; 297 # Now download if not already in cache 298 my $p1 = basename($url{$p}); 299 if (! -f "$cachedir/$p1") { 300 pb_system("wget --quiet -O $cachedir/$p1 $url{$p}","Downloading package $p1 ..."); 301 } else { 302 pb_log(1,"Package $p1 already in cache\n"); 303 } 304 305 # End if download only 306 if ($opts{'d'}) { 307 next; 308 } 309 310 # 311 # Copy the cached .RPM files into the yum directory, so that yum doesn't need to make them again. 312 # 313 if ($pbupd =~ /yum/) { 314 pb_log(1,"Link package into $vepath/var/cache/yum/core/packages\n"); 315 link("$cachedir/$p1","$vepath/var/cache/yum/core/packages/"); 316 link("$cachedir/$p1","$vepath/var/cache/yum/$darch/$dver/"); 317 symlink("$vepath/var/cache/yum/core/packages/$p1","$vepath/var/cache/yum/updates-released/packages/"); 318 } 319 320 # And extract it to the finale dir 321 pb_system("cd $vepath ; rpm2cpio $cachedir/$p1 | cpio -ivdum","Extracting package $p1 into $vepath"); 322 323 # Remove cached package if not asked to keep 324 if (! $opts{'k'}) { 325 unlink("$cachedir/$p1"); 326 } 327 286 328 } 287 next; 329 } else { 330 pb_log(0,"WARNING: unable to find URL for $p\n"); 331 $warning++; 332 $lwpkg .= " $p"; 288 333 } 289 334 } … … 293 338 } 294 339 295 # We Just printed packages names so now end340 # Stop here if we just print 296 341 if ($opts{'p'}) { 297 342 exit(0); 298 343 } 344 345 # Now executes the VE finalization steps required for it to work correctly 346 pb_log(0,"VE post configuration\n"); 347 348 # yum needs that distro-release package be installed, so force it 349 350 foreach my $p1 (<$cachedir/($ddir|redhat)-release-*.rpm>) { 351 copy("$cachedir/$p1","$vepath/tmp"); 352 pb_system("chroot $vepath rpm -ivh --force --nodeps /tmp/$p1","Forcing RPM installation of $p1"); 353 unlink("$vepath/tmp/$p1"); 354 } 355 # 356 # Make sure there is a resolv.conf file present, such that DNS lookups succeed. 357 # 358 pb_log(1,"Creating resolv.conf\n"); 359 pb_mkdir_p("$vepath/etc"); 360 copy("/etc/resolv.conf","$vepath/etc/"); 361 362 # 363 # BUGFIX: 364 # 365 if (($ddir eq "centos") && ($dver eq "5")) { 366 pb_log(1,"BUGFIX for centos-5\n"); 367 pb_mkdir_p("$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx"); 368 foreach my $i (<$vepath/usr/lib/python2.4/site-packages/urlgrabber/keepalive.*>) { 369 move($i,"$vepath/usr/lib/python2.4/site-packages/urlgrabber.skx/"); 370 } 371 } 372 373 # 374 # /proc needed 375 # 376 pb_mkdir_p("$vepath/proc"); 377 pb_system("mount -o bind /proc $vepath/proc","Mounting /proc"); 378 379 # 380 # Some devices may be needed 381 # 382 pb_system("mknod -m 644 $vepath/dev/random c 1 8","Creating $vepath/dev/random") if (! -c "$vepath/dev/random"); 383 pb_system("mknod -m 644 $vepath/dev/urandom c 1 9","Creating $vepath/dev/urandom") if (! -c "$vepath/dev/urandom"); 384 pb_system("mknod -m 666 $vepath/dev/zero c 1 5","Creating $vepath/dev/zero") if (! -c "$vepath/dev/zero"); 385 386 if ($pbupd =~ /yum/) { 387 # 388 # Force the architecture for yum 389 # The goal is to allow i386 chroot on x86_64 390 # 391 # FIX: Not sufficient to have yum working 392 # mirrorlist is not usable 393 # $releasever also needs to be filtered 394 # yum.conf as well 395 foreach my $i (<$vepath/etc/yum.repos.d/*>,"$vepath/etc/yum.conf") { 396 pb_system("sed -i -e 's/\$basearch/$darch/g' $i","","quiet"); 397 pb_system("sed -i -e 's/\$releasever/$dver/g' $i","","quiet"); 398 pb_system("sed -i -e 's/^mirrorlist/#mirrorlist/' $i","","quiet"); 399 pb_system("sed -i -e 's/^#baseurl/baseurl/' $i","","quiet"); 400 } 401 402 # 403 # Run "yum install the necessary modules". 404 # No need for sudo here 405 # 406 $pbupd =~ s/sudo//g; 407 pb_system("chroot $vepath /bin/bash -c \"$pbupd ldconfig yum passwd vim-minimal dhclient authconfig\"","Bootstrapping yum"); 408 } 409 410 # 411 # make 'passwd' work. 412 # 413 pb_log(1,"Authfix\n"); 414 pb_system("chroot $vepath /bin/bash -c \"if [ -x /usr/bin/authconfig ]; then /usr/bin/authconfig --enableshadow --update; fi\"","Calling authconfig"); 415 416 # 417 # Clean up 418 # 419 pb_log(1,"Cleaning up\n"); 420 if ($pbupd =~ /yum/) { 421 pb_system("chroot $vepath /usr/bin/yum clean all","Cleaning yum"); 422 } 423 pb_system("umount $vepath/proc","Unmounting /proc"); 424 find(\&unlink_old_conf, $vepath); 425 426 # Add additional packages if asked for 427 428 # Executes post-install step if asked for 429 if ($opts{'s'}) { 430 pb_system("$opts{'s'} $vepath","Executing the post-install script: $opts{'s'} $vepath"); 431 } 432 433 # Function for File::Find 434 sub unlink_old_conf { 435 436 unlink($_) if ($_ =~ /\.rpmorig$/); 437 unlink($_) if ($_ =~ /\.rpmnew$/); 438 } 439 440
Note:
See TracChangeset
for help on using the changeset viewer.