# HG changeset patch # User Pascal Bellard # Date 1334505098 -7200 # Node ID 02a3222651d530ab529150973e84ac3c1fd7394c # Parent b30c71e802a4052d564b4a528d423b31b213279f syslinux: merge md5sum, kbdmap and linux. kbdmap will append the kernel cmdline diff -r b30c71e802a4 -r 02a3222651d5 syslinux/receipt --- a/syslinux/receipt Sun Apr 15 17:25:16 2012 +0200 +++ b/syslinux/receipt Sun Apr 15 17:51:38 2012 +0200 @@ -36,37 +36,58 @@ { mkdir -p $fs/boot/isolinux cp -a $src/core/isolinux.bin $fs/boot/isolinux - cp -a $src/com32/modules/md5sum.c32 $fs/boot/isolinux + cp -a $src/com32/modules/md5sum.c32 $fs/boot/isolinux/c32box.c32 cp -a $src/com32/menu/vesamenu.c32 $fs/boot/isolinux # $stuff/isolinux.msg is the old way the have a splash image. cp $stuff/*.cfg $stuff/*.txt $stuff/help.* $stuff/opts.* $fs/boot/isolinux - while read cfg kbd loc ; do - sed -e "s/^display/kbdmap $cfg.kbd\ndisplay/" \ - -e "s/^label/say Now using $kbd keyboard and $loc locale.\nlabel/" \ - -e "s/rootfs.gz/rootfs.gz lang=$loc kmap=$kbd/" \ - < $fs/boot/isolinux/default.cfg > $fs/boot/isolinux/$cfg.cfg - cp $src/$kbd.kbd $fs/boot/isolinux/$cfg.kbd - cat >> $fs/boot/isolinux/common.cfg < $fs/boot/isolinux/cpio.kbd + while read label kbd loc menu; do + [ -s $src/$kbd.kbd ] || continue + cat >> $fs/boot/isolinux/i18n.cfg <> $fs/boot/isolinux/i18n.cfg < +#include +#include + +static int main_kbdmap(int argc, char *argv[]) +{ + const struct syslinux_keyboard_map *const kmap = syslinux_keyboard_map(); + size_t map_size, size, i; + char *kbdmap, *msg; + + msg = "Usage: kbdmap archive.cpio mapfile [cmdline].."; + if (argc < 3) + goto kbdmap_error; + + msg = "Load error"; + if (kmap->version != 1 || + loadfile(argv[1], (void **) &kbdmap, &map_size) || + strncmp(kbdmap, "07070", 5)) + goto kbdmap_error; + + // search for mapfile in cpio archive + for (i = 0; i < map_size;) { + int len, j; + char *name; + + for (j = size = 0; j < 8; j++) { + char c = kbdmap[54 + i + j] - '0'; + if (c > 9) c += '0' + 10 - 'A'; + size <<= 4; + size += c; + } + i += 110; + name = kbdmap + i; + len = 1 + strlen(name); + i += len; + i += ((-i)&3); + if (!strcmp(name, argv[2])) { + kbdmap += i; + break; + } + i += size + ((-size)&3); + } + + msg = "Filename error"; + if (i >= map_size) + goto kbdmap_error; + + msg = "Format error"; + if (size != kmap->length) + goto kbdmap_error; + + memcpy(kmap->map, kbdmap, size); + + // Save extra cmdline arguments + for (i = 3; i < (size_t) argc; i++) { + syslinux_setadv(i - 2, strlen(argv[i]), argv[i]); + } + + return 0; + +kbdmap_error: + printf("%s.\n",msg); + return 1; +} + +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * linux.c + * + * Sample module to load Linux kernels. This module can also create + * a file out of the DHCP return data if running under PXELINUX. + * + * If -dhcpinfo is specified, the DHCP info is written into the file + * /dhcpinfo.dat in the initramfs. + * + * Usage: linux.c32 [-dhcpinfo] kernel arguments... + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +const char *progname = "linux.c32"; + +/* Find the last instance of a particular command line argument + (which should include the final =; do not use for boolean arguments) */ +static char *find_argument(char **argv, const char *argument) +{ + int la = strlen(argument); + char **arg; + char *ptr = NULL; + + for (arg = argv; *arg; arg++) { + if (!memcmp(*arg, argument, la)) + ptr = *arg + la; + } + + return ptr; +} + +/* Search for a boolean argument; return its position, or 0 if not present */ +static int find_boolean(char **argv, const char *argument) +{ + char **arg; + + for (arg = argv; *arg; arg++) { + if (!strcmp(*arg, argument)) + return (arg - argv) + 1; + } + + return 0; +} + +/* Stitch together the command line from a set of argv's */ +static char *make_cmdline(char **argv) +{ + char **arg; + size_t bytes, size; + char *cmdline, *p; + int i; + + bytes = 1; /* Just in case we have a zero-entry cmdline */ + for (arg = argv; *arg; arg++) { + bytes += strlen(*arg) + 1; + } + for (i = 0; i < 255; i++) + if (syslinux_getadv(i, &size)) + bytes += ++size; + + p = cmdline = malloc(bytes); + if (!cmdline) + return NULL; + + for (arg = argv; *arg; arg++) { + int len = strlen(*arg); + memcpy(p, *arg, len); + p[len] = ' '; + p += len + 1; + } + + for (i = 0; i < 255; i++) { + const void *q = syslinux_getadv(i, &size); + if (q == NULL) continue; + memcpy(p, q, size); + p[size] = ' '; + p += size + 1; + } + + if (p > cmdline) + p--; /* Remove the last space */ + *p = '\0'; + + return cmdline; +} + +static int main_linux(int argc, char *argv[]) +{ + const char *kernel_name; + struct initramfs *initramfs; + char *cmdline; + char *boot_image; + void *kernel_data; + size_t kernel_len; + bool opt_dhcpinfo = false; + bool opt_quiet = false; + void *dhcpdata; + size_t dhcplen; + char **argp, *arg, *p; + + openconsole(&dev_null_r, &dev_stdcon_w); + + (void)argc; + argp = argv + 1; + + while ((arg = *argp) && arg[0] == '-') { + if (!strcmp("-dhcpinfo", arg)) { + opt_dhcpinfo = true; + } else { + fprintf(stderr, "%s: unknown option: %s\n", progname, arg); + return 1; + } + argp++; + } + + if (!arg) { + fprintf(stderr, "%s: missing kernel name\n", progname); + return 1; + } + + kernel_name = arg; + + boot_image = malloc(strlen(kernel_name) + 12); + if (!boot_image) + goto bail; + strcpy(boot_image, "BOOT_IMAGE="); + strcpy(boot_image + 11, kernel_name); + /* argp now points to the kernel name, and the command line follows. + Overwrite the kernel name with the BOOT_IMAGE= argument, and thus + we have the final argument. */ + *argp = boot_image; + + if (find_boolean(argp, "quiet")) + opt_quiet = true; + + if (!opt_quiet) + printf("Loading %s... ", kernel_name); + if (loadfile(kernel_name, &kernel_data, &kernel_len)) { + if (opt_quiet) + printf("Loading %s ", kernel_name); + printf("failed!\n"); + goto bail; + } + if (!opt_quiet) + printf("ok\n"); + + cmdline = make_cmdline(argp); + if (!cmdline) + goto bail; + + /* Initialize the initramfs chain */ + initramfs = initramfs_init(); + if (!initramfs) + goto bail; + + if ((arg = find_argument(argp, "initrd="))) { + do { + p = strchr(arg, ','); + if (p) + *p = '\0'; + + if (!opt_quiet) + printf("Loading %s... ", arg); + if (initramfs_load_archive(initramfs, arg)) { + if (opt_quiet) + printf("Loading %s ", kernel_name); + printf("failed!\n"); + goto bail; + } + if (!opt_quiet) + printf("ok\n"); + + if (p) + *p++ = ','; + } while ((arg = p)); + } + + /* Append the DHCP info */ + if (opt_dhcpinfo && + !pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) { + if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen, + "/dhcpinfo.dat", 0, 0755)) + goto bail; + } + + /* This should not return... */ + syslinux_boot_linux(kernel_data, kernel_len, initramfs, cmdline); + +bail: + fprintf(stderr, "Kernel load failure (insufficient memory?)\n"); + return 1; +} + int main(int argc, char *argv[]) { unsigned i; @@ -550,7 +849,9 @@ { "md5sum", main_md5sum }, { "ifmem", main_ifmem }, { "reboot", main_reboot }, - { "poweroff", main_poweroff } + { "poweroff", main_poweroff }, + { "kbdmap", main_kbdmap }, + { "linux", main_linux } }; openconsole(&dev_null_r, &dev_stdcon_w); @@ -559,5 +860,8 @@ for (i = 0; i < sizeof(bin)/sizeof(bin[0]); i++) if (strstr(argv[0], bin[i].name)) return bin[i].main(argc, argv); + printf("No %s in c32box modules\n", argv[0]); + for (i = 0; i < sizeof(bin)/sizeof(bin[0]); i++) + printf(" %s \n",bin[i].name); return 1; } diff -r b30c71e802a4 -r 02a3222651d5 syslinux/stuff/i18n.cfg --- a/syslinux/stuff/i18n.cfg Sun Apr 15 17:25:16 2012 +0200 +++ b/syslinux/stuff/i18n.cfg Sun Apr 15 17:51:38 2012 +0200 @@ -2,52 +2,3 @@ MENU BEGIN ^lang MENU TITLE Languages -# de -LABEL de - MENU LABEL Deutsch - CONFIG de.cfg -LABEL de_CH - MENU LABEL Deutsch Schweitz - CONFIG de_CH.cfg -LABEL deCH - MENU HIDE - CONFIG de_CH.cfg -# en -LABEL en - MENU LABEL English UK - CONFIG en.cfg -LABEL us - MENU LABEL English US - CONFIG us.cfg -# es -LABEL es - MENU LABEL Espanol - CONFIG es.cfg -# fr -LABEL fr - MENU LABEL Francais - CONFIG fr.cfg -LABEL be - MENU LABEL Francais Belgique - CONFIG be.cfg -LABEL ca - MENU LABEL Francais Canada - CONFIG ca.cfg -LABEL fr_CH - MENU LABEL Francais Suisse - CONFIG fr_CH.cfg -LABEL frCH - MENU HIDE - CONFIG fr_CH.cfg -# pt -LABEL pt - MENU LABEL Portugues Brazil - CONFIG pt.cfg -# ru -LABEL ru - MENU LABEL Russian - CONFIG ru.cfg -LABEL exit - MENU LABEL Back to main menu -MENU EXIT -MENU END diff -r b30c71e802a4 -r 02a3222651d5 syslinux/stuff/isolinux.cfg --- a/syslinux/stuff/isolinux.cfg Sun Apr 15 17:25:16 2012 +0200 +++ b/syslinux/stuff/isolinux.cfg Sun Apr 15 17:51:38 2012 +0200 @@ -29,8 +29,8 @@ # Labels LABEL slitaz MENU LABEL SliTaz Live - KERNEL /boot/bzImage - APPEND initrd=/boot/rootfs.gz rw root=/dev/null vga=normal autologin + COM32 c32box.c32 + APPEND linux /boot/bzImage initrd=/boot/rootfs.gz rw root=/dev/null vga=normal autologin LABEL help MENU LABEL Help & Options @@ -40,8 +40,8 @@ LABEL md5sum MENU LABEL Check media - COM32 md5sum.c32 - append /md5sum + COM32 c32box.c32 + append md5sum /md5sum LABEL cmdline MENU LABEL Command Line @@ -53,7 +53,13 @@ LABEL reboot MENU LABEL Reboot System - COM32 reboot.c32 + COM32 c32box.c32 + append reboot + +LABEL poweroff + MENU LABEL Power off + COM32 c32box.c32 + append poweroff # Help files F1 help.en