From a505b73a56a53ebb7da36f6f462818fc54b807e7 Mon Sep 17 00:00:00 2001 From: Asura Date: Mon, 12 Sep 2022 23:27:07 -0700 Subject: [PATCH] Fix build flutter deb --- DEBIAN/postinst | 13 ++++++++++--- DEBIAN/prerm | 7 ++++++- build.py | 35 +++++++++++++++++++++++++++++------ flutter/linux/CMakeLists.txt | 2 +- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/DEBIAN/postinst b/DEBIAN/postinst index d643c5caf..b30664ce0 100755 --- a/DEBIAN/postinst +++ b/DEBIAN/postinst @@ -5,8 +5,10 @@ set -e if [ "$1" = configure ]; then INITSYS=$(ls -al /proc/1/exe | awk -F' ' '{print $NF}' | awk -F'/' '{print $NF}') - + if [ "systemd" == "$INITSYS" ]; then + ln -s /usr/lib/rustdesk/flutter_hbb /usr/bin/rustdesk + if [ -e /etc/systemd/system/rustdesk.service ]; then rm /etc/systemd/system/rustdesk.service /usr/lib/systemd/system/rustdesk.service /usr/lib/systemd/user/rustdesk.service >/dev/null 2>&1 fi @@ -18,7 +20,12 @@ if [ "$1" = configure ]; then systemctl start rustdesk cp /usr/share/rustdesk/files/systemd/rustdesk.service.user /usr/lib/systemd/user/rustdesk.service - curUser=$(who | awk '{print $1}' | head -1) - systemctl --machine=${curUser}@.host --user daemon-reload + ubuntuVersion=$(grep -oP 'VERSION_ID="\K[\d]+' /etc/os-release | bc -l) + waylandSupportVersion=21 + if [ "$ubuntuVersion" -ge "$waylandSupportVersion" ] + then + curUser=$(who | awk '{print $1}' | head -1) + systemctl --machine=${curUser}@.host --user daemon-reload + fi fi fi diff --git a/DEBIAN/prerm b/DEBIAN/prerm index 3bb453198..e9e3931ac 100755 --- a/DEBIAN/prerm +++ b/DEBIAN/prerm @@ -5,12 +5,17 @@ set -e case $1 in remove|upgrade) INITSYS=$(ls -al /proc/1/exe | awk -F' ' '{print $NF}' | awk -F'/' '{print $NF}') + if [ "systemd" == "${INITSYS}" ]; then + rm /usr/bin/rustdesk + systemctl stop rustdesk || true systemctl disable rustdesk || true serverUser=$(ps -ef | grep -E 'rustdesk +--server' | awk '{print $1}' | head -1) - if [ "$serverUser" != "" ] && [ "$serverUser" != "root" ] + ubuntuVersion=$(grep -oP 'VERSION_ID="\K[\d]+' /etc/os-release | bc -l) + waylandSupportVersion=21 + if [ "$serverUser" != "" ] && [ "$serverUser" != "root" ] && [ "$ubuntuVersion" -ge "$waylandSupportVersion" ] then systemctl --machine=${serverUser}@.host --user stop rustdesk || true fi diff --git a/build.py b/build.py index cdca16645..e56d6a41e 100755 --- a/build.py +++ b/build.py @@ -121,15 +121,34 @@ def get_features(args): print("features:", features) return features +def generate_control_file(version): + control_file_path = "../DEBIAN/control" + os.system('/bin/rm -rf %s' % control_file_path) + + content = """Package: rustdesk +Version: %s +Architecture: amd64 +Maintainer: open-trade +Homepage: https://rustdesk.com +Depends: libgtk-3-0, libxcb-randr0, libxdo3, libxfixes3, libxcb-shape0, libxcb-xfixes0, libasound2, libsystemd0, pulseaudio, curl +Description: A remote control software. + +""" % version + file = open(control_file_path, "w") + file.write(content) + file.close() def build_flutter_deb(version): os.chdir('flutter') os.system('dpkg-deb -R rustdesk.deb tmpdeb') - # os.system('flutter build linux --release') - os.system('rm tmpdeb/usr/bin/rustdesk') + os.system('flutter build linux --release') os.system('strip build/linux/x64/release/liblibrustdesk.so') + + os.system('mkdir -p tmpdeb/usr/bin/') os.system('mkdir -p tmpdeb/usr/lib/rustdesk') os.system('mkdir -p tmpdeb/usr/share/rustdesk/files/systemd/') + os.system('mkdir -p tmpdeb/usr/share/applications/') + os.system( 'cp -r build/linux/x64/release/bundle/* tmpdeb/usr/lib/rustdesk/') os.system( @@ -137,18 +156,22 @@ def build_flutter_deb(version): os.system( 'cp build/linux/x64/release/liblibrustdesk.so tmpdeb/usr/lib/rustdesk/librustdesk.so') os.system( - 'cp rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') + 'cp ../rustdesk.service tmpdeb/usr/share/rustdesk/files/systemd/') os.system( - 'cp rustdesk.service.user tmpdeb/usr/share/rustdesk/files/systemd/') + 'cp ../rustdesk.service.user tmpdeb/usr/share/rustdesk/files/systemd/') os.system( 'cp ../128x128@2x.png tmpdeb/usr/share/rustdesk/files/rustdesk.png') os.system( - 'cp rustdesk.desktop tmpdeb/usr/share/applications/rustdesk.desktop') + 'cp ../rustdesk.desktop tmpdeb/usr/share/applications/rustdesk.desktop') os.system('mkdir -p tmpdeb/DEBIAN') + generate_control_file(version) os.system('cp -a ../DEBIAN/* tmpdeb/DEBIAN/') md5_file('usr/share/rustdesk/files/systemd/rustdesk.service') md5_file('usr/share/rustdesk/files/systemd/rustdesk.service.user') - os.system('dpkg-deb -b tmpdeb rustdesk.deb; /bin/rm -rf tmpdeb/') + os.system('dpkg-deb -b tmpdeb rustdesk.deb;') + + os.system('/bin/rm -rf tmpdeb/') + os.system('/bin/rm -rf ../DEBIAN/control') os.rename('rustdesk.deb', '../rustdesk-%s.deb' % version) os.chdir("..") diff --git a/flutter/linux/CMakeLists.txt b/flutter/linux/CMakeLists.txt index 9a4e0527b..83778e83d 100644 --- a/flutter/linux/CMakeLists.txt +++ b/flutter/linux/CMakeLists.txt @@ -129,7 +129,7 @@ set(RUSTDESK_LIB_BUILD_TYPE $,debug,release>) string(TOLOWER ${CMAKE_BUILD_TYPE} ${RUSTDESK_LIB_BUILD_TYPE}) message(STATUS "rustdesk lib build type: ${RUSTDESK_LIB_BUILD_TYPE}") -set(RUSTDESK_LIB "../../target/${RUSTDESK_LIB_BUILD_TYPE}/liblibrustdesk.so") +set(RUSTDESK_LIB "../build/linux/x64/${RUSTDESK_LIB_BUILD_TYPE}/liblibrustdesk.so") install(FILES "${RUSTDESK_LIB}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime RENAME librustdesk.so)