MCPcopy Index your code
hub / github.com/StackStorm/st2 / st2_pack_archive

Function st2_pack_archive

pants-plugins/macros.py:124–181  ·  view source on GitHub ↗

Create a makeself_archive using files from the given dependencies. This macro should be used in the same BUILD file as the pack_metadata target.

(**kwargs)

Source from the content-addressed store, hash-verified

122
123
124def st2_pack_archive(**kwargs):
125 """Create a makeself_archive using files from the given dependencies.
126
127 This macro should be used in the same BUILD file as the pack_metadata target.
128 """
129 build_file_path = build_file_dir() # noqa: F821
130 if "st2tests" == build_file_path.parts[0]:
131 # avoid creating duplicate archive for the core pack
132 # which is also located under st2tests/st2tests/fixtures/packs
133 return
134 pack_name = build_file_path.name # noqa: F821
135
136 dependencies = kwargs.pop("dependencies", [])
137 if ":metadata" not in dependencies:
138 dependencies = [":metadata", *dependencies]
139
140 # This is basically a "wrap_as_files" target (which does not exist yet)
141 shell_command( # noqa: F821
142 name="files",
143 execution_dependencies=dependencies,
144 command="true",
145 output_directories=["."],
146 root_output_directory=".",
147 )
148
149 # https://www.pantsbuild.org/stable/docs/shell/self-extractable-archives
150 # https://www.pantsbuild.org/stable/reference/targets/makeself_archive
151 makeself_archive( # noqa: F821
152 name="archive",
153 label=f"{pack_name} StackStorm pack",
154 files=[
155 ":files", # archive contents
156 "//:license", # LICENSE file included in archive header, excluded from contents
157 ],
158 args=( # see: https://makeself.io/#usage
159 # Makeself expects '--arg value' (space) not '--arg=value' (equals) for cmdline
160 "--license",
161 "__archive/LICENSE",
162 "--target",
163 f"/opt/stackstorm/packs/{pack_name}",
164 # reproducibility flags:
165 "--tar-extra", # extra tar args: '--arg=value' (equals delimited) space separated
166 f"--owner=root --group={ST2_PACKS_GROUP} --mtime={MTIME} --exclude=LICENSE",
167 "--packaging-date",
168 MTIME,
169 ),
170 output_path=f"packaging/packs/{pack_name}.tgz.run",
171 )
172
173 nfpm_content_file( # noqa: F821
174 name="archive_for_nfpm",
175 dependencies=[":archive"],
176 src=f"packaging/packs/{pack_name}.tgz.run",
177 dst=f"/opt/stackstorm/install/packs/{pack_name}.tgz.run",
178 file_owner="root",
179 file_group=ST2_PACKS_GROUP,
180 file_mode="rwxr-x---",
181 )

Callers

nothing calls this directly

Calls 1

popMethod · 0.45

Tested by

no test coverage detected