Repository navigation
Expand file tree
/
Copy pathscripts_smoke.sh
More file actions
executable file
·254 lines (240 loc) · 12.9 KB
/
Copy pathscripts_smoke.sh
File metadata and controls
executable file
·254 lines (240 loc) · 12.9 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/bin/bash
set -Eeuo pipefail
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_DIR"
fail() { echo "[smoke][ERROR] $*" >&2; exit 1; }
assert_file() { [ -f "$1" ] || fail "missing file: $1"; }
assert_executable() { [ -x "$1" ] || fail "not executable: $1"; }
assert_contains() { rg -q -- "$2" "$1" || fail "$1 does not contain $2"; }
assert_absent() { ! rg -q -- "$2" "$1" || fail "$1 unexpectedly contains $2"; }
assert_executable install.sh
assert_executable scripts/rebuild-candidate.sh
assert_executable scripts/select-latest-package.sh
assert_executable scripts/ci/update-nix-hashes.sh
assert_executable scripts/ci/validate-nix-pins.sh
assert_file assets/openai-codex-linux-repository-key.gpg.base64
assert_file nix/upstream-linux-packages.json
bash -n install.sh launcher/start.sh.template scripts/install-deps.sh \
scripts/rebuild-candidate.sh scripts/select-latest-package.sh \
tests/install_deps_pacman_rust_matrix.sh
bash -n scripts/lib/*.sh scripts/build-deb.sh scripts/build-rpm.sh scripts/build-pacman.sh scripts/build-appimage.sh
bash -n scripts/build-gentoo.sh scripts/install-gentoo.sh
node --test scripts/gentoo-native.test.js scripts/gentoo-install.test.js scripts/lib/gentoo-feature-support.test.js
assert_contains packaging/linux/codex-desktop.desktop '^Name=ChatGPT Community$'
assert_contains packaging/linux/codex-desktop.desktop '^Comment=Community Linux distribution based on OpenAI ChatGPT$'
# The retired launcher flags only focus the existing window (#1655).
for desktop_source in packaging/linux/codex-desktop.desktop \
packaging/appimage/codex-desktop.desktop flake.nix; do
assert_absent "$desktop_source" 'new-instance|CODEX_MULTI_LAUNCH'
done
desktop_fixture="$(mktemp -d "${TMPDIR:-/tmp}/codex-desktop-entry-smoke.XXXXXX")"
(
source scripts/lib/package-common.sh
APP_DIR="$desktop_fixture/app"
PACKAGE_NAME=codex-desktop
DESKTOP_TEMPLATE=packaging/linux/codex-desktop.desktop
PACKAGE_WITH_UPDATER=1 render_desktop_entry "$desktop_fixture/with-updater.desktop"
PACKAGE_WITH_UPDATER=0 render_desktop_entry "$desktop_fixture/without-updater.desktop"
mkdir -p "$APP_DIR/.codex-linux"
report="$APP_DIR/.codex-linux/patch-report.json"
printf '%s\n' '{"enabledFeatures":["desktop-new-window"],"patches":[{"name":"feature:desktop-new-window:second-instance","status":"applied"}]}' > "$report"
PACKAGE_WITH_UPDATER=1 render_desktop_entry "$desktop_fixture/new-window-and-updater.desktop"
PACKAGE_WITH_UPDATER=0 render_desktop_entry "$desktop_fixture/new-window-only.desktop"
filter_desktop_actions 0 < packaging/appimage/codex-desktop.desktop > "$desktop_fixture/appimage.desktop"
sed -i 's/"applied"/"skipped-optional"/' "$report"
PACKAGE_WITH_UPDATER=0 render_desktop_entry "$desktop_fixture/drifted.desktop"
)
assert_contains "$desktop_fixture/with-updater.desktop" '^Actions=CheckForUpdates;InstallReadyUpdate;$'
assert_absent "$desktop_fixture/without-updater.desktop" '^Actions=|^\[Desktop Action '
assert_contains "$desktop_fixture/without-updater.desktop" '^Exec=.*/usr/bin/codex-desktop %u$'
assert_contains "$desktop_fixture/new-window-and-updater.desktop" '^Actions=new-window;CheckForUpdates;InstallReadyUpdate;$'
assert_contains "$desktop_fixture/new-window-only.desktop" '^Actions=new-window;$'
assert_contains "$desktop_fixture/new-window-only.desktop" '^Exec=.*/usr/bin/codex-desktop --codex-community-new-window$'
assert_absent "$desktop_fixture/new-window-only.desktop" 'CheckForUpdates|InstallReadyUpdate'
assert_contains "$desktop_fixture/appimage.desktop" '^Exec=AppRun --codex-community-new-window$'
assert_absent "$desktop_fixture/drifted.desktop" 'new-window'
if command -v desktop-file-validate >/dev/null 2>&1; then
desktop-file-validate "$desktop_fixture/with-updater.desktop" "$desktop_fixture/without-updater.desktop" \
"$desktop_fixture/new-window-and-updater.desktop" "$desktop_fixture/new-window-only.desktop" ||
fail "rendered desktop entries are invalid"
fi
rm -rf "$desktop_fixture"
assert_contains install.sh 'CODEX_APP_DISPLAY_NAME:-ChatGPT Community'
assert_contains install.sh 'cp .*ICON_SOURCE.*CODEX_APP_ID'
assert_contains install.sh 'cp .*ICON_SOURCE.*resources/icon-chatgpt.png'
assert_contains scripts/lib/package-common.sh 'PACKAGE_DISPLAY_NAME:-ChatGPT Community'
assert_contains scripts/build-appimage.sh 'PACKAGE_DISPLAY_NAME:-ChatGPT Community'
assert_contains install.sh 'upstream-linux-package.sh'
assert_contains install.sh 'CODEX_TARGET_ARCH'
assert_contains launcher/start.sh.template '/ChatGPT'
assert_contains launcher/start.sh.template 'refresh_legacy_bundled_plugin_caches'
assert_contains launcher/start.sh.template 'https://gary.goatcounter.com/count'
assert_contains launcher/start.sh.template 'CODEX_LINUX_DISABLE_USAGE_REPORTING'
assert_contains launcher/start.sh.template 'codexLinuxPerUserBrowserSocketDir|codexLinuxIabSocketScope'
assert_contains launcher/start.sh.template '.plugin-appserver'
assert_contains Makefile 'scripts/select-latest-package.sh'
assert_contains Makefile 'build-native-feature-helpers'
assert_contains Makefile 'global-dictation-linux/Cargo.toml --target-dir global-dictation-linux/target'
assert_absent Makefile "compgen -G \"\$\$1\" | sort -V"
# A positional .deb argument equal to the UPSTREAM_DEB environment value must be
# accepted as one input: the Makefile forwards UPSTREAM_DEB both through the
# recipe environment and as the positional $(UPSTREAM_ARG), and install.sh used
# to reject that documented combination as a duplicate input.
smoke_parse_args_fixture() {
# $1 = UPSTREAM_DEB value, $2 = positional argument, $3 = output path
{
echo 'error() { echo "error: $*" >&2; exit 1; }'
echo "PROVIDED_UPSTREAM_DEB_PATH=\"$1\""
sed -n '/^parse_args()/,/^}/p' scripts/lib/install-helpers.sh
printf 'parse_args "%s"\n' "$2"
} > "$3"
}
smoke_parse_args_accepts_matching_env_positional() {
local fixture
fixture="$(mktemp)"
smoke_parse_args_fixture \
/tmp/chatgpt_26.915.31945_amd64.deb \
/tmp/chatgpt_26.915.31945_amd64.deb \
"$fixture"
if ! bash "$fixture"; then
rm -f "$fixture"
fail "parse_args rejected a positional .deb identical to UPSTREAM_DEB"
fi
rm -f "$fixture"
}
smoke_parse_args_rejects_conflicting_paths() {
local fixture
fixture="$(mktemp)"
smoke_parse_args_fixture \
/tmp/chatgpt_26.915.31945_amd64.deb \
/tmp/chatgpt_26.915.31029_amd64.deb \
"$fixture"
if bash "$fixture" 2>/dev/null; then
rm -f "$fixture"
fail "parse_args accepted conflicting upstream .deb paths"
fi
rm -f "$fixture"
}
smoke_parse_args_accepts_matching_env_positional
smoke_parse_args_rejects_conflicting_paths
assert_absent launcher/start.sh.template 'local content server'
assert_contains packaging/linux/control 'official Linux runtime'
assert_contains packaging/linux/codex-desktop.spec 'official runtime'
assert_contains flake.nix 'systemd util-linux xdg-utils'
assert_contains packaging/linux/codex-packaged-runtime.sh 'codex-update-manager check-now'
assert_absent packaging/linux/codex-packaged-runtime.sh '--if-stale'
assert_contains scripts/lib/install-helpers.sh 'sudo apt install nodejs npm curl dpkg-dev gnupg'
# Anchored guards: assert executable code lines, not comment prose, so a
# removed guard actually fails the smoke run even when the explanatory
# comment keeps the words. (rg patterns: avoid unescaped regex metachars.)
assert_contains scripts/lib/asar-patch.sh '^ command -v npx >/dev/null 2>&1 \|\| error'
assert_contains scripts/lib/asar-patch.sh '^ asar_command=\("\$\(resolve_asar_command\)"\)$'
assert_absent scripts/lib/asar-patch.sh 'asar_command=\(npx'
assert_contains scripts/lib/asar-patch.sh '^ --unpack "\{\*\.node,\*\.so,\*\.dylib\}"'
assert_contains scripts/lib/install-helpers.sh '^ if \[ -z "\$\{CODEX_ASAR_BIN:-\}" \] && ! command -v npx &>/dev/null; then$'
assert_contains scripts/lib/asar-patch.sh 'list --is-pack "\$app_asar" > "\$WORK_DIR/app.asar.upstream-layout"'
assert_contains scripts/lib/asar-patch.sh 'scripts/patches/lib/asar-layout.js'
assert_contains scripts/lib/asar-patch.sh 'scripts/patches/lib/asar-layout.js" verify'
assert_absent scripts/lib/asar-patch.sh 'cmp -s "\$WORK_DIR/app.asar.upstream-layout" "\$WORK_DIR/app.asar.output-layout"'
assert_absent scripts/lib/asar-patch.sh "find . -type f -printf '%P\\n' | LC_ALL=C sort"
selector_fixture="$(mktemp -d)"
trap 'rm -rf -- "$selector_fixture"' EXIT
touch -t 202608120900 "$selector_fixture/codex-desktop_2026.08.12.community_amd64.deb"
touch -t 202608121000 "$selector_fixture/codex-desktop_2026.08.12.100000_amd64.deb"
selected_package="$(scripts/select-latest-package.sh "$selector_fixture/codex-desktop_*.deb")"
[ "$selected_package" = "$selector_fixture/codex-desktop_2026.08.12.100000_amd64.deb" ] ||
fail "package selector did not choose the newest artifact: $selected_package"
SCRIPT_DIR="$REPO_DIR"
. scripts/lib/asar-patch.sh
asar_report="$selector_fixture/patch-report.json"
node - "$asar_report" <<'NODE'
const fs = require("node:fs");
const reportPath = process.argv[2];
fs.writeFileSync(reportPath, `${JSON.stringify({
patches: [{ status: "skipped-optional" }],
}, null, 2)}\n`);
NODE
if patch_report_has_changes "$asar_report"; then
fail "skipped optional ASAR descriptors must preserve the official archive"
fi
node - "$asar_report" <<'NODE'
const fs = require("node:fs");
const reportPath = process.argv[2];
const report = JSON.parse(fs.readFileSync(reportPath, "utf8"));
report.patches[0].status = "applied";
fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
NODE
patch_report_has_changes "$asar_report" || fail "applied ASAR descriptors must be packed"
# ASAR glob arguments must not pass through npx's shell: a brace glob such as
# `{*.node,*.so,*.dylib}` is split into separate words there, so asar would
# honor only the first alternative and silently drop the remaining unpack
# rules. The resolved CLI is executed directly instead.
asar_stub_dir="$selector_fixture/asar-stub"
mkdir -p "$asar_stub_dir"
cat > "$asar_stub_dir/asar" <<'STUB'
#!/bin/sh
printf '%s\n' "$0"
STUB
cat > "$asar_stub_dir/npx" <<'STUB'
#!/bin/sh
while [ $# -gt 0 ]; do
case "$1" in
--yes|--package=@electron/asar) shift ;;
--) shift; break ;;
*) break ;;
esac
done
PATH="$(cd "$(dirname "$0")" && pwd):$PATH" exec "$@"
STUB
chmod +x "$asar_stub_dir/asar" "$asar_stub_dir/npx"
resolved_asar="$(export PATH="$asar_stub_dir:$PATH"; resolve_asar_command)"
[ "$resolved_asar" = "$asar_stub_dir/asar" ] ||
fail "asar CLI resolution must return a directly executable path: $resolved_asar"
configured_asar="$(export CODEX_ASAR_BIN="$asar_stub_dir/asar"; resolve_asar_command)"
[ "$configured_asar" = "$asar_stub_dir/asar" ] ||
fail "CODEX_ASAR_BIN must be honored without npx resolution"
record_patch_report_asar_hashes "$asar_report" upstream-sha output-sha true
node - "$asar_report" <<'NODE'
const fs = require("node:fs");
const report = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
if (!report.upstreamAppAsar.preservedByteForByte) throw new Error("missing byte-preserved report state");
if (report.upstreamAppAsar.sha256 !== "upstream-sha") throw new Error("bad upstream hash");
if (report.outputAppAsar.sha256 !== "output-sha") throw new Error("bad output hash");
NODE
node - <<'NODE'
const { corePatchDescriptors } = require("./scripts/patches/runner.js");
const descriptors = corePatchDescriptors();
if (descriptors.length !== 0) {
throw new Error(`Unexpected default core patch registry: ${descriptors.map(({ id }) => id).join(", ")}`);
}
NODE
node - <<'NODE'
const fs = require("node:fs");
const path = require("node:path");
const root = "linux-features";
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
if (!entry.isDirectory() || entry.name === "local") continue;
const feature = path.join(root, entry.name, "feature.json");
if (!fs.existsSync(feature)) continue;
const manifest = JSON.parse(fs.readFileSync(feature, "utf8"));
if (!fs.existsSync(path.join(root, entry.name, "README.md"))) {
throw new Error(`${manifest.id} has no README`);
}
}
const pins = JSON.parse(fs.readFileSync("nix/upstream-linux-packages.json", "utf8"));
for (const architecture of ["amd64", "arm64"]) {
if (!pins[architecture].repositoryPath.endsWith(`_${architecture}.deb`)) {
throw new Error(`bad ${architecture} pin`);
}
}
NODE
node --test launcher/start.test.js tests/deb-prerm.test.js scripts/lib/upstream-linux-package.test.js \
scripts/lib/install-verification.test.js \
scripts/automation/upstream-linux-package-watchdog/test.js \
scripts/patch-linux-window-ui.test.js scripts/patches/runner.test.js \
scripts/patches/lib/asar-layout.test.js \
scripts/patches/lib/global-shortcuts-portal.test.js \
scripts/patches/lib/minified-js.test.js scripts/patches/lib/assets.test.js \
scripts/patches/core/*/test.js \
scripts/lib/linux-features.test.js
echo "[smoke] official Linux-package source, launcher, feature registry, packages, and pins are coherent"