CPackWiX: Extend CPACK_WIX_ACL to support directories

This commit is contained in:
Nils Gladitz 2014-09-27 17:34:39 +02:00
parent 58dc05de9e
commit d48c781fc2
6 changed files with 49 additions and 6 deletions

View File

@ -1,7 +1,8 @@
CPACK_WIX_ACL
-------------
Specifies access permissions for files installed by a WiX installer.
Specifies access permissions for files or directories
installed by a WiX installer.
The property can contain multiple list entries,
each of which has to match the following format.

View File

@ -847,13 +847,37 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
cmsys::Directory dir;
dir.Load(topdir.c_str());
if(dir.GetNumberOfFiles() == 2)
std::string relativeDirectoryPath =
cmSystemTools::RelativePath(toplevel.c_str(), topdir.c_str());
cmInstalledFile const* directoryInstalledFile =
this->GetInstalledFile(relativeDirectoryPath);
bool emptyDirectory = dir.GetNumberOfFiles() == 2;
bool createDirectory = false;
if(emptyDirectory)
{
createDirectory = true;
}
if(directoryInstalledFile)
{
if(directoryInstalledFile->HasProperty("CPACK_WIX_ACL"))
{
createDirectory = true;
}
}
if(createDirectory)
{
std::string componentId = fileDefinitions.EmitComponentCreateFolder(
directoryId, GenerateGUID());
directoryId, GenerateGUID(), directoryInstalledFile);
featureDefinitions.EmitComponentRef(componentId);
}
if(emptyDirectory)
{
return;
}

View File

@ -113,7 +113,9 @@ void cmWIXFilesSourceWriter::EmitUninstallShortcut(
}
std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
std::string const& directoryId, std::string const& guid)
std::string const& directoryId,
std::string const& guid,
cmInstalledFile const* installedFile)
{
std::string componentId =
std::string("CM_C_EMPTY_") + directoryId;
@ -127,6 +129,12 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
BeginElement("CreateFolder");
if(installedFile)
{
cmWIXAccessControlList acl(Logger, *installedFile, *this);
acl.Apply();
}
EndElement("CreateFolder");
EndElement("Component");
EndElement("DirectoryRef");

View File

@ -47,7 +47,8 @@ public:
std::string EmitComponentCreateFolder(
std::string const& directoryId,
std::string const& guid);
std::string const& guid,
cmInstalledFile const* installedFile);
std::string EmitComponentFile(
std::string const& directoryId,

View File

@ -76,6 +76,13 @@ void cmInstalledFile::AppendProperty(cmMakefile const* mf,
property.ValueExpressions.push_back(ge.Parse(value).release());
}
//----------------------------------------------------------------------------
bool cmInstalledFile::HasProperty(
const std::string& prop) const
{
return this->Properties.find(prop) != this->Properties.end();
}
//----------------------------------------------------------------------------
bool cmInstalledFile::GetProperty(
const std::string& prop, std::string& value) const

View File

@ -62,6 +62,8 @@ public:
void AppendProperty(cmMakefile const* mf,
const std::string& prop, const char* value,bool asString=false);
bool HasProperty(const std::string& prop) const;
bool GetProperty(const std::string& prop, std::string& value) const;
bool GetPropertyAsBool(const std::string& prop) const;