Skip to repository content214 lines · 7.6 KB · text
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-27T23:28:31.734Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
bundle-linux
1#!/usr/bin/env bash
2
3set -euxo pipefail
4source script/lib/blob-store.sh
5
6# Function for displaying help info
7help_info() {
8 echo "
9Usage: ${0##*/} [options]
10Build a release .tar.gz for Linux.
11
12Options:
13 -h, --help Display this help and exit.
14 --flatpak Set ZED_BUNDLE_TYPE=flatpak so that this can be included in system info
15 "
16}
17
18# Parse all arguments manually
19while [[ $# -gt 0 ]]; do
20 case $1 in
21 -h|--help)
22 help_info
23 exit 0
24 ;;
25 --flatpak)
26 export ZED_BUNDLE_TYPE=flatpak
27 shift
28 ;;
29 --)
30 shift
31 break
32 ;;
33 -*)
34 echo "Unknown option: $1" >&2
35 help_info
36 exit 1
37 ;;
38 *)
39 echo "Error: Unexpected argument: $1" >&2
40 help_info
41 exit 1
42 ;;
43 esac
44done
45
46export ZED_BUNDLE=true
47
48channel=$(<crates/zed/RELEASE_CHANNEL)
49target_dir="${CARGO_TARGET_DIR:-target}"
50
51version="$(script/get-crate-version zed)"
52# Set RELEASE_VERSION so it's compiled into GPUI and it knows about the version.
53export RELEASE_VERSION="${version}"
54
55commit=$(git rev-parse HEAD | cut -c 1-7)
56
57version_info=$(rustc --version --verbose)
58host_line=$(echo "$version_info" | grep host)
59target_triple=${host_line#*: }
60musl_triple=${target_triple%-gnu}-musl
61remote_server_triple=${REMOTE_SERVER_TARGET:-"${musl_triple}"}
62rustup_installed=false
63if command -v rustup >/dev/null 2>&1; then
64 rustup_installed=true
65fi
66
67# Generate the licenses first, so they can be baked into the binaries
68script/generate-licenses
69
70if "$rustup_installed"; then
71 rustup target add "$remote_server_triple"
72fi
73
74export CC=${CC:-$(which clang)}
75
76# Build binary in release mode
77# We need lld to link libwebrtc.a successfully on aarch64-linux.
78# NOTE: Since RUSTFLAGS env var overrides all .cargo/config.toml rustflags
79# (see https://github.com/rust-lang/cargo/issues/5376), the
80# [target.aarch64-unknown-linux-gnu] section in config.toml has no effect here.
81if [[ "$(uname -m)" == "aarch64" ]]; then
82 export RUSTFLAGS="${RUSTFLAGS:-} -C link-arg=-fuse-ld=lld -C link-args=-Wl,--disable-new-dtags,-rpath,\$ORIGIN/../lib"
83else
84 export RUSTFLAGS="${RUSTFLAGS:-} -C link-args=-Wl,--disable-new-dtags,-rpath,\$ORIGIN/../lib"
85fi
86cargo build --release --target "${target_triple}" --package zed --package cli
87# Build remote_server in separate invocation to prevent feature unification from other crates
88# from influencing dynamic libraries required by it.
89if [[ "$remote_server_triple" == "$musl_triple" ]]; then
90 export RUSTFLAGS="${RUSTFLAGS:-} -C target-feature=+crt-static"
91 musl_cc_var="CC_$(echo "$remote_server_triple" | tr '-' '_')"
92 export "$musl_cc_var"=musl-gcc
93fi
94cargo build --release --target "${remote_server_triple}" --package remote_server
95
96# Upload debug info to sentry.io
97if ! command -v sentry-cli >/dev/null 2>&1; then
98 echo "sentry-cli not found. skipping sentry upload."
99 echo "install with: 'curl -sL https://sentry.io/get-cli | bash'"
100else
101 if [[ -n "${SENTRY_AUTH_TOKEN:-}" ]]; then
102 echo "Uploading zed debug symbols to sentry..."
103 # note: this uploads the unstripped binary which is needed because it contains
104 # .eh_frame data for stack unwinding. see https://github.com/getsentry/symbolic/issues/783
105 for attempt in 1 2 3; do
106 echo "Attempting sentry upload (attempt $attempt/3)..."
107 if sentry-cli debug-files upload --include-sources --wait -p zed -o zed-dev \
108 "${target_dir}/${target_triple}"/release/omega \
109 "${target_dir}/${remote_server_triple}"/release/remote_server; then
110 echo "Sentry upload successful on attempt $attempt"
111 break
112 else
113 echo "Sentry upload failed on attempt $attempt"
114 if [ $attempt -eq 3 ]; then
115 echo "All sentry upload attempts failed"
116 fi
117 fi
118 done
119 else
120 echo "missing SENTRY_AUTH_TOKEN. skipping sentry upload."
121 fi
122fi
123
124# Strip debug symbols and save them for upload to DigitalOcean.
125# We use llvm-objcopy because GNU objcopy on older distros (e.g. Ubuntu 20.04)
126# doesn't understand CREL sections produced by newer LLVM.
127llvm-objcopy --strip-debug "${target_dir}/${target_triple}/release/omega"
128llvm-objcopy --strip-debug "${target_dir}/${target_triple}/release/cli"
129llvm-objcopy --strip-debug "${target_dir}/${remote_server_triple}/release/remote_server"
130
131# Ensure that remote_server does not depend on libssl nor libcrypto, as we got rid of these deps.
132if ldd "${target_dir}/${remote_server_triple}/release/remote_server" | grep -q 'libcrypto\|libssl'; then
133 if [[ "$remote_server_triple" == *-musl ]]; then
134 echo "Error: remote_server still depends on libssl or libcrypto" && exit 1
135 else
136 echo "Info: Using non-musl remote-server build."
137 fi
138fi
139
140suffix=""
141if [ "$channel" != "stable" ]; then
142 suffix="-$channel"
143fi
144
145# Move everything that should end up in the final package
146# into a temp directory.
147temp_dir=$(mktemp -d)
148zed_dir="${temp_dir}/omega$suffix.app"
149
150# Binary
151mkdir -p "${zed_dir}/bin" "${zed_dir}/libexec"
152cp "${target_dir}/${target_triple}/release/omega" "${zed_dir}/libexec/omega-editor"
153cp "${target_dir}/${target_triple}/release/cli" "${zed_dir}/bin/omega"
154
155# Libs
156# Bundle libstdc++ so older supported systems can run binaries built with our
157# toolchain even when their system libstdc++.so.6 lacks required GLIBCXX symbols.
158find_libs() {
159 ldd ${target_dir}/${target_triple}/release/omega |\
160 cut -d' ' -f3 |\
161 grep -v '\<\(libc.so\|libgcc_s.so\|libm.so\|libpthread.so\|libdl.so\|libasound.so\)'
162}
163
164mkdir -p "${zed_dir}/lib"
165rm -rf "${zed_dir}/lib/*"
166cp $(find_libs) "${zed_dir}/lib"
167
168# Icons
169mkdir -p "${zed_dir}/share/icons/hicolor/512x512/apps"
170cp "crates/zed/resources/app-icon$suffix.png" "${zed_dir}/share/icons/hicolor/512x512/apps/omega.png"
171mkdir -p "${zed_dir}/share/icons/hicolor/1024x1024/apps"
172cp "crates/zed/resources/app-icon$suffix@2x.png" "${zed_dir}/share/icons/hicolor/1024x1024/apps/omega.png"
173
174# .desktop
175export DO_STARTUP_NOTIFY="true"
176export APP_CLI="omega"
177export APP_ICON="omega"
178export APP_ARGS="%U"
179if [[ "$channel" == "preview" ]]; then
180 export APP_NAME="Omega RC"
181 APP_ID="com.openagents.omega.rc"
182 export APP_SCHEME="omega-rc"
183elif [[ "$channel" == "nightly" ]]; then
184 export APP_NAME="Omega Nightly"
185 APP_ID="com.openagents.omega.nightly"
186 export APP_SCHEME="omega-nightly"
187elif [[ "$channel" == "dev" ]]; then
188 export APP_NAME="Omega Dev"
189 APP_ID="com.openagents.omega.dev"
190 export APP_SCHEME="omega-dev"
191else
192 export APP_NAME="Omega"
193 APP_ID="com.openagents.omega"
194 export APP_SCHEME="omega"
195fi
196
197mkdir -p "${zed_dir}/share/applications"
198envsubst < "crates/zed/resources/zed.desktop.in" > "${zed_dir}/share/applications/$APP_ID.desktop"
199chmod +x "${zed_dir}/share/applications/$APP_ID.desktop"
200
201# Copy generated licenses so they'll end up in archive too
202cp "assets/licenses.md" "${zed_dir}/licenses.md"
203
204# Create archive out of everything that's in the temp directory
205arch=$(uname -m)
206archive="omega-linux-${arch}.tar.gz"
207
208rm -rf "${archive}"
209remove_match="omega(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz"
210ls "${target_dir}/release" | grep -E ${remove_match} | xargs -d "\n" -I {} rm -f "${target_dir}/release/{}" || true
211tar -czvf "${target_dir}/release/$archive" -C ${temp_dir} "omega$suffix.app"
212
213gzip -f --stdout --best "${target_dir}/${remote_server_triple}/release/remote_server" > "${target_dir}/zed-remote-server-linux-${arch}.gz"
214