From 44082462b715d7a22af5003d4eabc5afe1df1046 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Thu, 2 Jan 2025 13:40:55 +0700 Subject: [PATCH] chore: fixed macos update script --- client/client_scripts/mac_installer.sh | 36 +++++++++++++++----- client/ui/controllers/updateController.cpp | 7 ++-- client/ui/qml/Components/ChangelogDrawer.qml | 24 +++---------- ipc/ipc_interface.rep | 2 -- ipc/ipcserver.cpp | 11 ------ ipc/ipcserver.h | 1 - 6 files changed, 35 insertions(+), 46 deletions(-) diff --git a/client/client_scripts/mac_installer.sh b/client/client_scripts/mac_installer.sh index a572be8e..186f1502 100644 --- a/client/client_scripts/mac_installer.sh +++ b/client/client_scripts/mac_installer.sh @@ -8,22 +8,42 @@ rm -rf "$EXTRACT_DIR" mkdir -p "$EXTRACT_DIR" # Mount the DMG -hdiutil attach "$INSTALLER_PATH" -mountpoint "$EXTRACT_DIR/mounted_dmg" -nobrowse -quiet +MOUNT_POINT="$EXTRACT_DIR/mounted_dmg" +hdiutil attach "$INSTALLER_PATH" -mountpoint "$MOUNT_POINT" if [ $? -ne 0 ]; then echo "Failed to mount DMG" exit 1 fi -# Copy the app to /Applications -cp -R "$EXTRACT_DIR/mounted_dmg/AmneziaVPN.app" /Applications/ -if [ $? -ne 0 ]; then - echo "Failed to copy AmneziaVPN.app to /Applications" - hdiutil detach "$EXTRACT_DIR/mounted_dmg" -quiet +# Check if the application exists in the mounted DMG +if [ ! -d "$MOUNT_POINT/AmneziaVPN.app" ]; then + echo "Error: AmneziaVPN.app not found in the mounted DMG." + hdiutil detach "$MOUNT_POINT" #-quiet exit 1 fi +# Run the application +echo "Running AmneziaVPN.app from the mounted DMG..." +open "$MOUNT_POINT/AmneziaVPN.app" + +# Get the PID of the app launched from the DMG +APP_PATH="$MOUNT_POINT/AmneziaVPN.app" +PID=$(pgrep -f "$APP_PATH") + +if [ -z "$PID" ]; then + echo "Failed to retrieve PID for AmneziaVPN.app" + hdiutil detach "$MOUNT_POINT" + exit 1 +fi + +# Wait for the specific PID to exit +echo "Waiting for AmneziaVPN.app to exit..." +while kill -0 "$PID" 2>/dev/null; do + sleep 1 +done + # Unmount the DMG -hdiutil detach "$EXTRACT_DIR/mounted_dmg" -quiet +hdiutil detach "$EXTRACT_DIR/mounted_dmg" if [ $? -ne 0 ]; then echo "Failed to unmount DMG" exit 1 @@ -33,4 +53,4 @@ fi rm "$INSTALLER_PATH" echo "Installation completed successfully" -exit 0 \ No newline at end of file +exit 0 diff --git a/client/ui/controllers/updateController.cpp b/client/ui/controllers/updateController.cpp index e62ee02f..41b19bc1 100644 --- a/client/ui/controllers/updateController.cpp +++ b/client/ui/controllers/updateController.cpp @@ -147,14 +147,13 @@ void UpdateController::runInstaller() } file.close(); - QString t = installerPath; #if defined(Q_OS_WINDOWS) - runWindowsInstaller(t); + runWindowsInstaller(installerPath); #elif defined(Q_OS_MACOS) - runMacInstaller(t); + runMacInstaller(installerPath); #elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) - runLinuxInstaller(t); + runLinuxInstaller(installerPath); #endif } else { if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError diff --git a/client/ui/qml/Components/ChangelogDrawer.qml b/client/ui/qml/Components/ChangelogDrawer.qml index c2eae80e..0a919287 100644 --- a/client/ui/qml/Components/ChangelogDrawer.qml +++ b/client/ui/qml/Components/ChangelogDrawer.qml @@ -16,14 +16,6 @@ DrawerType2 { expandedContent: Item { implicitHeight: root.expandedHeight - Connections { - target: root - enabled: !GC.isMobile() - function onOpened() { - focusItem.forceActiveFocus() - } - } - Header2TextType { id: header anchors.top: parent.top @@ -32,6 +24,7 @@ DrawerType2 { anchors.topMargin: 16 anchors.rightMargin: 16 anchors.leftMargin: 16 + anchors.bottomMargin: 16 text: UpdateController.headerText } @@ -46,9 +39,10 @@ DrawerType2 { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - anchors.topMargin: 48 + anchors.topMargin: 16 anchors.rightMargin: 16 anchors.leftMargin: 16 + anchors.bottomMargin: 16 HoverHandler { enabled: parent.hoveredLink @@ -64,17 +58,11 @@ DrawerType2 { } } - Item { - id: focusItem - KeyNavigation.tab: updateButton - } - BasicButtonType { id: updateButton anchors.bottom: skipButton.top anchors.left: parent.left anchors.right: parent.right - anchors.topMargin: 16 anchors.bottomMargin: 8 anchors.rightMargin: 16 anchors.leftMargin: 16 @@ -87,8 +75,6 @@ DrawerType2 { PageController.showBusyIndicator(false) root.close() } - - KeyNavigation.tab: skipButton } BasicButtonType { @@ -107,13 +93,11 @@ DrawerType2 { textColor: "#D7D8DB" borderWidth: 1 - text: qsTr("Skip this version") + text: qsTr("Skip") clickedFunc: function() { root.close() } - - KeyNavigation.tab: focusItem } } } diff --git a/ipc/ipc_interface.rep b/ipc/ipc_interface.rep index 1647ea19..c0f031fe 100644 --- a/ipc/ipc_interface.rep +++ b/ipc/ipc_interface.rep @@ -32,7 +32,5 @@ class IpcInterface SLOT( bool enablePeerTraffic( const QJsonObject &configStr) ); SLOT( bool enableKillSwitch( const QJsonObject &excludeAddr, int vpnAdapterIndex) ); SLOT( bool updateResolvers(const QString& ifname, const QList& resolvers) ); - - SLOT( int mountDmg(const QString &path, bool mount) ); }; diff --git a/ipc/ipcserver.cpp b/ipc/ipcserver.cpp index b73ae407..648fe540 100644 --- a/ipc/ipcserver.cpp +++ b/ipc/ipcserver.cpp @@ -368,14 +368,3 @@ bool IpcServer::enablePeerTraffic(const QJsonObject &configStr) #endif return true; } - -int IpcServer::mountDmg(const QString &path, bool mount) -{ -#ifdef Q_OS_MACOS - qDebug() << path; - auto res = QProcess::execute(QString("sudo hdiutil %1 %2").arg(mount ? "attach" : "unmount", path)); - qDebug() << res; - return res; -#endif - return 0; -} \ No newline at end of file diff --git a/ipc/ipcserver.h b/ipc/ipcserver.h index 0f0153aa..f66dae90 100644 --- a/ipc/ipcserver.h +++ b/ipc/ipcserver.h @@ -38,7 +38,6 @@ public: virtual bool enableKillSwitch(const QJsonObject &excludeAddr, int vpnAdapterIndex) override; virtual bool disableKillSwitch() override; virtual bool updateResolvers(const QString &ifname, const QList &resolvers) override; - virtual int mountDmg(const QString &path, bool mount) override; private: int m_localpid = 0;