wok-next rev 20197

syslinux: updates from rolling
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 03 15:07:20 2017 +0100 (2017-11-03)
parents 07833512a72e
children 937f2ed1d5c8
files syslinux/receipt syslinux/stuff/extra/keytab-lilo.u syslinux/stuff/extra/md5sum.c syslinux/stuff/iso2exe/Makefile syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/win32.c syslinux/stuff/isolinux.cfg syslinux/stuff/tools/isohybrid.sh
line diff
     1.1 --- a/syslinux/receipt	Fri Nov 03 11:59:19 2017 +0100
     1.2 +++ b/syslinux/receipt	Fri Nov 03 15:07:20 2017 +0100
     1.3 @@ -59,6 +59,8 @@
     1.4  		mkdir -p $fs/boot/isolinux $install/usr/share/doc
     1.5  		cp $stuff/iso2exe/README* $install/usr/share/doc
     1.6  		cp $stuff/iso2exe/init.custom $install/usr/share/doc
     1.7 +		cp $src/doc/*.txt $install/usr/share/doc
     1.8 +		cp -a $src/man $install/usr/share/
     1.9  		cp $LINLD/*/linld.com $fs/boot
    1.10  		cp -a $src/core/isolinux.bin $fs/boot/isolinux
    1.11  		lzma e $src/com32/modules/md5sum.c32 $fs/boot/isolinux/c32box.c32
    1.12 @@ -70,11 +72,13 @@
    1.13  		while read label kbd loc tz menu; do
    1.14  			for i in ${kbd/,/ }; do
    1.15  				[ -e $src/kbd/$i ] || continue
    1.16 +				map=" $i"
    1.17 +				[ ${kbd#*,} == $i ] && map=
    1.18  				cat >> $fs/boot/isolinux/i18n.cfg <<EOT
    1.19  LABEL $label
    1.20  	MENU LABEL $menu
    1.21  	com32 c32box.c32
    1.22 -	append kbdmap kbd $i lang=$loc kmap=${kbd#*,} tz=$tz
    1.23 +	append kbd$map lang=$loc kmap=${kbd#*,} tz=$tz
    1.24  
    1.25  EOT
    1.26  				break
    1.27 @@ -108,6 +112,7 @@
    1.28  po		pl2		pl_PL	Europe/Warsaw		Polski
    1.29  pt		pt-latin1	pt_PT	Europe/Lisbon		Portugues
    1.30  ru		ru		ru_RU	Europe/Moscow		Russian
    1.31 +ru_uk\ uk	ru		ru_UA	Europe/Kiev		Russian Ukraine
    1.32  sl		slovene		sl_SI	Europe/Ljubljana	Slovenski
    1.33  fi		fi		fi_FI	Europe/Helsinki		Suomi
    1.34  se		se-lat6		sv_SE	Europe/Stockholm	Svenska
    1.35 @@ -132,7 +137,7 @@
    1.36  		for kbd in $(cd $src/kbd; ls | tee ../kbd.l); do
    1.37  			msg="Invalid file kbd/$kbd"
    1.38  			[ -s $src/kbd/$kbd ] && msg="Unused: file kbd/$kbd" &&
    1.39 -			grep -q " $kbd " $fs/boot/isolinux/i18n.cfg && continue
    1.40 +				grep -q "[= ]$kbd " $fs/boot/isolinux/i18n.cfg && continue
    1.41  			sed -i "/^$kbd\$/d" $src/kbd.l
    1.42  			echo "$msg"
    1.43  		done
     2.1 --- a/syslinux/stuff/extra/keytab-lilo.u	Fri Nov 03 11:59:19 2017 +0100
     2.2 +++ b/syslinux/stuff/extra/keytab-lilo.u	Fri Nov 03 15:07:20 2017 +0100
     2.3 @@ -1,3 +1,4 @@
     2.4 +kbd 2.0.3 support
     2.5  --- utils/keytab-lilo
     2.6  +++ utils/keytab-lilo
     2.7  @@ -48,9 +48,9 @@
     3.1 --- a/syslinux/stuff/extra/md5sum.c	Fri Nov 03 11:59:19 2017 +0100
     3.2 +++ b/syslinux/stuff/extra/md5sum.c	Fri Nov 03 15:07:20 2017 +0100
     3.3 @@ -248,6 +248,10 @@
     3.4   * Licensed under GPLv2 or later, see file LICENSE in this source tree.
     3.5   */
     3.6  
     3.7 +#ifdef EXTRA
     3.8 +#define WITH_UNROCKRIDGE
     3.9 +#endif
    3.10 +#ifdef WITH_UNROCKRIDGE
    3.11  static char *unrockridge(const char *name)
    3.12  {
    3.13  	static char buffer[256];
    3.14 @@ -270,6 +274,7 @@
    3.15  	buffer[i] = 0;
    3.16  	return buffer;
    3.17  }
    3.18 +#endif
    3.19  
    3.20  static uint8_t *hash_file(const char *filename)
    3.21  {
    3.22 @@ -278,9 +283,12 @@
    3.23  	static uint8_t hash_value[16*2+1];
    3.24  
    3.25  	src_fd = open(filename, O_RDONLY);
    3.26 +#ifdef WITH_UNROCKRIDGE
    3.27  	if (src_fd < 0) {
    3.28  		src_fd = open(unrockridge(filename), O_RDONLY);
    3.29  	}
    3.30 +#endif
    3.31 +
    3.32  	if (src_fd < 0) {
    3.33  		return NULL;
    3.34  	}
    3.35 @@ -301,6 +309,7 @@
    3.36  	return hash_value;
    3.37  }
    3.38  
    3.39 +#ifdef EXTRA
    3.40  static int main_say(int argc, char **argv)
    3.41  {
    3.42  	int i;
    3.43 @@ -310,6 +319,7 @@
    3.44  	sleep(5);
    3.45  	return 0;
    3.46  }
    3.47 +#endif
    3.48  
    3.49  static int main_md5sum(int argc, char **argv)
    3.50  {
    3.51 @@ -323,8 +333,10 @@
    3.52  		FILE *fp;
    3.53  		char eol, *line, buffer[4096];
    3.54  		fp = fopen(*argv,"r");
    3.55 +#ifdef WITH_UNROCKRIDGE
    3.56  		if (fp == NULL)
    3.57  			fp = fopen(unrockridge(*argv),"r");
    3.58 +#endif
    3.59  
    3.60  		while ((line = fgets(buffer,sizeof(buffer),fp)) != NULL) {
    3.61  			uint8_t *hash_value;
    3.62 @@ -494,7 +506,7 @@
    3.63      int i;
    3.64  
    3.65      for (i = 1; i < argc; i++) {
    3.66 -	if (!strcmp(argv[i], "-w") || !strcmp(argv[i], "--warm"))
    3.67 +	if (strstr(argv[i], "-w"))
    3.68  	    warm = 1;
    3.69      }
    3.70  
    3.71 @@ -578,22 +590,40 @@
    3.72  {
    3.73      const struct syslinux_keyboard_map *const kmap = syslinux_keyboard_map();
    3.74      size_t map_size, size, i;
    3.75 -    char *kbdmap, *msg;
    3.76 +    char *kbdmap, *msg, *kbdfile, *kbdname;
    3.77 +    int skip = 3;
    3.78  
    3.79      if (argc < 3)
    3.80 -	usage("Usage: kbdmap archive.cpio mapfile [cmdline]..");
    3.81 +	usage("Usage: kbdmap [archive.cpio] [mapfile] [cmdline]..");
    3.82 +
    3.83 +    if (loadfile(kbdfile = argv[1], (void **) &kbdmap, &map_size)) {
    3.84 +	kbdfile = "kbd";
    3.85 +	skip--;
    3.86 +    }
    3.87 +    else {
    3.88 +	free(kbdmap);
    3.89 +    }
    3.90 +
    3.91 +    if (strchr(kbdname = argv[skip-1],'=')) {
    3.92 +	for (i = --skip; argv[i]; i++) {
    3.93 +	    if (!strncmp(argv[i], "kmap=", 5)) {
    3.94 +		kbdname = argv[i] + 5;
    3.95 +		break;
    3.96 +	    }
    3.97 +	}
    3.98 +    }
    3.99  
   3.100      // Save extra cmdline arguments
   3.101 -    setlinuxarg(1, argc - 3, argv + 3);
   3.102 +    setlinuxarg(1, argc - skip, argv + skip);
   3.103  
   3.104      msg="Append to kernel parameters: ";
   3.105 -    for (i = 3; i < (size_t) argc; i++, msg = " ")
   3.106 +    for (i = skip; i < (size_t) argc; i++, msg = " ")
   3.107  	printf("%s%s",msg,argv[i]);
   3.108      printf("\n\n                            Hit RETURN to continue.\n");
   3.109  
   3.110      msg = "Load error";
   3.111      if (kmap->version != 1 ||
   3.112 -	loadfile(argv[1], (void **) &kbdmap, &map_size))
   3.113 +	loadfile(kbdfile, (void **) &kbdmap, &map_size))
   3.114      	goto kbdmap_error;
   3.115      if (* (short *) kbdmap == 0x005D) {
   3.116  	void *p = malloc(map_size = * (long *) (kbdmap + 5));
   3.117 @@ -623,7 +653,7 @@
   3.118  	len = 1 + strlen(name);
   3.119  	i += len;
   3.120  	i += ((-i)&3);
   3.121 -	if (!strcmp(name, argv[2])) {
   3.122 +	if (!strcmp(name, kbdname)) {
   3.123  	    kbdmap += i;
   3.124  	    break;
   3.125  	}
   3.126 @@ -717,6 +747,9 @@
   3.127  }
   3.128  
   3.129  /* Search for a boolean argument; return its position, or 0 if not present */
   3.130 +#if 1
   3.131 +#define find_boolean(a,b)	(find_argument(a,b) != NULL)
   3.132 +#else
   3.133  static int find_boolean(char **argv, const char *argument)
   3.134  {
   3.135      char **arg;
   3.136 @@ -728,49 +761,45 @@
   3.137  
   3.138      return 0;
   3.139  }
   3.140 +#endif
   3.141  
   3.142  static int got_config;
   3.143  static char *custom_cmdline = "";
   3.144  static int custom_initrdlen;
   3.145 -static char *custom_initrdbase;
   3.146 +static int custom_initrdbase;
   3.147  static char *custom_buffer;
   3.148  static struct disk_info diskinfo;
   3.149  
   3.150  static int has_custom_config(void)
   3.151  {
   3.152      const union syslinux_derivative_info *sdi;
   3.153 -    int retry=0;
   3.154      
   3.155      if (got_config)
   3.156      	goto done;
   3.157 +    got_config = -1;
   3.158      sdi = syslinux_derivative_info();
   3.159      if (sdi->c.filesystem != SYSLINUX_FS_ISOLINUX)
   3.160      	goto fail;
   3.161      disk_get_params(sdi->iso.drive_number, &diskinfo);
   3.162      custom_buffer = disk_read_sectors(&diskinfo, 32768 / diskinfo.bps, 1);
   3.163 -    got_config = (*(unsigned long *) (custom_buffer + 80) * 2048) / diskinfo.bps;
   3.164 -    do {
   3.165 -	free(custom_buffer);
   3.166 -	custom_buffer = disk_read_sectors(&diskinfo, got_config, 1);
   3.167 -	if (!memcmp(custom_buffer,"#!boot ",7)) {
   3.168 -	    char *p = custom_buffer+7+32+1;
   3.169 +    got_config = (*(unsigned long *) (custom_buffer + 80)) 
   3.170 +    		 * 2048 / diskinfo.bps;
   3.171 +    free(custom_buffer);
   3.172 +    custom_buffer = disk_read_sectors(&diskinfo, got_config, 1);
   3.173 +    if (!memcmp(custom_buffer,"#!boot ",7)) {
   3.174 +	char *p = custom_buffer+7+32+1;
   3.175  	
   3.176 -    	    if (!memcmp(p,"append=",7)) {
   3.177 -		custom_cmdline = p + 7;
   3.178 -		p = strchr(p,'\n');
   3.179 -		*p++ = 0;
   3.180 -    	    }
   3.181 -    	    if (!memcmp(p,"initrd:",7)) {
   3.182 -    		custom_initrdlen = strtoul(p + 7, &custom_initrdbase, 10);
   3.183 -    		custom_initrdbase++;
   3.184 -    	    }
   3.185 -    	    return 1;
   3.186 -	}
   3.187 -	got_config += 16UL;
   3.188 -	retry = 1 - retry;
   3.189 -    } while (retry);
   3.190 +    	if (!memcmp(p,"append=",7)) {
   3.191 +	    custom_cmdline = p + 7;
   3.192 +	    p = strchr(p,'\n');
   3.193 +	    *p++ = 0;
   3.194 +    	}
   3.195 +    	if (!memcmp(p,"initrd:",7)) {
   3.196 +    	    custom_initrdlen = strtoul(p + 7, &custom_initrdbase, 10);
   3.197 +    	    custom_initrdbase += (got_config << 11) + 1 - (int) custom_buffer;
   3.198 +    	}
   3.199 +    }
   3.200  fail:
   3.201 -    got_config = -1;
   3.202  done:
   3.203      return got_config > 0;
   3.204  }
   3.205 @@ -782,20 +811,15 @@
   3.206      
   3.207      p = *data = malloc(custom_initrdlen);
   3.208      if (!p) return 0;
   3.209 -    len = custom_initrdlen;
   3.210 -    while (1) {
   3.211 -	n = 2048 + custom_buffer - custom_initrdbase;
   3.212 +    for (len = custom_initrdlen; len != 0; len -= n, p += n) {
   3.213 +	free(custom_buffer);
   3.214 +	custom_buffer = disk_read_sectors(&diskinfo, custom_initrdbase >> 11,
   3.215 +					  2048 / diskinfo.bps);
   3.216 +	n = 2048 - (custom_initrdbase & 2047);
   3.217      	if (n > len)
   3.218      	    n = len;
   3.219 -	memcpy(p, custom_initrdbase, n);
   3.220 -	p += n;
   3.221 -	len -= n;
   3.222 -	if (len == 0)
   3.223 -	    break;
   3.224 -	free(custom_buffer);
   3.225 -	got_config += 2048 / diskinfo.bps;
   3.226 -	custom_initrdbase = custom_buffer = 
   3.227 -		disk_read_sectors(&diskinfo, got_config, 2048 / diskinfo.bps);
   3.228 +	memcpy(p, custom_buffer + (custom_initrdbase & 2047), n);
   3.229 +	custom_initrdbase += n;
   3.230      }
   3.231      return 1;
   3.232  }
   3.233 @@ -823,10 +847,10 @@
   3.234  	return NULL;
   3.235  
   3.236      for (arg = argv; *arg; arg++) {
   3.237 -	int len = strlen(*arg);
   3.238 -	memcpy(p, *arg, len);
   3.239 -	p[len] = ' ';
   3.240 -	p += len + 1;
   3.241 +	size = strlen(*arg);
   3.242 +	memcpy(p, *arg, size);
   3.243 +	p[size] = ' ';
   3.244 +	p += size + 1;
   3.245      }
   3.246  
   3.247      for (i = 0; i < 255; i++) {
   3.248 @@ -849,10 +873,7 @@
   3.249      return cmdline;
   3.250  }
   3.251  
   3.252 -static bool __constfunc cpu_has_cpuid(void)
   3.253 -{
   3.254 -    return cpu_has_eflag(X86_EFLAGS_ID);
   3.255 -}
   3.256 +#define cpu_has_cpuid() cpu_has_eflag(X86_EFLAGS_ID)
   3.257  
   3.258  static bool __constfunc cpu_has_level(uint32_t level)
   3.259  {
   3.260 @@ -896,8 +917,10 @@
   3.261  		if (cpu_has_feature(feature)) {
   3.262  			strcat(newfilename, ext);
   3.263  			fd = open(new, O_RDONLY);
   3.264 +#ifdef WITH_UNROCKRIDGE
   3.265  			if (fd < 0)
   3.266  				fd = open(new = unrockridge(new), O_RDONLY);
   3.267 +#endif
   3.268  			if (fd >= 0) {
   3.269  				found = new;
   3.270  				close(fd);
   3.271 @@ -945,6 +968,7 @@
   3.272      const char *initrd_name;
   3.273      struct initramfs *initramfs;
   3.274      struct setup_data *setup_data;
   3.275 +    char *errmsg;
   3.276      char *cmdline;
   3.277      char *boot_image;
   3.278      void *kernel_data;
   3.279 @@ -958,20 +982,20 @@
   3.280      openconsole(&dev_null_r, &dev_stdcon_w);
   3.281  
   3.282      (void)argc;
   3.283 -    argp = argv + 1;
   3.284  
   3.285 -    while ((arg = *argp) && arg[0] == '-') {
   3.286 +    for (argp = argv + 1; (arg = *argp) && arg[0] == '-'; argp++) {
   3.287  	if (!strcmp("-dhcpinfo", arg)) {
   3.288  	    opt_dhcpinfo = true;
   3.289  	} else {
   3.290 -	    fprintf(stderr, "%s: unknown option: %s\n", progname, arg);
   3.291 -	    return 1;
   3.292 +	    errmsg = "%s: unknown option: %s\n";
   3.293 +	    goto unknown_option;
   3.294  	}
   3.295 -	argp++;
   3.296      }
   3.297  
   3.298      if (!arg) {
   3.299 -	fprintf(stderr, "%s: missing kernel name\n", progname);
   3.300 +	errmsg = "%s: missing kernel name\n";
   3.301 +unknown_option:
   3.302 +	fprintf(stderr, errmsg, progname, arg);
   3.303  	return 1;
   3.304      }
   3.305  
   3.306 @@ -980,8 +1004,8 @@
   3.307      errno = 0;
   3.308      boot_image = malloc(strlen(kernel_name) + 12);
   3.309      if (!boot_image) {
   3.310 -	fprintf(stderr, "Error allocating BOOT_IMAGE string: ");
   3.311 -	goto bail;
   3.312 +	errmsg = "Error allocating BOOT_IMAGE string: ";
   3.313 +	goto bailmsg;
   3.314      }
   3.315      strcpy(boot_image, "BOOT_IMAGE=");
   3.316      strcpy(boot_image + 11, kernel_name);
   3.317 @@ -1008,20 +1032,20 @@
   3.318      errno = 0;
   3.319      cmdline = make_cmdline(argp);
   3.320      if (!cmdline) {
   3.321 -	fprintf(stderr, "make_cmdline() failed: ");
   3.322 -	goto bail;
   3.323 +	errmsg = "make_cmdline() failed: ";
   3.324 +	goto bailmsg;
   3.325      }
   3.326  
   3.327      /* Initialize the initramfs chain */
   3.328      errno = 0;
   3.329      initramfs = initramfs_init();
   3.330      if (!initramfs) {
   3.331 -	fprintf(stderr, "initramfs_init() failed: ");
   3.332 -	goto bail;
   3.333 +	errmsg = "initramfs_init() failed: ";
   3.334 +	goto bailmsg;
   3.335      }
   3.336  
   3.337      if ((arg = find_argument(argp, "initrd="))) {
   3.338 -	do {
   3.339 +	while (1) {
   3.340  	    p = strchr(arg, ',');
   3.341  	    if (p)
   3.342  		*p = '\0';
   3.343 @@ -1039,9 +1063,12 @@
   3.344  	    if (!opt_quiet)
   3.345  		printf("ok\n");
   3.346  
   3.347 -	    if (p)
   3.348 -		*p++ = ',';
   3.349 -	} while ((arg = p));
   3.350 +	    if (!p)
   3.351 +		break;
   3.352 +
   3.353 +	    *p++ = ',';
   3.354 +	    arg = p;
   3.355 +	}
   3.356      }
   3.357  
   3.358      /* Append the DHCP info */
   3.359 @@ -1050,8 +1077,8 @@
   3.360  	errno = 0;
   3.361  	if (initramfs_add_file(initramfs, dhcpdata, dhcplen, dhcplen,
   3.362  			       "/dhcpinfo.dat", 0, 0755)) {
   3.363 -	    fprintf(stderr, "Unable to add DHCP info: ");
   3.364 -	    goto bail;
   3.365 +	    errmsg = "Unable to add DHCP info: ";
   3.366 +	    goto bailmsg;
   3.367  	}
   3.368      }
   3.369  
   3.370 @@ -1078,10 +1105,7 @@
   3.371  	    char *ep;
   3.372  
   3.373  	    type = strtoul(arg + 5, &ep, 10);
   3.374 -	    if (ep[0] != '=' || !ep[1])
   3.375 -		continue;
   3.376 -
   3.377 -	    if (!type)
   3.378 +	    if (!type || ep[0] != '=' || !ep[1])
   3.379  		continue;
   3.380  
   3.381  	    if (setup_data_file(setup_data, type, ep+1, opt_quiet))
   3.382 @@ -1093,27 +1117,28 @@
   3.383      errno = 0;
   3.384      syslinux_boot_linux(kernel_data, kernel_len, initramfs,
   3.385  			setup_data, cmdline);
   3.386 -    fprintf(stderr, "syslinux_boot_linux() failed: ");
   3.387 +    errmsg = "syslinux_boot_linux() failed: ";
   3.388  
   3.389 +bailmsg:
   3.390 +    fprintf(stderr, errmsg);
   3.391  bail:
   3.392 +    errmsg = "Error %d";
   3.393      switch(errno) {
   3.394      case ENOENT:
   3.395 -	fprintf(stderr, "File not found\n");
   3.396 +	errmsg = "File not found";
   3.397  	break;
   3.398      case ENOMEM:
   3.399 -	fprintf(stderr, "Out of memory\n");
   3.400 -	break;
   3.401 -    default:
   3.402 -	fprintf(stderr, "Error %d\n", errno);
   3.403 -	break;
   3.404 +	errmsg = "Out of memory";
   3.405      }
   3.406 -    fprintf(stderr, "%luM RAM found on this %s bits machine.\n",
   3.407 +    fprintf(stderr, errmsg, errno);
   3.408 +    fprintf(stderr, "\n%luM RAM and %s bit cpu found.\n%s: Boot aborted!\n",
   3.409  		    memory_size() >> 10,
   3.410 -    		    cpu_has_feature(X86_FEATURE_LM) ? "64": "32");
   3.411 -    fprintf(stderr, "%s: Boot aborted!\n", progname);
   3.412 +    		    cpu_has_feature(X86_FEATURE_LM) ? "64": "32",
   3.413 +		    progname);
   3.414      return 1;
   3.415  }
   3.416  
   3.417 +#ifdef EXTRA
   3.418  static int main_setarg(int argc, char *argv[])
   3.419  {
   3.420  	if (argc < 3) {
   3.421 @@ -1191,6 +1216,7 @@
   3.422      sleep(5);
   3.423      return 0;
   3.424  }
   3.425 +#endif
   3.426  
   3.427  int main(int argc, char *argv[])
   3.428  {
   3.429 @@ -1199,16 +1225,19 @@
   3.430  		char *name;
   3.431  		int (*main)(int argc, char *argv[]);
   3.432  	} bin[] = {
   3.433 +#ifdef EXTRA
   3.434  		{ "say",	main_say      },
   3.435 -		{ "md5sum",	main_md5sum   },
   3.436 -		{ "ifmem",	main_ifmem    },
   3.437 -		{ "reboot",	main_reboot   },
   3.438 -		{ "poweroff",	main_poweroff },
   3.439 -		{ "kbdmap",	main_kbdmap   },
   3.440 -		{ "linux",	main_linux    },
   3.441  		{ "setarg",	main_setarg   },
   3.442  		{ "ifarg",	main_ifarg    },
   3.443 -		{ "listarg",	main_listarg  }
   3.444 +		{ "listarg",	main_listarg  },
   3.445 +#endif
   3.446 +		{ "kbdmap",	main_kbdmap   },
   3.447 +		{ "kbd",	main_kbdmap   },
   3.448 +		{ "ifmem",	main_ifmem    },
   3.449 +		{ "linux",	main_linux    },
   3.450 +		{ "md5sum",	main_md5sum   },
   3.451 +		{ "reboot",	main_reboot   },
   3.452 +		{ "poweroff",	main_poweroff }
   3.453  	};
   3.454  
   3.455  	openconsole(&dev_null_r, &dev_stdcon_w);
     4.1 --- a/syslinux/stuff/iso2exe/Makefile	Fri Nov 03 11:59:19 2017 +0100
     4.2 +++ b/syslinux/stuff/iso2exe/Makefile	Fri Nov 03 15:07:20 2017 +0100
     4.3 @@ -30,7 +30,7 @@
     4.4  	./iso2exe.sh --array ../mbr/isohdpfx.bin > $@
     4.5  
     4.6  iso2exe.com: iso2exe.c iso2exe.h
     4.7 -	$(BCC) $(BCCFLAGS) -o $@ iso2exe.c && upx --ultra-brute $@
     4.8 +	$(BCC) $(BCCFLAGS) -o $@ iso2exe.c && upx -5 --8086 $@
     4.9  
    4.10  iso2exe.exe: iso2exe.c iso2exe.h isohybrid.res
    4.11  	i586-pc-mingw32-gcc -Os -s -o $@ iso2exe.c isohybrid.res -lws2_32
     5.1 --- a/syslinux/stuff/iso2exe/bootiso.S	Fri Nov 03 11:59:19 2017 +0100
     5.2 +++ b/syslinux/stuff/iso2exe/bootiso.S	Fri Nov 03 15:07:20 2017 +0100
     5.3 @@ -1,5 +1,6 @@
     5.4  	.text
     5.5  	.code16
     5.6 +	.arch	i8086
     5.7  	.org	0
     5.8  
     5.9  CODESZ	=	0x8000			// 16 sectors = 32Kb
    5.10 @@ -19,6 +20,7 @@
    5.11  	.word	4064-(CODESZ/16)	// Maximum extra paragraphs needed
    5.12  	.word	0xFFF0			// Initial (relative) SS value
    5.13  	.word	0xFFFE			// Initial SP value
    5.14 +magic:
    5.15  	.word	0			// Checksum
    5.16  	.word	EXEADRS(exestart)	// Initial IP value
    5.17  	.word	0xFFF0			// Initial (relative) CS value
    5.18 @@ -32,14 +34,16 @@
    5.19  
    5.20  moved	=	0x8000
    5.21  start0:
    5.22 -	pushw	%dx			// restore %sp
    5.23 -	incw	%bp			// restore %bp
    5.24 +	//pushw	%dx			// restore %sp
    5.25 +	//incw	%bp			// restore %bp
    5.26  	xorw	%bx, %bx
    5.27  	movw	%bx, %ds
    5.28  	movb	$0x7C, %bh
    5.29 +	pushw	%ds
    5.30 +	popw	%ss
    5.31 +	movw	%bx, %sp
    5.32  	pushw	%bx			// return address
    5.33 -	pushaw
    5.34 -	movw	%sp, %bp
    5.35 +	pushw	%di
    5.36  	pushw	%es			// save %es:%di
    5.37  	cld
    5.38  	sti
    5.39 @@ -47,7 +51,7 @@
    5.40  	popw	%es
    5.41  	call	setreg
    5.42  	rep
    5.43 -	movsw
    5.44 +	  movsw
    5.45  	movw	$0x80, %dx
    5.46  	ljmp	$0, $moved+start2
    5.47  	.byte	0
    5.48 @@ -71,11 +75,11 @@
    5.49  
    5.50  dxfound:
    5.51  	call	readsectorX		// read isolinux boot sector
    5.52 -	movw	%dx, 10(%bp)
    5.53  	cmpw	(%bx), %cx
    5.54  	jnc	puts			// read fail or no isohydrid boot sector
    5.55 +	movw	$patch,%si
    5.56  	popw	%es
    5.57 -	popa				// isolinux boot needs %es:%di and %dx
    5.58 +	popw	%di			// isolinux boot needs %es:%di and %dx
    5.59  putsret:
    5.60  	ret
    5.61  
    5.62 @@ -118,12 +122,67 @@
    5.63  	ret
    5.64  	.org	0x01B8
    5.65  
    5.66 -	.org	0x7F48
    5.67 +////////////////////////// partition boot code ////////////////////////////////
    5.68 +// assume DS=SS BX=7C00 CH=01 DL=<drive> SI=7DBE
    5.69 +
    5.70 +	.org	0x7C00
    5.71 +	jmp	bootpartition
    5.72 +	.org	0x7C03
    5.73 +	.org	0x7DBE
    5.74 +table	=	moved+0x1BE
    5.75 +patch:
    5.76 +	.byte	0,0,0			// head of original bs
    5.77 +partcode:
    5.78 +	popw	%si
    5.79 +	xchgw	%si,%di
    5.80 +	call	movepartition
    5.81 +	pushw	%cx
    5.82 +	pushw	%cx
    5.83 +	decw	%di
    5.84 +	decw	%di
    5.85 +	movb	$4,%cl
    5.86 +	movw	$16,%ax
    5.87 +next:
    5.88 +	subw	%ax,%di
    5.89 +	cmpb	%ch,(%di)		// boot flag ?
    5.90 +	loope	next
    5.91 +	pushw	10(%di)
    5.92 +	pushw	8(%di)
    5.93 +	pushw	%cs
    5.94 +	pushw	%bx
    5.95 +	movb	$1,%cl
    5.96 +	pushw	%cx
    5.97 +	pushw	%ax
    5.98 +	movw	%sp,%si			// assume %ds = %ss
    5.99 +	pushw	%bx
   5.100 +	cmpw	$63,2(%di)		// empty or isolinux partition ?
   5.101 +	jbe	default
   5.102 +	movb	$0x42,%ah
   5.103 +	int	$0x13
   5.104 +default:
   5.105 +	ret
   5.106 +	.org	0x7DF0
   5.107 +bootpartition:
   5.108 +	pushw	%ds
   5.109 +	popw	%es
   5.110 +	pushw	%si
   5.111 +	movw	%bx,%di
   5.112 +	movsw
   5.113 +	movsb
   5.114 +	movw	$table-0x142,%di
   5.115 +	pushw	%di
   5.116 +movepartition:
   5.117 +	movb	$66,%cl			// 0142 and 0042
   5.118 +	rep
   5.119 +	  movsb
   5.120 +	ret
   5.121 +	.org	0x7E00
   5.122 +
   5.123 +	.org	0x7F83
   5.124  ////////////////////////////// DOS EXE code ///////////////////////////////////
   5.125  
   5.126  exestart:
   5.127  	cld
   5.128 -	movw	$EXEADRS(puts), %bp	
   5.129  	movw	129, %ax
   5.130  	cmpb	$0x2F, %al
   5.131  	je	ishelp
   5.132 @@ -135,38 +194,34 @@
   5.133  	je	abort
   5.134  	int	$0x21			// get DOS version
   5.135  	addb	$-3, %al
   5.136 -	movw	$0xF000+EXESTR(noDOS3), %ax
   5.137 +	movb	$EXESTR(noDOS3), %al
   5.138  	movw	$0x100, %di
   5.139  	jc	tst386
   5.140  abort:
   5.141 -	jmp	*%bp
   5.142 +goputs:
   5.143 +	jmp	puts
   5.144  
   5.145  tst386:
   5.146 -	pushfw				// save flags
   5.147 -		// bits  15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
   5.148 -		// flags  0 NT  IOPL OF DF IF TF SF ZF  0 AF  0 PF  1 CF
   5.149 -	// movb	$0xF0, %ah
   5.150 -	pushw	%ax
   5.151 -	popfw				// < 286 : flags[12..15] are forced 1
   5.152 -	pushfw				// = 286 : flags[12..15] are forced 0
   5.153 -	popw	%bx			// > 286 : only flags[15] is forced 0
   5.154 -	popfw				// restore flags (IOPL)
   5.155 -	addb	%ah, %bh		// test F0 and 00 cases
   5.156 -	js	is86			// NS=386+, NC=286
   5.157 +	pushw	%sp
   5.158 +	popw	%ax
   5.159 +	xorw	%sp, %ax		// clear C
   5.160 +	movb	$EXESTR(vm86modemsg), %al
   5.161 +	jnz	is86			// 86/186 not a 286+
   5.162 +	.arch	i486
   5.163  is386:
   5.164 -	smsww	%ax			// not privileged
   5.165 -	andb	$1, %al
   5.166 -	movw	$10, %si
   5.167 -	jne	tstvcpi
   5.168 -	movl	%cr0, %eax		// privileged
   5.169 -	incl	%eax
   5.170 +	smsww	%bx			// not privileged
   5.171 +	andb	$1, %bl			// clear C
   5.172 +	jne	isvm86
   5.173 +	movl	%cr0, %ebx		// privileged
   5.174 +	incl	%ebx
   5.175 +	.arch	i8086
   5.176  	movb	$EXESTR(rmPaging), %al
   5.177  	js	abort
   5.178 -	inc	%ax
   5.179 +is86:
   5.180 +	incw	%ax
   5.181  	//movb	$EXESTR(realmodemsg), %al
   5.182 -realmode:
   5.183 -	call	*%bp
   5.184 -is86:
   5.185 +isvm86:
   5.186 +	call	goputs
   5.187  	movw	comstart-end_header(%di), %si		// .com address
   5.188  	pushw	%di
   5.189  	movb	$0x7C/2, %ch		// 31K-31.5K, > com length
   5.190 @@ -174,49 +229,11 @@
   5.191  	movsw
   5.192  	ret
   5.193  
   5.194 -CallVCPI:
   5.195 -	int	$0x67
   5.196 -	testb	%ah, %ah
   5.197 -	xchgw	%ax, %cx
   5.198 -	pushw	%si
   5.199 -ScanVCPI:
   5.200 -	popw	%si
   5.201 -ChkVCPI:
   5.202 -NoVCPI:
   5.203 -	movb	$EXESTR(ERRvcpi), %al
   5.204 -	jne	abort
   5.205 -	lodsb
   5.206 -	shlw	$8, %ax
   5.207 -	jne	CallVCPI
   5.208 -VersionVCPI:
   5.209 -	xchgw	%ax, %si		// movb	$EXESTR(vm86modemsg), %al
   5.210 -	cmpb	$0x40, %cl		// EMM386 / VCPI 4.0 mini
   5.211 -	jnc	realmode		// %si = 0
   5.212 -tstvcpi:
   5.213 -	pushw	%ds
   5.214 -	movw	%si, %ds		// %si = 10
   5.215 -	movw	(0x67*4)+2-(16*10)-0x100(%di), %ds
   5.216 -	lodsw
   5.217 -	xorw	$0x4D45, %ax		// EM(MX) or EM(MQ)
   5.218 -	lodsw
   5.219 -	lodsw
   5.220 -	popw	%ds
   5.221 -	jne	NoVCPI
   5.222 -	xorw	$0x5858, %ax		// XX(X0)
   5.223 -	call	ScanVCPI
   5.224 -CmdVCPI:
   5.225 -	.byte	0x40			// status
   5.226 -	.byte	0xDE			// vcpi present ?
   5.227 -	.byte	0x46			// version
   5.228 -	.byte	0
   5.229 -
   5.230  vm86modemsg:
   5.231  // --------------- Must be in 7F40 7FFF range ------------------------
   5.232 +	.ascii	"v"			// v86 mode
   5.233  	.ascii	"86"			// 86 mode
   5.234  	.byte	EXESTR(mode)
   5.235 -ERRvcpi:
   5.236 -	.ascii	"VCPI4"			// VCPI4?
   5.237 -	.byte	EXESTR(need)
   5.238  rmPaging:
   5.239  	.ascii	"X"			// Xreal mode
   5.240  realmodemsg:
     6.1 --- a/syslinux/stuff/iso2exe/init	Fri Nov 03 11:59:19 2017 +0100
     6.2 +++ b/syslinux/stuff/iso2exe/init	Fri Nov 03 15:07:20 2017 +0100
     6.3 @@ -138,7 +138,7 @@
     6.4  
     6.5  checkmagic()
     6.6  {
     6.7 -	[ -s $1 ] && [ $(getarg magic) == $(get 24 $1 4) ]
     6.8 +	[ -s $1 ] && [ $(getarg magic) == $(get 18 $1 2) ]
     6.9  }
    6.10  
    6.11  getiso()
    6.12 @@ -826,7 +826,7 @@
    6.13  	gotcdfile isolinux.cfg
    6.14  	parse_isolinux < $file > /tmp/var$$
    6.15  	. /tmp/var$$
    6.16 -	for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
    6.17 +	for i in /media/cdrom/$KERNEL $(dirname $file)/$KERNEL /media/cdrom/$(locase $KERNEL) \
    6.18  		 $(dirname $file)/$(locase $KERNEL); do
    6.19  		[ -s $i ] && KERNEL=$i && break
    6.20  	done
    6.21 @@ -856,7 +856,7 @@
    6.22  	if [ "$INITRD" ]; then
    6.23  		l=0
    6.24  		for i in ${INITRD//,/ }; do
    6.25 -			for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
    6.26 +			for j in /media/cdrom/$i $(dirname $KERNEL)/$i /media/cdrom/$(locase $i) \
    6.27  				 $(dirname $KERNEL)/$(locase $i); do
    6.28  				[ -s $j ] && i=$j && break
    6.29  			done
    6.30 @@ -912,6 +912,7 @@
    6.31  		n=$(($n+1))
    6.32  	done | sh
    6.33  	ls fd???.img
    6.34 +	mv fd???.img /mnt
    6.35  }
    6.36  
    6.37  fdbootstrap()
     7.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Fri Nov 03 11:59:19 2017 +0100
     7.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Fri Nov 03 15:07:20 2017 +0100
     7.3 @@ -34,21 +34,8 @@
     7.4  add_rootfs()
     7.5  {
     7.6  	TMP=/tmp/iso2exe$$
     7.7 -	mkdir -p $TMP/dev
     7.8 -	cp -a /dev/tty /dev/tty0 $TMP/dev
     7.9 -	$0 --get init > $TMP/init.exe
    7.10 -#	mount -o loop,ro $1 $TMP
    7.11 -#	oldslitaz="$(ls $TMP/boot/isolinux/splash.lss 2> /dev/null)"
    7.12 -#	umount -d $TMP
    7.13 -#	[ "$oldslitaz" ] && # for SliTaz <= 3.0 only...
    7.14 -#	grep -q mount.posixovl.iso2exe $TMP/init.exe && mkdir $TMP/bin &&
    7.15 -#	cp /usr/sbin/mount.posixovl $TMP/bin/mount.posixovl.iso2exe \
    7.16 -#		2> /dev/null && echo "Store mount.posixovl ($(wc -c \
    7.17 -#			< /usr/sbin/mount.posixovl) bytes) ..."
    7.18 -	find $TMP -type f -print0 | xargs -0 chmod +x
    7.19 -	find $TMP -print0 | xargs -0 touch -t 197001010100.00 
    7.20 -	( cd $TMP ; find * | grep -v rootfs.gz | cpio -o -H newc ) | \
    7.21 -		compress $TMP/rootfs.gz
    7.22 +	mkdir -p $TMP
    7.23 +	$0 --get rootfs.gz > $TMP/rootfs.gz
    7.24  	SIZE=$(wc -c < $TMP/rootfs.gz)
    7.25  	store 24 $SIZE $1
    7.26  	OFS=$(( $OFS - $SIZE ))
    7.27 @@ -62,7 +49,7 @@
    7.28  	TMP=/tmp/bootiso$$
    7.29  	$0 --get bootiso.bin > $TMP 2> /dev/null 
    7.30  	OFS=$(($(get 20 $TMP) - 0xC0))
    7.31 -	printf "Adding DOS/EXE stub at %04X (%d bytes) ...\n" $OFS $((0x8000 - $OFS))
    7.32 +	printf "Adding DOS/EXE stub at %04X (%d bytes) ...\n" $OFS $((0x7FF0 - $OFS))
    7.33  	ddq if=$TMP bs=1 skip=$OFS of=$1 seek=$OFS conv=notrunc
    7.34  	rm -f $TMP
    7.35  }
    7.36 @@ -105,7 +92,7 @@
    7.37  		i=3; [ -n "$mac" ] && i=9
    7.38  		ddq if=/tmp/exe$$ bs=512 skip=1 of=$1 seek=$i conv=notrunc
    7.39  		for i in 12C 154 17C ; do	# always 3 UPX sections
    7.40 -			store $((0x$i)) $((1024 + $(get 0x$i $1))) $1 2
    7.41 +			store $((0x$i)) $((1024 + $(get 0x$i $1))) $1
    7.42  		done
    7.43  	fi
    7.44  	printf "Adding bootiso head at %04X...\n" 0
    7.45 @@ -118,12 +105,22 @@
    7.46  	ddq if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc
    7.47  	ddq if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 conv=notrunc
    7.48  	store 510 $((0xAA55)) $1
    7.49 -	rm -f /tmp/exe$$ /tmp/coff$$
    7.50  	i=$SIZE; OFS=$(($SIZE+512))
    7.51  	[ -n "$mac" ] && OFS=$SIZE && i=1536
    7.52  	store 417 $(($i/512)) $1 8
    7.53  	printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $i
    7.54  	ddq if=$2 bs=1 count=512 of=$1 seek=$i conv=notrunc
    7.55 +	if [ $(get $((0x7C00)) /tmp/exe$$) -eq 60905 ]; then
    7.56 +		ddq if=/tmp/exe$$ bs=1 count=66 skip=$((0x7DBE)) of=$1 seek=$(($i + 0x1BE)) conv=notrunc
    7.57 +		ddq if=$1 bs=1 count=3 skip=$i of=$1 seek=$(($i + 0x1BE)) conv=notrunc
    7.58 +		ddq if=/tmp/exe$$ bs=1 count=3 skip=$((0x7C00)) of=$1 seek=$i conv=notrunc
    7.59 +	fi
    7.60 +	rm -f /tmp/exe$$ /tmp/coff$$
    7.61 +	if [ -z "$RECURSIVE_PARTITION" -a $(get 470 $1 4) -eq 0 ]; then
    7.62 +		store 464 $((1+$i/512)) $1 8
    7.63 +		store 470 $(($i/512)) $1 8
    7.64 +		store 474 $(($(get 474 $1 4) - $i/512)) $1 32
    7.65 +	fi
    7.66  }
    7.67  
    7.68  add_fdbootstrap()
    7.69 @@ -144,12 +141,12 @@
    7.70  gzsize()
    7.71  {
    7.72  	echo $(($(hexdump -C | awk ' {
    7.73 -		for (i = 2; i < 18; i++) if ($i != "00") break;
    7.74 -		if (i == 18) {
    7.75 -			for (i = 17; i > 1; i--) if ($i != "00") break;
    7.76 -			print "0x" $1 " + 7 - " (16 - i) 
    7.77 +		for (i = 17; i > 1; i--) if ($i != "00") break;
    7.78 +		if (i == 1) {
    7.79 +			print "0x" $1 " + 1 + 1 - " n
    7.80  			exit
    7.81  		}
    7.82 +		n = 17 - i
    7.83  	}')))
    7.84  }
    7.85  
    7.86 @@ -175,7 +172,7 @@
    7.87  	rootfs.gz)	SIZE=$(get 24 "$ISO"); OFFSET=$(($stub - $SIZE));;
    7.88  	tazboot.com)	OFFSET=$(($(get 64 "$ISO") - 0xC0))
    7.89  			SIZE=$(($stub - $(get 24 "$ISO") - $OFFSET));;
    7.90 -	dosstub)	OFFSET=$stub; SIZE=$((0x8000 - $OFFSET));;
    7.91 +	dosstub)	OFFSET=$stub; SIZE=$((0x7FF0 - $OFFSET));;
    7.92  	boot.md5)	OFFSET=$((0x7FF0)); SIZE=16;;
    7.93  	fs.iso)		OFFSET=$((0x8000))
    7.94  			SIZE=$((2048*$c - $OFFSET));;
    7.95 @@ -193,6 +190,53 @@
    7.96  	esac
    7.97  }
    7.98  
    7.99 +trailer()
   7.100 +{
   7.101 +	OFFSET=$(stat -c %s "$1")
   7.102 +	[ $OFFSET -gt $HEAP ] &&
   7.103 +	printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET
   7.104 +	if [ $(get 510 "$1") -eq 43605 ]; then
   7.105 +		echo "MBR partitions :"
   7.106 +		for i in 0 1 2 3; do
   7.107 +			SIZE=$(get $((446+12+16*i)) "$1" 4)
   7.108 +			[ $SIZE -eq 0 ] && continue
   7.109 +			OFFSET=$(get $((446+8+16*i)) "$1" 4)
   7.110 +			printf " $i:%08X  %08X  %02X\n" $OFFSET $SIZE \
   7.111 +				$(get $((446+4+16*i)) "$1" 1)
   7.112 +		done
   7.113 +		if [ $(get 466 "$1") -eq 65263 ]; then
   7.114 +			echo "EFI partitions :"
   7.115 +			n=$(get 584 "$1" 1)
   7.116 +			s=$(get 596 "$1")
   7.117 +			o=$((($(get 552 "$1" 1)*512)-($(get 592 "$1")*$s)))
   7.118 +			i=0
   7.119 +			while [ $n -gt $i ]; do
   7.120 +				f=$(get $(($o+0x20)) "$1" 4)
   7.121 +				l=$(($(get $(($o+0x28)) "$1" 4)-$f))
   7.122 +				[ $l -eq 0 ] && break
   7.123 +				printf " $i:%08X  %08X  %s\n" $f $(($l+1)) \
   7.124 +				"$(od -An -N 36 -w -j $(($o+0x38)) -t a "$1" \
   7.125 +				 | sed 's/\( nul\)*//g;s/   //g;s/ sp//')"
   7.126 +				o=$(($o+$s))
   7.127 +				i=$(($i+1))
   7.128 +			done
   7.129 +		fi
   7.130 +	fi
   7.131 +	o=2048
   7.132 +	if [ $(get $o "$1") -eq 19792 ]; then
   7.133 +		echo "Apple partitions :"
   7.134 +		i=0
   7.135 +		while [ $(get $o "$1") -eq 19792 ]; do
   7.136 +			f=$((0x$(od -An -N 4 -j $(($o+8)) -t x1 "$1" | sed 's/ //g')))
   7.137 +			l=$((0x$(od -An -N 4 -j $(($o+0x54)) -t x1 "$1" | sed 's/ //g')))
   7.138 +			printf " $i:%08X  %08X  %s\n" $f $l \
   7.139 +			"$(ddq bs=1 skip=$(($o+16)) count=32 if="$1")"
   7.140 +			o=$(($o+2048))
   7.141 +			i=$(($i+1))
   7.142 +		done
   7.143 +	fi
   7.144 +}
   7.145 +
   7.146  list()
   7.147  {
   7.148  	HEAP=0
   7.149 @@ -209,49 +253,25 @@
   7.150  		[ $OFFSET -ge $HEAP ] && HEAP=$(($OFFSET+$SIZE))
   7.151  		printf "$f at %04X ($SIZE bytes).\n" $OFFSET
   7.152  	done
   7.153 -	OFFSET=$(stat -c %s "$ISO")
   7.154 -	[ $OFFSET -gt $HEAP ] &&
   7.155 -	printf "%d free bytes in %04X..%04X\n" $(($OFFSET - $HEAP)) $HEAP $OFFSET
   7.156 -	if [ $(get 510 "$ISO") -eq 43605 ]; then
   7.157 -		echo "MBR partitions :"
   7.158 -		for i in 0 1 2 3; do
   7.159 -			SIZE=$(get $((446+12+16*i)) "$ISO" 4)
   7.160 -			[ $SIZE -eq 0 ] && continue
   7.161 -			OFFSET=$(get $((446+8+16*i)) "$ISO" 4)
   7.162 -			printf " $i:%08X  %08X  %02X\n" $OFFSET $SIZE \
   7.163 -				$(get $((446+4+16*i)) "$ISO" 1)
   7.164 -		done
   7.165 -		if [ $(get 466 "$ISO") -eq 65263 ]; then
   7.166 -			echo "EFI partitions :"
   7.167 -			n=$(get 584 "$ISO" 1)
   7.168 -			s=$(get 596 "$ISO")
   7.169 -			o=$((($(get 552 "$ISO" 1)*512)-($(get 592 "$ISO")*$s)))
   7.170 -			i=0
   7.171 -			while [ $n -gt $i ]; do
   7.172 -				f=$(get $(($o+0x20)) "$ISO" 4)
   7.173 -				l=$(($(get $(($o+0x28)) "$ISO" 4)-$f))
   7.174 -				[ $l -eq 0 ] && break
   7.175 -				printf " $i:%08X  %08X  %s\n" $f $(($l+1)) \
   7.176 -				"$(od -An -N 36 -w -j $(($o+0x38)) -t a "$ISO" \
   7.177 -				 | sed 's/\( nul\)*//g;s/   //g;s/ sp//')"
   7.178 -				o=$(($o+$s))
   7.179 -				i=$(($i+1))
   7.180 +	trailer $ISO
   7.181 +}
   7.182 +
   7.183 +restore_hybrid_mbr()
   7.184 +{
   7.185 +	if [ $(get 0 "$1") -eq 60905 ]; then
   7.186 +		ddq bs=1 conv=notrunc if="$1" of="$1" skip=$((0x1BE)) seek=0 count=3
   7.187 +		ddq bs=1 skip=$((0x1BE)) count=66 if="$2" | \
   7.188 +			ddq bs=1 seek=$((0x1BE)) count=66 of="$1" conv=notrunc
   7.189 +		if [ -n "$RECURSIVE_PARTITION" ]; then
   7.190 +			for i in 0 1 2 3 ; do
   7.191 +				n=$(get $((0x1C6+16*i)) $1 4)
   7.192 +				[ $n -eq 0 -o $n -gt 64 ] && continue
   7.193 +				store $((0x1C0+16*i)) 1 $1 8
   7.194 +				store $((0x1C6+16*i)) 0 $1 32
   7.195 +				store $((0x1CA+16*i)) $(($(get $((0x1CA+16*i)) $1 4)+$n)) $1 32
   7.196  			done
   7.197  		fi
   7.198  	fi
   7.199 -	o=2048
   7.200 -	if [ $(get $o "$ISO") -eq 19792 ]; then
   7.201 -		echo "Apple partitions :"
   7.202 -		i=0
   7.203 -		while [ $(get $o "$ISO") -eq 19792 ]; do
   7.204 -			f=$((0x$(od -An -N 4 -j $(($o+8)) -t x1 "$ISO" | sed 's/ //g')))
   7.205 -			l=$((0x$(od -An -N 4 -j $(($o+0x54)) -t x1 "$ISO" | sed 's/ //g')))
   7.206 -			printf " $i:%08X  %08X  %s\n" $f $l \
   7.207 -			"$(ddq bs=1 skip=$(($o+16)) count=32 if="$ISO")"
   7.208 -			o=$(($o+2048))
   7.209 -			i=$(($i+1))
   7.210 -		done
   7.211 -	fi
   7.212  }
   7.213  
   7.214  extract()
   7.215 @@ -260,6 +280,7 @@
   7.216  		fileofs $f
   7.217  		[ $SIZE -eq 0 ] ||
   7.218  		ddq bs=1 count=$SIZE skip=$OFFSET if="$ISO" >$f
   7.219 +		[ "$f" == "syslinux.mbr" ] && restore_hybrid_mbr "$f" "$ISO"
   7.220  	done
   7.221  }
   7.222  
   7.223 @@ -278,9 +299,17 @@
   7.224  case "$1" in
   7.225  --build)
   7.226  	shift
   7.227 -	ls -l $@
   7.228 +	TMP=/tmp/iso2exe$$
   7.229 +	mkdir -p $TMP/dev
   7.230 +	cp -a /dev/tty /dev/tty0 $TMP/dev
   7.231 +	cat init > $TMP/init.exe
   7.232 +	find $TMP -type f -print0 | xargs -0 chmod +x
   7.233 +	find $TMP -print0 | xargs -0 touch -t 197001010100.00 
   7.234 +	( cd $TMP; find dev init.exe | cpio -o -H newc ) | compress rootfs.gz
   7.235 +	rm -rf $TMP
   7.236 +	ls -l $@ rootfs.gz
   7.237  	cat >> $0 <<EOM
   7.238 -$(tar cf - $@ | compress | uuencode -m -)
   7.239 +$(tar cf - ${@/init/rootfs.gz} | compress | uuencode -m -)
   7.240  EOT
   7.241  EOM
   7.242  	sed -i '/^case/,/^esac/d' $0
   7.243 @@ -493,7 +522,10 @@
   7.244  	    23117)
   7.245  		b=$(get 417 $1 1)
   7.246  		n=$(($(get 64 $1) + 0xC0 - ($(get 26 $1 1)*512) - ($b+1)*512))
   7.247 -		ddq if=$1 bs=512 count=1 skip=$b of=$1 conv=notrunc
   7.248 +		ddq if=$1 bs=512 count=1 skip=$b of=/tmp/hymbr$$
   7.249 +		restore_hybrid_mbr /tmp/hymbr$$ $1
   7.250 +		ddq if=/tmp/hymbr$$ of=$1 conv=notrunc
   7.251 +		rm -f /tmp/hymbr$$
   7.252  		if [ $(get 512 $1) -eq 17989 ]; then
   7.253  			n=$(($(get 0x25C $1)/512))
   7.254  			ddq if=$1 bs=512 seek=44 count=20 skip=$n of=$1 conv=notrunc
   7.255 @@ -517,7 +549,7 @@
   7.256  	esac
   7.257  	case "$(get 0 $1)" in
   7.258  	23117)	echo "The file $1 is already an EXE file." 1>&2 && exit 1;;
   7.259 -	0)	[ -x /usr/bin/isohybrid ] && isohybrid $1;;
   7.260 +	0)	[ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;;
   7.261  	esac
   7.262  
   7.263  	gpt= ; [ $(get 466 $1) -eq 65263 ] && gpt=1
   7.264 @@ -551,6 +583,7 @@
   7.265  			md5sum | cut -c-32 | sed 's/\(..\)/\\x\1/g')" | \
   7.266  			ddq bs=16 seek=2047 conv=notrunc of=$1
   7.267  	fi
   7.268 +	HEAP=$(($(custom_config_sector $1)*2048))
   7.269  	if [ "$append$initrd" ]; then
   7.270  		echo -n "Adding custom config... "
   7.271  		DATA=/tmp/$(basename $0)$$
   7.272 @@ -560,16 +593,17 @@
   7.273  		[ -s "$initrd" ] && echo "initrd:$(stat -c %s $initrd)" >> $DATA &&
   7.274  			cat $initrd >> $DATA
   7.275  		echo "#!boot $(md5sum $DATA | sed 's/ .*//')" | cat - $DATA | \
   7.276 -		ddq bs=2k seek=$(custom_config_sector $1) of=$1 conv=notrunc
   7.277 +		ddq bs=2k seek=$(custom_config_sector $1) of=$1
   7.278  		newsz=$(stat -c %s $1)
   7.279 +		mb=$(((($newsz -1)/1048576)+1))
   7.280 +		HEAP=$(($mb*1048576))
   7.281 +		ddq bs=1048576 seek=$mb count=0 of=$1
   7.282 +		h=$(get 417 "$1" 1)
   7.283 +		[ -z "$RECURSIVE_PARTITION" ] || h=0
   7.284  		for i in 0 1 2 3 ; do
   7.285 -			[ $(get $((0x1BE+16*i)) $1 4) == $((0x00010080)) ] || continue
   7.286 -			mb=$(((($newsz -1)/1024/1024)+1))
   7.287 -			h=$((512*$(get 417 "$1" 1)))
   7.288 +			[ $(get $((0x1BE+16*i)) $1 2) == $((0x0080)) ] || continue
   7.289 +			store $((0x1CA+16*i)) $(($mb*2048-$h)) $1 32
   7.290  			store $((0x1C5+16*i)) $(($mb-1)) $1 8
   7.291 -			store $(($h+0x1C5+16*i)) $(($mb-1)) $1 8
   7.292 -			store $((0x1CA+16*i)) $(($mb*2048)) $1 32
   7.293 -			store $(($h+0x1CA+16*i)) $(($mb*2048)) $1 32
   7.294  		done
   7.295  		if [ $newsz -gt $isosz ]; then
   7.296  			echo "$(($newsz - $isosz)) extra bytes."
   7.297 @@ -588,6 +622,7 @@
   7.298  		store 18 $(( (-$n -1) % 65536 )) $1
   7.299  	fi
   7.300  	echo " done."
   7.301 +	trailer $1
   7.302  }
   7.303  
   7.304  main "$@" <<EOT
     8.1 --- a/syslinux/stuff/iso2exe/win32.c	Fri Nov 03 11:59:19 2017 +0100
     8.2 +++ b/syslinux/stuff/iso2exe/win32.c	Fri Nov 03 15:07:20 2017 +0100
     8.3 @@ -4,6 +4,7 @@
     8.4  #include <sys/stat.h>
     8.5  #include <fcntl.h>
     8.6  
     8.7 +#define VCPI_LINUX_LOADER The DOS/EXE loader can boot in VM86 using VCPI API
     8.8  #define BOOTSTRAP_SECTOR_COUNT_OFFSET	26
     8.9  
    8.10  static int fullread(int fd, char *p, int n)
    8.11 @@ -28,6 +29,7 @@
    8.12  #define write fullwrite
    8.13  }
    8.14  
    8.15 +#ifdef VCPI_LINUX_LOADER
    8.16  static void exec16bits(char *isoFileName)
    8.17  {
    8.18  	int fdiso, fdtmp, i;
    8.19 @@ -49,6 +51,7 @@
    8.20  	close(fdtmp);
    8.21  	execl(tmpFileName, isoFileName);
    8.22  }
    8.23 +#endif
    8.24  
    8.25  static int iswinnt(void)
    8.26  {
    8.27 @@ -58,6 +61,7 @@
    8.28  	    Version.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS); // not Win9x
    8.29  }
    8.30  
    8.31 +#define LONG(x)	* (unsigned long *) (x)
    8.32  static int ishybrid(char *isoFileName)
    8.33  {
    8.34  	int fdiso;
    8.35 @@ -68,16 +72,15 @@
    8.36  	if (lseek(fdiso, 17 * 2048L, SEEK_SET) != -1 &&
    8.37  	    read(fdiso, buffer, 2048) == 2048 &&
    8.38  	    strncmp(buffer+7,"EL TORITO SPECIFICATION",23) == 0) {
    8.39 -		unsigned long lba = * (unsigned long *) (buffer + 71);
    8.40 +		unsigned long lba = LONG(buffer + 71);
    8.41  		
    8.42  		if (lseek(fdiso, lba * 2048L, SEEK_SET) != -1 &&
    8.43  		    read(fdiso, buffer, 2048) == 2048 &&
    8.44 -		    * (unsigned long *) (buffer + 0) == 1 &&
    8.45 -		    * (unsigned long *) (buffer + 30) == 0x88AA55) {
    8.46 -			lba = * (unsigned long *) (buffer + 40);
    8.47 +		    LONG(buffer + 0) == 1 && LONG(buffer + 30) == 0x88AA55) {
    8.48 +			lba = LONG(buffer + 40);
    8.49  			if (lseek(fdiso, lba * 2048L, SEEK_SET) != -1 &&
    8.50  			    read(fdiso, buffer, 2048) == 2048)
    8.51 -				magic = * (unsigned long *) (buffer + 64);
    8.52 +				magic = LONG(buffer + 64);
    8.53  		}
    8.54  	}
    8.55  	close(fdiso);
    8.56 @@ -169,7 +172,6 @@
    8.57  	}
    8.58  }
    8.59  
    8.60 -//TODO #define VCPI_LINUX_LOADER The DOS/EXE loader can boot in VM86 using VCPI API
    8.61  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    8.62  		   LPSTR lpCmdLine, int nCmdShow)
    8.63  {
    8.64 @@ -213,7 +215,14 @@
    8.65  	}
    8.66  	if (header[BOOTSTRAP_SECTOR_COUNT_OFFSET] == 0) { // No floppy bootstrap available
    8.67  		usbkeyicon = MB_ICONQUESTION;
    8.68 -		usbkeymsg = "Do you want to create a boot key ?";
    8.69 +		usbkeymsg =
    8.70 +		"You can create a SliTaz USB boot key or\n"
    8.71 +		"a boot memory card.\n"
    8.72 +		"(note that this will be read only like\n"
    8.73 +		"a CDROM. The Slitaz utility 'tazusb'\n"
    8.74 +		"can be used later to create a true\n"
    8.75 +		"read/write USB key).\n"
    8.76 +		"\nDo you want to create a boot key now ?";
    8.77  	}
    8.78  	if (MessageBox(NULL,usbkeymsg, "Create a boot stick ?",
    8.79  			MB_YESNO|usbkeyicon) == IDYES) {
    8.80 @@ -226,8 +235,7 @@
    8.81  			exit(0);
    8.82  		base = drives();
    8.83  		if (MessageBox(NULL,"Step 2: plug the USB stick in, "
    8.84 -				    "wait for Windows to mount it and "
    8.85 -				    "dismount it",
    8.86 +				    "wait for Windows to mount it",
    8.87  				"Drive detection 2/2",
    8.88  				MB_OKCANCEL|MB_ICONEXCLAMATION) == IDCANCEL)
    8.89  			exit(0);
     9.1 --- a/syslinux/stuff/isolinux.cfg	Fri Nov 03 11:59:19 2017 +0100
     9.2 +++ b/syslinux/stuff/isolinux.cfg	Fri Nov 03 15:07:20 2017 +0100
     9.3 @@ -1,31 +1,27 @@
     9.4  UI vesamenu.c32
     9.5 -PROMPT 0
     9.6 -TIMEOUT 80
     9.7 +PROMPT	0
     9.8 +TIMEOUT	80
     9.9  
    9.10 -# Menu settings
    9.11  MENU TITLE SliTaz GNU/Linux - 5.0-RC4 XXXXXXXX
    9.12  MENU BACKGROUND splash.jpg
    9.13 -MENU WIDTH 78
    9.14 -MENU MARGIN 6
    9.15 -MENU ROWS 12
    9.16 -MENU VSHIFT 3
    9.17 -MENU TIMEOUTROW 16
    9.18 -MENU TABMSGROW 14
    9.19 -MENU CMDLINEROW 14
    9.20 +MENU WIDTH	78
    9.21 +MENU MARGIN	6
    9.22 +MENU ROWS	12
    9.23 +MENU VSHIFT	3
    9.24 +MENU TIMEOUTROW	16
    9.25 +MENU TABMSGROW	14
    9.26 +MENU CMDLINEROW	14
    9.27  
    9.28 -# Menu colors
    9.29 -MENU COLOR border       *       #00000000 #00000000 none
    9.30 -MENU COLOR title	    *       #ffffffff #00000000 *
    9.31 -MENU COLOR sel          0       #ffffffff #00000000 none
    9.32 -MENU COLOR unsel        0       #50ffffff #00000000 none
    9.33 -#MENU COLOR help         37;40   #c0ffffff #a0000000 std
    9.34 -MENU COLOR help 	    *       #ffffffff #00000000 *
    9.35 -MENU COLOR timeout_msg  37;40   #80ffffff #00000000 std
    9.36 -MENU COLOR timeout      1;37;40 #c0ffffff #00000000 std
    9.37 -MENU COLOR msg07        37;40   #90ffffff #a0000000 std
    9.38 -MENU COLOR tabmsg       31;40   #30ffffff #00000000 std
    9.39 +MENU COLOR border	*	#00000000 #00000000 none
    9.40 +MENU COLOR title	*	#ffffffff #00000000 *
    9.41 +MENU COLOR sel		0	#ffffffff #00000000 none
    9.42 +MENU COLOR unsel	0	#50ffffff #00000000 none
    9.43 +MENU COLOR help		*	#ffffffff #00000000 *
    9.44 +MENU COLOR timeout_msg	37;40	#80ffffff #00000000 std
    9.45 +MENU COLOR timeout	1;37;40	#c0ffffff #00000000 std
    9.46 +MENU COLOR msg07	37;40	#90ffffff #a0000000 std
    9.47 +MENU COLOR tabmsg	31;40	#30ffffff #00000000 std
    9.48  
    9.49 -# Labels
    9.50  LABEL slitaz
    9.51  	MENU LABEL SliTaz Live
    9.52  	COM32 c32box.c32
    9.53 @@ -64,7 +60,6 @@
    9.54  	COM32 c32box.c32
    9.55  	append poweroff
    9.56  
    9.57 -# Help files
    9.58  F1 help.en
    9.59  F2 opts.en
    9.60  F3 help.fr
    10.1 --- a/syslinux/stuff/tools/isohybrid.sh	Fri Nov 03 11:59:19 2017 +0100
    10.2 +++ b/syslinux/stuff/tools/isohybrid.sh	Fri Nov 03 15:07:20 2017 +0100
    10.3 @@ -253,7 +253,7 @@
    10.4  trksz=$(( 512 * $heads * $sectors ))
    10.5  cylinders=$(( ($size + $trksz - 1) / $trksz ))
    10.6  pad=$(( (($cylinders * $trksz) - $size) / 512 ))
    10.7 -[ $pad -eq 0 ] || ddq bs=512 count=$pad if=/dev/zero >> $iso
    10.8 +#[ $pad -eq 0 ] || ddq bs=512 count=$pad if=/dev/zero >> $iso
    10.9  if [ $cylinders -gt 1024 ]; then
   10.10  	cat 1>&2 <<EOT
   10.11  Warning: more than 1024 cylinders ($cylinders).