aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuan M. Hoang <tmhoang@flatglobe.org>2018-06-18 18:53:11 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2018-06-19 07:08:42 +0000
commit7503de19f027c334f41dfbd8e793b04ad70622c0 (patch)
tree7e23a98fd4655c7e22eddf5d6b52739ca1745385
parentfcf202d3e511637897a5cade6ff6c1c04626e3d1 (diff)
downloadalpine_aports-7503de19f027c334f41dfbd8e793b04ad70622c0.tar.bz2
alpine_aports-7503de19f027c334f41dfbd8e793b04ad70622c0.tar.xz
alpine_aports-7503de19f027c334f41dfbd8e793b04ad70622c0.zip
scripts/mkimg, main/s390-tools: create bootable 'standard' iso for s390x
-rw-r--r--main/s390-tools/APKBUILD9
-rw-r--r--main/s390-tools/mk-s390-cdboot.c284
-rwxr-xr-xscripts/mkimg.base.sh10
3 files changed, 301 insertions, 2 deletions
diff --git a/main/s390-tools/APKBUILD b/main/s390-tools/APKBUILD
index fea27e9081..ae71844dfa 100644
--- a/main/s390-tools/APKBUILD
+++ b/main/s390-tools/APKBUILD
@@ -2,7 +2,7 @@
2# Maintainer: Tuan M. Hoang <tmhoang@flatglobe.org> 2# Maintainer: Tuan M. Hoang <tmhoang@flatglobe.org>
3pkgname=s390-tools 3pkgname=s390-tools
4pkgver=1.37.0 4pkgver=1.37.0
5pkgrel=3 5pkgrel=4
6pkgdesc="Utilities for Linux on IBM z Systems" 6pkgdesc="Utilities for Linux on IBM z Systems"
7url="http://www.ibm.com/developerworks/linux/linux390/s390-tools.html" 7url="http://www.ibm.com/developerworks/linux/linux390/s390-tools.html"
8arch="s390x" 8arch="s390x"
@@ -29,6 +29,8 @@ source="http://download.boulder.ibm.com/ibmdl/pub/software/dw/linux390/ht_src/$p
29 29
30 0200-dasdinfo-gnu-ext-hack.patch 30 0200-dasdinfo-gnu-ext-hack.patch
31 0300-disable-program-using-gnu-ext.patch 31 0300-disable-program-using-gnu-ext.patch
32
33 mk-s390-cdboot.c
32 " 34 "
33builddir="$srcdir/$pkgname-$pkgver" 35builddir="$srcdir/$pkgname-$pkgver"
34 36
@@ -38,11 +40,13 @@ build() {
38 HAVE_SNMP=0 \ 40 HAVE_SNMP=0 \
39 HAVE_PFM=0 \ 41 HAVE_PFM=0 \
40 LIBEXECINFO_LIBS="-lexecinfo" 42 LIBEXECINFO_LIBS="-lexecinfo"
43 gcc -Wall -o mk-s390-cdboot "$srcdir"/mk-s390-cdboot.c
41} 44}
42 45
43package() { 46package() {
44 cd "$builddir" 47 cd "$builddir"
45 make HAVE_SNMP=0 HAVE_PFM=0 DESTDIR="$pkgdir" install 48 make HAVE_SNMP=0 HAVE_PFM=0 DESTDIR="$pkgdir" install
49 install -Dm755 mk-s390-cdboot "$pkgdir"/sbin/mk-s390-cdboot
46} 50}
47 51
48sha512sums="3667ba4eb7e2b74629958f530002953adebe6e41d6429c99ae5f82d1406d6963aacdc35b63114683c365b9fa40ac32b4c22f226918ecb53423e80f944d24cb9c s390-tools-1.37.0.tar.bz2 52sha512sums="3667ba4eb7e2b74629958f530002953adebe6e41d6429c99ae5f82d1406d6963aacdc35b63114683c365b9fa40ac32b4c22f226918ecb53423e80f944d24cb9c s390-tools-1.37.0.tar.bz2
@@ -59,4 +63,5 @@ d4d707aadf095f48dd3ae79f60d17194e479d8a6ca08c6b6d64582e6d09b33d7d065a7349cc7fe61
59d879173250fc0cabef198785923248e6832158e38d6ea9ef615f14e2d6698810b54c38c8327f20b2c43d8d509a274b27a7c0ad999a0c0bed2743715f21ab859a 0100-zipl-no-pie.patch 63d879173250fc0cabef198785923248e6832158e38d6ea9ef615f14e2d6698810b54c38c8327f20b2c43d8d509a274b27a7c0ad999a0c0bed2743715f21ab859a 0100-zipl-no-pie.patch
601cbbe3fe265c7d4164143d24c532c18b354be4bc295ad24064d379660e43a475b7d678b458cdf74ffdb44d6cd38a497dbe00758d688c547c6ece63b6dee091b7 0101-zipl-dont-optimize-size.patch 641cbbe3fe265c7d4164143d24c532c18b354be4bc295ad24064d379660e43a475b7d678b458cdf74ffdb44d6cd38a497dbe00758d688c547c6ece63b6dee091b7 0101-zipl-dont-optimize-size.patch
614ce15b615ff08e5c0a23d3c3b19d1e9d6362239fb731e67fa68e6cd108cfdeaaf16186c5416cc211082aa60c4d1946b930b9ea4c300458da98e9a701feed99c3 0200-dasdinfo-gnu-ext-hack.patch 654ce15b615ff08e5c0a23d3c3b19d1e9d6362239fb731e67fa68e6cd108cfdeaaf16186c5416cc211082aa60c4d1946b930b9ea4c300458da98e9a701feed99c3 0200-dasdinfo-gnu-ext-hack.patch
626736ca9deb25838511e715e96d1f5bfc283460689e767181463d1827c80be200b1375708ff48772599083b14f74594f7053cf30fcc6c93ba7fa5dfae832434de 0300-disable-program-using-gnu-ext.patch" 666736ca9deb25838511e715e96d1f5bfc283460689e767181463d1827c80be200b1375708ff48772599083b14f74594f7053cf30fcc6c93ba7fa5dfae832434de 0300-disable-program-using-gnu-ext.patch
67349eb06895016d16194819c4a04f604720f1373ea61a9bc4c58467281c9a2ed3539bd4e8b6984f4e5177630dbe8b928aa95912c9a3e3b0e1fe275d59f9fe573d mk-s390-cdboot.c"
diff --git a/main/s390-tools/mk-s390-cdboot.c b/main/s390-tools/mk-s390-cdboot.c
new file mode 100644
index 0000000000..4a5825853a
--- /dev/null
+++ b/main/s390-tools/mk-s390-cdboot.c
@@ -0,0 +1,284 @@
1/*
2 * mk-s390-cdboot -- creates one big image using a kernel, a ramdisk and
3 * a parmfile
4 *
5 * 2003-07-24 Volker Sameske <sameske@de.ibm.com>
6 * 2008-09-22 Updated by David Cantrell <dcantrell@redhat.com>
7 *
8 * compile with:
9 * gcc -Wall -o mk-s390-cdboot mk-s390-cdboot.c
10 */
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <getopt.h>
15#include <string.h>
16#include <stdarg.h>
17#include <errno.h>
18#include <libgen.h>
19
20#define BUFFER_LEN 1024
21#define INITRD_START 0x0000000000800000LL
22#define START_PSW_ADDRESS 0x80010000
23
24static struct option getopt_long_options[]= {
25 { "image", 1, 0, 'i'},
26 { "ramdisk", 1, 0, 'r'},
27 { "parmfile", 1, 0, 'p'},
28 { "outfile", 1, 0, 'o'},
29 { "help", 0, 0, 'h'},
30 {0, 0, 0, 0}
31};
32
33static void usage(char *cmd) {
34 printf("%s [-h] [-v] -i <kernel> -r <ramdisk> -p <parmfile> -o <outfile>\n", cmd);
35}
36
37int main (int argc, char **argv) {
38 char *cmd = basename(argv[0]);
39 FILE *fd1 = NULL;
40 FILE *fd2 = NULL;
41 FILE *fd3 = NULL;
42 FILE *fd4 = NULL;
43 char buffer[BUFFER_LEN];
44 int wc, rc, oc, index;
45 unsigned long long initrd_start = INITRD_START;
46 unsigned long long initrd_size;
47 char *image = NULL;
48 char *ramdisk = NULL;
49 char *parmfile = NULL;
50 char *outfile = NULL;
51 int image_specified = 0;
52 int ramdisk_specified = 0;
53 int parmfile_specified = 0;
54 int outfile_specified = 0;
55 int start_psw_address = START_PSW_ADDRESS;
56
57 opterr = 0;
58 while (1) {
59 oc = getopt_long(argc, argv, "i:r:p:o:h?", getopt_long_options, &index);
60 if (oc == -1) {
61 break;
62 }
63
64 switch (oc) {
65 case '?':
66 case 'h':
67 usage(cmd);
68 exit(0);
69 case 'i':
70 image = strdup(optarg);
71 image_specified = 1;
72 break;
73 case 'r':
74 ramdisk = strdup(optarg);
75 ramdisk_specified = 1;
76 break;
77 case 'p':
78 parmfile = strdup(optarg);
79 parmfile_specified = 1;
80 break;
81 case 'o':
82 outfile = strdup(optarg);
83 outfile_specified = 1;
84 break;
85 default:
86 usage(cmd);
87 exit(0);
88 }
89 }
90
91 if (!image_specified || !ramdisk_specified ||
92 !parmfile_specified || !outfile_specified) {
93 usage(cmd);
94 exit(0);
95 }
96
97 printf("Creating bootable CD-ROM image...\n");
98 printf("kernel is : %s\n", image);
99 printf("ramdisk is : %s\n", ramdisk);
100 printf("parmfile is: %s\n", parmfile);
101 printf("outfile is : %s\n", outfile);
102
103 if ((fd1 = fopen(outfile, "w")) == NULL) {
104 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
105 abort();
106 }
107
108 if ((fd2 = fopen(image, "r")) == NULL) {
109 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
110 abort();
111 }
112
113 if ((fd3 = fopen(ramdisk, "r")) == NULL) {
114 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
115 abort();
116 }
117
118 if ((fd4 = fopen(parmfile, "r")) == NULL) {
119 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
120 abort();
121 }
122
123 printf("writing kernel...\n");
124 while (1) {
125 rc = fread(buffer, 1, 1, fd2);
126
127 if (rc == 0) {
128 break;
129 }
130
131 if (feof(fd2) || ferror(fd2)) {
132 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
133 abort();
134 }
135
136 wc = fwrite(buffer, 1, 1, fd1);
137 if (feof(fd1) || ferror(fd1)) {
138 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
139 abort();
140 }
141
142 if (wc != rc) {
143 fprintf(stderr, "could only write %i of %i bytes of kernel\n",
144 wc, rc);
145 }
146 }
147
148 printf("writing initrd...\n");
149 fseek(fd1, initrd_start, SEEK_SET);
150 while (1) {
151 rc = fread(buffer, 1, 1, fd3);
152
153 if (rc == 0) {
154 break;
155 }
156
157 if (feof(fd3) || ferror(fd3)) {
158 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
159 abort();
160 }
161
162 wc = fwrite(buffer, 1, 1, fd1);
163 if (feof(fd1) || ferror(fd1)) {
164 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
165 abort();
166 }
167
168 if (wc != rc) {
169 fprintf(stderr, "could only write %i of %i bytes of initrd\n",
170 wc, rc);
171 }
172 }
173
174 if (fseek(fd3, 0, SEEK_END) == -1) {
175 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
176 abort();
177 }
178
179 if ((initrd_size = ftell(fd3)) == -1) {
180 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
181 abort();
182 }
183
184 printf("changing start PSW address to 0x%08x...\n", start_psw_address);
185 if (fseek(fd1, 0x4, SEEK_SET) == -1) {
186 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
187 abort();
188 }
189
190 wc = fwrite(&start_psw_address, 1, 4, fd1);
191 if (feof(fd1) || ferror(fd1)) {
192 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
193 abort();
194 }
195
196 if (wc != 4) {
197 fprintf(stderr, "could only write %i of %i bytes of PSW address\n",
198 wc, 4);
199 }
200
201 printf("writing initrd address and size...\n");
202 printf("INITRD start: 0x%016llx\n", initrd_start);
203 printf("INITRD size : 0x%016llx\n", initrd_size);
204
205 if (fseek(fd1, 0x10408, SEEK_SET) == -1) {
206 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
207 abort();
208 }
209
210 wc = fwrite(&initrd_start, 1, 8, fd1);
211 if (feof(fd1) || ferror(fd1)) {
212 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
213 abort();
214 }
215
216 if (wc != 8) {
217 fprintf(stderr, "could only write %i of %i bytes of INITRD start\n",
218 wc, 8);
219 }
220
221 if (fseek(fd1, 0x10410, SEEK_SET) == -1) {
222 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
223 abort();
224 }
225
226 wc = fwrite(&initrd_size, 1, 8, fd1);
227 if (feof(fd1) || ferror(fd1)) {
228 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
229 abort();
230 }
231
232 if (wc != 8) {
233 fprintf(stderr, "could only write %i of %i bytes of INITRD size\n",
234 wc, 8);
235 }
236
237 printf("writing parmfile...\n");
238 if (fseek(fd1, 0x10480, SEEK_SET) == -1) {
239 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
240 abort();
241 }
242
243 while (1) {
244 rc = fread(buffer, 1, 1, fd4);
245
246 if (rc == 0) {
247 break;
248 }
249
250 if (feof(fd4) || ferror(fd4)) {
251 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
252 abort();
253 }
254
255 wc = fwrite(buffer, 1, 1, fd1);
256 if (feof(fd1) || ferror(fd1)) {
257 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
258 abort();
259 }
260
261 if (wc != 1) {
262 fprintf(stderr, "could only write %i of %i bytes of parmfile\n",
263 wc, 1);
264 }
265 }
266
267 if (fclose(fd1) == EOF) {
268 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
269 }
270
271 if (fclose(fd2) == EOF) {
272 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
273 }
274
275 if (fclose(fd3) == EOF) {
276 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
277 }
278
279 if (fclose(fd4) == EOF) {
280 fprintf(stderr, "%s (%d): %s\n", __func__, __LINE__, strerror(errno));
281 }
282
283 return EXIT_SUCCESS;
284}
diff --git a/scripts/mkimg.base.sh b/scripts/mkimg.base.sh
index 3ba6bfd04b..6dfd9db8a9 100755
--- a/scripts/mkimg.base.sh
+++ b/scripts/mkimg.base.sh
@@ -257,6 +257,16 @@ create_image_iso() {
257 -sysid LINUX \ 257 -sysid LINUX \
258 -volid "alpine-${profile_abbrev:-$PROFILE} $RELEASE $ARCH" 258 -volid "alpine-${profile_abbrev:-$PROFILE} $RELEASE $ARCH"
259 else 259 else
260 if [ "$ARCH" = s390x ]; then
261 printf %s "$initfs_cmdline $kernel_cmdline " > ${WORKDIR}/parmfile
262 for _f in $kernel_flavors; do
263 mk-s390-cdboot -p ${WORKDIR}/parmfile \
264 -i ${DESTDIR}/boot/vmlinuz-$_f \
265 -r ${DESTDIR}/boot/initramfs-$_f \
266 -o ${DESTDIR}/boot/merged.img
267 done
268 iso_opts="$iso_opts -no-emul-boot -eltorito-boot boot/merged.img"
269 fi
260 xorrisofs \ 270 xorrisofs \
261 -quiet \ 271 -quiet \
262 -output ${ISO} \ 272 -output ${ISO} \