oci.mk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ################################################################################
  2. #
  3. # Build the oci image
  4. #
  5. ################################################################################
  6. ROOTFS_OCI_DEPENDENCIES = host-sloci-image
  7. # architecture - take it from Go
  8. OCI_SLOCI_IMAGE_OPTS = --arch $(GO_GOARCH)
  9. # architecture variant (typically used only for arm)
  10. OCI_SLOCI_IMAGE_OPTS += $(and $(GO_GOARM),--arch-variant v$(GO_GOARM))
  11. # entrypoint and command
  12. # Special treatment: both the entrypoint and arguments (aka command) are
  13. # a double-quoted, space-separated, escaped-double-quoted string, like:
  14. # "foo \"1 2 3 4\" ' a b c d ' bar\ buz"
  15. # which should be interpreted as a 4-item list (using single quotes to
  16. # delimit them and see leading/trailing spaces):
  17. # 'foo'
  18. # '1 2 3 4'
  19. # ' a b c d '
  20. # 'bar buz'
  21. #
  22. # We use some trickery to have the shell properly expand this into a list
  23. # where each item is single-quoted and prefixed with the appropriate
  24. # option string:
  25. OCI_SLOCI_IMAGE_OPTS += \
  26. $(shell eval printf -- "--entrypoint\ \'%s\'\ " $(BR2_TARGET_ROOTFS_OCI_ENTRYPOINT)) \
  27. $(shell eval printf -- "--cmd\ \'%s\'\ " $(BR2_TARGET_ROOTFS_OCI_CMD))
  28. # author
  29. OCI_AUTHOR = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_AUTHOR))
  30. ifneq ($(OCI_AUTHOR),)
  31. OCI_SLOCI_IMAGE_OPTS += --author "$(OCI_AUTHOR)"
  32. endif
  33. # username or UID
  34. OCI_UID = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_UID))
  35. ifneq ($(OCI_UID),)
  36. OCI_SLOCI_IMAGE_OPTS += --user "$(OCI_UID)"
  37. endif
  38. # labels
  39. OCI_LABELS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_LABELS))
  40. ifneq ($(OCI_LABELS),)
  41. OCI_SLOCI_IMAGE_OPTS += \
  42. $(foreach label,$(OCI_LABELS),--label "$(label)")
  43. endif
  44. # environment variables
  45. OCI_ENV_VARS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_ENV_VARS))
  46. ifneq ($(OCI_ENV_VARS),)
  47. OCI_SLOCI_IMAGE_OPTS += \
  48. $(foreach var,$(OCI_ENV_VARS),--env "$(var)")
  49. endif
  50. # working directory
  51. OCI_WORKDIR = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_WORKDIR))
  52. ifneq ($(OCI_WORKDIR),)
  53. OCI_SLOCI_IMAGE_OPTS += --working-dir "$(OCI_WORKDIR)"
  54. endif
  55. # ports
  56. OCI_PORTS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_PORTS))
  57. ifneq ($(OCI_PORTS),)
  58. OCI_SLOCI_IMAGE_OPTS += \
  59. $(foreach port,$(OCI_PORTS),--port "$(port)")
  60. endif
  61. # tag
  62. OCI_TAG = $(or $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_TAG)),latest)
  63. # enable tar archive
  64. ifeq ($(BR2_TARGET_ROOTFS_OCI_ARCHIVE),y)
  65. OCI_SLOCI_IMAGE_OPTS += --tar
  66. endif
  67. define ROOTFS_OCI_CMD
  68. rm -rf $(BINARIES_DIR)/rootfs-oci
  69. $(HOST_DIR)/bin/sloci-image $(OCI_SLOCI_IMAGE_OPTS) $(TARGET_DIR) \
  70. $(BINARIES_DIR)/rootfs-oci:$(OCI_TAG)
  71. endef
  72. $(eval $(rootfs))