summaryrefslogtreecommitdiffstats
path: root/live/One/2006.0/config/patch-2006-live.pl
blob: c0da6280b37980608a468a497c6e4b6fbaf36292 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
$o->{autoExitInstall} = 1;
$o->{build_live_system} = 1;
$o->{desktop} = 'KDE';
$o->{autologin} = ${$o->{users}}[0]->{name};


my %cmdline;
my $opt; foreach (@ARGV) {
    if (/^--?(.*)/) {
        $cmdline{$opt} = 1 if $opt;
        $opt = $1;
    } else {
        $cmdline{$opt} = $_ if $opt;
        $opt = '';
    }
} $cmdline{$opt} = 1 if $opt;
exists $cmdline{langs} and $o->{locale}{langs} = +{ map { $_ => 1 } split(':', $cmdline{langs}) };

use install_any;
package install_any;

undef *ejectCdrom;
*ejectCdrom = sub {};

use pkgs;
package pkgs;

undef *read_rpmsrate;
*read_rpmsrate = sub {
    my ($packages, $rpmsrate_flags_chosen, $f) = @_;

    my ($rates, $flags, $need_to_copy) = read_rpmsrate_raw($f);
    
    foreach (keys %$flags) {
	my $p = packageByName($packages, $_) or next;
	my @flags = (@{$flags->{$_}}, map { if_(/locales-(.*)/, qq(LOCALES"$1")) } $p->requires_nosense);

	@flags = map {
	    my ($user_flags, $known_flags) = partition { /^!?CAT_/ } split('\|\|', $_);
	    my $ok = find {
		my $inv = s/^!//;
		$inv xor do {
		    if (my ($p) = /^HW"(.*)"/) {
			return $::o->{build_live_system} ? !$inv : detect_devices::matching_desc__regexp($p);
		    } elsif (($p) = /^HW_CAT"(.*)"/) {
			return $::o->{build_live_system} ? !$inv : modules::probe_category($p);
		    } elsif (($p) = /^DRIVER"(.*)"/) {
			return $::o->{build_live_system} ? !$inv : detect_devices::matching_driver__regexp($p);
		    } elsif (($p) = /^TYPE"(.*)"/) {
			return $::o->{build_live_system} ? !$inv : detect_devices::matching_type($p);
		    } else {
			$rpmsrate_flags_chosen->{$_};
		    }
		};
	    } @$known_flags;
	    $ok ? 'TRUE' : @$user_flags ? join('||', @$user_flags) : 'FALSE';
	} @flags;

	$p->set_rate($rates->{$_});
	$p->set_rflags(member('FALSE', @flags) ? 'FALSE' : @flags);
    }
    push @{$packages->{needToCopy} ||= []}, @$need_to_copy;
};

undef *bestKernelPackage;
*bestKernelPackage = sub {
    my ($packages) = @_;

    my @kernels = packages2kernels($packages) or internal_error('no kernel available');
    my ($version_BOOT) = c::kernel_version() =~ /^(\d+\.\d+)/;
    if (my @l = grep { $_->{version} =~ /\Q$version_BOOT/ } @kernels) {
	#- favour versions corresponding to current BOOT version
	@kernels = @l;
    }
    my @preferred_exts =
      $::o->{build_live_system} ? '-i586-up-1GB' :
      detect_devices::is_xbox() ? '-xbox' :
      detect_devices::is_i586() ? '-i586-up-1GB' :
      !detect_devices::has_cpu_flag('pae') ? ('-i686-up-4GB', '-i586-up-1GB') :
      detect_devices::hasSMP() ? '-smp' :
      '';
    foreach my $prefered_ext (@preferred_exts, '') {
	if (my @l = grep { $_->{ext} eq $prefered_ext } @kernels) {
	    @kernels = @l;
	}
    }

    log::l("bestKernelPackage (" . join(':', @preferred_exts) . "): " . join(' ', map { $_->{pkg}->name } @kernels) . (@kernels > 1 ? ' (choosing the first)' : ''));
    $preferred{'kernel-source-' . $kernels[0]{version}} = undef;
    $kernels[0]{pkg};
};

undef *selected_leaves;
*selected_leaves = sub {
    my ($packages) = @_;
    my $provides = $packages->{provides};

    my @l = grep { $_->flag_requested || $_->flag_installed } @{$packages->{depslist}};

    my %required_ids;
    foreach my $pkg (@l) {
	foreach my $req ($pkg->requires_nosense) {
	    my $h = $provides->{$req} or next;
	    my @provides = my ($provide) = keys %$h;
	    @provides == 1 or next;
	    if ($provide != (exists $required_ids{$pkg->id} ? $required_ids{$pkg->id} : $pkg->id)) {
#		log::l($packages->{depslist}[$provide]->name . " is not a leaf because required by " . $pkg->name . " (through require $req)"); 
		#- $pkg requires $req, provided by $provide, so we can skip $provide
		$required_ids{$provide} = $pkg->id;
	    }
	}
    }
    [ map { $_->name } grep { ! exists $required_ids{$_->id} } @l ];    
};

use install_steps;
package install_steps;

my $old = \&configureNetwork;
undef *configureNetwork;
*configureNetwork = sub {
    my ($o) = @_;
    if ($o->{build_live_system}) {
        require network::ethernet;
        network::ethernet::install_dhcp_client($o, undef);
    }
    &$old;
};

undef *doPartitionDisksAfter;
*doPartitionDisksAfter = sub {
    my ($o) = @_;

    if (!$::testing) {
	my $hds = $o->{all_hds}{hds};
	partition_table::write($_) foreach @$hds;
	$_->{rebootNeeded} and $o->rebootNeeded foreach @$hds;
    }

    fs::set_removable_mntpoints($o->{all_hds});
    fs::mount_options::set_all_default($o->{all_hds}, %$o, lang::fs_options($o->{locale}))
	if !$o->{isUpgrade};

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

    if ($::local_install) {
	my $p = fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ]);
	my $part = fs::get::device2part($p->{device}, $o->{fstab}) || $o->{fstab}[0];
	$part->{mntpoint} = '/';
	$part->{isMounted} = 1;
    }

    fs::get::root_($o->{fstab}) or die "Oops, no root partition";

    if (arch() =~ /ppc/ && detect_devices::get_mac_generation() =~ /NewWorld/) {
	die "Need bootstrap partition to boot system!" if !(defined $partition_table::mac::bootstrap_part);
    }
    
    if (arch() =~ /ia64/ && !fs::get::has_mntpoint("/boot/efi", $o->{all_hds})) {
	die N("You must have a FAT partition mounted in /boot/efi");
    }

    if ($o->{partitioning}{use_existing_root}) {
	#- ensure those partitions are mounted so that they are not proposed in choosePartitionsToFormat
	fs::mount::part($_) foreach sort { $a->{mntpoint} cmp $b->{mntpoint} }
				    grep { $_->{mntpoint} && maybeFormatted($_) } @{$o->{fstab}};
    }

    cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/nfsimage| &&
      !any { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and
	push @{$o->{all_hds}{nfss}}, { fs_type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" };
};