wok-6.x rev 20073

syslinux: shrink i18n.cfg
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Sep 24 19:06:48 2017 +0200 (2017-09-24)
parents cc3ce981e201
children b437748afc7d
files syslinux/receipt syslinux/stuff/extra/md5sum.c
line diff
     1.1 --- a/syslinux/receipt	Sun Sep 24 08:47:56 2017 +0200
     1.2 +++ b/syslinux/receipt	Sun Sep 24 19:06:48 2017 +0200
     1.3 @@ -66,12 +66,14 @@
     1.4  	rm -f $fs/boot/isolinux/display.txt
     1.5  	while read label kbd loc tz menu; do
     1.6  		for i in ${kbd/,/ }; do
     1.7 -			[ -e $src/kbd/$i ] || continue
     1.8 +	 		[ -e $src/kbd/$i ] || continue
     1.9 +			map=" $i"
    1.10 +			[ ${kbd#*,} == $i ] && map=
    1.11  			cat >> $fs/boot/isolinux/i18n.cfg <<EOT
    1.12  LABEL $label
    1.13  	MENU LABEL $menu
    1.14  	com32 c32box.c32
    1.15 -	append kbdmap kbd $i lang=$loc kmap=${kbd#*,} tz=$tz
    1.16 +	append kbd$map lang=$loc kmap=${kbd#*,} tz=$tz
    1.17  
    1.18  EOT
    1.19  			break
     2.1 --- a/syslinux/stuff/extra/md5sum.c	Sun Sep 24 08:47:56 2017 +0200
     2.2 +++ b/syslinux/stuff/extra/md5sum.c	Sun Sep 24 19:06:48 2017 +0200
     2.3 @@ -506,7 +506,7 @@
     2.4      int i;
     2.5  
     2.6      for (i = 1; i < argc; i++) {
     2.7 -	if (!strcmp(argv[i], "-w") || !strcmp(argv[i], "--warm"))
     2.8 +	if (strstr(argv[i], "-w"))
     2.9  	    warm = 1;
    2.10      }
    2.11  
    2.12 @@ -590,22 +590,40 @@
    2.13  {
    2.14      const struct syslinux_keyboard_map *const kmap = syslinux_keyboard_map();
    2.15      size_t map_size, size, i;
    2.16 -    char *kbdmap, *msg;
    2.17 +    char *kbdmap, *msg, *kbdfile, *kbdname;
    2.18 +    int skip = 3;
    2.19  
    2.20      if (argc < 3)
    2.21 -	usage("Usage: kbdmap archive.cpio mapfile [cmdline]..");
    2.22 +	usage("Usage: kbdmap [archive.cpio] [mapfile] [cmdline]..");
    2.23 +
    2.24 +    if (loadfile(kbdfile = argv[1], (void **) &kbdmap, &map_size)) {
    2.25 +	kbdfile = "kbd";
    2.26 +	skip--;
    2.27 +    }
    2.28 +    else {
    2.29 +	free(kbdmap);
    2.30 +    }
    2.31 +
    2.32 +    if (strchr(kbdname = argv[skip-1],'=')) {
    2.33 +	for (i = --skip; argv[i]; i++) {
    2.34 +	    if (!strncmp(argv[i], "kmap=", 5)) {
    2.35 +		kbdname = argv[i] + 5;
    2.36 +		break;
    2.37 +	    }
    2.38 +	}
    2.39 +    }
    2.40  
    2.41      // Save extra cmdline arguments
    2.42 -    setlinuxarg(1, argc - 3, argv + 3);
    2.43 +    setlinuxarg(1, argc - skip, argv + skip);
    2.44  
    2.45      msg="Append to kernel parameters: ";
    2.46 -    for (i = 3; i < (size_t) argc; i++, msg = " ")
    2.47 +    for (i = skip; i < (size_t) argc; i++, msg = " ")
    2.48  	printf("%s%s",msg,argv[i]);
    2.49      printf("\n\n                            Hit RETURN to continue.\n");
    2.50  
    2.51      msg = "Load error";
    2.52      if (kmap->version != 1 ||
    2.53 -	loadfile(argv[1], (void **) &kbdmap, &map_size))
    2.54 +	loadfile(kbdfile, (void **) &kbdmap, &map_size))
    2.55      	goto kbdmap_error;
    2.56      if (* (short *) kbdmap == 0x005D) {
    2.57  	void *p = malloc(map_size = * (long *) (kbdmap + 5));
    2.58 @@ -635,7 +653,7 @@
    2.59  	len = 1 + strlen(name);
    2.60  	i += len;
    2.61  	i += ((-i)&3);
    2.62 -	if (!strcmp(name, argv[2])) {
    2.63 +	if (!strcmp(name, kbdname)) {
    2.64  	    kbdmap += i;
    2.65  	    break;
    2.66  	}
    2.67 @@ -729,6 +747,9 @@
    2.68  }
    2.69  
    2.70  /* Search for a boolean argument; return its position, or 0 if not present */
    2.71 +#if 1
    2.72 +#define find_boolean(a,b)	(find_argument(a,b) != NULL)
    2.73 +#else
    2.74  static int find_boolean(char **argv, const char *argument)
    2.75  {
    2.76      char **arg;
    2.77 @@ -740,6 +761,7 @@
    2.78  
    2.79      return 0;
    2.80  }
    2.81 +#endif
    2.82  
    2.83  static int got_config;
    2.84  static char *custom_cmdline = "";
    2.85 @@ -754,12 +776,13 @@
    2.86      
    2.87      if (got_config)
    2.88      	goto done;
    2.89 +    got_config = -1;
    2.90      sdi = syslinux_derivative_info();
    2.91      if (sdi->c.filesystem != SYSLINUX_FS_ISOLINUX)
    2.92      	goto fail;
    2.93      disk_get_params(sdi->iso.drive_number, &diskinfo);
    2.94      custom_buffer = disk_read_sectors(&diskinfo, 32768 / diskinfo.bps, 1);
    2.95 -    got_config = (16 + *(unsigned long *) (custom_buffer + 80)) 
    2.96 +    got_config = (*(unsigned long *) (custom_buffer + 80)) 
    2.97      		 * 2048 / diskinfo.bps;
    2.98      free(custom_buffer);
    2.99      custom_buffer = disk_read_sectors(&diskinfo, got_config, 1);
   2.100 @@ -775,10 +798,8 @@
   2.101      	    custom_initrdlen = strtoul(p + 7, &custom_initrdbase, 10);
   2.102      	    custom_initrdbase += (got_config << 11) + 1 - (int) custom_buffer;
   2.103      	}
   2.104 -    	return 1;
   2.105      }
   2.106  fail:
   2.107 -    got_config = -1;
   2.108  done:
   2.109      return got_config > 0;
   2.110  }
   2.111 @@ -788,7 +809,7 @@
   2.112      int n, len;
   2.113      char *p;
   2.114      
   2.115 -    p = *data = malloc(len = custom_initrdlen);
   2.116 +    p = *data = malloc(custom_initrdlen);
   2.117      if (!p) return 0;
   2.118      for (len = custom_initrdlen; len != 0; len -= n, p += n) {
   2.119  	free(custom_buffer);
   2.120 @@ -826,10 +847,10 @@
   2.121  	return NULL;
   2.122  
   2.123      for (arg = argv; *arg; arg++) {
   2.124 -	int len = strlen(*arg);
   2.125 -	memcpy(p, *arg, len);
   2.126 -	p[len] = ' ';
   2.127 -	p += len + 1;
   2.128 +	size = strlen(*arg);
   2.129 +	memcpy(p, *arg, size);
   2.130 +	p[size] = ' ';
   2.131 +	p += size + 1;
   2.132      }
   2.133  
   2.134      for (i = 0; i < 255; i++) {
   2.135 @@ -947,6 +968,7 @@
   2.136      const char *initrd_name;
   2.137      struct initramfs *initramfs;
   2.138      struct setup_data *setup_data;
   2.139 +    char *errmsg;
   2.140      char *cmdline;
   2.141      char *boot_image;
   2.142      void *kernel_data;
   2.143 @@ -960,20 +982,20 @@
   2.144      openconsole(&dev_null_r, &dev_stdcon_w);
   2.145  
   2.146      (void)argc;
   2.147 -    argp = argv + 1;
   2.148  
   2.149 -    while ((arg = *argp) && arg[0] == '-') {
   2.150 +    for (argp = argv + 1; (arg = *argp) && arg[0] == '-'; argp++) {
   2.151  	if (!strcmp("-dhcpinfo", arg)) {
   2.152  	    opt_dhcpinfo = true;
   2.153  	} else {
   2.154 -	    fprintf(stderr, "%s: unknown option: %s\n", progname, arg);
   2.155 -	    return 1;
   2.156 +	    errmsg = "%s: unknown option: %s\n";
   2.157 +	    goto unknown_option;
   2.158  	}
   2.159 -	argp++;
   2.160      }
   2.161  
   2.162      if (!arg) {
   2.163 -	fprintf(stderr, "%s: missing kernel name\n", progname);
   2.164 +	errmsg = "%s: missing kernel name\n";
   2.165 +unknown_option:
   2.166 +	fprintf(stderr, errmsg, progname, arg);
   2.167  	return 1;
   2.168      }
   2.169  
   2.170 @@ -982,8 +1004,8 @@
   2.171      errno = 0;
   2.172      boot_image = malloc(strlen(kernel_name) + 12);
   2.173      if (!boot_image) {
   2.174 -	fprintf(stderr, "Error allocating BOOT_IMAGE string: ");
   2.175 -	goto bail;
   2.176 +	errmsg = "Error allocating BOOT_IMAGE string: ";
   2.177 +	goto bailmsg;
   2.178      }
   2.179      strcpy(boot_image, "BOOT_IMAGE=");
   2.180      strcpy(boot_image + 11, kernel_name);
   2.181 @@ -1010,20 +1032,20 @@
   2.182      errno = 0;
   2.183      cmdline = make_cmdline(argp);
   2.184      if (!cmdline) {
   2.185 -	fprintf(stderr, "make_cmdline() failed: ");
   2.186 -	goto bail;
   2.187 +	errmsg = "make_cmdline() failed: ";
   2.188 +	goto bailmsg;
   2.189      }
   2.190  
   2.191      /* Initialize the initramfs chain */
   2.192      errno = 0;
   2.193      initramfs = initramfs_init();
   2.194      if (!initramfs) {
   2.195 -	fprintf(stderr, "initramfs_init() failed: ");
   2.196 -	goto bail;
   2.197 +	errmsg = "initramfs_init() failed: ";
   2.198 +	goto bailmsg;
   2.199      }
   2.200  
   2.201      if ((arg = find_argument(argp, "initrd="))) {
   2.202 -	do {
   2.203 +	while (1) {
   2.204  	    p = strchr(arg, ',');
   2.205  	    if (p)
   2.206  		*p = '\0';
   2.207 @@ -1041,9 +1063,12 @@
   2.208  	    if (!opt_quiet)
   2.209  		printf("ok\n");
   2.210  
   2.211 -	    if (p)
   2.212 -		*p++ = ',';
   2.213 -	} while ((arg = p));
   2.214 +	    if (!p)
   2.215 +		break;
   2.216 +
   2.217 +	    *p++ = ',';
   2.218 +	    arg = p;
   2.219 +	}
   2.220      }
   2.221  
   2.222      /* Append the DHCP info */
   2.223 @@ -1052,8 +1077,8 @@
   2.224  	errno = 0;
   2.225  	if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen,
   2.226  			       "/dhcpinfo.dat", 0, 0755)) {
   2.227 -	    fprintf(stderr, "Unable to add DHCP info: ");
   2.228 -	    goto bail;
   2.229 +	    errmsg = "Unable to add DHCP info: ";
   2.230 +	    goto bailmsg;
   2.231  	}
   2.232      }
   2.233  
   2.234 @@ -1080,10 +1105,7 @@
   2.235  	    char *ep;
   2.236  
   2.237  	    type = strtoul(arg + 5, &ep, 10);
   2.238 -	    if (ep[0] != '=' || !ep[1])
   2.239 -		continue;
   2.240 -
   2.241 -	    if (!type)
   2.242 +	    if (!type || ep[0] != '=' || !ep[1])
   2.243  		continue;
   2.244  
   2.245  	    if (setup_data_file(setup_data, type, ep+1, opt_quiet))
   2.246 @@ -1095,24 +1117,24 @@
   2.247      errno = 0;
   2.248      syslinux_boot_linux(kernel_data, kernel_len, initramfs,
   2.249  			setup_data, cmdline);
   2.250 -    fprintf(stderr, "syslinux_boot_linux() failed: ");
   2.251 +    errmsg = "syslinux_boot_linux() failed: ";
   2.252  
   2.253 +bailmsg:
   2.254 +    fprintf(stderr, errmsg);
   2.255  bail:
   2.256 +    errmsg = "Error %d";
   2.257      switch(errno) {
   2.258      case ENOENT:
   2.259 -	fprintf(stderr, "File not found\n");
   2.260 +	errmsg = "File not found";
   2.261  	break;
   2.262      case ENOMEM:
   2.263 -	fprintf(stderr, "Out of memory\n");
   2.264 -	break;
   2.265 -    default:
   2.266 -	fprintf(stderr, "Error %d\n", errno);
   2.267 -	break;
   2.268 +	errmsg = "Out of memory";
   2.269      }
   2.270 -    fprintf(stderr, "%luM RAM found on this %s bits machine.\n",
   2.271 +    fprintf(stderr, errmsg, errno);
   2.272 +    fprintf(stderr, "\n%luM RAM and %s bit cpu found.\n%s: Boot aborted!\n",
   2.273  		    memory_size() >> 10,
   2.274 -    		    cpu_has_feature(X86_FEATURE_LM) ? "64": "32");
   2.275 -    fprintf(stderr, "%s: Boot aborted!\n", progname);
   2.276 +    		    cpu_has_feature(X86_FEATURE_LM) ? "64": "32",
   2.277 +		    progname);
   2.278      return 1;
   2.279  }
   2.280  
   2.281 @@ -1210,6 +1232,7 @@
   2.282  		{ "listarg",	main_listarg  },
   2.283  #endif
   2.284  		{ "kbdmap",	main_kbdmap   },
   2.285 +		{ "kbd",	main_kbdmap   },
   2.286  		{ "ifmem",	main_ifmem    },
   2.287  		{ "linux",	main_linux    },
   2.288  		{ "md5sum",	main_md5sum   },