74 lines
3.1 KiB
Bash
Executable file
74 lines
3.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
package_version="${WO_PACKAGE_VERSION:-$(sed -n 's/^version = "\([^"]*\)"/\1/p' "$repo_root/Cargo.toml" | head -n1)}"
|
|
package_arch="$(dpkg --print-architecture)"
|
|
build_root="${WO_DEB_BUILD_ROOT:-$repo_root/target/ubuntu-package}"
|
|
stage="$build_root/root"
|
|
deb="$build_root/wo_${package_version}_${package_arch}.deb"
|
|
|
|
for tool in cargo bun dpkg dpkg-deb; do
|
|
command -v "$tool" >/dev/null 2>&1 || {
|
|
echo "Missing build tool: $tool" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
if [[ ! -d "$repo_root/comraw" ]]; then
|
|
echo "Missing comraw source tree at $repo_root/comraw" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Building Wo release binaries"
|
|
(cd "$repo_root" && cargo build --release --locked --bins)
|
|
|
|
echo "Building Electron app and native DMA-BUF addon"
|
|
(cd "$repo_root/electron" && bun install --frozen-lockfile && bun run build && bun run build-native)
|
|
|
|
echo "Building comraw"
|
|
(cd "$repo_root/comraw" && bun install --frozen-lockfile)
|
|
rm -rf "$repo_root/comraw/node_modules/@wl-wo/wo-types"
|
|
mkdir -p "$repo_root/comraw/node_modules/@wl-wo"
|
|
cp -a "$repo_root/electron/types" "$repo_root/comraw/node_modules/@wl-wo/wo-types"
|
|
(cd "$repo_root/comraw" && bun run build)
|
|
|
|
rm -rf "$stage"
|
|
install -d "$stage/DEBIAN" "$stage/usr/bin" "$stage/usr/lib/wo/bin" \
|
|
"$stage/usr/lib/wo/electron" "$stage/usr/lib/wo/electron-runtime" \
|
|
"$stage/usr/lib/wo/comraw" "$stage/usr/share/wayland-sessions" \
|
|
"$stage/usr/share/xdg-desktop-portal/portals" "$stage/usr/share/dbus-1/services" \
|
|
"$stage/usr/share/doc/wo"
|
|
|
|
install -m755 "$repo_root/target/release/wo" "$stage/usr/lib/wo/bin/wo"
|
|
install -m755 "$repo_root/target/release/wo-portal" "$stage/usr/bin/wo-portal"
|
|
install -m755 "$repo_root/target/release/xdg-desktop-portal-wo" "$stage/usr/bin/xdg-desktop-portal-wo"
|
|
|
|
install -m755 "$repo_root/electron/node_modules/electron/dist/electron" \
|
|
"$stage/usr/lib/wo/electron-runtime/electron"
|
|
cp -a "$repo_root/electron/node_modules/electron/dist/." "$stage/usr/lib/wo/electron-runtime/"
|
|
cp -a "$repo_root/electron/dist" "$stage/usr/lib/wo/electron/"
|
|
cp -a "$repo_root/electron/native" "$stage/usr/lib/wo/electron/"
|
|
cp -a "$repo_root/comraw/dist" "$stage/usr/lib/wo/comraw/"
|
|
|
|
cat > "$stage/usr/bin/wo" <<'EOF'
|
|
#!/bin/sh
|
|
export WO_DATA_DIR=/usr/lib/wo
|
|
export WO_ELECTRON_PATH=/usr/lib/wo/electron-runtime/electron
|
|
export WO_ELECTRON_APP_DIR=/usr/lib/wo/electron
|
|
exec /usr/lib/wo/bin/wo "$@"
|
|
EOF
|
|
chmod 755 "$stage/usr/bin/wo"
|
|
|
|
install -m644 "$repo_root/packaging/wayland-sessions/wo.desktop" \
|
|
"$stage/usr/share/wayland-sessions/wo.desktop"
|
|
install -m644 "$repo_root/packaging/portals/wo.portal" \
|
|
"$stage/usr/share/xdg-desktop-portal/portals/wo.portal"
|
|
install -m644 "$repo_root/packaging/dbus-services/org.freedesktop.impl.portal.desktop.wo.service" \
|
|
"$stage/usr/share/dbus-1/services/org.freedesktop.impl.portal.desktop.wo.service"
|
|
install -m644 "$repo_root/config.example.toml" "$stage/usr/share/doc/wo/config.example.toml"
|
|
|
|
sed -e "s/@VERSION@/$package_version/" -e "s/@ARCH@/$package_arch/" \
|
|
"$repo_root/packaging/ubuntu/control.in" > "$stage/DEBIAN/control"
|
|
dpkg-deb --build --root-owner-group "$stage" "$deb"
|
|
echo "Built $deb"
|