summaryrefslogtreecommitdiffstats
path: root/config/live.cfg
blob: 22471c8e157908b57df34471021b4c3e58aad90f (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
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
#!/usr/bin/perl -cw

use MDK::Common;

my $ooo_version = '3.0';
my $use_modules = to_bool($live->{settings}{pack});
my @user_config_dirs = ('/etc/skel', if_($live->{settings}{default_user}, '/home/' . $live->{settings}{default_user}));

sub build_one_label {
	my ($live) = @_;

        my ($version, $extra) =  split(/-/, $live->{settings}{version});
	$version .= "S" if $extra eq 'spring';
	"LABEL=" . join("-", "Mageia", $version, $live->{settings}{desktop}, $live->{settings}{product});
}

my $_l = {
    workdir => $live->{settings}{workdir},
    system => {
        root => $live->{settings}{chroot},
        repository => $live->{settings}{repository},
        auto_install => 'config/auto_inst.cfg.pl',
        install_env => {
            DRAKLIVE_DESKTOP => $live->{settings}{desktop},
            DRAKLIVE_MEDIA => $live->{settings}{media},
            DRAKLIVE_PRODUCT => $live->{settings}{product},
            DRAKLIVE_ARCH => $live->{settings}{arch},
            DRAKLIVE_ADDITIONAL_REPOSITORY => $live->{settings}{additional_repository},
            DRAKLIVE_COMMERCIAL => $live->{settings}{commercial},
            DRAKLIVE_DEFAULT_USER => $live->{settings}{default_user},
        },
        hide_media_dirs => to_bool($live->{settings}{product} =~ /liveusb-rw/i),
        if_($live->{settings}{default_user}, preselect_kdm_user => $live->{settings}{default_user}),
        langs_always => [ 'en_US' ],
        files => [
	    # fix gnome-shell not showing draklive-install icon in menu in live mode
	    if_($live->{settings}{desktop} eq 'GNOME',
		[ 'files/01_gsettings-desktop-schemas.gschema.override', '/usr/share/glib-2.0/schemas/01_gsettings-desktop-schemas.gschema.override', { mode => 0644, no_install => 1 } ],
		[ 'files/glib2-branding.gschema.override', '/usr/share/glib-2.0/schemas/glib2-branding.gschema.override', { mode => 0644 } ],
            ),
            # blacklist pata_acpi
            [ 'files/blacklist_ide.conf', '/etc/modprobe.d/blacklist_ide.conf', { mode => 0644 } ],

            # clean live files
            [ 'files/live.51-mageia-resume.conf', '/etc/dracut.conf.d/51-mageia-resume.conf', { mode => 0644 } ],
            [ 'files/live.modprobe.conf', '/etc/modprobe.conf', { mode => 0644 } ],

	    # add local repos
	    if_($live->{settings}{arch} eq 'i586',
		[ 'files/mga_rpms/i586/mga_rpms', '/var/local' ],
	    ),
	    if_($live->{settings}{arch} eq 'x86_64',
		[ 'files/mga_rpms/x86_64/mga_rpms', '/var/local' ],
	    ),

	    # add initial dns resolver for online medias
	    [ 'files/resolv.conf', '/etc/resolv.conf', { mode => 0644 } ],

            # disable suspend and hibernate in live mode
            [ 'files/50-disable-suspend.pkla', '/etc/polkit-1/localauthority/50-local.d/50-disable-suspend.pkla', { mode => 0644, no_install => 1 } ],
            #- make cups the default spooler
            [ 'files/defaultspooler', '/etc/foomatic/defaultspooler', { mode => 0644 } ],
            if_(member($live->{settings}{media}, 'CD', 'DVD'),
                #- eject eject cd medium before halt/reboot
                [ 'files/halt-local.service', '/etc/systemd/system/halt-local.service', { mode => 0644, no_install => 1 } ],
                [ 'files/halt.local.CD', '/sbin/halt.local', { mode => 0755, no_install => 1 } ],
                #- do not load usblp and trigger autosetupprintqueues in live since cups is not available
                [ 'files/live.modprobe.CD', '/etc/modprobe.d/live.conf', { mode => 0644, no_install => 1 } ],
                # live media specific initrd
                [ 'files/live-dracut.conf', '/etc/dracut.conf.d/60-live.conf', { mode => 0644, no_install => 1 } ],
            ),
            #- disable first boot wizard at live boot
            [ 'files/firstboot', '/etc/sysconfig/firstboot', { mode => 0644 } ],
            #- enable drakx-finish-install at live boot
            [ "files/finish-install.$live->{settings}{media}", '/etc/sysconfig/finish-install', { mode => 0644 } ],
            #- disable speedboot for first boot after disk installation
            [ 'files/draklive-install.d/remove.d/disable-speedboot', '/etc/draklive-install.d/remove.d/disable-speedboot', { mode => 0644 } ],
            # fix for sometimes wrong permissions
            [ 'files/draklive-install.d/run.d/home-live-permissions.sh', '/etc/draklive-install.d/run.d/home-live-permissions.sh', { mode => 755 } ],
	    # fix for /var/lib/gdm sometimes ending up as root:root
	    if_($live->{settings}{desktop} eq 'GNOME',
		[ 'files/draklive-install.d/run.d/gdm-permissions.sh', '/etc/draklive-install.d/run.d/gdm-permissions.sh', { mode => 755 } ]
	    ),
	    if_($live->{settings}{desktop} eq 'PLASMA5',
		[ 'files/draklive-install.d/run.d/generate-gtk-icon-cache.sh', '/etc/draklive-install.d/run.d/generate-gtk-icon-cache.sh', { mode => 755 } ]
	    ),
            #- sysconfig files for first boot
            [ $live->{settings}{media} eq 'usb' ?
                "files/finish-install.$live->{settings}{media}" :
                'files/draklive-install.d/finish-install',
              '/etc/draklive-install.d/sysconfig/finish-install', { mode => 0644 } ],
            [ 'files/draklive-install.d/firstboot', '/etc/draklive-install.d/sysconfig/firstboot', { mode => 0644 } ],
            [ 'files/draklive-install.d/services', '/etc/draklive-install.d/services', { mode => 0644 } ],
            if_($live->{settings}{media} eq 'usb',
                [ 'files/draklive-install.d/draklive-resize', '/etc/draklive-install.d/sysconfig/draklive-resize', { mode => 0644 } ],
            ),
            #- don't make kbluetoothrc display an annoying and useless popup window, and disable it by default
            [ 'files/kbluetoothrc', '/etc/kde/kbluetoothrc', { mode => 0644 } ],
            [ 'files/korgacrc', '/etc/kde/korgacrc', { mode => 0644 } ],
            (map { [ 'files/mgaonlinerc', $_ . '/.MgaOnline/mgaonline', { mode => 0644, no_install => 1 } ] } @user_config_dirs),
            (map { [ 'files/draksnapshot.sysconfig', $_ . '/.draksnapshot', { mode => 0644, no_install => 1 } ] } @user_config_dirs),
            [ 'files/compute-ooo-dicts.pl', '/usr/sbin/compute-ooo-dicts.pl', { mode => 0755 } ],
            [ 'files/compute-i18n-list.pl', '/usr/sbin/compute-i18n-list.pl', { mode => 0755 } ],
	    # reload GDM to get correct locale
	    if_($live->{settings}{desktop} eq 'GNOME',
		if_($live->{settings}{media} eq 'DVD',
		    [ 'files/99dm-reload.xsetup', '/etc/X11/xsetup.d/', { mode => 0755 } ],
		),
    	    ),
        ],
        remove_files => [
            (map { "/etc/modprobe.preload.d/$_" } qw(cpufreq pcmcia rfswitch)),
            "/etc/udev/rules.d/70-persistent-*.rules",
            "/var/lib/dbus/machine-id",
            "/etc/ssh/ssh_host_*",
        ],
        module_options => {
            loop => "max_loop=64",
        },
        exclude_modules => [],
        additional_modules => [
            #'modules/i586/unionfs.ko',
        ],
        stage2_updates => [
            # [ "files/pkgs.pm", "/usr/lib/libDrakX/install/pkgs.pm" ],
        ],
        patches => [
	    # Temporary patches waiting to be applied to mga packages
	    # mga#17223
	    'patches/prefdm.patch',
	    # mga#19520
	    'patches/dkms.patch',
	    # mga#19517
	    'patches/do_pkgs.patch',
        ],
        erase_rpms => [
        ],
        rpms => [
        ],
        disable_services => [
            qw(bluetooth laptop-mode pcmcia mdadm pcscd),
            qw(cups hplip oki4daemon),     # printing
            qw(capi4linux ibod isdn4linux isdnlog bpalogin),
            qw(cpqarrayd upsd upsmon), # uncommon hardware
            qw(lisa ntpd snmpd), # unneeded software
            qw(dkms),           # slows down live boot, reenabled after install
            qw(anacron crond), # slows down basic usage and install, reenabled after install
            qw(sshd msec),
            qw(hcfpci hsf slmodemd),
            qw(portmap nfs-common),
            qw(kav4ws freshclam clamd),
	    if_(member($live->{settings}{media}, 'CD', 'DVD'), preload),
        ],
        vga_mode => 788,
        gfxboot => $live->{settings}{media} ne 'usb', #- disable gfxboot on USB, buggy with grub on some systems
        if_($live->{settings}{media} eq 'usb',
            initrd_pre_pivot =>
              #- keep an unmodified live tree for draklive-install
              #- hack: mount it rw with a dummy branch and remount it ro later, current unionfs fails to mount ro directly
              #- hack: the union can not be "stacked" (i.e. mounted) over another union, so do it early in initrd, and use a tmpfs for the dummy branch, so it can be moved in the real root
              join("\n", map { "sh -c '$_'" }
                   'mkdir -p /live/source /live/dummy',
                   'mount -o mode=755,rw -t tmpfs none /live/dummy',
                   'mount -o dirs=/live/dummy=rw' . if_($use_modules, ':$(cat /live/modules.lst)') . ':/live/distrib=ro -t unionfs unionfs /live/source',
               ),
        ),
        initrd_post =>
          join("\n",
               if_($live->{settings}{media} eq 'usb', do {
                   my $tmp = "/live/tmp";
                   my @sticky = qw(/var/tmp /tmp);
                   (
                       "sh -c 'mkdir -p $tmp'",
                       "mount -t tmpfs none $tmp",
                       "mkdir $tmp/var",
                       (map {
                           ("mkdir $tmp$_", "mount -o dirs=$tmp$_=rw:/live/distrib$_=ro -t unionfs unionfs $_");
                       } (qw(/var/log), @sticky)),
                       "chmod 1777 @sticky",
                   );
               }),
          ),
        postInstall => join(';',
                            if_($live->{settings}{default_user}, "echo $live->{settings}{default_user} > /etc/draklive-install.d/user"),
                            "perl -pi -e 's,<DEFAULT_USER>,$live->{settings}{default_user},' /etc/draklive-install.d/sysconfig/finish-install",
                            #- fix user perms for copied files
                            if_($live->{settings}{default_user}, "chown -R " .
                                  "$live->{settings}{default_user}.$live->{settings}{default_user}" .
                                  " /home/$live->{settings}{default_user}"
                            ),

                            # remove readahead
			    "rm -f /.readahead_collect",

                            #- adduser seems to create a sparse lastlog with a slot for all available users
                            #- which can be huge
                            '> /var/log/lastlog',
                            if_($live->{settings}{desktop} eq 'PLASMA5', 
                                "rm -f /usr/share/icons/*/icon-theme.cache",
                                "cp -a /etc/akonadi/mysql-global.conf /etc/akonadi/mysql-global-standard.conf",
                                "cp /etc/akonadi/mysql-global-mobile.conf /etc/akonadi/mysql-global.conf",
                                "ak=/etc/draklive-install.d/run.d/restore-akonadi-config.sh; echo -e '#!/bin/sh\ncp /etc/akonadi/mysql-global-standard.conf /etc/akonadi/mysql-global.conf' > \$ak; chmod +x \$ak",
                            ),
                            if_($live->{settings}{desktop} eq 'GNOME',
                                # compile schema to get dralkive-install in menu
                        	"glib-compile-schemas /usr/share/glib-2.0/schemas/",
                            ),

                            # switch to NetworkManager
                            "systemctl disable network",
                            "systemctl disable network-up",
                            "systemctl enable NetworkManager.service",
                            "systemctl enable NetworkManager-wait-online.service",

                            # add local medias
                            "urpmi.addmedia 'Live Core' /var/local/mga_rpms/core with media_info/hdlist.cz",
                            "urpmi.addmedia 'Live Nonfree' /var/local/mga_rpms/nonfree with media_info/hdlist.cz",

                            # add some online medias to avoid slowdown on initial boot
                            # will be replaced with mirrorbrain urls soon-ish
                            if_($live->{settings}{arch} eq 'i586',
                            "urpmi.addmedia --distrib http://mirrors.kernel.org/mageia/distrib/6/i586/",
                            ),
                            if_($live->{settings}{arch} eq 'x86_64',
                            "urpmi.addmedia --distrib http://mirrors.kernel.org/mageia/distrib/6/x86_64/",
                            ),

                            # remove pre-installed grub2, we need to be able to select grub2 vs grub2-efi at install time
                            "rpm -e --nodeps grub2",

			    # set the timestamp on the font directories to be a whole second
			    # fc-cache looks at the nano second portion which may be non-zero
			    # as we are on ext4, but then it will compare against the stamps
			    # on the squashfs live image which have whole second resolution
			    # (adapted from fix descrived in OpenMandriva bug 1764)
			    "find /usr/share/fonts -type d -exec touch -t \$(date +%Y%m%d%H%M.%S) '{}' ';'",
			    # now update the cache for the new timestamps
			    "fc-cache -rf",

                        ),
        additional_media => [
          if_($live->{settings}{updates_repository},
            {
                name => 'core_updates_testing',
                path => $live->{settings}{updates_repository} . '/' . $live->{settings}{arch} . '/media/core/updates_testing',
                packages => [
                ],
            },
          ),
        ],
    },
    loopbacks => {
        exclude => {
            type => 'squashfs',
            files => [
                { path => '/root/drakx' },
                #- to skip a file list generated with:
                #- find /usr/share/doc/HTML -mindepth 1 -maxdepth 1 -type d > /root/drakx/HTML.skipped
                #{ source => '/root/drakx/HTML.skipped', rooted => 1 },
            ],
        },
        if_($use_modules, modules  => [
           { type => 'squashfs', source => '/root/drakx/i18n-*.lst', rooted => 1 },
        ]),
    },
    regions => {
        #- the "all" region has a magical behavior and selects all langs
        int => [qw(en)],
    },
    packs => {
        int => [ map { "i18n-$_" } qw(en) ],
    },
    if_(member($live->{settings}{media}, 'CD', 'DVD'),
        media => {
            storage => 'cdrom',
            bootloader_timeout => 10,
            boot_entries => [ "" => " xdriver=free", "linux" => " install xdriver=free", "harddisk" => "" ],
            if_($live->{settings}{product} =~ /LiveCD|LiveDVD/i,
                source => build_one_label($live),
                pre => [ 'for i in seq 1 5; do showlabels --removable | grep ' . build_one_label($live) . '; if [ $? -eq 0 ]; then break; fi; sleep 1; done' ],
                extra_modules => [ qw(vfat sd_mod usb_storage ehci_hcd ehci_pci ehci_platform ohci_hcd ohci_pci ohci_platform uhci_hcd xhci_hcd xhci_pci xhci_plat_hcd) ],
		files => [
			 if_($live->{settings}{arch} eq 'x86_64',
			    [ 'files/UEFI/EFI', '' ],
			    if_($live->{settings}{desktop} eq 'PLASMA5',
				[ 'files/UEFI/PLASMA5/grub.cfg', 'EFI/BOOT/' ],
			    ),
			    if_($live->{settings}{desktop} eq 'GNOME',
				[ 'files/UEFI/GNOME/grub.cfg', 'EFI/BOOT/' ],
			    ),
			 ),
			    # FIXME: add doc and autorun
			    #[ 'extra/livecd/autorun/*', ''],
			    #map { [ 'extra/livecd/' . $_, $_ ] } qw(LISEZMOI.pdf README.pdf) 
			 ],
            ),

	

        },
        #extra_media => [ { storage => 'usb' } ],
        mount => MDV::Draklive::Mounts::volatile_squash_union($use_modules),
    ),
    if_($live->{settings}{media} eq 'usb',
        media => {
            storage => 'usb',
            bootloader_timeout => 1,
            mount_options => 'dmask=0000,fmask=0111',
            extra_boot => [ qw(cdrom) ],
            if_($live->{settings}{product} =~ /liveusb-rw/i,
                source => "LABEL=Mga_USB",
                title => "Mageia Live USB",
                boot_entries => [ "" => "" ],
                files => [
                    [ 'extra/liveusb-rw-common/*', '' ],
                    ($live->{settings}{commercial} ?
                       [ 'extra/liveusb-rw-commercial/*', '' ] :
                       [ 'extra/liveusb-rw/*', '' ]
                    ),
                ],
		partitions => [
		    {
			size => common::MB(8000),
			mntpoint => '/',
		    },
		],
                remove_files => [ '.svn', '*~' ],
            ),
        },
        mount => MDV::Draklive::Mounts::squash_union('1000M', '150M', $use_modules),
    ),
};