Build native Flutter Linux manager and deb release 0.2.5
This commit is contained in:
1 parent
3c6c4a0e90
commit
03e729a60b
35 files changed
+757
-69
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root=$(cd -- "$(dirname -- "$0")/.." && pwd -P)
|
||||
case "$(uname -m)" in x86_64) rid=linux-x64;; aarch64) rid=linux-arm64;; *) echo 'Unsupported architecture' >&2; exit 1;; esac
|
||||
flutter=${FLUTTER_BIN:-flutter}
|
||||
(cd "$root/flutter_manager" && "$flutter" pub get --enforce-lockfile && "$flutter" build linux --release --no-pub -t lib/main.dart)
|
||||
source="$root/flutter_manager/build/linux/$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')/release/bundle"
|
||||
test -x "$source/ads_manager"
|
||||
mkdir -p "$root/bin"
|
||||
stage=$(mktemp -d "$root/bin/flutter-stage.XXXXXX")
|
||||
trap 'rm -rf -- "$stage"' EXIT
|
||||
cp -a "$source/." "$stage/"
|
||||
if [[ -n "${ADS_SCRCPY_BUNDLE:-}" ]]; then
|
||||
python3 - "$ADS_SCRCPY_BUNDLE" <<'PY'
|
||||
import platform,struct,sys
|
||||
from pathlib import Path
|
||||
for name in ('adb','scrcpy'):
|
||||
header=(Path(sys.argv[1])/name).read_bytes()[:20]
|
||||
assert header[:4]==b'\x7fELF' and struct.unpack('<H',header[18:20])[0]==(183 if platform.machine()=='aarch64' else 62),'Not a native Linux tool: '+name
|
||||
PY
|
||||
mkdir -p "$stage/tools/scrcpy"
|
||||
cp -a "$ADS_SCRCPY_BUNDLE/." "$stage/tools/scrcpy/"
|
||||
fi
|
||||
output="$root/bin/flutter-$rid"
|
||||
if [[ -d "$output" ]]; then
|
||||
[[ "$(realpath "$output")" == "$root/bin/flutter-$rid" ]] || { echo 'Unexpected output location' >&2; exit 1; }
|
||||
if find "$output" -type f -name '*.env' | grep -q .; then echo 'Private env file in release output' >&2; exit 1; fi
|
||||
rm -rf -- "$output"
|
||||
fi
|
||||
mv -- "$stage" "$output"
|
||||
echo "Flutter Linux bundle: $output"
|
||||
@@ -36,6 +36,9 @@ package() {
|
||||
for tool in ads-agent ads-client adsctl ads-usb ads-server ads-relay; do
|
||||
if [[ -f "$payload/$tool" ]]; then check_elf "$payload/$tool"; chmod 755 "$payload/$tool"; fi
|
||||
done
|
||||
for tool in adb scrcpy; do
|
||||
if [[ -f "$payload/tools/scrcpy/$tool" ]]; then check_elf "$payload/tools/scrcpy/$tool"; chmod 755 "$payload/tools/scrcpy/$tool"; fi
|
||||
done
|
||||
if [[ "$kind" != agent ]]; then
|
||||
printf '#!/bin/sh\nexec /opt/ttstd/%s/%s "$@"\n' "$name" "$exe" > "$tree/usr/bin/$name"
|
||||
chmod 755 "$tree/usr/bin/$name"
|
||||
@@ -55,7 +58,9 @@ package() {
|
||||
if [[ "$kind" == avalonia || "$kind" == flutter ]]; then
|
||||
mkdir -p "$tree/usr/share/applications" "$tree/usr/share/icons/hicolor/256x256/apps"
|
||||
cp "$root/desktop/Ads.Desktop/Assets/app.png" "$tree/usr/share/icons/hicolor/256x256/apps/$name.png"
|
||||
printf '[Desktop Entry]\nType=Application\nName=ADS %s\nExec=%s\nIcon=%s\nTerminal=false\nCategories=Development;Utility;\n' "$kind" "$name" "$name" > "$tree/usr/share/applications/$name.desktop"
|
||||
desktop_name="$name"
|
||||
if [[ "$kind" == flutter ]]; then desktop_name=com.ttstd.ads.ads_manager; fi
|
||||
printf '[Desktop Entry]\nType=Application\nName=ADS %s\nExec=%s\nIcon=%s\nTerminal=false\nCategories=Development;Utility;\n' "$kind" "$name" "$name" > "$tree/usr/share/applications/$desktop_name.desktop"
|
||||
fi
|
||||
printf 'Package: %s\nVersion: %s\nArchitecture: %s\nMaintainer: TongTong Studio\nDepends: %s\nDescription: ADS %s remote Android management\n' "$name" "$version" "$arch" "$deps" "$kind" > "$tree/DEBIAN/control"
|
||||
chmod 755 "$tree/DEBIAN"; chmod 644 "$tree/DEBIAN/control"
|
||||
@@ -81,10 +86,19 @@ if [[ "$mode" == all || "$mode" == avalonia ]]; then
|
||||
package avalonia Ads.Desktop "$stage/avalonia-source" 'libc6 (>= 2.31), libgcc-s1, libstdc++6, libx11-6, libice6, libsm6, libfontconfig1, libfreetype6, libicu76 | libicu74 | libicu72 | libicu70, libssl3t64 | libssl3, zlib1g, adb, scrcpy'
|
||||
fi
|
||||
if [[ "$mode" == flutter ]]; then
|
||||
: "${ADS_FLUTTER_BUNDLE:?Provide a native Linux Flutter release bundle}"
|
||||
mkdir -p "$stage/flutter-source"; cp -a "$ADS_FLUTTER_BUNDLE/." "$stage/flutter-source/"
|
||||
if [[ -z "${ADS_FLUTTER_BUNDLE:-}" ]]; then
|
||||
bash "$root/scripts/build-flutter-linux.sh"
|
||||
fi
|
||||
source=${ADS_FLUTTER_BUNDLE:-$root/bin/flutter-$rid}
|
||||
mkdir -p "$stage/flutter-source"; cp -a "$source/." "$stage/flutter-source/"
|
||||
for tool in ads-agent adsctl ads-client ads-usb; do cp "$backend/$tool" "$stage/flutter-source/"; done
|
||||
package flutter ads_manager "$stage/flutter-source" 'libc6 (>= 2.31), libstdc++6, libgtk-3-0, libayatana-appindicator3-1, adb, scrcpy'
|
||||
deps='libc6 (>= 2.35), libgcc-s1, libstdc++6, libgtk-3-0t64 | libgtk-3-0, libayatana-appindicator3-1, xdg-utils'
|
||||
if [[ -f "$stage/flutter-source/tools/scrcpy/adb" && -f "$stage/flutter-source/tools/scrcpy/scrcpy" ]]; then
|
||||
deps+=', libudev1, libcap2'
|
||||
else
|
||||
deps+=', adb, scrcpy (>= 2.0)'
|
||||
fi
|
||||
package flutter ads_manager "$stage/flutter-source" "$deps"
|
||||
fi
|
||||
(cd "$output" && sha256sum ./*.deb > SHA256SUMS)
|
||||
echo "Linux packages: $output"
|
||||
Reference in new issue
Block a user