diff options
Diffstat (limited to 'scripts/lib/mic/kickstart/custom_commands')
-rw-r--r-- | scripts/lib/mic/kickstart/custom_commands/partition.py | 155 |
1 files changed, 39 insertions, 116 deletions
diff --git a/scripts/lib/mic/kickstart/custom_commands/partition.py b/scripts/lib/mic/kickstart/custom_commands/partition.py index fe8e55a376..4974a87d93 100644 --- a/scripts/lib/mic/kickstart/custom_commands/partition.py +++ b/scripts/lib/mic/kickstart/custom_commands/partition.py | |||
@@ -28,8 +28,14 @@ import shutil | |||
28 | 28 | ||
29 | from pykickstart.commands.partition import * | 29 | from pykickstart.commands.partition import * |
30 | from mic.utils.oe.misc import * | 30 | from mic.utils.oe.misc import * |
31 | |||
32 | from mic.kickstart.custom_commands import * | 31 | from mic.kickstart.custom_commands import * |
32 | from mic.plugin import pluginmgr | ||
33 | |||
34 | partition_methods = { | ||
35 | "do_stage_partition":None, | ||
36 | "do_prepare_partition":None, | ||
37 | "do_configure_partition":None, | ||
38 | } | ||
33 | 39 | ||
34 | class Wic_PartData(Mic_PartData): | 40 | class Wic_PartData(Mic_PartData): |
35 | removedKeywords = Mic_PartData.removedKeywords | 41 | removedKeywords = Mic_PartData.removedKeywords |
@@ -50,8 +56,22 @@ class Wic_PartData(Mic_PartData): | |||
50 | 56 | ||
51 | return retval | 57 | return retval |
52 | 58 | ||
53 | def prepare(self, cr_workdir, oe_builddir, boot_type, rootfs_dir, | 59 | def set_size(self, size): |
54 | bootimg_dir, kernel_dir, native_sysroot): | 60 | """ |
61 | Accessor for actual partition size, which must be set by source | ||
62 | plugins. | ||
63 | """ | ||
64 | self.size = size | ||
65 | |||
66 | def set_source_file(self, source_file): | ||
67 | """ | ||
68 | Accessor for source_file, the location of the generated partition | ||
69 | image, which must be set by source plugins. | ||
70 | """ | ||
71 | self.source_file = source_file | ||
72 | |||
73 | def prepare(self, cr, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir, | ||
74 | kernel_dir, native_sysroot): | ||
55 | """ | 75 | """ |
56 | Prepare content for individual partitions, depending on | 76 | Prepare content for individual partitions, depending on |
57 | partition command parameters. | 77 | partition command parameters. |
@@ -65,121 +85,24 @@ class Wic_PartData(Mic_PartData): | |||
65 | native_sysroot) | 85 | native_sysroot) |
66 | return | 86 | return |
67 | 87 | ||
68 | if self.source == "bootimg" and boot_type == "pcbios": | 88 | if self.source.startswith("rootfs"): |
69 | self.prepare_bootimg_pcbios(cr_workdir, oe_builddir, bootimg_dir, | ||
70 | kernel_dir, native_sysroot) | ||
71 | elif self.source == "bootimg" and boot_type == "efi": | ||
72 | self.prepare_bootimg_efi(cr_workdir, oe_builddir, bootimg_dir, | ||
73 | kernel_dir, native_sysroot) | ||
74 | elif self.source.startswith("rootfs"): | ||
75 | self.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, | 89 | self.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, |
76 | native_sysroot) | 90 | native_sysroot) |
77 | 91 | else: | |
78 | def prepare_bootimg_pcbios(self, cr_workdir, oe_builddir, bootimg_dir, | 92 | self._source_methods = pluginmgr.get_source_plugin_methods(self.source, partition_methods) |
79 | kernel_dir, native_sysroot): | 93 | self._source_methods["do_configure_partition"](self, cr, cr_workdir, |
80 | """ | 94 | oe_builddir, |
81 | Prepare content for a legacy bios boot partition. | 95 | bootimg_dir, |
82 | """ | 96 | kernel_dir, |
83 | staging_kernel_dir = kernel_dir | 97 | native_sysroot) |
84 | staging_data_dir = bootimg_dir | 98 | self._source_methods["do_stage_partition"](self, cr, cr_workdir, |
85 | 99 | oe_builddir, | |
86 | hdddir = "%s/hdd/boot" % cr_workdir | 100 | bootimg_dir, kernel_dir, |
87 | 101 | native_sysroot) | |
88 | install_cmd = "install -m 0644 %s/bzImage %s/vmlinuz" \ | 102 | self._source_methods["do_prepare_partition"](self, cr, cr_workdir, |
89 | % (staging_kernel_dir, hdddir) | 103 | oe_builddir, |
90 | tmp = exec_cmd(install_cmd) | 104 | bootimg_dir, kernel_dir, |
91 | 105 | native_sysroot) | |
92 | install_cmd = "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" \ | ||
93 | % (staging_data_dir, hdddir) | ||
94 | tmp = exec_cmd(install_cmd) | ||
95 | |||
96 | du_cmd = "du -bks %s" % hdddir | ||
97 | rc, out = exec_cmd(du_cmd) | ||
98 | blocks = int(out.split()[0]) | ||
99 | |||
100 | blocks += BOOTDD_EXTRA_SPACE | ||
101 | |||
102 | # Ensure total sectors is an integral number of sectors per | ||
103 | # track or mcopy will complain. Sectors are 512 bytes, and we | ||
104 | # generate images with 32 sectors per track. This calculation is | ||
105 | # done in blocks, thus the mod by 16 instead of 32. | ||
106 | blocks += (16 - (blocks % 16)) | ||
107 | |||
108 | # dosfs image, created by mkdosfs | ||
109 | bootimg = "%s/boot.img" % cr_workdir | ||
110 | |||
111 | dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (bootimg, blocks) | ||
112 | exec_native_cmd(dosfs_cmd, native_sysroot) | ||
113 | |||
114 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) | ||
115 | exec_native_cmd(mcopy_cmd, native_sysroot) | ||
116 | |||
117 | syslinux_cmd = "syslinux %s" % bootimg | ||
118 | exec_native_cmd(syslinux_cmd, native_sysroot) | ||
119 | |||
120 | chmod_cmd = "chmod 644 %s" % bootimg | ||
121 | exec_cmd(chmod_cmd) | ||
122 | |||
123 | du_cmd = "du -Lbms %s" % bootimg | ||
124 | rc, out = exec_cmd(du_cmd) | ||
125 | bootimg_size = out.split()[0] | ||
126 | |||
127 | self.size = bootimg_size | ||
128 | self.source_file = bootimg | ||
129 | |||
130 | def prepare_bootimg_efi(self, cr_workdir, oe_builddir, bootimg_dir, | ||
131 | kernel_dir, native_sysroot): | ||
132 | """ | ||
133 | Prepare content for an EFI (grub) boot partition. | ||
134 | """ | ||
135 | staging_kernel_dir = kernel_dir | ||
136 | staging_data_dir = bootimg_dir | ||
137 | |||
138 | hdddir = "%s/hdd/boot" % cr_workdir | ||
139 | |||
140 | install_cmd = "install -m 0644 %s/bzImage %s/vmlinuz" % \ | ||
141 | (staging_kernel_dir, hdddir) | ||
142 | tmp = exec_cmd(install_cmd) | ||
143 | |||
144 | shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, | ||
145 | "%s/grub.cfg" % cr_workdir) | ||
146 | |||
147 | cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir) | ||
148 | exec_cmd(cp_cmd, True) | ||
149 | |||
150 | shutil.move("%s/grub.cfg" % cr_workdir, | ||
151 | "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir) | ||
152 | |||
153 | du_cmd = "du -bks %s" % hdddir | ||
154 | rc, out = exec_cmd(du_cmd) | ||
155 | blocks = int(out.split()[0]) | ||
156 | |||
157 | blocks += BOOTDD_EXTRA_SPACE | ||
158 | |||
159 | # Ensure total sectors is an integral number of sectors per | ||
160 | # track or mcopy will complain. Sectors are 512 bytes, and we | ||
161 | # generate images with 32 sectors per track. This calculation is | ||
162 | # done in blocks, thus the mod by 16 instead of 32. | ||
163 | blocks += (16 - (blocks % 16)) | ||
164 | |||
165 | # dosfs image, created by mkdosfs | ||
166 | bootimg = "%s/boot.img" % cr_workdir | ||
167 | |||
168 | dosfs_cmd = "mkdosfs -n efi -C %s %d" % (bootimg, blocks) | ||
169 | exec_native_cmd(dosfs_cmd, native_sysroot) | ||
170 | |||
171 | mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) | ||
172 | exec_native_cmd(mcopy_cmd, native_sysroot) | ||
173 | |||
174 | chmod_cmd = "chmod 644 %s" % bootimg | ||
175 | exec_cmd(chmod_cmd) | ||
176 | |||
177 | du_cmd = "du -Lbms %s" % bootimg | ||
178 | rc, out = exec_cmd(du_cmd) | ||
179 | bootimg_size = out.split()[0] | ||
180 | |||
181 | self.size = bootimg_size | ||
182 | self.source_file = bootimg | ||
183 | 106 | ||
184 | def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, | 107 | def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, |
185 | rootfs_dir): | 108 | rootfs_dir): |