summaryrefslogtreecommitdiffstats
path: root/perl-install/pixmaps/bootloader.png
blob: a4f0e024bb950a56fc2b002fc092084ca2d2dc95 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 20 00 00 00 20 08 06 00 00 00 73 7a 7a .PNG........IHDR.............szz
0020 f4 00 00 00 04 67 41 4d 41 00 00 d6 d8 d4 4f 58 32 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 .....gAMA.....OX2....tEXtSoftwar
0040 65 00 41 64 6f 62 65 20 49 6d 61 67 65 52 65 61 64 79 71 c9 65 3c 00 00 07 39 49 44 41 54 78 da e.Adobe.ImageReadyq.e<...9IDATx.
0060 62 fc ff ff 3f 03 2d 80 89 49 3a 33 90 fa 83 26 2c 70 e2 c4 d4 8f 2c 2c 2c 70 01 80 00 62 62 a0 b...?.-..I:3...&,p....,,,p...bb.
0080 11 50 51 91 06 fb ac be 54 8f a1 26 f9 03 5c fc d7 af 5f 28 ea 00 02 88 66 0e b8 73 e7 e9 df 90 .PQ.....T..&..\..._(....f..s....
00a0 00 5d 06 77 cb af 0c ac bf cf c2 84 bf fc fd fb 97 01 39 d4 01 02 88 85 1c c3 41 06 30 32 32 c2 .].w..............9.......A.022.
00c0 82 1a 25 0e 3d 3d cd 59 b7 6f 3f f9 db dc 5c 93 21 36 88 87 e1 ff b7 73 0c bc 5c af e0 f2 bc bc ..%.==.Y.o?...\.!6.....s..\.....
00e0 bc 28 66 01 04 10 59 0e 80 59 0e 03 f3 27 e8 31 5c be f1 83 e1 dd 47 06 86 05 cb 4f fe d6 d1 51 .(f...Y..Y...'.1\.....G....O...Q
0100 64 f0 77 e5 66 10 e5 7e ce f0 e7 cd 65 06 76 56 88 1b 59 59 59 98 80 0e 06 b3 cf 9c 99 f9 17 44 d.w.f..~....e.vV..YYY..........D
0120 03 04 10 0b 25 c1 5c 5b 3b 0f ac ff d1 9d 8b 0c c1 b6 4c 0c 8c 6c 22 0c 69 61 2a 40 17 72 30 30 ....%.\[;.........L..l".ia*@.r00
0140 fc 7d c1 f0 ef f3 45 86 ff bf 9e 33 28 48 b1 32 b8 98 bc 67 d8 73 46 10 9e 00 92 92 3a 99 e7 cd .}....E....3(H.2...g.sF.....:...
0160 2b ff 07 10 40 8c 35 35 73 19 81 41 f6 8f 5c 47 00 7d fb e9 dd eb 17 7c 0d 49 e7 19 34 e4 3e 32 +...@.55s..A..\G.}.....|.I..4.>2
0180 30 32 b1 03 1d c0 0a 8c a7 9f 0c ff 7e bd 61 60 f8 f7 8d 81 81 89 0b 88 54 19 ae 3e 35 60 b8 f1 02..........~.a`........T..>5`..
01a0 88 97 e1 f6 c3 ff 0c 5b 77 3f 05 eb 07 08 20 46 63 e3 b4 ff 3e 3e 56 0c 7c 7c fc 0c bf 7f ff 21 .......[w?.....Fc...>>V.||.....!
01c0 c9 f2 3f 7f fe 32 fc fc f9 87 e1 eb d7 9f 0c 1c cc ef 18 72 3c 16 33 70 b3 3c 63 60 62 fc cd c0 ..?..2.............r<.3p.<c`b...
01e0 c8 f0 1f 91 ce 99 d8 18 18 58 f8 18 98 98 f9 40 f1 c7 f0 ef e7 53 86 1b f7 7e 32 a4 4f 08 65 00 .........X.....@.....S...~2.O.e.
0200 08 20 70 10 32 01 15 04 04 04 30 fc fb 07 4a 60 0c 0c 9f 3e 7d 62 f8 f8 f1 13 b1 49 12 ac ef f7 ..p.2.....0...J`...>}b.....I....
0220 ef 7f 0c f7 7f cb 31 18 70 57 31 fc ff 0d cc 76 ff 7f 83 65 ff 01 e1 af 1f 3f 18 5e bc fd c6 70 ......1.pW1....v...e.....?.^...p
0240 ff d9 33 86 47 2f fe 33 3c 7c c1 c9 70 e6 b6 16 58 1e 20 80 c0 0e f8 f2 e5 27 d0 27 20 43 18 18 ..3.G/.3<|..p...X........'.'.C..
0260 56 ae 5c c5 f0 e0 c1 03 06 71 71 71 06 1e 1e 1e b0 a2 9f 3f 7f 01 e5 7e 01 d5 7d c1 ea 84 7f ff V.\......qqq.......?...~..}.....
0280 20 be 35 55 7f c2 60 e8 2c 06 8c ff ef 0c ff ff 42 1d 00 74 dc db 8f ff 18 2e df fe c7 70 f2 1a ..5U..`.,.......B..t.........p..
02a0 07 c3 85 7b aa 0c 9f 7f eb 83 e5 3e 7d 7a c2 0c 10 40 2c 30 03 40 0a cf 9f bf c4 70 f3 e6 5d 06 ...{.......>}z...@,0.@.....p..].
02c0 4b 4b 4b 70 81 f1 ea d5 2b 86 6f df be 21 a5 7e 56 ac 0e 60 66 86 d0 be d6 4f 81 16 7f 65 f8 f9 KKKp....+.o..!.~V..`f....O...e..
02e0 e3 0b c3 af df ff 81 a9 9e 91 01 94 5f be fd 60 60 78 f8 92 8b 61 f7 45 27 06 0e 0e 01 86 0f 1f ............_..``x...a.E'.......
0300 1e 32 cf 9e 5d fe 4f 4c 4c 8c 01 20 80 50 72 c1 d3 a7 4f 19 94 95 95 c1 3e 7d 06 0c 2e 52 80 b9 .2..].OLL....Pr...O.....>}...R..
0320 e6 63 06 41 b6 ab 0c af 5f dc 67 78 fa ea 1f d0 51 8c 0c 82 c0 28 e7 e5 02 46 3f d0 81 bf fe 72 .c.A...._.gx....Q....(...F?....r
0340 83 2d ef ec 0c 63 14 12 12 62 90 90 90 00 a6 3b 3e 06 80 00 c2 28 09 b9 b8 b8 18 5e be 7c 89 28 .-...c...b.....;>....(.....^.|.(
0360 2a 99 7e 33 14 87 ed 62 60 65 78 82 d3 72 4e b6 9f 0c fe 06 4b 19 1e dc bf cd 70 f2 86 00 c3 fe *.~3...b`ex..rN.....K.....p.....
0380 1b fe 0c 8b 4e b6 30 5c 7f 61 c7 f0 ed 27 38 dd 31 c8 08 43 8a 63 90 e5 d2 d2 d2 0c a2 a2 a2 60 ....N.0\.a...'8.1..C.c.........`
03a0 bb 00 02 08 a3 1c f8 fc f9 33 03 a8 b8 84 01 50 2a 57 93 ba c7 e0 a4 75 97 61 e7 b5 4c ac 0e 10 .........3.....P*W.....u.a..L...
03c0 e4 7e cb 70 f0 b2 02 c3 c9 bb b1 0c 1f be 4b c3 c5 cf be 48 65 90 91 91 64 f8 fe 79 39 c3 bf ff .~.p..........K....He...d..y9...
03e0 90 22 80 9d 9d 9d 81 93 93 93 01 56 21 01 04 10 c1 ba 80 89 89 95 e1 fe 13 66 06 5d 85 e7 18 15 .".........V!............f.]....
0400 09 0c 3c 7b 2f c5 b0 f3 4a 04 8a e5 b0 22 fb 1d 67 0b c3 d1 6b 9a 0c 6f 3e 40 8a 1a f4 ba 00 20 ..<{/...J...."..g...k..o>@......
0420 80 58 60 0a 91 43 00 35 81 b1 30 bc fd c4 c9 60 a2 ca c8 a0 28 7a 85 41 4e 9a 8b e1 f8 35 35 a2 .X`..C.5..0....`....(z.AN....55.
0440 ea 31 90 b9 3f 7f fe 60 38 70 dd 81 81 f3 cf 7f 68 d9 81 5a d6 00 04 10 0b b6 b2 1d 1d 3c 79 2b .1..?..`8p......h..Z.........<y+
0460 c5 60 a2 fe 94 a1 2e 6e 37 30 45 89 30 38 19 5c 65 78 f8 f8 13 c3 bc bd d1 0c 6c 6c 6c 44 39 e4 .`.....n70E.08.\ex........lllD9.
0480 e1 3b 63 a0 e7 9e b3 72 73 73 33 20 b7 07 00 02 88 a8 ea f8 fc 3d 35 70 f1 7a f7 11 13 c3 dd 7b .;c....rss3..........=5p.z.....{
04a0 ef 18 7e 7d b9 cd a0 2e 71 8e e1 dd bb 37 44 55 5c 30 0f ae 5a d5 fc 07 94 08 91 1d 0d 10 40 44 ..~}....q....7DU\0..Z.........@D
04c0 39 c0 50 e5 11 d0 1b bf 18 b8 d9 de 33 dc 7d c2 c5 70 e6 1a 1f 03 33 d3 2f 06 2b b5 7d 44 d6 9e 9.P.........3.}..p....3./.+.}D..
04e0 10 6b 40 89 0f 84 99 61 05 07 10 00 04 10 51 b5 a1 92 c8 65 60 31 f9 92 41 4c e0 1b 83 30 2f 3b .k@....a......Q....e`1..AL...0/;
0500 c3 b7 ef dc c0 82 06 98 fa b9 5e 00 8b 33 ca aa 73 80 00 c2 70 80 80 00 a8 a4 fa 80 22 76 e4 02 ..........^..3..s...p......."v..
0520 3f 83 82 d0 37 70 69 a9 24 f9 8c 41 5c 80 01 58 b6 33 30 bc ff 4c 51 6d 0e 06 00 01 44 94 09 17 ?...7pi.$..A\..X.30..LQm....D...
0540 9f 47 30 7c db fc 89 c1 c3 f4 2c c3 d7 ef 0c 0c af 3f b0 00 ab 55 61 86 5b 6f 7c 19 58 38 29 73 .G0|......,......?...Ua.[o|.X8)s
0560 00 40 00 61 38 00 94 40 40 71 84 5c 18 81 c0 ed 4f 69 0c 0f b7 6f 07 06 fd 5f 86 57 5f 0d 19 c4 .@.a8..@@q.\....Oi...o..._.W_...
0580 c4 a4 29 b6 1c 04 00 02 08 25 11 ea ea ea 32 5c bf 7e 1d 5c 1f 80 8a 49 74 f0 8b cd 93 81 81 db ..)......%....2\.~.\...It.......
05a0 07 6c 39 21 00 aa c8 84 85 85 08 aa 03 08 20 94 10 90 91 91 61 70 70 70 60 d8 bb 77 2f 38 b5 42 .l9!................appp`..w/8.B
05c0 aa ea 2f 24 fb 0a 14 82 06 06 06 0c e6 e6 16 0c ef df bf c4 ab 16 20 80 58 60 c5 23 a8 2d f0 f5 ../$....................X`.#.-..
05e0 eb 57 60 13 4b 03 18 12 5a e0 12 90 95 15 12 1d 90 54 cb 88 b3 41 02 d1 ff 0b 48 ff 01 26 d4 7f .W`.K...Z........T...A....H..&..
0600 60 31 88 e3 3f 32 7c ff fe 0d 58 10 e1 6e f1 01 04 10 b4 41 f2 03 58 fd 3e 06 ba f6 35 d8 20 16 `1..?2|...X..n.....A..X.>...5...
0620 16 56 06 7e 7e 41 20 16 06 56 a1 dc 28 f9 16 5b 63 e4 c7 8f ef c0 9c f3 0a 68 ce 27 a0 fe 9f 0c .V.~~A...V..(..[c........h.'....
0640 b0 92 fd df bf bf c0 fa e3 27 d8 4c 98 47 21 0e 44 00 80 00 02 3b e0 e6 cd 5b c0 16 6e 13 50 e3 .........'.L.G!.D....;...[..n.P.
0660 5f b0 66 48 e9 c5 c4 e0 e3 e3 c3 e0 ef ef 0f 16 e3 65 38 c0 f0 93 41 81 81 9d e1 01 c3 5f 06 01 _.fH.............e8...A......_..
0680 06 36 20 fd 8d c1 80 e1 07 83 1c d0 e0 df 0c bb 77 ef 61 38 72 e4 04 46 48 81 cc fc fb f7 27 b0 .6..............w.a8r..FH.....'.
06a0 16 e4 c7 ea 01 80 00 62 e1 e4 64 67 3d 74 68 12 46 6b d4 d4 34 e3 3f 3f 3f 27 b8 b5 03 ca 10 32 .......b..dg=th.Fk..4.???'.....2
06c0 ff 0b 19 3e 32 04 30 f0 00 1d 02 72 00 c8 41 cf 18 ea 19 5e 32 e6 01 0d e7 04 76 38 04 81 6a d9 ...>2.0....r..A....^2.....v8..j.
06e0 40 ed 7d ac 71 a5 ad 1d c6 05 4a d8 ac ac a8 ad 2a 80 00 02 b7 8a 1d 1d 8d 19 d4 d4 d4 81 c1 f5 @.}.q.....J.....*...............
0700 07 29 f8 fe 33 28 28 28 02 1b 0f 4a c0 b4 f1 19 1c 9c f8 8a da 87 0f 1f 31 3c 79 f2 98 81 9b 9b .)..3(((...J............1<y.....
0720 0d dc 1a 82 99 f1 fd fb 1f 86 5d bb f6 00 1b b9 9f 19 b6 6c 69 64 44 af 0b 00 02 08 1c 05 2f 5f ..........]........lidD......./_
0740 7e 63 70 77 d7 04 36 12 df c3 eb 6b 50 b0 be 7b f7 0a 98 36 1e 80 e3 10 5f 27 1a 14 65 ac ac ec ~cpw..6....kP..{...6...._'..e...
0760 40 c7 0a 03 0d e7 00 27 60 48 d5 fb 1b 9c 30 59 59 21 f1 0e 4a e4 a0 66 18 b2 03 00 02 08 ac f2 @......'`H....0YY!..J..f........
0780 da b5 eb 0c 15 15 b5 0c b4 06 a0 06 2e 7a 01 07 10 60 00 76 21 c6 bd 17 82 5e d6 00 00 00 00 49 .............z...`.v!....^.....I
07a0 45 4e 44 ae 42 60 82 END.B`.
id='n390' href='#n390'>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 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
package install_any; # $Id$

use diagnostics;
use strict;

use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $boot_medium @advertising_images);

@ISA = qw(Exporter);
%EXPORT_TAGS = (
    all => [ qw(getNextStep spawnShell addToBeDone) ],
);
@EXPORT_OK = map { @$_ } values %EXPORT_TAGS;

#-######################################################################################
#- misc imports
#-######################################################################################
use MDK::Common::System;
use common;
use run_program;
use partition_table qw(:types);
use partition_table::raw;
use devices;
use fsedit;
use modules;
use detect_devices;
use lang;
use any;
use log;
use fs;

#- boot medium (the first medium to take into account).
$boot_medium = 1;

#-######################################################################################
#- Media change variables&functions
#-######################################################################################
my $postinstall_rpms = '';
my $current_medium = $boot_medium;
my $asked_medium = $boot_medium;
my $cdrom;
sub useMedium($) {
    #- before ejecting the first CD, there are some files to copy!
    #- does nothing if the function has already been called.
    $_[0] > 1 and $::o->{method} eq 'cdrom' and setup_postinstall_rpms($::prefix, $::o->{packages});

    $asked_medium eq $_[0] or log::l("selecting new medium '$_[0]'");
    $asked_medium = $_[0];
}
sub changeMedium($$) {
    my ($method, $medium) = @_;
    log::l("change to medium $medium for method $method (refused by default)");
    0;
}
sub relGetFile($) {
    local $_ = $_[0];
    m|\.rpm$| ? "$::o->{packages}{mediums}{$asked_medium}{rpmsdir}/$_" : $_;
}
sub askChangeMedium($$) {
    my ($method, $medium) = @_;
    my $allow;
    do {
	eval { $allow = changeMedium($method, $medium) };
    } while ($@); #- really it is not allowed to die in changeMedium!!! or install will cores with rpmlib!!!
    log::l($allow ? "accepting medium $medium" : "refusing medium $medium");
    $allow;
}
sub errorOpeningFile($) {
    my ($file) = @_;
    $file eq 'XXX' and return; #- special case to force closing file after rpmlib transaction.
    $current_medium eq $asked_medium and log::l("errorOpeningFile $file"), return; #- nothing to do in such case.
    $::o->{packages}{mediums}{$asked_medium}{selected} or return; #- not selected means no need for worying about.

    my $max = 32; #- always refuse after $max tries.
    if ($::o->{method} eq "cdrom") {
	cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image), and $cdrom = $1;
	return unless $cdrom;
	ejectCdrom($cdrom);
	while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) {
	    $current_medium = $asked_medium;
	    eval { fs::mount($cdrom, "/tmp/image", "iso9660", 'readonly') };
	    my $getFile = getFile($file); 
	    $getFile && @advertising_images and copy_advertising($::o);
	    $getFile and return $getFile;
	    $current_medium = 'unknown'; #- don't know what CD is inserted now.
	    ejectCdrom($cdrom);
	    --$max;
	}
    } else {
	while ($max > 0 && askChangeMedium($::o->{method}, $asked_medium)) {
	    $current_medium = $asked_medium;
	    my $getFile = getFile($file); $getFile and return $getFile;
	    $current_medium = 'unknown'; #- don't know what CD image has been copied.
	    --$max;
	}
    }

    #- keep in mind the asked medium has been refused on this way.
    #- this means it is no more selected.
    $::o->{packages}{mediums}{$asked_medium}{selected} = undef;

    #- on cancel, we can expect the current medium to be undefined too,
    #- this enable remounting if selecting a package back.
    $current_medium = 'unknown';

    return;
}
sub getFile {
    my ($f, $method) = @_;
    log::l("getFile $f:$method");
    my $rel = relGetFile($f);
    do {
	if ($f =~ m|^http://|) {
	    require http;
	    http::getFile($f);
	} elsif ($method =~ /crypto|update/i) {
	    require crypto;
	    crypto::getFile($f);
	} elsif ($::o->{method} eq "ftp") {
	    require ftp;
	    ftp::getFile($rel);
	} elsif ($::o->{method} eq "http") {
	    require http;
	    http::getFile("$ENV{URLPREFIX}/$rel");
	} else {
	    #- try to open the file, but examine if it is present in the repository, this allow
	    #- handling changing a media when some of the file on the first CD has been copied
	    #- to other to avoid media change...
	    my $f2 = "$postinstall_rpms/$f";
	    $f2 = "/tmp/image/$rel" unless $postinstall_rpms && -e $f2;
	    open GETFILE, $f2 and *GETFILE;
	}
    } || errorOpeningFile($f);
}
sub getAndSaveFile {
    my ($file, $local) = @_ == 1 ? ("Mandrake/mdkinst$_[0]", $_[0]) : @_;
    local $/ = \ (16 * 1024);
    my $f = ref($file) ? $file : getFile($file) or return;
    local *F; open F, ">$local" or return;
    local $_;
    while (<$f>) { syswrite F, $_ }
    1;
}


#-######################################################################################
#- Post installation RPMS from cdrom only, functions
#-######################################################################################
sub setup_postinstall_rpms($$) {
    my ($prefix, $packages) = @_;

    $postinstall_rpms and return;
    $postinstall_rpms = "$prefix/usr/postinstall-rpm";

    require pkgs;

    log::l("postinstall rpms directory set to $postinstall_rpms");
    clean_postinstall_rpms(); #- make sure in case of previous upgrade problem.
    mkdir_p($postinstall_rpms);

    my %toCopy;
    #- compute closure of package that may be copied, use INSTALL category
    #- in rpmsrate.
    $packages->{rpmdb} ||= pkgs::rpmDbOpen($prefix);
    foreach (@{$packages->{needToCopy} || []}) {
	my $p = pkgs::packageByName($packages, $_) or next;
	pkgs::selectPackage($packages, $p, 0, \%toCopy);
    }
    delete $packages->{rpmdb};

    my @toCopy = grep { $_ && !$_->flag_selected } map { $packages->{depslist}[$_] } keys %toCopy;

    #- extract headers of package, this is necessary for getting
    #- the complete filename of each package.
    #- copy the package files in the postinstall RPMS directory.
    #- last arg is default medium '' known as the CD#1.
    #- cp_af doesn't handle correctly a missing file.
    eval { cp_af((grep { -r $_ } map { "/tmp/image/" . relGetFile($_->filename) } @toCopy), $postinstall_rpms) };

    log::l("copying Auto Install Floppy");
    getAndSaveInstallFloppy($::o, "$postinstall_rpms/auto_install.img");
}

sub clean_postinstall_rpms() {
    $postinstall_rpms and -d $postinstall_rpms and rm_rf($postinstall_rpms);
}


#-######################################################################################
#- Specific Hardware to take into account and associated rpms to install
#-######################################################################################
sub allowNVIDIA_rpms {
    my ($packages) = @_;
    require pkgs;
    if (pkgs::packageByName($packages, "NVIDIA_GLX")) {
	#- at this point, we can allow using NVIDIA 3D acceleration packages.
	my @rpms;
	foreach (@{$packages->{depslist}}) {
	    my ($ext, $version, $release) = /kernel[^-]*(-smp|-enterprise|-secure)?(?:-(\d.*?)\.(\d+mdk))?$/ or next;
	    my $p = pkgs::packageByName($packages, $_);
	    $p->flag_available or next;
	    $version or ($version, $release) = ($p->version, $p->release);
	    my $name = "NVIDIA_kernel-$version-$release$ext";
	    pkgs::packageByName($packages, $name) or return;
	    push @rpms, $name;
	}
	@rpms > 0 or return;
	return [ @rpms, "NVIDIA_GLX" ];
    }
}

#-######################################################################################
#- Functions
#-######################################################################################
sub kernelVersion {
    my ($o) = @_;
    my $kernel = readlink "$o->{prefix}/boot/vmlinuz" || first(all("$o->{prefix}/boot"));
    first($kernel =~ /vmlinuz-(.*)/);
}


sub getNextStep {
    my ($s) = $::o->{steps}{first};
    $s = $::o->{steps}{$s}{next} while $::o->{steps}{$s}{done} || !$::o->{steps}{$s}{reachable};
    $s;
}

sub spawnShell {
    return if $::o->{localInstall} || $::testing;

    -x "/bin/sh" or die "cannot open shell - /bin/sh doesn't exist";

    fork and return;

    $ENV{DISPLAY} ||= ":0"; #- why not :pp

    local *F;
    sysopen F, "/dev/tty2", 2 or die "cannot open /dev/tty2 -- no shell will be provided";

    open STDIN, "<&F" or die '';
    open STDOUT, ">&F" or die '';
    open STDERR, ">&F" or die '';
    close F;

    print any::drakx_version(), "\n";

    c::setsid();

    ioctl(STDIN, c::TIOCSCTTY(), 0) or warn "could not set new controlling tty: $!";

    my $busybox = "/usr/bin/busybox";
    exec { -e $busybox ? $busybox : "/bin/sh" } "/bin/sh" or log::l("exec of /bin/sh failed: $!");
}

sub getAvailableSpace {
    my ($o) = @_;

    #- make sure of this place to be available for installation, this could help a lot.
    #- currently doing a very small install use 36Mb of postinstall-rpm, but installing
    #- these packages may eat up to 90Mb (of course not all the server may be installed!).
    #- 65mb may be a good choice to avoid almost all problem of insuficient space left...
    my $minAvailableSize = 65 * sqr(1024);

    my $n = !$::testing && getAvailableSpace_mounted($o->{prefix}) || 
            getAvailableSpace_raw($o->{fstab}) * 512 / 1.07;
    $n - max(0.1 * $n, $minAvailableSize);
}

sub getAvailableSpace_mounted {
    my ($prefix) = @_;
    my $dir = -d "$prefix/usr" ? "$prefix/usr" : $prefix;
    my (undef, $free) = MDK::Common::System::df($dir) or return;
    log::l("getAvailableSpace_mounted $free KB");
    $free * 1024 || 1;
}
sub getAvailableSpace_raw {
    my ($fstab) = @_;

    do { $_->{mntpoint} eq '/usr' and return $_->{size} } foreach @$fstab;
    do { $_->{mntpoint} eq '/'    and return $_->{size} } foreach @$fstab;

    if ($::testing) {
	my $nb = 450;
	log::l("taking ${nb}MB for testing");
	return $nb << 11;
    }
    die "missing root partition";
}

sub preConfigureTimezone {
    my ($o) = @_;
    require timezone;
   
    #- can't be done in install cuz' timeconfig %post creates funny things
    add2hash($o->{timezone}, timezone::read()) if $o->{isUpgrade};

    $o->{timezone}{timezone} ||= timezone::bestTimezone(lang::lang2text($o->{lang}));

    my $utc = $::expert && !grep { isFat($_) || isNT($_) } @{$o->{fstab}};
    my $ntp = timezone::ntp_server($o->{prefix});
    add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp });
}

sub setPackages {
    my ($o, $rebuild_needed) = @_;

    require pkgs;
    if (!$o->{packages} || is_empty_array_ref($o->{packages}{depslist})) {
	$o->{packages} = pkgs::psUsingHdlists($o->{prefix}, $o->{method});

	#- open rpm db according to right mode needed.
	$o->{packages}{rpmdb} ||= pkgs::rpmDbOpen($o->{prefix}, $rebuild_needed);

	pkgs::getDeps($o->{prefix}, $o->{packages});
	pkgs::selectPackage($o->{packages},
			    pkgs::packageByName($o->{packages}, 'basesystem') || die("missing basesystem package"), 1);

	#- must be done after selecting base packages (to save memory)
	pkgs::getProvides($o->{packages});

	#- must be done after getProvides
	pkgs::read_rpmsrate($o->{packages}, getFile("Mandrake/base/rpmsrate"));
	($o->{compssUsers}, $o->{compssUsersSorted}) = pkgs::readCompssUsers($o->{meta_class});

	#- preselect default_packages and compssUsersChoices.
	setDefaultPackages($o);
	pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || next) foreach @{$o->{default_packages}};
    } else {
	#- this has to be done to make sure necessary files for urpmi are
	#- present.
	pkgs::psUpdateHdlistsDeps($o->{prefix}, $o->{method}, $o->{packages});

	#- open rpm db (always without rebuilding db, it should be false at this point).
	$o->{packages}{rpmdb} ||= pkgs::rpmDbOpen($o->{prefix});
    }
}

sub setDefaultPackages {
    my ($o, $clean) = @_;

    if ($clean) {
	delete $o->{$_} foreach qw(default_packages compssUsersChoice); #- clean modified variables.
    }

    push @{$o->{default_packages}}, "nfs-utils-clients" if $o->{method} eq "nfs";
    push @{$o->{default_packages}}, "numlock" if $o->{miscellaneous}{numlock};
    push @{$o->{default_packages}}, "kernel22" if !$::oem && c::kernel_version() =~ /^\Q2.2/;
    push @{$o->{default_packages}}, "raidtools" if !is_empty_array_ref($o->{all_hds}{raids});
    push @{$o->{default_packages}}, "lvm" if !is_empty_array_ref($o->{all_hds}{lvms});
    push @{$o->{default_packages}}, "alsa", "alsa-utils" if modules::get_alias("sound-slot-0") =~ /^snd-card-/;
    push @{$o->{default_packages}}, uniq(grep { $_ } map { fsedit::package_needed_for_partition_type($_) } @{$o->{fstab}});

    #- if no cleaning needed, populate by default, clean is used for second or more call to this function.
    unless ($clean) {
	if ($::auto_install && ($o->{compssUsersChoice} || {})->{ALL}) {
	    $o->{compssUsersChoice}{$_} = 1 foreach map { @{$o->{compssUsers}{$_}{flags}} } @{$o->{compssUsersSorted}};
	}
	if (!$o->{compssUsersChoice} && !$o->{isUpgrade}) {
	    #- by default, choose:
	    if ($o->{meta_class} eq 'server') {
		$o->{compssUsersChoice}{$_} = 1 foreach 'X', 'MONITORING', 'NETWORKING_REMOTE_ACCESS_SERVER';
	    } else {
		$o->{compssUsersChoice}{$_} = 1 foreach 'GNOME', 'KDE', 'CONFIG', 'X';
		$o->{lang} eq 'eu_ES' and $o->{compssUsersChoice}{KDE} = 0;
		$o->{compssUsersChoice}{$_} = 1
		  foreach map { @{$o->{compssUsers}{$_}{flags}} } 'Workstation|Office Workstation', 'Workstation|Internet station';
	    }
	}
    }
    $o->{compssUsersChoice}{uc($_)} = 1 foreach grep { modules::probe_category("multimedia/$_") } modules::sub_categories('multimedia');
    $o->{compssUsersChoice}{uc($_)} = 1 foreach map { $_->{driver} =~ /Flag:(.*)/ } detect_devices::probeall();
    $o->{compssUsersChoice}{SYSTEM} = 1;
    $o->{compssUsersChoice}{DOCS} = !$o->{excludedocs};
    $o->{compssUsersChoice}{BURNER} = 1 if detect_devices::burners();
    $o->{compssUsersChoice}{DVD} = 1 if detect_devices::dvdroms();
    $o->{compssUsersChoice}{USB} = 1 if modules::get_probeall("usb-interface");
    $o->{compssUsersChoice}{PCMCIA} = 1 if detect_devices::hasPCMCIA();
    $o->{compssUsersChoice}{HIGH_SECURITY} = 1 if $o->{security} > 3;
    $o->{compssUsersChoice}{BIGMEM} = 1 if !$::oem && (availableRamMB() > 800) && (arch() !~ /ia64/);
    $o->{compssUsersChoice}{SMP} = 1 if detect_devices::hasSMP();
    $o->{compssUsersChoice}{'3D'} = 1 if 
      detect_devices::matching_desc('Matrox.* G[245][05]0') ||
      detect_devices::matching_desc('Rage X[CL]') ||
      detect_devices::matching_desc('3D Rage (?:LT|Pro)') ||
      detect_devices::matching_desc('Voodoo [35]') ||
      detect_devices::matching_desc('Voodoo Banshee') ||
      detect_devices::matching_desc('8281[05].* CGC') ||
      detect_devices::matching_desc('Rage 128') ||
      detect_devices::matching_desc('Radeon ') && !detect_devices::matching_desc('Radeon 8500') ||
      detect_devices::matching_desc('[nN]Vidia.*T[nN]T2') || #- TNT2 cards
      detect_devices::matching_desc('[nN]Vidia.*NV[56]') ||
      detect_devices::matching_desc('[nN]Vidia.*Vanta') ||
      detect_devices::matching_desc('[nN]Vidia.*GeForce') || #- GeForce cards
      detect_devices::matching_desc('[nN]Vidia.*NV1[15]') ||
      detect_devices::matching_desc('[nN]Vidia.*Quadro');


    foreach (map { substr($_, 0, 2) } lang::langs($o->{langs})) {
	pkgs::packageByName($o->{packages}, "locales-$_") or next;
	push @{$o->{default_packages}}, "locales-$_";
	$o->{compssUsersChoice}{qq(LOCALES"$_")} = 1; #- mainly for zh in case of zh_TW.Big5
    }
    foreach (lang::langsLANGUAGE($o->{langs})) {
	$o->{compssUsersChoice}{qq(LOCALES"$_")} = 1;
    }
    $o->{compssUsersChoice}{'CHARSET"' . lang::lang2charset($o->{lang}) . '"'} = 1;
}

sub unselectMostPackages {
    my ($o) = @_;
    pkgs::unselectAllPackages($o->{packages});
    pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_) || next) foreach @{$o->{default_packages}};
}

sub warnAboutNaughtyServers {
    my ($o) = @_;
    my @naughtyServers = pkgs::naughtyServers($o->{packages}) or return 1;
    if (!$o->ask_yesorno('', 
formatAlaTeX(_("You have selected the following server(s): %s


These servers are activated by default. They don't have any known security
issues, but some new could be found. In that case, you must make sure to upgrade
as soon as possible.


Do you really want to install these servers?
", join(", ", @naughtyServers))), 1)) {
	pkgs::unselectPackage($o->{packages}, pkgs::packageByName($o->{packages}, $_)) foreach @naughtyServers;
    }
}

sub addToBeDone(&$) {
    my ($f, $step) = @_;

    return &$f() if $::o->{steps}{$step}{done};

    push @{$::o->{steps}{$step}{toBeDone}}, $f;
}

sub setAuthentication {
    my ($o) = @_;
    my ($shadow, $md5, $ldap, $nis, $winbind, $winpass) = @{$o->{authentication} || {}}{qw(shadow md5 LDAP NIS winbind winpass)};
    my $p = $o->{prefix};
    any::enableShadow($p) if $shadow;
    if ($ldap) {
	$o->pkg_install(qw(chkauth openldap-clients nss_ldap pam_ldap));
	run_program::rooted($o->{prefix}, "/usr/sbin/chkauth", "ldap", "-D", $o->{netc}{LDAPDOMAIN}, "-s", $ldap);
    } elsif ($nis) {
	#$o->pkg_install(qw(chkauth ypbind yp-tools net-tools));
	#run_program::rooted($o->{prefix}, "/usr/sbin/chkauth", "yp", $domain, "-s", $nis);
	$o->pkg_install("ypbind");
	my $domain = $o->{netc}{NISDOMAIN};
	$domain || $nis ne "broadcast" or die _("Can't use broadcast with no NIS domain");
	my $t = $domain ? "domain $domain" . ($nis ne "broadcast" && " server")
	                : "ypserver";
	substInFile {
	    $_ = "#~$_" unless /^#/;
	    $_ .= "$t $nis\n" if eof;
	} "$p/etc/yp.conf";
	require network;
	network::write_conf("$p/etc/sysconfig/network", $o->{netc});
    } elsif ($winbind) {
	my $domain = $o->{netc}{WINDOMAIN};
	$o->pkg_install(qw(samba-winbind samba-common));
	{   #- setup pam
	    my $f = "$o->{prefix}/etc/pam.d/system-auth";
	    cp_af($f, "$f.orig");
	    cp_af("$f-winbind", $f);
	}
	write_smb_conf($domain);
	run_program::rooted($o->{prefix}, "chkconfig", "--level", "35", "winbind", "on");
	mkdir "$o->{prefix}/home/$domain", 0755;
	
	#- defer running smbpassword - no network yet
	$winbind = $winbind . "%" . $winpass;
	addToBeDone {
	    require install_steps;
	    install_steps::upNetwork($o, 'pppAvoided');
	    run_program::rooted($o->{prefix}, "/usr/bin/smbpasswd", "-j", $domain, "-U", $winbind);
	} 'configureNetwork';
    }
}

sub write_smb_conf {
    my ($domain) = @_;

    #- was going to just have a canned config in samba-winbind
    #- and replace the domain, but sylvestre/buchan didn't bless it yet

    my $f = "$::prefix/etc/samba/smb.conf";
    rename $f, "$f.orig";
    output($f, "
[global]
	workgroup = $domain  
	server string = Samba Server %v
	security = domain  
	encrypt passwords = Yes
	password server = *
	log file = /var/log/samba/log.%m
	max log size = 50
	socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
	character set = ISO8859-15
	os level = 18
	local master = No
	dns proxy = No
	winbind uid = 10000-20000
	winbind gid = 10000-20000
	winbind separator = +
	template homedir = /home/%D/%U
	template shell = /bin/bash
	winbind use default domain = yes
");
}

sub killCardServices {
    my $pid = chomp_(cat_("/tmp/cardmgr.pid"));
    $pid and kill(15, $pid); #- send SIGTERM
}

sub unlockCdrom(;$) {
    my ($cdrom) = @_;
    $cdrom or cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image), and $cdrom = $1;
    eval { $cdrom and ioctl detect_devices::tryOpen($1), c::CDROM_LOCKDOOR(), 0 };
}
sub ejectCdrom(;$) {
    my ($cdrom) = @_;
    getFile("XXX"); #- close still opened filehandle
    $cdrom ||= $1 if cat_("/proc/mounts") =~ m,(/(?:dev|tmp)/\S+)\s+(?:/mnt/cdrom|/tmp/image),;
    if ($cdrom) {
	#- umount BEFORE opening the cdrom device otherwise the umount will
	#- D state if the cdrom is already removed
	eval { fs::umount("/tmp/image") };
	if ($@) { log::l("files still open: ", readlink($_)) foreach map { glob_("$_/fd/*") } glob_("/proc/*") }
	eval { ioctl detect_devices::tryOpen($cdrom), c::CDROMEJECT(), 1 };	
    }
}

sub setupFB {
    my ($o, $vga) = @_;

    $vga ||= 785; #- assume at least 640x480x16.

    require bootloader;
    #- update bootloader entries with vga, all kernel are now framebuffer.
    foreach (qw(vmlinuz vmlinuz-secure vmlinuz-smp vmlinuz-hack)) {
	if (my $e = bootloader::get("/boot/$_", $o->{bootloader})) {
	    $e->{vga} = $vga;
	}
    }
    bootloader::install($o->{bootloader}, $o->{fstab}, $o->{all_hds}{hds});
    1;
}

sub hdInstallPath() {
    my $tail = first(readlink("/tmp/image") =~ m|^/tmp/hdimage/(.*)|);
    my $head = first(readlink("/tmp/hdimage") =~ m|$::prefix(.*)|);
    $tail && ($head ? "$head/$tail" : "/mnt/hd/$tail");
}

sub install_urpmi {
    my ($prefix, $method, $mediums) = @_;

    #- rare case where urpmi cannot be installed (no hd install path).
    $method eq 'disk' && !hdInstallPath() and return;

    my @cfg = map {
	my $name = $_->{fakemedium};

	local *LIST;
	my $mask = umask 077;
	open LIST, ">$prefix/var/lib/urpmi/list.$name" or log::l("failed to write list.$name");
	umask $mask;

	my $dir = ($_->{prefix} || ${{ nfs => "file://mnt/nfs", 
				       disk => "file:/" . hdInstallPath(),
				       ftp => $ENV{URLPREFIX},
				       http => $ENV{URLPREFIX},
				       cdrom => "removable://mnt/cdrom" }}{$method}) . "/$_->{rpmsdir}";

	local *FILES; open FILES, "$ENV{LD_LOADER} parsehdlist /tmp/$_->{hdlist} |";
	print LIST "$dir/$_\n" foreach chomp_(<FILES>);
	close FILES or log::l("parsehdlist failed"), return;
	close LIST;

	#- build synthesis file if there are still not existing (ie not copied from mirror).
	if (-s "$prefix/var/lib/urpmi/synthesis.hdlist.$name.cz" <= 32) {
	    unlink "$prefix/var/lib/urpmi/synthesis.hdlist.$name.cz";
	    run_program::rooted($prefix, "parsehdlist", ">", "/var/lib/urpmi/synthesis.hdlist.$name",
				"--synthesis", "/var/lib/urpmi/hdlist.$name.cz");
	    run_program::rooted($prefix, "gzip", "-S", ".cz", "/var/lib/urpmi/synthesis.hdlist.$name");
	}

	my ($qname, $qdir) = ($name, $dir);
	$qname =~ s/(\s)/\\$1/g; $qdir =~ s/(\s)/\\$1/g;

	#- output new urpmi.cfg format here.
	"$qname " . ($dir !~ /^(ftp|http)/ && $qdir) . " {
  hdlist: hdlist.$name.cz
  with_hdlist: ../base/" . ($_->{update} ? "hdlist.cz" : $_->{hdlist}) . "
  list: list.$name" . ($dir =~ /removable:/ && "
  removable: /dev/cdrom") . ($_->{update} && "
  update") . "
}

";
    } sort { $a->{medium} <=> $b->{medium} } values %$mediums;
    eval { output "$prefix/etc/urpmi/urpmi.cfg", @cfg };
}


#-###############################################################################
#- kde stuff
#-###############################################################################
sub kderc_largedisplay {
    my ($prefix) = @_;

    update_gnomekderc($_, 'KDE', 
		     Contrast => 7,
		     kfmIconStyle => "Large",
		     kpanelIconStyle => "Normal", #- to change to Large when icons looks better
		     KDEIconStyle => "Large") foreach list_skels($prefix, '.kderc');

    substInFile {
	s/^(GridWidth)=85/$1=100/;
	s/^(GridHeight)=70/$1=75/;
    } $_ foreach list_skels($prefix, '.kde/share/config/kfmrc');
}

sub kdeicons_postinstall {
    my ($prefix) = @_;

    #- parse etc/fstab file to search for dos/win, floppy, zip, cdroms icons.
    #- handle both supermount and fsdev usage.
    my %l = (
	     'cdrom' => [ 'cdrom', 'Cd-Rom' ],
	     'zip' => [ 'zip', 'Zip' ],
	     'floppy-ls' => [ 'floppy', 'LS-120' ],
	     'floppy' => [ 'floppy', 'Floppy' ],
    );
    foreach (fs::read_fstab($prefix, "/etc/fstab")) {

	my ($name_, $nb) = $_->{mntpoint} =~ m|.*/(\S+?)(\d*)$/|;
	my ($name, $text) = @{$l{$name_} || []};

	my $f = ${{
	    supermount => sub { $name .= '.fsdev' if $name },
	    vfat => sub { $name = 'Dos_'; $text = $name_ },
	}}{$_->{type}};
	&$f if $f;

	template2userfile($prefix, 
			  "$ENV{SHARE_PATH}/$name.kdelnk.in",
			  "Desktop/$text" .  ($nb && " $nb"). ".kdelnk",
			  1, %$_) if $name;
    }

    # rename the .kdelnk to the name found in the .kdelnk as kde doesn't use it
    # for displaying
    foreach my $dir (grep { -d $_ } list_skels($prefix, 'Desktop')) {
	foreach (grep { /\.kdelnk$/ } all($dir)) {
	    cat_("$dir/$_") =~ /^Name\[\Q$ENV{LANG}\E\]=(.{2,14})$/m
	      and rename "$dir/$_", "$dir/$1.kdelnk";
	}
    }
}

sub kdemove_desktop_file {
    my ($prefix) = @_;
    my @toMove = qw(doc.kdelnk news.kdelnk updates.kdelnk home.kdelnk printer.kdelnk floppy.kdelnk cdrom.kdelnk FLOPPY.kdelnk CDROM.kdelnk);

    #- remove any existing save in Trash of each user and
    #- move appropriate file there after an upgrade.
    foreach my $dir (grep { -d $_ } list_skels($prefix, 'Desktop')) {
	renamef("$dir/$_", "$dir/Trash/$_") 
	  foreach grep { -e "$dir/$_" } @toMove, grep { /\.rpmorig$/ } all($dir)
    }
}


#-###############################################################################
#- auto_install stuff
#-###############################################################################
sub auto_inst_file() { ($::g_auto_install ? "/tmp" : "$::prefix/root/drakx") . "/auto_inst.cfg.pl" }

sub report_bug {
    my ($prefix) = @_;
    any::report_bug($prefix, 'auto_inst' => g_auto_install('', 1));
}

sub g_auto_install {
    my ($replay, $respect_privacy) = @_;
    my $o = {};

    require pkgs;
    $o->{default_packages} = pkgs::selected_leaves($::o->{packages});

    my @fields = qw(mntpoint type size);
    $o->{partitions} = [ map { my %l; @l{@fields} = @$_{@fields}; \%l } grep { $_->{mntpoint} } @{$::o->{fstab}} ];
    
    exists $::o->{$_} and $o->{$_} = $::o->{$_} foreach qw(lang authentication mouse netc timezone superuser intf keyboard users partitioning isUpgrade manualFstab nomouseprobe crypto security netcnx useSupermount autoExitInstall mkbootdisk X services); #- TODO modules bootloader 

    if (my $printer = $::o->{printer}) {
	$o->{printer}{$_} = $::o->{printer}{$_} foreach qw(SPOOLER DEFAULT BROWSEPOLLADDR BROWSEPOLLPORT MANUALCUPSCONFIG);
	$o->{printer}{configured} = {};
	foreach my $queue (keys %{$::o->{printer}{configured}}) {
	    my $val = $::o->{printer}{configured}{$queue}{queuedata};
	    exists $val->{$_} and $o->{printer}{configured}{$queue}{queuedata}{$_} = $val->{$_} foreach keys %{$val || {}};
	}
    }

    local $o->{partitioning}{auto_allocate} = !$replay;
    $o->{autoExitInstall} = !$replay;
    $o->{interactiveSteps} = [ 'doPartitionDisks', 'formatPartitions'] if $replay;

    #- deep copy because we're modifying it below
    $o->{users} = [ @{$o->{users} || []} ];

    my @user_info_to_remove = (
	if_($respect_privacy, qw(name realname home pw)), 
	qw(oldu oldg password password2),
    );
    $_ = { %{$_ || {}} }, delete @$_{@user_info_to_remove} foreach $o->{superuser}, @{$o->{users} || []};

    if ($respect_privacy && $o->{netcnx}) {
	if (my $type = $o->{netcnx}{type}) {
	    my @netcnx_type_to_remove = qw(passwd passwd2 login phone_in phone_out);
	    $_ = { %{$_ || {}} }, delete @$_{@netcnx_type_to_remove} foreach $o->{netcnx}{$type};
	}
    }
    
    require Data::Dumper;
    my $str = join('', 
"#!/usr/bin/perl -cw
#
# You should check the syntax of this file before using it in an auto-install.
# You can do this with 'perl -cw auto_inst.cfg.pl' or by executing this file
# (note the '#!/usr/bin/perl -cw' on the first line).
", Data::Dumper->Dump([$o], ['$o']), "\0");
    $str =~ s/ {8}/\t/g; #- replace all 8 space char by only one tabulation, this reduces file size so much :-)
    $str;
}

sub getAndSaveInstallFloppy {
    my ($o, $where) = @_;
    if ($postinstall_rpms && -d $postinstall_rpms && -r "$postinstall_rpms/auto_install.img") {
	log::l("getAndSaveInstallFloppy: using file saved as $postinstall_rpms/auto_install.img");
	cp_af("$postinstall_rpms/auto_install.img", $where);
    } else {
	my $image = cat_("/proc/cmdline") =~ /pcmcia/ ? "pcmcia" :
	  ${{ disk => 'hd', cdrom => 'cdrom', ftp => 'network', nfs => 'network', http => 'network' }}{$o->{method}};
	$image .= arch() =~ /sparc64/ && "64"; #- for sparc64 there are a specific set of image.
	getAndSaveFile("images/$image.img", $where) or log::l("failed to write Install Floppy ($image.img) to $where"), return;
    }
    1;
}

sub getAndSaveAutoInstallFloppy {
    my ($o, $replay, $where) = @_;

    eval { modules::load('loop') };

    if (arch() =~ /sparc/) {
	my $imagefile = "$o->{prefix}/tmp/autoinst.img";
	my $mountdir = "$o->{prefix}/tmp/mount"; -d $mountdir or mkdir $mountdir, 0755;
	my $workdir = "$o->{prefix}/tmp/work"; -d $workdir or rmdir $workdir;

	getAndSaveInstallFloppy($o, $imagefile) or return;
        devices::make($_) foreach qw(/dev/loop6 /dev/ram);

        run_program::run("losetup", "/dev/loop6", $imagefile);
        fs::mount("/dev/loop6", $mountdir, "romfs", 'readonly');
        cp_af($mountdir, $workdir);
        fs::umount($mountdir);
        run_program::run("losetup", "-d", "/dev/loop6");

	substInFile { s/timeout.*//; s/^(\s*append\s*=\s*\".*)\"/$1 kickstart=floppy\"/ } "$workdir/silo.conf"; #" for po
#-TODO	output "$workdir/ks.cfg", generate_ks_cfg($o);
	output "$workdir/boot.msg", "\n7m",
"!! If you press enter, an auto-install is going to start.
    ALL data on this computer is going to be lost,
    including any Windows partitions !!
", "7m\n";

	local $o->{partitioning}{clearall} = 1;
	output("$workdir/auto_inst.cfg", g_auto_install());

        run_program::run("genromfs", "-d", $workdir, "-f", "/dev/ram", "-A", "2048,/..", "-a", "512", "-V", "DrakX autoinst");
        fs::mount("/dev/ram", $mountdir, 'romfs', 0);
        run_program::run("silo", "-r", $mountdir, "-F", "-i", "/fd.b", "-b", "/second.b", "-C", "/silo.conf");
        fs::umount($mountdir);
	require commands;
        commands::dd("if=/dev/ram", "of=$where", "bs=1440", "count=1024");

        rm_rf($workdir, $mountdir, $imagefile);
    } elsif (arch() =~ /ia64/) {
	#- nothing yet
    } else {
	my $imagefile = "$o->{prefix}/root/autoinst.img";
	my $mountdir = "$o->{prefix}/root/aif-mount"; -d $mountdir or mkdir $mountdir, 0755;

	my $param = 'kickstart=floppy ' . generate_automatic_stage1_params($o);

	getAndSaveInstallFloppy($o, $imagefile) or return;

	my $dev = devices::set_loop($imagefile) or log::l("couldn't set loopback device"), return;
        eval { fs::mount($dev, $mountdir, 'vfat', 0); 1 } or return;

	substInFile { 
	    s/timeout.*/$replay ? 'timeout 1' : ''/e;
	    s/^(\s*append)/$1 $param/ 
	} "$mountdir/syslinux.cfg";

	unlink "$mountdir/help.msg";
	output "$mountdir/boot.msg", "\n0c",
"!! If you press enter, an auto-install is going to start.
   All data on this computer is going to be lost,
   including any Windows partitions !!
", "07\n" if !$replay;

	local $o->{partitioning}{clearall} = !$replay;
	eval { output("$mountdir/auto_inst.cfg", g_auto_install($replay)) };
	$@ and log::l("Warning: <$@>");

	fs::umount($mountdir);
	rmdir $mountdir;
	devices::del_loop($dev);
	require commands;
	commands::dd("if=$imagefile", "of=$where", "bs=1440", "count=1024");
	unlink $imagefile;
    }
    1;
}


sub g_default_packages {
    my ($o, $quiet) = @_;

    my $floppy = detect_devices::floppy();

    while (1) {
	$o->ask_okcancel('', _("Insert a FAT formatted floppy in drive %s", $floppy), 1) or return;

	eval { fs::mount(devices::make($floppy), "/floppy", "vfat", 0) };
	last if !$@;
	$o->ask_warn('', _("This floppy is not FAT formatted"));
    }

    require Data::Dumper;
    my $str = Data::Dumper->Dump([ { default_packages => pkgs::selected_leaves($o->{packages}) } ], ['$o']);
    $str =~ s/ {8}/\t/g;
    output('/floppy/auto_inst.cfg', 
	   "# You should always check the syntax with 'perl -cw auto_inst.cfg.pl'\n",
	   "# before testing.  To use it, boot with ``linux defcfg=floppy''\n",
	   $str, "\0");
    fs::umount("/floppy");

    $quiet or $o->ask_warn('', _("To use this saved packages selection, boot installation with ``linux defcfg=floppy''"));
}

sub loadO {
    my ($O, $f) = @_; $f ||= auto_inst_file;
    my $o;
    if ($f =~ /^(floppy|patch)$/) {
	my $f = $f eq "floppy" ? 'auto_inst.cfg' : "patch";
	unless ($::testing) {
	    fs::mount(devices::make(detect_devices::floppy()), "/mnt", (arch() =~ /sparc/ ? "romfs" : "vfat"), 'readonly');
	    $f = "/mnt/$f";
	}
	-e $f or $f .= '.pl';

	my $b = before_leaving {
	    fs::umount("/mnt") unless $::testing;
	    modules::unload(qw(vfat fat));
	};
	$o = loadO($O, $f);
    } else {
	-e "$f.pl" and $f .= ".pl" unless -e $f;

	my $fh;
	if (-e $f) { open $fh, $f } else { $fh = getFile($f) or die _("Error reading file %s", $f) }
	{
	    local $/ = "\0";
	    no strict;
	    eval <$fh>;
	    close $fh;
	    $@ and die;
	}
	$O and add2hash_($o ||= {}, $O);
    }
    $O and bless $o, ref $O;
    $o;
}

sub generate_automatic_stage1_params {
    my ($o) = @_;

    my @ks = "method:$o->{method}";

    if ($o->{method} eq 'http') {
	"$ENV{URLPREFIX}" =~ m|http://([^/:]+)/(.*)| or die;
	push @ks, "server:$1", "directory:$2";
    } elsif ($o->{method} eq 'ftp') {
	push @ks,  "server:$ENV{HOST}", "directory:$ENV{PREFIX}", "user:$ENV{LOGIN}", "pass:$ENV{PASSWORD}";
    } elsif ($o->{method} eq 'nfs') {
	cat_("/proc/mounts") =~ m|(\S+):(\S+)\s+/tmp/image nfs| or die;
	push @ks, "server:$1", "directory:$2";
    }

    if (member($o->{method}, qw(http ftp nfs))) {
	my ($intf) = values %{$o->{intf}};
	push @ks, "interface:$intf->{DEVICE}";
	if ($intf->{BOOTPROTO} eq 'dhcp') {
	    push @ks, "network:dhcp";
	} else {
	    require network;
	    push @ks, "network:static", "ip:$intf->{IPADDR}", "netmask:$intf->{NETMASK}", "gateway:$o->{netc}{GATEWAY}";
	    my @dnss = network::dnsServers($o->{netc});
	    push @ks, "dns:$dnss[0]" if @dnss;
	}
    }

    #- sync it with ../mdk-stage1/automatic.c
    my %aliases = (method => 'met', network => 'netw', interface => 'int', gateway => 'gat', netmask => 'netm',
		   adsluser => 'adslu', adslpass => 'adslp', hostname => 'hos', domain => 'dom', server => 'ser',
		   directory => 'dir', user => 'use', pass => 'pas', disk => 'dis', partition => 'par');
    
    'automatic='.join(',', map { (/^([^:]+)(:.*)/ && $aliases{$1}) ? $aliases{$1}.$2 : $_ } @ks);
}

sub guess_mount_point {
    my ($part, $prefix, $user) = @_;

    my %l = (
	     '/'     => 'etc/fstab',
	     '/boot' => 'vmlinuz',
	     '/tmp'  => '.X11-unix',
	     '/usr'  => 'X11R6',
	     '/var'  => 'catman',
	    );

    my $handle = any::inspect($part, $prefix) or return;
    my $d = $handle->{dir};
    my ($mnt) = grep { -e "$d/$l{$_}" } keys %l;
    $mnt ||= (stat("$d/.bashrc"))[4] ? '/root' : '/home/user' . ++$$user if -e "$d/.bashrc";
    $mnt ||= (grep { -d $_ && (stat($_))[4] >= 500 && -e "$_/.bashrc" } glob_($d)) ? '/home' : '';
    ($mnt, $handle);
}

sub suggest_mount_points {
    my ($fstab, $prefix, $uniq) = @_;

    my $user;
    foreach my $part (grep { isTrueFS($_) } @$fstab) {
	$part->{mntpoint} && !$part->{unsafeMntpoint} and next; #- if already found via an fstab

	my ($mnt, $handle) = guess_mount_point($part, $prefix, \$user) or next;

	next if $uniq && fsedit::mntpoint2part($mnt, $fstab);
	$part->{mntpoint} = $mnt; delete $part->{unsafeMntpoint};

	#- try to find other mount points via fstab
	fs::merge_info_from_fstab($fstab, $handle->{dir}, $uniq, 'loose') if $mnt eq '/';
    }
    $_->{mntpoint} and log::l("suggest_mount_points: $_->{device} -> $_->{mntpoint}") foreach @$fstab;
}

#- mainly for finding the root partitions for upgrade
sub find_root_parts {
    my ($fstab, $prefix) = @_;
    log::l("find_root_parts");
    my $user;
    grep { 
	my ($mnt) = guess_mount_point($_, $prefix, \$user);
	$mnt eq '/';
    } @$fstab;
}
sub use_root_part {
    my ($all_hds, $part, $prefix) = @_;
    my $fstab = [ fsedit::get_really_all_fstab($all_hds) ];
    {
	my $handle = any::inspect($part, $prefix) or die;
	fs::merge_info_from_fstab($fstab, $handle->{dir}, 'uniq');
    }
    map { $_->{mntpoint} = 'swap' } grep { isSwap($_) } @$fstab; #- use all available swap.
}

sub getHds {
    my ($o, $f_err) = @_;
    my $ok = 1;
    my $try_scsi = !$::expert;
    my $flags = $o->{partitioning};

    my @drives = detect_devices::hds();
#    add2hash_($o->{partitioning}, { readonly => 1 }) if partition_table::raw::typeOfMBR($drives[0]{device}) eq 'system_commander';

  getHds: 
    my $all_hds = catch_cdie { fsedit::hds(\@drives, $flags) }
      sub {
	  $ok = 0;
	  my $err = formatError($@);
	  log::l("error reading partition table: $err");
	  !$flags->{readonly} && $f_err and $f_err->($err);
      };
    my $hds = $all_hds->{hds};

    if (is_empty_array_ref($hds) && $try_scsi) {
	$try_scsi = 0;
	$o->setupSCSI; #- ask for an unautodetected scsi card
	goto getHds;
    }
    if (!$::testing) {
	@$hds = grep { eval { partition_table::raw::test_for_bad_drives($_) }; !$@ } @$hds;
    }

    $ok = fsedit::verifyHds($hds, $flags->{readonly}, $ok)
        if !($flags->{clearall} || $flags->{clear});

    #- try to figure out if the same number of hds is available, use them if ok.
    $ok && $hds && @$hds > 0 && @{$o->{all_hds}{hds} || []} == @$hds and return $ok;

    fs::get_raw_hds('', $all_hds);
    fs::add2all_hds($all_hds, @{$o->{manualFstab}});

    $o->{all_hds} = $all_hds;
    $o->{fstab} = [ fsedit::get_all_fstab($all_hds) ];
    fs::merge_info_from_mtab($o->{fstab});

    my @win = grep { isFat($_) && isFat({ type => fsedit::typeOfPart($_->{device}) }) } @{$o->{fstab}};
    log::l("win parts: ", join ",", map { $_->{device} } @win) if @win;
    if (@win == 1) {
	#- Suggest /boot/efi on ia64.
	$win[0]{mntpoint} = arch() =~ /ia64/ ? "/boot/efi" : "/mnt/windows";
    } else {
	my %w; foreach (@win) {
	    my $v = $w{$_->{device_windobe}}++;
	    $_->{mntpoint} = $_->{unsafeMntpoint} = "/mnt/win_" . lc($_->{device_windobe}) . ($v ? $v+1 : ''); #- lc cuz of StartOffice(!) cf dadou
	}
    }

    my @sunos = grep { isSunOS($_) && type2name($_->{type}) =~ /root/i } @{$o->{fstab}}; #- take only into account root partitions.
    if (@sunos) {
	my $v = '';
	map { $_->{mntpoint} = $_->{unsafeMntpoint} = "/mnt/sunos" . ($v && ++$v) } @sunos;
    }
    #- a good job is to mount SunOS root partition, and to use mount point described here in /etc/vfstab.

    $ok;
}

sub log_sizes {
    my ($o) = @_;
    my @df = MDK::Common::System::df($o->{prefix});
    log::l(sprintf "Installed: %s(df), %s(rpm)",
	   formatXiB($df[0] - $df[1], 1024),
	   formatXiB(sum(run_program::rooted_get_stdout($o->{prefix}, 'rpm', '-qa', '--queryformat', '%{size}\n')))) if -x "$o->{prefix}/bin/rpm";
}

sub copy_advertising {
    my ($o) = @_;

    return if $::rootwidth < 800;

    my $f;
    my $source_dir = "Mandrake/share/advertising";
    foreach ("." . $o->{lang}, "." . substr($o->{lang},0,2), '') {
	$f = getFile("$source_dir$_/list") or next;
	$source_dir = "$source_dir$_";
    }
    if (my @files = <$f>) {
	my $dir = "$o->{prefix}/tmp/drakx-images";
	mkdir $dir;
	unlink glob_("$dir/*");
	foreach (@files) {
	    chomp;
	    getAndSaveFile("$source_dir/$_", "$dir/$_");
	    s/\.png/\.pl/;
	    getAndSaveFile("$source_dir/$_", "$dir/$_");
	    s/\.pl/_icon\.png/;
	    getAndSaveFile("$source_dir/$_", "$dir/$_");
	    s/_icon\.png/\.png/;
	}
	@advertising_images = map { "$dir/$_" } @files;
    }
}

sub remove_advertising {
    my ($o) = @_;
    eval { rm_rf("$o->{prefix}/tmp/drakx-images") };
    @advertising_images = ();
}

sub disable_user_view {
    my ($prefix) = @_;
    substInFile { s/^UserView=.*/UserView=true/ } "$prefix/usr/share/config/kdm/kdmrc";
    substInFile { s/^Browser=.*/Browser=0/ } "$prefix/etc/X11/gdm/gdm.conf";
}

sub write_fstab {
    my ($o) = @_;
    fs::write_fstab($o->{all_hds}, $o->{prefix}) if !$::live;
}

my @bigseldom_used_groups = (
);

sub check_prog {