Skip to content

Commit 46eb05f

Browse files
committed
layer: Require pax (IEEE Std 1003.1-2013)
The idea with a spec like this is to define behavior so that different implementations can interoperate reliably. When there is an interop problem betweem implementations A and B, it should be clear from the spec whether implementation A is broken, implementation B is broken, or the spec is insufficiently clear. For example, pax defines 'g' and 'x' typeflags [1] that aren't part of the older ustar (IEEE Std 1003.1-1988) [2]. Before this commit, if implementation A produced a layer with a 'g' or 'x' typeflag and implementation B died unpacking it, it was unclear whose fault it was. With this commit, it is clearly B's fault (because it does not understand the pax typeflag). If implementation A had produces a layer with an 'S' typeflag (which GNU uses for sparse files [3]) and implementation B died unpacking it, it is neither party's fault, because pax explicitly makes those values implementation-defined. Interop around them is up to out of band communication between the layer author and layer consumer, and is not covered by this spec. The previous "File Types" section listed sockets, but the pax spec has: Attempts to archive a socket using ustar interchange format shall produce a diagnostic message. And I see no socket entry in Go's set of tar-type constants [4], so I'm not sure how they were supported before. It looks like Go has supported pax since v1.1 [5,6]. [1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_02 [2]: https://github.com/libarchive/libarchive/wiki/ManPageTar5#POSIX_ustar_Archives [3]: https://github.com/libarchive/libarchive/wiki/ManPageTar5#gnu-tar-archives [4]: https://golang.org/pkg/archive/tar/#pkg-constants [5]: https://codereview.appspot.com/6700047 [6]: golang/go@1068279 Signed-off-by: W. Trevor King <[email protected]>
1 parent eebd585 commit 46eb05f

File tree

4 files changed

+24
-44
lines changed

4 files changed

+24
-44
lines changed

config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This specification uses the following terms:
1313
</dt>
1414
<dd>
1515
Image filesystems are composed of <i>layers</i>.
16-
Each layer represents a set of filesystem changes in a tar-based <a href="layer.md">layer format</a>, recording files to be added, changed, or deleted relative to its parent layer.
16+
Each layer represents a set of filesystem changes in a pax-based <a href="layer.md">layer format</a>, recording files to be added, changed, or deleted relative to its parent layer.
1717
Layers do not have configuration metadata such as environment variables or default arguments - these are properties of the image as a whole rather than any particular layer.
1818
Using a layer-based or union filesystem such as AUFS, or by computing the diff from filesystem snapshots, the filesystem changeset can be used to present a series of image layers as if they were one cohesive filesystem.
1919
</dd>
@@ -30,8 +30,8 @@ This specification uses the following terms:
3030
Layer DiffID
3131
</dt>
3232
<dd>
33-
A layer DiffID is a SHA256 digest over the layer's uncompressed tar archive and serialized in the descriptor digest format, e.g., <code>sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9</code>.
34-
Layers must be packed and unpacked reproducibly to avoid changing the layer ID, for example by using tar-split to save the tar headers.
33+
A layer DiffID is a SHA256 digest over the layer's uncompressed pax archive and serialized in the descriptor digest format, e.g., <code>sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9</code>.
34+
Layers must be packed and unpacked reproducibly to avoid changing the layer ID, for example by using tar-split to save the pax headers.
3535
NOTE: the DiffID is different than the digest in the manifest list because the manifest digest is taken over the gzipped layer for <code>application/vnd.oci.image.layer.tar+gzip</code> types.
3636
</dd>
3737
<dt>

image-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ $ cat ./blobs/sha256/5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a43335
103103
```
104104
```
105105
$ cat ./blobs/sha256/e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f
106-
[tar stream]
106+
[pax stream]
107107
```
108108

109109
[descriptors]: ./descriptor.md

layer.md

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ This document will use a concrete example to illustrate how to create and consum
66

77
## Distributable Format
88

9-
Layer Changesets for the [mediatype](./media-types.md) `application/vnd.oci.image.layer.tar+gzip` MUST be packaged in [tar archive][tar-archive].
10-
Layer Changesets for the [mediatype](./media-types.md) `application/vnd.oci.image.layer.tar+gzip` MUST NOT include duplicate entries for file paths in the resulting [tar archive][tar-archive].
9+
Layer changesets have the [media type](media-types.md) `application/vnd.oci.image.layer.tar+gzip`.
10+
Layer changesets MUST be packaged in the pax interchange format, as [specified by IEEE Std 1003.1-2013][pax], and compressed using gzip, as [specified by RFC 1952][rfc1952].
11+
Layer changesets MUST NOT include duplicate entries for target paths (`path` from the pax extended header or the value computed from `prefix` and `name` in the ustar header).
12+
13+
Portable layers SHOULD NOT use features that [IEEE Std 1003.1-2013][pax] leaves unspecified, undefined, or implementation-defined.
14+
For example, pax reserves `typeflag` values A through Z for custom implementations, so support for unpacking such entries may be mixed.
15+
[Sparse files](https://en.wikipedia.org/wiki/Sparse_file) SHOULD NOT be used because they [are a GNU extension][tar.5-gnu].
1116

1217
## Change Types
1318

@@ -17,37 +22,10 @@ Types of changes that can occur in a changeset are:
1722
* Modifications
1823
* Removals
1924

20-
Additions and Modifications are represented the same in the changeset tar archive.
25+
Additions and Modifications are have the same representation in the pax archive.
2126

2227
Removals are represented using "[whiteout](#whiteouts)" file entries (See [Representing Changes](#representing-changes)).
2328

24-
### File Types
25-
26-
Throughout this document section, the use of word "files" or "entries" includes:
27-
28-
* regular files
29-
* directories
30-
* sockets
31-
* symbolic links
32-
* block devices
33-
* character devices
34-
* FIFOs
35-
36-
### File Attributes
37-
38-
Where supported, MUST include file attributes for Additions and Modifications include:
39-
40-
* Modification Time (`mtime`)
41-
* User ID (`uid`)
42-
* User Name (`uname`) *secondary to `uid`*
43-
* Group ID (`gid `)
44-
* Group Name (`gname`) *secondary to `gid`*
45-
* Mode (`mode`)
46-
* Extended Attributes (`xattrs`)
47-
* Symlink reference (`linkname`)
48-
49-
[Sparse files](https://en.wikipedia.org/wiki/Sparse_file) SHOULD NOT be used because they lack consistent support across tar implementations.
50-
5129
## Creating
5230

5331
### Initial Root Filesystem
@@ -76,7 +54,7 @@ rootfs-c9d-v1/
7654
my-app-tools
7755
```
7856

79-
The `rootfs-c9d-v1` directory is then created as a plain [tar archive][tar-archive] with relative path to `rootfs-c9d-v1`.
57+
The `rootfs-c9d-v1` directory is then created as a plain [pax archive][pax] with paths relative to `rootfs-c9d-v1`.
8058
Entries for the following files:
8159

8260
```
@@ -91,7 +69,7 @@ Entries for the following files:
9169
### Populate a Comparison Filesystem
9270

9371
Create a new directory and initialize it with a copy or snapshot of the prior root filesystem.
94-
Example commands that can preserve [file attributes](#file-attributes) to make this copy are:
72+
Example commands that can preserve [file attributes][pax] to make this copy are:
9573
* [cp(1)](http://linux.die.net/man/1/cp): `cp -a rootfs-c9d-v1/ rootfs-c9d-v1.s1/`
9674
* [rsync(1)](http://linux.die.net/man/1/rsync): `rsync -aHAX rootfs-c9d-v1/ rootfs-c9d-v1.s1/`
9775
* [tar(1)](http://linux.die.net/man/1/tar): `mkdir rootfs-c9d-v1.s1 && tar --acls --xattrs -C rootfs-c9d-v1/ -c . | tar -C rootfs-c9d-v1.s1/ --acls --xattrs -x` (including `--selinux` where supported)
@@ -152,12 +130,12 @@ This reflects the removal of `/etc/my-app-config` and creation of a file and dir
152130

153131
### Representing Changes
154132

155-
A [tar archive][tar-archive] is then created which contains *only* this changeset:
133+
A [pax archive][pax] is then created which contains *only* this changeset:
156134

157135
- Added and modified files and directories in their entirety
158136
- Deleted files or directories marked with a [whiteout file](#whiteouts)
159137

160-
The resulting tar archive for `rootfs-c9d-v1.s1` has the following entries:
138+
The resulting pax archive for `rootfs-c9d-v1.s1` has the following entries:
161139

162140
```
163141
./etc/my-app.d/
@@ -170,10 +148,10 @@ Where the basename name of `./etc/my-app-config` is now prefixed with `.wh.`, an
170148

171149
## Applying
172150

173-
Layer Changesets of [mediatype](./media-types.md) `application/vnd.oci.image.layer.tar+gzip` are applied rather than strictly extracted in normal fashion for tar archives.
151+
Layer Changesets of [mediatype](./media-types.md) `application/vnd.oci.image.layer.tar+gzip` are applied rather than strictly extracted in normal fashion for pax archives.
174152

175153
Applying a layer changeset requires consideration for the [whiteout](#whiteouts) files.
176-
In the absence of any [whiteout](#whiteouts) files in a layer changeset, the archive is extracted like a regular tar archive.
154+
In the absence of any [whiteout](#whiteouts) files in a layer changeset, the archive is extracted like a regular pax archive.
177155

178156

179157
### Changeset over existing files
@@ -268,7 +246,7 @@ Note that this opaque file will apply to _all_ children, including sub-directori
268246

269247
Implementations SHOULD generate layers using _explicit whiteout_ files, but MUST accept both.
270248

271-
Any given image is likely to be composed of several of these Image Filesystem Changeset tar archives.
249+
Any given image is likely to be composed of several of these layers.
272250

273251
# Non-Distributable Layers
274252

@@ -279,4 +257,6 @@ Layers that have these restrictions SHOULD be tagged with an alternative mediaty
279257
[Descriptors](descriptor.md) referencing these layers MAY include `urls` for downloading these layers.
280258
It is implementation-defined whether or not implementations upload layers tagged with this media type.
281259

282-
[tar-archive]: https://en.wikipedia.org/wiki/Tar_(computing)
260+
[pax]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13
261+
[rfc1952]: https://tools.ietf.org/html/rfc1952
262+
[tar.5-gnu]: https://github.com/libarchive/libarchive/wiki/ManPageTar5#gnu-tar-archives

media-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ The following media types identify the formats described here and their referenc
66
- `application/vnd.oci.image.manifest.list.v1+json`: [Manifest list](manifest.md#manifest-list)
77
- `application/vnd.oci.image.manifest.v1+json`: [Image manifest format](manifest.md#image-manifest)
88
- `application/vnd.oci.image.config.v1+json`: [Container config JSON](config.md)
9-
- `application/vnd.oci.image.layer.tar+gzip`: ["Layer", as a gzipped tar archive](layer.md)
10-
- `application/vnd.oci.image.layer.nondistributable.tar+gzip`: ["Layer", as a gzipped tar that has distribution restrictions](layer.md#non-distributable-layers)
9+
- `application/vnd.oci.image.layer.tar+gzip`: ["Layer", as a gzipped pax archive](layer.md)
10+
- `application/vnd.oci.image.layer.nondistributable.tar+gzip`: ["Layer", as a gzipped pax that has distribution restrictions](layer.md#non-distributable-layers)
1111

1212
## Compatibility Matrix
1313

0 commit comments

Comments
 (0)