github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/stage1/aci/aci-install.mk (about)

     1  # Here we create a set of directories inside the ACI rootfs directory,
     2  # generate a manifest and copy it along with the os-release file to the
     3  # ACI rootfs directory.
     4  #
     5  # AMI_FLAVOR - flavor for which directories and manifest should be
     6  # created and copied along with the os-release file into the ACI
     7  # rootfs directory.
     8  #
     9  # AMI_TMPDIR - a directory where this file can put its temporary files
    10  
    11  # the ACI rootfs for this flavor
    12  AMI_ACIROOTFSDIR := $(STAGE1_ACIROOTFSDIR_$(AMI_FLAVOR))
    13  # dirs base and rests
    14  AMI_ACI_DIRS_BASE := $(AMI_ACIROOTFSDIR)
    15  AMI_ACI_DIRS_RESTS := \
    16  	etc \
    17  	opt/stage2 \
    18  	rkt/iottymux \
    19  	rkt/status \
    20  	rkt/env
    21  # all the directories we want to be created in the ACI rootfs
    22  AMI_ACI_DIR_CHAINS := \
    23  	$(foreach r,$(AMI_ACI_DIRS_RESTS), \
    24  		$(call dir-chain,$(AMI_ACI_DIRS_BASE),$r))
    25  # all final directories to be created
    26  AMI_ACI_INSTALLED_DIRS := $(addprefix $(AMI_ACI_DIRS_BASE)/,$(AMI_ACI_DIRS_RESTS))
    27  # os-release in /etc in the ACI rootfs
    28  AMI_ACI_OS_RELEASE := $(AMI_ACI_DIRS_BASE)/etc/os-release
    29  # manifest in the ACI directory
    30  AMI_ACI_MANIFEST := $(STAGE1_ACIDIR_$(AMI_FLAVOR))/manifest
    31  # generated manifest to be copied to the ACI directory
    32  AMI_GEN_MANIFEST := $(AMI_TMPDIR)/aci-manifest-$(AMI_FLAVOR)
    33  # a manifest template
    34  AMI_SRC_MANIFEST := $(MK_SRCDIR)/aci-manifest.in
    35  # a name for this flavor
    36  AMI_NAME := coreos.com/rkt/stage1-$(AMI_FLAVOR)
    37  # list of installed files and symlinks
    38  AMI_INSTALLED_FILES := \
    39  	$(AMI_ACI_OS_RELEASE) \
    40  	$(AMI_ACI_MANIFEST) \
    41  	$(AMI_ACI_DIRS_BASE)/etc/mtab
    42  
    43  ifeq ($(AMI_FLAVOR),src)
    44  
    45  # src flavor has a slightly different rule about its name - we append
    46  # the systemd version to it too
    47  
    48  AMI_NAME := $(AMI_NAME)-$(RKT_STAGE1_SYSTEMD_VER)
    49  
    50  endif
    51  
    52  # stage1 version, usually the same as rkt version, unless we override
    53  # it with something else
    54  AMI_STAGE1_VERSION := $(RKT_VERSION)
    55  
    56  ifneq ($(RKT_STAGE1_VERSION_OVERRIDE),)
    57  
    58  AMI_STAGE1_VERSION := $(RKT_STAGE1_VERSION_OVERRIDE)
    59  
    60  endif
    61  
    62  # escaped values of the ACI name, version and enter command, so
    63  # they can be safely used in the replacement part of sed's s///
    64  # command.
    65  AMI_SED_NAME := $(call sed-replacement-escape,$(AMI_NAME))
    66  AMI_SED_VERSION := $(call sed-replacement-escape,$(AMI_STAGE1_VERSION))
    67  AMI_SED_ENTER := $(call sed-replacement-escape,$(STAGE1_ENTER_CMD_$(AMI_FLAVOR)))
    68  AMI_SED_ARCH := $(call sed-replacement-escape,$(RKT_ACI_ARCH))
    69  AMI_SED_STOP := $(call sed-replacement-escape,$(STAGE1_STOP_CMD_$(AMI_FLAVOR)))
    70  
    71  # main stamp ensures everything is done
    72  $(call setup-stamp-file,AMI_STAMP,$(AMI_FLAVOR)-main)
    73  
    74  # stamp and dep file for invalidating the generated manifest if name,
    75  # version or enter command changes for this flavor
    76  $(call setup-stamp-file,AMI_MANIFEST_KV_DEPMK_STAMP,$(AMI_FLAVOR)-manifest-kv-dep)
    77  $(call setup-dep-file,AMI_MANIFEST_KV_DEPMK,$(AMI_FLAVOR)-manifest-kv-dep)
    78  
    79  # stamp and dep file for invalidating the ACI rootfs removing stamp if
    80  # the list of installed files or directories change
    81  $(call setup-stamp-file,AMI_INSTALLED_KV_DEPMK_STAMP,$(AMI_FLAVOR)-installed-kv-dep)
    82  $(call setup-dep-file,AMI_INSTALLED_KV_DEPMK,$(AMI_FLAVOR)-installed-kv-dep)
    83  
    84  # stamp for removing the ACI rootfs if installed files/directories change
    85  $(call setup-stamp-file,AMI_RMDIR_STAMP,$(AMI_FLAVOR)-acirootfs-remove)
    86  
    87  # main stamp rule - makes sure that os-release, manifest and specific
    88  # directories are inside the ACI rootfs and deps file are generated
    89  $(call generate-stamp-rule,$(AMI_STAMP),$(AMI_INSTALLED_FILES) $(AMI_MANIFEST_KV_DEPMK_STAMP) $(AMI_INSTALLED_KV_DEPMK_STAMP),$(AMI_ACI_INSTALLED_DIRS))
    90  
    91  # this rule generates a manifest
    92  $(call forward-vars,$(AMI_GEN_MANIFEST), \
    93  	AMI_FLAVOR AMI_SED_NAME AMI_SED_VERSION AMI_SED_ENTER AMI_SED_ARCH AMI_SED_STOP)
    94  $(AMI_GEN_MANIFEST): $(AMI_SRC_MANIFEST) | $(AMI_TMPDIR)
    95  	$(VQ) \
    96  	set -e; \
    97  	$(call vb,vt,MANIFEST,$(AMI_FLAVOR)) \
    98  	sed \
    99  		-e 's/@RKT_STAGE1_NAME@/$(AMI_SED_NAME)/g' \
   100  		-e 's/@RKT_STAGE1_VERSION@/$(AMI_SED_VERSION)/g' \
   101  		-e 's/@RKT_STAGE1_ENTER@/$(AMI_SED_ENTER)/g' \
   102  		-e 's/@RKT_STAGE1_ARCH@/$(AMI_SED_ARCH)/g' \
   103  		-e 's/@RKT_STAGE1_STOP@/$(AMI_SED_STOP)/g' \
   104  	"$<" >"$@.tmp"; \
   105  	$(call bash-cond-rename,$@.tmp,$@)
   106  
   107  # invalidate generated manifest if name, version, arch, enter or stop cmd changes
   108  $(call generate-kv-deps,$(AMI_MANIFEST_KV_DEPMK_STAMP),$(AMI_GEN_MANIFEST),$(AMI_MANIFEST_KV_DEPMK),AMI_SED_NAME AMI_SED_VERSION AMI_SED_ARCH AMI_SED_STOP AMI_SED_ENTER)
   109  
   110  # this removes the ACI rootfs dir
   111  $(call generate-rm-dir-rule,$(AMI_RMDIR_STAMP),$(AMI_ACIROOTFSDIR))
   112  
   113  # invalidate the ACI rootfs removing stamp if installed files change
   114  $(call generate-kv-deps,$(AMI_INSTALLED_KV_DEPMK_STAMP),$(AMI_RMDIR_STAMP),$(AMI_INSTALLED_KV_DEPMK),AMI_INSTALLED_FILES AMI_ACI_INSTALLED_DIRS)
   115  
   116  STAGE1_INSTALL_DIRS_$(AMI_FLAVOR) += $(addsuffix :0755,$(AMI_ACI_DIR_CHAINS))
   117  STAGE1_INSTALL_FILES_$(AMI_FLAVOR) += \
   118  	$(AMI_GEN_MANIFEST):$(AMI_ACI_MANIFEST):0644 \
   119  	$(MK_SRCDIR)/os-release:$(AMI_ACI_OS_RELEASE):0644
   120  STAGE1_INSTALL_SYMLINKS_$(AMI_FLAVOR) += \
   121  	../proc/self/mounts:$(AMI_ACI_DIRS_BASE)/etc/mtab
   122  STAGE1_SECONDARY_STAMPS_$(AMI_FLAVOR) += $(AMI_STAMP)
   123  CLEAN_FILES += $(AMI_GEN_MANIFEST)
   124  
   125  $(call undefine-namespaces,AMI)