Move Volume::CommitTransactionHandler to top level
Also move constant definitions to Constants.h/cpp.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2013-2014, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
*/
|
||||
#ifndef COMMIT_TRANSACTION_HANDLER_H
|
||||
#define COMMIT_TRANSACTION_HANDLER_H
|
||||
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <Directory.h>
|
||||
|
||||
#include "FSTransaction.h"
|
||||
#include "FSUtils.h"
|
||||
#include "Volume.h"
|
||||
|
||||
|
||||
typedef std::set<std::string> StringSet;
|
||||
|
||||
|
||||
class CommitTransactionHandler {
|
||||
public:
|
||||
CommitTransactionHandler(Volume* volume,
|
||||
const PackageSet& packagesAlreadyAdded,
|
||||
const PackageSet& packagesAlreadyRemoved);
|
||||
~CommitTransactionHandler();
|
||||
|
||||
void HandleRequest(BMessage* request,
|
||||
BMessage* reply);
|
||||
void HandleRequest(
|
||||
const BActivationTransaction& transaction,
|
||||
BMessage* reply);
|
||||
void HandleRequest(const PackageSet& packagesAdded,
|
||||
const PackageSet& packagesRemoved);
|
||||
|
||||
void Revert();
|
||||
|
||||
const BString& OldStateDirectoryName() const
|
||||
{ return fOldStateDirectoryName; }
|
||||
|
||||
private:
|
||||
typedef BObjectList<Package> PackageList;
|
||||
typedef FSUtils::RelativePath RelativePath;
|
||||
|
||||
private:
|
||||
void _GetPackagesToDeactivate(
|
||||
const BActivationTransaction& transaction);
|
||||
void _ReadPackagesToActivate(
|
||||
const BActivationTransaction& transaction);
|
||||
void _ApplyChanges(BMessage* reply);
|
||||
void _CreateOldStateDirectory(BMessage* reply);
|
||||
void _RemovePackagesToDeactivate();
|
||||
void _AddPackagesToActivate();
|
||||
|
||||
void _PreparePackageToActivate(Package* package);
|
||||
void _AddGroup(Package* package,
|
||||
const BString& groupName);
|
||||
void _AddUser(Package* package, const BUser& user);
|
||||
void _AddGlobalWritableFiles(Package* package);
|
||||
void _AddGlobalWritableFile(Package* package,
|
||||
const BGlobalWritableFileInfo& file,
|
||||
const BDirectory& rootDirectory,
|
||||
const BDirectory& extractedFilesDirectory);
|
||||
void _AddGlobalWritableFileRecurse(Package* package,
|
||||
const BDirectory& sourceDirectory,
|
||||
FSUtils::Path& relativeSourcePath,
|
||||
const BDirectory& targetDirectory,
|
||||
const char* targetName,
|
||||
BWritableFileUpdateType updateType);
|
||||
|
||||
void _RevertAddPackagesToActivate();
|
||||
void _RevertRemovePackagesToDeactivate();
|
||||
void _RevertUserGroupChanges();
|
||||
|
||||
void _RunPostInstallScripts();
|
||||
void _RunPostInstallScript(Package* package,
|
||||
const BString& script);
|
||||
|
||||
static BString _GetPath(const FSUtils::Entry& entry,
|
||||
const BString& fallback);
|
||||
|
||||
void _ExtractPackageContent(Package* package,
|
||||
const BStringList& contentPaths,
|
||||
BDirectory& targetDirectory,
|
||||
BDirectory& _extractedFilesDirectory);
|
||||
|
||||
static status_t _TagPackageEntriesRecursively(
|
||||
BDirectory& directory, const BString& value,
|
||||
bool nonDirectoriesOnly);
|
||||
|
||||
private:
|
||||
Volume* fVolume;
|
||||
PackageList fPackagesToActivate;
|
||||
PackageSet fPackagesToDeactivate;
|
||||
PackageSet fAddedPackages;
|
||||
PackageSet fRemovedPackages;
|
||||
const PackageSet& fPackagesAlreadyAdded;
|
||||
const PackageSet& fPackagesAlreadyRemoved;
|
||||
BDirectory fOldStateDirectory;
|
||||
BString fOldStateDirectoryName;
|
||||
node_ref fTransactionDirectoryRef;
|
||||
BDirectory fWritableFilesDirectory;
|
||||
StringSet fAddedGroups;
|
||||
StringSet fAddedUsers;
|
||||
FSTransaction fFSTransaction;
|
||||
};
|
||||
|
||||
|
||||
#endif // COMMIT_TRANSACTION_HANDLER_H
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
#include <package/PackagesDirectoryDefs.h>
|
||||
|
||||
|
||||
const char* const kPackageFileNameExtension = ".hpkg";
|
||||
const char* const kAdminDirectoryName = PACKAGES_DIRECTORY_ADMIN_DIRECTORY;
|
||||
const char* const kActivationFileName = PACKAGES_DIRECTORY_ACTIVATION_FILE;
|
||||
const char* const kTemporaryActivationFileName
|
||||
= PACKAGES_DIRECTORY_ACTIVATION_FILE ".tmp";
|
||||
const char* const kWritableFilesDirectoryName = "writable-files";
|
||||
const char* const kPackageFileAttribute = "SYS:PACKAGE";
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2014, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CONSTANTS_H
|
||||
#define CONSTANTS_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
extern const char* const kPackageFileNameExtension;
|
||||
extern const char* const kAdminDirectoryName;
|
||||
extern const char* const kActivationFileName;
|
||||
extern const char* const kTemporaryActivationFileName;
|
||||
extern const char* const kWritableFilesDirectoryName;
|
||||
extern const char* const kPackageFileAttribute;
|
||||
|
||||
static const bigtime_t kHandleNodeMonitorEvents = 'nmon';
|
||||
|
||||
static const bigtime_t kNodeMonitorEventHandlingDelay = 500000;
|
||||
static const bigtime_t kCommunicationTimeout = 1000000;
|
||||
|
||||
|
||||
#endif // CONSTANTS_H
|
||||
@@ -5,6 +5,8 @@ UsePrivateHeaders app interface kernel shared storage ;
|
||||
|
||||
Server package_daemon
|
||||
:
|
||||
CommitTransactionHandler.cpp
|
||||
Constants.cpp
|
||||
DebugSupport.cpp
|
||||
Exception.cpp
|
||||
FSTransaction.cpp
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <package/DaemonDefs.h>
|
||||
#include <package/manager/Exceptions.h>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "DebugSupport.h"
|
||||
#include "PackageManager.h"
|
||||
|
||||
@@ -30,9 +31,6 @@ using namespace BPackageKit::BPrivate;
|
||||
using namespace BPackageKit::BManager::BPrivate;
|
||||
|
||||
|
||||
static const bigtime_t kCommunicationTimeout = 1000000;
|
||||
|
||||
|
||||
// #pragma mark - AbstractVolumeJob
|
||||
|
||||
|
||||
|
||||
+2
-1251
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,7 @@ using BPackageKit::BPrivate::BDaemonClient;
|
||||
|
||||
class BDirectory;
|
||||
|
||||
class CommitTransactionHandler;
|
||||
class Root;
|
||||
class VolumeState;
|
||||
|
||||
@@ -138,9 +139,8 @@ public:
|
||||
|
||||
private:
|
||||
struct NodeMonitorEvent;
|
||||
struct CommitTransactionHandler;
|
||||
|
||||
friend struct CommitTransactionHandler;
|
||||
friend class CommitTransactionHandler;
|
||||
|
||||
typedef FSUtils::RelativePath RelativePath;
|
||||
typedef DoublyLinkedList<NodeMonitorEvent> NodeMonitorEventList;
|
||||
|
||||
Reference in New Issue
Block a user