summaryrefslogtreecommitdiffstats
path: root/perl-install/pixmaps/printer_del.png
blob: d80786d508216e1d9152f22a9b4282440b877209 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 1c 00 00 00 1c 08 06 00 00 00 72 0d df .PNG........IHDR.............r..
0020 94 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 05 a2 49 44 41 54 78 da e.Adobe.ImageReadyq.e<....IDATx.
0060 62 f9 ff ff 3f 03 08 68 68 68 30 20 83 ee 95 7b 15 55 44 b9 93 7f fd fc c1 fa e7 cf 1f 66 06 22 b...?..hhh0....{.UD..........f."
0080 c0 ce fd 47 96 2e ea 6b b8 01 64 fe 00 e2 ff d8 d4 00 04 10 0b 2e cd 1f 3f 7d 55 d6 d4 97 ae 66 ...G...k..d.............?}U....f
00a0 20 01 2c 58 f2 f8 1d 90 fa 04 c4 8f 81 f8 17 36 35 00 01 c4 84 4b f3 9b f7 1f 98 19 48 04 cf 9f ..,X...........65....K......H...
00c0 3c d2 01 52 d2 f8 3c 02 10 40 38 2d 7c f7 f1 13 13 a9 16 7e ff fe 9d 0f 48 71 e2 33 17 20 80 70 <..R..<..@8-|......~....Hq.3...p
00e0 ba e4 f3 b7 1f d8 23 01 0f f8 fd e7 2f 41 35 00 01 84 d3 c2 2f 3f be 33 fc fd 4b aa 85 7f 08 aa ......#...../A5...../?.3..K.....
0100 01 08 20 dc 16 7e ff ce f0 87 54 0b 89 70 21 40 00 e1 4e a5 5f bf 01 7d 48 5a a0 fe fa f3 9b a0 .....~....T..p!@..N._..}HZ......
0120 1a 80 00 c2 1a b9 ed 4b 77 1a 79 98 e9 c6 81 7c 48 0a f6 f0 f2 55 cf a9 eb 8a 04 1a 01 4a 3c ac .......Kw.y....|H....U.......J<.
0140 d8 cc 06 08 20 ac 3e 64 62 64 9c 2f f8 f3 8d de 91 23 07 48 f2 a1 aa 38 bf 8a 91 a5 bd ca 51 cf ......>dbd./.....#.H...8......Q.
0160 88 5b e7 b7 af 58 04 ca 29 40 8c 12 ce 00 01 c4 08 2b 69 d6 9f 7d 68 24 23 c8 19 fc f4 e5 1b 56 .[...X..)@.......+i..}h$#......V
0180 16 36 ce 52 07 6d 05 06 72 41 db d2 4d 8f 2d 94 44 8f f0 0a 8a bd 7a f0 f2 fd f9 ce fc d8 75 a0 .6.R.m..rA..M.-.D.....z.......u.
01a0 5c 03 c4 7f 00 02 08 ee 43 15 71 fe 09 ba 32 02 b6 d2 02 1c 0c 6f be fc 65 f8 f0 fd 2f d9 16 7a \.......C.q...2......o..e.../..z
01c0 59 1b c9 da 68 c8 82 82 96 e1 ec f9 0b 0c 66 66 66 3f 4f 9d 3a b5 0f c8 7d 0d 10 40 70 0b 95 85 Y...h.........fff?O.:...}..@p...
01e0 39 58 fe 01 3d cb cd c9 c3 70 e9 d5 77 86 67 df 7e 92 6d 21 0b 93 30 c3 3f 68 7a 93 92 94 64 30 9X..=....p..w.g.~.m!..0.?hz...d0
0200 31 b7 ac 00 5a f8 04 94 f8 01 02 08 9e 68 fe fc fd cf f4 f7 1f 03 c3 93 8f 7f 18 28 05 7f 80 b6 1...Z........h.............(....
0220 bd f9 fa 97 01 64 9e 88 a8 38 83 00 3f bf 0a 50 58 13 88 05 00 02 08 ee c3 7f ff 20 f8 fc b3 2f .....d...8..?..PX............../
0240 0c 8f 3f a0 96 bb 82 ec ff 19 de 7e fb c7 c0 c8 c4 c8 c0 c8 48 5c 89 c7 c1 fa 9f c1 52 8e 07 cc ..?........~........H\......R...
0260 16 15 16 e2 16 91 53 d1 7d f3 e8 ce 31 80 00 42 58 08 4c 3c df 3f 7e 64 70 3a bd 8e e1 e7 a6 2d ......S.}...1..BX.L<.?~dp:.....-
0280 0c ec ff 20 71 f8 d0 d8 92 21 ea e8 73 06 26 1b 17 06 66 6e 01 06 26 36 4e a2 2c fc f9 9f 9f 61 ....q....!..s.&...fn..&6N.,....a
02a0 e7 fb 2b 0c ac 3f ff 32 b8 f0 48 31 88 f3 b2 4b bf 61 60 e0 07 08 20 b8 85 1f cf 9c e3 fa 9b 93 ..+..?.2..H1...K.a`.............
02c0 c5 c0 f5 e0 3e c3 1b 60 3c 3e e3 e0 61 10 fe f5 9d 41 e9 c0 01 86 a3 9c 5c 0c 19 c0 fa 72 f3 75 ....>..`<>..a....A......\....r.u
02e0 60 34 f0 88 02 f3 0d e1 8a e4 8d 38 03 c3 e6 6b 6b 18 e4 79 24 18 ec e4 7c 19 80 75 2a 1b 50 98 `4.........8...kk..y$...|..u*.P.
0300 0b 20 80 c0 16 4e 56 32 54 0c ff f8 54 eb 0a 33 27 03 6f 47 0f 83 5e 62 14 83 29 1f 2f 58 e3 8d .....NV2T...T..3'.oG..^b..)./X..
0320 b5 9b 18 9e 55 d6 32 4c 5a dd c6 f0 5c c3 9c e1 cc d5 4b 50 0b 19 f1 5a c8 a7 9c cd 70 a5 68 19 ....U.2LZ...\.....KP...Z....p.h.
0340 98 7d 68 ff 4e 90 85 20 0d cc 00 01 04 b6 d0 fe ed e3 a6 77 ff fe 33 4b 2d 98 cc a0 11 ec 87 a2 .}h.N..............w..3K-.......
0360 11 c4 97 36 37 61 b8 af 6d c0 30 f3 f7 67 86 74 63 2d 06 3e 21 51 06 16 36 76 ac 16 ed 5a 3a 1d ...67a..m.0..g.tc-.>!Q..6v...Z:.
0380 4c ff ff f6 06 98 26 20 49 f5 d7 af df 40 f6 3f 30 1b 20 80 c0 16 0a fe fe e5 77 c5 ce 85 c1 c9 L.....&.I....@.?0.........w.....
03a0 d5 91 e1 f4 c4 99 18 86 28 ba 3a 30 bc 09 8b 64 d0 5b 34 9b c1 bd ae 99 c1 d6 c9 95 41 46 56 1e ........(.:0...d.[4.........AFV.
03c0 43 dd c5 47 af 19 2e 1f db cb f0 fc fe 2d 06 50 79 f2 17 5a a8 fc fc f9 13 e4 43 30 1b 20 80 c0 C..G.........-.Py..Z......C0....
03e0 16 0a fc fe c9 27 e2 e9 ce 70 ba b1 93 c1 d4 c5 9a 81 9d 9f 1f b9 56 65 d8 1e 9f ce 20 12 13 c9 .....'...p............Ve........
0400 20 f2 fb 3b 83 a5 84 0e 03 f7 df 4f 0c 4a c2 6c 0c 9c 9c a8 09 88 85 f9 3f 43 65 cf 6c 06 39 8e ...;.......O.J.l........?Ce.l.9.
0420 3f 0c 72 72 f2 0c 50 4f 81 2d fc 0b ad 49 00 02 08 9e 68 7e 7e fa cc f0 0b 18 37 cf 22 23 19 d8 ?.rr..PO.-...I....h~~.....7."#..
0440 79 51 4b 19 5e b7 78 06 5e 19 49 86 67 ec 3c 0c 37 af 5f 66 60 ff c5 cf 20 2a 21 c7 20 2b 2b 87 yQK.^.x.^.I.g.<.7._f`....*!..++.
0460 a2 4e 56 48 80 e1 c3 7f 36 86 ef 3f fe 33 dc bc 05 4c 60 20 0c 04 37 1f bd 63 f8 f4 17 92 9d 00 .NVH....6..?.3...L`...7..c......
0480 02 08 6c e1 7b 7e f6 cf 9f b7 6e e3 75 da b5 91 e1 6d 88 2f 46 50 99 6a aa 33 1c 2d ae 61 10 61 ..l.{~....n.u....m./FP.j.3.-.a.a
04a0 fd cb b0 ea e0 16 06 6f 91 00 86 f7 5f 7e 31 f0 7f ff 87 99 ff 58 98 18 56 4e ed 3f f9 e5 d1 8d .......o...._~1......X..VN.?....
04c0 9b a0 c4 8f 54 78 3f 05 b5 5c 00 02 08 6c e1 65 5e de 45 5a d7 ce 65 df 04 a6 48 bd c4 68 0c 43 ....Tx?..\...l.e^.EZ..e...H..h.C
04e0 40 29 95 77 ed 2a 86 9d 02 82 ff 1f fe fa f9 6b e1 de a3 bf d7 5c 7d f4 9b 85 83 eb 1f d6 92 86 @).w.*.........k.....\}.........
0500 83 1b 54 72 1c 01 e2 ab 40 fc 15 16 39 a0 b2 14 20 80 c0 b5 45 98 aa 8e 5a f3 df 47 bb ff bf 66 ..Tr....@...9.......E...Z..G...f
0520 95 7b 96 91 c3 60 9a 9f 0e 0c 42 29 86 cf 4f 9e 01 2d db cc f0 b3 b9 99 41 49 f4 cd 3f 8f 2f e2 .{...`....B)..O..-......AI..?./.
0540 77 3e 30 fe bf cd ca ca 7a 8b 85 85 e5 0d 23 23 23 ae 12 1e d4 5c bc 00 c4 d7 41 e5 27 b2 04 40 w>0.....z.....###....\....A.'..@
0560 00 81 2d 04 36 82 d9 e5 fe 31 99 d4 33 bc 5a a8 fe e1 9b f2 b3 9f 3c 0c 3f 99 21 99 5b e3 ef 3b ..-.6....1..3.Z.......<.?.!.[..;
0580 86 2b 22 bc 3f 1b 59 f8 2f de f9 cb 78 1a 68 c9 61 26 26 a6 ab 40 fa 3b be e2 14 da 3e fd 0c 65 .+".?.Y./...x.h.a&&..@.;....>..e
05a0 c3 01 40 00 c1 2c 04 65 4a 6e 90 f9 36 4c ff e3 74 98 be 5b 68 fc fa 26 79 8b 85 fd f3 6d 26 ae ..@..,.eJn..6L..t..[h..&y....m&.
05c0 cf bb ff 30 03 73 3b c3 3d 20 3e 01 4a fd a0 68 c7 d5 b2 26 04 00 02 88 11 a9 a9 cf 08 6d 53 4a ...0.s;.=.>.J..h...&.........mSJ
05e0 01 b1 02 94 e6 02 25 60 50 d8 03 f1 7d 68 8b fa cb 8d 1b 37 fe 91 5b 93 00 04 18 00 05 d2 19 d4 ......%`P...}h.....7..[.........
0600 55 fb 38 7b 00 00 00 00 49 45 4e 44 ae 42 60 82 U.8{....IEND.B`.
f='#n332'>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 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 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559
package any; # $Id$

use diagnostics;
use strict;

#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use detect_devices;
use partition_table;
use fs::type;
use lang;
use run_program;
use devices;
use modules;
use log;
use fs;
use c;

sub facesdir() {
    "$::prefix/usr/share/mdk/faces/";
}
sub face2png {
    my ($face) = @_;
    facesdir() . $face . ".png";
}
sub facesnames() {
    my $dir = facesdir();
    my @l = grep { /^[A-Z]/ } all($dir);
    map { if_(/(.*)\.png/, $1) } (@l ? @l : all($dir));
}

sub addKdmIcon {
    my ($user, $icon) = @_;
    my $dest = "$::prefix/usr/share/faces/$user.png";
    eval { cp_af(facesdir() . $icon . ".png", $dest) } if $icon;
}

sub alloc_user_faces {
    my ($users) = @_;
    my @m = my @l = facesnames();
    foreach (grep { !$_->{icon} || $_->{icon} eq "automagic" } @$users) {
	$_->{auto_icon} = splice(@m, rand(@m), 1); #- known biased (see cookbook for better)
	log::l("auto_icon is $_->{auto_icon}");
	@m = @l unless @m;
    }
}

sub create_user {
    my ($u, $authentication) = @_;

    my @existing = stat("$::prefix/home/$u->{name}");

    if (!getpwnam($u->{name})) {
	my $uid = $u->{uid} || $existing[4];
	if ($uid && getpwuid($uid)) {
	    undef $uid; #- suggested uid already in use
	}
	my $gid = $u->{gid} || $existing[5] || int getgrnam($u->{name});
	if ($gid) {
	    if (getgrgid($gid)) {
		undef $gid if getgrgid($gid) ne $u->{name};
	    } else {
		run_program::rooted($::prefix, 'groupadd', '-g', $gid, $u->{name});
	    }
	} elsif ($u->{rename_from}) {
	    run_program::rooted($::prefix, 'groupmod', '-n', $u->{name}, $u->{rename_from});
	}

	require authentication;
	my $symlink_home_from = $u->{rename_from} && (getpwnam($u->{rename_from}))[7];
	run_program::raw({ root => $::prefix, sensitive_arguments => 1 },
			    ($u->{rename_from} ? 'usermod' : 'adduser'), 
			    '-p', authentication::user_crypted_passwd($u, $authentication),
			    if_($uid, '-u', $uid), if_($gid, '-g', $gid), 
			    if_($u->{realname}, '-c', $u->{realname}),
			    if_($u->{home}, '-d', $u->{home}, if_($u->{rename_from}, '-m')),
			    if_($u->{shell}, '-s', $u->{shell}), 
			    ($u->{rename_from}
			     ? ('-l', $u->{name}, $u->{rename_from})
			     : $u->{name}));
	symlink($u->{home}, $symlink_home_from) if $symlink_home_from;
    }

    my (undef, undef, $uid, $gid, undef, undef, undef, $home) = getpwnam($u->{name});

    if (@existing && $::isInstall && ($uid != $existing[4] || $gid != $existing[5])) {
	log::l("chown'ing $home from $existing[4].$existing[5] to $uid.$gid");
	eval { common::chown_('recursive', $uid, $gid, "$::prefix$home") };
    }
}

sub add_users {
    my ($users, $authentication) = @_;

    alloc_user_faces($users);

    foreach (@$users) {
	create_user($_, $authentication);
	run_program::rooted($::prefix, "usermod", "-G", join(",", @{$_->{groups}}), $_->{name}) if !is_empty_array_ref($_->{groups});
	addKdmIcon($_->{name}, delete $_->{auto_icon} || $_->{icon});
    }
}

sub install_bootloader_pkgs {
    my ($do_pkgs, $b) = @_;

    bootloader::ensure_pkg_is_installed($do_pkgs, $b);
    install_acpi_pkgs($do_pkgs, $b);
}

sub install_acpi_pkgs {
    my ($do_pkgs, $b) = @_;

    my $acpi = bootloader::get_append_with_key($b, 'acpi');
    my $use_acpi = !member($acpi, 'off', 'ht');
    if ($use_acpi) {
	$do_pkgs->ensure_is_installed('acpi', '/usr/bin/acpi', $::isInstall);
	$do_pkgs->ensure_is_installed('acpid', '/usr/sbin/acpid', $::isInstall);
    }
    require services;
    services::set_status($_, $use_acpi, $::isInstall) foreach qw(acpi acpid);
}

sub setupBootloaderBeforeStandalone {
    my ($do_pkgs, $b, $all_hds, $fstab) = @_;
    require keyboard;
    my $keyboard = keyboard::read_or_default();
    my $allow_fb = listlength(cat_("/proc/fb"));
    my $cmdline = cat_('/proc/cmdline');
    my $vga_fb = first($cmdline =~ /\bvga=(\S+)/);
    my $quiet = $cmdline =~ /\bsplash=silent\b/;
    setupBootloaderBefore($do_pkgs, $b, $all_hds, $fstab, $keyboard, $allow_fb, $vga_fb, $quiet);
}

sub setupBootloaderBefore {
    my ($do_pkgs, $bootloader, $all_hds, $fstab, $keyboard, $allow_fb, $vga_fb, $quiet) = @_;
    require bootloader;

    #- auto_install backward compatibility
    #- one should now use {message_text}
    if ($bootloader->{message} =~ m!^[^/]!) {
	$bootloader->{message_text} = delete $bootloader->{message};
    }

    #- remove previous ide-scsi lines
    bootloader::modify_append($bootloader, sub {
	my ($_simple, $dict) = @_;
	@$dict = grep { $_->[1] ne 'ide-scsi' } @$dict;
    });

    if (cat_("/proc/cmdline") =~ /mem=nopentium/) {
	bootloader::set_append_with_key($bootloader, mem => 'nopentium');
    }
    if (cat_("/proc/cmdline") =~ /\b(pci)=(\S+)/) {
	bootloader::set_append_with_key($bootloader, $1, $2);
    }
    if (my ($acpi) = cat_("/proc/cmdline") =~ /\bacpi=(\w+)/) {
	if ($acpi eq 'ht') {
	    #- the user is using the default, which may not be the best
	    my $year = detect_devices::computer_info()->{BIOS_Year};
	    if ($year >= 2002) {
		log::l("forcing ACPI on recent bios ($year)");
		$acpi = '';
	    }
	}
	bootloader::set_append_with_key($bootloader, acpi => $acpi);
    }
    if (cat_("/proc/cmdline") =~ /\bnoapic/) {
	bootloader::set_append_simple($bootloader, 'noapic');
    }
    if (cat_("/proc/cmdline") =~ /\bnoresume/) {
	bootloader::set_append_simple($bootloader, 'noresume');
    } elsif (bootloader::get_append_simple($bootloader, 'noresume')) {
    } else {
	my ($MemTotal) = cat_("/proc/meminfo") =~ /^MemTotal:\s*(\d+)/m;
	if (my ($biggest_swap) = sort { $b->{size} <=> $a->{size} } grep { isSwap($_) } @$fstab) {
	    log::l("MemTotal: $MemTotal < ", $biggest_swap->{size} / 2);
	    if ($MemTotal < $biggest_swap->{size} / 2) {
		bootloader::set_append_with_key($bootloader, resume => fs::wild_device::from_part('', $biggest_swap));
	    }
	}
    }

    #- check for valid fb mode to enable a default boot with frame buffer.
    my $vga = $allow_fb && (!detect_devices::matching_desc__regexp('3D Rage LT') &&
                            !detect_devices::matching_desc__regexp('Rage Mobility [PL]') &&
                            !detect_devices::matching_desc__regexp('i740') &&
                            !detect_devices::matching_desc__regexp('Matrox') &&
                            !detect_devices::matching_desc__regexp('Tseng.*ET6\d00') &&
                            !detect_devices::matching_desc__regexp('SiS.*SG86C2.5') &&
                            !detect_devices::matching_desc__regexp('SiS.*559[78]') &&
                            !detect_devices::matching_desc__regexp('SiS.*300') &&
                            !detect_devices::matching_desc__regexp('SiS.*540') &&
                            !detect_devices::matching_desc__regexp('SiS.*6C?326') &&
                            !detect_devices::matching_desc__regexp('SiS.*6C?236') &&
                            !detect_devices::matching_desc__regexp('Voodoo [35]|Voodoo Banshee') && #- 3d acceleration seems to bug in fb mode
                            !detect_devices::matching_desc__regexp('828[14][05].* CGC') #- i810 & i845 now have FB support during install but we disable it afterwards
                               );
    my $force_vga = $allow_fb && (detect_devices::matching_desc__regexp('SiS.*630') || #- SiS 630 need frame buffer.
                                  detect_devices::matching_desc__regexp('GeForce.*Integrated') #- needed for fbdev driver (hack).
                                 );

    #- propose the default fb mode for kernel fb, if bootsplash is installed.
    my $need_fb = $do_pkgs->are_installed('bootsplash');
    bootloader::suggest($bootloader, $all_hds,
                        vga_fb => ($force_vga || $vga && $need_fb) && $vga_fb,
                        quiet => $quiet);

    $bootloader->{keytable} ||= keyboard::keyboard2kmap($keyboard);
}

sub setupBootloader {
    my ($in, $b, $all_hds, $fstab, $security) = @_;

    require bootloader;
  general:
    {
	local $::Wizard_no_previous = 1 if $::isStandalone;
	setupBootloader__general($in, $b, $all_hds, $fstab, $security) or return 0;
    }
    setupBootloader__boot_bios_drive($in, $b, $all_hds->{hds}) or goto general;
    {
	local $::Wizard_finished = 1 if $::isStandalone;
	setupBootloader__entries($in, $b, $all_hds, $fstab) or goto general;
    }
    1;
}

sub setupBootloaderUntilInstalled {
    my ($in, $b, $all_hds, $fstab, $security) = @_;
    do {
        my $before = fs::fstab_to_string($all_hds);
        setupBootloader($in, $b, $all_hds, $fstab, $security) or $in->exit;
        if ($before ne fs::fstab_to_string($all_hds)) {
            #- for /tmp using tmpfs when "clean /tmp" is chosen
            fs::write_fstab($all_hds);
        }
    } while !installBootloader($in, $b, $all_hds);
}

sub installBootloader {
    my ($in, $b, $all_hds) = @_;
    return if detect_devices::is_xbox();
    install_bootloader_pkgs($in->do_pkgs, $b);

    eval { run_program::rooted($::prefix, 'echo | lilo -u') } if $::isInstall && !$::o->{isUpgrade} && -e "$::prefix/etc/lilo.conf" && glob("$::prefix/boot/boot.*");

  retry:
    eval { 
	my $_w = $in->wait_message(N("Please wait"), N("Bootloader installation in progress"));
	bootloader::install($b, $all_hds);
    };

    if (my $err = $@) {
	$err =~ /wizcancel/ and return;
	$err =~ s/^\w+ failed// or die;
	$err = formatError($err);
	while ($err =~ s/^Warning:.*//m) {}
	if (my ($dev) = $err =~ /^Reference:\s+disk\s+"(.*?)".*^Is the above disk an NT boot disk?/ms) {
	    if ($in->ask_yesorno('',
formatAlaTeX(N("LILO wants to assign a new Volume ID to drive %s.  However, changing
the Volume ID of a Windows NT, 2000, or XP boot disk is a fatal Windows error.
This caution does not apply to Windows 95 or 98, or to NT data disks.

Assign a new Volume ID?", $dev)))) {
		$b->{force_lilo_answer} = 'n';
	    } else {
		$b->{'static-bios-codes'} = 1;
	    }
	    goto retry;
	} else {
	    $in->ask_warn('', [ N("Installation of bootloader failed. The following error occurred:"), $err ]);
	    return;
	}
    } elsif (arch() =~ /ppc/) {
	if (detect_devices::get_mac_model() !~ /IBM/) {
            my $of_boot = bootloader::dev2yaboot($b->{boot});
	    $in->ask_warn('', N("You may need to change your Open Firmware boot-device to\n enable the bootloader.  If you do not see the bootloader prompt at\n reboot, hold down Command-Option-O-F at reboot and enter:\n setenv boot-device %s,\\\\:tbxi\n Then type: shut-down\nAt your next boot you should see the bootloader prompt.", $of_boot));
	}
    }
    1;
}


sub setupBootloader_simple {
    my ($in, $b, $all_hds, $fstab, $security) = @_;
    my $hds = $all_hds->{hds};

    require bootloader;
    bootloader::ensafe_first_bios_drive($hds)
	|| $b->{bootUnsafe} || arch() =~ /ppc/ or return 1; #- default is good enough
    
    if (arch() !~ /ia64/) {
	setupBootloader__mbr_or_not($in, $b, $hds, $fstab) or return 0;
    } else {
      general:
	setupBootloader__general($in, $b, $all_hds, $fstab, $security) or return 0;
    }
    setupBootloader__boot_bios_drive($in, $b, $hds) or goto general;
    1;
}


sub setupBootloader__boot_bios_drive {
    my ($in, $b, $hds) = @_;

    if (arch() =~ /ppc/ ||
	  !is_empty_hash_ref($b->{bios})) {
	#- some bios mapping already there
	return 1;
    } elsif (bootloader::mixed_kind_of_disks($hds) && $b->{boot} =~ /\d$/) { #- on a partition
	# see below
    } else {
	return 1;
    }

    log::l("_ask_boot_bios_drive");
    my $hd = $in->ask_from_listf('', N("You decided to install the bootloader on a partition.
This implies you already have a bootloader on the hard drive you boot (eg: System Commander).

On which drive are you booting?"), \&partition_table::description, $hds) or return 0;
    log::l("mixed_kind_of_disks chosen $hd->{device}");
    $b->{first_hd_device} = "/dev/$hd->{device}";
    1;
}

sub setupBootloader__mbr_or_not {
    my ($in, $b, $hds, $fstab) = @_;

    log::l("setupBootloader__mbr_or_not");

    if (arch() =~ /ppc/) {
	if (defined $partition_table::mac::bootstrap_part) {
	    $b->{boot} = $partition_table::mac::bootstrap_part;
	    log::l("set bootstrap to $b->{boot}"); 
	} else {
	    die "no bootstrap partition - yaboot.conf creation failed";
	}
    } else {
	my $floppy = detect_devices::floppy();

	my @l = (
	    bootloader::ensafe_first_bios_drive($hds) ?
	         (map { [ N("First sector (MBR) of drive %s", partition_table::description($_)) => '/dev/' . $_->{device} ] } @$hds)
	      :
		 [ N("First sector of drive (MBR)") => '/dev/' . $hds->[0]{device} ],
	    
		 [ N("First sector of the root partition") => '/dev/' . fs::get::root($fstab, 'boot')->{device} ],
		     if_($floppy, 
                 [ N("On Floppy") => "/dev/$floppy" ],
		     ),
		 [ N("Skip") => '' ],
		);

	my $default = find { $_->[1] eq $b->{boot} } @l;
	$in->ask_from_({ title => N("Bootloader Installation"),
			 interactive_help_id => 'setupBootloaderBeginner',
		       },
		      [
                          { label => N("Where do you want to install the bootloader?"), title => 1 },
                          { val => \$default, list => \@l, format => sub { $_[0][0] }, type => 'list' },
                       ]
                  );
	my $new_boot = $default->[1];

	#- remove bios mapping if the user changed the boot device
	delete $b->{bios} if $new_boot && $new_boot ne $b->{boot};
	$b->{boot} = $new_boot or return;
    }
    1;
}

sub setupBootloader__general {
    my ($in, $b, $all_hds, $fstab, $security) = @_;

    return if detect_devices::is_xbox();
    my @method_choices = bootloader::method_choices($all_hds);
    my $prev_force_acpi = my $force_acpi = bootloader::get_append_with_key($b, 'acpi') !~ /off|ht/;
    my $prev_enable_apic = my $enable_apic = !bootloader::get_append_simple($b, 'noapic');
    my $prev_enable_lapic = my $enable_lapic = !bootloader::get_append_simple($b, 'nolapic');
    my $prev_enable_smp = my $enable_smp = !bootloader::get_append_simple($b, 'nosmp');
    my $prev_clean_tmp = my $clean_tmp = any { $_->{mntpoint} eq '/tmp' } @{$all_hds->{special} ||= []};
    my $prev_boot = $b->{boot};
    my $prev_method = $b->{method};

    $b->{password2} ||= $b->{password} ||= '';
    $::Wizard_title = N("Boot Style Configuration");
    if (arch() !~ /ppc/) {
	my (@boot_devices, %boot_devices);
	foreach (bootloader::allowed_boot_parts($b, $all_hds)) {
	    my $dev = "/dev/$_->{device}";
	    push @boot_devices, $dev;
	    $boot_devices{$dev} = $_->{info} ? "$dev ($_->{info})" : $dev;
	}

	$in->ask_from_({ #messages => N("Bootloader main options"),
			 title => N("Bootloader main options"),
			 interactive_help_id => 'setupBootloader',
		       }, [
			 #title => N("Bootloader main options"),
            { label => N("Bootloader"), title => 1 },
            { label => N("Bootloader to use"), val => \$b->{method}, list => \@method_choices, format => \&bootloader::method2text },
                if_(arch() !~ /ia64/,
            { label => N("Boot device"), val => \$b->{boot}, list => \@boot_devices, format => sub { $boot_devices{$_[0]} } },
		),
            { label => N("Main options"), title => 1 },
            { label => N("Delay before booting default image"), val => \$b->{timeout} },
            { text => N("Enable ACPI"), val => \$force_acpi, type => 'bool' },
            { text => N("Enable SMP"), val => \$enable_smp, type => 'bool', advanced => 1 },
            { text => N("Enable APIC"), val => \$enable_apic, type => 'bool', advanced => 1, disabled => sub { !$enable_lapic } }, 
            { text => N("Enable Local APIC"), val => \$enable_lapic, type => 'bool', advanced => 1 },
		if_($security >= 4 || $b->{password} || $b->{restricted},
	    { label => N("Password"), val => \$b->{password}, hidden => 1,
	      validate => sub { 
		  my $ok = $b->{password} eq $b->{password2} or $in->ask_warn('', [ N("The passwords do not match"), N("Please try again") ]);
		  my $ok2 = !($b->{password} && $b->{method} eq 'grub-graphic') or $in->ask_warn('', N("You can not use a password with %s", bootloader::method2text($b->{method})));
		  $ok && $ok2;
	      } },
            { label => N("Password (again)"), val => \$b->{password2}, hidden => 1 },
            { text => N("Restrict command line options"), val => \$b->{restricted}, type => "bool", text => N("restrict"),
	      validate => sub { my $ok = !$b->{restricted} || $b->{password} or $in->ask_warn('', N("Option ``Restrict command line options'' is of no use without a password")); $ok } },
		),
            { text => N("Clean /tmp at each boot"), val => \$clean_tmp, type => 'bool', advanced => 1 },
        ]) or return 0;
    } else {
	$b->{boot} = $partition_table::mac::bootstrap_part;	
	$in->ask_from_({ messages => N("Bootloader main options"),
			 title => N("Bootloader main options"),
			 interactive_help_id => 'setupYabootGeneral',
		       }, [
            { label => N("Bootloader to use"), val => \$b->{method}, list => \@method_choices, format => \&bootloader::method2text },
            { label => N("Init Message"), val => \$b->{'init-message'} },
            { label => N("Boot device"), val => \$b->{boot}, list => [ map { "/dev/$_" } (map { $_->{device} } (grep { isAppleBootstrap($_) } @$fstab)) ] },
            { label => N("Open Firmware Delay"), val => \$b->{delay} },
            { label => N("Kernel Boot Timeout"), val => \$b->{timeout} },
            { label => N("Enable CD Boot?"), val => \$b->{enablecdboot}, type => "bool" },
            { label => N("Enable OF Boot?"), val => \$b->{enableofboot}, type => "bool" },
            { label => N("Default OS?"), val => \$b->{defaultos}, list => [ 'linux', 'macos', 'macosx', 'darwin' ] },
        ]) or return 0;				
    }

    #- remove bios mapping if the user changed the boot device
    delete $b->{bios} if $b->{boot} ne $prev_boot;

    if ($b->{boot} =~ m!/dev/md\d+$!) {
	$b->{'raid-extra-boot'} = 'mbr';
    } else {
	delete $b->{'raid-extra-boot'} if $b->{'raid-extra-boot'} eq 'mbr';
    }

    bootloader::ensure_pkg_is_installed($in->do_pkgs, $b) or goto &setupBootloader__general;

    bootloader::suggest_message_text($b) if ! -e "$::prefix/boot/message-text"; #- in case we switch from grub to lilo

    if ($prev_force_acpi != $force_acpi) {
	bootloader::set_append_with_key($b, acpi => ($force_acpi ? '' : 'ht'));
    }

    if ($prev_enable_smp != $enable_smp) {
	($enable_smp ? \&bootloader::remove_append_simple : \&bootloader::set_append_simple)->($b, 'nosmp');
    }

    if ($prev_enable_apic != $enable_apic) {
	($enable_apic ? \&bootloader::remove_append_simple : \&bootloader::set_append_simple)->($b, 'noapic');
	($enable_apic ? \&bootloader::set_append_simple : \&bootloader::remove_append_simple)->($b, 'apic');
    }
    if ($prev_enable_lapic != $enable_lapic) {
	($enable_lapic ? \&bootloader::remove_append_simple : \&bootloader::set_append_simple)->($b, 'nolapic');
	($enable_lapic ? \&bootloader::set_append_simple : \&bootloader::remove_append_simple)->($b, 'lapic');
    }

    if ($prev_clean_tmp != $clean_tmp) {
	if ($clean_tmp && !fs::get::has_mntpoint('/tmp', $all_hds)) {
	    push @{$all_hds->{special}}, { device => 'none', mntpoint => '/tmp', fs_type => 'tmpfs' };
	} else {
	    @{$all_hds->{special}} = grep { $_->{mntpoint} ne '/tmp' } @{$all_hds->{special}};
	}
    }

    if (bootloader::main_method($prev_method) eq 'lilo' && 
	bootloader::main_method($b->{method}) eq 'grub') {
	log::l("switching for lilo to grub, ensure we don't read lilo.conf anymore");
	renamef("$::prefix/etc/lilo.conf", "$::prefix/etc/lilo.conf.unused");
    }
    1;
}

sub setupBootloader__entries {
    my ($in, $b, $all_hds, $fstab) = @_;

    require Xconfig::resolution_and_depth;

    my $Modify = sub {
	require network::network; #- to list network profiles
	my ($e) = @_;
	my $default = my $old_default = $e->{label} eq $b->{default};
	my $vga = Xconfig::resolution_and_depth::from_bios($e->{vga});
	my ($append, $netprofile) = bootloader::get_append_netprofile($e);

	my %hd_infos = map { $_->{device} => $_->{info} } fs::get::hds($all_hds);
	my %root_descr = map { 
	    my $info = delete $hd_infos{$_->{rootDevice}};
	    my $dev = "/dev/$_->{device}";
	    my $info_ = $info ? "$dev ($info)" : $dev;
	    ($dev => $info_, fs::wild_device::from_part('', $_) => $info_);
	} @$fstab;

	my @l;
	if ($e->{type} eq "image") { 
	    @l = (
{ label => N("Image"), val => \$e->{kernel_or_dev}, list => [ map { "/boot/$_" } bootloader::installed_vmlinuz() ], not_edit => 0 },
{ label => N("Root"), val => \$e->{root}, list => [ map { fs::wild_device::from_part('', $_) } @$fstab ], format => sub { $root_descr{$_[0]} }  },
{ label => N("Append"), val => \$append },
  if_($e->{xen}, 
{ label => N("Xen append"), val => \$e->{xen_append} }
  ),
  if_(arch() !~ /ppc|ia64/,
{ label => N("Video mode"), val => \$vga, list => [ '', Xconfig::resolution_and_depth::bios_vga_modes() ], format => \&Xconfig::resolution_and_depth::to_string, advanced => 1 },
),
{ label => N("Initrd"), val => \$e->{initrd}, list => [ map { if_(/^initrd/, "/boot/$_") } all("$::prefix/boot") ], not_edit => 0, advanced => 1 },
{ label => N("Network profile"), val => \$netprofile, list => [ sort(uniq('', $netprofile, network::network::netprofile_list())) ], advanced => 1 },
	    );
	} else {
	    @l = ( 
{ label => N("Root"), val => \$e->{kernel_or_dev}, list => [ map { "/dev/$_->{device}" } @$fstab, detect_devices::floppies() ] },
	    );
	}
	if (arch() !~ /ppc/) {
	    @l = (
		  { label => N("Label"), val => \$e->{label} },
		  @l,
		  { text => N("Default"), val => \$default, type => 'bool' },
		 );
	} else {
	    unshift @l, { label => N("Label"), val => \$e->{label}, list => ['macos', 'macosx', 'darwin'] };
	    if ($e->{type} eq "image") {
		@l = ({ label => N("Label"), val => \$e->{label} },
		(@l[1..2], { label => N("Append"), val => \$append }),
		{ label => N("NoVideo"), val => \$e->{novideo}, type => 'bool' },
		{ text => N("Default"), val => \$default, type => 'bool' }
		);
	    }
	}

	$in->ask_from_(
	    {
	     interactive_help_id => arch() =~ /ppc/ ? 'setupYabootAddEntry' : 'setupBootloaderAddEntry',
	     callbacks => {
	       complete => sub {
		   $e->{label} or $in->ask_warn('', N("Empty label not allowed")), return 1;
		   $e->{kernel_or_dev} or $in->ask_warn('', $e->{type} eq 'image' ? N("You must specify a kernel image") : N("You must specify a root partition")), return 1;
		   member(lc $e->{label}, map { lc $_->{label} } grep { $_ != $e } @{$b->{entries}}) and $in->ask_warn('', N("This label is already used")), return 1;
		   0;
	       } } }, \@l) or return;

	$b->{default} = $old_default || $default ? $default && $e->{label} : $b->{default};
	my $new_vga = ref($vga) ? $vga->{bios} : $vga;
	if ($new_vga ne $e->{vga}) {
	    $e->{vga} = $new_vga;
	    $e->{initrd} and bootloader::add_boot_splash($e->{initrd}, $e->{vga});
	}
	bootloader::set_append_netprofile($e, $append, $netprofile);
	bootloader::configure_entry($b, $e); #- hack to make sure initrd file are built.
	1;
    };

    my $Add = sub {
	my @labels = map { $_->{label} } @{$b->{entries}};
	my ($e, $prefix);
	if ($in->ask_from_list_('', N("Which type of entry do you want to add?"),
				[ N_("Linux"), arch() =~ /sparc/ ? N_("Other OS (SunOS...)") : arch() =~ /ppc/ ? 
				  N_("Other OS (MacOS...)") : N_("Other OS (Windows...)") ]
			       ) eq "Linux") {
	    $e = { type => 'image',
		   root => '/dev/' . fs::get::root($fstab)->{device}, #- assume a good default.
		 };
	    $prefix = "linux";
	} else {
	    $e = { type => 'other' };
	    $prefix = arch() =~ /sparc/ ? "sunos" : arch() =~ /ppc/ ? "macos" : "windows";
	}
	$e->{label} = $prefix;
	for (my $nb = 0; member($e->{label}, @labels); $nb++) {
	    $e->{label} = "$prefix-$nb";
	}
	$Modify->($e) or return;
	bootloader::add_entry($b, $e);
	$e;
    };

    my $Remove = sub {
	my ($e) = @_;
	delete $b->{default} if $b->{default} eq $e->{label};
	@{$b->{entries}} = grep { $_ != $e } @{$b->{entries}};
	1;
    };

    my $Up = sub {
	my ($e) = @_;
	my @entries = @{$b->{entries}};
	my ($index) = grep { $entries[$_]->{label} eq $e->{label} } 0..$#entries;
	if ($index > 0) {
	  (@{$b->{entries}}->[$index - 1], @{$b->{entries}}->[$index]) = (@{$b->{entries}}->[$index], @{$b->{entries}}->[$index - 1]);
	}
	1;
    };
    
    my $Down = sub {
	my ($e) = @_;
	my @entries = @{$b->{entries}};
	my ($index) = grep { $entries[$_]->{label} eq $e->{label} } 0..$#entries;
	if ($index < $#entries) {
	  (@{$b->{entries}}->[$index + 1], @{$b->{entries}}->[$index]) = (@{$b->{entries}}->[$index], @{$b->{entries}}->[$index + 1]);
	}
	1;
    };

    my @prev_entries = @{$b->{entries}};
    if ($in->ask_from__add_modify_remove(N("Bootloader Configuration"),
N("Here are the entries on your boot menu so far.
You can create additional entries or change the existing ones."), [ { 
        format => sub {
	    my ($e) = @_;
	    ref($e) ? 
	      ($b->{default} eq $e->{label} ? "  *  " : "     ") . "$e->{label} ($e->{kernel_or_dev})" : 
		translate($e);
	}, list => $b->{entries},
    } ], Add => $Add, Modify => $Modify, Remove => $Remove, Up => $Up, Down => $Down)) {
	1;
    } else {
	@{$b->{entries}} = @prev_entries;
	'';
    }
}

sub get_autologin() {
    my %desktop = getVarsFromSh("$::prefix/etc/sysconfig/desktop");
    my $gdm_file = "$::prefix/etc/X11/gdm/custom.conf";
    my $kdm_file = common::read_alternative('kdm4-config');
    my $autologin_file = "$::prefix/etc/sysconfig/autologin";
    my $desktop = $desktop{DESKTOP} || first(sessions());
    my %desktop_to_dm = (
        GNOME => 'gdm',
        KDE4 => 'kdm',
        xfce4 => 'gdm',
        LXDE => 'gdm',
    );
    my %dm_canonical = (
        gnome => 'gdm',
        kde => 'kdm',
    );
    my $dm =
      lc($desktop{DISPLAYMANAGER}) ||
      $desktop_to_dm{$desktop} ||
      basename(chomp_(run_program::rooted_get_stdout($::prefix, "/etc/X11/lookupdm")));
    $dm = $dm_canonical{$dm} if exists $dm_canonical{$dm};

    my $autologin_user;
    if ($dm eq "gdm") {
        my %conf = read_gnomekderc($gdm_file, 'daemon');
        $autologin_user = text2bool($conf{AutomaticLoginEnable}) && $conf{AutomaticLogin};
    } elsif ($dm eq "kdm") {
        my %conf = read_gnomekderc($kdm_file, 'X-:0-Core');
        $autologin_user = text2bool($conf{AutoLoginEnable}) && $conf{AutoLoginUser};
    } else {
        my %conf = getVarsFromSh($autologin_file);
        $autologin_user = text2bool($conf{AUTOLOGIN}) && $conf{USER};
    }

    { user => $autologin_user, desktop => $desktop, dm => $dm };
}

sub set_autologin {
    my ($do_pkgs, $autologin) = @_;
    log::l("set_autologin $autologin->{user} $autologin->{desktop}");
    my $do_autologin = bool2text($autologin->{user});

    $autologin->{dm} ||= 'xdm';
    $do_pkgs->ensure_is_installed($autologin->{dm})
      or return;
    if ($autologin->{user} && $autologin->{dm} eq 'xdm') {
        $do_pkgs->ensure_is_installed('autologin', '/usr/bin/startx.autologin')
          or return;
    }

    #- Configure KDM / MDKKDM
    my $kdm_conffile = common::read_alternative('kdm4-config');
    eval { common::update_gnomekderc_no_create($kdm_conffile, 'X-:0-Core' => (
	AutoLoginEnable => $do_autologin,
	AutoLoginUser => $autologin->{user},
    )) } if -e $kdm_conffile;

    #- Configure GDM
    my $gdm_conffile = "$::prefix/etc/X11/gdm/custom.conf";
    eval { update_gnomekderc($gdm_conffile, daemon => (
	AutomaticLoginEnable => $do_autologin,
	AutomaticLogin => $autologin->{user},
    )) } if -e $gdm_conffile;

    my $xdm_autologin_cfg = "$::prefix/etc/sysconfig/autologin";
    if ($autologin->{dm} eq 'xdm') {
	setVarsInShMode($xdm_autologin_cfg, 0644,
			{ USER => $autologin->{user}, AUTOLOGIN => bool2yesno($autologin->{user}), EXEC => '/usr/bin/startx.autologin' });
    } else {
	unlink $xdm_autologin_cfg;
    }

    my $sys_conffile = "$::prefix/etc/sysconfig/desktop";
    my %desktop = getVarsFromSh($sys_conffile);
    $desktop{DESKTOP} = $autologin->{desktop};
    $desktop{DISPLAYMANAGER} = $autologin->{dm};
    setVarsInSh($sys_conffile, \%desktop);

    if ($autologin->{user}) {
	my $home = (getpwnam($autologin->{user}))[7];
	set_window_manager($home, $autologin->{desktop});
    }
}
sub set_window_manager {
    my ($home, $wm) = @_;
    log::l("set_window_manager $home $wm");
    my $p_home = "$::prefix$home";

    #- for KDM/GDM
    my $wm_number = sessions_with_order()->{$wm} || '';
    update_gnomekderc("$p_home/.dmrc", 'Desktop', Session => "$wm_number$wm");
    my $user = find { $home eq $_->[7] } list_passwd();
    chown($user->[2], $user->[3], "$p_home/.dmrc");
    chmod(0644, "$p_home/.dmrc");

    #- for startx/autologin
    {
	my %l = getVarsFromSh("$p_home/.desktop");
	$l{DESKTOP} = $wm;
	setVarsInSh("$p_home/.desktop", \%l);
    }
}

sub rotate_log {
    my ($f) = @_;
    if (-e $f) {
	my $i = 1;
	for (; -e "$f$i" || -e "$f$i.gz"; $i++) {}
	rename $f, "$f$i";
    }
}
sub rotate_logs {
    my ($prefix) = @_;
    rotate_log("$prefix/root/drakx/$_") foreach qw(stage1.log ddebug.log install.log updates.log);
}

sub writeandclean_ldsoconf {
    my ($prefix) = @_;
    my $file = "$prefix/etc/ld.so.conf";
    my @l = chomp_(cat_($file));

    my @default = ('/lib', '/usr/lib'); #- no need to have /lib and /usr/lib in ld.so.conf
    my @suggest = ('/usr/X11R6/lib', '/usr/lib/qt3/lib'); #- needed for upgrade where package renaming can cause this to disappear

    if (arch() =~ /x86_64/) {
	@default = map { $_, $_ . '64' } @default;
	@suggest = map { $_, $_ . '64' } @suggest;
    }
    push @l, grep { -d "$::prefix$_" } @suggest;
    @l = difference2(\@l, \@default);

    log::l("writeandclean_ldsoconf");
    output($file, map { "$_\n" } uniq(@l));
}

sub shells() {
    grep { -x "$::prefix$_" } chomp_(cat_("$::prefix/etc/shells"));
}

sub inspect {
    my ($part, $o_prefix, $b_rw) = @_;

    isMountableRW($part) || !$b_rw && isOtherAvailableFS($part) or return;

    my $dir = $::isInstall ? "/tmp/inspect_tmp_dir" : "/root/.inspect_tmp_dir";

    if ($part->{isMounted}) {
	$dir = ($o_prefix || '') . $part->{mntpoint};
    } elsif ($part->{notFormatted} && !$part->{isFormatted}) {
	$dir = '';
    } else {
	mkdir $dir, 0700;
	eval { fs::mount::mount(fs::wild_device::from_part('', $part), $dir, $part->{fs_type}, !$b_rw) };
	$@ and return;
    }
    my $h = before_leaving {
	if (!$part->{isMounted} && $dir) {
	    fs::mount::umount($dir);
	    unlink($dir);
	}
    };
    $h->{dir} = $dir;
    $h;
}

sub ask_user {
    my ($in, $users, $security, %options) = @_;

    ask_user_and_root($in, undef, $users, $security, %options);
}

sub is_xguest_installed() {
    -e "$::prefix/etc/security/namespace.d/guest.conf";
}

sub ask_user_and_root {
    my ($in, $superuser, $users, $security, %options) = @_;

    my $xguest = is_xguest_installed();

    $options{needauser} ||= $security >= 3;

    my @icons = facesnames();
    my @suggested_names = $::isInstall ? do {
	my @l = grep { !/^\./ && $_ ne 'lost+found' && -d "$::prefix/home/$_" } all("$::prefix/home");
	grep { ! defined getpwnam($_) } @l;
    } : ();

    my %high_security_groups = (
        xgrp => N("access to X programs"),
	rpm => N("access to rpm tools"),
	wheel => N("allow \"su\""),
	adm => N("access to administrative files"),
	ntools => N("access to network tools"),
	ctools => N("access to compilation tools"),
    );

    my $u = {};
    $u->{password2} ||= $u->{password} ||= '';
    $u->{shell} ||= '/bin/bash';
    my $names = @$users ? N("(already added %s)", join(", ", map { $_->{realname} || $_->{name} } @$users)) : '';
    
    my %groups;

    require authentication;
    my $validate_name = sub {
	$u->{name} or $in->ask_warn('', N("Please give a user name")), return;
        $u->{name} =~ /^[a-z]+[a-z0-9_-]*$/ or $in->ask_warn('', N("The user name must start with a lower case letter followed by only lower cased letters, numbers, `-' and `_'")), return;
        length($u->{name}) <= 32 or $in->ask_warn('', N("The user name is too long")), return;
        defined getpwnam($u->{name}) || member($u->{name}, map { $_->{name} } @$users) and $in->ask_warn('', N("This user name has already been added")), return;
	'ok';
    };
    my $validate_uid_gid = sub {
	my ($field) = @_;
	my $id = $u->{$field} or return 'ok';
	my $name = $field eq 'uid' ? N("User ID") : N("Group ID");
	$id =~ /^\d+$/ or $in->ask_warn('', N("%s must be a number", $name)), return;
	$id >= 500 or $in->ask_yesorno('', N("%s should be above 500. Accept anyway?", $name)) or return;
	'ok';
    };
    my $ret = $in->ask_from_(
        { title => N("User management"),
          interactive_help_id => 'addUser',
	  if_($::isInstall && $superuser, cancel => ''),
          focus_first => 1,
        }, [ 
	      $superuser ? (
	  { text => N("Enable guest account"), val => \$xguest, type => 'bool', advanced => 1 },
	  { label => N("Set administrator (root) password"), title => 1 },
	  { label => N("Password"), val => \$superuser->{password},  hidden => 1, alignment => 'right', weakness_check => 1,
	    validate => sub { authentication::check_given_password($in, $superuser, 2 * $security) } },
	  { label => N("Password (again)"), val => \$superuser->{password2}, hidden => 1, alignment => 'right' },
              ) : (),
	  { label => N("Enter a user"), title => 1 }, if_($names, { label => $names }),
           if_($security <= 3 && !$options{noicons} && @icons,
	  { label => N("Icon"), val => \ ($u->{icon} ||= 'default'), list => \@icons, icon2f => \&face2png,
            alignment => 'right', format => \&translate },
           ),
	  { label => N("Real name"), val => \$u->{realname}, alignment => 'right', focus_out => sub {
		$u->{name} ||= lc(Locale::gettext::iconv($u->{realname}, "utf-8", "ascii//TRANSLIT"));
                $u->{name} =~ s/[^a-zA-Z0-9_-]//g; # drop any charcter that would break login program
	    } },

          { label => N("Login name"), val => \$u->{name}, list => \@suggested_names, alignment => 'right',
            not_edit => 0, validate => $validate_name },
          { label => N("Password"),val => \$u->{password}, hidden => 1, alignment => 'right', weakness_check => 1,
	    validate => sub { authentication::check_given_password($in, $u, $security > 3 ? 6 : 0) } },
          { label => N("Password (again)"), val => \$u->{password2}, hidden => 1, alignment => 'right' },
          { label => N("Shell"), val => \$u->{shell}, list => [ shells() ], advanced => 1 },
	  { label => N("User ID"), val => \$u->{uid}, advanced => 1, validate => sub { $validate_uid_gid->('uid') } },
	  { label => N("Group ID"), val => \$u->{gid}, advanced => 1, validate => sub { $validate_uid_gid->('gid') } },
	    if_($security > 3,
                map {
                    { label => $_, val => \$groups{$_}, text => $high_security_groups{$_}, type => 'bool' };
                } keys %high_security_groups,
               ),
	  ],
    );

    if ($xguest && !is_xguest_installed()) {
        $in->do_pkgs->ensure_is_installed('xguest', '/etc/security/namespace.d/guest.conf');
    } elsif (!$xguest && is_xguest_installed()) {
        $in->do_pkgs->remove('xguest') or return;
    }

    $u->{groups} = [ grep { $groups{$_} } keys %groups ];

    push @$users, $u if $u->{name};

    $ret && $u;
}

sub sessions() {
    split(' ', run_program::rooted_get_stdout($::prefix, '/usr/sbin/chksession', '-l'));
}
sub sessions_with_order() {
    my %h = map { /(.*)=(.*)/ } split(' ', run_program::rooted_get_stdout($::prefix, '/usr/sbin/chksession', '-L'));
    \%h;
}

sub urpmi_add_all_media {
    my ($in, $o_previous_release) = @_;

    my $binary = find { whereis_binary($_, $::prefix) } 'gurpmi.addmedia', 'urpmi.addmedia' or return;
    
    #- configure urpmi media if network is up
    require network::tools;
    return if !network::tools::has_network_connection();
    my $wait;
    my @options = ('--distrib', '--mirrorlist', '$MIRRORLIST');
    if ($binary eq 'urpmi.addmedia') {
	$wait = $in->wait_message(N("Please wait"), N("Please wait, adding media..."));
    } elsif ($in->isa('interactive::gtk')) {
	push @options, '--silent-success';
	mygtk2::flush();
    }

    my $reason = join(',', $o_previous_release ? 
      ('reason=upgrade', 'upgrade_by=drakx', "upgrade_from=$o_previous_release->{version}") :
       'reason=install');
    log::l("URPMI_ADDMEDIA_REASON $reason");