summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/README79
-rwxr-xr-xmake_boot_img1
-rw-r--r--mdk-stage1/disk.c71
-rw-r--r--mdk-stage1/disk.h3
-rw-r--r--mdk-stage1/stage1.c9
-rw-r--r--mdk-stage1/tools.c1
-rw-r--r--perl-install/bootloader.pm27
-rw-r--r--perl-install/install2.pm18
-rw-r--r--perl-install/install_steps.pm4
-rw-r--r--perl-install/install_steps_gtk.pm2
-rw-r--r--perl-install/install_steps_interactive.pm10
-rw-r--r--rescue/.cvsignore1
-rw-r--r--rescue/Makefile2
-rw-r--r--rescue/kernel_read_part.c26
-rw-r--r--rescue/tree/boot/grub/menu.lst5
-rwxr-xr-xrescue/tree/etc/oem674
-rwxr-xr-xrescue/tree/etc/oem-all676
-rwxr-xr-xrescue/tree/etc/rc.sysinit2
-rwxr-xr-xtools/oem-prepare477
19 files changed, 9 insertions, 2079 deletions
diff --git a/docs/README b/docs/README
index 3d230af4f..6c8307707 100644
--- a/docs/README
+++ b/docs/README
@@ -276,82 +276,3 @@ replaces stage1, and init then monitors stage2)
have a look at gi/docs/object_class.fig
-
-********************************************************************************
-* OEM **************************************************************************
-********************************************************************************
-> I am a system OEM in Bangalore,India selling systems bundled with
-> Mandrakelinux. The problem is that with every system I sell, I need to
-> install & configure the system which takes HOURS!. Can I do a diskcopy
-> instead?
->
-> Please Help. This is a major bottleneck for me.
-
-many solutions:
-
-- make an install on drive hdb, then :
- dd if=/dev/hdb of=/dev/hdc
- but you should make sure the hardware is *REALLY* identical.
-
-- try the oem feature
- 3. - burn a cd out of *latest* cooker or 8.0 and above.
- - boot on it telling "oem" to syslinux
- !! it will destroy every data on the harddrive or
- resize (or use free space) if *ONLY* one fat partition is defined !!
- - you now have a very automated install matrix
- (duplicate it with "dd if=/dev/hdb of=/dev/hdc bs=1M count=730")
-
- put the harddrive in the oem box, the user will now have an *very* automated
- install, just asking the root password and user password, and some other
- question according its hardware.
-
- 4. just like 3. but you may have to mount /cdrom after typing rescue on
- syslinux prompt (oem script do it automatically if a automatic boot nfs
- network has been done as server is known). under /cdrom may be anything
- as long as it provides an installation tree of Mandrakelinux.
- after that run oem script by typing "/etc/oem -f" for normal installation
- or "/etc/oem -f server" for server installation (normal with server installed).
-
- 5. (just like 3. without burning a cd, doing the first part by hand)
- have a look at the /etc/oem script on the rescue and do it by hand...
-
-
-cu Pixel, fpons.
-
-
-comments:
-1. maybe copy unnecessary things -> take too long
- solution -> use bs=8k count=xxxx
-2. kernel_reread can be found on the new rescue, source is also at end of this
-mail. This solution works with one partition. Can be easily enhanced to many
-primary partitions... For extended partitions, more complicated, but not much :)
-3. has just been added in latest cooker. It may still have some pb. The main
-current limitation is IDE only, though it can be fixed easily for special cases.
-
---------------------------------------------------------------------------------
-#include <stdio.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-
-void die(char *msg)
-{
- perror(msg);
- exit(1);
-}
-
-void kernel_read(char *dev)
-{
- int fd;
- if ((fd = open(dev, O_RDONLY)) == -1) die("can't open device");
- ioctl(fd, BLKRRPART, 0);
- close(fd);
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 2) {
- fprintf(stderr, "usage: kernel_read_part <hard drive device>\n");
- exit(1);
- }
- kernel_read(argv[1]);
-}
diff --git a/make_boot_img b/make_boot_img
index a6dd190d0..c4c85b4fe 100755
--- a/make_boot_img
+++ b/make_boot_img
@@ -203,7 +203,6 @@ sub entries_append {
my @entries = (
(map { $_->[0] => "$automatic $default_acpi $_->[1]" } group_by2(@simple_entries)),
acpi => "$automatic $default_vga",
- if_(member($type, "cdrom", "all"), oem => "automatic=method:cdrom $default_vga $default_acpi rescue oem",),
if_($type eq "all", all => "pcmcia $default_vga $default_acpi"),
);
diff --git a/mdk-stage1/disk.c b/mdk-stage1/disk.c
index 1060cd199..8318bb6f4 100644
--- a/mdk-stage1/disk.c
+++ b/mdk-stage1/disk.c
@@ -315,74 +315,3 @@ enum return_type disk_prepare(void)
return RETURN_BACK;
return disk_prepare();
}
-
-#ifndef MANDRAKE_MOVE
-int
-process_recovery(void)
-{
- char ** medias, ** medias_models;
- int count, i;
-
- log_message("trying the automatic recovery of oem installs");
-
- count = get_disks(&medias, &medias_models);
-
- for (i=0; i<count; i++) {
- char * parts[50];
- char * parts_comments[50];
- char ** part, ** comment;
- log_message("examining disk %s (%s)", medias[i], medias_models[i]);
-
- if (list_partitions(medias[i], parts, parts_comments)) {
- log_message("could not read partitions information, bailing out");
- return 0;
- }
-
- part = parts;
- comment = parts_comments;
- while (part && *part) {
- char * disk_own_mount = "/tmp/hdimage";
- log_message("examining partition %s (%s)", *part, *comment);
- if (try_mount(*part, disk_own_mount))
- log_message("couldn't mount it");
- else {
- FILE *f;
- char buf[500];
- char location[500];
- strcpy(location, disk_own_mount);
- strcat(location, "/VERSION");
- if (!(f = fopen(location, "rb")) || !fgets(buf, sizeof(buf), f)) {
- log_perror("could not fopen or fgets VERSION");
- goto examine_next_part;
- }
- fclose(f);
- if (!strstr(buf, VERSION)) {
- log_message("mismatching VERSION contents");
- goto examine_next_part;
- }
- strcpy(location, disk_own_mount);
- strcat(location, "/install/stage2");
- if (access(location, R_OK)) {
- log_message("install/stage2 is not here");
- goto examine_next_part;
- }
-
- log_message("going on with a recovery on disk %s partition %s", medias[i], *part);
-
- symlink(disk_own_mount, IMAGE_LOCATION);
- may_load_clp(); /* no error check */
-
- add_to_env("METHOD", "disk");
- return 1;
- }
-
- examine_next_part:
- umount(disk_own_mount);
- part++;
- comment++;
- }
- }
-
- return 0;
-}
-#endif
diff --git a/mdk-stage1/disk.h b/mdk-stage1/disk.h
index 91cfbb2fd..fae890894 100644
--- a/mdk-stage1/disk.h
+++ b/mdk-stage1/disk.h
@@ -23,8 +23,5 @@
#define _DISK_H_
enum return_type disk_prepare(void);
-#ifndef MANDRAKE_MOVE
-int process_recovery(void);
-#endif
#endif
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index c25e3d68f..9768bce56 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -640,15 +640,8 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))
if (total_memory() < MEM_LIMIT_MOVE)
stg1_info_message(DISTRIB_NAME " typically needs more than %d Mbytes of memory (detected %d Mbytes). You may proceed, but the machine may crash or lock up for no apparent reason. Continue at your own risk. Alternatively, you may reboot your system now.",
MEM_LIMIT_MOVE, total_memory());
-#else
-#ifndef DISABLE_DISK
- if (IS_RECOVERY && streq(get_auto_value("method"), "cdrom")) {
- if (!process_recovery())
- method_select_and_prepare();
- } else
-#endif
#endif
- method_select_and_prepare();
+ method_select_and_prepare();
#ifndef MANDRAKE_MOVE
if (access(STAGE2_LOCATION, R_OK) != 0)
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index be1043798..45cafcfad 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -107,7 +107,6 @@ void process_cmdline(void)
if (!strcmp(name, "rescue")) set_param(MODE_RESCUE);
if (!strcmp(name, "noauto")) set_param(MODE_NOAUTO);
if (!strcmp(name, "netauto")) set_param(MODE_NETAUTO);
- if (!strcmp(name, "recovery")) set_param(MODE_RECOVERY);
if (!strcmp(name, "debugstage1")) set_param(MODE_DEBUGSTAGE1);
if (!strcmp(name, "automatic")) {
set_param(MODE_AUTOMATIC);
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 29bf33959..2010c625e 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -746,33 +746,6 @@ wait for default boot.
any::set_login_serial_console($port, $speed);
}
- #- add a restore entry if installation is done from disk, in order to allow redoing it.
- if (my $hd_install_path = any::hdInstallPath()) {
- my ($cmdline, $vga);
- if ($::restore && -e "/tmp/image/boot/vmlinuz" && -e "/tmp/image/boot/all.rdz" &&
- ($cmdline = cat_("/tmp/image/boot/grub/menu.lst") =~ m|kernel \S+/boot/vmlinuz (.*)$|m)) {
- #- cmdline should'n have any reference to vga=...
- $cmdline =~ s/vga=(\S+)//g and $vga = $1;
- log::l("copying kernel and stage1 install to $::prefix/boot/restore");
- eval { mkdir "$::prefix/boot/restore";
- cp_af("/tmp/image/boot/vmlinuz", "$::prefix/boot/restore/vmlinuz");
- cp_af("/tmp/image/boot/all.rdz", "$::prefix/boot/restore/all.rdz") };
- unless ($@) {
- log::l("adding a restore bootloader entry on $hd_install_path (remapped to $::prefix/boot/restore)");
- add_entry($bootloader, {
- type => 'image',
- label => 'restore',
- kernel_or_dev => "/boot/restore/vmlinuz",
- initrd => "/boot/restore/all.rdz",
- append => "$cmdline recovery", #- the restore entry is a recovery entry
- if_($vga, vga => $vga),
- });
- }
- } else {
- log::l("no restore bootloader need to be used on $hd_install_path");
- }
- }
-
my @kernels = get_kernels_and_labels() or die "no kernel installed";
foreach my $kernel (@kernels) {
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 5d006aa17..2a64574db 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -381,7 +381,6 @@ sub main {
map_each {
my ($n, $v) = @_;
my $f = ${{
- oem => sub { $::oem = $v },
lang => sub { $o->{locale}{lang} = $v },
flang => sub { $o->{locale}{lang} = $v; push @auto, 'selectLanguage' },
method => sub { $o->{method} = $v },
@@ -399,8 +398,6 @@ sub main {
testing => sub { $::testing = 1 },
patch => sub { $patch = 1 },
defcfg => sub { $cfg = $v },
- recovery => sub { $::recovery = 1 },
- restore => sub { $::restore = 1 },
newt => sub { $o->{interactive} = "newt" },
text => sub { $o->{interactive} = "newt" },
stdio => sub { $o->{interactive} = "stdio" },
@@ -534,9 +531,6 @@ sub main {
#- oem patch should be read before to still allow patch or defcfg.
eval { $o = $::o = install_any::loadO($o, "install/patch-oem.pl"); log::l("successfully read oem patch") };
- #- recovery mode should be read early to allow default parameter to be taken.
- eval { $o = $::o = install_any::loadO($o, "install/recovery.cfg"); log::l("successfully read recovery") } if $::recovery;
- $@ and $::recovery = 0; #- avoid keeping recovery if there was a problem reading the recovery.cfg file.
#- patch should be read after defcfg in order to take precedance.
eval { $o = $::o = install_any::loadO($o, $cfg); log::l("successfully read default configuration: $cfg") } if $cfg;
eval { $o = $::o = install_any::loadO($o, "patch"); log::l("successfully read patch") } if $patch;
@@ -580,14 +574,6 @@ sub main {
$o->{meta_class} eq 'powerpackplus' and $o->{meta_class} = 'server';
log::l("meta_class $o->{meta_class}");
- if ($::oem) {
- $o->{partitioning}{use_existing_root} = 1;
- $o->{compssListLevel} = 4;
- push @auto, 'selectInstallClass', 'doPartitionDisks', 'choosePackages', 'configureTimezone', 'exitInstall';
- }
- if ($::recovery) {
- push @auto, 'selectLanguage', 'selectInstallClass', 'selectMouse', 'selectKeyboard', 'doPartitionDisks', 'formatPartitions', 'miscellaneous', 'choosePackages', 'configureTimezone';
- }
foreach (@auto) {
my $s = $o->{steps}{/::(.*)/ ? $1 : $_} or next;
@@ -650,10 +636,6 @@ sub main {
$o->{modules_conf}->write;
detect_devices::install_addons($o->{prefix});
- #- save recovery file if needed (ie disk style install).
- $o->{method} eq 'disk' and
- output($o->{prefix} . any::hdInstallPath() . '/install/recovery.cfg', install_any::g_auto_install(1));
-
#- mainly for auto_install's
#- do not use run_program::xxx because it doesn't leave stdin/stdout unchanged
system("bash", "-c", $o->{postInstallNonRooted}) if $o->{postInstallNonRooted};
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 716a5c66b..0752c50d5 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -211,7 +211,7 @@ sub doPartitionDisksAfter {
die N("You must have a FAT partition mounted in /boot/efi");
}
- if ($o->{partitioning}{use_existing_root} && !$::recovery) {
+ if ($o->{partitioning}{use_existing_root}) {
#- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat
fs::mount_part($_, $o->{prefix}) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} }
grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}};
@@ -267,7 +267,7 @@ sub choosePartitionsToFormat($$) {
$_->{mntpoint} or next;
add2hash_($_, { toFormat => $_->{notFormatted} }) if $_->{fs_type}; #- eg: don't set toFormat for isRawRAID (0xfd)
- $_->{$::recovery ? 'toFormat' : 'toFormatUnsure'} ||= member($_->{mntpoint}, '/', '/usr');
+ $_->{toFormatUnsure} ||= member($_->{mntpoint}, '/', '/usr');
if (!$_->{toFormat}) {
my $fs_type = fs::type::fs_type_from_magic($_);
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm
index d8e11ac25..e7ab57d7a 100644
--- a/perl-install/install_steps_gtk.pm
+++ b/perl-install/install_steps_gtk.pm
@@ -559,7 +559,7 @@ sub installPackages {
my ($method, $medium) = @_;
#- if not using a cdrom medium or an iso image, always abort.
- return if !install_any::method_allows_medium_change($method) || $::oem;
+ return if !install_any::method_allows_medium_change($method);
my $name = pkgs::mediumDescr($o->{packages}, $medium);
local $| = 1; print "\a";
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index ddb61d568..40ab337bb 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -82,16 +82,14 @@ sub acceptLicense {
my $r = $::testing ? 'Accept' : 'Refuse';
- ($::recovery ?
- $o->ask_yesorno('', N("Do you want to recover your system?"), 0) :
- $o->ask_from_({ title => N("License agreement"),
+ $o->ask_from_({ title => N("License agreement"),
cancel => N("Quit"),
messages => formatAlaTeX(install_messages::main_license() . "\n\n\n" . install_messages::warning_about_patents()),
interactive_help_id => 'acceptLicense',
more_buttons => [ [ N("Release Notes"), sub { $o->ask_warn(N("Release Notes"), $o->{release_notes}) }, 1 ] ],
callbacks => { ok_disabled => sub { $r eq 'Refuse' } },
},
- [ { list => [ N_("Accept"), N_("Refuse") ], val => \$r, type => 'list', format => sub { translate($_[0]) } } ]))
+ [ { list => [ N_("Accept"), N_("Refuse") ], val => \$r, type => 'list', format => sub { translate($_[0]) } } ])
or do {
if ($::globetrotter) {
system("killall XFree86");
@@ -450,7 +448,7 @@ sub choosePackages {
#- this is done at the very beginning to take into account
#- selection of CD by user if using a cdrom.
- $o->chooseCD($packages) if install_any::method_allows_medium_change($o->{method}) && !$::oem;
+ $o->chooseCD($packages) if install_any::method_allows_medium_change($o->{method});
my $w = $o->wait_message('', N("Looking for available packages..."));
my $availableC = &install_steps::choosePackages;
@@ -741,7 +739,7 @@ sub installPackages {
my ($method, $medium) = @_;
#- if not using a cdrom medium or an iso image, always abort.
- return if !install_any::method_allows_medium_change($method) || $::oem;
+ return if !install_any::method_allows_medium_change($method);
my $name = pkgs::mediumDescr($o->{packages}, $medium);
local $| = 1; print "\a";
diff --git a/rescue/.cvsignore b/rescue/.cvsignore
index b5f45186d..c660273e8 100644
--- a/rescue/.cvsignore
+++ b/rescue/.cvsignore
@@ -1,2 +1 @@
rescue.clp
-kernel_read_part
diff --git a/rescue/Makefile b/rescue/Makefile
index 591676a70..c08d21c75 100644
--- a/rescue/Makefile
+++ b/rescue/Makefile
@@ -5,7 +5,7 @@ all: rescue.clp
install: rescue.clp
cp -f $< $(STAGE2_DEST)
-rescue.clp: kernel_read_part list list.$(ARCH) drvinst guessmounts lsparts rescue-doc make_rescue_img
+rescue.clp: list list.$(ARCH) drvinst guessmounts lsparts rescue-doc make_rescue_img
./make_rescue_img
clean:
diff --git a/rescue/kernel_read_part.c b/rescue/kernel_read_part.c
deleted file mode 100644
index 279dfe787..000000000
--- a/rescue/kernel_read_part.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <stdio.h>
-#include <sys/mount.h>
-#include <fcntl.h>
-
-void die(char *msg)
-{
- perror(msg);
- exit(1);
-}
-
-void kernel_read(char *dev)
-{
- int fd;
- if ((fd = open(dev, O_RDONLY)) == -1) die("can't open device");
- ioctl(fd, BLKRRPART, 0);
- close(fd);
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 2) {
- fprintf(stderr, "usage: kernel_read_part <hard drive device>\n");
- exit(1);
- }
- kernel_read(argv[1]);
-}
diff --git a/rescue/tree/boot/grub/menu.lst b/rescue/tree/boot/grub/menu.lst
deleted file mode 100644
index 1af0c85e3..000000000
--- a/rescue/tree/boot/grub/menu.lst
+++ /dev/null
@@ -1,5 +0,0 @@
-timeout 0
-
-title oem
-kernel (hd0,0)/boot/vmlinuz ramdisk_size=32000 hd vga=788 fbeginner oem
-initrd (hd0,0)/boot/hd.rdz
diff --git a/rescue/tree/etc/oem b/rescue/tree/etc/oem
deleted file mode 100755
index 7b87a4560..000000000
--- a/rescue/tree/etc/oem
+++ /dev/null
@@ -1,674 +0,0 @@
-#!/usr/bin/perl
-
-if (shift(@ARGV) ne '-f') {
- print "Call it with option -f, but don't fear loosing all your data, this command is dangerous!";
- print "
-usage: /etc/oem -f [options]
-where [options] are:
- server : allow server installalation
- boot_entries=entry1,...,entryN : set boot entries to use,
- the first one is the default one
- no<option> : disable options <option>
-";
- exit 1;
-}
-my (%options, $yes, $hd, $hdp, $cd, $fs);
-
-#- avoid globing as it is not available in rescue ramdisk.
-foreach my $device (split ' ', `/bin/ls -d /proc/ide/hd*`) {
- open F, "$device/media" or next;
- foreach (<F>) {
- /disk/ and do { $hd ||= $device; $hd =~ s,/proc/ide/,,; };
- /cdrom/ and do { $cd ||= $device; $cd =~ s,/proc/ide/,,; };
- }
- close F;
-}
-#- examine available SCSI devices (avoid SCSI floppies like LS-120 or ZIP disk or generic floppies).
-eval {
- system "/usr/bin/drvinst"; #- load scsi drivers else it wont do anything.
-
- my ($driveNum, $cdromNum) = (0, 0);
- open F, "/proc/scsi/scsi" or die "no scsi available";
- local $_ = <F>; /^Attached devices:/ or die "to attached devices found";
- while ($_ = <F>) {
- my ($id) = /^Host:.*?Id: (\d+)/ or die "no host found";
- $_ = <F>; my ($vendor, $model) = /^\s*Vendor:\s*(.*?)\s+Model:\s*(.*?)\s+Rev:/ or die "no vendor nor model found";
- $_ = <F>; my ($type) = /^\s*Type:\s*(.*)/;
- if ($type =~ /Direct-Access/ && $model !~ /ZIP\s+\d+|LS-?120|144MB|[Ff]loppy/) {
- $hd ||= "sd" . chr($driveNum++ + ord('a'));
- } elsif ($type =~ /CD-ROM/) {
- $cd ||= "scd" . $cdromNum++;
- }
- }
- close F;
-};
-#- examine DAC960 device.
-#- there is a problem as there is no more than 7 partitions available, this means no /home and no /var.
-unless ($hd) {
- local $_;
- open F, "dmesg |";
- while (<F>) {
- m|/dev/(rd/.*?): .*?,| and $hd ||= $1, last;
- }
- close F;
- if ($hd) {
- my ($c_id, $d_id) = $hd =~ m|rd/c(\d+)d(\d+)|;
- -d "/dev/rd" or mkdir "/dev/rd";
- system "mknod", "/dev/$hd", "b", 48+$c_id, 8*$d_id;
- foreach (1..7) {
- system "mknod", "/dev/${hd}p$_", "b", 48+$c_id, 8*$d_id+$_;
- }
- $hdp = $hd . 'p';
- }
-}
-#- examine Compaq Smart Array device.
-unless ($hd) {
- foreach ('array/ida', 'cpqarray/ida', 'cciss/cciss') {
- my $prefix = "/proc/driver/$_"; #- kernel 2.4 places it here
- $prefix = "/proc/$_" if !-e "${prefix}0"; #- kernel 2.2
-
- my ($name) = m|/(.*)|;
- for (my $i = 0; -r ($f = "${prefix}$i"); $i++) {
- local $_;
- open F, $f;
- while (<F>) {
- if (m|^\s*($name/.*?):|) {
- $hd ||= $1;
- }
- }
- close F;
- }
- }
- if ($hd) {
- my ($type, $c_id, $d_id) = $hd =~ m,(ida|cciss)/c(\d+)d(\d+),;
- -d "/dev/$type" or mkdir "/dev/$type";
- system "mknod", "/dev/$hd", "b", ($type eq 'ida' ? 72 : 104)+$c_id, 16*$d_id;
- foreach (1..15) {
- system "mknod", "/dev/${hd}p$_", "b", ($type eq 'ida' ? 72 : 104)+$c_id, 16*$d_id+$_;
- }
- $hdp = $hd . 'p';
- }
-}
-$hd && -e "/dev/$hd" or die "unable to access hard disk";
-print "hd: $hd\ncd: $cd\n";
-$hdp ||= $hd;
-
-#- try to free any reference to hard disk which will be used (as in rescue mode it has already loaded
-#- existing partition in /mnt.
-open F, "/proc/mounts";
-while (<F>) {
- /$hdp(\d*)\s+(\S+)/ and $already_mounted{$2} = "$hdp$1";
-}
-foreach (sort { $b cmp $a } keys %already_mounted) {
- print "umounting $already_mounted{$_} from $_\n";
- system "umount", $_;
-}
-
-#- find a cdrom (like) image, normally a true cdrom but if nfs install is running, use it instead.
-mkdir "/cdrom";
-open F, "/proc/cmdline";
-while (<F>) {
- /automatic=method:nfs,.*server:([^\s,]*),.*directory:([^\s,]*)/
- and system "mount", "-r", "-t", "nfs", "$1:$2", "/cdrom", "-o", "nolock";
-}
-close F;
-unless (-e "/cdrom/VERSION") {
- -e "/dev/$cd" or die "unable to access local cdrom";
- system "mount", "-r", "-t", "iso9660", "/dev/$cd", "/cdrom";
-}
-
-#- using default options for HP.
-#$options{free_size} = 500;
-#$options{free_primary} = 1;
-#$options{free_fs} = 'fat32';
-#$options{boot_entries} = 'linux,linux-nonfb,restore,failsafe,floppy';
-#$options{kernel} = "acpi=off";
-
-open F, "/cdrom/VERSION" or die "no installation cdrom found on $cd";
-while (<F>) {
- /\[boot_entries[=:]([^]]*)\]/ and $options{boot_entries} = $1;
- /\[ext2\]/ and $options{fs} = "ext2";
- /\[ext3\]/ and $options{fs} = "ext3";
-}
-close F;
-foreach (@ARGV) { /^([^=:]*)[=:]?(.*)/ and $options{$1} = $2; /^no([^=:]*)/ and delete $options{$1} }
-
-foreach (keys %options) {
- print "Using option [$_" . ($options{$_} && "=$options{$_}") . "]\n";
-}
-
-#- filesystem to use.
-$fs ||= $options{fs} || "ext3";
-$fs eq "ext3" and system "modprobe", "ext3";
-print "Using filesystem of type $fs\n";
-
-#- check for already existing partition table, if none are found
-#- create 3 partitions (one for install, one for swap and one for root).
-#- if only a fat partition is found, resize it do include the above partition.
-#- other combination are really dangerous and are not supported, ask
-#- the user that all data on the disk will be erased and go on.
-my ($heads, $sectors, $cylinders, $hd_size, @hd_parts);
-sub correct_start_end {
- my ($rstart, $end, $keep_start) = @_;
- my ($cylinder_size, $c_start, $c_end) = ($sectors*$heads*512/1024/1024, undef, undef);
- if (abs($cylinder_size*$cylinders-$hd_size)/$hd_size < 0.01) {
- $c_start = $$rstart+($keep_start ? 0 : $cylinder_size/$heads);
- $c_end = $cylinder_size*int(1/2+$end/$cylinder_size);
- $c_end > $hd_size and $c_end = $hd_size;
- $$rstart = $c_end;
- } else {
- $c_start = $$rstart;
- $c_end = $end;
- $c_end > $hd_size and $c_end = $hd_size;
- $$rstart = $c_end+5; #- fall back to use a problable safe method.
- }
- $c_start >= $c_end and die "no space left for partitionning\n";
- ($c_start, $c_end);
-}
-open F, "fdisk -l /dev/$hd |";
-while (<F>) {
- /(\d+)\s*heads/ and $heads = $1;
- /(\d+)\s*sectors/ and $sectors = $1;
- /(\d+)\s*cylinders/ and $cylinders = $1;
-}
-if ($heads == 1 && $cylinders == 1) {
- $cylinders = $sectors / 255 / 63;
- $heads = 255;
- $sectors = 63;
-}
-close F;
-for (1..2) {
- open F, "parted /dev/$hd -s print |";
- while (<F>) {
- /^Disk geometry [^:]*:\s*([\d\.]+)-([\d\.]+)/ and do { $hd_size = $2 - $1 - 1 };
- #/^Disk label type:\s*msdos/ and do { $hd_type = 'msdos' };
- /^(\d+)\s+([\d\.]+)\s+([\d\.]+)\s+(primary|logical|extended)\s*(\S*)/ and do {
- #- this automatically drops extended partition here!
- push @hd_parts, { minor => $1, start => $2, end => $3, type => $4, fstype => $5 };
- };
- }
- close F;
- $hd_size and last;
- print "Unable to detect partition on disk, trying with new label\n";
- do {
- print "
-
-I'm going to install the OEM version on your hard drive
-!!ALL DATA WILL BE LOST!!
-
-Type \`\`yes'' and [enter] to go on\n"
- } while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
- system "parted", "/dev/$hd", "mklabel", "msdos";
-}
-my $min_size = $options{min_size} || 9000;
-my $def_size = $options{def_size} || 8500;
-my $trigger_size = $options{trigger_size} || 9000;
-#my $inst_size = $options{inst_size} || 1500;
-my $inst_size = $options{inst_size} || 5000;
-my $swap_size = $options{swap_size} || 128;
-$hd_size > $min_size or die "hard disk is too small to contain oem install (${hd_size}MB found, need $min_size at least)";
-
-my ($fat_pos, $resize_fat_size, $root_size);
-if (@hd_parts == 1 && $hd_parts[$fat_pos = 0]{fstype} eq 'FAT' ||
- @hd_parts == 2 && $hd_parts[0]{type} eq 'primary' && $hd_parts[$fat_pos = 1]{fstype} eq 'FAT' ||
- @hd_parts == 3 && $hd_parts[0]{type} eq 'primary' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 2]{fstype} eq 'FAT' ||
- @hd_parts == 2 && $hd_parts[0]{type} eq 'extended' && $hd_parts[$fat_pos = 1]{fstype} eq 'FAT' ||
- @hd_parts == 3 && $hd_parts[0]{type} eq 'extended' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 5]{fstype} eq 'FAT') {
- if ($hd_size - $hd_parts[$fat_pos]{end} > $min_size + $options{free_size}) {
- #- check first if there are some available space left on the disk.
- #- so we are using it, root_size is fixed to match hard disk size.
- $resize_fat_size = 0;
- $root_size = $hd_size - $hd_parts[$fat_pos]{end} - $options{free_size} - $inst_size - $swap_size;
- $root_size > $trigger_size and $root_size = $def_size;
- } elsif ($hd_size > 2*$min_size + $options{free_size}) {
- #- resize this fat partition.
- $resize_fat_size = 0.5 * $hd_size;
- $root_size = $hd_size - $resize_fat_size - $options{free_size} - $inst_size - $swap_size;
- $root_size > $trigger_size and $root_size = $def_size;
- }
-}
-unless ($root_size) {
- #- there have not been defined above, so remove everything and start from
- #- a blank partition.
- $resize_fat_size = undef;
- $root_size = $hd_size - $resize_fat_size - $options{free_size} - $inst_size - $swap_size;
- $root_size > $trigger_size and $root_size = $def_size;
-}
-
-#- launch parted to edit partition table, start at minor.
-#- point define where we start.
-my $minor = defined $resize_fat_size && $hd_parts[0]{type} eq 'extended' ? 6 : 5;
-my $point = 0.0;
-my @commands;
-
-if (defined $resize_fat_size) {
- do {
- print "
-
-!!An existing Windows partition has been found and will be kept.
-Additional Linux partitions will be created!!
-
-Type \`\`yes'' and [enter] to go on\n"
- } while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
- #- keep the current partition table, and try to resize the fat partition
- #- if the size is not 0.
- #- KEEP IN MIND there is only one partition defined.
- if ($resize_fat_size) {
- $point = $hd_parts[$fat_pos]{start};
- push @commands, sprintf "resize %d %s %s", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
- } else {
- $point = $hd_parts[$fat_pos]{end};
- }
- $point+=9; #- keep blank space between partitions if parted cannot handle partition table correctly.
-} else {
- unless (defined $yes) {
- do {
- print "
-
-I'm going to install the OEM version on your hard drive
-!!ALL DATA WILL BE LOST!!
-
-Type \`\`yes'' and [enter] to go on\n"
- } while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
- }
- #- build a new disk label here.
- push @commands, "mklabel msdos";
-}
-
-#- at this point, the partition are created.
-my ($instz, $inst, $swap, $root, $var, $home, $free) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef, undef);
-
-#- all linux partition are stored inside an extended partition, this is easier to manipulate after.
-my $free_point = $point;
-if ($minor == 5) {
- push @commands, sprintf "mkpart extended %s %s", correct_start_end(\$free_point, $hd_size - ($options{free_primary} && $options{free_size}),
- 'keepstart');
-} else {
- $hd_parts[0]{type} eq 'extended' or die "first partition assumed to be extended";
- $point = $hd_parts[0]{start};
- push @commands, sprintf "resize %s %s %s", $hd_parts[0]{minor}, correct_start_end(\$free_point,
- $hd_size - ($options{free_primary} && $options{free_size}),
- 'keepstart');
-}
-push @commands, sprintf "mkpart logical ext2 %s %s", correct_start_end(\$point, $point+$inst_size);
-push @commands, sprintf "mkpart logical linux-swap %s %s", correct_start_end(\$point, $point+$swap_size);
-push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$root_size);
-if (exists $options{server} && $hd !~ /^rd\//) {
- my $var_size = ($hd_size - $point) / 2;
- if ($var_size > 1500) {
- $var = $root+1;
- push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$var_size);
- }
-}
-if ($hd_size - $point - $options{free_size} > 100 && $hd !~ /^rd\//) {
- $home = ($var || $root) + 1;
- push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $hd_size-$options{free_size});
-}
-if ($options{free_size} && $options{free_fs}) {
- if ($options{free_primary}) {
- $free = scalar(grep { $_->{type} eq 'primary' } @hd_parts) + 2;
- if ($free > 4) {
- $free = ($home || $var || $root) + 1;
- delete $options{free_primary};
- print "Unable to use primary partition for free partition, using logical partition.\n";
- }
- } else {
- $free = ($home || $var || $root) + 1;
- }
- push @commands, sprintf "mkpart %s %s %s %s", $options{free_primary} ? 'primary' : 'logical', $options{free_fs}, correct_start_end($options{free_primary} ? \$free_point : \$point, $hd_size);
-}
-system("parted", "-s", "/dev/$hd", @commands) == 0 or die "unable to partition the disk $hd";
-
-#- try to help user if a free space has been set and no fs defined for it.
-if ($options{free_size} && !$options{free_fs}) {
- print "
-
-!!A free space has been configured, now you can use parted
-to defined the partition as you want.
-
-Type \`\`quit'' and [enter] to finish parted\n";
- system "parted", "-i", "/dev/$hd";
-}
-
-#- we have to build swap and mount it.
-print "Setting swap\n";
-system "mkswap", "/dev/$hdp$swap";
-system "swapon", "/dev/$hdp$swap";
-
-#- we have to format using right fs.
-print "Formatting /dev/$hdp$inst partition\n";
-mkfs("ext2", "/dev/$hdp$inst");
-print "Formatting /dev/$hdp$root partition\n";
-mkfs($fs, "/dev/$hdp$root");
-if ($var) {
- print "Formatting /dev/$hdp$var partition\n";
- mkfs($fs, "/dev/$hdp$var");
-}
-if ($home) {
- print "Formatting /dev/$hdp$home partition\n";
- mkfs($fs, "/dev/$hdp$home");
-}
-if ($free) {
- print "Formatting /dev/$hdp$free partition\n";
- mkfs($options{free_fs}, "/dev/$hdp$free");
-}
-
-print "Mounting partitions\n";
-mkdir "/hd";
-system "mount", "-t", "ext2", "/dev/$hdp$inst", "/hd";
-mkdir "/mnt";
-system "mount", "-t", $fs, "/dev/$hdp$root", "/mnt";
-if ($var) {
- mkdir "/mnt/var";
- system "mount", "-t", $fs, "/dev/$hdp$var", "/mnt/var";
-}
-if ($home) {
- mkdir "/mnt/home";
- system "mount", "-t", $fs, "/dev/$hdp$home", "/mnt/home";
-}
-
-print "Copying installation on hard drive\n";
-mkdir "/hd/boot";
-if (-e "/cdrom/oem/vmlinuz" && -e "/cdrom/oem/all.rdz") {
- system "cp", "-a", "/cdrom/oem/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/cdrom/oem/all.rdz", "/hd/boot/all.rdz";
-} elsif (-e "/cdrom/isolinux/alt0/vmlinuz" && -e "/cdrom/isolinux/alt0/all.rdz") {
- system "cp", "-a", "/cdrom/isolinux/alt0/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/cdrom/isolinux/alt0/all.rdz", "/hd/boot/all.rdz";
-} elsif (-e "/cdrom/boot/vmlinuz" && -e "/cdrom/boot/hd.rdz") {
- system "cp", "-a", "/cdrom/boot/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/cdrom/boot/hd.rdz", "/hd/boot/all.rdz";
-} elsif (-e "/cdrom/images/hd.img") {
- mkdir "/tmp/hd";
- system "modprobe", "loop";
- system "modprobe", "vfat";
- system "mount", "-t", "vfat", "/cdrom/images/hd.img", "/tmp/hd", "-o", "loop";
- system "cp", "-a", "/tmp/hd/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/tmp/hd/hd.rdz", "/hd/boot/all.rdz";
- system "umount", "/tmp/hd";
-} else {
- die "no installation stage1 found";
-}
-
-mkdir "/hd/Mandrake";
-mkdir "/hd/Mandrake/RPMS";
-system "cp", "-a", "/cdrom/VERSION", "/hd";
-system "cp", "-a", "/cdrom/Mandrake/base", "/cdrom/Mandrake/mdkinst", "/cdrom/Mandrake/share", "/hd/Mandrake";
-
-if (open F, ">/hd/Mandrake/oem_patch.pl") {
- print "Setting OEM specific extension to DrakX\n";
- if (exists $options{server}) {
- print F q{
- use install_steps;
- package install_steps;
- undef *choosePackages;
- *choosePackages = sub {
- my ($o, $packages, $compssUsers, $first_time) = @_;
-
- #- make sure we kept some space left for available else the system may
- #- not be able to start (xfs at least).
- my $available = install_any::getAvailableSpace($o);
- my $availableCorrected = pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024);
-
- #- avoid destroying user selection of packages but only
- #- for expert, as they may have done individual selection before.
- install_any::unselectMostPackages($o);
-
- #- use specific OEM packages selection, go to level 5
- #- and disable some extension.
- $o->{compssUsersChoice}{$_} = 0 foreach 'GNOME';
- $o->{compssUsersChoice}{$_} = 0
- foreach map { @{$o->{compssUsers}{$_}{flags}} } 'Workstation|Office Workstation', 'Workstation|Internet station';
- $o->{compssListLevel} = 5;
- pkgs::setSelectedFromCompssList($packages, $o->{compssUsersChoice}, $o->{compssListLevel}, $availableCorrected);
-
- $availableCorrected;
- };
- };
- } else {
- print F q{
- use install_steps;
- package install_steps;
- undef *choosePackages;
- *choosePackages = sub {
- my ($o, $packages, $compssUsers, $first_time) = @_;
-
- #- make sure we kept some space left for available else the system may
- #- not be able to start (xfs at least).
- my $available = install_any::getAvailableSpace($o);
- my $availableCorrected = pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024);
-
- #- avoid destroying user selection of packages but only
- #- for expert, as they may have done individual selection before.
- install_any::unselectMostPackages($o);
-
- #- use specific OEM packages selection, go to level 4.
- #- and select at least GAMES group, everything else has
- #- already be selected during master preparation.
- $o->{compssListLevel} = 4;
- $o->{compssUsersChoice}{$_} = 1 foreach qw(GAMES VIDEO AUDIO GRAPHICS);
- pkgs::setSelectedFromCompssList($packages, $o->{compssUsersChoice}, $o->{compssListLevel}, $availableCorrected);
-
- $availableCorrected;
- };
- };
- }
- if ($options{boot_entries}) {
- print "Setting OEM specific extension for boot entries\n";
- print F q{
- my $sorted_entries = q(} . $options{boot_entries} . q{); #- insert boot_entries options here as string q(...).
- my $old_setupBootloaderBefore = \&setupBootloaderBefore;
- undef *setupBootloaderBefore;
- *setupBootloaderBefore = sub {
- $old_setupBootloaderBefore->(@_);
- my @entries = split ',', $sorted_entries;
- my @result_entries;
- foreach my $p (@entries) {
- foreach (@{$_[0]{bootloader}{entries}}) {
- $_->{label} eq $p and push @result_entries, $_;
- }
- }
- if (@result_entries) {
- $_[0]{bootloader}{entries} = \@result_entries;
- $_[0]{bootloader}{default} = $result_entries[0]{label}; #- first image is default.
- }
- };
- };
- }
- close F;
-}
-
-print "Setting bootloader\n";
-mkdir "/hd/boot/grub";
-foreach (1..2) {
- -e "/hd/boot/grub/stage$_" or system "cp", "-a", "/boot/grub/stage$_", "/hd/boot/grub";
-}
-open F, ">/hd/boot/grub/menu.lst";
-if (defined $resize_fat_size) {
- print F "timeout 5\n";
- print F "color black/cyan yellow/cyan\n\n";
- print F "title linux\n";
-} else {
- print F "timeout 0\n\n";
- print F "title oem\n";
-}
-print F "kernel (hd0,$instz)/boot/vmlinuz ramdisk_size=128000 $options{kernel} automatic=method:disk,disk:$hd,partition:$hdp$inst,directory:/ hd vga=788 fbeginner oem defcfg=/tmp/hdimage/Mandrake/oem_patch.pl\n";
-print F "initrd (hd0,$instz)/boot/all.rdz\n";
-#- if a windows partition is available, add an entrie for it.
-if (defined $resize_fat_size) {
- print F "\ntitle windows\n";
- printf F "rootnoverify (hd0,%s)\n", $hd_parts[$fat_pos]{minor}-1;
- print F "makeactive\n";
- print F "chainloader +1\n";
-}
-close F;
-open F, ">/hd/boot/grub/device.map";
-print F "(hd0) /dev/$hd\n";
-close F;
-open F, "| grub --device-map=/hd/boot/grub/device.map --batch";
-print F "install (hd0,$instz)/boot/grub/stage1 d (hd0) (hd0,$instz)/boot/grub/stage2 p (hd0,$instz)/boot/grub/menu.lst\n";
-print F "quit\n";
-close F or die "error while executing grub";
-
-my $packages = read_depslist("/cdrom/Mandrake/base/depslist.ordered");
-
-my @media;
-open F, "/cdrom/Mandrake/base/hdlists";
-foreach (<F>) {
- chomp;
- s/\s*#.*$//;
- /^\s*$/ and next;
- m/^\s*(hdlist\S*\.cz2?)\s+(\S+)\s*(.*)$/ or die "invalid hdlist description \"$_\" in hdlists file";
-
- push @media, { hdlist => $1, rpmsdir => $2, descr => $3 };
-}
-close F;
-
-#- initialize installation.
-foreach (qw(/etc /etc/sysconfig /etc/rpm /var /var/lib /var/lib/rpm /var/log /proc)) {
- mkdir "/mnt/$_";
-}
-system "mount", "-t", "proc", "proc", "/mnt/proc";
-open F, ">/mnt/etc/fstab";
-print F "/dev/$hdp$root / $fs defaults 1 1\n";
-if ($var) {
- print F "/dev/$hdp$var /var $fs defaults 1 2\n";
-}
-if ($home) {
- print F "/dev/$hdp$home /home $fs defaults 1 2\n";
-}
-close F;
-#- stupid things for installer to work correctly.
-#open F, ">/mnt/etc/mandrake-release";
-#print F "Mandrake Linux release 9.1 (Bamboo) for i586";
-#close F;
-
-#- keep in mind all the rpm files available (according to hdlists).
-my (%files, %rpms);
-
-require packdrake;
-foreach my $medium (@media) {
- my $packer = new packdrake("/cdrom/Mandrake/base/$medium->{hdlist}");
- foreach (@{$packer->{files}}) {
- $packer->{data}{$_}[0] eq 'f' or next;
- my ($fullname, $file) = /([^:]*):(.*)/ ? ($1, "$2.rpm") : ($_, "$_.rpm");
- $files{$fullname} = $file;
- $rpms{$fullname} = $medium->{rpmsdir};
- #- convert %{ARCH} to effective arch of the given package.
- my ($arch) = $fullname =~ /\.([^\.\-]*)$/;
- $rpms{$fullname} =~ s|%{ARCH}|$arch|g;
- }
-}
-
-#- install some important packages.
-system "rpm", "--root", "/mnt", "--initdb";
-
-#- copy and install from each cd image.
-foreach my $medium (@media) {
- my $rpmsidr = $medium->{rpmsdir};
- $rpmsdir =~ s|%{ARCH}.*||; #- only for checking directory presence...
- while ($cd && ! -d "/cdrom/$rpmsdir") {
- system "unmount", "/dev/$cd";
- system "eject", "/dev/$cd";
- print "Please insert the cdrom labeled \"$medium->{descr}\"\n and press [enter] when done\n";
- $yes = <STDIN>;
- system "mount", "-r", "-t", "iso9660", "/dev/$cd", "/cdrom";
- }
-
- print "Copying packages from medium labeled \"$medium->{descr}\" to hard disk\n";
- foreach my $pkg (@{$packages->{depslist}}) {
- $files{rpm_fullname($pkg)} or next;
- my $infile = "/cdrom/" . $rpms{rpm_fullname($pkg)} . "/" . $files{rpm_fullname($pkg)};
- my $outfile = "/hd/" . $rpms{rpm_fullname($pkg)} . "/" . $files{rpm_fullname($pkg)};
- if (-r $infile && -s $infile != -s $outfile) {
- -d "/hd/" . $rpms{rpm_fullname($pkg)} or system "mkdir", "-p", "/hd/" . $rpms{rpm_fullname($pkg)};
- print " copying " . rpm_fullname($pkg) . "\n";
- system "cp", "-a", $infile, $outfile;
- if (rpm_fullname($pkg) =~ /mandrake-release/) {
- system "rpm", "-Uvh", "--root", "/mnt", "--nodeps", "--force", $outfile;
- }
- #- clean to say everything is done.
- delete $files{rpm_fullname($pkg)};
- delete $rpms{rpm_fullname($pkg)};
- }
- }
-}
-
-#- try to figure out if a oem-message-graphic already exists.
-#- if this is the case, rename it to /mnt/boot/message-graphic
-if (-e "/cdrom/Mandrake/base/oem-message-graphic") {
- print "Using specific oem graphic image\n";
- if (-e "/mnt/boot/message-graphic") {
- rename "/mnt/boot/message-graphic", "/mnt/boot/message-graphic.old";
- system "cp", "-a", "/cdrom/Mandrake/base/oem-message-graphic", "/mnt/boot/message-graphic";
- } elsif (-e "/mnt/boot/lilo-graphic/message") {
- rename "/mnt/boot/lilo-graphic/message", "/mnt/boot/lilo-graphic/message.old";
- system "cp", "-a", "/cdrom/Mandrake/base/oem-message-graphic", "/mnt/boot/lilo-graphic/message";
- }
-}
-
-#- clean all initrd image which may have been built.
-system "rm -f /mnt/boot/initrd*";
-
-system "umount", "/mnt/proc";
-$home and system "umount", "/mnt/home";
-$var and system "umount", "/mnt/var";
-system "umount", "/mnt";
-system "umount", "/hd";
-system "umount", "/cdrom";
-
-$cd and system "eject", "/dev/$cd";
-
-print "
-Done. OEM hard drive ready!
-The hard drive is now ready for a customer.
-System is now halted.\n\n";
-
-system "halt";
-
-#- gives way to format partition (simpler approach)
-sub mkfs {
- my ($fs, $dev) = @_;
- for ($fs) {
- /ext2/ and do { system "mkfs.ext2", $dev;
- next };
- /ext3/ and do { system "mkfs.ext2", "-j", $dev;
- system "tune2fs", "-c0", "-i0", $dev;
- next };
- /fat16/ and do { system "mkdosfs", $dev;
- next };
- /fat32/ and do { system "mkdosfs", "-F", "32", $dev;
- next };
- die "unknown fs: $_\n";
- }
-}
-
-sub chop_version {
- ($_[0] =~ /^([^:\s]*)-[^:\-\s]+-[^:\-\s]+\.[^:\.\-\s]*(?::\S*)?/)[0] || die "unable to parse $_[0]";
-}
-sub rpm_fullname {
- ($_[0]{name} =~ /^([^:\s]*-[^:\-\s]+-[^:\-\s]+\.[^:\.\-\s]*)(?::\S*)?/)[0] || die "unable to parse $_[0]";
-}
-
-sub read_depslist {
- my ($file) = @_;
- my $packages = { depslist => [], names => {} };
-
- #- read depslist.oredered file.
- my $id = 0;
-
- open F, "$file" or die "unable to open ordered dependencies list file";
- while (<F>) {
- my ($name, $size, @deps) = split;
- push @{$packages->{depslist}}, { id => $id++, name => $name, size => $size, deps => \@deps };
- }
- close F;
-
- foreach (@{$packages->{depslist}}) {
- $packages->{names}{chop_version($_->{name})} = $_;
- }
-
- print "read " . scalar(@{$packages->{depslist}}) . " package dependancies\n";
- $packages;
-}
-
diff --git a/rescue/tree/etc/oem-all b/rescue/tree/etc/oem-all
deleted file mode 100755
index c02d505f3..000000000
--- a/rescue/tree/etc/oem-all
+++ /dev/null
@@ -1,676 +0,0 @@
-#!/usr/bin/perl
-
-#- $Id$
-
-if (shift(@ARGV) ne '-f') {
- print "Call it with option -f, but don't fear loosing all your data, this command is dangerous!";
- print "
-usage: /etc/oem -f [options]
-where [options] are:
- server : allow server installalation
- boot_entries=entry1,...,entryN : set boot entries to use,
- the first one is the default one
- no<option> : disable options <option>
-";
- exit 1;
-}
-my (%options, $yes, $hd, $hdp, $cd, $fs);
-
-#- avoid globing as it is not available in rescue ramdisk.
-foreach my $device (split ' ', `/bin/ls -d /proc/ide/hd*`) {
- open F, "$device/media" or next;
- foreach (<F>) {
- /disk/ and do { $hd ||= $device; $hd =~ s,/proc/ide/,,; };
- /cdrom/ and do { $cd ||= $device; $cd =~ s,/proc/ide/,,; };
- }
- close F;
-}
-#- examine available SCSI devices (avoid SCSI floppies like LS-120 or ZIP disk or generic floppies).
-eval {
- system "/usr/bin/drvinst"; #- load scsi drivers else it wont do anything.
-
- my ($driveNum, $cdromNum) = (0, 0);
- open F, "/proc/scsi/scsi" or die "no scsi available";
- local $_ = <F>; /^Attached devices:/ or die "to attached devices found";
- while ($_ = <F>) {
- my ($id) = /^Host:.*?Id: (\d+)/ or die "no host found";
- $_ = <F>; my ($vendor, $model) = /^\s*Vendor:\s*(.*?)\s+Model:\s*(.*?)\s+Rev:/ or die "no vendor nor model found";
- $_ = <F>; my ($type) = /^\s*Type:\s*(.*)/;
- if ($type =~ /Direct-Access/ && $model !~ /ZIP\s+\d+|LS-?120|144MB|[Ff]loppy/) {
- $hd ||= "sd" . chr($driveNum++ + ord('a'));
- } elsif ($type =~ /CD-ROM/) {
- $cd ||= "scd" . $cdromNum++;
- }
- }
- close F;
-};
-#- examine DAC960 device.
-#- there is a problem as there is no more than 7 partitions available, this means no /home and no /var.
-unless ($hd) {
- local $_;
- open F, "dmesg |";
- while (<F>) {
- m|/dev/(rd/.*?): .*?,| and $hd ||= $1, last;
- }
- close F;
- if ($hd) {
- my ($c_id, $d_id) = $hd =~ m|rd/c(\d+)d(\d+)|;
- -d "/dev/rd" or mkdir "/dev/rd";
- system "mknod", "/dev/$hd", "b", 48+$c_id, 8*$d_id;
- foreach (1..7) {
- system "mknod", "/dev/${hd}p$_", "b", 48+$c_id, 8*$d_id+$_;
- }
- $hdp = $hd . 'p';
- }
-}
-#- examine Compaq Smart Array device.
-unless ($hd) {
- foreach ('array/ida', 'cpqarray/ida', 'cciss/cciss') {
- my $prefix = "/proc/driver/$_"; #- kernel 2.4 places it here
- $prefix = "/proc/$_" if !-e "${prefix}0"; #- kernel 2.2
-
- my ($name) = m|/(.*)|;
- for (my $i = 0; -r ($f = "${prefix}$i"); $i++) {
- local $_;
- open F, $f;
- while (<F>) {
- if (m|^\s*($name/.*?):|) {
- $hd ||= $1;
- }
- }
- close F;
- }
- }
- if ($hd) {
- my ($type, $c_id, $d_id) = $hd =~ m,(ida|cciss)/c(\d+)d(\d+),;
- -d "/dev/$type" or mkdir "/dev/$type";
- system "mknod", "/dev/$hd", "b", ($type eq 'ida' ? 72 : 104)+$c_id, 16*$d_id;
- foreach (1..15) {
- system "mknod", "/dev/${hd}p$_", "b", ($type eq 'ida' ? 72 : 104)+$c_id, 16*$d_id+$_;
- }
- $hdp = $hd . 'p';
- }
-}
-$hd && -e "/dev/$hd" or die "unable to access hard disk";
-print "hd: $hd\ncd: $cd\n";
-$hdp ||= $hd;
-
-#- try to free any reference to hard disk which will be used (as in rescue mode it has already loaded
-#- existing partition in /mnt.
-open F, "/proc/mounts";
-while (<F>) {
- /$hdp(\d*)\s+(\S+)/ and $already_mounted{$2} = "$hdp$1";
-}
-foreach (sort { $b cmp $a } keys %already_mounted) {
- print "umounting $already_mounted{$_} from $_\n";
- system "umount", $_;
-}
-
-#- find a cdrom (like) image, normally a true cdrom but if nfs install is running, use it instead.
-mkdir "/cdrom";
-open F, "/proc/cmdline";
-while (<F>) {
- /automatic=method:nfs,.*server:([^\s,]*),.*directory:([^\s,]*)/
- and system "mount", "-r", "-t", "nfs", "$1:$2", "/cdrom", "-o", "nolock";
-}
-close F;
-unless (-e "/cdrom/VERSION") {
- -e "/dev/$cd" or die "unable to access local cdrom";
- system "mount", "-r", "-t", "iso9660", "/dev/$cd", "/cdrom";
-}
-
-#- using default options for HP.
-#$options{free_size} = 500;
-#$options{free_primary} = 1;
-#$options{free_fs} = 'fat32';
-#$options{boot_entries} = 'linux,linux-nonfb,restore,failsafe,floppy';
-#$options{kernel} = "acpi=off";
-
-open F, "/cdrom/VERSION" or die "no installation cdrom found on $cd";
-while (<F>) {
- /\[boot_entries[=:]([^]]*)\]/ and $options{boot_entries} = $1;
- /\[ext2\]/ and $options{fs} = "ext2";
- /\[ext3\]/ and $options{fs} = "ext3";
-}
-close F;
-foreach (@ARGV) { /^([^=:]*)[=:]?(.*)/ and $options{$1} = $2; /^no([^=:]*)/ and delete $options{$1} }
-
-foreach (keys %options) {
- print "Using option [$_" . ($options{$_} && "=$options{$_}") . "]\n";
-}
-
-#- filesystem to use.
-$fs ||= $options{fs} || "ext3";
-$fs eq "ext3" and system "modprobe", "ext3";
-print "Using filesystem of type $fs\n";
-
-#- check for already existing partition table, if none are found
-#- create 3 partitions (one for install, one for swap and one for root).
-#- if only a fat partition is found, resize it do include the above partition.
-#- other combination are really dangerous and are not supported, ask
-#- the user that all data on the disk will be erased and go on.
-my ($heads, $sectors, $cylinders, $hd_size, @hd_parts);
-sub correct_start_end {
- my ($rstart, $end, $keep_start) = @_;
- my ($cylinder_size, $c_start, $c_end) = ($sectors*$heads*512/1024/1024, undef, undef);
- if (abs($cylinder_size*$cylinders-$hd_size)/$hd_size < 0.01) {
- $c_start = $$rstart+($keep_start ? 0 : $cylinder_size/$heads);
- $c_end = $cylinder_size * int(1 / 2 + $end / $cylinder_size);
- $c_end > $hd_size and $c_end = $hd_size;
- $$rstart = $c_end;
- } else {
- $c_start = $$rstart;
- $c_end = $end;
- $c_end > $hd_size and $c_end = $hd_size;
- $$rstart = $c_end+5; #- fall back to use a problable safe method.
- }
- $c_start >= $c_end and die "no space left for partitionning\n";
- ($c_start, $c_end);
-}
-open F, "fdisk -l /dev/$hd |";
-while (<F>) {
- /(\d+)\s*heads/ and $heads = $1;
- /(\d+)\s*sectors/ and $sectors = $1;
- /(\d+)\s*cylinders/ and $cylinders = $1;
-}
-if ($heads == 1 && $cylinders == 1) {
- $cylinders = $sectors / 255 / 63;
- $heads = 255;
- $sectors = 63;
-}
-close F;
-for (1..2) {
- open F, "parted /dev/$hd -s print |";
- while (<F>) {
- /^Disk geometry [^:]*:\s*([\d\.]+)-([\d\.]+)/ and do { $hd_size = $2 - $1 - 1 };
- #/^Disk label type:\s*msdos/ and do { $hd_type = 'msdos' };
- /^(\d+)\s+([\d\.]+)\s+([\d\.]+)\s+(primary|logical|extended)\s*(\S*)/ and do {
- #- this automatically drops extended partition here!
- push @hd_parts, { minor => $1, start => $2, end => $3, type => $4, fstype => $5 };
- };
- }
- close F;
- $hd_size and last;
- print "Unable to detect partition on disk, trying with new label\n";
- do {
- print "
-
-I'm going to install the OEM version on your hard drive
-!!ALL DATA WILL BE LOST!!
-
-Type \`\`yes'' and [enter] to go on\n"
- } while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
- system "parted", "/dev/$hd", "mklabel", "msdos";
-}
-my $min_size = $options{min_size} || 9000;
-my $def_size = $options{def_size} || 8500;
-my $trigger_size = $options{trigger_size} || 9000;
-#my $inst_size = $options{inst_size} || 1500;
-my $inst_size = $options{inst_size} || 5000;
-my $swap_size = $options{swap_size} || 128;
-$hd_size > $min_size or die "hard disk is too small to contain oem install (${hd_size}MB found, need $min_size at least)";
-
-my ($fat_pos, $resize_fat_size, $root_size);
-if (@hd_parts == 1 && $hd_parts[$fat_pos = 0]{fstype} eq 'FAT' ||
- @hd_parts == 2 && $hd_parts[0]{type} eq 'primary' && $hd_parts[$fat_pos = 1]{fstype} eq 'FAT' ||
- @hd_parts == 3 && $hd_parts[0]{type} eq 'primary' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 2]{fstype} eq 'FAT' ||
- @hd_parts == 2 && $hd_parts[0]{type} eq 'extended' && $hd_parts[$fat_pos = 1]{fstype} eq 'FAT' ||
- @hd_parts == 3 && $hd_parts[0]{type} eq 'extended' && $hd_parts[1]{type} eq 'primary' && $hd_parts[$fat_pos = 5]{fstype} eq 'FAT') {
- if ($hd_size - $hd_parts[$fat_pos]{end} > $min_size + $options{free_size}) {
- #- check first if there are some available space left on the disk.
- #- so we are using it, root_size is fixed to match hard disk size.
- $resize_fat_size = 0;
- $root_size = $hd_size - $hd_parts[$fat_pos]{end} - $options{free_size} - $inst_size - $swap_size;
- $root_size > $trigger_size and $root_size = $def_size;
- } elsif ($hd_size > 2*$min_size + $options{free_size}) {
- #- resize this fat partition.
- $resize_fat_size = 0.5 * $hd_size;
- $root_size = $hd_size - $resize_fat_size - $options{free_size} - $inst_size - $swap_size;
- $root_size > $trigger_size and $root_size = $def_size;
- }
-}
-unless ($root_size) {
- #- there have not been defined above, so remove everything and start from
- #- a blank partition.
- $resize_fat_size = undef;
- $root_size = $hd_size - $resize_fat_size - $options{free_size} - $inst_size - $swap_size;
- $root_size > $trigger_size and $root_size = $def_size;
-}
-
-#- launch parted to edit partition table, start at minor.
-#- point define where we start.
-my $minor = defined $resize_fat_size && $hd_parts[0]{type} eq 'extended' ? 6 : 5;
-my $point = 0.0;
-my @commands;
-
-if (defined $resize_fat_size) {
- do {
- print "
-
-!!An existing Windows partition has been found and will be kept.
-Additional Linux partitions will be created!!
-
-Type \`\`yes'' and [enter] to go on\n"
- } while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
- #- keep the current partition table, and try to resize the fat partition
- #- if the size is not 0.
- #- KEEP IN MIND there is only one partition defined.
- if ($resize_fat_size) {
- $point = $hd_parts[$fat_pos]{start};
- push @commands, sprintf "resize %d %s %s", $hd_parts[$fat_pos]{minor}, correct_start_end(\$point, $point+$resize_fat_size, 'keepstart');
- } else {
- $point = $hd_parts[$fat_pos]{end};
- }
- $point+=9; #- keep blank space between partitions if parted cannot handle partition table correctly.
-} else {
- unless (defined $yes) {
- do {
- print "
-
-I'm going to install the OEM version on your hard drive
-!!ALL DATA WILL BE LOST!!
-
-Type \`\`yes'' and [enter] to go on\n"
- } while (($yes = <STDIN>) !~ /^\s*yes\s*$/i);
- }
- #- build a new disk label here.
- push @commands, "mklabel msdos";
-}
-
-#- at this point, the partition are created.
-my ($instz, $inst, $swap, $root, $var, $home, $free) = ($minor-1, $minor, $minor+1, $minor+2, undef, undef, undef);
-
-#- all linux partition are stored inside an extended partition, this is easier to manipulate after.
-my $free_point = $point;
-if ($minor == 5) {
- push @commands, sprintf "mkpart extended %s %s", correct_start_end(\$free_point, $hd_size - ($options{free_primary} && $options{free_size}),
- 'keepstart');
-} else {
- $hd_parts[0]{type} eq 'extended' or die "first partition assumed to be extended";
- $point = $hd_parts[0]{start};
- push @commands, sprintf "resize %s %s %s", $hd_parts[0]{minor}, correct_start_end(\$free_point,
- $hd_size - ($options{free_primary} && $options{free_size}),
- 'keepstart');
-}
-push @commands, sprintf "mkpart logical ext2 %s %s", correct_start_end(\$point, $point+$inst_size);
-push @commands, sprintf "mkpart logical linux-swap %s %s", correct_start_end(\$point, $point+$swap_size);
-push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$root_size);
-if (exists $options{server} && $hd !~ /^rd\//) {
- my $var_size = ($hd_size - $point) / 2;
- if ($var_size > 1500) {
- $var = $root+1;
- push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $point+$var_size);
- }
-}
-if ($hd_size - $point - $options{free_size} > 100 && $hd !~ /^rd\//) {
- $home = ($var || $root) + 1;
- push @commands, sprintf "mkpart logical %s %s %s", $fs, correct_start_end(\$point, $hd_size-$options{free_size});
-}
-if ($options{free_size} && $options{free_fs}) {
- if ($options{free_primary}) {
- $free = scalar(grep { $_->{type} eq 'primary' } @hd_parts) + 2;
- if ($free > 4) {
- $free = ($home || $var || $root) + 1;
- delete $options{free_primary};
- print "Unable to use primary partition for free partition, using logical partition.\n";
- }
- } else {
- $free = ($home || $var || $root) + 1;
- }
- push @commands, sprintf "mkpart %s %s %s %s", $options{free_primary} ? 'primary' : 'logical', $options{free_fs}, correct_start_end($options{free_primary} ? \$free_point : \$point, $hd_size);
-}
-system("parted", "-s", "/dev/$hd", @commands) == 0 or die "unable to partition the disk $hd";
-
-#- try to help user if a free space has been set and no fs defined for it.
-if ($options{free_size} && !$options{free_fs}) {
- print "
-
-!!A free space has been configured, now you can use parted
-to defined the partition as you want.
-
-Type \`\`quit'' and [enter] to finish parted\n";
- system "parted", "-i", "/dev/$hd";
-}
-
-#- we have to build swap and mount it.
-print "Setting swap\n";
-system "mkswap", "/dev/$hdp$swap";
-system "swapon", "/dev/$hdp$swap";
-
-#- we have to format using right fs.
-print "Formatting /dev/$hdp$inst partition\n";
-mkfs("ext2", "/dev/$hdp$inst");
-print "Formatting /dev/$hdp$root partition\n";
-mkfs($fs, "/dev/$hdp$root");
-if ($var) {
- print "Formatting /dev/$hdp$var partition\n";
- mkfs($fs, "/dev/$hdp$var");
-}
-if ($home) {
- print "Formatting /dev/$hdp$home partition\n";
- mkfs($fs, "/dev/$hdp$home");
-}
-if ($free) {
- print "Formatting /dev/$hdp$free partition\n";
- mkfs($options{free_fs}, "/dev/$hdp$free");
-}
-
-print "Mounting partitions\n";
-mkdir "/hd";
-system "mount", "-t", "ext2", "/dev/$hdp$inst", "/hd";
-mkdir "/mnt";
-system "mount", "-t", $fs, "/dev/$hdp$root", "/mnt";
-if ($var) {
- mkdir "/mnt/var";
- system "mount", "-t", $fs, "/dev/$hdp$var", "/mnt/var";
-}
-if ($home) {
- mkdir "/mnt/home";
- system "mount", "-t", $fs, "/dev/$hdp$home", "/mnt/home";
-}
-
-print "Copying installation on hard drive\n";
-mkdir "/hd/boot";
-if (-e "/cdrom/oem/vmlinuz" && -e "/cdrom/oem/all.rdz") {
- system "cp", "-a", "/cdrom/oem/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/cdrom/oem/all.rdz", "/hd/boot/all.rdz";
-} elsif (-e "/cdrom/isolinux/alt0/vmlinuz" && -e "/cdrom/isolinux/alt0/all.rdz") {
- system "cp", "-a", "/cdrom/isolinux/alt0/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/cdrom/isolinux/alt0/all.rdz", "/hd/boot/all.rdz";
-} elsif (-e "/cdrom/boot/vmlinuz" && -e "/cdrom/boot/hd.rdz") {
- system "cp", "-a", "/cdrom/boot/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/cdrom/boot/hd.rdz", "/hd/boot/all.rdz";
-} elsif (-e "/cdrom/images/hd.img") {
- mkdir "/tmp/hd";
- system "modprobe", "loop";
- system "modprobe", "vfat";
- system "mount", "-t", "vfat", "/cdrom/images/hd.img", "/tmp/hd", "-o", "loop";
- system "cp", "-a", "/tmp/hd/vmlinuz", "/hd/boot/vmlinuz";
- system "cp", "-a", "/tmp/hd/hd.rdz", "/hd/boot/all.rdz";
- system "umount", "/tmp/hd";
-} else {
- die "no installation stage1 found";
-}
-
-mkdir "/hd/Mandrake";
-mkdir "/hd/Mandrake/RPMS";
-system "cp", "-a", "/cdrom/VERSION", "/hd";
-system "cp", "-a", "/cdrom/Mandrake/base", "/cdrom/Mandrake/mdkinst", "/cdrom/Mandrake/share", "/hd/Mandrake";
-
-if (open F, ">/hd/Mandrake/oem_patch.pl") {
- print "Setting OEM specific extension to DrakX\n";
- if (exists $options{server}) {
- print F q{
- use install_steps;
- package install_steps;
- undef *choosePackages;
- *choosePackages = sub {
- my ($o, $packages, $compssUsers, $first_time) = @_;
-
- #- make sure we kept some space left for available else the system may
- #- not be able to start (xfs at least).
- my $available = install_any::getAvailableSpace($o);
- my $availableCorrected = pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024);
-
- #- avoid destroying user selection of packages but only
- #- for expert, as they may have done individual selection before.
- install_any::unselectMostPackages($o);
-
- #- use specific OEM packages selection, go to level 5
- #- and disable some extension.
- $o->{compssUsersChoice}{$_} = 0 foreach 'GNOME';
- $o->{compssUsersChoice}{$_} = 0
- foreach map { @{$o->{compssUsers}{$_}{flags}} } 'Workstation|Office Workstation', 'Workstation|Internet station';
- $o->{compssListLevel} = 5;
- pkgs::setSelectedFromCompssList($packages, $o->{compssUsersChoice}, $o->{compssListLevel}, $availableCorrected);
-
- $availableCorrected;
- };
- };
- } else {
- print F q{
- use install_steps;
- package install_steps;
- undef *choosePackages;
- *choosePackages = sub {
- my ($o, $packages, $compssUsers, $first_time) = @_;
-
- #- make sure we kept some space left for available else the system may
- #- not be able to start (xfs at least).
- my $available = install_any::getAvailableSpace($o);
- my $availableCorrected = pkgs::invCorrectSize($available / sqr(1024)) * sqr(1024);
-
- #- avoid destroying user selection of packages but only
- #- for expert, as they may have done individual selection before.
- install_any::unselectMostPackages($o);
-
- #- use specific OEM packages selection, go to level 4.
- #- and select at least GAMES group, everything else has
- #- already be selected during master preparation.
- $o->{compssListLevel} = 4;
- $o->{compssUsersChoice}{$_} = 1 foreach qw(GAMES VIDEO AUDIO GRAPHICS);
- pkgs::setSelectedFromCompssList($packages, $o->{compssUsersChoice}, $o->{compssListLevel}, $availableCorrected);
-
- $availableCorrected;
- };
- };
- }
- if ($options{boot_entries}) {
- print "Setting OEM specific extension for boot entries\n";
- print F q{
- my $sorted_entries = q(} . $options{boot_entries} . q{); #- insert boot_entries options here as string q(...).
- my $old_setupBootloaderBefore = \&setupBootloaderBefore;
- undef *setupBootloaderBefore;
- *setupBootloaderBefore = sub {
- $old_setupBootloaderBefore->(@_);
- my @entries = split ',', $sorted_entries;
- my @result_entries;
- foreach my $p (@entries) {
- foreach (@{$_[0]{bootloader}{entries}}) {
- $_->{label} eq $p and push @result_entries, $_;
- }
- }
- if (@result_entries) {
- $_[0]{bootloader}{entries} = \@result_entries;
- $_[0]{bootloader}{default} = $result_entries[0]{label}; #- first image is default.
- }
- };
- };
- }
- close F;
-}
-
-print "Setting bootloader\n";
-mkdir "/hd/boot/grub";
-foreach (1..2) {
- -e "/hd/boot/grub/stage$_" or system "cp", "-a", "/boot/grub/stage$_", "/hd/boot/grub";
-}
-open F, ">/hd/boot/grub/menu.lst";
-if (defined $resize_fat_size) {
- print F "timeout 5\n";
- print F "color black/cyan yellow/cyan\n\n";
- print F "title linux\n";
-} else {
- print F "timeout 0\n\n";
- print F "title oem\n";
-}
-print F "kernel (hd0,$instz)/boot/vmlinuz ramdisk_size=128000 $options{kernel} automatic=method:disk,disk:$hd,partition:$hdp$inst,directory:/ hd vga=788 fbeginner oem defcfg=/tmp/hdimage/Mandrake/oem_patch.pl\n";
-print F "initrd (hd0,$instz)/boot/all.rdz\n";
-#- if a windows partition is available, add an entrie for it.
-if (defined $resize_fat_size) {
- print F "\ntitle windows\n";
- printf F "rootnoverify (hd0,%s)\n", $hd_parts[$fat_pos]{minor}-1;
- print F "makeactive\n";
- print F "chainloader +1\n";
-}
-close F;
-open F, ">/hd/boot/grub/device.map";
-print F "(hd0) /dev/$hd\n";
-close F;
-open F, "| grub --device-map=/hd/boot/grub/device.map --batch";
-print F "install (hd0,$instz)/boot/grub/stage1 d (hd0) (hd0,$instz)/boot/grub/stage2 p (hd0,$instz)/boot/grub/menu.lst\n";
-print F "quit\n";
-close F or die "error while executing grub";
-
-my $packages = read_depslist("/cdrom/Mandrake/base/depslist.ordered");
-
-my @media;
-open F, "/cdrom/Mandrake/base/hdlists";
-foreach (<F>) {
- chomp;
- s/\s*#.*$//;
- /^\s*$/ and next;
- m/^\s*(hdlist\S*\.cz2?)\s+(\S+)\s*(.*)$/ or die "invalid hdlist description \"$_\" in hdlists file";
-
- push @media, { hdlist => $1, rpmsdir => $2, descr => $3 };
-}
-close F;
-
-#- initialize installation.
-foreach (qw(/etc /etc/sysconfig /etc/rpm /var /var/lib /var/lib/rpm /var/log /proc)) {
- mkdir "/mnt/$_";
-}
-system "mount", "-t", "proc", "proc", "/mnt/proc";
-open F, ">/mnt/etc/fstab";
-print F "/dev/$hdp$root / $fs defaults 1 1\n";
-if ($var) {
- print F "/dev/$hdp$var /var $fs defaults 1 2\n";
-}
-if ($home) {
- print F "/dev/$hdp$home /home $fs defaults 1 2\n";
-}
-close F;
-#- stupid things for installer to work correctly.
-#open F, ">/mnt/etc/mandrake-release";
-#print F "Mandrake Linux release 9.1 (Bamboo) for i586";
-#close F;
-
-#- keep in mind all the rpm files available (according to hdlists).
-my (%files, %rpms);
-
-require packdrake;
-foreach my $medium (@media) {
- my $packer = new packdrake("/cdrom/Mandrake/base/$medium->{hdlist}");
- foreach (@{$packer->{files}}) {
- $packer->{data}{$_}[0] eq 'f' or next;
- my ($fullname, $file) = /([^:]*):(.*)/ ? ($1, "$2.rpm") : ($_, "$_.rpm");
- $files{$fullname} = $file;
- $rpms{$fullname} = $medium->{rpmsdir};
- #- convert %{ARCH} to effective arch of the given package.
- my ($arch) = $fullname =~ /\.([^\.\-]*)$/;
- $rpms{$fullname} =~ s|%{ARCH}|$arch|g;
- }
-}
-
-#- install some important packages.
-system "rpm", "--root", "/mnt", "--initdb";
-
-#- copy and install from each cd image.
-foreach my $medium (@media) {
- my $rpmsdir = $medium->{rpmsdir};
- $rpmsdir =~ s|%{ARCH}.*||; #- only for checking directory presence...
- while ($cd && ! -d "/cdrom/$rpmsdir") {
- system "unmount", "/dev/$cd";
- system "eject", "/dev/$cd";
- print "Please insert the cdrom labeled \"$medium->{descr}\"\n and press [enter] when done\n";
- $yes = <STDIN>;
- system "mount", "-r", "-t", "iso9660", "/dev/$cd", "/cdrom";
- }
-
- print "Copying packages from medium labeled \"$medium->{descr}\" to hard disk\n";
- foreach my $pkg (@{$packages->{depslist}}) {
- $files{rpm_fullname($pkg)} or next;
- my $infile = "/cdrom/" . $rpms{rpm_fullname($pkg)} . "/" . $files{rpm_fullname($pkg)};
- my $outfile = "/hd/" . $rpms{rpm_fullname($pkg)} . "/" . $files{rpm_fullname($pkg)};
- if (-r $infile && -s $infile != -s $outfile) {
- -d "/hd/" . $rpms{rpm_fullname($pkg)} or system "mkdir", "-p", "/hd/" . $rpms{rpm_fullname($pkg)};
- print " copying " . rpm_fullname($pkg) . "\n";
- system "cp", "-a", $infile, $outfile;
- if (rpm_fullname($pkg) =~ /mandrake-release/) {
- system "rpm", "-Uvh", "--root", "/mnt", "--nodeps", "--force", $outfile;
- }
- #- clean to say everything is done.
- delete $files{rpm_fullname($pkg)};
- delete $rpms{rpm_fullname($pkg)};
- }
- }
-}
-
-#- try to figure out if a oem-message-graphic already exists.
-#- if this is the case, rename it to /mnt/boot/message-graphic
-if (-e "/cdrom/Mandrake/base/oem-message-graphic") {
- print "Using specific oem graphic image\n";
- if (-e "/mnt/boot/message-graphic") {
- rename "/mnt/boot/message-graphic", "/mnt/boot/message-graphic.old";
- system "cp", "-a", "/cdrom/Mandrake/base/oem-message-graphic", "/mnt/boot/message-graphic";
- } elsif (-e "/mnt/boot/lilo-graphic/message") {
- rename "/mnt/boot/lilo-graphic/message", "/mnt/boot/lilo-graphic/message.old";
- system "cp", "-a", "/cdrom/Mandrake/base/oem-message-graphic", "/mnt/boot/lilo-graphic/message";
- }
-}
-
-#- clean all initrd image which may have been built.
-system "rm -f /mnt/boot/initrd*";
-
-system "umount", "/mnt/proc";
-$home and system "umount", "/mnt/home";
-$var and system "umount", "/mnt/var";
-system "umount", "/mnt";
-system "umount", "/hd";
-system "umount", "/cdrom";
-
-$cd and system "eject", "/dev/$cd";
-
-print "
-Done. OEM hard drive ready!
-The hard drive is now ready for a customer.
-System is now halted.\n\n";
-
-system "halt";
-
-#- gives way to format partition (simpler approach)
-sub mkfs {
- my ($fs, $dev) = @_;
- for ($fs) {
- /ext2/ and do { system "mkfs.ext2", $dev;
- next };
- /ext3/ and do { system "mkfs.ext2", "-j", $dev;
- system "tune2fs", "-c0", "-i0", $dev;
- next };
- /fat16/ and do { system "mkdosfs", $dev;
- next };
- /fat32/ and do { system "mkdosfs", "-F", "32", $dev;
- next };
- die "unknown fs: $_\n";
- }
-}
-
-sub chop_version {
- ($_[0] =~ /^([^:\s]*)-[^:\-\s]+-[^:\-\s]+\.[^:\.\-\s]*(?::\S*)?/)[0] || die "unable to parse $_[0]";
-}
-sub rpm_fullname {
- ($_[0]{name} =~ /^([^:\s]*-[^:\-\s]+-[^:\-\s]+\.[^:\.\-\s]*)(?::\S*)?/)[0] || die "unable to parse $_[0]";
-}
-
-sub read_depslist {
- my ($file) = @_;
- my $packages = { depslist => [], names => {} };
-
- #- read depslist.oredered file.
- my $id = 0;
-
- open F, "$file" or die "unable to open ordered dependencies list file";
- while (<F>) {
- my ($name, $size, @deps) = split;
- push @{$packages->{depslist}}, { id => $id++, name => $name, size => $size, deps => \@deps };
- }
- close F;
-
- foreach (@{$packages->{depslist}}) {
- $packages->{names}{chop_version($_->{name})} = $_;
- }
-
- print "read " . scalar(@{$packages->{depslist}}) . " package dependancies\n";
- $packages;
-}
-
diff --git a/rescue/tree/etc/rc.sysinit b/rescue/tree/etc/rc.sysinit
index 0f9d6b3c1..15643bfaf 100755
--- a/rescue/tree/etc/rc.sysinit
+++ b/rescue/tree/etc/rc.sysinit
@@ -43,8 +43,6 @@ load loop
load sd_mod
load sr_mod
-grep -q oem /proc/cmdline && exec /etc/oem-all -f
-
/sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0
/sbin/route add 127.0.0.1 lo
diff --git a/tools/oem-prepare b/tools/oem-prepare
deleted file mode 100755
index e6c3b1458..000000000
--- a/tools/oem-prepare
+++ /dev/null
@@ -1,477 +0,0 @@
-#!/usr/bin/perl
-
-my ($mode, $dir, $reject_dir, $lang) = @ARGV;
-$mode =~ s/^--(rebuild|clean)$/$1/ or die "mode should be --rebuild or --clean\n";
--e "$dir/Mandrake/base/hdlists" && -d $reject_dir or die "usage: oem-prepare <--rebuild|--clean> <top_dir> <reject_dir> <lang>\n";
-
-#- detect language used and default options.
-open F, "$dir/VERSION" or die "no installation found on $dir";
-while (<F>) {
- /[\s-]fr/ and $lang = 'fr';
- /\[lang[=:]([^]]*)\]/ and $lang = $1;
- /[\[\-]server[\]\-]/ and $options{server} = '';
-}
-close F;
-
-my ($flang, $charset);
-#- default language fall to english ?
-foreach ($lang || 'en') {
- /fr/ and ($lang, $flang, $charset) = ('fr', 'fr_FR@euro', 'iso-8859-15');
- /en/ and ($lang, $flang, $charset) = ('en', 'en_US', 'iso-8859-1');
- /de/ and ($lang, $flang, $charset) = ('de', 'de_DE@euro', 'iso-8859-15');
- /it/ and ($lang, $flang, $charset) = ('it', 'it_IT@euro', 'iso-8859-15');
- /es/ and ($lang, $flang, $charset) = ('es', 'es_ES@euro', 'iso-8859-15');
-}
-print "Found lang $lang\n";
-foreach (keys %options) {
- print "Using option [$_" . ($options{$_} && "=$options{$_}") . "]\n";
-}
-
-
-my $packages = select_packages($dir, $lang);
-
-my @media;
-open F, "$dir/Mandrake/base/hdlists";
-foreach (<F>) {
- chomp;
- s/\s*#.*$//;
- /^\s*$/ and next;
- m/^\s*(hdlist\S*\.cz2?)\s+(\S+)\s*(.*)$/ or die "invalid hdlist description \"$_\" in hdlists file";
-
- push @media, { hdlist => $1, rpmsdir => $2, descr => $3 };
-}
-close F;
-
-
-#- keep in mind all the rpm files available (according to hdlists).
-my (%rpms, %files);
-
-require packdrake;
-foreach my $medium (@media) {
- my $packer = new packdrake("$dir/Mandrake/base/$medium->{hdlist}");
- foreach (@{$packer->{files}}) {
- $packer->{data}{$_}[0] eq 'f' or next;
- my ($fullname, $file) = /([^:]*):(.*)/ ? ($1, "$2.rpm") : ($_, "$_.rpm");
- $files{$fullname} = $file;
- $rpms{$file} = $medium->{rpmsdir};
- -e "$dir/$medium->{rpmsdir}/$file" and next; #- already exist in the right directory.
- if (-e "$reject_dir/$file") {
- $mode eq 'rebuild' and system "mv", "-f", "$reject_dir/$file", "$dir/$medium->{rpmsdir}/";
- next;
- }
- print STDERR "unable to find package $file listed in medium \"$medium->{descr}\"\n";
- }
-}
-
-if ($mode eq 'clean') {
- #- copy and install from each cd image.
- foreach my $medium (@media) {
- print "Examining packages from medium labeled \"$medium->{descr}\"\n";
-
- foreach my $pkg (@{$packages->{depslist}}) {
- $pkg->{closure} && !$pkg->{selected} or next;
- my $file = "$dir/$medium->{rpmsdir}/" . $files{rpm_fullname($pkg)};
- if (-e $file) {
- delete $rpms{$files{rpm_fullname($pkg)}} or next;
- print " copying $file\n";
- delete $pkg->{closure};
- }
- }
-
- if (my $pkg = pkgs::packageByName($packages, 'glibc')) { #- HACK FOR GLIBC
- if ($pkg->{selected}) {
- my $file = "$dir/$medium->{rpmsdir}/" . $files{rpm_fullname($pkg)};
- if (-e $file) {
- delete $rpms{$files{rpm_fullname($pkg)}} or next;
- print " installing $file\n";
- delete $pkg->{selected};
- }
- }
- } else {
- die "no glibc package found";
- }
- foreach my $pkg (@{$packages->{depslist}}) {
- $pkg->{selected} or next;
- my $file = "$dir/$medium->{rpmsdir}/" . $files{rpm_fullname($pkg)};
- if (-e $file) {
- delete $rpms{$files{rpm_fullname($pkg)}} or next;
- print " installing $file\n";
- delete $pkg->{selected};
- }
- }
-
- scalar(grep { $_->{selected} || $_->{closure} } @{$packages->{depslist}}) == 0 and last;
- }
-
- #- copy files.
- #- at this point, everything left in %rpms has to be moved to $reject_dir.
- foreach (keys %rpms) {
- -e "$reject_dir/$_" and next; #- already cleaned.
- -e "$dir/$rpms{$_}/$_" or print STDERR "file \"$_\" should be in [$dir/$rpms{$_}]\n", next;
- system "mv", "-f", "$dir/$rpms{$_}/$_", $reject_dir;
- }
-}
-
-#- provide package fullname that have to be installed and copied.
-sub select_packages {
- my ($dir, $lang) = @_;
- my $o = { packages => read_depslist("$dir/Mandrake/base/depslist.ordered") };
-
- #- act as DrakX will do to select packages.
- pkgs::read_rpmsrate($o->{packages}, install_any::getFile("Mandrake/base/rpmsrate") || die "unable to read rpmsrate");
- ($o->{compssUsers}, $o->{compssUsersSorted}, $o->{compssUsersIcons}, $o->{compssUsersDescr}) =
- pkgs::readCompssUsers($o->{packages}, $o->{meta_class});
- eval { install_any::getFile("XXX") }; #- close out any still opened filehandle..
-
- pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, 'basesystem') || die "no basesystem package found");
- #- by default, choose:
- $o->{compssUsersChoice}{$_} = 1 foreach 'GNOME', 'KDE', 'CONFIG', 'X';
- $o->{compssUsersChoice}{$_} = 1
- foreach map { @{$o->{compssUsers}{$_}{flags}} } 'Workstation|Office Workstation', 'Workstation|Internet station';
-
- if (exists $options{server}) {
- foreach (qw(KDE ACCESSIBILITY PUBLISHING CUPS EDITORS TEXT_TOOLS COMMUNICATIONS TERMINALS
- NETWORKING_FILE_TRANSFER NETWORKING_OTHER
- NETWORKING_FILE_TRANSFER_SERVER NETWORKING_FIREWALLING_SERVER NETWORKING_LDAP_SERVER
- NETWORKING_MAIL_SERVER NETWORKING_OTHER_SERVER
- NETWORKING_REMOTE_ACCESS NETWORKING_REMOTE_ACCESS_SERVER NETWORKING_DNS NETWORKING_DNS_SERVER
- NETWORKING_FILE NETWORKING_FILE_SERVER NETWORKING_WWW NETWORKING_WWW_SERVER
- ARCHIVING DEVELOPMENT MONITORING FILE_TOOLS CONFIG BOOKS SYSTEM X DOCS)) {
- $o->{compssUsersChoice}{$_} = 1;
- }
- #- additional packages to be selected for server, databases with MySQL (avoid rpmsrate modifications).
- foreach (qw(MySQL-client MySQL-shared MySQL perl-Mysql)) {
- my $pkg = pkgs::packageByName($o->{packages}, $_);
- $pkg and pkgs::selectPackage($o->{packages}, $pkg);
- }
- } else {
- $o->{compssUsersChoice}{$_} = 1 foreach map { @{$o->{compssUsers}{$_}} } @{$o->{compssUsersSorted}};
- $o->{compssUsersChoice}{$_} = 1 foreach qw(SYSTEM X DOCS);
- @{$o->{compssUsersChoice}}{grep { /SERVER|DATABASES/ } keys %{$o->{compssUsersChoice}}} = ();
- }
-
- my $lang_pkg = $lang && pkgs::packageByName($o->{packages}, "locales-$lang");
- if ($lang_pkg) {
- pkgs::selectPackage($o->{packages}, $lang_pkg);
- $o->{compssUsersChoice}{qq(LOCALES"$lang")} = 1;
- $o->{compssUsersChoice}{qq(LOCALES"$flang")} = 1;
- $o->{compssUsersChoice}{qq(CHARSET"$charset")} = 1;
- }
-
- pkgs::setSelectedFromCompssList($o->{packages}, $o->{compssUsersChoice}, 4, 0);
- #- save selected, but keep selected property.
- foreach my $pkg (@{$o->{packages}{depslist}}) {
- $pkg->{selected} and $pkg->{save_selected} = $pkg->{selected};
- }
-
- #- extend selection to closure now, make all selected as closure and restore selected after.
- $o->{compssUsersChoice}{$_} = 1 foreach qw(BURNER DVD PCMCIA BIGMEM SMP 3D TV SCANNER PHOTO SOUND);
- pkgs::setSelectedFromCompssList($o->{packages}, $o->{compssUsersChoice}, 4, 0);
- $o->{compssUsersChoice}{$_} = 0 foreach qw(BURNER DVD PCMCIA BIGMEM SMP 3D TV SCANNER PHOTO SOUND);
- #- INSTALL class need to be copied as closure (unless installed after).
- #- but we have to remove kernel22 and kernel22-smp now obsolete for oem.
- foreach (@{$o->{packages}{needToCopy}}) {
- /^(kernel22.*|raidtools|lvm|reiserfsprogs|xfsprogs|jfsprogs|XFree86-(Mach8|Mach32|Mono|W32|3DLabs|P9000|8514|VGA16|I128|AGX))$/ and next;
- my $pkg = pkgs::packageByName($o->{packages}, $_);
- pkgs::selectPackage($o->{packages}, $pkg);
- }
- #- first select package that have to go to closure according to their names.
- foreach my $pkg (@{$o->{packages}{depslist}}) {
- $pkg->{name} =~ /kernel-(\d|smp|enterprise)/ and pkgs::selectPackage($o->{packages}, $pkg);
- $pkg->{name} =~ /NVIDIA/ and pkgs::selectPackage($o->{packages}, $pkg);
- }
- foreach my $pkg (@{$o->{packages}{depslist}}) {
- delete $pkg->{selected} && !$pkg->{save_selected} and $pkg->{closure} = 1;
- $pkg->{save_selected} and $pkg->{selected} = $pkg->{save_selected};
- }
-
- #- package that have to selected here as a bonus for oem install.
- foreach (qw(cups cups-drivers a2ps drakprofile draksync numlock icewm-light
- Mesa Mesa-demos alsa alsa-utils curl
- glibc vim-minimal kernel gcc-cpp
- ), exists $options{server} ? qw(openldap-migration openldap-clients pam_ldap) : ()) {
- my $pkg = pkgs::packageByName($o->{packages}, $_);
- $pkg and pkgs::selectPackage($o->{packages}, $pkg);
- }
-
- #- special packages that are to be move to closure always ...
- foreach (qw(nfs-utils-client numlock usbd hotplug alsa alsa-utils
- Aurora Aurora-Monitor-NewStyle-Categorizing-WsLib bootsplash)) {
- my $pkg = pkgs::packageByName($o->{packages}, $_);
- if ($pkg) {
- pkgs::selectPackage($o->{packages}, $pkg);
- $pkg->{closure} = 1;
- delete $pkg->{selected};
- }
- }
-
- #- special packages that are to be removed always... BEWARE THIS IS A HACK !!!
-# foreach (qw(gmc gcc3.0 gcc3.0-c++ gcc3.0-cpp libstdc++3.0 libstdc++3.0-devel)) {
-# my $pkg = pkgs::packageByName($o->{packages}, $_);
-# if ($pkg) {
-# delete $pkg->{closure};
-# delete $pkg->{selected};
-# }
-# }
-
- $o->{packages};
-}
-
-sub chop_version {
- ($_[0] =~ /^([^:\s]*)-[^:\-\s]+-[^:\-\s]+\.[^:\.\-\s]*(?::\S*)?/)[0] || die "unable to parse $_[0]";
-}
-sub rpm_fullname {
- ($_[0]{name} =~ /^([^:\s]*-[^:\-\s]+-[^:\-\s]+\.[^:\.\-\s]*)(?::\S*)?/)[0] || die "unable to parse $_[0]";
-}
-
-sub read_depslist {
- my ($file) = @_;
- my $packages = { depslist => [], names => {} };
-
- #- read depslist.oredered file.
- my $id = 0;
-
- open F, "$file" or die "unable to open ordered dependencies list file";
- while (<F>) {
- my ($name, $size, @deps) = split;
- push @{$packages->{depslist}}, { id => $id++, name => $name, size => $size, deps => \@deps };
- }
- close F;
-
- foreach (@{$packages->{depslist}}) {
- $packages->{names}{chop_version($_->{name})} = $_;
- }
-
- print "read " . scalar(@{$packages->{depslist}}) . " package dependancies\n";
- $packages;
-}
-
-#- compability method for the below ones, wrap DrakX code extracted.
-package log;
-sub l {}
-
-package detect_devices;
-sub matching_desc { 1 }
-
-package install_any;
-sub getFile { open FILE, "$dir/$_[0]" or return; \*FILE }
-
-package pkgs;
-sub if_ { my $b = shift; $b or return (); wantarray ? @_ : $_[0] }
-sub formatXiB { $_[0] } #- NOP
-sub packageName { ::chop_version($_[0]{name}) }
-sub packageFlagSelected { $_[0]{selected} }
-sub packageSize { $_[0]{size} }
-sub packageDepsId { @{$_[0]{deps}} }
-sub packageRate { $_[0]{values}[0] }
-sub packageRateRFlags { @{$_[0]{values}} }
-sub packageSetRateRFlags {
- my ($pkg, @rate_rflags) = @_;
- $pkg->{values} = [ @rate_rflags ];
-}
-sub packageByName {
- my ($packages, $name) = @_;
- $packages->{names}{$name};
-}
-sub packageById {
- my ($packages, $id) = @_;
- $packages->{depslist}[$id];
-}
-sub selectedSize {
- my ($packages) = @_;
- my $size = 0;
- foreach (@{$packages->{depslist}}) {
- $_->{selected} and $size += $_->{size};
- }
- $size;
-}
-my @preferred = qw(perl-GTK postfix gcc gcc-cpp gcc-c++ proftpd ghostscript-X vim-minimal kernel db1 db2 ispell-en Bastille-Curses-module nautilus libxpm4);
-sub selectPackage {
- my ($packages, $pkg, $base, $otherOnly, $check_recursion) = @_;
-
- #- avoid infinite recursion (mainly against badly generated depslist.ordered).
- $check_recursion ||= {}; exists $check_recursion->{$pkg->{name}} and return; $check_recursion->{$pkg->{name}} = undef;
-
- #- make sure base package are set even if already selected.
- $base and $pkg->{base} = 1;
-
- #- select package and dependancies, otherOnly may be a reference
- #- to a hash to indicate package that will strictly be selected
- #- when value is true, may be selected when value is false (this
- #- is only used for unselection, not selection)
- unless ($pkg->{selected}) {
- foreach (@{$pkg->{deps}}) {
- my $preferred;
- if (/\|/) {
- #- choice deps should be reselected recursively as no
- #- closure on them is computed, this code is exactly the
- #- same as pixel's one.
- my %preferred; @preferred{@preferred} = ();
- foreach (split '\|') {
- my $dep = $packages->{depslist}[$_] or next;
- $preferred ||= $dep;
- $dep->{selected} and $preferred = $dep, last;
- exists $preferred{::chop_version($dep->{name})} and $preferred = $dep;
- }
- selectPackage($packages, $preferred, $base, $otherOnly, $check_recursion) if $preferred;
- } else {
- #- deps have been closed except for choices, so no need to
- #- recursively apply selection, expand base on it.
- my $dep = $packages->{depslist}[$_];
- $base and $dep->{base} = 1;
- $otherOnly and !$dep->{selected} and $otherOnly->{::chop_version($dep->{name})} = 1;
- $otherOnly or $dep->{selected} += 1;
- }
- }
- }
- $otherOnly and !$pkg->{selected} and $otherOnly->{::chop_version($pkg->{name})} = 1;
- $otherOnly or $pkg->{selected} += 1;
- 1;
-}
-
-#- this code is extracted from DrakX and SHOULD NOT BE MODIFIED, wrapper method exists above to provide a good choice.
-sub read_rpmsrate {
- my ($packages, $f) = @_;
- my $line_nb = 0;
- my $fatal_error;
- my (@l);
- while (<$f>) {
- $line_nb++;
- /\t/ and die "tabulations not allowed at line $line_nb\n";
- s/#.*//; # comments
-
- my ($indent, $data) = /(\s*)(.*)/;
- next if !$data; # skip empty lines
-
- @l = grep { $_->[0] < length $indent } @l;
-
- my @m = @l ? @{$l[$#l][1]} : ();
- my ($t, $flag, @l2);
- while ($data =~
- /^((
- [1-5]
- |
- (?: (?: !\s*)? [0-9A-Z_]+(?:".*?")?)
- (?: \s*\|\|\s* (?: !\s*)? [0-9A-Z_]+(?:".*?")?)*
- )
- (?:\s+|$)
- )(.*)/x) { #@")) {
- ($t, $flag, $data) = ($1,$2,$3);
- while ($flag =~ s,^\s*(("[^"]*"|[^"\s]*)*)\s+,$1,) {}
- my $ok = 0;
- $flag = join('||', grep {
- if (my ($inv, $p) = /^(!)?HW"(.*)"/) {
- ($inv xor detect_devices::matching_desc($p)) and $ok = 1;
- 0;
- } else {
- 1;
- }
- } split '\|\|', $flag);
- push @m, $ok ? 'TRUE' : $flag || 'FALSE';
- push @l2, [ length $indent, [ @m ] ];
- $indent .= $t;
- }
- if ($data) {
- # has packages on same line
- my ($rate) = grep { /^\d$/ } @m or die sprintf qq(missing rate for "%s" at line %d (flags are %s)\n), $data, $line_nb, join('&&', @m);
- foreach (split ' ', $data) {
- if ($packages) {
- my $p = packageByName($packages, $_) or next;
- my @m2 =
- map { if_($_ && packageName($_) =~ /locales-(.*)/, qq(LOCALES"$1")) }
- map { packageById($packages, $_) } packageDepsId($p);
-
- my @m3 = ((grep { !/^\d$/ } @m), @m2);
- if (@m3 >= 1 && $m3[0] eq 'INSTALL' || @m3 >=2 && $m3[1] eq 'INSTALL') {
- push @{$packages->{needToCopy} ||= []}, $_;
- next; #- don't need to put INSTALL flag for a package.
- }
- if (packageRate($p)) {
- my ($rate2, @m4) = packageRateRFlags($p);
- if (@m3 > 1 || @m4 > 1) {
- log::l("can't handle complicate flags for packages appearing twice ($_)");
- $fatal_error++;
- }
- log::l("package $_ appearing twice with different rates ($rate != $rate2)") if $rate != $rate2;
- packageSetRateRFlags($p, $rate, "$m3[0]||$m4[0]");
- } else {
- packageSetRateRFlags($p, $rate, @m3);
- }
- } else {
- print "$_ = ", join(" && ", @m), "\n";
- }
- }
- push @l, @l2;
- } else {
- push @l, [ $l2[0][0], $l2[$#l2][1] ];
- }
- }
- $fatal_error and die "$fatal_error fatal errors in rpmsrate";
-}
-
-sub readCompssUsers {
- my ($packages, $meta_class) = @_;
- my (%compssUsers, %compssUsersIcons, , %compssUsersDescr, @sorted, $l);
- my (%compss);
-
- my $file = 'Mandrake/base/compssUsers';
- my $f = $meta_class && install_any::getFile("$file.$meta_class") || install_any::getFile($file) or die "can't find $file";
- local $_;
- while (<$f>) {
- /^\s*$/ || /^#/ and next;
- s/#.*//;
-
- if (/^(\S.*)/) {
- my ($icon, $descr);
- /^(.*?)\s*\[icon=(.*?)\](.*)/ and $_ = "$1$3", $icon = $2;
- /^(.*?)\s*\[descr=(.*?)\](.*)/ and $_ = "$1$3", $descr = $2;
- $compssUsersIcons{$_} = $icon;
- $compssUsersDescr{$_} = $descr;
- push @sorted, $_;
- $compssUsers{$_} = $l = [];
- } elsif (/^\s+(.*?)\s*$/) {
- push @$l, $1;
- }
- }
- \%compssUsers, \@sorted, \%compssUsersIcons, \%compssUsersDescr;
-}
-
-sub setSelectedFromCompssList {
- my ($packages, $compssUsersChoice, $min_level, $max_size, $otherOnly) = @_;
- $compssUsersChoice->{TRUE} = 1; #- ensure TRUE is set
- my $nb = selectedSize($packages);
- foreach my $p (sort { packageRate($b) <=> packageRate($a) } values %{$packages->{names}}) {
- my ($rate, @flags) = packageRateRFlags($p);
- next if
- !$rate || $rate < $min_level ||
- grep { !grep { /^!(.*)/ ? !$compssUsersChoice->{$1} : $compssUsersChoice->{$_} } split('\|\|') } @flags;
-
- #- determine the packages that will be selected when
- #- selecting $p. the packages are not selected.
- my %newSelection;
- selectPackage($packages, $p, 0, \%newSelection);
-
- #- this enable an incremental total size.
- my $old_nb = $nb;
- foreach (grep { $newSelection{$_} } keys %newSelection) {
- $nb += packageSize($packages->{names}{$_});
- }
- if ($max_size && $nb > $max_size) {
- $nb = $old_nb;
- $min_level = packageRate($p);
- last;
- }
-
- #- at this point the package can safely be selected.
- if ($otherOnly) {
- selectPackage($packages, $p, 0, $otherOnly);
- } else {
- selectPackage($packages, $p);
- }
- }
- unless ($otherOnly) {
- log::l("setSelectedFromCompssList: reached size ", formatXiB($nb), ", up to indice $min_level (less than ", formatXiB($max_size), ")");
- log::l("setSelectedFromCompssList: ", join(" ", sort map { packageName($_) } grep { packageFlagSelected($_) } @{$packages->{depslist}}));
- }
- $min_level;
-}