You've already forked linuxdeploy
mirror of
https://github.com/encounter/linuxdeploy.git
synced 2026-03-30 11:18:58 -07:00
Add namespace and prepare unittest
This commit is contained in:
+55
-54
@@ -13,68 +13,69 @@ using namespace linuxdeploy::core::log;
|
||||
using namespace linuxdeploy::util;
|
||||
namespace bf = boost::filesystem;
|
||||
|
||||
namespace linuxdeploy {
|
||||
int deployAppDirRootFiles(args::ValueFlagList<std::string>& desktopFilePaths,
|
||||
args::ValueFlag<std::string>& customAppRunPath, appdir::AppDir& appDir) {
|
||||
// search for desktop file and deploy it to AppDir root
|
||||
ldLog() << std::endl << "-- Deploying files into AppDir root directory --" << std::endl;
|
||||
|
||||
int deployAppDirRootFiles(args::ValueFlagList<std::string>& desktopFilePaths,
|
||||
args::ValueFlag<std::string>& customAppRunPath, appdir::AppDir& appDir) {
|
||||
// search for desktop file and deploy it to AppDir root
|
||||
ldLog() << std::endl << "-- Deploying files into AppDir root directory --" << std::endl;
|
||||
|
||||
if (is_regular_file(appDir.path() / "AppRun")) {
|
||||
if (customAppRunPath)
|
||||
ldLog() << LD_WARNING << "AppRun exists but custom AppRun specified, overwriting existing AppRun"
|
||||
<< std::endl;
|
||||
else
|
||||
ldLog() << LD_WARNING << "AppRun exists, skipping deployment" << std::endl;
|
||||
} else {
|
||||
auto deployedDesktopFiles = appDir.deployedDesktopFiles();
|
||||
|
||||
desktopfile::DesktopFile desktopFile;
|
||||
|
||||
if (deployedDesktopFiles.empty()) {
|
||||
ldLog() << LD_WARNING
|
||||
<< "Could not find desktop file in AppDir, cannot create links for AppRun, desktop file and icon in AppDir root"
|
||||
<< std::endl;
|
||||
if (is_regular_file(appDir.path() / "AppRun")) {
|
||||
if (customAppRunPath)
|
||||
ldLog() << LD_WARNING << "AppRun exists but custom AppRun specified, overwriting existing AppRun"
|
||||
<< std::endl;
|
||||
else
|
||||
ldLog() << LD_WARNING << "AppRun exists, skipping deployment" << std::endl;
|
||||
} else {
|
||||
if (!desktopFilePaths.Get().empty()) {
|
||||
auto firstDeployedDesktopFileName = boost::filesystem::path(
|
||||
desktopFilePaths.Get().front()).filename().string();
|
||||
auto deployedDesktopFiles = appDir.deployedDesktopFiles();
|
||||
|
||||
auto desktopFileMatchingName = find_if(
|
||||
deployedDesktopFiles.begin(),
|
||||
deployedDesktopFiles.end(),
|
||||
[&firstDeployedDesktopFileName](const desktopfile::DesktopFile& desktopFile) {
|
||||
auto fileName = desktopFile.path().filename().string();
|
||||
return fileName == firstDeployedDesktopFileName;
|
||||
desktopfile::DesktopFile desktopFile;
|
||||
|
||||
if (deployedDesktopFiles.empty()) {
|
||||
ldLog() << LD_WARNING
|
||||
<< "Could not find desktop file in AppDir, cannot create links for AppRun, desktop file and icon in AppDir root"
|
||||
<< std::endl;
|
||||
} else {
|
||||
if (!desktopFilePaths.Get().empty()) {
|
||||
auto firstDeployedDesktopFileName = boost::filesystem::path(
|
||||
desktopFilePaths.Get().front()).filename().string();
|
||||
|
||||
auto desktopFileMatchingName = find_if(
|
||||
deployedDesktopFiles.begin(),
|
||||
deployedDesktopFiles.end(),
|
||||
[&firstDeployedDesktopFileName](const desktopfile::DesktopFile& desktopFile) {
|
||||
auto fileName = desktopFile.path().filename().string();
|
||||
return fileName == firstDeployedDesktopFileName;
|
||||
}
|
||||
);
|
||||
|
||||
if (desktopFileMatchingName != deployedDesktopFiles.end()) {
|
||||
desktopFile = *desktopFileMatchingName;
|
||||
} else {
|
||||
ldLog() << LD_ERROR << "Could not find desktop file deployed earlier any more:"
|
||||
<< firstDeployedDesktopFileName << std::endl;
|
||||
return 1;
|
||||
}
|
||||
);
|
||||
|
||||
if (desktopFileMatchingName != deployedDesktopFiles.end()) {
|
||||
desktopFile = *desktopFileMatchingName;
|
||||
} else {
|
||||
ldLog() << LD_ERROR << "Could not find desktop file deployed earlier any more:"
|
||||
<< firstDeployedDesktopFileName << std::endl;
|
||||
desktopFile = deployedDesktopFiles[0];
|
||||
ldLog() << LD_WARNING << "No desktop file specified, using first desktop file found:"
|
||||
<< desktopFile.path() << std::endl;
|
||||
}
|
||||
|
||||
ldLog() << "Deploying desktop file:" << desktopFile.path() << std::endl;
|
||||
|
||||
bool rv;
|
||||
|
||||
if (customAppRunPath) {
|
||||
rv = appDir.createLinksInAppDirRoot(desktopFile, customAppRunPath.Get());
|
||||
} else {
|
||||
rv = appDir.createLinksInAppDirRoot(desktopFile);
|
||||
}
|
||||
|
||||
if (!rv) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
desktopFile = deployedDesktopFiles[0];
|
||||
ldLog() << LD_WARNING << "No desktop file specified, using first desktop file found:"
|
||||
<< desktopFile.path() << std::endl;
|
||||
}
|
||||
|
||||
ldLog() << "Deploying desktop file:" << desktopFile.path() << std::endl;
|
||||
|
||||
bool rv;
|
||||
|
||||
if (customAppRunPath) {
|
||||
rv = appDir.createLinksInAppDirRoot(desktopFile, customAppRunPath.Get());
|
||||
} else {
|
||||
rv = appDir.createLinksInAppDirRoot(desktopFile);
|
||||
}
|
||||
|
||||
if (!rv) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user