summaryrefslogtreecommitdiffstats
path: root/perl-install/c/stuff.xs.pl
blob: fb9f86074f0ee81a2bf6242cf9016d714fe03cde (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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
use Config;

print '
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

/* workaround for glibc and kernel header files not in sync */
#define dev_t dev_t

#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <resolv.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/mount.h>
#include <linux/keyboard.h>
#include <linux/kd.h>
#include <linux/hdreg.h>
#include <linux/vt.h>
#include <linux/fd.h>
#include <linux/cdrom.h>
#include <linux/loop.h>
#include <linux/blkpg.h>
#include <net/if.h>
#include <net/route.h>

/* for is_ext3 */
#include <ext2fs/ext2_fs.h>
#include <ext2fs/ext2fs.h>

#include <libldetect.h>
#include <X11/Xlib.h>
#include <X11/extensions/xf86misc.h>

#include <langinfo.h>
#include <string.h>
#include <iconv.h>

#include <libintl.h>
#include <term.h>
#undef max_colors

#define SECTORSIZE 512

char *prom_getopt();
void prom_setopt();
char *prom_getproperty();
char *disk2PromPath();
char *promRootName();

';

$ENV{C_DRAKX} && $Config{archname} =~ /i.86/ and print '
char *pcmcia_probe(void);
';

$ENV{C_RPM} and print '
#undef Fflush
#undef Mkdir
#undef Stat
#include <rpm/rpmlib.h>
#include <rpm/rpmio.h>

void rpmError_callback_empty(void) {}

int rpmError_callback_data;
void rpmError_callback(void) {
  if (rpmErrorCode() != RPMERR_UNLINK && rpmErrorCode() != RPMERR_RMDIR) {
    write(rpmError_callback_data, rpmErrorString(), strlen(rpmErrorString()));
  }
}

';

$ENV{C_DRAKX} and print '

void initIMPS2() {
  unsigned char imps2_s1[] = { 243, 200, 243, 100, 243, 80, };
  unsigned char imps2_s2[] = { 246, 230, 244, 243, 100, 232, 3, };

  int fd = open("/dev/mouse", O_WRONLY);
  if (fd < 0) return;

  write (fd, imps2_s1, sizeof (imps2_s1));
  usleep (30000);
  write (fd, imps2_s2, sizeof (imps2_s2));
  usleep (30000);
  tcflush (fd, TCIFLUSH);
  tcdrain(fd);
}

void log_message(const char * s, ...) {}

';

print '

SV * iconv_(char* s, char* from_charset, char* to_charset) {
  iconv_t cd = iconv_open(to_charset, from_charset);
  char* retval = s;
  if (cd != (iconv_t) (-1)) {
      size_t s_len = strlen(retval);
      /* the maximum expansion when converting happens when converting
	 tscii to utf-8; each tscii char can become up to 4 unicode chars
	 and each one of those unicode chars can be 3 bytes long */
      char *buf = alloca(4 * 3 * s_len);
      {
	  char *ptr = buf;
	  size_t ptr_len = 4 * 3 * s_len;
	  if ((iconv(cd, &s, &s_len, &ptr, &ptr_len)) != (size_t) (-1)) {
	      *ptr = 0;
	      retval = buf;
	  }
      }
      iconv_close(cd);
  }
  return newSVpv(retval, 0);
}

MODULE = c::stuff		PACKAGE = c::stuff

';

$ENV{C_DRAKX} && $Config{archname} =~ /i.86/ and print '
char *
pcmcia_probe()
';

$ENV{C_DRAKX} and print '

int
Xtest(display)
  char *display
  CODE:
  int pid;
  if ((pid = fork()) == 0) {
    Display *d = XOpenDisplay(display);
    if (d) {
      XSetCloseDownMode(d, RetainPermanent);
      XCloseDisplay(d);
    }
    _exit(d != NULL);
  }
  waitpid(pid, &RETVAL, 0);
  OUTPUT:
  RETVAL

void
setMouseLive(display, type, emulate3buttons)
  char *display
  int type
  int emulate3buttons
  CODE:
  {
    XF86MiscMouseSettings mseinfo;
    Display *d = XOpenDisplay(display);
    if (d) {
      if (XF86MiscGetMouseSettings(d, &mseinfo) == True) {
        mseinfo.type = type;
        mseinfo.flags |= MF_REOPEN;
        mseinfo.emulate3buttons = emulate3buttons;
        XF86MiscSetMouseSettings(d, &mseinfo);
        XFlush(d);
        if (type == MTYPE_IMPS2) initIMPS2();
      }
    }
  }
';

print '
char *
dgettext(domainname, msgid)
   char * domainname
   char * msgid

int
add_partition(hd, start_sector, size_sector, part_number)
  int hd
  unsigned long start_sector
  unsigned long size_sector
  int part_number
  CODE:
  {
    long long start = start_sector * 512;
    long long size = size_sector * 512;
    struct blkpg_partition p = { start, size, part_number, "", "" };
    struct blkpg_ioctl_arg s = { BLKPG_ADD_PARTITION, 0, sizeof(struct blkpg_partition), (void *) &p };
    RETVAL = ioctl(hd, BLKPG, &s) == 0;
  }
  OUTPUT:
  RETVAL

int
is_secure_file(filename)
  char * filename
  CODE:
  {
    int fd;
    unlink(filename); /* in case it exists and we manage to remove it */
    RETVAL = (fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) != -1;
    if (RETVAL) close(fd);
  }
  OUTPUT:
  RETVAL

int
is_ext3(device_name)
  char * device_name
  CODE:
  {
    ext2_filsys fs;
    int retval = ext2fs_open (device_name, 0, 0, 0, unix_io_manager, &fs);
    if (retval) {
      RETVAL = 0;
    } else {
      RETVAL = fs->super->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL;
      ext2fs_close(fs);  
    }
  }
  OUTPUT:
  RETVAL

void
setlocale()
   CODE:
   setlocale(LC_ALL, "");
   setlocale(LC_NUMERIC, "C"); /* otherwise eval "1.5" returns 1 in fr_FR for example */

char *
bindtextdomain(domainname, dirname)
   char * domainname
   char * dirname

char *
bind_textdomain_codeset(domainname, codeset)
   char * domainname
   char * codeset

int
KTYP(x)
  int x
  CODE:
  RETVAL = KTYP(x);
  OUTPUT:
  RETVAL

int
lseek_sector(fd, sector, offset)
  int fd
  long sector
  long offset
  CODE:
  RETVAL = lseek64(fd, (off64_t) sector * SECTORSIZE + offset, SEEK_SET) >= 0;
  OUTPUT:
  RETVAL

int
isBurner(fd)
  int fd
  CODE:
  RETVAL = ioctl(fd, CDROM_GET_CAPABILITY) & CDC_CD_RW;
  OUTPUT:
  RETVAL

int
isDvdDrive(fd)
  int fd
  CODE:
  RETVAL = ioctl(fd, CDROM_GET_CAPABILITY) & CDC_DVD;
  OUTPUT:
  RETVAL

char *
floppy_info(name)
  char * name
  CODE:
  int fd = open(name, O_RDONLY | O_NONBLOCK);
  RETVAL = NULL;
  if (fd != -1) {
     char drivtyp[17];
     if (ioctl(fd, FDGETDRVTYP, (void *)drivtyp) == 0) {
       struct floppy_drive_struct ds;
       if (ioctl(fd, FDPOLLDRVSTAT, &ds) == 0 && ds.track >= 0)
         RETVAL = drivtyp;
     }
     close(fd);
  }
  OUTPUT:
  RETVAL

unsigned int
total_sectors(fd)
  int fd
  CODE:
  {
    long s;
    RETVAL = ioctl(fd, BLKGETSIZE, &s) == 0 ? s : 0;
  }
  OUTPUT:
  RETVAL

void
unlimit_core()
  CODE:
  {
    struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY };
    setrlimit(RLIMIT_CORE, &rlim);
  }

int
getlimit_core()
  CODE:
  {
    struct rlimit rlim;
    getrlimit(RLIMIT_CORE, &rlim);
    RETVAL = rlim.rlim_cur;
  }
  OUTPUT:
  RETVAL

void
openlog(ident)
  char *ident
  CODE:
  openlog(ident, 0, 0);

void
closelog()

void
syslog(priority, mesg)
  int priority
  char *mesg
  CODE:
  syslog(priority, mesg);

void
setsid()

void
_exit(status)
  int status
  
int
detectSMP()

void
pci_probe()
  PPCODE:
    struct pciusb_entries entries = pci_probe();
    char buf[2048];
    int i;

    EXTEND(SP, entries.nb);
    for (i = 0; i < entries.nb; i++) {
      struct pciusb_entry *e = &entries.entries[i];
      snprintf(buf, sizeof(buf), "%04x\t%04x\t%04x\t%04x\t%d\t%d\t%d\t%s\t%s\t%s", 
               e->vendor, e->device, e->subvendor, e->subdevice, e->pci_bus, e->pci_device, e->pci_function,
               pci_class2text(e->class_), e->module ? e->module : "unknown", e->text);
      PUSHs(sv_2mortal(newSVpv(buf, 0)));
    }
    pciusb_free(&entries);

void
usb_probe()
  PPCODE:
    struct pciusb_entries entries = usb_probe();
    char buf[2048];
    int i;

    EXTEND(SP, entries.nb);
    for (i = 0; i < entries.nb; i++) {
      struct pciusb_entry *e = &entries.entries[i];
      snprintf(buf, sizeof(buf), "%04x\t%04x\t%s\t%s\t%s\t%d\t%d", 
               e->vendor, e->device, usb_class2text(e->class_), e->module ? e->module : "unknown", e->text, e->pci_bus, e->pci_device);
      PUSHs(sv_2mortal(newSVpv(buf, 0)));
    }
    pciusb_free(&entries);

unsigned int
getpagesize()

int
hasNetDevice(device)
  char * device
  CODE:
    struct ifreq req;
    int s = socket(AF_INET, SOCK_DGRAM, 0);
    if (s == -1) { RETVAL = 0; return; }

    strcpy(req.ifr_name, device);

    RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0;
    close(s);
  OUTPUT:
  RETVAL

int
addDefaultRoute(gateway)
  char *gateway
  CODE:
    struct rtentry route;
    struct sockaddr_in addr;
    int s = socket(AF_INET, SOCK_DGRAM, 0);
    if (s == -1) { RETVAL = 0; return; }

    memset(&route, 0, sizeof(route));

    addr.sin_family = AF_INET;
    addr.sin_port = 0;
    inet_aton(gateway, &addr.sin_addr);
    memcpy(&route.rt_gateway, &addr, sizeof(addr));

    addr.sin_addr.s_addr = INADDR_ANY;
    memcpy(&route.rt_dst, &addr, sizeof(addr));
    memcpy(&route.rt_genmask, &addr, sizeof(addr));

    route.rt_flags = RTF_UP | RTF_GATEWAY;
    route.rt_metric = 0;

    RETVAL = !ioctl(s, SIOCADDRT, &route);
  OUTPUT:
  RETVAL

char *
kernel_version()
  CODE:
  struct utsname u;
  if (uname(&u) == 0) RETVAL = u.release; else RETVAL = NULL;
  OUTPUT:
  RETVAL

int
prom_open()

void
prom_close()

int
prom_getsibling(node)
  int node

int
prom_getchild(node)
  int node

void
prom_getopt(key)
  char *key
  PPCODE:
  int lenp = 0;
  char *value = NULL;
  value = prom_getopt(key, &lenp);
  EXTEND(sp, 1);
  if (value != NULL) {
    PUSHs(sv_2mortal(newSVpv(value, 0)));
  } else {
    PUSHs(&PL_sv_undef);
  }

void
prom_setopt(key, value)
  char *key
  char *value

void
prom_getproperty(key)
  char *key
  PPCODE:
  int lenp = 0;
  char *value = NULL;
  value = prom_getproperty(key, &lenp);
  EXTEND(sp, 1);
  if (value != NULL) {
    PUSHs(sv_2mortal(newSVpv(value, lenp)));
  } else {
    PUSHs(&PL_sv_undef);
  }

void
prom_getstring(key)
  char *key
  PPCODE:
  int lenp = 0;
  char *value = NULL;
  value = prom_getproperty(key, &lenp);
  EXTEND(sp, 1);
  if (value != NULL) {
    PUSHs(sv_2mortal(newSVpv(value, 0)));
  } else {
    PUSHs(&PL_sv_undef);
  }

int
prom_getbool(key)
  char *key

void
initSilo()

char *
disk2PromPath(disk)
  unsigned char *disk

int
hasAliases()

char *
promRootName()

void
setPromVars(linuxAlias, bootDevice)
  char *linuxAlias
  char *bootDevice

SV *
iconv(s, from_charset, to_charset)
  char *s
  char *from_charset
  char *to_charset
  CODE:
  RETVAL = iconv_(s, from_charset, to_charset);
  OUTPUT:
  RETVAL

int
is_tagged_utf8(s)
   SV *s
   CODE:
   RETVAL = SvUTF8(s);
   OUTPUT:
   RETVAL

void
set_tagged_utf8(s)
   SV *s
   CODE:
   SvUTF8_on(s);

void
upgrade_utf8(s)
   SV *s
   CODE:
   sv_utf8_upgrade(s);

void
unset_tagged_utf8(s)
   SV *s
   CODE:
   SvUTF8_off(s);

char *
standard_charset()
  CODE:
  RETVAL = nl_langinfo(CODESET);
  OUTPUT:
  RETVAL

';

$ENV{C_RPM} and print '
char *
rpmErrorString()

void
rpmSetVeryVerbose()
  CODE:
  rpmSetVerbosity(RPMMESS_DEBUG);

void
rpmErrorSetCallback(fd)
  int fd
  CODE:
  rpmError_callback_data = fd;
  rpmErrorSetCallback(rpmError_callback);

int
rpmvercmp(char *a, char *b);
';

@macros = (
  [ qw(int S_IFCHR S_IFBLK S_IFIFO KDSKBENT KT_SPEC NR_KEYS MAX_NR_KEYMAPS BLKRRPART TIOCSCTTY
       HDIO_GETGEO BLKGETSIZE LOOP_GET_STATUS
       MS_MGC_VAL MS_RDONLY O_NONBLOCK F_SETFL F_GETFL O_CREAT SECTORSIZE WNOHANG
       VT_ACTIVATE VT_WAITACTIVE VT_GETSTATE CDROM_LOCKDOOR CDROMEJECT CDROM_DRIVE_STATUS CDS_DISC_OK
       LOG_WARNING LOG_INFO LOG_LOCAL1
       ) ],
);

$\= "\n";
print;

foreach (@macros) {
    my ($type, @l) = @$_;
    foreach (@l) {
	print<< "END"
$type
$_()
  CODE:
  RETVAL = $_;

  OUTPUT:
  RETVAL

END

    }
}
lass="hl opt">->{label} =~ /^old([^_]*)_/ } foreach @$entries; foreach (0..scalar keys %usedold) { exists $usedold{$_} or $freeold = $_ || '', last } foreach (@$entries) { if ($_->{label} eq $v->{label}) { compare_entries($_, $v) or return; #- avoid inserting it twice as another entry already exists ! $_->{label} = "old${freeold}_$_->{label}"; } } push @$entries, $v; } sub add_kernel($$$$$) { my ($prefix, $lilo, $kernelVersion, $specific, $v) = @_; my $ext = $specific && "-$specific"; $specific =~ s/\d+\.\d+|hack//; my ($vmlinuz, $image, $initrdImage) = ("vmlinuz-$kernelVersion$specific", "/boot/vmlinuz$ext", "/boot/initrd$ext.img"); -e "$prefix/boot/$vmlinuz" or log::l("unable to find kernel image $prefix/boot/$vmlinuz"), return; { my $f = "initrd-$kernelVersion$specific.img"; eval { mkinitrd($prefix, "$kernelVersion$specific", "/boot/$f") }; undef $initrdImage if $@; symlinkf $f, "$prefix$initrdImage" or $initrdImage = "/boot/$f" if $initrdImage; } symlinkf "$vmlinuz", "$prefix/$image" or $image = "/boot/$vmlinuz"; add2hash($v, { type => 'image', label => 'linux', kernel_or_dev => $image, initrd => $initrdImage, append => $lilo->{perImageAppend}, }); add_entry($lilo->{entries}, $v); $v; } sub get_append { my ($b, $key) = @_; ($b->{perImageAppend} =~ /\b$key=(\S*)/)[0]; } sub add_append { my ($b, $key, $val) = @_; foreach ({ append => $b->{perImageAppend} }, @{$b->{entries}}) { $_->{append} =~ s/\b$key=\S*\s*//; $_->{append} =~ s/\s*$/ $key=$val)/ if $val; } } sub configure_entry($$) { my ($prefix, $entry) = @_; if ($entry->{type} eq 'image') { my $specific_version; $entry->{kernel_or_dev} =~ /vmlinu.-(.*)/ and $specific_version = $1; readlink("$prefix/$entry->{kernel_or_dev}") =~ /vmlinu.-(.*)/ and $specific_version = $1; if ($specific_version) { $entry->{initrd} or $entry->{initrd} = "/boot/initrd-$specific_version.img"; unless (-e "$prefix/$entry->{initrd}") { eval { mkinitrd($prefix, $specific_version, "$entry->{initrd}") }; undef $entry->{initrd} if $@; } } } $entry; } sub dev2prompath { #- SPARC only my ($dev) = @_; my ($wd, $num) = $dev =~ /^(.*\D)(\d*)$/; require c; $dev = c::disk2PromPath($wd) and $dev = $dev =~ /^sd\(/ ? "$dev$num" : "$dev;$num"; $dev; } sub suggest { my ($prefix, $lilo, $hds, $fstab, $kernelVersion, $vga_fb) = @_; my $root_part = fsedit::get_root($fstab); my $root = isLoopback($root_part) ? "loop7" : $root_part->{device}; my $boot = fsedit::get_root($fstab, 'boot')->{device}; my $partition = first($boot =~ /\D*(\d*)/); require c; c::initSilo() if arch() =~ /sparc/; my ($onmbr, $unsafe) = $lilo->{crushMbr} ? (1, 0) : suggest_onmbr($hds); add2hash_($lilo, arch() =~ /sparc/ ? { default => "linux", entries => [], timeout => 5, use_partition => 0, #- we should almost always have a whole disk partition. root => "/dev/$root", partition => $partition || 1, boot => $root eq $boot && "/boot", #- this helps for getting default partition for silo. } : arch =~ /ppc/ ? { defaultos => "linux", default => "linux", entries => [], initmsg => "Welcome to Mandrake Linux!", delay => 30, #- OpenFirmware delay timeout => 50, enableofboot => 1, enablecdboot => 1, useboot => $boot, } : { bootUnsafe => $unsafe, default => "linux", lba32 => 1, entries => [], timeout => $onmbr && 5, if_(arch() !~ /ia64/, boot => "/dev/" . ($onmbr ? $hds->[0]{device} : fsedit::get_root($fstab, 'boot')->{device}), map => "/boot/map", install => "/boot/boot.b", ), }); if (!$lilo->{message} || $lilo->{message} eq "1") { $lilo->{message} = join('', cat_("$prefix/boot/message")); if (!$lilo->{message}) { my $msg_en = #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) __("Welcome to %s the operating system chooser! Choose an operating system in the list above or wait %d seconds for default boot. "); my $msg = translate($msg_en); #- use the english version if more than 20% of 8bits chars $msg = $msg_en if int(grep { $_ & 0x80 } unpack "c*", $msg) / length($msg) > 0.2; $lilo->{message} = sprintf $msg, arch() =~ /sparc/ ? "SILO" : "LILO", $lilo->{timeout}; } } add2hash_($lilo, { getVarsFromSh("$prefix/etc/sysconfig/system") }); #- for CLEAN_TMP add2hash_($lilo, { memsize => $1 }) if cat_("/proc/cmdline") =~ /mem=(\S+)/; #- give more priority to secure kernel because if the user want security, he will got it... my $isSecure = -e "$prefix/boot/vmlinuz-${kernelVersion}secure"; my $isEnterprise = -e "$prefix/boot/vmlinuz-${kernelVersion}enterprise"; my $isSMP = detect_devices::hasSMP(); if ($isSMP && !-e "$prefix/boot/vmlinuz-${kernelVersion}smp") { log::l("SMP machine, but no SMP kernel found") unless $isSecure; $isSMP = 0; } my $entry = add_kernel($prefix, $lilo, $kernelVersion, $isSecure ? 'secure' : $isEnterprise ? 'enterprise' : $isSMP ? 'smp' : '', { label => 'linux', root => "/dev/$root", if_($vga_fb, vga => $vga_fb), #- using framebuffer }); add_kernel($prefix, $lilo, $kernelVersion, '', { label => $isSecure || $isEnterprise || $isSMP ? 'linux-up' : 'linux-nonfb', root => "/dev/$root", }) if $isSecure || $isEnterprise || $isSMP || $vga_fb; my $failsafe = add_kernel($prefix, $lilo, $kernelVersion, '', { label => 'failsafe', root => "/dev/$root", }); $entry->{append} .= " quiet" if $vga_fb; $failsafe->{append} .= " failsafe" if $failsafe && !$lilo->{password}; #- manage older kernel if installed. foreach (qw(2.2 hack)) { my $hasOld = -e "$prefix/boot/vmlinuz-$_"; if ($hasOld) { my $oldVersion = first(readlink("$prefix/boot/vmlinuz-$_") =~ /vmlinuz-(.*mdk)/); my $oldSecure = -e "$prefix/boot/vmlinuz-${_}secure"; my $oldSMP = $isSMP && -e "$prefix/boot/vmlinuz-${_}smp"; add_kernel($prefix, $lilo, $oldVersion, $oldSecure ? "${_}secure" : $oldSMP ? "${_}smp" : $_, { label => "linux-$_", root => "/dev/$root", $vga_fb ? ( vga => $vga_fb) : (), #- using framebuffer }); add_kernel($prefix, $lilo, $oldVersion, $_, { label => $oldSecure || $oldSMP ? "linux-${_}up" : "linux-${_}nonfb", root => "/dev/$root", }) if $oldSecure || $oldSMP || $vga_fb; my $entry = add_kernel($prefix, $lilo, $oldVersion, $_, { label => "failsafe-$_", root => "/dev/$root", }); $entry->{append} .= " failsafe" if $entry && !$lilo->{password}; } } if (arch() =~ /sparc/) { #- search for SunOS, it could be a really better approach to take into account #- partition type for mounting point. my $sunos = 0; foreach (@$hds) { foreach (@{$_->{primary}{normal}}) { my $path = $_->{device} =~ m|^/| && $_->{device} !~ m|^/dev/| ? $_->{device} : dev2prompath($_->{device}); add_entry($lilo->{entries}, { type => 'other', kernel_or_dev => $path, label => "sunos" . ($sunos++ ? $sunos : ''), }) if $path && isSunOS($_) && type2name($_->{type}) =~ /root/i; } } } elsif (arch() =~ /ppc/) { #- if we identified a MacOS partition earlier - add it if (defined $partition_table_mac'macos_part) { add_entry($lilo->{entries}, { label => "macos", kernel_or_dev => $partition_table_mac'macos_part }); } } else { #- search for dos (or windows) boot partition. Don't look in extended partitions! my %nbs; foreach (@$hds) { foreach (@{$_->{primary}{normal}}) { my $label = isNT($_) ? 'NT' : isDos($_) ? 'dos' : 'windows'; add_entry($lilo->{entries}, { type => 'other', kernel_or_dev => "/dev/$_->{device}", label => $label . ($nbs{$label}++ ? $nbs{$label} : ''), table => "/dev/$_->{rootDevice}", unsafe => 1 }) if isNT($_) || isFat($_) && isFat({ type => fsedit::typeOfPart($_->{device}) }); } } } my %l = ( yaboot => bool(arch() =~ /ppc/), silo => bool(arch() =~ /sparc/), lilo => bool(arch() !~ /sparc|ppc/) && !isLoopback(fsedit::get_root($fstab)), grub => bool(arch() !~ /sparc|ppc/ && availableRamMB() < 800), #- don't use grub if more than 800MB loadlin => bool(arch() !~ /sparc|ppc/) && -e "/initrd/loopfs/lnx4win", ); unless ($lilo->{methods}) { $lilo->{methods} ||= { map { $_ => 1 } grep { $l{$_} } keys %l }; if ($lilo->{methods}{lilo} && -e "$prefix/boot/lilo-graphic") { $lilo->{methods}{lilo} = "lilo-graphic"; exists $lilo->{methods}{grub} and $lilo->{methods}{grub} = undef; } } } sub suggest_floppy { my ($bootloader) = @_; my $floppy = detect_devices::floppy() or return; $floppy eq 'fd0' or log::l("suggest_floppy: not adding $floppy"), return; add_entry($bootloader->{entries}, { type => 'other', kernel_or_dev => '/dev/fd0', label => 'floppy', unsafe => 1 }); } sub keytable($$) { my ($prefix, $f) = @_; local $_ = $f; if ($_ && !/\.klt$/) { $f = "/boot/$_.klt"; run_program::rooted($prefix, "keytab-lilo.pl", ">", $f, $_) or undef $f; } $f && -r "$prefix/$f" && $f; } sub has_profiles { bool(get_label("office", $b)) } sub set_profiles { my ($b, $want_profiles) = @_; my $office = get_label("office", $b); if ($want_profiles xor $office) { my $e = get_label("linux", $b); if ($want_profiles) { push @{$b->{entries}}, { %$e, label => "office", append => "$e->{append} prof=Office" }; $e->{append} .= " prof=Home"; } else { # remove profiles $e->{append} =~ s/\s*prof=\w+//; @{$b->{entries}} = grep { $_ != $office } @{$b->{entries}}; } } } sub get_of_dev($$) { my ($prefix, $unix_dev) = @_; #- don't care much for this - need to run ofpath rooted, and I need the result #- In test mode, just run on "/", otherwise you can't get to the /proc files if ($::testing) { $prefix = ""; } run_program::rooted_or_die($prefix, "/usr/local/sbin/ofpath $unix_dev", ">", "/tmp/ofpath"); open(FILE, "$prefix/tmp/ofpath") || die "Can't open $prefix/tmp/ofpath"; my $of_dev = ""; local $_ = ""; while (<FILE>){ $of_dev = $_; } chop($of_dev); my @del_file = ($prefix . "/tmp/ofpath"); unlink (@del_file); log::l("OF Device: $of_dev"); $of_dev; } sub install_yaboot($$$) { my ($prefix, $lilo, $fstab, $hds) = @_; $lilo->{prompt} = $lilo->{timeout}; if ($lilo->{message}) { local *F; open F, ">$prefix/boot/message" and print F $lilo->{message} or $lilo->{message} = 0; } { local *F; local $\ = "\n"; my $f = "$prefix/etc/yaboot.conf"; open F, ">$f" or die "cannot create yaboot config file: $f"; log::l("writing yaboot config to $f"); print F "#yaboot.conf - generated by DrakX"; print F "init-message=\"\\n$lilo->{initmsg}\\n\"" if $lilo->{initmsg}; if ($lilo->{boot}) { print F "boot=$lilo->{boot}"; my $of_dev = get_of_dev($prefix, $lilo->{boot}); print F "ofboot=$of_dev"; } else { die "no bootstrap partition defined." } $lilo->{$_} and print F "$_=$lilo->{$_}" foreach qw(delay timeout); print F "install=/usr/local/lib/yaboot/yaboot"; print F "magicboot=/usr/local/lib/yaboot/ofboot"; $lilo->{$_} and print F $_ foreach qw(enablecdboot enableofboot); $lilo->{$_} and print F "$_=$lilo->{$_}" foreach qw(defaultos default); print F "nonvram"; my $boot = "/dev/" . $lilo->{useboot} if $lilo->{useboot}; foreach (@{$lilo->{entries}}) { if ($_->{type} eq "image") { my $of_dev = ''; if ($boot !~ /$_->{root}/) { $of_dev = get_of_dev($prefix, $boot); print F "$_->{type}=$of_dev," . substr($_->{kernel_or_dev}, 5); } else { $of_dev = get_of_dev($prefix, $_->{root}); print F "$_->{type}=$of_dev,$_->{kernel_or_dev}"; } print F "\tlabel=", substr($_->{label}, 0, 15); #- lilo doesn't handle more than 15 char long labels print F "\troot=$_->{root}"; if ($boot !~ /$_->{root}/) { print F "\tinitrd=$of_dev," . substr($_->{initrd}, 5) if $_->{initrd}; } else { print F "\tinitrd=$of_dev,$_->{initrd}" if $_->{initrd}; } print F "\tappend=\"$_->{append}\"" if $_->{append}; print F "\tread-write" if $_->{'read-write'}; print F "\tread-only" if !$_->{'read-write'}; } else { my $of_dev = get_of_dev($prefix, $_->{kernel_or_dev}); print F "$_->{label}=$of_dev"; } } } log::l("Installing boot loader..."); my $f = "$prefix/tmp/of_boot_dev"; my $of_dev = get_of_dev($prefix, $lilo->{boot}); output($f, "$of_dev\n"); $::testing and return; if (defined $install_steps_interactive::new_bootstrap) { run_program::run("hformat", "$lilo->{boot}") or die "hformat failed"; } run_program::rooted($prefix, "/sbin/ybin", "2>", "/tmp/.error") or die "ybin failed"; unlink "$prefix/tmp/.error"; } sub install_silo($$$) { my ($prefix, $silo, $fstab) = @_; my $boot = fsedit::get_root($fstab, 'boot')->{device}; my ($wd, $num) = $boot =~ /^(.*\D)(\d*)$/; #- setup boot promvars for. require c; if ($boot =~ /^md/) { #- get all mbr devices according to /boot are listed, #- then join all zero based partition translated to prom with ';'. #- keep bootdev with the first of above. log::l("/boot is present on raid partition which is not currently supported for promvars"); } else { if (!$silo->{use_partition}) { foreach (@$fstab) { if (!$_->{start} && $_->{device} =~ /$wd/) { $boot = $_->{device}; log::l("found a zero based partition in $wd as $boot"); last; } } } $silo->{bootalias} = c::disk2PromPath($boot); $silo->{bootdev} = $silo->{bootalias}; log::l("preparing promvars for device=$boot"); } c::hasAliases() or log::l("clearing promvars alias as non supported"), $silo->{bootalias} = ''; if ($silo->{message}) { local *F; open F, ">$prefix/boot/message" and print F $silo->{message} or $silo->{message} = 0; } { local *F; local $\ = "\n"; my $f = "$prefix/boot/silo.conf"; #- always write the silo.conf file in /boot ... symlinkf "../boot/silo.conf", "$prefix/etc/silo.conf"; #- ... and make a symlink from /etc. open F, ">$f" or die "cannot create silo config file: $f"; log::l("writing silo config to $f"); $silo->{$_} and print F "$_=$silo->{$_}" foreach qw(partition root default append); $silo->{$_} and print F $_ foreach qw(restricted); #- print F "password=", $silo->{password} if $silo->{restricted} && $silo->{password}; #- done by msec print F "timeout=", round(10 * $silo->{timeout}) if $silo->{timeout}; print F "message=$silo->{boot}/message" if $silo->{message}; foreach (@{$silo->{entries}}) {#my ($v, $e) = each %{$silo->{entries}}) { my $type = "$_->{type}=$_->{kernel_or_dev}"; $type =~ s|/boot|$silo->{boot}|; print F $type; print F "\tlabel=$_->{label}"; if ($_->{type} eq "image") { my $initrd = $_->{initrd}; $initrd =~ s|/boot|$silo->{boot}|; print F "\tpartition=$_->{partition}" if $_->{partition}; print F "\troot=$_->{root}" if $_->{root}; print F "\tinitrd=$initrd" if $_->{initrd}; print F "\tappend=\"$1\"" if $_->{append} =~ /^\s*"?(.*?)"?\s*$/; print F "\tread-write" if $_->{'read-write'}; print F "\tread-only" if !$_->{'read-write'}; } } } log::l("Installing boot loader..."); $::testing and return; run_program::rooted($prefix, "silo", "2>", "/tmp/.error", $silo->{use_partition} ? ("-t") : ()) or run_program::rooted($prefix, "silo", "2>", "/tmp/.error", "-p", "2", $silo->{use_partition} ? ("-t") : ()) or die "silo failed"; unlink "$prefix/tmp/.error"; #- try writing in the prom. log::l("setting promvars alias=$silo->{bootalias} bootdev=$silo->{bootdev}"); require c; c::setPromVars($silo->{bootalias}, $silo->{bootdev}); } sub install_lilo ($$) { my ($prefix, $lilo, $fstab, $hds) = @_; $lilo->{prompt} = $lilo->{timeout}; my $file2fullname = sub { my ($file) = @_; if (arch() =~ /ia64/) { (my $part, $file) = fsedit::file2part($prefix, $fstab, $file); my %hds = map_index { $_ => "hd$::i" } sort map { $_->{device} } @$hds; $hds->{$part->{device}} . ":" . $file; } else { $file } }; #- try to use a specific stage2 if defined and present. -e "$prefix/boot/$lilo->{methods}{lilo}" and symlinkf $lilo->{methods}{lilo}, "$prefix/boot/lilo"; log::l("stage2 of lilo used is " . readlink "$prefix/boot/lilo"); if ($lilo->{methods}{lilo} eq "lilo-graphic") { -e "$prefix/boot/$lilo->{methods}{lilo}/message" and symlinkf "$lilo->{methods}{lilo}/message", "$prefix/boot/message"; } else { -e "$prefix/boot/message" and unlink "$prefix/boot/message"; print "-->$prefix/boot/messag<--\n"; my $msg_en = #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) __("Welcome to %s the operating system chooser! Choose an operating system in the list above or wait %d seconds for default boot. "); my $msg = translate($msg_en); #- use the english version if more than 20% of 8bits chars $msg = $msg_en if int(grep { $_ & 0x80 } unpack "c*", $msg) / length($msg) > 0.2; $msg = sprintf $msg, arch() =~ /sparc/ ? "SILO" : "LILO", $lilo->{timeout}; local *F; open F, ">$prefix/boot/message" and print F $msg; } { local *F; local $\ = "\n"; my $f = arch() =~ /ia64/ ? "$prefix/boot/efi/elilo.conf" : "$prefix/etc/lilo.conf"; open F, ">$f" or die "cannot create lilo config file: $f"; log::l("writing lilo config to $f"); $lilo->{$_} and print F "$_=$lilo->{$_}" foreach qw(boot map install vga default append keytable); $lilo->{$_} and print F $_ foreach qw(linear lba32 compact prompt restricted); #- print F "password=", $lilo->{password} if $lilo->{restricted} && $lilo->{password}; #- done by msec print F "timeout=", round(10 * $lilo->{timeout}) if $lilo->{timeout}; my $dev = $hds->[0]{device}; my %dev2bios = map_index { $_ => $::i } dev2bios($hds, $lilo->{boot}); if ($dev2bios{$dev}) { my %bios2dev = reverse %dev2bios; print F "disk=/dev/$bios2dev{0} bios=0x80"; printf F "disk=/dev/$dev bios=0x%x", 0x80 + $dev2bios{$dev}; } elsif ($dev =~ /hd[bde]/) { print F "disk=/dev/$dev bios=0x80"; } print F "message=/boot/message"; print F "menu-scheme=wb:bw:wb:bw"; foreach (@{$lilo->{entries}}) { print F "$_->{type}=$_->{kernel_or_dev}"; my $label = substr($_->{label}, 0, 15); #- lilo doesn't handle more than 15 char long labels $label =~ s/\s/_/g; #- lilo doesn't like spaces print F "\tlabel=$label"; if ($_->{type} eq "image") { print F "\troot=", $file2fullname->($_->{root}); print F "\tinitrd=", $file2fullname->($_->{initrd}) if $_->{initrd}; print F "\tappend=\"$_->{append}\"" if $_->{append}; print F "\tvga=$_->{vga}" if $_->{vga}; print F "\tread-write" if $_->{'read-write'}; print F "\tread-only" if !$_->{'read-write'}; } else { print F "\ttable=$_->{table}" if $_->{table}; print F "\tunsafe" if $_->{unsafe} && !$_->{table}; if (my ($dev) = $_->{table} =~ m|/dev/(.*)|) { if ($dev2bios{$dev}) { #- boot off the nth drive, so reverse the BIOS maps my $nb = sprintf("0x%x", 0x80 + $dev2bios{$dev}); $_->{mapdrive} ||= { '0x80' => $nb, $nb => '0x80' }; } } while (my ($from, $to) = each %{$_->{mapdrive} || {}}) { print F "\tmap-drive=$from"; print F "\t to=$to"; } } } } log::l("Installing boot loader..."); $::testing and return; run_program::rooted_or_die($prefix, "lilo", "2>", "/tmp/.error"); unlink "$prefix/tmp/.error"; } sub dev2bios { my ($hds, $where) = @_; my @dev = map { $_->{device} } @$hds; member($where, @dev) or ($where) = @dev; #- if not on mbr, s/h(d[e-g])/x$1/ foreach $where, @dev; #- emulates ultra66 as xd_ my $start = substr($where, 0, 2); my $translate = sub { $_ eq $where ? "aaa" : #- if exact match, value it first /^$start(.*)/ ? "ad$1" : #- if same class (ide/scsi/ultra66), value it before other classes $_; }; @dev = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, &$translate ] } @dev; s/x(d.)/h$1/ foreach @dev; #- switch back; @dev; } sub dev2grub { my ($dev, $dev2bios) = @_; $dev =~ m|^(/dev/)?(...)(.*)$| or die "dev2grub (bad device $dev), caller is " . join(":", caller()); my $grub = $dev2bios->{$2} or die "dev2grub ($2)"; "($grub" . ($3 && "," . ($3 - 1)) . ")"; } sub install_grub { my ($prefix, $lilo, $fstab, $hds) = @_; my %dev2bios = ( (map_index { $_ => "fd$::i" } detect_devices::floppies()), (map_index { $_ => "hd$::i" } dev2bios($hds, $lilo->{boot})), ); { my %bios2dev = reverse %dev2bios; output "$prefix/boot/grub/device.map", join '', map { "($_) /dev/$bios2dev{$_}\n" } sort keys %bios2dev; } my $bootIsReiser = isReiserfs(fsedit::get_root($fstab, 'boot')); my $file2grub = sub { my ($part, $file) = fsedit::file2part($prefix, $fstab, $_[0]); dev2grub($part->{device}, \%dev2bios) . $file; }; { local *F; local $\ = "\n"; my $f = "$prefix/boot/grub/menu.lst"; open F, ">$f" or die "cannot create grub config file: $f"; log::l("writing grub config to $f"); $lilo->{$_} and print F "$_ $lilo->{$_}" foreach qw(timeout); print F "color black/cyan yellow/cyan"; print F "i18n ", $file2grub->("/boot/grub/messages"); print F "keytable ", $file2grub->($lilo->{keytable}) if $lilo->{keytable}; #- since we use notail in reiserfs, altconfigfile is broken :-( unless ($bootIsReiser) { print F "altconfigfile ", $file2grub->(my $once = "/boot/grub/menu.once"); output "$prefix$once", " " x 100; } map_index { print F "default $::i" if $_->{label} eq $lilo->{default}; } @{$lilo->{entries}}; foreach (@{$lilo->{entries}}) { print F "\ntitle $_->{label}"; if ($_->{type} eq "image") { my $vga = $_->{vga} || $lilo->{vga}; printf F "kernel %s root=%s %s%s%s\n", $file2grub->($_->{kernel_or_dev}), $_->{root} =~ /loop7/ ? "707" : $_->{root}, #- special to workaround bug in kernel (see #ifdef CONFIG_BLK_DEV_LOOP) $_->{append}, $_->{'read-write'} && " rw", $vga && $vga ne "normal" && " vga=$vga"; print F "initrd ", $file2grub->($_->{initrd}) if $_->{initrd}; } else { print F "root ", dev2grub($_->{kernel_or_dev}, \%dev2bios); if ($_->{kernel_or_dev} !~ /fd/) { #- boot off the second drive, so reverse the BIOS maps $_->{mapdrive} ||= { '0x80' => '0x81', '0x81' => '0x80' } if $_->{table} && $lilo->{boot} !~ /$_->{table}/; map_each { print F "map ($::b) ($::a)" } %{$_->{mapdrive} || {}}; print F "makeactive"; } print F "chainloader +1"; } } } my $hd = fsedit::get_root($fstab, 'boot')->{rootDevice}; my $dev = dev2grub($lilo->{boot}, \%dev2bios); my ($s1, $s2, $m) = map { $file2grub->("/boot/grub/$_") } qw(stage1 stage2 menu.lst); my $f = "/boot/grub/install.sh"; output "$prefix$f", "grub --device-map=/boot/grub/device.map --batch <<EOF install $s1 d $dev $s2 p $m quit EOF "; output "$prefix/boot/grub/messages", map { substr(translate($_) . "\n", 0, 78) } ( #- ensure the translated messages are not too big the hard way #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) #-PO: and keep them smaller than 79 chars long __("Welcome to GRUB the operating system chooser!"), #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) #-PO: and keep them smaller than 79 chars long __("Use the %c and %c keys for selecting which entry is highlighted."), #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) #-PO: and keep them smaller than 79 chars long __("Press enter to boot the selected OS, \'e\' to edit the"), #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) #-PO: and keep them smaller than 79 chars long __("commands before booting, or \'c\' for a command-line."), #-PO: these messages will be displayed at boot time in the BIOS, use only ASCII (7bit) #-PO: and keep them smaller than 79 chars long __("The highlighted entry will be booted automatically in %d seconds."), ); my $e = "$prefix/boot/.enough_space"; output $e, 1; -s $e or die _("not enough room in /boot"); unlink $e; log::l("Installing boot loader..."); $::testing and return; symlink "$prefix/boot", "/boot"; run_program::run("sh", $f) or die "grub installation failed"; unlink "$prefix/tmp/.error.grub", "/boot"; } sub lnx4win_file { my $lilo = shift; map { local $_ = $_; s,/,\\,g; "$lilo->{boot_drive}:\\lnx4win$_" } @_; } sub loadlin_cmd { my ($prefix, $lilo) = @_; my $e = get_label("linux", $lilo) || first(grep { $_->{type} eq "image" } @{$lilo->{entries}}); commands::cp("$prefix$e->{kernel_or_dev}", "$prefix/boot/vmlinuz") unless -e "$prefix/boot/vmlinuz"; commands::cp("$prefix$e->{initrd}", "$prefix/boot/initrd.img") unless -e "$prefix/boot/initrd.img"; $e->{label}, sprintf"%s %s initrd=%s root=%s $e->{append}", lnx4win_file($lilo, "/loadlin.exe", "/boot/vmlinuz", "/boot/initrd.img"), $e->{root} =~ /loop7/ ? "0707" : $e->{root}; #- special to workaround bug in kernel (see #ifdef CONFIG_BLK_DEV_LOOP) } sub install_loadlin { my ($prefix, $lilo, $fstab) = @_; my $boot; ($boot) = grep { $lilo->{boot} eq "/dev/$_->{device}" } @$fstab; ($boot) = grep { loopback::carryRootLoopback($_) } @$fstab unless $boot && $boot->{device_windobe}; ($boot) = grep { isFat($_) } @$fstab unless $boot && $boot->{device_windobe}; log::l("loadlin device is $boot->{device} (windobe $boot->{device_windobe})"); $lilo->{boot_drive} = $boot->{device_windobe}; my ($winpart) = grep { $_->{device_windobe} eq 'C' } @$fstab; log::l("winpart is $winpart->{device}"); my $winhandle = any::inspect($winpart, $prefix, 'rw'); my $windrive = $winhandle->{dir}; log::l("windrive is $windrive"); my ($label, $cmd) = loadlin_cmd($prefix, $lilo); #install_loadlin_config_sys($lilo, $windrive, $label, $cmd); #install_loadlin_desktop($lilo, $windrive); output "/initrd/loopfs/lnx4win/linux.bat", unix2dos( '@echo off echo Mandrake Linux smartdrv /C ' . "$cmd\n"); } sub install_loadlin_config_sys { my ($lilo, $windrive, $label, $cmd) = @_; my $config_sys = "$windrive/config.sys"; local $_ = cat_($config_sys); output "$windrive/config.mdk", $_ if $_; my $timeout = $lilo->{timeout} || 1; $_ = " [Menu] menuitem=Windows menudefault=Windows,$timeout [Windows] " . $_ if !/^\Q[Menu]/m; #- remove existing entry s/^menuitem=$label\s*//mi; s/\n\[$label\].*?(\n\[|$)/$1/si; #- add entry s/(.*\nmenuitem=[^\n]*)/$1\nmenuitem=$label/s; $_ .= " [$label] shell=$cmd "; output $config_sys, unix2dos($_); } sub install_loadlin_desktop { my ($lilo, $windrive) = @_; my $windir = lc(cat_("$windrive/msdos.sys") =~ /^WinDir=.:\\(\S+)/m ? $1 : "windows"); #-PO: "Desktop" and "Start Menu" are the name of the directories found in c:\windows #-PO: so you may need to put them in English or in a different language if MS-windows doesn't exist in your language foreach (__("Desktop"), #-PO: "Desktop" and "Start Menu" are the name of the directories found in c:\windows __("Start Menu")) { my $d = "$windrive/$windir/" . translate($_); -d $d or $d = "$windrive/$windir/$_"; -d $d or log::l("can't find windows $d directory"), next; output "$d/Linux4Win.url", unix2dos(sprintf q([InternetShortcut] URL=file:\lnx4win\lnx4win.exe WorkingDirectory=%s IconFile=%s IconIndex=0 ), lnx4win_file($lilo, "/", "/lnx4win.ico")); } } sub install { my ($prefix, $lilo, $fstab, $hds) = @_; { my $f = "$prefix/etc/sysconfig/system"; setVarsInSh($f, add2hash_({ CLEAN_TMP => $lilo->{CLEAN_TMP} }, { getVarsFromSh($f) })); } $lilo->{keytable} = keytable($prefix, $lilo->{keytable}); my %l = grep_each { $::b } %{$lilo->{methods}}; my @rcs = map { my $f = $bootloader::{"install_$_"} or die "unknown bootloader method $_"; eval { $f->(@_) }; $@; } reverse sort keys %l; #- reverse sort for having grub installed after lilo if both are there. return if grep { !$_ } @rcs; #- at least one worked? die first(map { $_ } @rcs); } #-###################################################################################### #- Wonderful perl :( #-###################################################################################### 1; #