diff options
Diffstat (limited to 'meta/classes/image_types_wic.bbclass')
-rw-r--r-- | meta/classes/image_types_wic.bbclass | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/meta/classes/image_types_wic.bbclass b/meta/classes/image_types_wic.bbclass deleted file mode 100644 index 49be1da77a..0000000000 --- a/meta/classes/image_types_wic.bbclass +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | # The WICVARS variable is used to define list of bitbake variables used in wic code | ||
2 | # variables from this list is written to <image>.env file | ||
3 | WICVARS ?= "\ | ||
4 | BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_EFI_BOOT_FILES IMAGE_BOOT_FILES \ | ||
5 | IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR RECIPE_SYSROOT_NATIVE \ | ||
6 | ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS HOSTTOOLS_DIR \ | ||
7 | KERNEL_IMAGETYPE MACHINE INITRAMFS_IMAGE INITRAMFS_IMAGE_BUNDLE INITRAMFS_LINK_NAME APPEND \ | ||
8 | ASSUME_PROVIDED PSEUDO_IGNORE_PATHS" | ||
9 | |||
10 | inherit ${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', 'kernel-artifact-names', '', d)} | ||
11 | |||
12 | WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks" | ||
13 | WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks" | ||
14 | WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p for p in '${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/canned-wks' % l for l in '${BBPATH}:${COREBASE}'.split(':'))}" | ||
15 | WKS_FULL_PATH = "${@wks_search(d.getVar('WKS_FILES').split(), d.getVar('WKS_SEARCH_PATH')) or ''}" | ||
16 | |||
17 | def wks_search(files, search_path): | ||
18 | for f in files: | ||
19 | if os.path.isabs(f): | ||
20 | if os.path.exists(f): | ||
21 | return f | ||
22 | else: | ||
23 | searched = bb.utils.which(search_path, f) | ||
24 | if searched: | ||
25 | return searched | ||
26 | |||
27 | WIC_CREATE_EXTRA_ARGS ?= "" | ||
28 | |||
29 | IMAGE_CMD_wic () { | ||
30 | out="${IMGDEPLOYDIR}/${IMAGE_NAME}" | ||
31 | build_wic="${WORKDIR}/build-wic" | ||
32 | tmp_wic="${WORKDIR}/tmp-wic" | ||
33 | wks="${WKS_FULL_PATH}" | ||
34 | if [ -e "$tmp_wic" ]; then | ||
35 | # Ensure we don't have any junk leftover from a previously interrupted | ||
36 | # do_image_wic execution | ||
37 | rm -rf "$tmp_wic" | ||
38 | fi | ||
39 | if [ -z "$wks" ]; then | ||
40 | bbfatal "No kickstart files from WKS_FILES were found: ${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately." | ||
41 | fi | ||
42 | BUILDDIR="${TOPDIR}" PSEUDO_UNLOAD=1 wic create "$wks" --vars "${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o "$build_wic/" -w "$tmp_wic" ${WIC_CREATE_EXTRA_ARGS} | ||
43 | mv "$build_wic/$(basename "${wks%.wks}")"*.direct "$out${IMAGE_NAME_SUFFIX}.wic" | ||
44 | } | ||
45 | IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH WKS_FILES TOPDIR" | ||
46 | do_image_wic[cleandirs] = "${WORKDIR}/build-wic" | ||
47 | |||
48 | PSEUDO_IGNORE_PATHS .= ",${WORKDIR}/build-wic" | ||
49 | |||
50 | # Rebuild when the wks file or vars in WICVARS change | ||
51 | USING_WIC = "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), '1', '', d)}" | ||
52 | WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}" | ||
53 | do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}" | ||
54 | do_image_wic[depends] += "${@' '.join('%s-native:do_populate_sysroot' % r for r in ('parted', 'gptfdisk', 'dosfstools', 'mtools'))}" | ||
55 | |||
56 | # We ensure all artfacts are deployed (e.g virtual/bootloader) | ||
57 | do_image_wic[recrdeptask] += "do_deploy" | ||
58 | do_image_wic[deptask] += "do_image_complete" | ||
59 | |||
60 | WKS_FILE_DEPENDS_DEFAULT = '${@bb.utils.contains_any("BUILD_ARCH", [ 'x86_64', 'i686' ], "syslinux-native", "",d)}' | ||
61 | WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native" | ||
62 | WKS_FILE_DEPENDS_BOOTLOADERS = "" | ||
63 | WKS_FILE_DEPENDS_BOOTLOADERS_x86 = "syslinux grub-efi systemd-boot" | ||
64 | WKS_FILE_DEPENDS_BOOTLOADERS_x86-64 = "syslinux grub-efi systemd-boot" | ||
65 | WKS_FILE_DEPENDS_BOOTLOADERS_x86-x32 = "syslinux grub-efi" | ||
66 | |||
67 | WKS_FILE_DEPENDS ??= "${WKS_FILE_DEPENDS_DEFAULT} ${WKS_FILE_DEPENDS_BOOTLOADERS}" | ||
68 | |||
69 | DEPENDS += "${@ '${WKS_FILE_DEPENDS}' if d.getVar('USING_WIC') else '' }" | ||
70 | |||
71 | python do_write_wks_template () { | ||
72 | """Write out expanded template contents to WKS_FULL_PATH.""" | ||
73 | import re | ||
74 | |||
75 | template_body = d.getVar('_WKS_TEMPLATE') | ||
76 | |||
77 | # Remove any remnant variable references left behind by the expansion | ||
78 | # due to undefined variables | ||
79 | expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}") | ||
80 | while True: | ||
81 | new_body = re.sub(expand_var_regexp, '', template_body) | ||
82 | if new_body == template_body: | ||
83 | break | ||
84 | else: | ||
85 | template_body = new_body | ||
86 | |||
87 | wks_file = d.getVar('WKS_FULL_PATH') | ||
88 | with open(wks_file, 'w') as f: | ||
89 | f.write(template_body) | ||
90 | f.close() | ||
91 | # Copy the finalized wks file to the deploy directory for later use | ||
92 | depdir = d.getVar('IMGDEPLOYDIR') | ||
93 | basename = d.getVar('IMAGE_BASENAME') | ||
94 | bb.utils.copyfile(wks_file, "%s/%s" % (depdir, basename + '-' + os.path.basename(wks_file))) | ||
95 | } | ||
96 | |||
97 | do_flush_pseudodb() { | ||
98 | ${FAKEROOTENV} ${FAKEROOTCMD} -S | ||
99 | } | ||
100 | |||
101 | python () { | ||
102 | if d.getVar('USING_WIC'): | ||
103 | wks_file_u = d.getVar('WKS_FULL_PATH', False) | ||
104 | wks_file = d.expand(wks_file_u) | ||
105 | base, ext = os.path.splitext(wks_file) | ||
106 | if ext == '.in' and os.path.exists(wks_file): | ||
107 | wks_out_file = os.path.join(d.getVar('WORKDIR'), os.path.basename(base)) | ||
108 | d.setVar('WKS_FULL_PATH', wks_out_file) | ||
109 | d.setVar('WKS_TEMPLATE_PATH', wks_file_u) | ||
110 | d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True') | ||
111 | |||
112 | # We need to re-parse each time the file changes, and bitbake | ||
113 | # needs to be told about that explicitly. | ||
114 | bb.parse.mark_dependency(d, wks_file) | ||
115 | |||
116 | try: | ||
117 | with open(wks_file, 'r') as f: | ||
118 | body = f.read() | ||
119 | except (IOError, OSError) as exc: | ||
120 | pass | ||
121 | else: | ||
122 | # Previously, I used expandWithRefs to get the dependency list | ||
123 | # and add it to WICVARS, but there's no point re-parsing the | ||
124 | # file in process_wks_template as well, so just put it in | ||
125 | # a variable and let the metadata deal with the deps. | ||
126 | d.setVar('_WKS_TEMPLATE', body) | ||
127 | bb.build.addtask('do_write_wks_template', 'do_image_wic', 'do_image', d) | ||
128 | bb.build.addtask('do_image_wic', 'do_image_complete', None, d) | ||
129 | } | ||
130 | |||
131 | # | ||
132 | # Write environment variables used by wic | ||
133 | # to tmp/sysroots/<machine>/imgdata/<image>.env | ||
134 | # | ||
135 | python do_rootfs_wicenv () { | ||
136 | wicvars = d.getVar('WICVARS') | ||
137 | if not wicvars: | ||
138 | return | ||
139 | |||
140 | stdir = d.getVar('STAGING_DIR') | ||
141 | outdir = os.path.join(stdir, d.getVar('MACHINE'), 'imgdata') | ||
142 | bb.utils.mkdirhier(outdir) | ||
143 | basename = d.getVar('IMAGE_BASENAME') | ||
144 | with open(os.path.join(outdir, basename) + '.env', 'w') as envf: | ||
145 | for var in wicvars.split(): | ||
146 | value = d.getVar(var) | ||
147 | if value: | ||
148 | envf.write('%s="%s"\n' % (var, value.strip())) | ||
149 | envf.close() | ||
150 | # Copy .env file to deploy directory for later use with stand alone wic | ||
151 | depdir = d.getVar('IMGDEPLOYDIR') | ||
152 | bb.utils.copyfile(os.path.join(outdir, basename) + '.env', os.path.join(depdir, basename) + '.env') | ||
153 | } | ||
154 | addtask do_flush_pseudodb after do_rootfs before do_image do_image_qa | ||
155 | addtask do_rootfs_wicenv after do_image before do_image_wic | ||
156 | do_rootfs_wicenv[vardeps] += "${WICVARS}" | ||
157 | do_rootfs_wicenv[prefuncs] = 'set_image_size' | ||