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