summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2019-07-26 12:33:27 +0200
committerRobert Griebl <robert.griebl@pelagicore.com>2019-08-02 14:57:33 +0200
commit5b0c0787c975e27d87111754f98255c1a1dfff32 (patch)
tree255b634e32eab223e8f33d6e5f32bb5b023b9f71
parent3c28fe19b6419fdb1f5a91670b5bd222fa3a619c (diff)
Remove support for multiple installation locations
We had removed support for SD-Card (removable location) installations in a previous patch. Supporting multiple non-removable locations adds a lot of complexity to the AM's installer that isn't really needed, since modern Linux kernels can support these niche use-cases much more transparently through the device mapper/lvm infrastructure. Change-Id: Iaf10d2eb28b9d61e54c5268bcbdd623005b8508d Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--doc/configuration.qdoc67
-rw-r--r--doc/controller.qdoc3
-rw-r--r--src/application-lib/applicationinfo.cpp3
-rw-r--r--src/application-lib/installationreport.cpp16
-rw-r--r--src/application-lib/installationreport.h4
-rw-r--r--src/application-lib/packagedatabase.cpp20
-rw-r--r--src/application-lib/packagedatabase.h8
-rw-r--r--src/dbus-lib/io.qt.packagemanager.xml19
-rw-r--r--src/dbus-lib/packagemanagerdbuscontextadaptor.cpp32
-rw-r--r--src/installer-lib/deinstallationtask.cpp14
-rw-r--r--src/installer-lib/deinstallationtask.h5
-rw-r--r--src/installer-lib/installationlocation.cpp231
-rw-r--r--src/installer-lib/installationlocation.h84
-rw-r--r--src/installer-lib/installationtask.cpp24
-rw-r--r--src/installer-lib/installationtask.h8
-rw-r--r--src/installer-lib/installer-lib.pro2
-rw-r--r--src/installer-lib/packagemanager.cpp334
-rw-r--r--src/installer-lib/packagemanager.h23
-rw-r--r--src/installer-lib/packagemanager_p.h3
-rw-r--r--src/main-lib/applicationinstaller.h42
-rw-r--r--src/main-lib/defaultconfiguration.cpp50
-rw-r--r--src/main-lib/defaultconfiguration.h9
-rw-r--r--src/main-lib/main.cpp40
-rw-r--r--src/main-lib/main.h6
-rw-r--r--src/manager-lib/application.cpp5
-rw-r--r--src/plugin-interfaces/containerinterface.cpp4
-rw-r--r--src/tools/controller/controller.cpp46
-rw-r--r--template-opt/am/config-windows.yaml13
-rw-r--r--template-opt/am/config.yaml18
-rw-r--r--tests/applicationinstaller/tst_applicationinstaller.cpp159
-rw-r--r--tests/installationreport/tst_installationreport.cpp3
-rw-r--r--tests/main/am-config.yaml10
-rw-r--r--tests/main/tst_main.cpp18
-rw-r--r--tests/packager-tool/tst_packager-tool.cpp13
34 files changed, 403 insertions, 933 deletions
diff --git a/doc/configuration.qdoc b/doc/configuration.qdoc
index 9ef3d870..3b291c3b 100644
--- a/doc/configuration.qdoc
+++ b/doc/configuration.qdoc
@@ -160,18 +160,18 @@ or across multiple config files, the final value is resolved based on these rule
\li The base directory for built-in application manifests; you can also specify multiple
directories as a list.
\row
- \li \b --installed-apps-manifest-dir
- \br [\c applications/installedAppsManifestDir]
+ \li \b --installation-dir
+ \br [\c applications/installationDir]
\li string
- \li The base directory for installed application manifests. This option must be specified
- if you want to install new applications; otherwise only the built-in ones are
+ \li The base directory for package installations. This option must be specified
+ if you want to install new package; otherwise only the built-in ones are
available. (default: empty/disabled)
\row
- \li \b --app-image-mount-dir
- \br [\c applications/appImageMountDir]
+ \li \b --document-dir
+ \br [\c applications/documentDir]
\li string
- \li The base directory where application images are mounted to.
- (defaults: \c /opt/am/image-mounts)
+ \li The base directory for per-package document storage directories.
+ (default: empty/disabled)
\row
\li \b --dbus
\li string
@@ -353,8 +353,9 @@ or across multiple config files, the final value is resolved based on these rule
\row
\li [\c installationLocations]
\li array<object>
- \li The definition of installation locations available on the system; an array of
- \l {Installation Locations} objects.
+ \li The definition of installation locations available on the system. This is deprecated,
+ since only a single installation location is supported now, defined by \c
+ --installationDir or \c{applications/installationDir}.
\row
\li [\c runtimes]
\li map<object>
@@ -495,52 +496,6 @@ of these available interfaces are as follows:
\l {freedesktop.org specification}
\endtable
-\section1 Installation Locations
-
-The \c installationLocations YAML field is a list of YAML objects, very similar to
-ApplicationInstaller::getInstallationLocation.
-
-\table
- \header
- \li Config Key
- \li Type
- \li Description
- \row
- \li \c id
- \li string
- \li The installation location ID that is used as the handle for all other
- ApplicationInstaller function calls. The \c id consists of a \c type and \c index
- field, concatenated with a single dash. For example, \c removable-0.
-
- Valid values for \c type are \c internal and \c removable.
-
- In case there is more than one installation location for the same type of device, this
- zero-based index is used for disambiguation. For example, two SD card slots will result
- in the IDs \c removable-0 and \c removable-1. Otherwise, the index is always \c 0.
- \row
- \li \c isDefault
- \li bool
- \li Only one installation location can be the default location, which must be mounted and
- accessible at all times. This location can be used by a UI application to get a
- sensible default for the installation location that it needs to pass to
- \l{ApplicationInstaller::startPackageInstallation()}{startPackageInstallation()}.
- \row
- \li \c installationPath
- \li string
- \li The absolute file system path to the base directory where applications are installed.
- \row
- \li \c documentPath
- \li string
- \li The absolute file system path to the base directory where per-user document directories
- are created. This entry can either be located on this device, or it can be the same as
- the \c documentPath of the master installation location.
- \row
- \li \c mountPoint
- \li string
- \li Only required for \c removable installation location: The absolute file system path to
- the mount-point of the device, where \c installationPath is located.
-\endtable
-
\section1 Runtime Configuration
The runtime configuration sub-objects are specific to the actual runtimes, so the table below has
diff --git a/doc/controller.qdoc b/doc/controller.qdoc
index 6b6511c9..b9309f19 100644
--- a/doc/controller.qdoc
+++ b/doc/controller.qdoc
@@ -85,9 +85,6 @@ The following commands are available:
\li Installs the package given on the command-line. If the package file is specified as \c{-},
the tool tries to read the package from \c stdin. The following options are supported:
- \c{-l, --location}: Install to a specific installation location
- (see \c show-installation-location).
-
\c{-a, --acknowledge}: Automatically acknowledge the installation, instead of relying on
the System UI's logic.
\row
diff --git a/src/application-lib/applicationinfo.cpp b/src/application-lib/applicationinfo.cpp
index c714e86d..33421f6b 100644
--- a/src/application-lib/applicationinfo.cpp
+++ b/src/application-lib/applicationinfo.cpp
@@ -158,8 +158,7 @@ QVariantMap ApplicationInfo::toVariantMap() const
map[qSL("baseDir")] = packageInfo()->baseDir().absolutePath();
map[qSL("codeDir")] = map[qSL("baseDir")]; // 5.12 backward compatibility
map[qSL("manifestDir")] = map[qSL("baseDir")]; // 5.12 backward compatibility
- map[qSL("installationLocationId")] = packageInfo()->installationReport()
- ? packageInfo()->installationReport()->installationLocationId() : QString();
+ map[qSL("installationLocationId")] = packageInfo()->installationReport() ? qSL("internal-0") : QString();
map[qSL("supportsApplicationInterface")] = m_supportsApplicationInterface;
map[qSL("dlt")] = packageInfo()->dltConfiguration();
diff --git a/src/application-lib/installationreport.cpp b/src/application-lib/installationreport.cpp
index ba59888a..2ef2678b 100644
--- a/src/application-lib/installationreport.cpp
+++ b/src/application-lib/installationreport.cpp
@@ -83,16 +83,6 @@ void InstallationReport::setPackageId(const QString &packageId)
m_packageId = packageId;
}
-QString InstallationReport::installationLocationId() const
-{
- return m_installationLocationId;
-}
-
-void InstallationReport::setInstallationLocationId(const QString &installationLocationId)
-{
- m_installationLocationId = installationLocationId;
-}
-
QVariantMap InstallationReport::extraMetaData() const
{
return m_extraMetaData;
@@ -188,7 +178,7 @@ bool InstallationReport::deserialize(QIODevice *from)
return false;
try {
- checkYamlFormat(docs, 3 /*number of expected docs*/, { "am-installation-report" }, 2 /*version*/);
+ checkYamlFormat(docs, 3 /*number of expected docs*/, { "am-installation-report" }, 3 /*version*/);
} catch (const Exception &) {
return false;
}
@@ -204,7 +194,6 @@ bool InstallationReport::deserialize(QIODevice *from)
throw false;
}
- m_installationLocationId = root[qSL("installationLocationId")].toString();
m_diskSpaceUsed = root[qSL("diskSpaceUsed")].toULongLong();
m_digest = QByteArray::fromHex(root[qSL("digest")].toString().toLatin1());
if (m_digest.isEmpty())
@@ -265,12 +254,11 @@ bool InstallationReport::serialize(QIODevice *to) const
return false;
QVariantMap header {
- { "formatVersion", 2 },
+ { "formatVersion", 3 },
{ "formatType", "am-installation-report" }
};
QVariantMap root {
{ qSL("packageId"), packageId() },
- { qSL("installationLocationId"), installationLocationId() },
{ qSL("diskSpaceUsed"), diskSpaceUsed() },
{ qSL("digest"), QLatin1String(digest().toHex()) }
};
diff --git a/src/application-lib/installationreport.h b/src/application-lib/installationreport.h
index 3140f35b..d924fec1 100644
--- a/src/application-lib/installationreport.h
+++ b/src/application-lib/installationreport.h
@@ -60,9 +60,6 @@ public:
QString packageId() const;
void setPackageId(const QString &packageId);
- QString installationLocationId() const;
- void setInstallationLocationId(const QString &installationLocationId);
-
QVariantMap extraMetaData() const;
void setExtraMetaData(const QVariantMap &extraMetaData);
QVariantMap extraSignedMetaData() const;
@@ -91,7 +88,6 @@ public:
private:
QString m_packageId;
- QString m_installationLocationId;
QByteArray m_digest;
quint64 m_diskSpaceUsed = 0;
QStringList m_files;
diff --git a/src/application-lib/packagedatabase.cpp b/src/application-lib/packagedatabase.cpp
index 6ca32e1c..2b49a7db 100644
--- a/src/application-lib/packagedatabase.cpp
+++ b/src/application-lib/packagedatabase.cpp
@@ -53,10 +53,10 @@
QT_BEGIN_NAMESPACE_AM
-PackageDatabase::PackageDatabase(const QStringList &builtInAppsDirs,
- const QString &installedAppsDir)
- : m_builtInAppsDirs(builtInAppsDirs)
- , m_installedAppsDir(installedAppsDir)
+PackageDatabase::PackageDatabase(const QStringList &builtInPackagesDirs,
+ const QString &installedPackagesDir)
+ : m_builtInPackagesDirs(builtInPackagesDirs)
+ , m_installedPackagesDir(installedPackagesDir)
{ }
PackageDatabase::PackageDatabase(const QString &singlePackagePath)
@@ -65,6 +65,11 @@ PackageDatabase::PackageDatabase(const QString &singlePackagePath)
Q_ASSERT(!singlePackagePath.isEmpty());
}
+QString PackageDatabase::installedPackagesDir() const
+{
+ return m_installedPackagesDir;
+}
+
void PackageDatabase::enableLoadFromCache()
{
if (m_parsed)
@@ -151,6 +156,7 @@ QMap<PackageInfo *, QString> PackageDatabase::loadManifestsFromDir(YamlPackageSc
throw Exception(f, "failed to deserialize the installation report");
pkg->setInstallationReport(report.take());
+ pkg->setBaseDir(QDir(m_installedPackagesDir).filePath(pkg->id()));
}
result.insert(pkg.take(), manifestPath);
} catch (const Exception &e) {
@@ -191,11 +197,11 @@ void PackageDatabase::parse()
throw Exception("Failed to load manifest for package: %1").arg(e.errorString());
}
} else {
- for (const QString &dir : m_builtInAppsDirs)
+ for (const QString &dir : m_builtInPackagesDirs)
m_builtInPackages.unite(loadManifestsFromDir(&yps, dir, true));
- if (!m_installedAppsDir.isEmpty())
- m_installedPackages = loadManifestsFromDir(&yps, m_installedAppsDir, false);
+ if (!m_installedPackagesDir.isEmpty())
+ m_installedPackages = loadManifestsFromDir(&yps, m_installedPackagesDir, false);
}
if (m_saveToCache)
diff --git a/src/application-lib/packagedatabase.h b/src/application-lib/packagedatabase.h
index 2aaced4d..8669acce 100644
--- a/src/application-lib/packagedatabase.h
+++ b/src/application-lib/packagedatabase.h
@@ -56,9 +56,11 @@ class YamlPackageScanner;
class PackageDatabase
{
public:
- PackageDatabase(const QStringList &builtInAppsDirs, const QString &installedAppsDir = QString());
+ PackageDatabase(const QStringList &builtInPackagesDirs, const QString &installedPackagesDir = QString());
PackageDatabase(const QString &singlePackagePath);
+ QString installedPackagesDir() const;
+
void enableLoadFromCache();
void enableSaveToCache();
@@ -82,8 +84,8 @@ private:
bool m_loadFromCache = false;
bool m_saveToCache = false;
bool m_parsed = false;
- QStringList m_builtInAppsDirs;
- QString m_installedAppsDir;
+ QStringList m_builtInPackagesDirs;
+ QString m_installedPackagesDir;
QString m_singlePackagePath;
QMap<PackageInfo *, QString> m_builtInPackages;
diff --git a/src/dbus-lib/io.qt.packagemanager.xml b/src/dbus-lib/io.qt.packagemanager.xml
index 7466318a..37e41b9d 100644
--- a/src/dbus-lib/io.qt.packagemanager.xml
+++ b/src/dbus-lib/io.qt.packagemanager.xml
@@ -5,6 +5,12 @@
<property name="developmentMode" type="b" access="read"/>
<property name="applicationUserIdSeparation" type="b" access="read"/>
<property name="commonApplicationGroupId" type="u" access="read"/>
+ <property name="installationLocation" type="v" access="read">
+ <annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
+ </property>
+ <property name="documentLocation" type="v" access="read">
+ <annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
+ </property>
<signal name="taskStarted">
<arg name="taskId" type="s" direction="out"/>
</signal>
@@ -44,21 +50,8 @@
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
<arg name="id" type="s" direction="in"/>
</method>
- <method name="installationLocationIds">
- <arg type="as" direction="out"/>
- </method>
- <method name="installationLocationIdFromPackage">
- <arg type="s" direction="out"/>
- <arg name="id" type="s" direction="in"/>
- </method>
- <method name="getInstallationLocation">
- <arg type="a{sv}" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
- <arg name="installationLocationId" type="s" direction="in"/>
- </method>
<method name="startPackageInstallation">
<arg type="s" direction="out"/>
- <arg name="installationLocationId" type="s" direction="in"/>
<arg name="sourceUrl" type="s" direction="in"/>
</method>
<method name="acknowledgePackageInstallation">
diff --git a/src/dbus-lib/packagemanagerdbuscontextadaptor.cpp b/src/dbus-lib/packagemanagerdbuscontextadaptor.cpp
index 7e7c4f1d..b38bbe96 100644
--- a/src/dbus-lib/packagemanagerdbuscontextadaptor.cpp
+++ b/src/dbus-lib/packagemanagerdbuscontextadaptor.cpp
@@ -114,6 +114,16 @@ bool PackageManagerAdaptor::developmentMode() const
return PackageManager::instance()->developmentMode();
}
+QDBusVariant PackageManagerAdaptor::installationLocation() const
+{
+ return QDBusVariant(PackageManager::instance()->installationLocation());
+}
+
+QDBusVariant PackageManagerAdaptor::documentLocation() const
+{
+ return QDBusVariant(PackageManager::instance()->documentLocation());
+}
+
void PackageManagerAdaptor::acknowledgePackageInstallation(const QString &taskId)
{
AM_AUTHENTICATE_DBUS(void)
@@ -146,24 +156,6 @@ QVariantMap PackageManagerAdaptor::get(const QString &id)
return map;
}
-QVariantMap PackageManagerAdaptor::getInstallationLocation(const QString &installationLocationId)
-{
- AM_AUTHENTICATE_DBUS(QVariantMap)
- return PackageManager::instance()->getInstallationLocation(installationLocationId);
-}
-
-QString PackageManagerAdaptor::installationLocationIdFromPackage(const QString &packageId)
-{
- AM_AUTHENTICATE_DBUS(QString)
- return PackageManager::instance()->installationLocationIdFromPackage(packageId);
-}
-
-QStringList PackageManagerAdaptor::installationLocationIds()
-{
- AM_AUTHENTICATE_DBUS(QStringList)
- return PackageManager::instance()->installationLocationIds();
-}
-
qlonglong PackageManagerAdaptor::installedPackageSize(const QString &packageId)
{
AM_AUTHENTICATE_DBUS(qlonglong)
@@ -193,10 +185,10 @@ QString PackageManagerAdaptor::removePackage(const QString &packageId, bool keep
return PackageManager::instance()->removePackage(packageId, keepDocuments, force);
}
-QString PackageManagerAdaptor::startPackageInstallation(const QString &installationLocationId, const QString &sourceUrl)
+QString PackageManagerAdaptor::startPackageInstallation(const QString &sourceUrl)
{
AM_AUTHENTICATE_DBUS(QString)
- return PackageManager::instance()->startPackageInstallation(installationLocationId, sourceUrl);
+ return PackageManager::instance()->startPackageInstallation(sourceUrl);
}
QString PackageManagerAdaptor::taskState(const QString &taskId)
diff --git a/src/installer-lib/deinstallationtask.cpp b/src/installer-lib/deinstallationtask.cpp
index 1c0fe8a2..94551abe 100644
--- a/src/installer-lib/deinstallationtask.cpp
+++ b/src/installer-lib/deinstallationtask.cpp
@@ -51,11 +51,13 @@
QT_BEGIN_NAMESPACE_AM
-DeinstallationTask::DeinstallationTask(PackageInfo *package, const InstallationLocation &installationLocation,
- bool forceDeinstallation, bool keepDocuments, QObject *parent)
+DeinstallationTask::DeinstallationTask(PackageInfo *package, const QString &installationPath,
+ const QString &documentPath, bool forceDeinstallation,
+ bool keepDocuments, QObject *parent)
: AsynchronousTask(parent)
, m_package(package)
- , m_installationLocation(installationLocation)
+ , m_installationPath(installationPath)
+ , m_documentPath(documentPath)
, m_forceDeinstallation(forceDeinstallation)
, m_keepDocuments(keepDocuments)
{
@@ -74,8 +76,6 @@ void DeinstallationTask::execute()
// these have been checked in PackageManager::removePackage() already
Q_ASSERT(m_package);
Q_ASSERT(m_package->installationReport());
- Q_ASSERT(m_package->installationReport()->installationLocationId() == m_installationLocation.id());
- Q_ASSERT(m_installationLocation.isValid());
bool managerApproval = false;
@@ -104,13 +104,13 @@ void DeinstallationTask::execute()
ScopedRenamer appDirRename;
if (!m_keepDocuments) {
- if (!docDirRename.rename(QDir(m_installationLocation.documentPath()).absoluteFilePath(m_package->id()),
+ if (!docDirRename.rename(QDir(m_documentPath).absoluteFilePath(m_package->id()),
ScopedRenamer::NameToNameMinus)) {
throw Exception(Error::IO, "could not rename %1 to %1-").arg(docDirRename.baseName());
}
}
- if (!appDirRename.rename(QDir(m_installationLocation.installationPath()).absoluteFilePath(m_package->id()),
+ if (!appDirRename.rename(QDir(m_installationPath).absoluteFilePath(m_package->id()),
ScopedRenamer::NameToNameMinus)) {
throw Exception(Error::IO, "could not rename %1 to %1-").arg(appDirRename.baseName());
}
diff --git a/src/installer-lib/deinstallationtask.h b/src/installer-lib/deinstallationtask.h
index a313169b..895f75c3 100644
--- a/src/installer-lib/deinstallationtask.h
+++ b/src/installer-lib/deinstallationtask.h
@@ -54,7 +54,7 @@ class DeinstallationTask : public AsynchronousTask
Q_OBJECT
public:
- DeinstallationTask(PackageInfo *package, const InstallationLocation &installationLocation,
+ DeinstallationTask(PackageInfo *package, const QString &installationPath, const QString &documentPath,
bool forceDeinstallation, bool keepDocuments, QObject *parent = nullptr);
bool cancel() override;
@@ -64,7 +64,8 @@ protected:
private:
PackageInfo *m_package;
- const InstallationLocation &m_installationLocation;
+ QString m_installationPath;
+ QString m_documentPath;
bool m_forceDeinstallation;
bool m_keepDocuments;
bool m_canBeCanceled = true;
diff --git a/src/installer-lib/installationlocation.cpp b/src/installer-lib/installationlocation.cpp
deleted file mode 100644
index ec09920b..00000000
--- a/src/installer-lib/installationlocation.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Luxoft Sweden AB
-** Copyright (C) 2018 Pelagicore AG
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Luxoft Application Manager.
-**
-** $QT_BEGIN_LICENSE:LGPL-QTAS$
-** Commercial License Usage
-** Licensees holding valid commercial Qt Automotive Suite licenses may use
-** this file in accordance with the commercial license agreement provided
-** with the Software or, alternatively, in accordance with the terms
-** contained in a written agreement between you and The Qt Company. For
-** licensing terms and conditions see https://www.qt.io/terms-conditions.
-** For further information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-** SPDX-License-Identifier: LGPL-3.0
-**
-****************************************************************************/
-
-#include <QDir>
-
-#include "installationlocation.h"
-#include "global.h"
-#include "utilities.h"
-#include "exception.h"
-
-#if defined(Q_OS_WIN)
-# include <Windows.h>
-#else
-# include <sys/stat.h>
-# include <errno.h>
-# if defined(Q_OS_ANDROID)
-# include <sys/vfs.h>
-# define statvfs statfs
-# else
-# include <sys/statvfs.h>
-# endif
-#endif
-
-QT_BEGIN_NAMESPACE_AM
-
-static QString fixPath(const QString &path, const QString &hardwareId)
-{
- QString realPath = path;
- realPath.replace(qL1S("@HARDWARE-ID@"), hardwareId);
- QDir dir(realPath);
- return (dir.exists() ? dir.canonicalPath() : dir.absolutePath()) + qL1C('/');
-}
-
-static bool diskUsage(const QString &path, quint64 *bytesTotal, quint64 *bytesFree)
-{
- QString cpath = QFileInfo(path).canonicalPath();
-
-#if defined(Q_OS_WIN)
- return GetDiskFreeSpaceExW((LPCWSTR) cpath.utf16(), (ULARGE_INTEGER *) bytesFree,
- (ULARGE_INTEGER *) bytesTotal, nullptr);
-
-#else // Q_OS_UNIX
- int result;
- struct ::statvfs svfs;
-
- do {
- result = ::statvfs(cpath.toLocal8Bit(), &svfs);
- if (result == -1 && errno == EINTR)
- continue;
- } while (false);
-
- if (result == 0) {
- if (bytesTotal)
- *bytesTotal = quint64(svfs.f_frsize) * svfs.f_blocks;
- if (bytesFree)
- *bytesFree = quint64(svfs.f_frsize) * svfs.f_bavail;
- return true;
- }
- return false;
-#endif // Q_OS_WIN
-}
-
-const InstallationLocation InstallationLocation::invalid = InstallationLocation {};
-
-
-bool InstallationLocation::operator==(const InstallationLocation &other) const
-{
- return (m_valid == other.m_valid)
- && (m_index == other.m_index)
- && (m_installationPath == other.m_installationPath)
- && (m_documentPath == other.m_documentPath);
-}
-
-QString InstallationLocation::id() const
-{
- QString name = m_valid ? qSL("internal") : qSL("invalid");
- if (m_valid)
- name = name + QLatin1Char('-') + QString::number(m_index);
- return name;
-}
-
-int InstallationLocation::index() const
-{
- return m_index;
-}
-
-bool InstallationLocation::isValid() const
-{
- return m_valid;
-}
-
-bool InstallationLocation::isDefault() const
-{
- return m_isDefault;
-}
-
-QString InstallationLocation::installationPath() const
-{
- return m_installationPath;
-}
-
-QString InstallationLocation::documentPath() const
-{
- return m_documentPath;
-}
-
-bool InstallationLocation::installationDeviceFreeSpace(quint64 *bytesTotal, quint64 *bytesFree) const
-{
- return diskUsage(installationPath(), bytesTotal, bytesFree);
-}
-
-bool InstallationLocation::documentDeviceFreeSpace(quint64 *bytesTotal, quint64 *bytesFree) const
-{
- return diskUsage(documentPath(), bytesTotal, bytesFree);
-}
-
-QVariantMap InstallationLocation::toVariantMap() const
-{
- QVariantMap map;
- map[qSL("id")] = id();
- map[qSL("type")] = m_valid ? qSL("internal") : qSL("invalid");
- map[qSL("index")] = index();
- map[qSL("installationPath")] = installationPath();
- map[qSL("documentPath")] = documentPath();
- map[qSL("isDefault")] = isDefault();
-
- quint64 total = 0, free = 0;
- installationDeviceFreeSpace(&total, &free);
-
- map[qSL("installationDeviceSize")] = total;
- map[qSL("installationDeviceFree")] = free;
-
- total = free = 0;
- documentDeviceFreeSpace(&total, &free);
-
- map[qSL("documentDeviceSize")] = total;
- map[qSL("documentDeviceFree")] = free;
-
- return map;
-}
-
-QVector<InstallationLocation> InstallationLocation::parseInstallationLocations(const QVariantList &list,
- const QString &hardwareId) Q_DECL_NOEXCEPT_EXPR(false)
-{
- QVector<InstallationLocation> locations;
- bool gotDefault = false;
-
- for (const QVariant &v : list) {
- QVariantMap map = v.toMap();
-
- QString id = map.value(qSL("id")).toString();
- QString instPath = map.value(qSL("installationPath")).toString();
- QString documentPath = map.value(qSL("documentPath")).toString();
- bool isDefault = map.value(qSL("isDefault")).toBool();
-
- if (isDefault) {
- if (!gotDefault)
- gotDefault = true;
- else
- throw Exception(Error::Parse, "multiple default installation locations defined");
- }
-
- QString type = id.section('-', 0, 0);
- bool ok = false;
- int index = id.section('-', 1).toInt(&ok);
-
- if ((type == qSL("internal")) && (index >= 0) && ok) {
- InstallationLocation il;
- il.m_valid = true;
- il.m_index = index;
- il.m_installationPath = fixPath(instPath, hardwareId);
- il.m_documentPath = fixPath(documentPath, hardwareId);
- il.m_isDefault = isDefault;
-
- if (!QDir::root().mkpath(instPath)) {
- throw Exception(Error::Parse, "the app directory %2 for the installation location %1 does not exist")
- .arg(id).arg(instPath);
- }
- if (!QDir::root().mkpath(documentPath)) {
- throw Exception(Error::Parse, "the doc directory %2 for the installation location %1 does not exist")
- .arg(id).arg(documentPath);
- }
-
- locations.append(il);
- } else {
- throw Exception(Error::Parse, "could not parse the installation location with id %1").arg(id);
- }
- }
- return locations;
-}
-
-QT_END_NAMESPACE_AM
diff --git a/src/installer-lib/installationlocation.h b/src/installer-lib/installationlocation.h
deleted file mode 100644
index 43e921ab..00000000
--- a/src/installer-lib/installationlocation.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 Luxoft Sweden AB
-** Copyright (C) 2018 Pelagicore AG
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Luxoft Application Manager.
-**
-** $QT_BEGIN_LICENSE:LGPL-QTAS$
-** Commercial License Usage
-** Licensees holding valid commercial Qt Automotive Suite licenses may use
-** this file in accordance with the commercial license agreement provided
-** with the Software or, alternatively, in accordance with the terms
-** contained in a written agreement between you and The Qt Company. For
-** licensing terms and conditions see https://www.qt.io/terms-conditions.
-** For further information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-** SPDX-License-Identifier: LGPL-3.0
-**
-****************************************************************************/
-
-#pragma once
-
-#include <QtAppManCommon/global.h>
-#include <QString>
-#include <QVariantMap>
-
-QT_BEGIN_NAMESPACE_AM
-
-class InstallationLocation
-{
-public:
- static const InstallationLocation invalid;
-
- bool operator==(const InstallationLocation &other) const;
- inline bool operator!=(const InstallationLocation &other) const { return !((*this) == other); }
-
- QString id() const;
- int index() const;
-
- QString installationPath() const;
- QString documentPath() const;
-
- bool installationDeviceFreeSpace(quint64 *bytesTotal, quint64 *bytesFree) const;
- bool documentDeviceFreeSpace(quint64 *bytesTotal, quint64 *bytesFree) const;
-
- bool isValid() const;
- bool isDefault() const;
-
- QVariantMap toVariantMap() const;
-
- static QVector<InstallationLocation> parseInstallationLocations(const QVariantList &list,
- const QString &hardwareId) Q_DECL_NOEXCEPT_EXPR(false);
-
-private:
- bool m_valid = false;
- int m_index = 0;
- bool m_isDefault = false;
- QString m_installationPath;
- QString m_documentPath;
-};
-
-QT_END_NAMESPACE_AM
diff --git a/src/installer-lib/installationtask.cpp b/src/installer-lib/installationtask.cpp
index 619e49c4..ad017286 100644
--- a/src/installer-lib/installationtask.cpp
+++ b/src/installer-lib/installationtask.cpp
@@ -122,10 +122,12 @@ private:
QMutex InstallationTask::s_serializeFinishInstallation { };
-InstallationTask::InstallationTask(const InstallationLocation &installationLocation, const QUrl &sourceUrl, QObject *parent)
+InstallationTask::InstallationTask(const QString &installationPath, const QString &documentPath,
+ const QUrl &sourceUrl, QObject *parent)
: AsynchronousTask(parent)
, m_pm(PackageManager::instance())
- , m_installationLocation(installationLocation)
+ , m_installationPath(installationPath)
+ , m_documentPath(documentPath)
, m_sourceUrl(sourceUrl)
{ }
@@ -161,8 +163,8 @@ void InstallationTask::acknowledge()
void InstallationTask::execute()
{
try {
- if (!m_installationLocation.isValid())
- throw Exception("invalid installation location");
+ if (m_installationPath.isEmpty())
+ throw Exception("no installation location was configured");
TemporaryDir extractionDir;
if (!extractionDir.isValid())
@@ -293,13 +295,6 @@ void InstallationTask::checkExtractedFile(const QString &file) Q_DECL_NOEXCEPT_E
if (m_iconFileName.isEmpty())
throw Exception(Error::Package, "the 'icon' field in info.yaml cannot be empty or absent.");
- InstallationLocation existingLocation = m_pm->installationLocationFromPackage(m_package->id());
-
- if (existingLocation.isValid() && (existingLocation != m_installationLocation)) {
- throw Exception(Error::Package, "the package %1 cannot be installed to %2, since it is already installed to %3")
- .arg(m_package->id(), m_installationLocation.id(), existingLocation.id());
- }
-
m_packageId = m_package->id();
m_foundInfo = true;
@@ -342,7 +337,7 @@ void InstallationTask::checkExtractedFile(const QString &file) Q_DECL_NOEXCEPT_E
{ qSL("baseDir"), m_package->baseDir().absolutePath() },
{ qSL("codeDir"), m_package->baseDir().absolutePath() }, // 5.12 backward compatibility
{ qSL("manifestDir"), m_package->baseDir().absolutePath() }, // 5.12 backward compatibility
- { qSL("installationLocationId"), m_installationLocation.id() }
+ { qSL("installationLocationId"), qSL("internal-0") } // 5.13 backward compatibility
};
emit m_pm->taskRequestingInstallationAcknowledge(id(), applicationData,
m_extractor->installationReport().extraMetaData(),
@@ -387,7 +382,7 @@ void InstallationTask::startInstallation() Q_DECL_NOEXCEPT_EXPR(false)
{
// 2. delete old, partial installation
- QDir installationDir = QString(m_installationLocation.installationPath() + qL1C('/'));
+ QDir installationDir = QString(m_installationPath + qL1C('/'));
QString installationTarget = m_packageId + qL1C('+');
if (installationDir.exists(installationTarget)) {
if (!removeRecursiveHelper(installationDir.absoluteFilePath(installationTarget)))
@@ -405,7 +400,7 @@ void InstallationTask::startInstallation() Q_DECL_NOEXCEPT_EXPR(false)
void InstallationTask::finishInstallation() Q_DECL_NOEXCEPT_EXPR(false)
{
- QDir documentDirectory(m_installationLocation.documentPath());
+ QDir documentDirectory(m_documentPath);
ScopedDirectoryCreator documentDirCreator;
enum { Installation, Update } mode = Installation;
@@ -415,7 +410,6 @@ void InstallationTask::finishInstallation() Q_DECL_NOEXCEPT_EXPR(false)
// create the installation report
InstallationReport report = m_extractor->installationReport();
- report.setInstallationLocationId(m_installationLocation.id());
QFile reportFile(m_extractionDir.absoluteFilePath(qSL(".installation-report.yaml")));
if (!reportFile.open(QFile::WriteOnly) || !report.serialize(&reportFile))
diff --git a/src/installer-lib/installationtask.h b/src/installer-lib/installationtask.h
index 4ea271d0..6fc43f16 100644
--- a/src/installer-lib/installationtask.h
+++ b/src/installer-lib/installationtask.h
@@ -48,7 +48,6 @@
#include <QMutex>
#include <QtAppManApplication/installationreport.h>
-#include <QtAppManInstaller/installationlocation.h>
#include <QtAppManInstaller/asynchronoustask.h>
#include <QtAppManInstaller/scopeutilities.h>
@@ -63,8 +62,8 @@ class InstallationTask : public AsynchronousTask
{
Q_OBJECT
public:
- InstallationTask(const InstallationLocation &installationLocation, const QUrl &sourceUrl,
- QObject *parent = nullptr);
+ InstallationTask(const QString &installationPath, const QString &documentPath,
+ const QUrl &sourceUrl, QObject *parent = nullptr);
~InstallationTask() override;
void acknowledge();
@@ -83,7 +82,8 @@ private:
private:
PackageManager *m_pm;
- const InstallationLocation &m_installationLocation;
+ QString m_installationPath;
+ QString m_documentPath;
QUrl m_sourceUrl;
bool m_foundInfo = false;
bool m_foundIcon = false;
diff --git a/src/installer-lib/installer-lib.pro b/src/installer-lib/installer-lib.pro
index dcceedfa..0cf2695a 100644
--- a/src/installer-lib/installer-lib.pro
+++ b/src/installer-lib/installer-lib.pro
@@ -22,7 +22,6 @@ HEADERS += \
deinstallationtask.h \
installationtask.h \
scopeutilities.h \
- installationlocation.h \
package.h \
packagemanager.h \
packagemanager_p.h \
@@ -33,7 +32,6 @@ SOURCES += \
installationtask.cpp \
deinstallationtask.cpp \
scopeutilities.cpp \
- installationlocation.cpp \
packagemanager.cpp \
package.cpp \
sudo.cpp \
diff --git a/src/installer-lib/packagemanager.cpp b/src/installer-lib/packagemanager.cpp
index 4b2e09b9..c84fe833 100644
--- a/src/installer-lib/packagemanager.cpp
+++ b/src/installer-lib/packagemanager.cpp
@@ -53,6 +53,20 @@
#include "sudo.h"
#include "utilities.h"
+#if defined(Q_OS_WIN)
+# include <Windows.h>
+#else
+# include <sys/stat.h>
+# include <errno.h>
+# if defined(Q_OS_ANDROID)
+# include <sys/vfs.h>
+# define statvfs statfs
+# else
+# include <sys/statvfs.h>
+# endif
+#endif
+
+
QT_BEGIN_NAMESPACE_AM
enum Roles
@@ -76,14 +90,14 @@ PackageManager *PackageManager::s_instance = nullptr;
QHash<int, QByteArray> PackageManager::s_roleNames;
PackageManager *PackageManager::createInstance(PackageDatabase *packageDatabase,
- const QVector<InstallationLocation> &installationLocations)
+ const QString &documentPath)
{
if (Q_UNLIKELY(s_instance))
qFatal("PackageManager::createInstance() was called a second time.");
Q_ASSERT(packageDatabase);
- QScopedPointer<PackageManager> pm(new PackageManager(packageDatabase, installationLocations));
+ QScopedPointer<PackageManager> pm(new PackageManager(packageDatabase, documentPath));
registerQmlTypes();
// map all the built-in packages first
@@ -155,12 +169,13 @@ void PackageManager::registerQmlTypes()
}
PackageManager::PackageManager(PackageDatabase *packageDatabase,
- const QVector<InstallationLocation> &installationLocations)
+ const QString &documentPath)
: QAbstractListModel()
, d(new PackageManagerPrivate())
{
d->database = packageDatabase;
- d->installationLocations = installationLocations;
+ d->installationPath = packageDatabase->installedPackagesDir();
+ d->documentPath = documentPath;
}
PackageManager::~PackageManager()
@@ -405,6 +420,86 @@ void PackageManager::setCACertificates(const QList<QByteArray> &chainOfTrust)
d->chainOfTrust = chainOfTrust;
}
+static QVariantMap locationMap(const QString &path)
+{
+ QString cpath = QFileInfo(path).canonicalPath();
+ quint64 bytesTotal = 0;
+ quint64 bytesFree = 0;
+
+#if defined(Q_OS_WIN)
+ GetDiskFreeSpaceExW((LPCWSTR) cpath.utf16(), (ULARGE_INTEGER *) &bytesFree,
+ (ULARGE_INTEGER *) &bytesTotal, nullptr);
+
+#else // Q_OS_UNIX
+ int result;
+ struct ::statvfs svfs;
+
+ do {
+ result = ::statvfs(cpath.toLocal8Bit(), &svfs);
+ if (result == -1 && errno == EINTR)
+ continue;
+ } while (false);
+
+ if (result == 0) {
+ bytesTotal = quint64(svfs.f_frsize) * svfs.f_blocks;
+ bytesFree = quint64(svfs.f_frsize) * svfs.f_bavail;
+ }
+#endif // Q_OS_WIN
+
+
+ return QVariantMap {
+ { qSL("path"), path },
+ { qSL("deviceSize"), bytesTotal },
+ { qSL("deviceFree"), bytesFree }
+ };
+}
+
+/*!
+ \qmlproperty object PackageManager::installationLocation
+
+ Returns an object describing the location under which applications are installed in detail.
+
+ The returned object has the following members:
+
+ \table
+ \header
+ \li \c Name
+ \li \c Type
+ \li Description
+ \row
+ \li \c path
+ \li \c string
+ \li The absolute file-system path to the base directory.
+ \row
+ \li \c deviceSize
+ \li \c int
+ \li The size of the device holding \c path in bytes.
+ \row
+ \li \c deviceFree
+ \li \c int
+ \li The amount of bytes available on the device holding \c path.
+ \endtable
+
+ Returns an empty object in case the installer component is disabled.
+*/
+QVariantMap PackageManager::installationLocation() const
+{
+ return locationMap(d->installationPath);
+}
+
+/*!
+ \qmlproperty object PackageManager::documentLocation
+
+ Returns an object describing the location under which per-user document
+ directories are created in detail.
+
+ The returned object has the same members as described in PackageManager::installationLocation.
+*/
+QVariantMap PackageManager::documentLocation() const
+{
+ return locationMap(d->documentPath);
+}
+
void PackageManager::cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false)
{
// Check that everything in the app-db is available
@@ -412,54 +507,46 @@ void PackageManager::cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false)
// key: baseDirPath, value: subDirName/ or fileName
QMultiMap<QString, QString> validPaths;
- for (const InstallationLocation &il : qAsConst(d->installationLocations)) {
- validPaths.insert(il.documentPath(), QString());
- validPaths.insert(il.installationPath(), QString());
- }
+ if (!d->documentPath.isEmpty())
+ validPaths.insert(d->documentPath, QString());
+ if (!d->installationPath.isEmpty())
+ validPaths.insert(d->installationPath, QString());
for (Package *pkg : d->packages) { // we want to detach here!
const InstallationReport *ir = pkg->info()->installationReport();
if (ir) {
- const InstallationLocation &il = installationLocationFromId(ir->installationLocationId());
-
- bool valid = il.isValid();
-
- if (!valid)
- qCDebug(LogInstaller) << "cleanup: uninstalling" << pkg->id() << "- installationLocation is invalid";
-
- if (valid) {
- QString pkgDir = il.installationPath() + pkg->id();
- QStringList checkDirs;
- QStringList checkFiles;
-
- checkFiles << pkgDir + qSL("/info.yaml");
- checkFiles << pkgDir + qSL("/.installation-report.yaml");
- checkDirs << pkgDir;
- checkDirs << il.installationPath() + pkg->id();
-
- for (const QString &checkFile : qAsConst(checkFiles)) {
- QFileInfo fi(checkFile);
- if (!fi.exists() || !fi.isFile() || !fi.isReadable()) {
- valid = false;
- qCDebug(LogInstaller) << "cleanup: uninstalling" << pkg->id() << "- file missing:" << checkFile;
- break;
- }
- }
- for (const QString &checkDir : checkDirs) {
- QFileInfo fi(checkDir);
- if (!fi.exists() || !fi.isDir() || !fi.isReadable()) {
- valid = false;
- qCDebug(LogInstaller) << "cleanup: uninstalling" << pkg->id() << "- directory missing:" << checkDir;
- break;
- }
+ bool valid = true;
+
+ QString pkgDir = d->installationPath + pkg->id();
+ QStringList checkDirs;
+ QStringList checkFiles;
+
+ checkFiles << pkgDir + qSL("/info.yaml");
+ checkFiles << pkgDir + qSL("/.installation-report.yaml");
+ checkDirs << pkgDir;
+ checkDirs << d->installationPath + pkg->id();
+
+ for (const QString &checkFile : qAsConst(checkFiles)) {
+ QFileInfo fi(checkFile);
+ if (!fi.exists() || !fi.isFile() || !fi.isReadable()) {
+ valid = false;
+ qCDebug(LogInstaller) << "cleanup: uninstalling" << pkg->id() << "- file missing:" << checkFile;
+ break;
}
-
- if (valid) {
- validPaths.insertMulti(il.installationPath(), pkg->id() + qL1C('/'));
- validPaths.insertMulti(il.documentPath(), pkg->id() + qL1C('/'));
+ }
+ for (const QString &checkDir : checkDirs) {
+ QFileInfo fi(checkDir);
+ if (!fi.exists() || !fi.isDir() || !fi.isReadable()) {
+ valid = false;
+ qCDebug(LogInstaller) << "cleanup: uninstalling" << pkg->id() << "- directory missing:" << checkDir;
+ break;
}
}
- if (!valid) {
+
+ if (valid) {
+ validPaths.insertMulti(d->installationPath, pkg->id() + qL1C('/'));
+ validPaths.insertMulti(d->documentPath, pkg->id() + qL1C('/'));
+ } else {
if (startingPackageRemoval(pkg->id())) {
if (finishedPackageInstall(pkg->id()))
continue;
@@ -506,39 +593,6 @@ void PackageManager::cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false)
}
}
-
-QVector<InstallationLocation> PackageManager::installationLocations() const
-{
- return d->installationLocations;
-}
-
-const InstallationLocation &PackageManager::defaultInstallationLocation() const
-{
- for (const InstallationLocation &il : d->installationLocations) {
- if (il.isDefault())
- return il;
- }
- return InstallationLocation::invalid;
-}
-
-const InstallationLocation &PackageManager::installationLocationFromId(const QString &installationLocationId) const
-{
- for (const InstallationLocation &il : d->installationLocations) {
- if (il.id() == installationLocationId)
- return il;
- }
- return InstallationLocation::invalid;
-}
-
-const InstallationLocation &PackageManager::installationLocationFromPackage(const QString &packageId) const
-{
- if (Package *package = fromId(packageId)) {
- if (const InstallationReport *report = package->info()->installationReport())
- return installationLocationFromId(report->installationLocationId());
- }
- return InstallationLocation::invalid;
-}
-
/*!
\qmlmethod list<string> PackageManager::packageIds()
@@ -569,105 +623,6 @@ QVariantMap PackageManager::get(const QString &id) const
}
/*!
- \qmlmethod list<string> PackageManager::installationLocationIds()
-
- Retuns a list of all known installation location ids. Calling getInstallationLocation() on one of
- the returned identifiers will yield specific information about the individual installation locations.
-*/
-QStringList PackageManager::installationLocationIds() const
-{
- QStringList ids;
- for (const InstallationLocation &il : d->installationLocations)
- ids << il.id();
- return ids;
-}
-
-/*!
- \qmlmethod string PackageManager::installationLocationIdFromApplication(string packageId)
-
- Returns the installation location id for the package identified by \a packageId. Returns
- an empty string in case the package is not installed.
-
- \sa installationLocationIds()
-*/
-QString PackageManager::installationLocationIdFromPackage(const QString &packageId) const
-{
- const InstallationLocation &il = installationLocationFromPackage(packageId);
- return il.isValid() ? il.id() : QString();
-}
-
-/*!
- \qmlmethod object PackageManager::getInstallationLocation(string installationLocationId)
-
- Returns an object describing the installation location identified by \a installationLocationId
- in detail.
-
- The returned object has the following members:
-
- \table
- \header
- \li \c Name
- \li \c Type
- \li Description
- \row
- \li \c id
- \li \c string
- \li The installation location id that is used as the handle for all other ApplicationInstaller
- function calls. The \c id consists of the \c type and \c index field, concatenated by
- a single dash (for example, \c internal-0).
- \row
- \li \c type
- \li \c string
- \li The type of device this installation location is connected to. Valid values are \c
- internal (for any kind of built-in storage, e.g. flash) and \c invalid.
- \row
- \li \c index
- \li \c int
- \li In case there is more than one installation location for the same type of device, this
- \c zero-based index is used for disambiguation. Otherwise, the index is always \c 0.
- \row
- \li \c isDefault
- \li \c bool
-
- \li Exactly one installation location is the default location which must be mounted and
- accessible at all times. This can be used by an UI application to get a sensible
- default for the installation location that it needs to pass to startPackageInstallation().
- \row
- \li \c installationPath
- \li \c string
- \li The absolute file-system path to the base directory under which applications are installed.
- \row
- \li \c installationDeviceSize
- \li \c int
- \li The size of the device holding \c installationPath in bytes.
- \row
- \li \c installationDeviceFree
- \li \c int
- \li The amount of bytes available on the device holding \c installationPath.
- \row
- \li \c documentPath
- \li \c string
- \li The absolute file-system path to the base directory under which per-user document
- directories are created.
- \row
- \li \c documentDeviceSize
- \li \c int
- \li The size of the device holding \c documentPath in bytes.
- \row
- \li \c documentDeviceFree
- \li \c int
- \li The amount of bytes available on the device holding \c documentPath.
- \endtable
-
- Returns an empty object in case the \a installationLocationId is not valid.
-*/
-QVariantMap PackageManager::getInstallationLocation(const QString &installationLocationId) const
-{
- const InstallationLocation &il = installationLocationFromId(installationLocationId);
- return il.isValid() ? il.toVariantMap() : QVariantMap();
-}
-
-/*!
\qmlmethod int PackageManager::installedPackageSize(string packageId)
Returns the size in bytes that the package identified by \a packageId is occupying on the storage
@@ -720,20 +675,17 @@ QVariantMap PackageManager::installedPackageExtraSignedMetaData(const QString &p
/*! \internal
Type safe convenience function, since DBus does not like QUrl
*/
-QString PackageManager::startPackageInstallation(const QString &installationLocationId, const QUrl &sourceUrl)
+QString PackageManager::startPackageInstallation(const QUrl &sourceUrl)
{
- AM_TRACE(LogInstaller, installationLocationId, sourceUrl);
-
- const InstallationLocation &il = installationLocationFromId(installationLocationId);
+ AM_TRACE(LogInstaller, sourceUrl);
- return enqueueTask(new InstallationTask(il, sourceUrl));
+ return enqueueTask(new InstallationTask(d->installationPath, d->documentPath, sourceUrl));
}
/*!
- \qmlmethod string PackageManager::startPackageInstallation(string installationLocationId, string sourceUrl)
+ \qmlmethod string PackageManager::startPackageInstallation(string sourceUrl)
- Downloads an application package from \a sourceUrl and installs it to the installation location
- described by \a installationLocationId.
+ Downloads an application package from \a sourceUrl and installs it.
The actual download and installation will happen asynchronously in the background. The
PackageManager emits the signals \l taskStarted, \l taskProgressChanged, \l
@@ -751,12 +703,12 @@ QString PackageManager::startPackageInstallation(const QString &installationLoca
Returns a unique \c taskId. This can also be an empty string, if the task could not be
created (in this case, no signals will be emitted).
*/
-QString PackageManager::startPackageInstallation(const QString &installationLocationId, const QString &sourceUrl)
+QString PackageManager::startPackageInstallation(const QString &sourceUrl)
{
QUrl url(sourceUrl);
if (url.scheme().isEmpty())
url = QUrl::fromLocalFile(sourceUrl);
- return startPackageInstallation(installationLocationId, url);
+ return startPackageInstallation(url);
}
/*!
@@ -803,11 +755,9 @@ QString PackageManager::removePackage(const QString &packageId, bool keepDocumen
AM_TRACE(LogInstaller, packageId, keepDocuments)
if (Package *package = fromId(packageId)) {
- if (const InstallationReport *report = package->info()->installationReport()) {
- const InstallationLocation &il = installationLocationFromId(report->installationLocationId());
-
- if (il.isValid() && (il.id() == report->installationLocationId()))
- return enqueueTask(new DeinstallationTask(package->info(), il, force, keepDocuments));
+ if (package->info()->installationReport()) {
+ return enqueueTask(new DeinstallationTask(package->info(), d->installationPath,
+ d->documentPath, force, keepDocuments));
}
}
return QString();
diff --git a/src/installer-lib/packagemanager.h b/src/installer-lib/packagemanager.h
index a2b90cf3..24cd0f63 100644
--- a/src/installer-lib/packagemanager.h
+++ b/src/installer-lib/packagemanager.h
@@ -46,7 +46,6 @@
#include <QAbstractListModel>
#include <QtAppManCommon/global.h>
#include <QtAppManApplication/packageinfo.h>
-#include <QtAppManInstaller/installationlocation.h>
#include <QtAppManInstaller/asynchronoustask.h>
#include <QtAppManInstaller/installationtask.h>
#include <QtAppManInstaller/deinstallationtask.h>
@@ -73,6 +72,9 @@ class PackageManager : public QAbstractListModel
Q_PROPERTY(bool developmentMode READ developmentMode CONSTANT)
Q_PROPERTY(QString hardwareId READ hardwareId CONSTANT)
+ Q_PROPERTY(QVariantMap installationLocation READ installationLocation CONSTANT)
+ Q_PROPERTY(QVariantMap documentLocation READ documentLocation CONSTANT)
+
Q_PROPERTY(bool applicationUserIdSeparation READ isApplicationUserIdSeparationEnabled)
Q_PROPERTY(uint commonApplicationGroupId READ commonApplicationGroupId)
@@ -85,7 +87,7 @@ public:
~PackageManager() override;
static PackageManager *createInstance(PackageDatabase *packageDatabase,
- const QVector<InstallationLocation> &installationLocations);
+ const QString &documentPath);
static PackageManager *instance();
static QObject *instanceForQml(QQmlEngine *qmlEngine, QJSEngine *);
@@ -122,27 +124,20 @@ public:
void cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false);
- // InstallationLocation handling
- QVector<InstallationLocation> installationLocations() const;
- const InstallationLocation &defaultInstallationLocation() const;
- const InstallationLocation &installationLocationFromId(const QString &installationLocationId) const;
- const InstallationLocation &installationLocationFromPackage(const QString &packageId) const;
+ QVariantMap installationLocation() const;
+ QVariantMap documentLocation() const;
// Q_SCRIPTABLEs are available via both QML and D-Bus
Q_SCRIPTABLE QStringList packageIds() const;
Q_SCRIPTABLE QVariantMap get(const QString &id) const;
- Q_SCRIPTABLE QStringList installationLocationIds() const;
- Q_SCRIPTABLE QString installationLocationIdFromPackage(const QString &packageId) const;
- Q_SCRIPTABLE QVariantMap getInstallationLocation(const QString &installationLocationId) const;
-
Q_SCRIPTABLE qint64 installedPackageSize(const QString &packageId) const;
Q_SCRIPTABLE QVariantMap installedPackageExtraMetaData(const QString &packageId) const;
Q_SCRIPTABLE QVariantMap installedPackageExtraSignedMetaData(const QString &packageId) const;
// all QString return values are task-ids
- QString startPackageInstallation(const QString &installationLocationId, const QUrl &sourceUrl);
- Q_SCRIPTABLE QString startPackageInstallation(const QString &installationLocationId, const QString &sourceUrl);
+ QString startPackageInstallation(const QUrl &sourceUrl);
+ Q_SCRIPTABLE QString startPackageInstallation(const QString &sourceUrl);
Q_SCRIPTABLE void acknowledgePackageInstallation(const QString &taskId);
Q_SCRIPTABLE QString removePackage(const QString &id, bool keepDocuments, bool force = false);
@@ -200,7 +195,7 @@ private:
uint findUnusedUserId() const Q_DECL_NOEXCEPT_EXPR(false);
explicit PackageManager(PackageDatabase *packageDatabase,
- const QVector<InstallationLocation> &installationLocations);
+ const QString &documentPath);
PackageManager(const PackageManager &);
PackageManager &operator=(const PackageManager &);
static PackageManager *s_instance;
diff --git a/src/installer-lib/packagemanager_p.h b/src/installer-lib/packagemanager_p.h
index 4035c896..89d5c287 100644
--- a/src/installer-lib/packagemanager_p.h
+++ b/src/installer-lib/packagemanager_p.h
@@ -70,7 +70,8 @@ public:
uint maxUserId = uint(-1);
uint commonGroupId = uint(-1);
- QVector<InstallationLocation> installationLocations;
+ QString installationPath;
+ QString documentPath;
QString error;
diff --git a/src/main-lib/applicationinstaller.h b/src/main-lib/applicationinstaller.h
index dbf66d9a..70dcece8 100644
--- a/src/main-lib/applicationinstaller.h
+++ b/src/main-lib/applicationinstaller.h
@@ -47,12 +47,12 @@
#include <QUrl>
#include <QStringList>
#include <QDir>
+#include <QDebug>
#include <QtAppManCommon/error.h>
-#include <QtAppManCommon/error.h>
+#include <QtAppManCommon/logging.h>
#include <QtAppManManager/applicationmanager.h>
#include <QtAppManInstaller/packagemanager.h>
#include <QtAppManInstaller/package.h>
-#include <QtAppManInstaller/installationlocation.h>
#include <QtAppManInstaller/asynchronoustask.h>
QT_FORWARD_DECLARE_CLASS(QQmlEngine)
@@ -91,18 +91,48 @@ public:
uint commonApplicationGroupId() const { return m_pm->commonApplicationGroupId(); }
// Q_SCRIPTABLEs are available via both QML and D-Bus
- Q_SCRIPTABLE QStringList installationLocationIds() const { return m_pm->installationLocationIds(); }
+ Q_SCRIPTABLE QStringList installationLocationIds() const { return { qL1S("internal-0") }; }
Q_SCRIPTABLE QString installationLocationIdFromApplication(const QString &applicationId) const
{
auto app = ApplicationManager::instance()->fromId(applicationId);
- return m_pm->installationLocationIdFromPackage(app ? app->package()->id() : QString());
+ if (app && ((!app->package()->isBuiltIn() || app->package()->canBeRevertedToBuiltIn())))
+ return qL1S("internal-0");
+ return QString();
}
Q_SCRIPTABLE QVariantMap getInstallationLocation(const QString &installationLocationId) const
- { return m_pm->getInstallationLocation(installationLocationId); }
+ {
+ if (installationLocationId != qL1S("internal-0"))
+ return QVariantMap { };
+
+ auto iloc = m_pm->installationLocation();
+ auto dloc = m_pm->documentLocation();
+
+ return QVariantMap {
+ { qSL("id"), qSL("internal-0") },
+ { qSL("type"), qSL("internal") },
+ { qSL("index"), 0 },
+ { qSL("isDefault"), true },
+ { qSL("installationPath"), iloc.value(qL1S("path")) },
+ { qSL("installationDeviceSize"), iloc.value(qL1S("size")) },
+ { qSL("installationDeviceFree"), iloc.value(qL1S("free")) },
+ { qSL("documentPath"), dloc.value(qL1S("path")) },
+ { qSL("documentDeviceSize"), dloc.value(qL1S("size")) },
+ { qSL("documentDeviceFree"), dloc.value(qL1S("free")) }
+ };
+ }
// all QString return values are task-ids
Q_SCRIPTABLE QString startPackageInstallation(const QString &installationLocationId, const QString &sourceUrl)
- { return m_pm->startPackageInstallation(installationLocationId, sourceUrl); }
+ {
+ if (installationLocationId == qL1S("internal-0")) {
+ return m_pm->startPackageInstallation(sourceUrl);
+ } else {
+ qCWarning(LogInstaller) << "The only supported legacy installation location is 'internal-0', "
+ "but an installation was requested to:" << installationLocationId;
+ return QString();
+ }
+ }
+
Q_SCRIPTABLE void acknowledgePackageInstallation(const QString &taskId)
{ return m_pm->acknowledgePackageInstallation(taskId); }
Q_SCRIPTABLE QString removePackage(const QString &packageId, bool keepDocuments, bool force = false)
diff --git a/src/main-lib/defaultconfiguration.cpp b/src/main-lib/defaultconfiguration.cpp
index b9e61e8e..e3416b6f 100644
--- a/src/main-lib/defaultconfiguration.cpp
+++ b/src/main-lib/defaultconfiguration.cpp
@@ -91,7 +91,9 @@ DefaultConfiguration::DefaultConfiguration(const QStringList &defaultConfigFileP
m_clp.addOption({ qSL("database"), qSL("filepath of the application database cache."), qSL("file") });
m_clp.addOption({ { qSL("r"), qSL("recreate-database") }, qSL("recreate the application database cache.") });
m_clp.addOption({ qSL("builtin-apps-manifest-dir"), qSL("base directory for built-in application manifests."), qSL("dir") });
- m_clp.addOption({ qSL("installed-apps-manifest-dir"), qSL("base directory for installed application manifests."), qSL("dir") });
+ m_clp.addOption({ qSL("installation-dir"), qSL("base directory for package installations."), qSL("dir") });
+ m_clp.addOption({ qSL("document-dir"), qSL("base directory for per-package document directories."), qSL("dir") });
+ m_clp.addOption({ qSL("installed-apps-manifest-dir"), qSL("deprecated (ignored)."), qSL("dir") });
m_clp.addOption({ qSL("app-image-mount-dir"), qSL("deprecated, not needed anymore."), qSL("dir") });
m_clp.addOption({ qSL("disable-installer"), qSL("disable the application installer sub-system.") });
m_clp.addOption({ qSL("disable-intents"), qSL("disable the intents sub-system.") });
@@ -139,10 +141,30 @@ void DefaultConfiguration::parseWithArguments(const QStringList &arguments, QStr
*deploymentWarnings << qL1S("No --database command line parameter or applications/database configuration"
" key specified. Database won't be cached to speed up subsequent System-UI startups.");
- if (installedAppsManifestDir().isEmpty())
- *deploymentWarnings << qL1S("No --installed-apps-manifest-dir command line parameter or"
- " applications/installedAppsManifestDir configuration key specified. It won't be possible to install,"
- " remove or access installable applications.");
+ if (installationDir().isEmpty()) {
+ const auto ilocs = value<QVariant>(nullptr, { "installationLocations" }).toList();
+ if (!ilocs.isEmpty()) {
+ *deploymentWarnings << qL1S("Support for \"installationLocations\" in the main config file has been removed:");
+
+ for (const auto iloc : ilocs) {
+ QVariantMap map = iloc.toMap();
+ QString id = map.value(qSL("id")).toString();
+ if (id == qSL("internal-0")) {
+ m_installationDir = map.value(qSL("installationPath")).toString();
+ m_documentDir = map.value(qSL("documentPath")).toString();
+ *deploymentWarnings << qL1S(" * still using installation location \"internal-0\" for backward compatibility");
+ } else {
+ *deploymentWarnings << qL1S(" * ignoring installation location ") + id;
+ }
+ }
+ }
+ }
+
+ if (installationDir().isEmpty()) {
+ *deploymentWarnings << qL1S("No --installation-dir command line parameter or"
+ " applications/installationDir configuration key specified. It won't be possible to install,"
+ " remove or access installable packages.");
+ }
if (value<bool>("start-session-dbus"))
*deploymentWarnings << qL1S("Option \"--start-session-dbus\" has been deprecated and will be ignored.");
@@ -172,9 +194,18 @@ QStringList DefaultConfiguration::builtinAppsManifestDirs() const
return value<QStringList>("builtin-apps-manifest-dir", { "applications", "builtinAppsManifestDir" });
}
-QString DefaultConfiguration::installedAppsManifestDir() const
+QString DefaultConfiguration::installationDir() const
{
- return value<QString>("installed-apps-manifest-dir", { "applications", "installedAppsManifestDir" });
+ if (m_installationDir.isEmpty())
+ m_installationDir = value<QString>("installation-dir", { "applications", "installationDir" });
+ return m_installationDir;
+}
+
+QString DefaultConfiguration::documentDir() const
+{
+ if (m_documentDir.isEmpty())
+ m_documentDir = value<QString>("document-dir", { "applications", "documentDir" });
+ return m_documentDir;
}
bool DefaultConfiguration::disableInstaller() const
@@ -343,11 +374,6 @@ QVariantMap DefaultConfiguration::openGLConfiguration() const
return value<QVariant>(nullptr, { "ui", "opengl" }).toMap();
}
-QVariantList DefaultConfiguration::installationLocations() const
-{
- return value<QVariant>(nullptr, { "installationLocations" }).toList();
-}
-
QList<QPair<QString, QString>> DefaultConfiguration::containerSelectionConfiguration() const
{
QList<QPair<QString, QString>> config;
diff --git a/src/main-lib/defaultconfiguration.h b/src/main-lib/defaultconfiguration.h
index d253d420..6bcd70b3 100644
--- a/src/main-lib/defaultconfiguration.h
+++ b/src/main-lib/defaultconfiguration.h
@@ -65,7 +65,10 @@ public:
bool recreateDatabase() const;
QStringList builtinAppsManifestDirs() const;
- QString installedAppsManifestDir() const;
+
+ QString installationDir() const;
+ QString documentDir() const;
+
bool disableInstaller() const;
bool disableIntents() const;
QMap<QString, int> intentTimeouts() const;
@@ -98,8 +101,6 @@ public:
QVariantMap openGLConfiguration() const;
- QVariantList installationLocations() const;
-
QList<QPair<QString, QString>> containerSelectionConfiguration() const;
QVariantMap containerConfigurations() const;
QVariantMap runtimeConfigurations() const;
@@ -131,6 +132,8 @@ private:
QString m_mainQmlFile;
bool m_onlyOnePositionalArgument = false;
bool m_forceVerbose = false;
+ mutable QString m_installationDir; // cached value
+ mutable QString m_documentDir; // cached value
};
QT_END_NAMESPACE_AM
diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp
index 180fdd51..35ce3dac 100644
--- a/src/main-lib/main.cpp
+++ b/src/main-lib/main.cpp
@@ -212,7 +212,8 @@ void Main::setup(const DefaultConfiguration *cfg, const QStringList &deploymentW
m_noSecurity = cfg->noSecurity();
m_developmentMode = cfg->developmentMode();
m_builtinAppsManifestDirs = cfg->builtinAppsManifestDirs();
- m_installedAppsManifestDir = cfg->installedAppsManifestDir();
+ m_installationDir = cfg->installationDir();
+ m_documentDir = cfg->documentDir();
CrashHandler::setCrashActionConfiguration(cfg->managerCrashAction());
setupLogging(cfg->verbose(), cfg->loggingRules(), cfg->messagePattern(), cfg->useAMConsoleLogger());
@@ -236,15 +237,13 @@ void Main::setup(const DefaultConfiguration *cfg, const QStringList &deploymentW
setupRuntimesAndContainers(cfg->runtimeConfigurations(), cfg->openGLConfiguration(),
cfg->containerConfigurations(), cfg->pluginFilePaths("container"),
cfg->iconThemeSearchPaths(), cfg->iconThemeName());
- if (!cfg->disableInstaller())
- setupInstallationLocations(cfg->installationLocations());
loadPackageDatabase(cfg->recreateDatabase(), cfg->singleApp());
setupSingletons(cfg->containerSelectionConfiguration(), cfg->quickLaunchRuntimesPerContainer(),
cfg->quickLaunchIdleLoad());
- if (m_installedAppsManifestDir.isEmpty() || cfg->disableInstaller()) {
+ if (m_installationDir.isEmpty() || cfg->disableInstaller()) {
StartupTimer::instance()->checkpoint("skipping installer");
} else {
setupInstaller(cfg->caCertificates(),
@@ -425,24 +424,12 @@ void Main::setupRuntimesAndContainers(const QVariantMap &runtimeConfigurations,
StartupTimer::instance()->checkpoint("after runtime registration");
}
-void Main::setupInstallationLocations(const QVariantList &installationLocations)
-{
-#if !defined(AM_DISABLE_INSTALLER)
- m_installationLocations = InstallationLocation::parseInstallationLocations(installationLocations,
- hardwareId());
- if (m_installationLocations.isEmpty())
- qCWarning(LogDeployment) << "No installation locations defined in config file";
-#else
- Q_UNUSED(installationLocations)
-#endif
-}
-
void Main::loadPackageDatabase(bool recreateDatabase, const QString &singlePackage) Q_DECL_NOEXCEPT_EXPR(false)
{
if (!singlePackage.isEmpty()) {
m_packageDatabase = new PackageDatabase(singlePackage);
} else {
- m_packageDatabase = new PackageDatabase(m_builtinAppsManifestDirs, m_installedAppsManifestDir);
+ m_packageDatabase = new PackageDatabase(m_builtinAppsManifestDirs, m_installationDir);
if (!recreateDatabase)
m_packageDatabase->enableLoadFromCache();
m_packageDatabase->enableSaveToCache();
@@ -461,17 +448,6 @@ void Main::loadPackageDatabase(bool recreateDatabase, const QString &singlePacka
if (!RuntimeFactory::instance()->manager(app->runtimeName()))
throw Exception("application '%1' uses an unknown runtime: %2").arg(app->id(), app->runtimeName());
}
-
- // fix the basedir of the package here, because (PackageDatabase
- // (application-lib) doesn't know about InstallationLocation (installer-lib)
- if (package->installationReport()) {
- for (const InstallationLocation &il : m_installationLocations) {
- if (il.id() == package->installationReport()->installationLocationId()) {
- package->setBaseDir(QDir(il.installationPath() + package->id()));
- break;
- }
- }
- }
}
StartupTimer::instance()->checkpoint("after package database loading");
@@ -509,7 +485,7 @@ void Main::setupSingletons(const QList<QPair<QString, QString>> &containerSelect
int quickLaunchRuntimesPerContainer,
qreal quickLaunchIdleLoad) Q_DECL_NOEXCEPT_EXPR(false)
{
- m_packageManager = PackageManager::createInstance(m_packageDatabase, m_installationLocations);
+ m_packageManager = PackageManager::createInstance(m_packageDatabase, m_documentDir);
qCDebug(LogSystem) << "Registering packages:";
@@ -568,8 +544,10 @@ void Main::setupInstaller(const QStringList &caCertificatePaths,
if (Q_UNLIKELY(hardwareId().isEmpty()))
throw Exception("the installer is enabled, but the device-id is empty");
- if (Q_UNLIKELY(!QDir::root().mkpath(m_installedAppsManifestDir)))
- throw Exception("could not create manifest directory for installed applications: \'%1\'").arg(m_installedAppsManifestDir);
+ if (!m_installationDir.isEmpty() && !QDir::root().mkpath(m_installationDir))
+ throw Exception("could not create package installation directory: \'%1\'").arg(m_installationDir);
+ if (!m_documentDir.isEmpty() && !QDir::root().mkpath(m_documentDir))
+ throw Exception("could not create document directory for packages: \'%1\'").arg(m_documentDir);
StartupTimer::instance()->checkpoint("after installer setup checks");
diff --git a/src/main-lib/main.h b/src/main-lib/main.h
index 06ee6ae7..626e1f1f 100644
--- a/src/main-lib/main.h
+++ b/src/main-lib/main.h
@@ -59,7 +59,6 @@ typedef QApplication MainBase;
typedef QGuiApplication MainBase;
#endif
-#include <QtAppManInstaller/installationlocation.h>
#include <QtAppManSharedMain/sharedmain.h>
#include <QVector>
@@ -115,7 +114,6 @@ protected:
void setupRuntimesAndContainers(const QVariantMap &runtimeConfigurations, const QVariantMap &openGLConfiguration,
const QVariantMap &containerConfigurations, const QStringList &containerPluginPaths,
const QStringList &iconThemeSearchPaths, const QString &iconThemeName);
- void setupInstallationLocations(const QVariantList &installationLocations);
void loadPackageDatabase(bool recreateDatabase, const QString &singlePackage) Q_DECL_NOEXCEPT_EXPR(false);
void setupIntents(const QMap<QString, int> &timeouts) Q_DECL_NOEXCEPT_EXPR(false);
void setupSingletons(const QList<QPair<QString, QString>> &containerSelectionConfiguration,
@@ -160,7 +158,6 @@ private:
#if !defined(AM_DISABLE_INSTALLER)
ApplicationInstaller *m_applicationInstaller = nullptr;
#endif
- QVector<InstallationLocation> m_installationLocations;
NotificationManager *m_notificationManager = nullptr;
IntentServer *m_intentServer = nullptr;
WindowManager *m_windowManager = nullptr;
@@ -171,7 +168,8 @@ private:
bool m_noSecurity = false;
bool m_developmentMode = false;
QStringList m_builtinAppsManifestDirs;
- QString m_installedAppsManifestDir;
+ QString m_installationDir;
+ QString m_documentDir;
};
QT_END_NAMESPACE_AM
diff --git a/src/manager-lib/application.cpp b/src/manager-lib/application.cpp
index bfb59fce..2e489e7f 100644
--- a/src/manager-lib/application.cpp
+++ b/src/manager-lib/application.cpp
@@ -194,10 +194,7 @@
\qmlproperty string ApplicationObject::codeDir
\readonly
- The absolute path to the application's installation directory. Please note this directory might
- not always be available for applications that were installed onto removable media.
-
- \sa {Installation Locations}
+ The absolute path to the application's installation directory.
*/
/*!
\qmlproperty enumeration ApplicationObject::state
diff --git a/src/plugin-interfaces/containerinterface.cpp b/src/plugin-interfaces/containerinterface.cpp
index d5009720..53e71b30 100644
--- a/src/plugin-interfaces/containerinterface.cpp
+++ b/src/plugin-interfaces/containerinterface.cpp
@@ -131,10 +131,6 @@ ContainerManagerInterface::~ContainerManagerInterface() { }
\row
\li \c applicationProperties
\li A map with all application properties as seen in the manifest.
- \row
- \li \c installationLocationId
- \li The installation location id, if this application was installed - empty for built-in
- applications.
\endtable
*/
diff --git a/src/tools/controller/controller.cpp b/src/tools/controller/controller.cpp
index d105b227..89e15e5a 100644
--- a/src/tools/controller/controller.cpp
+++ b/src/tools/controller/controller.cpp
@@ -194,12 +194,12 @@ static void listApplications() Q_DECL_NOEXCEPT_EXPR(false);
static void showApplication(const QString &appId, bool asJson = false) Q_DECL_NOEXCEPT_EXPR(false);
static void listPackages() Q_DECL_NOEXCEPT_EXPR(false);
static void showPackage(const QString &packageId, bool asJson = false) Q_DECL_NOEXCEPT_EXPR(false);
-static void installPackage(const QString &packageUrl, const QString &location, bool acknowledge) Q_DECL_NOEXCEPT_EXPR(false);
+static void installPackage(const QString &packageUrl, bool acknowledge) Q_DECL_NOEXCEPT_EXPR(false);
static void removePackage(const QString &packageId, bool keepDocuments, bool force) Q_DECL_NOEXCEPT_EXPR(false);
static void listInstallationTasks() Q_DECL_NOEXCEPT_EXPR(false);
static void cancelInstallationTask(bool all, const QString &taskId) Q_DECL_NOEXCEPT_EXPR(false);
static void listInstallationLocations() Q_DECL_NOEXCEPT_EXPR(false);
-static void showInstallationLocation(const QString &location, bool asJson = false) Q_DECL_NOEXCEPT_EXPR(false);
+static void showInstallationLocation(bool asJson = false) Q_DECL_NOEXCEPT_EXPR(false);
class ThrowingApplication : public QCoreApplication // clazy:exclude=missing-qobject-macro
{
@@ -406,17 +406,18 @@ int main(int argc, char *argv[])
break;
case InstallPackage:
- clp.addOption({ { qSL("l"), qSL("location") }, qSL("Set a custom installation location."), qSL("installation-location"), qSL("internal-0") });
+ clp.addOption({ { qSL("l"), qSL("location") }, qSL("Set a custom installation location (deprecated and ignored)."), qSL("installation-location"), qSL("internal-0") });
clp.addOption({ { qSL("a"), qSL("acknowledge") }, qSL("Automatically acknowledge the installation (unattended mode).") });
clp.addPositionalArgument(qSL("package"), qSL("The file name of the package; can be - for stdin."));
clp.process(a);
if (clp.positionalArguments().size() != 2)
clp.showHelp(1);
+ if (clp.isSet(qSL("l")))
+ fprintf(stderr, "Ignoring the deprecated -l option.\n");
a.runLater(std::bind(installPackage,
clp.positionalArguments().at(1),
- clp.value(qSL("l")),
clp.isSet(qSL("a"))));
break;
@@ -461,15 +462,16 @@ int main(int argc, char *argv[])
break;
case ShowInstallationLocation:
- clp.addPositionalArgument(qSL("installation-location"), qSL("The id of an installation location."));
+ clp.addPositionalArgument(qSL("installation-location"), qSL("The id of an installation location (deprecated and ignored)."));
clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") });
clp.process(a);
- if (clp.positionalArguments().size() != 2)
+ if (clp.positionalArguments().size() > 2)
clp.showHelp(1);
+ if (clp.positionalArguments().size() == 2)
+ fprintf(stderr, "Ignoring the deprecated installation-location.\n");
a.runLater(std::bind(showInstallationLocation,
- clp.positionalArguments().at(1),
clp.isSet(qSL("json"))));
break;
}
@@ -655,7 +657,7 @@ void showPackage(const QString &packageId, bool asJson) Q_DECL_NOEXCEPT_EXPR(fal
qApp->quit();
}
-void installPackage(const QString &package, const QString &location, bool acknowledge) Q_DECL_NOEXCEPT_EXPR(false)
+void installPackage(const QString &package, bool acknowledge) Q_DECL_NOEXCEPT_EXPR(false)
{
QString packageFile = package;
@@ -683,7 +685,7 @@ void installPackage(const QString &package, const QString &location, bool acknow
if (!fi.exists() || !fi.isReadable() || !fi.isFile())
throw Exception(Error::IO, "Package file is not readable: %1").arg(packageFile);
- fprintf(stdout, "Starting installation of package %s to %s...\n", qPrintable(packageFile), qPrintable(location));
+ fprintf(stdout, "Starting installation of package %s ...\n", qPrintable(packageFile));
dbus.connectToManager();
dbus.connectToPackager();
@@ -727,7 +729,7 @@ void installPackage(const QString &package, const QString &location, bool acknow
// start the package installation
- auto reply = dbus.packager()->startPackageInstallation(location, fi.absoluteFilePath());
+ auto reply = dbus.packager()->startPackageInstallation(fi.absoluteFilePath());
reply.waitForFinished();
if (reply.isError())
throw Exception(Error::IO, "failed to call startPackageInstallation via DBus: %1").arg(reply.error().message());
@@ -878,28 +880,18 @@ void listInstallationLocations() Q_DECL_NOEXCEPT_EXPR(false)
{
dbus.connectToPackager();
- auto reply = dbus.packager()->installationLocationIds();
- reply.waitForFinished();
- if (reply.isError())
- throw Exception(Error::IO, "failed to call installationLocationIds via DBus: %1").arg(reply.error().message());
-
- const auto installationLocationIds = reply.value();
- for (auto installationLocationId : installationLocationIds)
- fprintf(stdout, "%s\n", qPrintable(installationLocationId));
+ auto installationLocation = dbus.packager()->installationLocation().variant().toMap();
+ if (!installationLocation.isEmpty())
+ fputs("internal-0\n", stdout);
qApp->quit();
}
-void showInstallationLocation(const QString &location, bool asJson) Q_DECL_NOEXCEPT_EXPR(false)
+void showInstallationLocation(bool asJson) Q_DECL_NOEXCEPT_EXPR(false)
{
dbus.connectToPackager();
- auto reply = dbus.packager()->getInstallationLocation(location);
- reply.waitForFinished();
- if (reply.isError())
- throw Exception(Error::IO, "failed to call getInstallationLocation via DBus: %1").arg(reply.error().message());
-
- QVariant app = reply.value();
- fprintf(stdout, "%s\n", asJson ? QJsonDocument::fromVariant(app).toJson().constData()
- : QtYaml::yamlFromVariantDocuments({ app }).constData());
+ auto installationLocation = dbus.packager()->installationLocation().variant().toMap();
+ fprintf(stdout, "%s\n", asJson ? QJsonDocument::fromVariant(installationLocation).toJson().constData()
+ : QtYaml::yamlFromVariantDocuments({ installationLocation }).constData());
qApp->quit();
}
diff --git a/template-opt/am/config-windows.yaml b/template-opt/am/config-windows.yaml
index 0f1325b7..6c160fca 100644
--- a/template-opt/am/config-windows.yaml
+++ b/template-opt/am/config-windows.yaml
@@ -4,15 +4,6 @@ formatType: am-configuration
# installations will go into the standard /opt/am hierarchy
applications:
- installedAppsManifestDir: "c:/cygwin/opt/am/manifests"
- appImageMountDir: "c:/cygwin/opt/am/image-mounts"
+ installationDir: "c:/cygwin/opt/am/apps"
+ documentDir: "c:/cygwin/opt/am/docs"
database: "c:/cygwin/opt/am/apps.db"
-
-# simulate an internal and a SD-card installation location
-
-installationLocations:
-- id: "internal-0"
- installationPath: "c:/cygwin/opt/am/apps"
- documentPath: "c:/cygwin/opt/am/docs"
- mountPoint: "c:/cygwin/opt"
- isDefault: true
diff --git a/template-opt/am/config.yaml b/template-opt/am/config.yaml
index 94fc9bcb..38ce6195 100644
--- a/template-opt/am/config.yaml
+++ b/template-opt/am/config.yaml
@@ -4,20 +4,6 @@ formatType: am-configuration
# installations will go into the standard /opt/am hierarchy
applications:
- installedAppsManifestDir: "/opt/am/manifests"
- appImageMountDir: "/opt/am/image-mounts"
+ installationDir: "/opt/am/apps"
+ documentDir: "/opt/am/docs"
database: "/opt/am/apps.db"
-
-# simulate an internal and a SD-card installation location
-
-installationLocations:
-- id: "internal-0"
- installationPath: "/opt/am/apps"
- documentPath: "/opt/am/docs"
- mountPoint: "/opt"
- isDefault: true
-
-- id: "removable-0"
- installationPath: "/media/sdcard/apps"
- documentPath: "/media/sdcard/docs"
- mountPoint: "/media/sdcard"
diff --git a/tests/applicationinstaller/tst_applicationinstaller.cpp b/tests/applicationinstaller/tst_applicationinstaller.cpp
index b8138025..b9871ef0 100644
--- a/tests/applicationinstaller/tst_applicationinstaller.cpp
+++ b/tests/applicationinstaller/tst_applicationinstaller.cpp
@@ -109,8 +109,6 @@ private slots:
//TODO: test AI::cleanupBrokenInstallations() before calling cleanup() the first time!
- void installationLocations();
-
void packageInstallation_data();
void packageInstallation();
@@ -132,8 +130,6 @@ public:
enum PathLocation {
Internal0,
Documents0,
- Internal1,
- Documents1,
PathLocationCount
};
@@ -148,10 +144,8 @@ private:
{
QString base;
switch (pathLocation) {
- case Internal0: base = qSL("internal-0"); break;
- case Documents0: base = qSL("documents-0"); break;
- case Internal1: base = qSL("internal-1"); break;
- case Documents1: base = qSL("documents-1"); break;
+ case Internal0: base = qSL("internal"); break;
+ case Documents0: base = qSL("documents"); break;
default: break;
}
@@ -193,7 +187,6 @@ private:
QTemporaryDir m_workDir;
QString m_hardwareId;
- QVector<InstallationLocation> m_installationLocations;
PackageManager *m_pm = nullptr;
QSignalSpy *m_startedSpy = nullptr;
QSignalSpy *m_requestingInstallationAcknowledgeSpy = nullptr;
@@ -254,36 +247,29 @@ void tst_PackageManager::initTestCase()
for (int i = 0; i < PathLocationCount; ++i)
QVERIFY(QDir().mkdir(pathTo(PathLocation(i))));
- // define some installation locations for testing
-
- QVariantList iloc = QVariantList {
- QVariantMap {
- { "isDefault", true },
- { "id", "internal-0" },
- { "installationPath", pathTo(Internal0) },
- { "documentPath", pathTo(Documents0) }
- },
- QVariantMap {
- { "id", "internal-1" },
- { "installationPath", pathTo(Internal1) },
- { "documentPath", pathTo(Documents1) },
- }
- };
-
- m_installationLocations = InstallationLocation::parseInstallationLocations(iloc, m_hardwareId);
-
- QCOMPARE(m_installationLocations.size(), 2);
-
// finally, instantiate the PackageManager and a bunch of signal-spies for its signals
-
try {
- PackageDatabase *pdb = new PackageDatabase({ pathTo(Internal0) }, pathTo(Internal1));
- m_pm = PackageManager::createInstance(pdb, m_installationLocations);
+ PackageDatabase *pdb = new PackageDatabase(QStringList(), pathTo(Internal0));
+ m_pm = PackageManager::createInstance(pdb, pathTo(Documents0));
m_pm->setHardwareId(m_hardwareId);
} catch (const Exception &e) {
QVERIFY2(false, e.what());
}
+ const QVariantMap iloc = m_pm->installationLocation();
+ QCOMPARE(iloc.size(), 3);
+ QCOMPARE(iloc.value(qSL("path")).toString(), pathTo(Internal0));
+ QVERIFY(iloc.value(qSL("deviceSize")).toLongLong() > 0);
+ QVERIFY(iloc.value(qSL("deviceFree")).toLongLong() > 0);
+ QVERIFY(iloc.value(qSL("deviceFree")).toLongLong() < iloc.value(qSL("deviceSize")).toLongLong());
+
+ const QVariantMap dloc = m_pm->documentLocation();
+ QCOMPARE(dloc.size(), 3);
+ QCOMPARE(dloc.value(qSL("path")).toString(), pathTo(Documents0));
+ QVERIFY(dloc.value(qSL("deviceSize")).toLongLong() > 0);
+ QVERIFY(dloc.value(qSL("deviceFree")).toLongLong() > 0);
+ QVERIFY(dloc.value(qSL("deviceFree")).toLongLong() < dloc.value(qSL("deviceSize")).toLongLong());
+
m_startedSpy = new QSignalSpy(m_pm, &PackageManager::taskStarted);
m_requestingInstallationAcknowledgeSpy = new QSignalSpy(m_pm, &PackageManager::taskRequestingInstallationAcknowledge);
m_blockingUntilInstallationAcknowledgeSpy = new QSignalSpy(m_pm, &PackageManager::taskBlockingUntilInstallationAcknowledge);
@@ -344,46 +330,10 @@ void tst_PackageManager::cleanup()
recursiveOperation(pathTo(Internal0), safeRemove);
}
-void tst_PackageManager::installationLocations()
-{
- QVERIFY(!InstallationLocation().isValid());
-
- const QVector<InstallationLocation> loclist = m_pm->installationLocations();
-
- QCOMPARE(loclist.size(), m_installationLocations.size());
- for (const InstallationLocation &loc : loclist)
- QVERIFY(m_installationLocations.contains(loc));
-
- QVector<InstallationLocation> locationList = InstallationLocation::parseInstallationLocations(QVariantList {
- QVariantMap {
- { "id", "internal-0" },
- { "installationPath", QDir::tempPath() },
- { "documentPath", QDir::tempPath() },
- { "isDefault", true }
- },
- }, m_hardwareId);
- QCOMPARE(locationList.size(), 1);
- InstallationLocation &tmp = locationList.first();
- QVariantMap map = tmp.toVariantMap();
- QVERIFY(!map.isEmpty());
-
- QCOMPARE(map.value(qSL("id")).toString(), tmp.id());
- QCOMPARE(map.value(qSL("index")).toInt(), tmp.index());
- QCOMPARE(map.value(qSL("installationPath")).toString(), tmp.installationPath());
- QCOMPARE(map.value(qSL("documentPath")).toString(), tmp.documentPath());
- QCOMPARE(map.value(qSL("isDefault")).toBool(), tmp.isDefault());
- QVERIFY(map.value(qSL("installationDeviceSize")).toLongLong() > 0);
- QVERIFY(map.value(qSL("installationDeviceFree")).toLongLong() > 0);
- QVERIFY(map.value(qSL("documentDeviceSize")).toLongLong() > 0);
- QVERIFY(map.value(qSL("documentDeviceFree")).toLongLong() > 0);
-}
-
void tst_PackageManager::packageInstallation_data()
{
QTest::addColumn<QString>("packageName");
- QTest::addColumn<QString>("installationLocationId");
QTest::addColumn<QString>("updatePackageName");
- QTest::addColumn<QString>("updateInstallationLocationId");
QTest::addColumn<bool>("devSigned");
QTest::addColumn<bool>("storeSigned");
QTest::addColumn<bool>("expectedSuccess");
@@ -407,61 +357,55 @@ void tst_PackageManager::packageInstallation_data()
};
QTest::newRow("normal") \
- << "test.appkg" << "internal-0" << "test-update.appkg" << "internal-0"
+ << "test.appkg" << "test-update.appkg"
<< false << false << true << true << nomd<< "";
QTest::newRow("no-dev-signed") \
- << "test.appkg" << "internal-0" << "" << ""
+ << "test.appkg" << ""
<< true << false << false << false << nomd << "cannot install unsigned packages";
QTest::newRow("dev-signed") \
- << "test-dev-signed.appkg" << "internal-0" << "test-update-dev-signed.appkg" << "internal-0"
+ << "test-dev-signed.appkg" << "test-update-dev-signed.appkg"
<< true << false << true << true << nomd << "";
QTest::newRow("no-store-signed") \
- << "test.appkg" << "internal-0" << "" << ""
+ << "test.appkg" << ""
<< false << true << false << false << nomd << "cannot install unsigned packages";
QTest::newRow("no-store-but-dev-signed") \
- << "test-dev-signed.appkg" << "internal-0" << "" << ""
+ << "test-dev-signed.appkg" << ""
<< false << true << false << false << nomd << "cannot install development packages on consumer devices";
QTest::newRow("store-signed") \
- << "test-store-signed.appkg" << "internal-0" << "" << ""
+ << "test-store-signed.appkg" << ""
<< false << true << true << false << nomd << "";
QTest::newRow("extra-metadata") \
- << "test-extra.appkg" << "internal-0" << "" << ""
+ << "test-extra.appkg" << ""
<< false << false << true << false << extramd << "";
QTest::newRow("extra-metadata-dev-signed") \
- << "test-extra-dev-signed.appkg" << "internal-0" << "" << ""
+ << "test-extra-dev-signed.appkg" << ""
<< true << false << true << false << extramd << "";
- QTest::newRow("update-to-different-location") \
- << "test.appkg" << "internal-0" << "test-update.appkg" << "internal-1"
- << false << false << true << false << nomd << "the package com.pelagicore.test cannot be installed to internal-1, since it is already installed to internal-0";
- QTest::newRow("invalid-location") \
- << "test.appkg" << "internal-42" << "" << ""
- << false << false << false << false << nomd << "invalid installation location";
QTest::newRow("invalid-file-order") \
- << "test-invalid-file-order.appkg" << "internal-0" << "" << ""
+ << "test-invalid-file-order.appkg" << ""
<< false << false << false << false << nomd << "The package icon (as stated in info.yaml) must be the second file in the package. Expected 'icon.png', got 'test'";
QTest::newRow("invalid-header-format") \
- << "test-invalid-header-formatversion.appkg" << "internal-0" << "" << ""
+ << "test-invalid-header-formatversion.appkg" << ""
<< false << false << false << false << nomd << "metadata has an invalid format specification: wrong formatVersion header: expected 2, got 0";
QTest::newRow("invalid-header-diskspaceused") \
- << "test-invalid-header-diskspaceused.appkg" << "internal-0" << "" << ""
+ << "test-invalid-header-diskspaceused.appkg" << ""
<< false << false << false << false << nomd << "metadata has an invalid diskSpaceUsed field (0)";
QTest::newRow("invalid-header-id") \
- << "test-invalid-header-id.appkg" << "internal-0" << "" << ""
+ << "test-invalid-header-id.appkg" << ""
<< false << false << false << false << nomd << "metadata has an invalid packageId field (:invalid)";
QTest::newRow("non-matching-header-id") \
- << "test-non-matching-header-id.appkg" << "internal-0" << "" << ""
+ << "test-non-matching-header-id.appkg" << ""
<< false << false << false << false << nomd << "the package identifiers in --PACKAGE-HEADER--' and info.yaml do not match";
QTest::newRow("tampered-extra-signed-header") \
- << "test-tampered-extra-signed-header.appkg" << "internal-0" << "" << ""
+ << "test-tampered-extra-signed-header.appkg" << ""
<< false << false << false << false << nomd << "~package digest mismatch.*";
QTest::newRow("invalid-info.yaml") \
- << "test-invalid-info.appkg" << "internal-0" << "" << ""
+ << "test-invalid-info.appkg" << ""
<< false << false << false << false << nomd << "~.*YAML parse error at line \\d+, column \\d+: did not find expected key";
QTest::newRow("invalid-info.yaml-id") \
- << "test-invalid-info-id.appkg" << "internal-0" << "" << ""
+ << "test-invalid-info-id.appkg" << ""
<< false << false << false << false << nomd << "~.*the identifier \\(:invalid\\) is not a valid package-id: must consist of printable ASCII characters only, except any of .*";
QTest::newRow("invalid-footer-signature") \
- << "test-invalid-footer-signature.appkg" << "internal-0" << "" << ""
+ << "test-invalid-footer-signature.appkg" << ""
<< true << false << false << false << nomd << "could not verify the package's developer signature";
}
@@ -471,9 +415,7 @@ void tst_PackageManager::packageInstallation_data()
void tst_PackageManager::packageInstallation()
{
QFETCH(QString, packageName);
- QFETCH(QString, installationLocationId);
QFETCH(QString, updatePackageName);
- QFETCH(QString, updateInstallationLocationId);
QFETCH(bool, devSigned);
QFETCH(bool, storeSigned);
QFETCH(bool, expectedSuccess);
@@ -481,6 +423,9 @@ void tst_PackageManager::packageInstallation()
QFETCH(QVariantMap, extraMetaData);
QFETCH(QString, errorString);
+ QString installationDir = m_pm->installationLocation().value(qSL("path")).toString();
+ QString documentDir = m_pm->documentLocation().value(qSL("path")).toString();
+
AllowInstallations allow(storeSigned ? AllowInstallations::RequireStoreSigned
: (devSigned ? AllowInstallations::RequireDevSigned
: AllowInstallations::AllowUnsinged));
@@ -488,8 +433,6 @@ void tst_PackageManager::packageInstallation()
int lastPass = (updatePackageName.isEmpty() ? 1 : 2);
// pass 1 is the installation / pass 2 is the update (if needed)
for (int pass = 1; pass <= lastPass; ++pass) {
- const InstallationLocation &il = m_pm->installationLocationFromId(pass == 1 ? installationLocationId : updateInstallationLocationId);
-
// this makes the results a bit ugly to look at, but it helps with debugging a lot
if (pass > 1)
qInfo("Pass %d", pass);
@@ -497,7 +440,7 @@ void tst_PackageManager::packageInstallation()
// install (or update) the package
QUrl url = QUrl::fromLocalFile(AM_TESTDATA_DIR "packages/" + (pass == 1 ? packageName : updatePackageName));
- QString taskId = m_pm->startPackageInstallation(il.id(), url);
+ QString taskId = m_pm->startPackageInstallation(url);
QVERIFY(!taskId.isEmpty());
m_pm->acknowledgePackageInstallation(taskId);
@@ -523,10 +466,10 @@ void tst_PackageManager::packageInstallation()
//TODO: remove system((QString::fromUtf8("find ") + m_workDir.path()).toLocal8Bit().constData());
- QVERIFY(QFile::exists(il.installationPath() + qSL("com.pelagicore.test/.installation-report.yaml")));
- QVERIFY(QDir(pathTo(il.documentPath() + "/com.pelagicore.test")).exists());
+ QVERIFY(QFile::exists(installationDir + qSL("/com.pelagicore.test/.installation-report.yaml")));
+ QVERIFY(QDir(documentDir + qSL("/com.pelagicore.test")).exists());
- QString fileCheckPath = il.installationPath() + "/com.pelagicore.test";
+ QString fileCheckPath = installationDir + "/com.pelagicore.test";
// now check the installed files
@@ -577,7 +520,7 @@ void tst_PackageManager::packageInstallation()
}
// check that all files are gone
- for (PathLocation pl: { Internal0, Internal1, Documents0, Documents1 }) {
+ for (PathLocation pl: { Internal0, Documents0 }) {
QStringList entries = QDir(pathTo(pl)).entryList({ qSL("com.pelagicore.test*") });
QVERIFY2(entries.isEmpty(), qPrintable(pathTo(pl) + qSL(": ") + entries.join(qSL(", "))));
}
@@ -590,19 +533,18 @@ Q_DECLARE_METATYPE(FunctionMap)
void tst_PackageManager::simulateErrorConditions_data()
{
- QTest::addColumn<QString>("installationLocation");
QTest::addColumn<bool>("testUpdate");
QTest::addColumn<QString>("errorString");
QTest::addColumn<FunctionMap>("functions");
#ifdef Q_OS_LINUX
QTest::newRow("applications-dir-read-only") \
- << "internal-0" << false << "~could not create installation directory .*" \
+ << false << "~could not create installation directory .*" \
<< FunctionMap { { "before-start", [this]() { return chmod(pathTo(Internal0).toLocal8Bit(), 0000) == 0; } },
{ "after-failed", [this]() { return chmod(pathTo(Internal0).toLocal8Bit(), 0777) == 0; } } };
QTest::newRow("documents-dir-read-only") \
- << "internal-0" << false << "~could not create the document directory .*" \
+ << false << "~could not create the document directory .*" \
<< FunctionMap { { "before-start", [this]() { return chmod(pathTo(Documents0).toLocal8Bit(), 0000) == 0; } },
{ "after-failed", [this]() { return chmod(pathTo(Documents0).toLocal8Bit(), 0777) == 0; } } };
#endif
@@ -610,7 +552,6 @@ void tst_PackageManager::simulateErrorConditions_data()
void tst_PackageManager::simulateErrorConditions()
{
- QFETCH(QString, installationLocation);
QFETCH(bool, testUpdate);
QFETCH(QString, errorString);
QFETCH(FunctionMap, functions);
@@ -620,7 +561,7 @@ void tst_PackageManager::simulateErrorConditions()
if (testUpdate) {
// the check will run when updating a package, so we need to install it first
- taskId = m_pm->startPackageInstallation(installationLocation, QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
+ taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
QVERIFY(!taskId.isEmpty());
m_pm->acknowledgePackageInstallation(taskId);
QVERIFY(m_finishedSpy->wait(spyTimeout));
@@ -631,7 +572,7 @@ void tst_PackageManager::simulateErrorConditions()
foreach (const auto &f, functions.values(qSL("before-start")))
QVERIFY(f());
- taskId = m_pm->startPackageInstallation(installationLocation, QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
+ taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
foreach (const auto &f, functions.values(qSL("after-start")))
QVERIFY(f());
@@ -671,7 +612,7 @@ void tst_PackageManager::cancelPackageInstallation()
{
QFETCH(bool, expectedResult);
- QString taskId = m_pm->startPackageInstallation(qSL("internal-0"), QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
+ QString taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
QVERIFY(!taskId.isEmpty());
if (isDataTag("before-started-signal")) {
@@ -710,12 +651,12 @@ void tst_PackageManager::cancelPackageInstallation()
void tst_PackageManager::parallelPackageInstallation()
{
- QString task1Id = m_pm->startPackageInstallation(qSL("internal-0"), QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
+ QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg")));
QVERIFY(!task1Id.isEmpty());
QVERIFY(m_blockingUntilInstallationAcknowledgeSpy->wait(spyTimeout));
QCOMPARE(m_blockingUntilInstallationAcknowledgeSpy->first()[0].toString(), task1Id);
- QString task2Id = m_pm->startPackageInstallation(qSL("internal-0"), QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/bigtest-dev-signed.appkg")));
+ QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/bigtest-dev-signed.appkg")));
QVERIFY(!task2Id.isEmpty());
m_pm->acknowledgePackageInstallation(task2Id);
QVERIFY(m_finishedSpy->wait(spyTimeout));
diff --git a/tests/installationreport/tst_installationreport.cpp b/tests/installationreport/tst_installationreport.cpp
index 129cd355..74758e28 100644
--- a/tests/installationreport/tst_installationreport.cpp
+++ b/tests/installationreport/tst_installationreport.cpp
@@ -62,7 +62,6 @@ void tst_InstallationReport::test()
ir.setDigest("##digest##");
QVERIFY(ir.isValid());
ir.addFiles(files.mid(1));
- ir.setInstallationLocationId(qSL("test-42"));
ir.setDeveloperSignature("%%dev-sig%%");
ir.setStoreSignature("$$store-sig$$");
@@ -71,7 +70,6 @@ void tst_InstallationReport::test()
QCOMPARE(ir.files(), files);
QCOMPARE(ir.diskSpaceUsed(), 42ULL);
QCOMPARE(ir.digest().constData(), "##digest##");
- QCOMPARE(ir.installationLocationId(), qSL("test-42"));
QCOMPARE(ir.developerSignature().constData(), "%%dev-sig%%");
QCOMPARE(ir.storeSignature().constData(), "$$store-sig$$");
@@ -89,7 +87,6 @@ void tst_InstallationReport::test()
QCOMPARE(ir2.files(), files);
QCOMPARE(ir2.diskSpaceUsed(), 42ULL);
QCOMPARE(ir2.digest().constData(), "##digest##");
- QCOMPARE(ir2.installationLocationId(), qSL("test-42"));
QCOMPARE(ir2.developerSignature().constData(), "%%dev-sig%%");
QCOMPARE(ir2.storeSignature().constData(), "$$store-sig$$");
diff --git a/tests/main/am-config.yaml b/tests/main/am-config.yaml
index c29bb9c3..73e8bb2c 100644
--- a/tests/main/am-config.yaml
+++ b/tests/main/am-config.yaml
@@ -3,15 +3,9 @@ formatType: am-configuration
---
applications:
builtinAppsManifestDir: "${CONFIG_PWD}/builtin-apps"
- installedAppsManifestDir: "/tmp/am-test-main/manifests"
+ installationDir: "/tmp/am-test-main/apps"
+ documentDir: "/tmp/am-test-main/docs"
database: "/tmp/am-test-main/apps.db"
-installationLocations:
-- id: "internal-0"
- installationPath: "/tmp/am-test-main/apps"
- documentPath: "/tmp/am-test-main/docs"
- mountPoint: "/tmp"
- isDefault: true
-
ui:
mainQml: "${CONFIG_PWD}/dummy.qml"
diff --git a/tests/main/tst_main.cpp b/tests/main/tst_main.cpp
index 8630de6d..43add742 100644
--- a/tests/main/tst_main.cpp
+++ b/tests/main/tst_main.cpp
@@ -77,13 +77,11 @@ private:
tst_Main::tst_Main()
{
argc = 3;
- argv = new char*[3];
- argv[0] = new char[255];
- sprintf(argv[0], "tst_update-builtin-app");
- argv[1] = new char[255];
- sprintf(argv[1], "--dbus");
- argv[2] = new char[255];
- sprintf(argv[2], "none");
+ argv = new char*[argc + 1];
+ argv[0] = qstrdup("tst_update-builtin-app");
+ argv[1] = qstrdup("--dbus");
+ argv[2] = qstrdup("none");
+ argv[3] = nullptr;
}
tst_Main::~tst_Main()
@@ -188,9 +186,9 @@ void tst_Main::installPackage(const QString &pkgPath)
installationFinished = true;
});
- packageManager->startPackageInstallation(qSL("internal-0"), QUrl::fromLocalFile(pkgPath));
+ packageManager->startPackageInstallation(QUrl::fromLocalFile(pkgPath));
- QTRY_COMPARE(installationFinished, true);
+ QTRY_VERIFY(installationFinished);
}
void tst_Main::removePackage(const QString &id)
@@ -206,7 +204,7 @@ void tst_Main::removePackage(const QString &id)
packageManager->removePackage(id, false /* keepDocuments */);
- QTRY_COMPARE(removalFinished, true);
+ QTRY_VERIFY(removalFinished);
}
/*
diff --git a/tests/packager-tool/tst_packager-tool.cpp b/tests/packager-tool/tst_packager-tool.cpp
index 81465e63..3e47de3c 100644
--- a/tests/packager-tool/tst_packager-tool.cpp
+++ b/tests/packager-tool/tst_packager-tool.cpp
@@ -31,7 +31,6 @@
#include <QCoreApplication>
#include "global.h"
-#include "installationlocation.h"
#include "applicationmanager.h"
#include "application.h"
#include "qtyaml.h"
@@ -99,16 +98,9 @@ void tst_PackagerTool::initTestCase()
m_hardwareId = qSL("foobar");
- QVariantMap internalLocation {
- { "id", "internal-0" },
- { "installationPath", pathTo("internal-0") },
- { "documentPath", pathTo("documents-0") },
- };
- QVector<InstallationLocation> locations = InstallationLocation::parseInstallationLocations({ internalLocation }, m_hardwareId);
-
PackageDatabase *pdb = new PackageDatabase(pathTo("internal-0"));
try {
- m_pm = PackageManager::createInstance(pdb, locations);
+ m_pm = PackageManager::createInstance(pdb, pathTo("documents-0"));
m_pm->setHardwareId(m_hardwareId);
} catch (const Exception &e) {
QVERIFY2(false, e.what());
@@ -398,8 +390,7 @@ void tst_PackagerTool::installPackage(const QString &filePath)
m_pm->setDevelopmentMode(true); // allow packages without store signature
- QString taskId = m_pm->startPackageInstallation(qSL("internal-0"),
- QUrl::fromLocalFile(filePath));
+ QString taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(filePath));
m_pm->acknowledgePackageInstallation(taskId);
QVERIFY(finishedSpy.wait(2 * spyTimeout));