blob: 86a98bb11dc58339e234d7832581f2fb19994f43 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit rootfs_${IMAGE_PKGTYPE}
2
3inherit populate_sdk_ext
4
5TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
6TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
7POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_sysroot_relativelinks; "
8
9inherit gzipnative
10
11LICENSE = "MIT"
12PACKAGES = ""
13DEPENDS += "${MLPREFIX}qemuwrapper-cross ${MLPREFIX}depmodwrapper-cross"
14RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL}"
15RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}"
16
17INHIBIT_DEFAULT_DEPS = "1"
18
19TESTIMAGECLASS = "${@base_conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}"
20inherit ${TESTIMAGECLASS}
21
22# IMAGE_FEATURES may contain any available package group
23IMAGE_FEATURES ?= ""
24IMAGE_FEATURES[type] = "list"
25IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs empty-root-password allow-empty-password post-install-logging"
26
27# Generate companion debugfs?
28IMAGE_GEN_DEBUGFS ?= "0"
29
30# rootfs bootstrap install
31ROOTFS_BOOTSTRAP_INSTALL = "${@bb.utils.contains("IMAGE_FEATURES", "package-management", "", "${ROOTFS_PKGMANAGE_BOOTSTRAP}",d)}"
32
33# packages to install from features
34FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
35FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}"
36FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
37FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}"
38
39# Define some very basic feature package groups
40FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}"
41SPLASH ?= "psplash"
42FEATURE_PACKAGES_splash = "${SPLASH}"
43
44IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}'
45
46def check_image_features(d):
47 valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems', True) or "").split()
48 valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys()
49 for var in d:
50 if var.startswith("PACKAGE_GROUP_"):
51 bb.warn("PACKAGE_GROUP is deprecated, please use FEATURE_PACKAGES instead")
52 valid_features.append(var[14:])
53 elif var.startswith("FEATURE_PACKAGES_"):
54 valid_features.append(var[17:])
55 valid_features.sort()
56
57 features = set(oe.data.typed_value('IMAGE_FEATURES', d))
58 for feature in features:
59 if feature not in valid_features:
60 if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d):
61 raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES (added via EXTRA_IMAGE_FEATURES) is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
62 else:
63 raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
64
65IMAGE_INSTALL ?= ""
66IMAGE_INSTALL[type] = "list"
67export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}"
68PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}"
69
70# Images are generally built explicitly, do not need to be part of world.
71EXCLUDE_FROM_WORLD = "1"
72
73USE_DEVFS ?= "1"
74USE_DEPMOD ?= "1"
75
76PID = "${@os.getpid()}"
77
78PACKAGE_ARCH = "${MACHINE_ARCH}"
79
80LDCONFIGDEPEND ?= "ldconfig-native:do_populate_sysroot"
81LDCONFIGDEPEND_libc-uclibc = ""
82LDCONFIGDEPEND_libc-musl = ""
83
84# This is needed to have depmod data in PKGDATA_DIR,
85# but if you're building small initramfs image
86# e.g. to include it in your kernel, you probably
87# don't want this dependency, which is causing dependency loop
88KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata"
89
90do_rootfs[depends] += " \
91 makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \
92 virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \
93 ${KERNELDEPMODDEPEND} \
94"
95do_rootfs[recrdeptask] += "do_packagedata"
96
97def command_variables(d):
98 return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND',
99 'IMAGE_PREPROCESS_COMMAND','ROOTFS_POSTPROCESS_COMMAND','POPULATE_SDK_POST_HOST_COMMAND','POPULATE_SDK_POST_TARGET_COMMAND','SDK_POSTPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS',
100 'RPM_POSTPROCESS_COMMANDS']
101
102python () {
103 variables = command_variables(d)
104 for var in variables:
105 if d.getVar(var, False):
106 d.setVarFlag(var, 'func', '1')
107}
108
Patrick Williamsd7e96312015-09-22 08:09:05 -0500109def fstype_variables(d):
110 import oe.image
111
112 image = oe.image.Image(d)
113 alltypes, fstype_groups, cimages = image._get_image_types()
114 fstype_vars = set()
115 for fstype_group in fstype_groups:
116 for fstype in fstype_group:
117 fstype_vars.add('IMAGE_CMD_' + fstype)
118 if fstype in cimages:
119 for ctype in cimages[fstype]:
120 fstype_vars.add('COMPRESS_CMD_' + ctype)
121
122 return sorted(fstype_vars)
123
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124def rootfs_variables(d):
125 from oe.rootfs import variable_depends
Patrick Williamsd7e96312015-09-22 08:09:05 -0500126 variables = ['IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE','IMAGE_ROOTFS_EXTRA_SPACE',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','RM_OLD_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS','SDK_OS',
128 'SDK_OUTPUT','SDKPATHNATIVE','SDKTARGETSYSROOT','SDK_DIR','SDK_VENDOR','SDKIMAGE_INSTALL_COMPLEMENTARY','SDK_PACKAGE_ARCHS','SDK_OUTPUT','SDKTARGETSYSROOT','MULTILIBRE_ALLOW_REP',
129 'MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS','PACKAGE_ARCHS',
130 'PACKAGE_CLASSES','TARGET_VENDOR','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS',
131 'COMPRESSIONTYPES', 'IMAGE_GEN_DEBUGFS']
Patrick Williamsd7e96312015-09-22 08:09:05 -0500132 variables.extend(fstype_variables(d))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 variables.extend(command_variables(d))
134 variables.extend(variable_depends(d))
135 return " ".join(variables)
136
137do_rootfs[vardeps] += "${@rootfs_variables(d)}"
138
139do_build[depends] += "virtual/kernel:do_deploy"
140
141def build_live(d):
142 if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg
143 d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d))
144 d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d))
145 if d.getVar('NOISO', True) == "0" or d.getVar('NOHDD', True) == "0":
146 return "image-live"
147 return ""
148 return "image-live"
149
150IMAGE_TYPE_live = "${@build_live(d)}"
151inherit ${IMAGE_TYPE_live}
152
153IMAGE_TYPE_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi", "qcow2"], "image-vm", "", d)}'
154inherit ${IMAGE_TYPE_vm}
155
156python () {
157 deps = " " + imagetypes_getdepends(d)
158 d.appendVarFlag('do_rootfs', 'depends', deps)
159
160 deps = ""
161 for dep in (d.getVar('EXTRA_IMAGEDEPENDS', True) or "").split():
162 deps += " %s:do_populate_sysroot" % dep
163 d.appendVarFlag('do_build', 'depends', deps)
164
165 #process IMAGE_FEATURES, we must do this before runtime_mapping_rename
166 #Check for replaces image features
167 features = set(oe.data.typed_value('IMAGE_FEATURES', d))
168 remain_features = features.copy()
169 for feature in features:
170 replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature, True) or "").split())
171 remain_features -= replaces
172
173 #Check for conflict image features
174 for feature in remain_features:
175 conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature, True) or "").split())
176 temp = conflicts & remain_features
177 if temp:
178 bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN', True), feature, ' '.join(list(temp))))
179
180 d.setVar('IMAGE_FEATURES', ' '.join(list(remain_features)))
181
182 check_image_features(d)
183 initramfs_image = d.getVar('INITRAMFS_IMAGE', True) or ""
184 if initramfs_image != "":
185 d.appendVarFlag('do_build', 'depends', " %s:do_bundle_initramfs" % d.getVar('PN', True))
186 d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_rootfs" % initramfs_image)
187}
188
189IMAGE_CLASSES += "image_types"
190inherit ${IMAGE_CLASSES}
191
192IMAGE_POSTPROCESS_COMMAND ?= ""
193
194# Zap the root password if debug-tweaks feature is not enabled
195ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'empty-root-password' ], "", "zap_empty_root_password ; ",d)}'
196
197# Allow dropbear/openssh to accept logins from accounts with an empty password string if debug-tweaks is enabled
198ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-empty-password' ], "ssh_allow_empty_password; ", "",d)}'
199
200# Enable postinst logging if debug-tweaks is enabled
201ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'post-install-logging' ], "postinst_enable_logging; ", "",d)}'
202
203# Create /etc/timestamp during image construction to give a reasonably sane default time setting
204ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
205
206# Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is enabled
207ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
208
209# Write manifest
210IMAGE_MANIFEST = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.manifest"
211ROOTFS_POSTUNINSTALL_COMMAND =+ "write_image_manifest ; "
212# Set default postinst log file
213POSTINST_LOGFILE ?= "${localstatedir}/log/postinstall.log"
214# Set default target for systemd images
215SYSTEMD_DEFAULT_TARGET ?= '${@bb.utils.contains("IMAGE_FEATURES", "x11-base", "graphical.target", "multi-user.target", d)}'
216ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("DISTRO_FEATURES", "systemd", "set_systemd_default_target; ", "", d)}'
217
218ROOTFS_POSTPROCESS_COMMAND += 'empty_var_volatile;'
219
220# some default locales
221IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
222
223LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS', True).split()))}"
224
225# Prefer image, but use the fallback files for lookups if the image ones
226# aren't yet available.
227PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
228
229do_rootfs[dirs] = "${TOPDIR}"
230do_rootfs[lockfiles] += "${IMAGE_ROOTFS}.lock"
231do_rootfs[cleandirs] += "${S}"
232
233# Must call real_do_rootfs() from inside here, rather than as a separate
234# task, so that we have a single fakeroot context for the whole process.
235do_rootfs[umask] = "022"
236
237# A hook function to support read-only-rootfs IMAGE_FEATURES
238read_only_rootfs_hook () {
239 # Tweak the mount option and fs_passno for rootfs in fstab
240 sed -i -e '/^[#[:space:]]*\/dev\/root/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}' ${IMAGE_ROOTFS}/etc/fstab
241
242 if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
243 # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
244 if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
245 sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS
246 fi
247 # Run populate-volatile.sh at rootfs time to set up basic files
248 # and directories to support read-only rootfs.
249 if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
250 ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
251 fi
252 # If we're using openssh and the /etc/ssh directory has no pre-generated keys,
253 # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
254 # and the keys under /var/run/ssh.
255 if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
256 if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
257 echo "SYSCONFDIR=/etc/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
258 echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
259 else
260 echo "SYSCONFDIR=/var/run/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
261 echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh
262 fi
263 fi
264 fi
265
266 if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then
267 # Update user database files so that services don't fail for a read-only systemd system
268 for conffile in ${IMAGE_ROOTFS}/usr/lib/sysusers.d/systemd.conf ${IMAGE_ROOTFS}/usr/lib/sysusers.d/systemd-remote.conf; do
269 [ -e $conffile ] || continue
270 grep -v "^#" $conffile | sed -e '/^$/d' | while read type name id comment; do
271 if [ "$type" = "u" ]; then
272 useradd_params=""
273 [ "$id" != "-" ] && useradd_params="$useradd_params --uid $id"
274 [ "$comment" != "-" ] && useradd_params="$useradd_params --comment $comment"
275 useradd_params="$useradd_params --system $name"
276 eval useradd --root ${IMAGE_ROOTFS} $useradd_params || true
277 elif [ "$type" = "g" ]; then
278 groupadd_params=""
279 [ "$id" != "-" ] && groupadd_params="$groupadd_params --gid $id"
280 groupadd_params="$groupadd_params --system $name"
281 eval groupadd --root ${IMAGE_ROOTFS} $groupadd_params || true
282 fi
283 done
284 done
285 fi
286}
287
288PACKAGE_EXCLUDE ??= ""
289PACKAGE_EXCLUDE[type] = "list"
290
291python rootfs_process_ignore() {
292 excl_pkgs = d.getVar("PACKAGE_EXCLUDE", True).split()
293 inst_pkgs = d.getVar("PACKAGE_INSTALL", True).split()
294 inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY", True).split()
295
296 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
297 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
298
299 for pkg in excl_pkgs:
300 if pkg in inst_pkgs:
301 bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL (%s). It will be removed from the list." % (pkg, d.getVar('PN', True), inst_pkgs))
302 inst_pkgs.remove(pkg)
303
304 if pkg in inst_attempt_pkgs:
305 bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL_ATTEMPTONLY (%s). It will be removed from the list." % (pkg, d.getVar('PN', True), inst_pkgs))
306 inst_attempt_pkgs.remove(pkg)
307
308 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
309 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
310}
311do_rootfs[prefuncs] += "rootfs_process_ignore"
312
313# We have to delay the runtime_mapping_rename until just before rootfs runs
314# otherwise, the multilib renaming could step in and squash any fixups that
315# may have occurred.
316python rootfs_runtime_mapping() {
317 pn = d.getVar('PN', True)
318 runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
319 runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
320 runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
321}
322do_rootfs[prefuncs] += "rootfs_runtime_mapping"
323
324fakeroot python do_rootfs () {
325 from oe.rootfs import create_rootfs
326 from oe.image import create_image
327 from oe.manifest import create_manifest
328
329 # generate the initial manifest
330 create_manifest(d)
331
332 # generate rootfs
333 create_rootfs(d)
334
335 # generate final images
336 create_image(d)
337}
338
339insert_feed_uris () {
340
341 echo "Building feeds for [${DISTRO}].."
342
343 for line in ${FEED_URIS}
344 do
345 # strip leading and trailing spaces/tabs, then split into name and uri
346 line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
347 feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
348 feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
349
350 echo "Added $feed_name feed with URL $feed_uri"
351
352 # insert new feed-sources
353 echo "src/gz $feed_name $feed_uri" >> ${IMAGE_ROOTFS}/etc/opkg/${feed_name}-feed.conf
354 done
355}
356
357MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
358MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
359MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
360
361# This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES.
362zap_empty_root_password () {
363 if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
364 sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
365 fi
366 if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
367 sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
368 fi
369}
370
371# allow dropbear/openssh to accept root logins and logins from accounts with an empty password string
372ssh_allow_empty_password () {
373 if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
374 sed -i 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
375 sed -i 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
376 fi
377
378 if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
379 if grep -q DROPBEAR_EXTRA_ARGS ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
380 if ! grep -q "DROPBEAR_EXTRA_ARGS=.*-B" ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear ; then
381 sed -i 's/^DROPBEAR_EXTRA_ARGS="*\([^"]*\)"*/DROPBEAR_EXTRA_ARGS="\1 -B"/' ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear
382 fi
383 else
384 printf '\nDROPBEAR_EXTRA_ARGS="-B"\n' >> ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear
385 fi
386 fi
387
388 if [ -d ${IMAGE_ROOTFS}${sysconfdir}/pam.d ] ; then
389 sed -i 's/nullok_secure/nullok/' ${IMAGE_ROOTFS}${sysconfdir}/pam.d/*
390 fi
391}
392
393# Disable DNS lookups, the SSH_DISABLE_DNS_LOOKUP can be overridden to allow
394# distros to choose not to take this change
395SSH_DISABLE_DNS_LOOKUP ?= " ssh_disable_dns_lookup ; "
396ROOTFS_POSTPROCESS_COMMAND_append_qemuall = "${SSH_DISABLE_DNS_LOOKUP}"
397ssh_disable_dns_lookup () {
398 if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
399 sed -i -e 's:#UseDNS yes:UseDNS no:' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
400 fi
401}
402
403# Enable postinst logging if debug-tweaks is enabled
404postinst_enable_logging () {
405 mkdir -p ${IMAGE_ROOTFS}${sysconfdir}/default
406 echo "POSTINST_LOGGING=1" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst
407 echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst
408}
409
410# Modify systemd default target
411set_systemd_default_target () {
412 if [ -d ${IMAGE_ROOTFS}${sysconfdir}/systemd/system -a -e ${IMAGE_ROOTFS}${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET} ]; then
413 ln -sf ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET} ${IMAGE_ROOTFS}${sysconfdir}/systemd/system/default.target
414 fi
415}
416
417# If /var/volatile is not empty, we have seen problems where programs such as the
418# journal make assumptions based on the contents of /var/volatile. The journal
419# would then write to /var/volatile before it was mounted, thus hiding the
420# items previously written.
421#
422# This change is to attempt to fix those types of issues in a way that doesn't
423# affect users that may not be using /var/volatile.
424empty_var_volatile () {
425 if [ -e ${IMAGE_ROOTFS}/etc/fstab ]; then
426 match=`awk '$1 !~ "#" && $2 ~ /\/var\/volatile/{print $2}' ${IMAGE_ROOTFS}/etc/fstab 2> /dev/null`
427 if [ -n "$match" ]; then
428 find ${IMAGE_ROOTFS}/var/volatile -mindepth 1 -delete
429 fi
430 fi
431}
432
433# Turn any symbolic /sbin/init link into a file
434remove_init_link () {
435 if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then
436 LINKFILE=${IMAGE_ROOTFS}`readlink ${IMAGE_ROOTFS}/sbin/init`
437 rm ${IMAGE_ROOTFS}/sbin/init
438 cp $LINKFILE ${IMAGE_ROOTFS}/sbin/init
439 fi
440}
441
442make_zimage_symlink_relative () {
443 if [ -L ${IMAGE_ROOTFS}/boot/zImage ]; then
444 (cd ${IMAGE_ROOTFS}/boot/ && for i in `ls zImage-* | sort`; do ln -sf $i zImage; done)
445 fi
446}
447
448python write_image_manifest () {
449 from oe.rootfs import image_list_installed_packages
450 with open(d.getVar('IMAGE_MANIFEST', True), 'w+') as image_manifest:
451 image_manifest.write(image_list_installed_packages(d, 'ver'))
452 image_manifest.write("\n")
453}
454
455# Can be use to create /etc/timestamp during image construction to give a reasonably
456# sane default time setting
457rootfs_update_timestamp () {
458 date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
459}
460
461# Prevent X from being started
462rootfs_no_x_startup () {
463 if [ -f ${IMAGE_ROOTFS}/etc/init.d/xserver-nodm ]; then
464 chmod a-x ${IMAGE_ROOTFS}/etc/init.d/xserver-nodm
465 fi
466}
467
468rootfs_trim_schemas () {
469 for schema in ${IMAGE_ROOTFS}/etc/gconf/schemas/*.schemas
470 do
471 # Need this in case no files exist
472 if [ -e $schema ]; then
473 oe-trim-schemas $schema > $schema.new
474 mv $schema.new $schema
475 fi
476 done
477}
478
479rootfs_check_host_user_contaminated () {
480 contaminated="${WORKDIR}/host-user-contaminated.txt"
481 HOST_USER_UID="$(PSEUDO_UNLOAD=1 id -u)"
482 HOST_USER_GID="$(PSEUDO_UNLOAD=1 id -g)"
483
484 find "${IMAGE_ROOTFS}" -wholename "${IMAGE_ROOTFS}/home" -prune \
485 -user "$HOST_USER_UID" -o -group "$HOST_USER_GID" >"$contaminated"
486
487 if [ -s "$contaminated" ]; then
488 echo "WARNING: Paths in the rootfs are owned by the same user or group as the user running bitbake. See the logfile for the specific paths."
489 cat "$contaminated" | sed "s,^, ,"
490 fi
491}
492
493# Make any absolute links in a sysroot relative
494rootfs_sysroot_relativelinks () {
495 sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
496}
497
498do_fetch[noexec] = "1"
499do_unpack[noexec] = "1"
500do_patch[noexec] = "1"
501do_configure[noexec] = "1"
502do_compile[noexec] = "1"
503do_install[noexec] = "1"
504do_populate_sysroot[noexec] = "1"
505do_package[noexec] = "1"
506do_package_qa[noexec] = "1"
507do_packagedata[noexec] = "1"
508do_package_write_ipk[noexec] = "1"
509do_package_write_deb[noexec] = "1"
510do_package_write_rpm[noexec] = "1"
511
512addtask rootfs before do_build
513# Allow the kernel to be repacked with the initramfs and boot image file as a single file
514do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs"
515do_bundle_initramfs[nostamp] = "1"
516do_bundle_initramfs[noexec] = "1"
517do_bundle_initramfs () {
518 :
519}
520addtask bundle_initramfs after do_rootfs