Browse code

cdrkit: EFI boot support

Change-Id: I05c34363a0a543ec96d421d0da289577140142c9
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2112
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Tested-by: gerrit-photon <photon-checkins@vmware.com>

Alexey Makhalov authored on 2017/03/07 14:29:47
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,204 @@
0
+diff --git a/doc/icedax/tracknames.pl b/doc/icedax/tracknames.pl
1
+old mode 100755
2
+new mode 100644
3
+index 09f0fcf..801b89e
4
+--- a/doc/icedax/tracknames.pl
5
+@@ -1,4 +1,4 @@
6
+-#!/usr/local/bin/perl 
7
++#!/usr/bin/perl 
8
+ # A quick perl hack to get rename files pulled in with icedax.
9
+ # by billo@billo.com
10
+ #
11
+diff --git a/genisoimage/eltorito.c b/genisoimage/eltorito.c
12
+index b97bdf1..5d7c2d1 100644
13
+--- a/genisoimage/eltorito.c
14
+@@ -59,7 +59,7 @@ static	void	get_torito_desc(struct eltorito_boot_descriptor *boot_desc);
15
+ static	void	fill_boot_desc(struct eltorito_defaultboot_entry *boot_desc_entry,
16
+ 										struct eltorito_boot_entry_info *boot_entry);
17
+ void	get_boot_entry(void);
18
+-void	new_boot_entry(void);
19
++void	new_boot_entry();
20
+ static	int	tvd_write(FILE *outfile);
21
+ 
22
+ 
23
+@@ -283,6 +283,7 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
24
+ 	int			i;
25
+ 	int			offset;
26
+ 	struct eltorito_defaultboot_entry boot_desc_record;
27
++	struct eltorito_sectionheader_entry section_header;
28
+ 
29
+ 	memset(boot_desc, 0, sizeof (*boot_desc));
30
+ 	boot_desc->type[0] = 0;
31
+@@ -317,7 +318,7 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
32
+ 	 */
33
+ 	memset(&valid_desc, 0, sizeof (valid_desc));
34
+ 	valid_desc.headerid[0] = 1;
35
+-	valid_desc.arch[0] = EL_TORITO_ARCH_x86;
36
++	valid_desc.arch[0] = first_boot_entry->arch;
37
+ 
38
+ 	/*
39
+ 	 * we'll shove start of publisher id into id field,
40
+@@ -347,10 +348,53 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
41
+ 	/* now write it to the virtual boot catalog */
42
+ 	memcpy(de2->table, &valid_desc, 32);
43
+ 
44
+-	for (current_boot_entry = first_boot_entry, offset = sizeof (valid_desc);
45
+-		current_boot_entry != NULL;
46
+-		current_boot_entry = current_boot_entry->next,
47
+-		offset += sizeof (boot_desc_record)) {
48
++	/* Fill the first entry, since it's special and already has the
49
++	 * matching header via the validation header... */
50
++	offset = sizeof (valid_desc);
51
++	current_boot_entry = first_boot_entry;
52
++
53
++	if (offset >= SECTOR_SIZE) {
54
++#ifdef	USE_LIBSCHILY
55
++		comerrno(EX_BAD, "Too many El Torito boot entries\n");
56
++#else
57
++		fprintf(stderr,	"Too many El Torito boot entries\n");
58
++		exit(1);
59
++#endif
60
++	}
61
++	fill_boot_desc(&boot_desc_record, current_boot_entry);
62
++	memcpy(de2->table + offset, &boot_desc_record,
63
++				sizeof (boot_desc_record));
64
++
65
++	offset += sizeof(boot_desc_record);
66
++
67
++	for (current_boot_entry = current_boot_entry->next;
68
++			current_boot_entry != NULL;
69
++			current_boot_entry = current_boot_entry->next) {
70
++		struct eltorito_sectionheader_entry section_header;
71
++
72
++		if (offset >= SECTOR_SIZE) {
73
++#ifdef	USE_LIBSCHILY
74
++			comerrno(EX_BAD,
75
++			"Too many El Torito boot entries\n");
76
++#else
77
++			fprintf(stderr,
78
++			"Too many El Torito boot entries\n");
79
++			exit(1);
80
++#endif
81
++		}
82
++
83
++		memset(&section_header, '\0', sizeof(section_header));
84
++		if (current_boot_entry->next)
85
++			section_header.headerid[0] = EL_TORITO_SECTION_HEADER;
86
++		else
87
++			section_header.headerid[0] = EL_TORITO_LAST_SECTION_HEADER;
88
++
89
++		section_header.arch[0] = current_boot_entry->arch;
90
++		set_721(section_header.num_entries, 1);
91
++
92
++		memcpy(de2->table + offset, &section_header,
93
++					sizeof(section_header));
94
++		offset += sizeof(section_header);
95
+ 
96
+ 		if (offset >= SECTOR_SIZE) {
97
+ #ifdef	USE_LIBSCHILY
98
+@@ -365,6 +409,8 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
99
+ 		fill_boot_desc(&boot_desc_record, current_boot_entry);
100
+ 		memcpy(de2->table + offset, &boot_desc_record,
101
+ 					sizeof (boot_desc_record));
102
++		offset += sizeof (boot_desc_record);
103
++
104
+ 	}
105
+ }/* get_torito_desc(... */
106
+ 
107
+diff --git a/genisoimage/genisoimage.c b/genisoimage/genisoimage.c
108
+index a5b0b46..8add1ac 100644
109
+--- a/genisoimage/genisoimage.c
110
+@@ -47,6 +47,7 @@
111
+ 
112
+ #include <mconfig.h>
113
+ #include "genisoimage.h"
114
++#include "iso9660.h"
115
+ #include <errno.h>
116
+ #include <timedefs.h>
117
+ #include <fctldefs.h>
118
+@@ -523,6 +524,8 @@ static const struct ld_option ld_options[] =
119
+ 	'\0', NULL, "Set debug flag", ONE_DASH},
120
+ 	{{"eltorito-boot", required_argument, NULL, 'b'},
121
+ 	'b', "FILE", "Set El Torito boot image name", ONE_DASH},
122
++	{{"efi-boot", required_argument, NULL, 'e'},
123
++	'e', "FILE", "Set EFI boot image name", ONE_DASH},
124
+ 	{{"eltorito-alt-boot", no_argument, NULL, OPTION_ALT_BOOT},
125
+ 	'\0', NULL, "Start specifying alternative El Torito boot parameters", ONE_DASH},
126
+ 	{{"sparc-boot", required_argument, NULL, 'B'},
127
+@@ -1502,6 +1505,7 @@ int main(int argc, char *argv[])
128
+ 			all_files = 0;
129
+ 			break;
130
+ 		case 'b':
131
++		case 'e':
132
+ 			do_sort++;		/* We sort bootcat/botimage */
133
+ 			use_eltorito++;
134
+ 			boot_image = optarg;	/* pathname of the boot image */
135
+@@ -1517,6 +1521,10 @@ int main(int argc, char *argv[])
136
+ #endif
137
+ 			}
138
+ 			get_boot_entry();
139
++			if (c == 'e')
140
++				current_boot_entry->arch = EL_TORITO_ARCH_EFI;
141
++			else
142
++				current_boot_entry->arch = EL_TORITO_ARCH_x86;
143
+ 			current_boot_entry->boot_image = boot_image;
144
+ 			break;
145
+ 		case OPTION_ALT_BOOT:
146
+diff --git a/genisoimage/genisoimage.h b/genisoimage/genisoimage.h
147
+index bbedfb0..76e5e21 100644
148
+--- a/genisoimage/genisoimage.h
149
+@@ -293,6 +293,7 @@ struct deferred_write {
150
+ struct eltorito_boot_entry_info {
151
+ 	struct eltorito_boot_entry_info *next;
152
+ 	char		*boot_image;
153
++	char		arch;
154
+ 	int		not_bootable;
155
+ 	int		no_emul_boot;
156
+ 	int		hard_disk_boot;
157
+diff --git a/genisoimage/iso9660.h b/genisoimage/iso9660.h
158
+index c74c2a9..c8b7a05 100644
159
+--- a/genisoimage/iso9660.h
160
+@@ -62,10 +62,14 @@ struct iso_volume_descriptor {
161
+ #define	EL_TORITO_ARCH_x86	0
162
+ #define	EL_TORITO_ARCH_PPC	1
163
+ #define	EL_TORITO_ARCH_MAC	2
164
++#define	EL_TORITO_ARCH_EFI	0xef
165
+ 
166
+ #define	EL_TORITO_BOOTABLE	0x88
167
+ #define	EL_TORITO_NOT_BOOTABLE	0
168
+ 
169
++#define	EL_TORITO_SECTION_HEADER	0x90
170
++#define	EL_TORITO_LAST_SECTION_HEADER	0x91
171
++
172
+ #define	EL_TORITO_MEDIA_NOEMUL	0
173
+ #define	EL_TORITO_MEDIA_12FLOP	1
174
+ #define	EL_TORITO_MEDIA_144FLOP	2
175
+@@ -173,7 +177,7 @@ struct eltorito_validation_entry {
176
+ struct eltorito_defaultboot_entry {
177
+ 	char boot_id			[ISODCL(1,    1)]; /* 711 */
178
+ 	char boot_media			[ISODCL(2,    2)];
179
+-	char loadseg			[ISODCL(3,    4)]; /* 711 */
180
++	char loadseg			[ISODCL(3,    4)]; /* 712 */
181
+ 	char sys_type			[ISODCL(5,    5)];
182
+ 	char pad1			[ISODCL(6,    6)];
183
+ 	char nsect			[ISODCL(7,    8)];
184
+@@ -181,6 +185,14 @@ struct eltorito_defaultboot_entry {
185
+ 	char pad2			[ISODCL(13,  32)];
186
+ };
187
+ 
188
++/* El Torito Section Header Entry in boot catalog */
189
++struct eltorito_sectionheader_entry {
190
++	char headerid			[ISODCL(1,    1)]; /* 711 */
191
++	char arch			[ISODCL(2,    2)];
192
++	char num_entries		[ISODCL(3,    4)]; /* 711 */
193
++	char id				[ISODCL(5,   32)];
194
++};
195
++
196
+ /*
197
+  * XXX JS: The next two structures have odd lengths!
198
+  * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.
... ...
@@ -1,7 +1,7 @@
1 1
 Summary: 	Utilities for writing cds.
2 2
 Name: 		cdrkit
3 3
 Version: 	1.1.11
4
-Release: 	2%{?dist}
4
+Release: 	3%{?dist}
5 5
 License: 	GPLv2+
6 6
 Group: 		System Environment/Base
7 7
 Vendor:		VMware, Inc.
... ...
@@ -9,6 +9,7 @@ Distribution: 	Photon
9 9
 Source0: 	%{name}-%{version}.tar.gz
10 10
 %define sha1 cdrkit=3f7ddc06db0272942e1a4cd98c3c96462df77387
11 11
 URL:  		http://gd.tuwien.ac.at/utils/schilling/cdrtools/
12
+Patch0:		cdrkit-1.1.9-efi-boot.patch
12 13
 BuildArchitectures: x86_64
13 14
 Requires: 	bash
14 15
 Requires: 	libcap
... ...
@@ -19,6 +20,9 @@ BuildRequires: 	bzip2-devel
19 19
 The Cdrtools package contains CD recording utilities. These are useful for reading, creating or writing (burning) Compact Discs.
20 20
 %prep
21 21
 %setup -q
22
+%patch0 -p1
23
+
24
+%build
22 25
 make %{?_smp_mflags}
23 26
 
24 27
 %install
... ...
@@ -34,8 +38,10 @@ ln -s  genisoimage  %{buildroot}%{_prefix}/bin/mkisofs
34 34
 %{_sbindir}/*
35 35
 %{_datadir}/man/*
36 36
 %changelog
37
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.1.11-2
38
--	GA - Bump release of all rpms
39
-* Sat Feb 14 2015 Sharath George <sharathg@vmware.com>
40
-- first packaging
37
+*   Mon Mar 6 2017 Alexey Makhalov <amakhalov@vmware.com> 1.1.11-3
38
+-   Support for efi boot (.patch)
39
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.1.11-2
40
+-   GA - Bump release of all rpms
41
+*   Sat Feb 14 2015 Sharath George <sharathg@vmware.com>
42
+-   first packaging
41 43