github.com/stackdocker/rkt@v0.10.1-0.20151109095037-1aa827478248/stage1/units/units-install.mk (about)

     1  # This file puts all the units and symlinks into the ACI rootfs
     2  # directory for given flavor. Also, makes sure that some directores
     3  # are created.
     4  #
     5  # Inputs
     6  #
     7  # UNI_FLAVOR - a flavor
     8  
     9  # unit dir in source tree
    10  UNI_SRC_UNITDIR := $(MK_SRCDIR)/units
    11  # all target unit files in source tree
    12  UNI_SRC_TARGET_UNITS := $(wildcard $(UNI_SRC_UNITDIR)/*.target)
    13  # all service unit files in source tree
    14  UNI_SRC_SERVICE_UNITS := $(wildcard $(UNI_SRC_UNITDIR)/*.service)
    15  # all units
    16  UNI_SRC_UNITS := $(UNI_SRC_TARGET_UNITS) $(UNI_SRC_SERVICE_UNITS)
    17  # the following two lists have equal length
    18  # targets for symlinks in the ACI unit directory
    19  UNI_SYMLINK_TARGETS := reboot.target
    20  # filenames of the symlinks in the ACI unit directory
    21  UNI_SYMLINK_FILENAMES := ctrl-alt-del.target
    22  
    23  # ACI rootfs
    24  UNI_ACIROOTFSDIR := $(STAGE1_ACIROOTFSDIR_$(UNI_FLAVOR))
    25  # base and rest for units directory in the ACI rootfs
    26  UNI_UNITDIR_BASE := $(UNI_ACIROOTFSDIR)
    27  UNI_UNITDIR_REST := usr/lib/systemd/system
    28  # rests for all the directories we want to have in the ACI rootfs
    29  UNI_UNITDIR_RESTS := \
    30          $(UNI_UNITDIR_REST) \
    31          $(UNI_UNITDIR_REST)/default.target.wants \
    32          $(UNI_UNITDIR_REST)/sockets.target.wants
    33  # main directory for the units
    34  UNI_UNITDIR := $(UNI_UNITDIR_BASE)/$(UNI_UNITDIR_REST)
    35  # all unit directories
    36  UNI_UNIT_DIRS := $(foreach d,$(UNI_UNITDIR_RESTS),$(UNI_UNITDIR_BASE)/$d)
    37  # all symlinks in aci
    38  UNI_SYMLINKS := $(addprefix $(UNI_UNITDIR)/,$(UNI_SYMLINK_FILENAMES))
    39  # all units in aci
    40  UNI_UNITS := $(addprefix $(UNI_UNITDIR)/,$(notdir $(UNI_SRC_UNITS)))
    41  # all directory chains in aci
    42  UNI_DIR_CHAINS := $(sort $(foreach r,$(UNI_UNITDIR_RESTS),$(call dir-chain,$(UNI_UNITDIR_BASE),$r)))
    43  # stuff for INSTALL_* variables
    44  UNI_SYMLINK_PAIRS := $(join $(addsuffix :,$(UNI_SYMLINK_TARGETS)),$(UNI_SYMLINKS))
    45  UNI_INSTALL_FILES_TRIPLETS := $(call install-file-triplets,$(UNI_SRC_UNITS),$(UNI_UNITS),0644)
    46  UNI_INSTALL_DIRS_PAIRS := $(addsuffix :0755,$(UNI_DIR_CHAINS))
    47  
    48  # This stamps make sure that all stuff were copied and deps were
    49  # generated
    50  $(call setup-stamp-file,UNI_STAMP,$(UNI_FLAVOR)-main)
    51  # This stamp makes sure that directories and symlinks were created and
    52  # files were copied.
    53  $(call setup-stamp-file,UNI_COPY_STAMP,$(UNI_FLAVOR)-copy)
    54  # This stamp makes sure that the unit dir is removed in case something
    55  # changes in units
    56  $(call setup-stamp-file,UNI_REMOVE_ACIROOTFSDIR_STAMP,$(UNI_FLAVOR)-remove-acirootfs)
    57  
    58  # stamp, filelist and a dep file for generating dependencies on target
    59  # files
    60  $(call setup-stamp-file,UNI_UNIT_TARGET_DEPS_STAMP,$(UNI_FLAVOR)-target-deps)
    61  $(call setup-filelist-file,UNI_UNIT_TARGET_FILELIST,$(UNI_FLAVOR)-target)
    62  $(call setup-dep-file,UNI_UNIT_TARGET_DEPMK,$(UNI_FLAVOR)-target)
    63  
    64  # stamp, filelist and a dep file for generating dependencies on
    65  # service files
    66  $(call setup-stamp-file,UNI_UNIT_SERVICE_DEPS_STAMP,$(UNI_FLAVOR)-service-deps)
    67  $(call setup-filelist-file,UNI_UNIT_SERVICE_FILELIST,$(UNI_FLAVOR)-service)
    68  $(call setup-dep-file,UNI_UNIT_SERVICE_DEPMK,$(UNI_FLAVOR)-service)
    69  
    70  # stamp and a dep file for generating dependencies on symlinks
    71  $(call setup-stamp-file,UNI_UNIT_SYMLINKS_KV_DEPS_STAMP,$(UNI_FLAVOR)-symlinks-kv-deps)
    72  $(call setup-dep-file,UNI_UNIT_SYMLINKS_KV_DEPMK,$(UNI_FLAVOR)-symlinks-kv)
    73  
    74  # this stamp makes sure that everything was copied and deps were
    75  # generated
    76  $(call generate-stamp-rule,$(UNI_STAMP),$(UNI_COPY_STAMP) $(UNI_UNIT_TARGET_DEPS_STAMP) $(UNI_UNIT_SERVICE_DEPS_STAMP) $(UNI_UNIT_SYMLINKS_KV_DEPS_STAMP))
    77  
    78  # this stamp makes sure that everything is copied
    79  $(call generate-stamp-rule,$(UNI_COPY_STAMP),$(UNI_UNITS),$(UNI_SYMLINKS) $(UNI_UNIT_DIRS))
    80  
    81  # this removes the ACI rootfs directory
    82  $(call generate-rm-dir-rule,$(UNI_REMOVE_ACIROOTFSDIR_STAMP),$(UNI_ACIROOTFSDIR))
    83  
    84  STAGE1_INSTALL_FILES_$(UNI_FLAVOR) += $(UNI_INSTALL_FILES_TRIPLETS)
    85  STAGE1_INSTALL_DIRS_$(UNI_FLAVOR) += $(UNI_INSTALL_DIRS_PAIRS)
    86  STAGE1_INSTALL_SYMLINKS_$(UNI_FLAVOR) += $(UNI_SYMLINK_PAIRS)
    87  STAGE1_SECONDARY_STAMPS_$(UNI_FLAVOR) += $(UNI_STAMP)
    88  
    89  # Below dep.mk files are generated that may nuke the entire ACI rootfs
    90  # directory. We have to do it that way, because the unit directory in
    91  # the ACI rootfs may contain files that came from the initial ACI
    92  # rootfs preparation. So we might need to recreate the tree before
    93  # putting our units again.
    94  
    95  # This filelist of all target unit files can be generated any time.
    96  $(call generate-shallow-filelist,$(UNI_UNIT_TARGET_FILELIST),$(UNI_SRC_UNITDIR),.target)
    97  # This dep.mk can be generated only after the filelist above was
    98  # generated. Will trigger removing of the ACI rootfs directory in all
    99  # ACI rootfses if target unit files change.
   100  $(call generate-glob-deps,$(UNI_UNIT_TARGET_DEPS_STAMP),$(UNI_REMOVE_ACIROOTFSDIR_STAMP),$(UNI_UNIT_TARGET_DEPMK),.target,$(UNI_UNIT_TARGET_FILELIST),$(UNI_SRC_UNITDIR),normal)
   101  
   102  # This filelist of all service unit files can be generated any time.
   103  $(call generate-shallow-filelist,$(UNI_UNIT_SERVICE_FILELIST),$(UNI_SRC_UNITDIR),.service)
   104  # This dep.mk can be generated only after the filelist above was
   105  # generated. Will trigger removing of the ACI rootfs directory in all
   106  # ACI rootfses if service unit files change.
   107  $(call generate-glob-deps,$(UNI_UNIT_SERVICE_DEPS_STAMP),$(UNI_REMOVE_ACIROOTFSDIR_STAMP),$(UNI_UNIT_SERVICE_DEPMK),.service,$(UNI_UNIT_SERVICE_FILELIST),$(UNI_SRC_UNITDIR),normal)
   108  
   109  # This dep.mk will force the removal of the ACI rootfs directory if
   110  # any symlink to be created changes.
   111  $(call generate-kv-deps,$(UNI_UNIT_SYMLINKS_KV_DEPS_STAMP),$(UNI_REMOVE_ACIROOTFSDIR_STAMP),$(UNI_UNIT_SYMLINKS_KV_DEPMK),UNI_SYMLINK_TARGETS UNI_SYMLINK_FILENAMES)
   112  
   113  $(call undefine-namespaces,UNI)