summaryrefslogtreecommitdiffstats
path: root/perl-install/modules.pm
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2001-04-09 00:36:02 +0000
committerdamien <damien@mandriva.com>2001-04-09 00:36:02 +0000
commitc9bca6e16d098fc647d9b18ff0956c5927f8a25f (patch)
tree013900e02345ad0be40db2d0084c10cbb620bc47 /perl-install/modules.pm
parent7594e76d93c3cc6410d222fa261d3937ddb6fc43 (diff)
downloaddrakx-backup-do-not-use-c9bca6e16d098fc647d9b18ff0956c5927f8a25f.tar
drakx-backup-do-not-use-c9bca6e16d098fc647d9b18ff0956c5927f8a25f.tar.gz
drakx-backup-do-not-use-c9bca6e16d098fc647d9b18ff0956c5927f8a25f.tar.bz2
drakx-backup-do-not-use-c9bca6e16d098fc647d9b18ff0956c5927f8a25f.tar.xz
drakx-backup-do-not-use-c9bca6e16d098fc647d9b18ff0956c5927f8a25f.zip
removed use install_any
Diffstat (limited to 'perl-install/modules.pm')
-rw-r--r--perl-install/modules.pm1
1 files changed, 0 insertions, 1 deletions
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index 7622d47f2..2e15fb1bb 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -6,7 +6,6 @@ use vars qw(%drivers);
use common qw(:common :file :system :functional);
use detect_devices;
use run_program;
-use install_any;
use log;
href='#n193'>193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
package move; # $Id$ $

#- Copyright (c) 2003-2004 Mandrakesoft
#-
#- This program is free software; you can redistribute it and/or modify
#- it under the terms of the GNU General Public License as published by
#- the Free Software Foundation; either version 2, or (at your option)
#- any later version.
#-
#- This program is distributed in the hope that it will be useful,
#- but WITHOUT ANY WARRANTY; without even the implied warranty of
#- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#- GNU General Public License for more details.
#-
#- You should have received a copy of the GNU General Public License
#- along with this program; if not, write to the Free Software
#- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use diagnostics;
use strict;

use modules;
use common;
use fs;
use fsedit;
use run_program;
use partition_table qw(:types);
use swap;
use log;
use lang;
use Digest::MD5 qw(md5_hex);

my $key_disabled;

my ($using_existing_user_config, $using_existing_host_config);
my $key_sysconf = '/home/.sysconf';
my $key_part;
my $virtual_key_part;
my $key_mountopts = 'umask=077,uid=501,gid=501,shortname=mixed,nobadchars';

sub symlinkf_short {
    my ($dest, $file) = @_;
    if (my $l = readlink $dest) {
	$dest = $l if $l =~ m!^/!;
    }
    -d $file and log::l("$file already exists and is a directory! writing in directory may be needed, not overwriting"), return;
    symlinkf($dest, $file);
}

sub handle_etcfiles {
    my (@allowed_modes) = @_;
    #- non-trivial files listed from tools/scan-etc.pl
    my ($mode, $allowed);
    foreach (chomp_(cat_('/image/move/etcfiles'))) {
        if (m|^# (\S+)|) {
	    $mode = $1;
	    $allowed = member($mode, @allowed_modes);
	} elsif (m|^/| && $allowed) {
            if ($mode eq 'READ') {
                mkdir_p(dirname($_));
		symlinkf_short("/image$_", $_) if !-e $_;
	    } elsif ($mode eq 'OVERWRITE') {
                mkdir_p(dirname($_));
                cp_f("/image$_", $_);  #- need copy contents
            } elsif ($mode eq 'DIR') {
		mkdir_p $_;
	    }
        }
    }

}

sub handle_virtual_key() {
    return if $key_disabled;
    if (my ($device, $file, $options) = cat_('/proc/cmdline') =~ /\bvirtual_key=([^,\s]+),([^,\s]+)(,\S+)?/) {
        log::l("using device=$device file=$file as a virtual key with options $options");
        my $dir = '/virtual_key_mount';
        mkdir $dir;
        run_program::run('mount', $device, $dir);
        if ($options =~ /format/) {
	    if (! -e "$dir$file") {
		require commands;
		commands::dd("if=/dev/zero", "of=$dir$file", "bs=1M", "count=40");
	    }
	    run_program::run('mkdosfs', "$dir$file");
	}
        require devices;
        my $loop = devices::find_free_loop();
        run_program::run('losetup', $loop, "$dir$file");
        run_program::run('mount', $loop, '/home', '-o', $key_mountopts);
	$virtual_key_part = { device => $loop, mntpoint => '/home', type => 0xc, isMounted => 1 };
    }
}

sub setup_userconf {
    my ($o) = @_;
    if (is_empty_array_ref($o->{users}) && `getent passwd 501` =~ /([^:]+):/) {
        log::l("passwd/501 is $1");
        $o->{users} = [ { name => $1 } ];
	$ENV{HOME} = "/home/$1"; #- used by lang::read()  :-/
        print "using existing user configuration\n";
        $using_existing_user_config = 1;
    }
}

sub lang2move_clp_name {
    my ($lang) = @_;
    my $dir = '/usr/share/locale/' . lang::l2locale($lang);
    my $link = readlink($dir) or return -d $dir ? '' : 'ERROR';
    my ($name) = $link =~ m!image_(i18n_.*?)/! or log::l("ERROR: bad link $link for $dir"), return 'ERROR';
    $name;
}

#- run very soon at stage2 start, setup things on tmpfs rw / that
#- were not necessary to start stage2 itself (there were setup
#- by stage1 of course)
sub init {
    my ($o) = @_;

    $::testing and goto drakx_stuff;

    #- rw things
    mkdir "/$_" foreach qw(home mnt root root/tmp etc var);

    mkdir "/etc/$_" foreach qw(X11);
    touch '/etc/modules.conf';
    touch '/etc/modprobe.conf';
    cp_f('/proc/mounts', '/etc/mtab');

    #- these files need be writable but we need a sensible first contents
    cp_f("/image/etc/$_", '/etc') foreach qw(passwd passwd- group sudoers fstab);

    #- these files are typically opened in read-write mode, we need them copied
    mkdir_p("/etc/$_"), cp_f(glob_("/image/etc/$_/*"), "/etc/$_")
      foreach qw(cups profile.d sysconfig devfs/conf.d);

    #- TODO: cp_af is broken for symlinks to directories
    #- replace below with cp_af is fixed in perl-MDK-Common
    run_program::run('cp', '-a', glob("/image/etc/rc[0-6].d"), '/etc');

    #- directories we badly need as non-links because files will be written in
    handle_etcfiles('DIR');
 
    #- for /etc/sysconfig/networking/ifcfg-lo
    mkdir "/etc/sysconfig/networking";

    #- ro things
    symlinkf_short("/image/etc/$_", "/etc/$_")
      foreach qw(alternatives man.config services shells pam.d inputrc ld.so.conf 
                 DIR_COLORS bashrc profile init.d devfsd.conf gtk-2.0 pango fonts modules.devfs 
                 dynamic hotplug gnome-vfs-2.0 gnome-vfs-mime-magic gtk gconf menu menu-methods nsswitch.conf default login.defs 
                 skel ld.so.cache openoffice xinetd.d xinetd.conf syslog.conf sysctl.conf sysconfig/networking/ifcfg-lo
                 ifplugd);
    symlinkf_short("/image/etc/X11/$_", "/etc/X11/$_")
      foreach qw(encodings.dir app-defaults applnk fs lbxproxy proxymngr rstart wmsession.d xinit xkb xserver xsm);
    symlinkf_short("/image/root/$_", "/root/$_") foreach qw(.bashrc);

    mkdir_p(dirname("/var/$_")), symlinkf_short("/image/var/$_", "/var/$_") foreach qw(lib/samba lib/rpm cache/gstreamer-0.6);

    #- non-trivial files/directories that need be readable, files that will be overwritten
    handle_etcfiles('READ', 'OVERWRITE');

    run_program::run('chown', 'clamav.clamav', '/var/log/clamav/freshclam.log');

    #- create remaining /etc and /var subdirectories if not already copied or symlinked,
    #- because programs most often won't try to create the missing subdir before trying
    #- to write a file, leading to obscure unexpected failures
    foreach (cat_('/image/move/directories-to-create')) {
	my ($mode, $uid, $gid, $name) = split;
	next if -d $name;
	mkdir($name);
	chmod(oct($mode), $name);
	chown($uid, $gid, $name);
    }

    chmod 01777, '/tmp', '/var/tmp';  #- /var/tmp -> badly needed for printing from OOo

    #- remaining non existent /etc files are symlinked from the RO volume,
    #- better to have them RO than non existent.
    #- PB: problems arise when programs try to open then in O_WRONLY
    #- or O_RDWR -> in that case, they should be handled in the
    #- OVERWRITE section of data/etcfiles)
    foreach (chomp_(cat_('/image/move/all-etcfiles'))) {
        -f $_ or symlinkf_short("/image$_", $_);
    }

    #- free up stage1 memory
    eval { fs::umount($_) } foreach qw(/stage1/proc/bus/usb /stage1/proc /stage1);

    #- devfsd needed for devices accessed by old names
    fs::mount("none", "/dev", "devfs", 0);
    fs::mount("none", "/dev/pts", "devpts", 0);
    run_program::run('/sbin/devfsd', '/dev');

    -d '/lib/modules/' . c::kernel_version() or warn("ERROR: kernel package " . c::kernel_version() . " not installed\n"), c::_exit(1);

    $key_disabled = !-e '/cdrom/live_tree_nvidia.clp' && cat_('/proc/mounts') !~ /nfs/;

    run_program::run('/sbin/service', 'syslog', 'start');
    run_program::run('sysctl', '-w', 'kernel.hotplug=/bin/true');
    modules::load_category('bus/usb');