-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgenerate.sh
executable file
·126 lines (107 loc) · 3.6 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
set -e
# must be tags for now
# (if you want to use sth else, you need to read this script and modify it accordingly)
CORE_CHECKOUT=v1.156.2
DESKTOP_CHECKOUT=v1.54.2
# this script needs:
# - serveral repos checked out next to this repo
# - flatpak-builder-tools
# - deltachat-core-rust
# - deltachat-desktop
# - python3, nodejs 20, flatpak-node-generator
# - jq
# if -d ../.venv
# then
source ../.venv/bin/activate
# fi
# git checkout & print hashes
echo "[git checkout core]"
cd ../deltachat-core-rust
git fetch --all --tags
git checkout $CORE_CHECKOUT
CORE_COMMIT_HASH=$(git rev-parse HEAD)
cd -
echo "[git checkout desktop]"
cd ../deltachat-desktop
git fetch --all --tags
git checkout $DESKTOP_CHECKOUT
git clean -d -x -f
DESKTOP_COMMIT_HASH=$(git rev-parse HEAD)
cd -
# generate sources
echo "[core build dependencies]"
python3 ../flatpak-builder-tools/cargo/flatpak-cargo-generator.py -o generated/sources-rust.json ../deltachat-core-rust/Cargo.lock
echo "[desktop build dependencies]"
# start proxy registry that records the packages that are fetched
node record.mjs &
PID_RECORD=$!
cd ../deltachat-desktop
pnpm config set registry http://localhost:3000 --location project
rm -r $(pwd)/.pnpm-store || true
pnpm config set store-dir $(pwd)/.pnpm-store --location project
echo "[desktop deps: ignore other architectures]"
# desktop modify package json to exclude all unused architectures
# the temporary file `package.new.json` is nessesary because jq does not support in place editing of files.
jq ".pnpm.supportedArchitectures.os = [\"linux\"] | .pnpm.supportedArchitectures.cpu = [\"x64\", \"arm64\"]" package.json > package.new.json
mv package.new.json package.json
echo "[desktop deps: fetching]"
rm -rf .pnpm-store node_modules || true
pnpm i --frozen-lockfile
# make the proxy registry save what it recorded
kill -SIGINT $PID_RECORD
cd -
echo "[@deltachat/jsonrpc-client build-dependencies]"
cd ../deltachat-core-rust/deltachat-jsonrpc/typescript
rm -r node_modules || true
npm i --lockfile-version 2 --package-lock-only
cd -
pwd
flatpak-node-generator -o generated/sources-jsonrpc-client-npm.json -r npm ../deltachat-core-rust/deltachat-jsonrpc/typescript/package-lock.json
cp ../deltachat-core-rust/deltachat-jsonrpc/typescript/package-lock.json generated/deltachat-jsonrpc.typescript.package-lock.json
echo "[writing to manifest files]"
cat >generated/desktop-git.json <<EOL
[
{
"type": "git",
"url": "https://github.com/deltachat/deltachat-desktop.git",
"tag": "${DESKTOP_CHECKOUT}",
"commit": "${DESKTOP_COMMIT_HASH}",
"dest": "main"
}
]
EOL
cat >generated/core-git.json <<EOL
[
{
"type": "git",
"url": "https://github.com/chatmail/core.git",
"tag": "${CORE_CHECKOUT}",
"commit": "${CORE_COMMIT_HASH}",
"dest": "."
}
]
EOL
echo "[pnpm package to install pnpm]"
result=$(npm view [email protected] --json | jq "{url: .dist.tarball, integrity: .dist.integrity}")
# Use Python to decode the integrity hash and construct the manifest source item
python3 - <<EOL > generated/pnpm.json
import json
import sys
import base64
data = json.loads('''$result''')
if data.get("integrity", "").startswith("sha512-"):
output = {
"type": "archive",
"url": data["url"],
"sha512": base64.b64decode(data["integrity"].replace("sha512-", "")).hex(),
"dest": "pnpm"
}
print(json.dumps(output, indent=2))
else:
print("Input package has unexpected hash, expected sha512", file=sys.stderr)
sys.exit(1)
EOL
echo "[generate manifest that puts electron binary into cache]"
node generate_electron_dependency.mjs
echo "[done]"