skeleton-init-systemd.mk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ################################################################################
  2. #
  3. # skeleton-init-systemd
  4. #
  5. ################################################################################
  6. # The skeleton can't depend on the toolchain, since all packages depends on the
  7. # skeleton and the toolchain is a target package, as is skeleton.
  8. # Hence, skeleton would depends on the toolchain and the toolchain would depend
  9. # on skeleton.
  10. SKELETON_INIT_SYSTEMD_ADD_TOOLCHAIN_DEPENDENCY = NO
  11. SKELETON_INIT_SYSTEMD_ADD_SKELETON_DEPENDENCY = NO
  12. SKELETON_INIT_SYSTEMD_DEPENDENCIES = skeleton-init-common
  13. SKELETON_INIT_SYSTEMD_PROVIDES = skeleton
  14. ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
  15. define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
  16. echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
  17. endef
  18. else
  19. # On a R/O rootfs, /var is a tmpfs filesystem. So, at build time, we
  20. # redirect /var to the "factory settings" location. Just before the
  21. # filesystem gets created, the /var symlink will be replaced with
  22. # a real (but empty) directory, and the "factory files" will be copied
  23. # back there by the tmpfiles.d mechanism.
  24. define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
  25. mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d
  26. echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
  27. echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab
  28. endef
  29. define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
  30. rm -rf $(TARGET_DIR)/usr/share/factory/var
  31. mv $(TARGET_DIR)/var $(TARGET_DIR)/usr/share/factory/var
  32. mkdir -p $(TARGET_DIR)/var
  33. for i in $(TARGET_DIR)/usr/share/factory/var/* \
  34. $(TARGET_DIR)/usr/share/factory/var/lib/* \
  35. $(TARGET_DIR)/usr/share/factory/var/lib/systemd/*; do \
  36. [ -e "$${i}" ] || continue; \
  37. j="$${i#$(TARGET_DIR)/usr/share/factory}"; \
  38. if [ -L "$${i}" ]; then \
  39. printf "L+! %s - - - - %s\n" \
  40. "$${j}" "../usr/share/factory/$${j}" \
  41. || exit 1; \
  42. else \
  43. printf "C! %s - - - -\n" "$${j}" \
  44. || exit 1; \
  45. fi; \
  46. done >$(TARGET_DIR)/etc/tmpfiles.d/var-factory.conf
  47. endef
  48. SKELETON_INIT_SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
  49. endif
  50. define SKELETON_INIT_SYSTEMD_INSTALL_TARGET_CMDS
  51. mkdir -p $(TARGET_DIR)/home
  52. mkdir -p $(TARGET_DIR)/srv
  53. mkdir -p $(TARGET_DIR)/var
  54. ln -s ../run $(TARGET_DIR)/var/run
  55. # prevent install scripts to create var/lock as directory
  56. ln -s ../run/lock $(TARGET_DIR)/var/lock
  57. install -D -m644 $(SKELETON_INIT_SYSTEMD_PKGDIR)/legacy.conf $(TARGET_DIR)/usr/lib/tmpfiles.d/legacy.conf
  58. $(SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW)
  59. endef
  60. $(eval $(generic-package))