@tmpxinchen/tmp1 1.0.58 → 1.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/reassemble.sh DELETED
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Reassemble the split tarball published as npm packages.
3
- # usage: ./reassemble.sh <out-file> [first-version]
4
- # example: ./reassemble.sh gitlab-ce-18.11.12.tar 1.0.1
5
- set -euo pipefail
6
- PKG="@tmpxinchen/tmp1"
7
- OUT="${1:?usage: reassemble.sh <out-file> [first-version]}"
8
- START="${2:-1.0.1}"
9
- WORK="$(mktemp -d)"
10
- trap 'rm -rf "$WORK"' EXIT
11
-
12
- echo "[1/3] listing versions of $PKG ..."
13
- npm view "$PKG" versions --json > "$WORK/versions.json"
14
- python3 - "$WORK/versions.json" "$START" > "$WORK/list.txt" <<'PY'
15
- import json, re, sys
16
- vs = json.load(open(sys.argv[1]))
17
- start = sys.argv[2]
18
- def key(v):
19
- return tuple(int(x) for x in re.findall(r'\d+', v))
20
- vs = [v for v in vs if '-' not in v and key(v) >= key(start)]
21
- for v in sorted(vs, key=key):
22
- print(v)
23
- PY
24
- [[ -s "$WORK/list.txt" ]] || { echo "no versions >= $START found"; exit 1; }
25
- echo " $(wc -l < "$WORK/list.txt") chunks: $(head -1 "$WORK/list.txt") .. $(tail -1 "$WORK/list.txt")"
26
-
27
- echo "[2/3] downloading + verifying chunks ..."
28
- : > "$OUT"
29
- i=0
30
- total=$(wc -l < "$WORK/list.txt")
31
- src_sha=""; src_size=0
32
- while read -r v; do
33
- i=$((i+1))
34
- mkdir -p "$WORK/$v"
35
- npm pack "$PKG@$v" --silent --pack-destination "$WORK" >/dev/null
36
- tar -xzf "$WORK/$PKG-$(echo "$v" | sed 's|.*/||')" -C "$WORK/$v" 2>/dev/null || \
37
- tar -xzf "$WORK"/tmpxinchen-tmp1-"$v".tgz -C "$WORK/$v"
38
- python3 - "$WORK/$v/package/MANIFEST.json" "$i" "$OUT" <<'PY'
39
- import hashlib, json, sys
40
- m = json.load(open(sys.argv[1]))
41
- idx = int(sys.argv[2]); out = sys.argv[3]
42
- assert m["chunkIndex"] == idx, f'order mismatch: expected {idx}, got {m["chunkIndex"]}'
43
- data = open(m["chunkFile"], 'rb').read()
44
- assert len(data) == m["chunkBytes"], f'chunk {idx} size mismatch'
45
- assert hashlib.sha256(data).hexdigest() == m["chunkSha256"], f'chunk {idx} sha256 mismatch'
46
- with open(out, 'ab') as f:
47
- f.write(data)
48
- print(f" chunk {idx}/{m['totalChunks']} v{m['version']} ok ({m['chunkBytes']} bytes)")
49
- PY
50
- src_sha=$(python3 -c "import json;print(json.load(open('$WORK/$v/package/MANIFEST.json'))['sourceSha256'])")
51
- src_size=$(python3 -c "import json;print(json.load(open('$WORK/$v/package/MANIFEST.json'))['sourceBytes'])")
52
- done < "$WORK/list.txt"
53
-
54
- echo "[3/3] verifying reassembled file ..."
55
- [[ "$(wc -c < "$OUT")" -eq "$src_size" ]] || { echo "size mismatch"; exit 1; }
56
- echo "$src_sha $OUT" | sha256sum -c -
57
- echo "done: $OUT"