david-ar commited on
Commit
eea6aa6
·
verified ·
1 Parent(s): eda5a30

release tarball checksums: debian sid + homebrew + guix, 2026-08-11 harvest

Browse files
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc0-1.0
3
+ pretty_name: Release tarball checksums (Debian, Homebrew, Guix)
4
+ tags:
5
+ - file-hashes
6
+ configs:
7
+ - config_name: data
8
+ data_files: data/tarballs.parquet
9
+ - config_name: maps
10
+ data_files: maps/md5.parquet
11
+ ---
12
+
13
+ # Release tarball checksums (Debian, Homebrew, Guix)
14
+
15
+ Per-artifact checksums of **release archives as shipped** — the
16
+ tarball itself, not its contents. Content-level indexes (Software
17
+ Heritage, distro file digests) unpack archives before hashing, so a
18
+ pristine `hello-2.12.3.tar.gz` matches nothing in them; the three
19
+ package indexes here publish exact hashes of the artifact:
20
+
21
+ - **debian** — sid `Sources.xz`, all four components: md5 **and**
22
+ sha256 per source file (orig/debian tarballs, `.dsc`, `.asc`) —
23
+ each row is a single witness carrying both digests
24
+ - **homebrew** — `formula.json`: sha256 of each formula's stable
25
+ upstream archive
26
+ - **guix** — `sources.json`, `outputHashMode=flat` entries only
27
+ (recursive entries are NAR-style directory hashes, not raw bytes):
28
+ sha256 of raw tarball bytes, with content-addressed mirror URLs
29
+
30
+ **159,973 rows** (debian 131,303 / guix 20,390 / homebrew 8,280),
31
+ harvested 2026-08-11.
32
+
33
+ ## Layout
34
+
35
+ - `data/tarballs.parquet` — witness, sha256, md5, name, version,
36
+ filename, loc; **sorted by sha256**. `loc` is the Debian pool
37
+ directory, the Homebrew upstream URL, or the Guix content-addressed
38
+ mirror URL.
39
+ - `maps/md5.parquet` — md5 → sha256 (Debian rows), **sorted by md5**.
40
+ - `tarballs.tsv.gz` — the normalized harvest the parquet is built
41
+ from.
42
+
43
+ Both parquet files carry page indexes (zstd, no dictionaries,
44
+ 128 KiB pages), so a point lookup over HTTP range reads fetches a few
45
+ tens of KB. This is how [hashdex](https://github.com/davidar/hashdex)
46
+ resolves hashes from the CLI and from a static browser page.
47
+
48
+ ## Rebuild
49
+
50
+ `release_tarballs.py` in this repo fetches the three indexes (six
51
+ metadata GETs, ~50 MB, no package content) and writes the TSV;
52
+ `tarballs_parquet.py` converts and verifies (sorted keys, page
53
+ indexes present). Sources move — Debian sid continuously, Homebrew
54
+ and Guix per commit — so a rebuild reflects harvest time.
55
+
56
+ Checksums metadata © the respective projects (Debian archive,
57
+ Homebrew, GNU Guix), generously public; this compilation CC0.
data/tarballs.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:decf7c7be456c25b226388b8d768bcb39850515f8d90418d027c9124d3c13214
3
+ size 15020745
maps/md5.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9f5b242536ab867757b05ae297fbb6c1adeae73af73d247702a6e238b30432d
3
+ size 7418626
release_tarballs.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Harvest release-artifact hashes from distro package indexes.
3
+
4
+ Three sources publish full per-artifact hash indexes — the tarballs
5
+ themselves as shipped, the lifecycle every other hashdex source misses
6
+ (SWH unpacks archives; Fedora FILEDIGESTS covers installed files):
7
+
8
+ debian deb.debian.org sid Sources.xz — md5 AND sha256 per source
9
+ file (orig/debian tarballs, .dsc, .asc): multi-hash
10
+ single-witness rows, an edge-minting-compliant crosswalk
11
+ homebrew formulae.brew.sh/api/formula.json — sha256 of each
12
+ formula's stable upstream archive
13
+ guix guix.gnu.org/sources.json — SRI sha256 of raw tarball
14
+ bytes for outputHashMode=flat entries, each carrying a
15
+ content-addressed mirror URL (a claim URL by construction)
16
+
17
+ Preimage trap: Guix "recursive" entries (git/svn/hg) are NAR-style
18
+ directory hashes, NOT raw bytes — only flat url entries are ingested.
19
+
20
+ Ingest is 6 HTTP GETs of index metadata (~50 MB), never content:
21
+ admission-rule clean. Dumps are kept beside the output.
22
+
23
+ Usage:
24
+ tools/release_tarballs.py [outdir] # default ~/.cache/hashdex/tarballs
25
+ hdx index build tarballs <outdir>/tarballs.tsv.gz
26
+
27
+ Output TSV columns (one row per file×witness, "-" = absent):
28
+ witness sha256 md5 name version filename loc
29
+ where loc is the Debian pool directory, the Homebrew upstream URL, or
30
+ the Guix content-addressed mirror URL.
31
+ """
32
+ import base64
33
+ import gzip
34
+ import json
35
+ import lzma
36
+ import pathlib
37
+ import re
38
+ import sys
39
+ import urllib.request
40
+
41
+ UA = "hashdex-release-tarballs/0.1 (hash index research; 6 index GETs)"
42
+
43
+ DEBIAN_BASE = "https://deb.debian.org/debian/dists/sid"
44
+ DEBIAN_COMPONENTS = ["main", "contrib", "non-free", "non-free-firmware"]
45
+ BREW_URL = "https://formulae.brew.sh/api/formula.json"
46
+ GUIX_URL = "https://guix.gnu.org/sources.json"
47
+
48
+ HEX256 = re.compile(r"[0-9a-f]{64}")
49
+ HEX128 = re.compile(r"[0-9a-f]{32}")
50
+
51
+
52
+ def fetch(url, dest):
53
+ """GET url to dest (skipping if already present), return bytes."""
54
+ if dest.exists():
55
+ print(f" reusing {dest.name} ({dest.stat().st_size:,} bytes)", file=sys.stderr)
56
+ return dest.read_bytes()
57
+ req = urllib.request.Request(url, headers={"User-Agent": UA})
58
+ with urllib.request.urlopen(req, timeout=120) as resp:
59
+ data = resp.read()
60
+ # urllib does not decompress; guix.gnu.org serves sources.json
61
+ # with Content-Encoding: gzip.
62
+ if resp.headers.get("Content-Encoding") == "gzip" or data[:2] == b"\x1f\x8b":
63
+ data = gzip.decompress(data)
64
+ dest.write_bytes(data)
65
+ print(f" fetched {dest.name} ({len(data):,} bytes)", file=sys.stderr)
66
+ return data
67
+
68
+
69
+ def field(s, width, what):
70
+ if "\t" in s or "\n" in s:
71
+ raise ValueError(f"{what} contains separator: {s!r}")
72
+ if len(s.encode()) > width:
73
+ raise ValueError(f"{what} over {width} bytes: {s!r}")
74
+ return s if s else "-"
75
+
76
+
77
+ def debian_rows(sources_xz):
78
+ """Parse RFC822 stanzas; one row per Checksums-Sha256 file, md5
79
+ joined from the Files paragraph by filename."""
80
+ text = lzma.decompress(sources_xz).decode("utf-8", errors="replace")
81
+ for stanza in text.split("\n\n"):
82
+ if not stanza.strip():
83
+ continue
84
+ fields = {}
85
+ key = None
86
+ for line in stanza.split("\n"):
87
+ if line[:1] in (" ", "\t"):
88
+ if key:
89
+ fields[key] += "\n" + line.strip()
90
+ else:
91
+ key, _, val = line.partition(":")
92
+ fields[key] = val.strip()
93
+ pkg = fields.get("Package", "")
94
+ version = fields.get("Version", "")
95
+ directory = fields.get("Directory", "")
96
+ if not (pkg and version and directory):
97
+ continue
98
+ md5s = {}
99
+ for line in fields.get("Files", "").split("\n"):
100
+ parts = line.split()
101
+ if len(parts) == 3 and HEX128.fullmatch(parts[0]):
102
+ md5s[parts[2]] = parts[0]
103
+ for line in fields.get("Checksums-Sha256", "").split("\n"):
104
+ parts = line.split()
105
+ if len(parts) != 3 or not HEX256.fullmatch(parts[0]):
106
+ continue
107
+ sha256, _, filename = parts
108
+ yield ("debian", sha256, md5s.get(filename, "-"), pkg, version, filename, directory)
109
+
110
+
111
+ def brew_rows(formula_json):
112
+ for f in json.loads(formula_json):
113
+ stable = (f.get("urls") or {}).get("stable") or {}
114
+ sha256 = stable.get("checksum")
115
+ url = stable.get("url")
116
+ if not (sha256 and url and HEX256.fullmatch(sha256)):
117
+ continue
118
+ version = (f.get("versions") or {}).get("stable") or ""
119
+ yield ("homebrew", sha256, "-", f["name"], version, "-", url)
120
+
121
+
122
+ def guix_rows(sources_json):
123
+ data = json.loads(sources_json)
124
+ entries = data["sources"] if isinstance(data, dict) else data
125
+ dropped = 0
126
+ for e in entries:
127
+ if e.get("type") != "url" or e.get("outputHashMode") != "flat":
128
+ continue # recursive = NAR directory hash, not raw bytes
129
+ integrity = e.get("integrity", "")
130
+ if not integrity.startswith("sha256-"):
131
+ continue
132
+ try:
133
+ digest = base64.b64decode(integrity[len("sha256-") :])
134
+ except ValueError:
135
+ continue
136
+ if len(digest) != 32:
137
+ continue
138
+ urls = e.get("urls") or []
139
+ # Prefer the content-addressed mirrors: URLs that name the hash
140
+ # are claims about the bytes by construction.
141
+ loc = next(
142
+ (u for u in urls if "bordeaux.guix.gnu.org/file/" in u),
143
+ next((u for u in urls if "tarballs.nixos.org/sha256/" in u), None),
144
+ )
145
+ # The content-addressed URLs are .../file/<filename>/sha256/<hash>
146
+ # — the artifact's name is the segment after /file/, never the
147
+ # URL basename (that's the hash).
148
+ filename = next(
149
+ (u.split("/file/", 1)[1].split("/", 1)[0] for u in urls if "/file/" in u),
150
+ urls[0].rsplit("/", 1)[-1] if urls else "",
151
+ )
152
+ if not (loc and filename):
153
+ dropped += 1
154
+ continue
155
+ yield ("guix", digest.hex(), "-", "-", "-", filename, loc)
156
+ if dropped:
157
+ print(
158
+ f" note: {dropped} flat entries had no content-addressed mirror URL, dropped",
159
+ file=sys.stderr,
160
+ )
161
+
162
+
163
+ # Widths mirror the tarballs SourceSpec row layout in src/inverted.rs.
164
+ WIDTHS = {"name": 72, "version": 56, "filename": 128, "loc": 192}
165
+
166
+
167
+ def main():
168
+ outdir = pathlib.Path(
169
+ sys.argv[1] if len(sys.argv) > 1 else pathlib.Path.home() / ".cache/hashdex/tarballs"
170
+ )
171
+ outdir.mkdir(parents=True, exist_ok=True)
172
+
173
+ rows = []
174
+ print("debian sid Sources:", file=sys.stderr)
175
+ for comp in DEBIAN_COMPONENTS:
176
+ url = f"{DEBIAN_BASE}/{comp}/source/Sources.xz"
177
+ try:
178
+ data = fetch(url, outdir / f"debian-sid-{comp}-Sources.xz")
179
+ except Exception as e:
180
+ print(f" warning: {comp}: {e}", file=sys.stderr)
181
+ continue
182
+ rows.extend(debian_rows(data))
183
+ print("homebrew formula.json:", file=sys.stderr)
184
+ rows.extend(brew_rows(fetch(BREW_URL, outdir / "brew-formula.json")))
185
+ print("guix sources.json:", file=sys.stderr)
186
+ rows.extend(guix_rows(fetch(GUIX_URL, outdir / "guix-sources.json")))
187
+
188
+ out = outdir / "tarballs.tsv.gz"
189
+ seen = set()
190
+ counts = {}
191
+ skipped = 0
192
+ with gzip.open(out, "wt", encoding="utf-8") as fh:
193
+ for witness, sha256, md5, name, version, filename, loc in rows:
194
+ try:
195
+ line = "\t".join(
196
+ [
197
+ witness,
198
+ sha256,
199
+ md5,
200
+ field(name, WIDTHS["name"], "name"),
201
+ field(version, WIDTHS["version"], "version"),
202
+ field(filename, WIDTHS["filename"], "filename"),
203
+ field(loc, WIDTHS["loc"], "loc"),
204
+ ]
205
+ )
206
+ except ValueError as e:
207
+ skipped += 1
208
+ if skipped <= 10:
209
+ print(f" warning: skipping row: {e}", file=sys.stderr)
210
+ continue
211
+ if line in seen:
212
+ continue
213
+ seen.add(line)
214
+ fh.write(line + "\n")
215
+ counts[witness] = counts.get(witness, 0) + 1
216
+ per = ", ".join(f"{w} {n:,}" for w, n in sorted(counts.items()))
217
+ print(f"wrote {out}: {sum(counts.values()):,} rows ({per}), {skipped} skipped", file=sys.stderr)
218
+ print(out)
219
+
220
+
221
+ if __name__ == "__main__":
222
+ main()
tarballs.tsv.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3387051f4eade696827758929410cf224995c9c4e705f7ebd8d9cfff9bad48ff
3
+ size 12306972
tarballs_parquet.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Convert the release-tarballs TSV to the published parquet layout.
3
+
4
+ Parquet is the wire format (HDXI stays a locally-derived index): one
5
+ data table sorted by sha256 with page indexes for ~64 KB point reads,
6
+ plus a small md5→sha256 map (Debian rows carry md5) sorted by md5.
7
+
8
+ data/tarballs.parquet witness sha256 md5 name version filename loc
9
+ maps/md5.parquet md5 sha256
10
+
11
+ Usage:
12
+ tools/tarballs_parquet.py [tarballs.tsv.gz] [outdir]
13
+ (defaults: ~/.cache/hashdex/tarballs/tarballs.tsv.gz, sibling parquet/)
14
+
15
+ Then upload outdir to the HF dataset and point hdx/web at it.
16
+ """
17
+ import gzip
18
+ import pathlib
19
+ import sys
20
+
21
+ try:
22
+ import pyarrow as pa
23
+ import pyarrow.parquet as pq
24
+ except ImportError:
25
+ sys.exit("needs pyarrow (pip install pyarrow)")
26
+
27
+ COLUMNS = ["witness", "sha256", "md5", "name", "version", "filename", "loc"]
28
+
29
+ # Page size is only enforced per write batch: a large batch writes one
30
+ # giant page regardless of data_page_size. Keep batches small.
31
+ WRITER_OPTS = dict(
32
+ compression="zstd",
33
+ compression_level=3,
34
+ use_dictionary=False,
35
+ data_page_size=128 * 1024,
36
+ write_batch_size=256,
37
+ write_page_index=True,
38
+ )
39
+
40
+
41
+ def read_rows(tsv_path):
42
+ rows = []
43
+ with gzip.open(tsv_path, "rt", encoding="utf-8") as fh:
44
+ for line in fh:
45
+ parts = line.rstrip("\n").split("\t")
46
+ if len(parts) != len(COLUMNS):
47
+ sys.exit(f"malformed TSV line: {line!r}")
48
+ rows.append([None if v == "-" else v for v in parts])
49
+ return rows
50
+
51
+
52
+ def write_sorted(rows, cols, sort_key, path):
53
+ rows = sorted(rows, key=sort_key)
54
+ table = pa.table(
55
+ {c: pa.array([r[i] for r in rows], type=pa.string()) for i, c in enumerate(cols)}
56
+ )
57
+ path.parent.mkdir(parents=True, exist_ok=True)
58
+ pq.write_table(table, path, **WRITER_OPTS)
59
+ return len(rows)
60
+
61
+
62
+ def verify(path, key_col, expect_rows):
63
+ f = pq.ParquetFile(path)
64
+ assert f.metadata.num_rows == expect_rows, (path, f.metadata.num_rows, expect_rows)
65
+ # Page indexes must be physically present — readers rely on them
66
+ # for point lookups (duckdb's parquet_metadata does not show this).
67
+ for rg in range(f.metadata.num_row_groups):
68
+ for col in range(f.metadata.num_columns):
69
+ assert f.metadata.row_group(rg).column(col).has_offset_index, (path, rg, col)
70
+ keys = f.read(columns=[key_col]).column(0).to_pylist()
71
+ assert keys == sorted(keys), f"{path}: {key_col} not sorted"
72
+ print(
73
+ f" {path}: {expect_rows:,} rows, sorted by {key_col}, "
74
+ f"page-indexed, {path.stat().st_size:,} bytes"
75
+ )
76
+
77
+
78
+ def main():
79
+ tsv = pathlib.Path(
80
+ sys.argv[1]
81
+ if len(sys.argv) > 1
82
+ else pathlib.Path.home() / ".cache/hashdex/tarballs/tarballs.tsv.gz"
83
+ )
84
+ outdir = pathlib.Path(sys.argv[2]) if len(sys.argv) > 2 else tsv.parent / "parquet"
85
+
86
+ rows = read_rows(tsv)
87
+ n = write_sorted(
88
+ rows,
89
+ COLUMNS,
90
+ lambda r: (r[1], r[0], r[3] or "", r[5] or ""),
91
+ outdir / "data" / "tarballs.parquet",
92
+ )
93
+
94
+ md5_rows = sorted({(r[2], r[1]) for r in rows if r[2]})
95
+ m = write_sorted(
96
+ [list(t) for t in md5_rows],
97
+ ["md5", "sha256"],
98
+ lambda r: (r[0], r[1]),
99
+ outdir / "maps" / "md5.parquet",
100
+ )
101
+
102
+ verify(outdir / "data" / "tarballs.parquet", "sha256", n)
103
+ verify(outdir / "maps" / "md5.parquet", "md5", m)
104
+ print(outdir)
105
+
106
+
107
+ if __name__ == "__main__":
108
+ main()