From c6f5d4ea4fcc18cb57cb49e7b9c22beac5c2f377 Mon Sep 17 00:00:00 2001 From: kamiyadm Date: Mon, 6 Nov 2023 10:35:04 +0800 Subject: [PATCH] fix: some app run failed in other linux distro * get the runtime info from the latest version. * the default LINGLONG_ROOT_PATH should be /var/lib/linglong. * if the VERSION_ID and NAME are matched, we think it's deepin/uos. Log: --- debian/linglong-bin.postinst | 11 +++++++---- scripts/61-linglong | 13 +++++++------ scripts/linglong.sh | 11 +++++++---- src/module/runtime/app.cpp | 2 +- src/package_manager/impl/package_manager.cpp | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/debian/linglong-bin.postinst b/debian/linglong-bin.postinst index 961d03f4c..05928ec20 100755 --- a/debian/linglong-bin.postinst +++ b/debian/linglong-bin.postinst @@ -7,13 +7,16 @@ configure) if [ -f /etc/os-release ]; then VERSION=$(sed -ne '/^VERSION_ID=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}') + NAME=$(sed -ne '/^NAME=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}') if [ -z "${VERSION}" ]; then VERSION=0 fi - if [ ${VERSION} -eq 20 ]; then - LINGLONG_ROOT="/data/linglong" - elif [ ${VERSION} -eq 23 ]; then - LINGLONG_ROOT="/persistent/linglong" + if [[ "$NAME" == "UOS" || "$NAME" == "Deepin" || "$NAME" == "deepin" || "$NAME" == "uos" ]]; then + if [ ${VERSION} -eq 20 ]; then + LINGLONG_ROOT="/data/linglong" + elif [ ${VERSION} -eq 23 ]; then + LINGLONG_ROOT="/persistent/linglong" + fi fi fi diff --git a/scripts/61-linglong b/scripts/61-linglong index fb0ebcfdc..714ce390b 100755 --- a/scripts/61-linglong +++ b/scripts/61-linglong @@ -5,15 +5,16 @@ VERSION=0 if [ -f /etc/os-release ]; then VERSION=$(sed -ne '/^VERSION_ID=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}') - + NAME=$(sed -ne '/^NAME=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}') if [ -z "${VERSION}" ]; then VERSION=0 fi - - if [ ${VERSION} -eq 20 ]; then - LINGLONG_ROOT="/data/linglong" - elif [ ${VERSION} -eq 23 ]; then - LINGLONG_ROOT="/persistent/linglong" + if [[ "$NAME" == "UOS" || "$NAME" == "Deepin" || "$NAME" == "deepin" || "$NAME" == "uos" ]]; then + if [ ${VERSION} -eq 20 ]; then + LINGLONG_ROOT="/data/linglong" + elif [ ${VERSION} -eq 23 ]; then + LINGLONG_ROOT="/persistent/linglong" + fi fi fi diff --git a/scripts/linglong.sh b/scripts/linglong.sh index edd7be58a..47e84efb3 100644 --- a/scripts/linglong.sh +++ b/scripts/linglong.sh @@ -5,13 +5,16 @@ VERSION=0 if [ -f /etc/os-release ]; then VERSION=$(sed -ne '/^VERSION_ID=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}') + NAME=$(sed -ne '/^NAME=.*$/P' /etc/os-release | awk -F = '{print $2}' | sed -e 's/"//g' | awk -F . '{print $1}') if [ -z "${VERSION}" ]; then VERSION=0 fi - if [ ${VERSION} -eq 20 ]; then - LINGLONG_ROOT="/data/linglong" - elif [ ${VERSION} -eq 23 ]; then - LINGLONG_ROOT="/persistent/linglong" + if [ "$NAME" == "UOS" ] || [ "$NAME" == "Deepin" ] || [ "$NAME" == "deepin" ] || [ "$NAME" == "uos" ]; then + if [ ${VERSION} -eq 20 ]; then + LINGLONG_ROOT="/data/linglong" + elif [ ${VERSION} -eq 23 ]; then + LINGLONG_ROOT="/persistent/linglong" + fi fi fi diff --git a/src/module/runtime/app.cpp b/src/module/runtime/app.cpp index 9c6312427..8d0a74e11 100644 --- a/src/module/runtime/app.cpp +++ b/src/module/runtime/app.cpp @@ -259,7 +259,7 @@ class AppPrivate // 获取环境变量LINGLONG_ROOT auto linglongRootPath = envMap.contains(QString("LINGLONG_ROOT")) ? envMap[QString("LINGLONG_ROOT")] - : QString("/persistent/linglong"); + : QString("/var/lib/linglong"); QMap variables = { { "APP_ROOT_PATH", appRootPath }, { "RUNTIME_ROOT_PATH", runtimeRootPath }, diff --git a/src/package_manager/impl/package_manager.cpp b/src/package_manager/impl/package_manager.cpp index 00e7e581b..cb115d7b6 100644 --- a/src/package_manager/impl/package_manager.cpp +++ b/src/package_manager/impl/package_manager.cpp @@ -464,7 +464,7 @@ bool PackageManagerPrivate::checkAppBase(const QString &runtime, return false; } - auto runtimeInfo = appList.at(0); + auto runtimeInfo = appList.last(); auto baseRef = runtimeInfo->runtime; QStringList baseList = baseRef.split('/'); if (baseList.size() < 3) {