blob: d2f8105f1315c767b02c2841a0e4e2142cc6ceaf [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
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500153IMAGE_TYPE_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi", "qcow2", "hdddirect"], "image-vm", "", d)}'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154inherit ${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
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500242 # If we're using openssh and the /etc/ssh directory has no pre-generated keys,
243 # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly
244 # and the keys under /var/run/ssh.
245 if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then
246 if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then
247 echo "SYSCONFDIR=/etc/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
248 echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh
249 else
250 echo "SYSCONFDIR=/var/run/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh
251 echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh
252 fi
253 fi
254
255 # Also tweak the key location for dropbear in the same way.
256 if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then
257 if [ -e ${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key ]; then
258 echo "DROPBEAR_RSAKEY_DIR=/etc/dropbear" >> ${IMAGE_ROOTFS}/etc/default/dropbear
259 else
260 echo "DROPBEAR_RSAKEY_DIR=/var/lib/dropbear" >> ${IMAGE_ROOTFS}/etc/default/dropbear
261 fi
262 fi
263
264
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500265 if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then
266 # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes
267 if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then
268 sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS
269 fi
270 # Run populate-volatile.sh at rootfs time to set up basic files
271 # and directories to support read-only rootfs.
272 if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
273 ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
274 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500275 fi
276
277 if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then
278 # Update user database files so that services don't fail for a read-only systemd system
279 for conffile in ${IMAGE_ROOTFS}/usr/lib/sysusers.d/systemd.conf ${IMAGE_ROOTFS}/usr/lib/sysusers.d/systemd-remote.conf; do
280 [ -e $conffile ] || continue
281 grep -v "^#" $conffile | sed -e '/^$/d' | while read type name id comment; do
282 if [ "$type" = "u" ]; then
283 useradd_params=""
284 [ "$id" != "-" ] && useradd_params="$useradd_params --uid $id"
285 [ "$comment" != "-" ] && useradd_params="$useradd_params --comment $comment"
286 useradd_params="$useradd_params --system $name"
287 eval useradd --root ${IMAGE_ROOTFS} $useradd_params || true
288 elif [ "$type" = "g" ]; then
289 groupadd_params=""
290 [ "$id" != "-" ] && groupadd_params="$groupadd_params --gid $id"
291 groupadd_params="$groupadd_params --system $name"
292 eval groupadd --root ${IMAGE_ROOTFS} $groupadd_params || true
293 fi
294 done
295 done
296 fi
297}
298
299PACKAGE_EXCLUDE ??= ""
300PACKAGE_EXCLUDE[type] = "list"
301
302python rootfs_process_ignore() {
303 excl_pkgs = d.getVar("PACKAGE_EXCLUDE", True).split()
304 inst_pkgs = d.getVar("PACKAGE_INSTALL", True).split()
305 inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY", True).split()
306
307 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
308 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
309
310 for pkg in excl_pkgs:
311 if pkg in inst_pkgs:
312 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))
313 inst_pkgs.remove(pkg)
314
315 if pkg in inst_attempt_pkgs:
316 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))
317 inst_attempt_pkgs.remove(pkg)
318
319 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
320 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
321}
322do_rootfs[prefuncs] += "rootfs_process_ignore"
323
324# We have to delay the runtime_mapping_rename until just before rootfs runs
325# otherwise, the multilib renaming could step in and squash any fixups that
326# may have occurred.
327python rootfs_runtime_mapping() {
328 pn = d.getVar('PN', True)
329 runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
330 runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
331 runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
332}
333do_rootfs[prefuncs] += "rootfs_runtime_mapping"
334
335fakeroot python do_rootfs () {
336 from oe.rootfs import create_rootfs
337 from oe.image import create_image
338 from oe.manifest import create_manifest
339
340 # generate the initial manifest
341 create_manifest(d)
342
343 # generate rootfs
344 create_rootfs(d)
345
346 # generate final images
347 create_image(d)
348}
349
350insert_feed_uris () {
351
352 echo "Building feeds for [${DISTRO}].."
353
354 for line in ${FEED_URIS}
355 do
356 # strip leading and trailing spaces/tabs, then split into name and uri
357 line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`"
358 feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`"
359 feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`"
360
361 echo "Added $feed_name feed with URL $feed_uri"
362
363 # insert new feed-sources
364 echo "src/gz $feed_name $feed_uri" >> ${IMAGE_ROOTFS}/etc/opkg/${feed_name}-feed.conf
365 done
366}
367
368MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
369MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
370MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
371
372# This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES.
373zap_empty_root_password () {
374 if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
375 sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
376 fi
377 if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
378 sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
379 fi
380}
381
382# allow dropbear/openssh to accept root logins and logins from accounts with an empty password string
383ssh_allow_empty_password () {
384 if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
385 sed -i 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
386 sed -i 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
387 fi
388
389 if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then
390 if grep -q DROPBEAR_EXTRA_ARGS ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
391 if ! grep -q "DROPBEAR_EXTRA_ARGS=.*-B" ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear ; then
392 sed -i 's/^DROPBEAR_EXTRA_ARGS="*\([^"]*\)"*/DROPBEAR_EXTRA_ARGS="\1 -B"/' ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear
393 fi
394 else
395 printf '\nDROPBEAR_EXTRA_ARGS="-B"\n' >> ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear
396 fi
397 fi
398
399 if [ -d ${IMAGE_ROOTFS}${sysconfdir}/pam.d ] ; then
400 sed -i 's/nullok_secure/nullok/' ${IMAGE_ROOTFS}${sysconfdir}/pam.d/*
401 fi
402}
403
404# Disable DNS lookups, the SSH_DISABLE_DNS_LOOKUP can be overridden to allow
405# distros to choose not to take this change
406SSH_DISABLE_DNS_LOOKUP ?= " ssh_disable_dns_lookup ; "
407ROOTFS_POSTPROCESS_COMMAND_append_qemuall = "${SSH_DISABLE_DNS_LOOKUP}"
408ssh_disable_dns_lookup () {
409 if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then
410 sed -i -e 's:#UseDNS yes:UseDNS no:' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config
411 fi
412}
413
414# Enable postinst logging if debug-tweaks is enabled
415postinst_enable_logging () {
416 mkdir -p ${IMAGE_ROOTFS}${sysconfdir}/default
417 echo "POSTINST_LOGGING=1" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst
418 echo "LOGFILE=${POSTINST_LOGFILE}" >> ${IMAGE_ROOTFS}${sysconfdir}/default/postinst
419}
420
421# Modify systemd default target
422set_systemd_default_target () {
423 if [ -d ${IMAGE_ROOTFS}${sysconfdir}/systemd/system -a -e ${IMAGE_ROOTFS}${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET} ]; then
424 ln -sf ${systemd_unitdir}/system/${SYSTEMD_DEFAULT_TARGET} ${IMAGE_ROOTFS}${sysconfdir}/systemd/system/default.target
425 fi
426}
427
428# If /var/volatile is not empty, we have seen problems where programs such as the
429# journal make assumptions based on the contents of /var/volatile. The journal
430# would then write to /var/volatile before it was mounted, thus hiding the
431# items previously written.
432#
433# This change is to attempt to fix those types of issues in a way that doesn't
434# affect users that may not be using /var/volatile.
435empty_var_volatile () {
436 if [ -e ${IMAGE_ROOTFS}/etc/fstab ]; then
437 match=`awk '$1 !~ "#" && $2 ~ /\/var\/volatile/{print $2}' ${IMAGE_ROOTFS}/etc/fstab 2> /dev/null`
438 if [ -n "$match" ]; then
439 find ${IMAGE_ROOTFS}/var/volatile -mindepth 1 -delete
440 fi
441 fi
442}
443
444# Turn any symbolic /sbin/init link into a file
445remove_init_link () {
446 if [ -h ${IMAGE_ROOTFS}/sbin/init ]; then
447 LINKFILE=${IMAGE_ROOTFS}`readlink ${IMAGE_ROOTFS}/sbin/init`
448 rm ${IMAGE_ROOTFS}/sbin/init
449 cp $LINKFILE ${IMAGE_ROOTFS}/sbin/init
450 fi
451}
452
453make_zimage_symlink_relative () {
454 if [ -L ${IMAGE_ROOTFS}/boot/zImage ]; then
455 (cd ${IMAGE_ROOTFS}/boot/ && for i in `ls zImage-* | sort`; do ln -sf $i zImage; done)
456 fi
457}
458
459python write_image_manifest () {
460 from oe.rootfs import image_list_installed_packages
461 with open(d.getVar('IMAGE_MANIFEST', True), 'w+') as image_manifest:
462 image_manifest.write(image_list_installed_packages(d, 'ver'))
463 image_manifest.write("\n")
464}
465
466# Can be use to create /etc/timestamp during image construction to give a reasonably
467# sane default time setting
468rootfs_update_timestamp () {
469 date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
470}
471
472# Prevent X from being started
473rootfs_no_x_startup () {
474 if [ -f ${IMAGE_ROOTFS}/etc/init.d/xserver-nodm ]; then
475 chmod a-x ${IMAGE_ROOTFS}/etc/init.d/xserver-nodm
476 fi
477}
478
479rootfs_trim_schemas () {
480 for schema in ${IMAGE_ROOTFS}/etc/gconf/schemas/*.schemas
481 do
482 # Need this in case no files exist
483 if [ -e $schema ]; then
484 oe-trim-schemas $schema > $schema.new
485 mv $schema.new $schema
486 fi
487 done
488}
489
490rootfs_check_host_user_contaminated () {
491 contaminated="${WORKDIR}/host-user-contaminated.txt"
492 HOST_USER_UID="$(PSEUDO_UNLOAD=1 id -u)"
493 HOST_USER_GID="$(PSEUDO_UNLOAD=1 id -g)"
494
495 find "${IMAGE_ROOTFS}" -wholename "${IMAGE_ROOTFS}/home" -prune \
496 -user "$HOST_USER_UID" -o -group "$HOST_USER_GID" >"$contaminated"
497
498 if [ -s "$contaminated" ]; then
499 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."
500 cat "$contaminated" | sed "s,^, ,"
501 fi
502}
503
504# Make any absolute links in a sysroot relative
505rootfs_sysroot_relativelinks () {
506 sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
507}
508
509do_fetch[noexec] = "1"
510do_unpack[noexec] = "1"
511do_patch[noexec] = "1"
512do_configure[noexec] = "1"
513do_compile[noexec] = "1"
514do_install[noexec] = "1"
515do_populate_sysroot[noexec] = "1"
516do_package[noexec] = "1"
517do_package_qa[noexec] = "1"
518do_packagedata[noexec] = "1"
519do_package_write_ipk[noexec] = "1"
520do_package_write_deb[noexec] = "1"
521do_package_write_rpm[noexec] = "1"
522
523addtask rootfs before do_build
524# Allow the kernel to be repacked with the initramfs and boot image file as a single file
525do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs"
526do_bundle_initramfs[nostamp] = "1"
527do_bundle_initramfs[noexec] = "1"
528do_bundle_initramfs () {
529 :
530}
531addtask bundle_initramfs after do_rootfs