Well here is a little description of how DrakX can be modified or extended. Please refer to README file for getting DrakX code source and to known more exactly how it works and what it can do. ******************************************************************************** * Execution of DrakX *********************************************************** ******************************************************************************** DrakX has originally be written by pixel in perl and C. entry point for stage2 is /usr/bin/runinstall2 which is typically a link to /usr/bin/install2 which simply load module install2.pm and execute install2::main with @ARGV. install2::main parse command line arguments, prepare installation, find the right install_interactive class (take a look at gi/docs/object_class.fig) according to command line, memory available and if the interactive chosen is initializing correctly, else it will try a less-demanding interactive object. Once done, $::o is set to this install & interactive object and main runs the various step of install2 defined in $o->{steps}, starting with $o->{steps}{first} and iterating with method install_any::getNextStep(). while running step, it trap any errors that may arise and use perl exception to change step. ******************************************************************************** * DrakX modules descriptions *************************************************** ******************************************************************************** Here is a brief description of what each modules of DrakX is doing. install2: main module of DrakX as described above, main loop execution of DrakX. install_steps: generic installation module containing steps definition, all steps should always be defined here as some methods may be used on automatic mode. there is no interactivity available. typically are defined base operation for configuring each step according to $o. install_steps_interactive: generic installation module with generic interative methods. typically are found all interactive code of DrakX for each steps. install_steps_auto_install: implementation installation module without interactive methods to match auto_install mode. this is the simplest as almost no method are redefined (inherit module install_steps only, compared to other implementation modules described below). install_steps_stdio: implementation installation module with interactive stdio methods to match stdio mode. inherit modules install_steps_interactive and interactive_stdio. install_steps_newt: implementation installation module with interactive newt methods to match newt mode. inherit modules install_steps_interactive and interactive_newt. install_steps_gtk: implementation installation module with interactive gtk methods to match gtk mode. inherit modules install_steps_interactive and interactive_gtk. install_any: contains various methods using generic interactive interface but not used by standalone tools. install_gtk: contains various methods using gtk interface but not used by standalone tools. interactive_stdio: implementation methods for interactivity in stdio mode. inherit module interactive. interactive_newt: implementation methods for interactivity in newt mode. inherit module interactive. interactive_gtk: implementation methods for interactivity in gtk mode. inherit module interactive. my_gtk: basic gtk access methods. any: contains various methods using generic interactive interface. to compare against install_any module as this one is available for standalone tools. class_discard: simple module that implement every methods undefined to return nothing. this trick is used to ensure no undefined method can arise when using code that reference interactive method which are not defined. common: contains very simple and very usefull (common) methods to do various task. some methods inspired by functionnal language. c: contains wrapper to C definition of methods used by DrakX, use of C is necessary for C extern libraries interface (rpmlib, ldetect), kernel interface, XFree interface. commands: implement some un*x commands, conflicting name with perl contains trailing underscore (_). this module is used by commands perl script that determine which command to run according to $0 (this is used this way when DrakX is running). run_program: allow running a program with redirection but without using a shell. allow rooted execution. help: contains all help message displayed by DrakX. log: log facility methods. lang: language manipulation methods, get and set sysconfig file, load po. keyboard: keyboard manipulation methods, get and set sysconfig file, set console keyboard mapping. mouse: mouse manipulation methods, get and set sysconfig file, change mouse. timezone: time zone manipulation methods, get and set timezone. services: services manipulation methods, activate or delete services (see /etc/rc.d/init.d directories). detect_devices: manage detection of various class of hardware. devices: manage device file, create device special according device name. partition_table: base partition table management methods, it manages appriopriate partition_table_XXX object according to what has been read as XXX partition table type. partition_table_raw: generic class for the following partition_table_XXX. partition_table_emtpy: matches an empty partition table. partition_table_dos: matches a DOS partition table. partition_table_bsd: matches a BSD partition table. partition_table_mac: matches an Apple partition table. partition_table_sun: matches a Sun Label partition table. fs: read and write /etc/fstab file, mount and umount, format. fsedit: manage (modyfy, edit) mount point associated to partition (like editing /etc/fstab). swap: swap management methods, format and mount (activation). raid: raid (software only) management methods. lvm: lvm (Logical Volume Manager) management methods. loopback: loopback management methods, used for lnx4win type installation or using a file as a partition. diskdrake: diskdrake itself, disk graphical (using gtk) manipulation tools. ftp: ftp mangement methods, used when using ftp install. http: http management methods, used when using http install. modparm: kernel modules options management, allow building nice dialog with each module parameter available. modules: kernel modules management, allow loading or unloading (ala modprobe or insmod). printer: printer management methods, read and write both LPR or CUPS configuration. printerdrake: interactive printer management methods. network: network management methods, get and set sysconfig file. netconnect: network configuration wizard. netconnect_const: network configuration wirard data. Xconfig: X configuration (monitor + already existing config file) management. Xconfigurator: X configuration wizard. Xconfigurator_const: X configuration wizard data. booloader: bootloader (LILO, GRUB, LOADLIN, SILO) configuration management methods. pkgs: rpm package and hdlist, depslist management methods, allow selecting or unselecting packages, manage rpmsrate file and select group, installation and removal methods of rpm file. crypto: *obsoleted* module to manage crypto site and rpm file. standalone: standalone only, allow defining a standalone tools. bootlook: standalone only, interface with DrakConf to configure bootloader options. tinyfirewall: standalone only, interface with DrakConf to configure a tiny firewall. ******************************************************************************** * DrakX FAT resizer module description ***************************************** ******************************************************************************** here is a fat resizer written in perl and C used by DrakX (diskdrake) to resize FAT16/FAT32 partition. it moves clusters to make sure a shrink can be done on the limit of the partition itself, if no cluster need to be moved, only boot sector partition limit are modified. any: various methods to flag cluster, compute min size. boot_sector: boot sector management methods. c_rewritten: originally resize_fat was only perl, this contains code section that are the most sensible to speed or memory contraints and have been rewritten to C using perl extension. dir_entry: manage directory structure. directory: traverse directory recursively, needed to move correctly cluster. fat: manage fat structure. info_sector: manage info sector. io: manage I/O on disk (need to take care of big file as partition size may be larger than 2GB). main: main resizer algortihm. if needed allocate new clusters, copy files, copy directories. update boot sector info. ******************************************************************************** * Adding a new step to DrakX *************************************************** ******************************************************************************** Say we want to add a question for setting "alawindows" option. We put it pretty early in the install, let's say after "Select Installation Class". 1. in install2.pm add selectAlawindows => [ __("A la windows or not"), 0, 1, '' ], after selectInstallClass => [ __("Select installation class"), 1, 1, '' ], the 0, 1, '' means not "redoable", "skip on error", "don't hide" 2. add your function selectAlawindows in install2.pm sub selectAlawindows { $o->selectAlawindows } 3. add your function selectAlawindows in install_steps_interactive.pm sub selectAlawindows { my ($o) = @_; $o->{alawindows} = $o->ask_yesorno('', _("Throw everything away as windobe does?"), 1); } 4. add your function selectAlawindows in install_steps.pm (not needed in that case, except for auto_install) sub selectAlawindows {} 8 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 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
package install::steps; # $Id: steps.pm 268013 2010-04-29 15:02:04Z pterjan $
use diagnostics;
use strict;
use vars qw(@filesToSaveForUpgrade @filesNewerToUseAfterUpgrade);
#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use install::any 'addToBeDone';
use partition_table;
use detect_devices;
use fs::any;
use fs::type;
use fs::partitioning;
use modules;
use run_program;
use lang;
use keyboard;
use fsedit;
use do_pkgs;
use install::pkgs;
use any;
use log;
our @ISA = qw(do_pkgs);
@filesToSaveForUpgrade = qw(
/etc/ld.so.conf /etc/fstab /etc/hosts /etc/conf.modules /etc/modules.conf
);
@filesNewerToUseAfterUpgrade = qw(
/etc/profile
);
#-######################################################################################
#- OO Stuff
#-######################################################################################
sub new($$) {
my ($type, $o) = @_;
bless $o, ref($type) || $type;
return $o;
}
sub charsetChanged {
my ($_o) = @_;
}
#-######################################################################################
#- In/Out Steps Functions
#-######################################################################################
sub enteringStep {
my ($_o, $step) = @_;
log::l("starting step `$step'");
}
sub leavingStep {
my ($o, $step) = @_;
log::l("step `$step' finished");
if (-d "$::prefix/root/drakx") {
eval { cp_af("/tmp/ddebug.log", "$::prefix/root/drakx") };
output(install::any::auto_inst_file(), install::any::g_auto_install(1));
}
foreach my $s (@{$o->{orderedSteps}}) {
#- the reachability property must be recomputed each time to take
#- into account failed step.
next if $o->{steps}{$s}{done} && !$o->{steps}{$s}{redoable};
my $reachable = 1;
if (my $needs = $o->{steps}{$s}{needs}) {
my @l = ref($needs) ? @$needs : $needs;
$reachable = min(map { $o->{steps}{$_}{done} || 0 } @l);
}
$o->{steps}{$s}{reachable} = 1 if $reachable;
}
$o->{steps}{$step}{reachable} = $o->{steps}{$step}{redoable};
while (my $f = shift @{$o->{steps}{$step}{toBeDone} || []}) {
eval { &$f() };
if (my $err = $@) {
$o->ask_warn(N("Error"), [
N("An error occurred, but I do not know how to handle it nicely.
Continue at your own risk."), formatError($err) || $err ]);
}
}
}
sub errorInStep {
my ($_o, $err) = @_;
print "error :(\n";
print "$err\n\n";
c::_exit(1);
}
sub kill_action {}
#-######################################################################################
#- Steps Functions
#-######################################################################################
#------------------------------------------------------------------------------
sub selectLanguage {
my ($o) = @_;
$o->{locale}{langs} ||= { $o->{locale}{lang} => 1 };
if (!exists $o->{locale}{country}) {
lang::lang_changed($o->{locale});
}
add2hash_($o->{locale}, { utf8 => lang::utf8_should_be_needed($o->{locale}) });
lang::set($o->{locale}, !$o->isa('interactive::gtk'));
log::l("selectLanguage: pack_langs: ", lang::pack_langs($o->{locale}{langs}), " utf8-flag: ", to_bool($o->{locale}{utf8}));
#- for auto_install compatibility with old $o->{keyboard} containing directly $o->{keyboard}{KEYBOARD}
$o->{keyboard} = { KEYBOARD => $o->{keyboard} } if $o->{keyboard} && !ref($o->{keyboard});
if (!$o->{keyboard} || $o->{keyboard}{unsafe}) {
$o->{keyboard} = keyboard::default($o->{locale});
$o->{keyboard}{unsafe} = 1;
keyboard::setup_install($o->{keyboard});
}