1313The ` cache ` role creates an ** offline package tarball** from an existing local repository:
1414
1515- Verify repository directories exist and are populated
16+ - Include the versioned Pigsty source release artifact when available
1617- Clean up dirty/unwanted packages to reduce size
1718- Recreate YUM/APT repository metadata
18- - Create compressed tarball of all packages
19+ - Create a compressed tarball containing packages and optional source
1920- Fetch tarball to control node for distribution
2021
2122This enables:
@@ -34,6 +35,7 @@ Before running the cache role:
34353 . ** ` rsync ` must be installed** on both control and target nodes (for ` synchronize ` module)
35364 . ** SOW 0.3.0 must be available** from the Pigsty INFRA repository
36375 . The repo should contain all required packages (run ` ./infra.yml -t repo ` first)
38+ 6 . To include source in an air-gapped build, stage ` dist/<version>/pigsty-<version>.tgz ` first
3739
3840
3941## Playbooks
@@ -79,6 +81,8 @@ cache # Full role execution
7981│
8082├── cache_check # Verify repo directories exist
8183│
84+ ├── cache_src # Resolve and include Pigsty source artifact
85+ │
8286├── cache_create # Clean packages & recreate metadata
8387│
8488├── cache_tgz # Create compressed tarball
@@ -97,6 +101,12 @@ cache # Full role execution
97101| ` cache_pkg_dir ` | ` dist/${version} ` | Output directory on control node |
98102| ` cache_repo ` | ` pigsty ` | Repo names to cache (CSV for multiple) |
99103
104+ ### Source Artifact Settings
105+
106+ | Variable | Default | Description |
107+ | -------------| ---------| --------------------------------------|
108+ | ` cache_src ` | ` auto ` | Policy: ` auto ` , ` local ` , or ` remote ` |
109+
100110### Referenced Variables
101111
102112| Variable | Default | Description |
@@ -142,14 +152,61 @@ dist/<version>/pigsty-pkg-<version>.<os>.<arch>.tgz
142152``` text
143153pigsty/ # repo_name directory
144154├── *.rpm or *.deb # Package files
155+ ├── pigsty-v4.5.0.tgz # Pigsty source release artifact, when available
145156├── repodata/ # YUM metadata (RPM only)
146157│ ├── repomd.xml
147158│ └── *-primary.xml.gz # Plus filelists/other metadata
148159├── Packages # APT metadata (DEB only)
149160├── Packages.gz # APT metadata (DEB only)
150- └── repo_complete # SHA-256 checksums marker
161+ └── repo_complete # Package checksum marker
162+ ```
163+
164+
165+ ## Pigsty Source Artifact
166+
167+ The cache role never packages the current checkout implicitly. It only looks for
168+ the versioned release artifact or downloads the same versioned filename.
169+
170+ The ` cache_src ` policy determines provenance:
171+
172+ | Policy | Behavior |
173+ | ----------| ----------|
174+ | ` auto ` | Try local ` dist/<version>/pigsty-<version>.tgz ` , then download from the versioned URL |
175+ | ` local ` | Copy the local ` dist ` artifact when it exists; never access the network |
176+ | ` remote ` | Download ` https://repo.pigsty.io/src/pigsty-<version>.tgz ` directly |
177+
178+ Source inclusion is best-effort. Copy or download errors are reported and
179+ ignored, so the package cache tarball is still produced without the source file.
180+ The source step runs only when ` repo_name ` is included in ` cache_repo ` , ensuring
181+ the source artifact is part of the resulting cache tarball. SOW scans RPM/DEB
182+ packages only and preserves the TGZ as a plain repository asset.
183+
184+ For a disconnected build, prepare the artifact explicitly and force local-only
185+ resolution:
186+
187+ ``` bash
188+ # Create this only when the current checkout is intentionally the release input
189+ bin/release v4.5.0
190+
191+ # Never use network; a missing file is reported and ignored
192+ ./cache.yml -l infra -e cache_src=local
193+ ```
194+
195+ For a normal connected release build, ` auto ` requires no extra arguments:
196+
197+ ``` bash
198+ ./cache.yml -l infra
199+ ```
200+
201+ With the default ` repo_home ` and ` repo_name ` , after extracting the outer cache
202+ archive the source contract is:
203+
204+ ``` text
205+ /www/pigsty/pigsty-<version>.tgz
151206```
152207
208+ This stable path can be consumed by a later bootstrap enhancement without
209+ guessing from the build checkout or requiring network access.
153210
154211
155212## Dirty Package Cleanup
@@ -232,8 +289,11 @@ ls -la /www/pigsty/
232289# Only recreate repo metadata (skip fetch)
233290./cache.yml -l infra -t cache_create
234291
235- # Only create tarball and fetch (skip metadata)
236- ./cache.yml -l infra -t cache_tgz,cache_fetch
292+ # Only include source, create tarball and fetch (skip metadata)
293+ ./cache.yml -l infra -t cache_src,cache_tgz,cache_fetch
294+
295+ # Use a pre-staged local source artifact (never use network)
296+ ./cache.yml -l infra -e cache_src=local
237297
238298# Show cache info only
239299./cache.yml -l infra -t cache_info
0 commit comments