-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPKGBUILD
More file actions
135 lines (105 loc) · 3.48 KB
/
PKGBUILD
File metadata and controls
135 lines (105 loc) · 3.48 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
# Maintainer: Local package build
pkgname=codex-app
pkgver=1.0.26
pkgrel=1
pkgdesc="Linux package of Codex Desktop"
arch=('x86_64')
url="https://developers.openai.com/codex/app/"
license=('MIT')
depends=(
'electron39'
'python'
'hicolor-icon-theme'
'xdg-utils'
)
makedepends=(
'libicns'
'nodejs'
'npm'
'p7zip'
)
_electron_major=39
source=(
"Codex.dmg::https://persistent.oaistatic.com/codex-app-prod/Codex.dmg"
"codex-app.sh"
"codex-app.desktop"
)
noextract=(
'Codex.dmg'
)
sha256sums=('b0c9ccab01491983c210d7252f4c66897b4156ce2d50bcdfe130b0a1e253b833'
'c6c7a3f61e963020d1cfeb1b6f56e42d89b98e4c0e8f9af73a84ade8b518ff59'
'7d4460887df563d7fd5465db0ff950fb9a0b119556c9d659302359f8b12c6a7a')
prepare() {
cd "${srcdir}"
rm -rf dmg app-extracted app.asar app.asar.unpacked native-build
mkdir dmg
7z x -y "Codex.dmg" -o"${srcdir}/dmg" >/dev/null
icon_icns="$(find dmg -path '*/Contents/Resources/*.icns' | head -n1)"
mkdir -p icon
icns2png -x -o icon "${icon_icns}"
local appdir
appdir="$(find dmg -maxdepth 4 -type d -name '*.app' | head -n1)"
[[ -n "${appdir}" ]] || {
echo "Could not find .app bundle in DMG"
return 1
}
npx --yes asar extract \
"${appdir}/Contents/Resources/app.asar" \
app-extracted
[[ -d "${appdir}/Contents/Resources/app.asar.unpacked" ]] &&
cp -a "${appdir}/Contents/Resources/app.asar.unpacked" .
rm -rf app-extracted/node_modules/sparkle-darwin
find app-extracted -type f \( -name '*.dylib' -o -name 'sparkle.node' \) -delete
local bs3_ver npty_ver
bs3_ver="$(node -p "require('${srcdir}/app-extracted/node_modules/better-sqlite3/package.json').version")"
npty_ver="$(node -p "require('${srcdir}/app-extracted/node_modules/node-pty/package.json').version")"
mkdir native-build
cd native-build
cat >package.json <<'EOF_PKG'
{
"name": "codex-native-rebuild",
"private": true,
"license": "UNLICENSED"
}
EOF_PKG
npm pack --pack-destination "${srcdir}" "better-sqlite3@${bs3_ver}"
npm pack --pack-destination "${srcdir}" "node-pty@${npty_ver}"
npm install \
--ignore-scripts \
--no-audit \
--no-fund \
"${srcdir}/better-sqlite3-${bs3_ver}.tgz" \
"${srcdir}/node-pty-${npty_ver}.tgz"
export npm_config_runtime=electron
export npm_config_target="${_electron_major}.0.0"
export npm_config_disturl="https://electronjs.org/headers"
export npm_config_build_from_source=true
npx --yes @electron/rebuild -v "${_electron_major}.0.0" --force
rm -rf "${srcdir}/app-extracted/node_modules/better-sqlite3"
rm -rf "${srcdir}/app-extracted/node_modules/node-pty"
cp -a node_modules/better-sqlite3 "${srcdir}/app-extracted/node_modules/"
cp -a node_modules/node-pty "${srcdir}/app-extracted/node_modules/"
cd "${srcdir}"
npx --yes asar pack app-extracted app.asar --unpack "{*.node,*.so}"
}
package() {
cd "${srcdir}"
install -Dm644 app.asar \
"${pkgdir}/usr/lib/${pkgname}/resources/app.asar"
if [[ -d app.asar.unpacked ]]; then
cp -a app.asar.unpacked \
"${pkgdir}/usr/lib/${pkgname}/resources/"
fi
if [[ -d app-extracted/webview ]]; then
mkdir -p "${pkgdir}/usr/lib/${pkgname}/content"
cp -a app-extracted/webview \
"${pkgdir}/usr/lib/${pkgname}/content/"
fi
install -Dm755 codex-app.sh \
"${pkgdir}/usr/bin/codex-app"
install -Dm644 icon/*512x512*.png \
"${pkgdir}/usr/share/icons/hicolor/512x512/apps/codex-app.png"
install -Dm644 codex-app.desktop \
"${pkgdir}/usr/share/applications/codex-app.desktop"
}