[Cmake-commits] [cmake-commits] hoffman committed cmCPackComponentGroup.h 1.1.2.2 1.1.2.3 cmCPackGenerator.cxx 1.6.2.1 1.6.2.2 cmCPackNSISGenerator.cxx 1.31.2.1 1.31.2.2 cmCPackNSISGenerator.h 1.11.2.1 1.11.2.2 cmCPackPackageMakerGenerator.cxx 1.23.2.1 1.23.2.2 cmCPackPackageMakerGenerator.h 1.12.2.1 1.12.2.2
cmake-commits at cmake.org
cmake-commits at cmake.org
Sun Jul 13 17:55:28 EDT 2008
Update of /cvsroot/CMake/CMake/Source/CPack
In directory public:/mounts/ram/cvs-serv32502/Source/CPack
Modified Files:
Tag: CMake-2-6
cmCPackComponentGroup.h cmCPackGenerator.cxx
cmCPackNSISGenerator.cxx cmCPackNSISGenerator.h
cmCPackPackageMakerGenerator.cxx
cmCPackPackageMakerGenerator.h
Log Message:
ENH: Merge from head create RC7
Index: cmCPackGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackGenerator.cxx,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -C 2 -d -r1.6.2.1 -r1.6.2.2
*** cmCPackGenerator.cxx 25 Jun 2008 13:51:38 -0000 1.6.2.1
--- cmCPackGenerator.cxx 13 Jul 2008 21:55:24 -0000 1.6.2.2
***************
*** 654,657 ****
--- 654,665 ----
mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
+ if ( !cmsys::SystemTools::MakeDirectory(dir.c_str()))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: "
+ << dir << std::endl);
+ return 0;
+ }
+
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)"
***************
*** 665,668 ****
--- 673,684 ----
mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
+ if ( !cmsys::SystemTools::MakeDirectory(tempInstallDirectory.c_str()))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: "
+ << tempInstallDirectory << std::endl);
+ return 0;
+ }
+
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Using non-DESTDIR install... (mf->AddDefinition)" << std::endl);
***************
*** 1256,1259 ****
--- 1272,1285 ----
component->IsDisabledByDefault
= this->IsSet((macroPrefix + "_DISABLED").c_str());
+ component->IsDownloaded
+ = this->IsSet((macroPrefix + "_DOWNLOADED").c_str())
+ || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
+
+ const char* archiveFile = this->GetOption((macroPrefix + "_ARCHIVE_FILE").c_str());
+ if (archiveFile && *archiveFile)
+ {
+ component->ArchiveFile = archiveFile;
+ }
+
const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str());
if (groupName && *groupName)
***************
*** 1345,1348 ****
--- 1371,1385 ----
group->IsExpandedByDefault
= this->IsSet((macroPrefix + "_EXPANDED").c_str());
+ const char* parentGroupName
+ = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str());
+ if (parentGroupName && *parentGroupName)
+ {
+ group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
+ group->ParentGroup->Subgroups.push_back(group);
+ }
+ else
+ {
+ group->ParentGroup = 0;
+ }
}
return group;
Index: cmCPackComponentGroup.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackComponentGroup.h,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C 2 -d -r1.1.2.2 -r1.1.2.3
*** cmCPackComponentGroup.h 25 Jun 2008 13:51:38 -0000 1.1.2.2
--- cmCPackComponentGroup.h 13 Jul 2008 21:55:24 -0000 1.1.2.3
***************
*** 19,25 ****
#define cmCPackComponentGroup_h
! #include <map>
! #include <string>
! #include <vector>
class cmCPackComponentGroup;
--- 19,23 ----
#define cmCPackComponentGroup_h
! #include "cmStandardIncludes.h"
class cmCPackComponentGroup;
***************
*** 50,54 ****
{
public:
! cmCPackComponent() : Group(0) { }
/// The name of the component (used to reference the component).
--- 48,52 ----
{
public:
! cmCPackComponent() : Group(0), TotalSize(0) { }
/// The name of the component (used to reference the component).
***************
*** 71,74 ****
--- 69,76 ----
bool IsDisabledByDefault : 1;
+ /// Whether this component should be downloaded on-the-fly. If false,
+ /// the component will be a part of the installation package.
+ bool IsDownloaded : 1;
+
/// A description of this component.
std::string Description;
***************
*** 77,80 ****
--- 79,86 ----
std::vector<cmCPackInstallationType *> InstallationTypes;
+ /// If IsDownloaded is true, the name of the archive file that
+ /// contains the files that are part of this component.
+ std::string ArchiveFile;
+
/// The components that this component depends on.
std::vector<cmCPackComponent *> Dependencies;
***************
*** 88,91 ****
--- 94,109 ----
/// The list of installed directories that are part of this component.
std::vector<std::string> Directories;
+
+ /// Get the total installed size of all of the files in this
+ /// component, in bytes. installDir is the directory into which the
+ /// component was installed.
+ unsigned long GetInstalledSize(const char* installDir) const;
+
+ /// Identical to GetInstalledSize, but returns the result in
+ /// kilobytes.
+ unsigned long GetInstalledSizeInKbytes(const char* installDir) const;
+
+ private:
+ mutable unsigned long TotalSize;
};
***************
*** 96,99 ****
--- 114,119 ----
{
public:
+ cmCPackComponentGroup() : ParentGroup(0) { }
+
/// The name of the group (used to reference the group).
std::string Name;
***************
*** 113,116 ****
--- 133,142 ----
/// The components within this group.
std::vector<cmCPackComponent*> Components;
+
+ /// The parent group of this component group (if any).
+ cmCPackComponentGroup *ParentGroup;
+
+ /// The subgroups of this group.
+ std::vector<cmCPackComponentGroup*> Subgroups;
};
Index: cmCPackNSISGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackNSISGenerator.h,v
retrieving revision 1.11.2.1
retrieving revision 1.11.2.2
diff -C 2 -d -r1.11.2.1 -r1.11.2.2
*** cmCPackNSISGenerator.h 25 Jun 2008 13:51:39 -0000 1.11.2.1
--- cmCPackNSISGenerator.h 13 Jul 2008 21:55:24 -0000 1.11.2.2
***************
*** 54,59 ****
/// Produce a string that contains the NSIS code to describe a
! /// particular component.
! std::string CreateComponentDescription(cmCPackComponent *component) const;
/// Produce NSIS code that selects all of the components that this component
--- 54,62 ----
/// Produce a string that contains the NSIS code to describe a
! /// particular component. Any added macros will be emitted via
! /// macrosOut.
! std::string
! CreateComponentDescription(cmCPackComponent *component,
! cmOStringStream& macrosOut);
/// Produce NSIS code that selects all of the components that this component
***************
*** 61,65 ****
std::string CreateSelectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited) const;
/// Produce NSIS code that de-selects all of the components that are dependent
--- 64,68 ----
std::string CreateSelectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited);
/// Produce NSIS code that de-selects all of the components that are dependent
***************
*** 67,75 ****
std::string CreateDeselectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited) const;
/// Produce a string that contains the NSIS code to describe a
! /// particular component group, including its components.
! std::string CreateComponentGroupDescription(cmCPackComponentGroup *group) const;
/// Translations any newlines found in the string into \r\n, so that the
--- 70,81 ----
std::string CreateDeselectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited);
/// Produce a string that contains the NSIS code to describe a
! /// particular component group, including its components. Any
! /// added macros will be emitted via macrosOut.
! std::string
! CreateComponentGroupDescription(cmCPackComponentGroup *group,
! cmOStringStream& macrosOut);
/// Translations any newlines found in the string into \r\n, so that the
Index: cmCPackPackageMakerGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackPackageMakerGenerator.cxx,v
retrieving revision 1.23.2.1
retrieving revision 1.23.2.2
diff -C 2 -d -r1.23.2.1 -r1.23.2.2
*** cmCPackPackageMakerGenerator.cxx 25 Jun 2008 13:51:40 -0000 1.23.2.1
--- cmCPackPackageMakerGenerator.cxx 13 Jul 2008 21:55:24 -0000 1.23.2.2
***************
*** 33,36 ****
--- 33,37 ----
{
this->PackageMakerVersion = 0.0;
+ this->PackageCompatibilityVersion = 10.4;
}
***************
*** 43,47 ****
bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
{
! return true;
}
--- 44,48 ----
bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
{
! return this->PackageCompatibilityVersion >= 10.4;
}
***************
*** 166,170 ****
if (!this->Components.empty())
{
! // Create the directory where component packages will be installed.
std::string basePackageDir = packageDirFileName;
basePackageDir += "/Contents/Packages";
--- 167,171 ----
if (!this->Components.empty())
{
! // Create the directory where component packages will be built.
std::string basePackageDir = packageDirFileName;
basePackageDir += "/Contents/Packages";
***************
*** 177,186 ****
}
// Create packages for each component
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt)
{
! std::string packageFile = basePackageDir;
packageFile += '/';
packageFile += GetPackageName(compIt->second);
--- 178,253 ----
}
+ // Create the directory where downloaded component packages will
+ // be placed.
+ const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY");
+ std::string uploadDirectory;
+ if (userUploadDirectory && *userUploadDirectory)
+ {
+ uploadDirectory = userUploadDirectory;
+ }
+ else
+ {
+ uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY");
+ uploadDirectory += "/CPackUploads";
+ }
+
// Create packages for each component
+ bool warnedAboutDownloadCompatibility = false;
+
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt)
{
! std::string packageFile;
! if (compIt->second.IsDownloaded)
! {
! if (this->PackageCompatibilityVersion >= 10.5 &&
! this->PackageMakerVersion >= 3.0)
! {
! // Build this package within the upload directory.
! packageFile = uploadDirectory;
!
! if(!cmSystemTools::FileExists(uploadDirectory.c_str()))
! {
! if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Unable to create package upload directory "
! << uploadDirectory << std::endl);
! return 0;
! }
! }
! }
! else if (!warnedAboutDownloadCompatibility)
! {
! if (this->PackageCompatibilityVersion < 10.5)
! {
! cmCPackLogger(cmCPackLog::LOG_WARNING,
! "CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 or greater enable downloaded packages. CPack will build a non-downloaded package."
! << std::endl);
! }
!
! if (this->PackageMakerVersion < 3)
! {
! cmCPackLogger(cmCPackLog::LOG_WARNING,
! "CPack warning: unable to build downloaded packages with PackageMaker versions prior to 3.0. CPack will build a non-downloaded package."
! << std::endl);
! }
!
! warnedAboutDownloadCompatibility = true;
! }
! }
!
! if (packageFile.empty())
! {
! // Build this package within the overall distribution
! // metapackage.
! packageFile = basePackageDir;
!
! // We're not downloading this component, even if the user
! // requested it.
! compIt->second.IsDownloaded = false;
! }
!
packageFile += '/';
packageFile += GetPackageName(compIt->second);
***************
*** 230,234 ****
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Info.plist\" -d \""
! << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Description.plist\"";
if ( this->PackageMakerVersion > 2.0 )
--- 297,301 ----
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Info.plist\" -d \""
! << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Description.plist\"";
if ( this->PackageMakerVersion > 2.0 )
***************
*** 340,343 ****
--- 407,434 ----
<< this->PackageMakerVersion << std::endl);
+ // Determine the package compatibility version. If it wasn't
+ // specified by the user, we define it based on which features the
+ // user requested.
+ const char *packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
+ if (packageCompat && *packageCompat)
+ {
+ this->PackageCompatibilityVersion = atof(packageCompat);
+ }
+ else if (this->GetOption("CPACK_DOWNLOAD_SITE"))
+ {
+ this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5");
+ this->PackageCompatibilityVersion = 10.5;
+ }
+ else if (this->GetOption("CPACK_COMPONENTS_ALL"))
+ {
+ this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4");
+ this->PackageCompatibilityVersion = 10.4;
+ }
+ else
+ {
+ this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3");
+ this->PackageCompatibilityVersion = 10.3;
+ }
+
pkgPath += "/MacOS";
path.push_back(pkgPath);
***************
*** 492,501 ****
cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component)
{
! std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! packagesDir += ".dummy";
! cmOStringStream out;
! out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
! << "-" << component.Name << ".pkg";
! return out.str();
}
--- 583,599 ----
cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component)
{
! if (component.ArchiveFile.empty())
! {
! std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! packagesDir += ".dummy";
! cmOStringStream out;
! out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
! << "-" << component.Name << ".pkg";
! return out.str();
! }
! else
! {
! return component.ArchiveFile + ".pkg";
! }
}
***************
*** 510,553 ****
"- Building component package: " << packageFile << std::endl);
! // Create the description file for this component.
! std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
! descriptionFile += '/' + component.Name + "-Description.plist";
! std::ofstream out(descriptionFile.c_str());
! out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
! << "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
! << "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" << std::endl
! << "<plist version=\"1.4\">" << std::endl
! << "<dict>" << std::endl
! << " <key>IFPkgDescriptionTitle</key>" << std::endl
! << " <string>" << component.DisplayName << "</string>" << std::endl
! << " <key>IFPkgDescriptionVersion</key>" << std::endl
! << " <string>" << this->GetOption("CPACK_PACKAGE_VERSION")
! << "</string>" << std::endl
! << " <key>IFPkgDescriptionDescription</key>" << std::endl
! << " <string>" + this->EscapeForXML(component.Description)
! << "</string>" << std::endl
! << "</dict>" << std::endl
! << "</plist>" << std::endl;
! out.close();
! // Create the Info.plist file for this component
! std::string moduleVersionSuffix = ".";
! moduleVersionSuffix += component.Name;
! this->SetOption("CPACK_MODULE_VERSION_SUFFIX", moduleVersionSuffix.c_str());
! std::string infoFileName = component.Name;
! infoFileName += "-Info.plist";
! if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str()))
{
! return false;
}
// Run PackageMaker
- cmOStringStream pkgCmd;
- pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
- << "\" -build -p \"" << packageFile << "\""
- << " -f \"" << packageDir << "\""
- << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
- << "/" << infoFileName << "\""
- << " -d \"" << descriptionFile << "\"";
return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
}
--- 608,679 ----
"- Building component package: " << packageFile << std::endl);
! // The command that will be used to run PackageMaker
! cmOStringStream pkgCmd;
! if (this->PackageCompatibilityVersion < 10.5 ||
! this->PackageMakerVersion < 3.0)
{
! // Create Description.plist and Info.plist files for normal Mac OS
! // X packages, which work on Mac OS X 10.3 and newer.
! std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
! descriptionFile += '/' + component.Name + "-Description.plist";
! std::ofstream out(descriptionFile.c_str());
! out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
! << "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
! << "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" << std::endl
! << "<plist version=\"1.4\">" << std::endl
! << "<dict>" << std::endl
! << " <key>IFPkgDescriptionTitle</key>" << std::endl
! << " <string>" << component.DisplayName << "</string>" << std::endl
! << " <key>IFPkgDescriptionVersion</key>" << std::endl
! << " <string>" << this->GetOption("CPACK_PACKAGE_VERSION")
! << "</string>" << std::endl
! << " <key>IFPkgDescriptionDescription</key>" << std::endl
! << " <string>" + this->EscapeForXML(component.Description)
! << "</string>" << std::endl
! << "</dict>" << std::endl
! << "</plist>" << std::endl;
! out.close();
!
! // Create the Info.plist file for this component
! std::string moduleVersionSuffix = ".";
! moduleVersionSuffix += component.Name;
! this->SetOption("CPACK_MODULE_VERSION_SUFFIX", moduleVersionSuffix.c_str());
! std::string infoFileName = component.Name;
! infoFileName += "-Info.plist";
! if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str()))
! {
! return false;
! }
!
! pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
! << "\" -build -p \"" << packageFile << "\""
! << " -f \"" << packageDir << "\""
! << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
! << "/" << infoFileName << "\""
! << " -d \"" << descriptionFile << "\"";
! }
! else
! {
! // Create a "flat" package on Mac OS X 10.5 and newer. Flat
! // packages are stored in a single file, rather than a directory
! // like normal packages, and can be downloaded by the installer
! // on-the-fly in Mac OS X 10.5 or newer. Thus, we need to create
! // flat packages when the packages will be downloaded on the fly.
! std::string pkgId = "com.";
! pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
! pkgId += '.';
! pkgId += this->GetOption("CPACK_PACKAGE_NAME");
! pkgId += '.';
! pkgId += component.Name;
!
! pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
! << "\" --root \"" << packageDir << "\""
! << " --id " << pkgId
! << " --target " << this->GetOption("CPACK_OSX_PACKAGE_VERSION")
! << " --out \"" << packageFile << "\"";
}
// Run PackageMaker
return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
}
***************
*** 581,585 ****
++groupIt)
{
! CreateChoiceOutline(groupIt->second, choiceOut);
}
--- 707,714 ----
++groupIt)
{
! if (groupIt->second.ParentGroup == 0)
! {
! CreateChoiceOutline(groupIt->second, choiceOut);
! }
}
***************
*** 623,626 ****
--- 752,762 ----
{
out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
+ std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
+ for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
+ ++groupIt)
+ {
+ CreateChoiceOutline(**groupIt, out);
+ }
+
std::vector<cmCPackComponent*>::const_iterator compIt;
for (compIt = group.Components.begin(); compIt != group.Components.end();
***************
*** 661,666 ****
packageId += this->GetOption("CPACK_PACKAGE_NAME");
packageId += '.';
- packageId += this->GetOption("CPACK_PACKAGE_VERSION");
- packageId += '.';
packageId += component.Name;
--- 797,800 ----
***************
*** 707,764 ****
// component.
std::string relativePackageLocation = "Contents/Packages/";
! relativePackageLocation += GetPackageName(component);
! // Determine the installed size of the package. To do so, we dig
! // into the Info.plist file from the generated package to retrieve
! // this size.
! int installedSize = 0;
! std::string infoPlistFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! infoPlistFile += ".mpkg/";
! infoPlistFile += relativePackageLocation;
! infoPlistFile += "/Contents/Info.plist";
! bool foundFlagInstalledSize = false;
! std::string line;
! std::ifstream ifs(infoPlistFile.c_str());
! while ( cmSystemTools::GetLineFromStream(ifs, line) )
! {
! if (foundFlagInstalledSize)
! {
! std::string::size_type pos = line.find("<integer>");
! if (pos == std::string::npos)
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot parse package size in "
! << infoPlistFile << std::endl
! << "String is \"" << line << "\"" << std::endl);
! }
! else
! {
! line.erase(0, pos + 9);
! pos = line.find("</integer>");
! if (pos == std::string::npos)
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot parse package size in "
! << infoPlistFile << std::endl);
! }
! else
! {
! line.erase(pos, std::string::npos);
! installedSize = atoi(line.c_str());
! }
! }
! foundFlagInstalledSize = false;
! }
! else
! {
! foundFlagInstalledSize
! = line.find("IFPkgFlagInstalledSize") != std::string::npos;
! }
! }
!
out << "<pkg-ref id=\"" << packageId << "\" "
<< "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
<< "installKBytes=\"" << installedSize << "\" "
! << "auth=\"Admin\" onConclusion=\"None\">"
! << "file:./" << relativePackageLocation << "</pkg-ref>" << std::endl;
}
--- 841,867 ----
// component.
std::string relativePackageLocation = "Contents/Packages/";
! relativePackageLocation += this->GetPackageName(component);
! // Determine the installed size of the package.
! std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! dirName += '/';
! dirName += component.Name;
! unsigned long installedSize
! = component.GetInstalledSizeInKbytes(dirName.c_str());
out << "<pkg-ref id=\"" << packageId << "\" "
<< "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
<< "installKBytes=\"" << installedSize << "\" "
! << "auth=\"Admin\" onConclusion=\"None\">";
! if (component.IsDownloaded)
! {
! out << this->GetOption("CPACK_DOWNLOAD_SITE")
! << this->GetPackageName(component);
! }
! else
! {
! out << "file:./" << relativePackageLocation;
! }
! out << "</pkg-ref>" << std::endl;
}
Index: cmCPackPackageMakerGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackPackageMakerGenerator.h,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -C 2 -d -r1.12.2.1 -r1.12.2.2
*** cmCPackPackageMakerGenerator.h 25 Jun 2008 13:51:40 -0000 1.12.2.1
--- cmCPackPackageMakerGenerator.h 13 Jul 2008 21:55:24 -0000 1.12.2.2
***************
*** 117,120 ****
--- 117,121 ----
double PackageMakerVersion;
+ double PackageCompatibilityVersion;
};
Index: cmCPackNSISGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackNSISGenerator.cxx,v
retrieving revision 1.31.2.1
retrieving revision 1.31.2.2
diff -C 2 -d -r1.31.2.1 -r1.31.2.2
*** cmCPackNSISGenerator.cxx 25 Jun 2008 13:51:39 -0000 1.31.2.1
--- cmCPackNSISGenerator.cxx 13 Jul 2008 21:55:24 -0000 1.31.2.2
***************
*** 174,177 ****
--- 174,180 ----
std::string groupDescriptions;
std::string installTypesCode;
+ std::string defines;
+ cmOStringStream macrosOut;
+ bool anyDownloadedComponents = false;
// Create installation types. The order is significant, so we first fill
***************
*** 202,206 ****
++groupIt)
{
! componentCode += this->CreateComponentGroupDescription(&groupIt->second);
// Add the group description, if any.
--- 205,213 ----
++groupIt)
{
! if (groupIt->second.ParentGroup == 0)
! {
! componentCode +=
! this->CreateComponentGroupDescription(&groupIt->second, macrosOut);
! }
// Add the group description, if any.
***************
*** 219,225 ****
++compIt)
{
if (!compIt->second.Group)
{
! componentCode += this->CreateComponentDescription(&compIt->second);
}
--- 226,242 ----
++compIt)
{
+ if (compIt->second.Files.empty())
+ {
+ // NSIS cannot cope with components that have no files.
+ continue;
+ }
+
+ anyDownloadedComponents =
+ anyDownloadedComponents || compIt->second.IsDownloaded;
+
if (!compIt->second.Group)
{
! componentCode
! += this->CreateComponentDescription(&compIt->second, macrosOut);
}
***************
*** 229,232 ****
--- 246,250 ----
sectionList += "\"\n";
selectedVarsList += "Var " + compIt->first + "_selected\n";
+ selectedVarsList += "Var " + compIt->first + "_was_installed\n";
// Add the component description, if any.
***************
*** 239,242 ****
--- 257,262 ----
}
+ componentCode += macrosOut.str();
+
if (componentDescriptions.empty() && groupDescriptions.empty())
{
***************
*** 255,258 ****
--- 275,288 ----
componentDescriptions.c_str());
}
+
+ if (anyDownloadedComponents)
+ {
+ defines += "!define CPACK_USES_DOWNLOAD\n";
+ if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE")))
+ {
+ defines += "!define CPACK_NSIS_ADD_REMOVE\n";
+ }
+ }
+
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", installTypesCode.c_str());
this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", "!insertmacro MUI_PAGE_COMPONENTS");
***************
*** 261,264 ****
--- 291,295 ----
this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", sectionList.c_str());
this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", selectedVarsList.c_str());
+ this->SetOption("CPACK_NSIS_DEFINES", defines.c_str());
}
***************
*** 560,564 ****
std::string
cmCPackNSISGenerator::
! CreateComponentDescription(cmCPackComponent *component) const
{
// Basic description of the component
--- 591,595 ----
std::string
cmCPackNSISGenerator::
! CreateComponentDescription(cmCPackComponent *component, cmOStringStream& macrosOut)
{
// Basic description of the component
***************
*** 591,599 ****
}
componentCode += " SetOutPath \"$INSTDIR\"\n";
! componentCode += " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n";
componentCode += "SectionEnd\n";
// Macro used to remove the component
! componentCode += "!macro Remove_${" + component->Name + "}\n";
std::vector<std::string>::iterator pathIt;
for (pathIt = component->Files.begin();
--- 622,783 ----
}
componentCode += " SetOutPath \"$INSTDIR\"\n";
!
! componentCode += " IntCmp $" + component->Name
! + "_was_installed ${SF_SELECTED} noinstall_" + component->Name + "\n";
!
! // Create the actual installation commands
! if (component->IsDownloaded)
! {
! if (component->ArchiveFile.empty())
! {
! // Compute the name of the archive.
! std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! packagesDir += ".dummy";
! cmOStringStream out;
! out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
! << "-" << component->Name << ".zip";
! component->ArchiveFile = out.str();
! }
!
! // Create the directory for the upload area
! const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY");
! std::string uploadDirectory;
! if (userUploadDirectory && *userUploadDirectory)
! {
! uploadDirectory = userUploadDirectory;
! }
! else
! {
! uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY");
! uploadDirectory += "/CPackUploads";
! }
! if(!cmSystemTools::FileExists(uploadDirectory.c_str()))
! {
! if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Unable to create NSIS upload directory " << uploadDirectory
! << std::endl);
! return "";
! }
! }
!
! // Remove the old archive, if one exists
! std::string archiveFile = uploadDirectory + '/' + component->ArchiveFile;
! cmCPackLogger(cmCPackLog::LOG_OUTPUT,
! "- Building downloaded component archive: "
! << archiveFile << std::endl);
! if (cmSystemTools::FileExists(archiveFile.c_str(), true))
! {
! if (!cmSystemTools::RemoveFile(archiveFile.c_str()))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Unable to remove archive file " << archiveFile
! << std::endl);
! return "";
! }
! }
!
! // Find a ZIP program
! if (!this->IsSet("ZIP_EXECUTABLE"))
! {
! this->ReadListFile("CPackZIP.cmake");
!
! if (!this->IsSet("ZIP_EXECUTABLE"))
! {
! cmCPackLogger(cmCPackLog::LOG_ERROR,
! "Unable to find ZIP program"
! << std::endl);
! return "";
! }
! }
!
! // The directory where this component's files reside
! std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! dirName += '/';
! dirName += component->Name;
! dirName += '/';
!
! // Build the list of files to go into this archive, and determine the
! // size of the installed component.
! std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
! zipListFileName += "/winZip.filelist";
! bool needQuotesInFile
! = cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
! unsigned long totalSize = 0;
! { // the scope is needed for cmGeneratedFileStream
! cmGeneratedFileStream out(zipListFileName.c_str());
! std::vector<std::string>::iterator fileIt;
! for (fileIt = component->Files.begin();
! fileIt != component->Files.end();
! ++fileIt)
! {
! if ( needQuotesInFile )
! {
! out << "\"";
! }
! out << *fileIt;
! if ( needQuotesInFile )
! {
! out << "\"";
! }
! out << std::endl;
!
! totalSize += cmSystemTools::FileLength((dirName + *fileIt).c_str());
! }
! }
!
! // Build the archive in the upload area
! std::string cmd = this->GetOption("CPACK_ZIP_COMMAND");
! cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", archiveFile.c_str());
! cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>",
! zipListFileName.c_str());
! std::string output;
! int retVal = -1;
! int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retVal,
! dirName.c_str(), false, 0);
! if ( !res || retVal )
! {
! std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
! tmpFile += "/CompressZip.log";
! cmGeneratedFileStream ofs(tmpFile.c_str());
! ofs << "# Run command: " << cmd.c_str() << std::endl
! << "# Output:" << std::endl
! << output.c_str() << std::endl;
! cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
! << cmd.c_str() << std::endl
! << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
! return "";
! }
!
! // Create the NSIS code to download this file on-the-fly.
! unsigned totalSizeInKbytes = (totalSize + 512) / 1024;
! if (totalSizeInKbytes == 0)
! {
! totalSizeInKbytes = 1;
! }
! cmOStringStream out;
! out << " AddSize " << totalSizeInKbytes << "\n"
! << " Push \"" << component->ArchiveFile << "\"\n"
! << " Call DownloadFile\n"
! << " ZipDLL::extractall \"$INSTDIR\\"
! << component->ArchiveFile << "\" \"$INSTDIR\"\n"
! << " Pop $2 ; error message\n"
! " StrCmp $2 \"success\" +2 0\n"
! " MessageBox MB_OK \"Failed to unzip $2\"\n"
! " Delete $INSTDIR\\$0\n";
! componentCode += out.str();
! }
! else
! {
! componentCode += " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n";
! }
! componentCode += " noinstall_" + component->Name + ":\n";
componentCode += "SectionEnd\n";
// Macro used to remove the component
! macrosOut << "!macro Remove_${" << component->Name << "}\n";
! macrosOut << " IntCmp $" << component->Name << "_was_installed 0 noremove_"
! << component->Name << "\n";
std::vector<std::string>::iterator pathIt;
for (pathIt = component->Files.begin();
***************
*** 601,605 ****
++pathIt)
{
! componentCode += " Delete \"$INSTDIR\\" + *pathIt + "\"\n";
}
for (pathIt = component->Directories.begin();
--- 785,791 ----
++pathIt)
{
! macrosOut << " Delete \"$INSTDIR\\"
! << cmSystemTools::ConvertToWindowsOutputPath(pathIt->c_str())
! << "\"\n";
}
for (pathIt = component->Directories.begin();
***************
*** 607,627 ****
++pathIt)
{
! componentCode += " RMDir \"$INSTDIR\\" + *pathIt + "\"\n";
}
! componentCode += "!macroend\n";
// Macro used to select each of the components that this component
// depends on.
std::set<cmCPackComponent *> visited;
! componentCode += "!macro Select_" + component->Name + "_depends\n";
! componentCode += CreateSelectionDependenciesDescription(component, visited);
! componentCode += "!macroend\n";
// Macro used to deselect each of the components that depend on this
// component.
visited.clear();
! componentCode += "!macro Deselect_required_by_" + component->Name + "\n";
! componentCode += CreateDeselectionDependenciesDescription(component, visited);
! componentCode += "!macroend\n";
return componentCode;
}
--- 793,816 ----
++pathIt)
{
! macrosOut << " RMDir \"$INSTDIR\\"
! << cmSystemTools::ConvertToWindowsOutputPath(pathIt->c_str())
! << "\"\n";
}
! macrosOut << " noremove_" << component->Name << ":\n";
! macrosOut << "!macroend\n";
// Macro used to select each of the components that this component
// depends on.
std::set<cmCPackComponent *> visited;
! macrosOut << "!macro Select_" << component->Name << "_depends\n";
! macrosOut << CreateSelectionDependenciesDescription(component, visited);
! macrosOut << "!macroend\n";
// Macro used to deselect each of the components that depend on this
// component.
visited.clear();
! macrosOut << "!macro Deselect_required_by_" << component->Name << "\n";
! macrosOut << CreateDeselectionDependenciesDescription(component, visited);
! macrosOut << "!macroend\n";
return componentCode;
}
***************
*** 630,634 ****
std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited) const
{
// Don't visit a component twice
--- 819,823 ----
std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited)
{
// Don't visit a component twice
***************
*** 661,665 ****
std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited) const
{
// Don't visit a component twice
--- 850,854 ----
std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
(cmCPackComponent *component,
! std::set<cmCPackComponent *>& visited)
{
// Don't visit a component twice
***************
*** 693,699 ****
std::string
cmCPackNSISGenerator::
! CreateComponentGroupDescription(cmCPackComponentGroup *group) const
{
! if (group->Components.empty())
{
// Silently skip empty groups. NSIS doesn't support them.
--- 882,889 ----
std::string
cmCPackNSISGenerator::
! CreateComponentGroupDescription(cmCPackComponentGroup *group,
! cmOStringStream& macrosOut)
{
! if (group->Components.empty() && group->Subgroups.empty())
{
// Silently skip empty groups. NSIS doesn't support them.
***************
*** 714,717 ****
--- 904,915 ----
code += "\"" + group->DisplayName + "\" " + group->Name + "\n";
}
+
+ std::vector<cmCPackComponentGroup*>::iterator groupIt;
+ for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end();
+ ++groupIt)
+ {
+ code += this->CreateComponentGroupDescription(*groupIt, macrosOut);
+ }
+
std::vector<cmCPackComponent*>::iterator comp;
for (comp = group->Components.begin();
***************
*** 719,723 ****
++comp)
{
! code += this->CreateComponentDescription(*comp);
}
code += "SectionGroupEnd\n";
--- 917,926 ----
++comp)
{
! if ((*comp)->Files.empty())
! {
! continue;
! }
!
! code += this->CreateComponentDescription(*comp, macrosOut);
}
code += "SectionGroupEnd\n";
More information about the Cmake-commits
mailing list