ENH: More work on NSI to improve installing and uninstalling
This commit is contained in:
parent
537e2b4ed5
commit
b07ece004c
@ -342,9 +342,7 @@ Section "Dummy Section" SecDummy
|
|||||||
;Use the entire tree produced by the INSTALL target. Keep the
|
;Use the entire tree produced by the INSTALL target. Keep the
|
||||||
;list of directories here in sync with the RMDir commands below.
|
;list of directories here in sync with the RMDir commands below.
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
File /r "${INST_DIR}\bin"
|
File /r "${INST_DIR}\*.*"
|
||||||
File /r "${INST_DIR}\doc"
|
|
||||||
File /r "${INST_DIR}\share"
|
|
||||||
|
|
||||||
@CPACK_NSIS_EXTRA_COMMANDS@
|
@CPACK_NSIS_EXTRA_COMMANDS@
|
||||||
|
|
||||||
@ -397,11 +395,10 @@ FunctionEnd
|
|||||||
|
|
||||||
Section "Uninstall"
|
Section "Uninstall"
|
||||||
|
|
||||||
;Remove directories we installed.
|
;Remove files we installed.
|
||||||
;Keep the list of directories here in sync with the File commands above.
|
;Keep the list of directories here in sync with the File commands above.
|
||||||
RMDir /r "$INSTDIR\bin"
|
@CPACK_NSIS_DELETE_FILES@
|
||||||
RMDir /r "$INSTDIR\doc"
|
@CPACK_NSIS_DELETE_DIRECTORIES@
|
||||||
RMDir /r "$INSTDIR\share"
|
|
||||||
|
|
||||||
;Remove the uninstaller itself.
|
;Remove the uninstaller itself.
|
||||||
Delete "$INSTDIR\Uninstall.exe"
|
Delete "$INSTDIR\Uninstall.exe"
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <cmsys/SystemTools.hxx>
|
#include <cmsys/SystemTools.hxx>
|
||||||
#include <cmsys/Glob.hxx>
|
#include <cmsys/Glob.hxx>
|
||||||
|
#include <cmsys/Directory.hxx>
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCPackNSISGenerator::cmCPackNSISGenerator()
|
cmCPackNSISGenerator::cmCPackNSISGenerator()
|
||||||
@ -43,7 +44,6 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
|
|||||||
{
|
{
|
||||||
(void)outFileName; // TODO: Fix nsis to force out file name
|
(void)outFileName; // TODO: Fix nsis to force out file name
|
||||||
(void)toplevel;
|
(void)toplevel;
|
||||||
(void)files;
|
|
||||||
std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
|
std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
|
||||||
if ( nsisInFileName.size() == 0 )
|
if ( nsisInFileName.size() == 0 )
|
||||||
{
|
{
|
||||||
@ -54,6 +54,35 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
|
|||||||
std::string tmpFile = nsisFileName;
|
std::string tmpFile = nsisFileName;
|
||||||
tmpFile += "/NSISOutput.log";
|
tmpFile += "/NSISOutput.log";
|
||||||
nsisFileName += "/project.nsi";
|
nsisFileName += "/project.nsi";
|
||||||
|
cmOStringStream str;
|
||||||
|
std::vector<std::string>::const_iterator it;
|
||||||
|
for ( it = files.begin(); it != files.end(); ++ it )
|
||||||
|
{
|
||||||
|
std::string fileN = cmSystemTools::RelativePath(toplevel,
|
||||||
|
it->c_str());
|
||||||
|
cmSystemTools::ReplaceString(fileN, "/", "\\");
|
||||||
|
str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
|
||||||
|
}
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str().c_str() << std::endl);
|
||||||
|
this->SetOption("CPACK_NSIS_DELETE_FILES", str.str().c_str());
|
||||||
|
std::vector<std::string> dirs;
|
||||||
|
this->GetListOfSubdirectories(toplevel, dirs);
|
||||||
|
std::vector<std::string>::const_iterator sit;
|
||||||
|
cmOStringStream dstr;
|
||||||
|
for ( sit = dirs.begin(); sit != dirs.end(); ++ sit )
|
||||||
|
{
|
||||||
|
std::string fileN = cmSystemTools::RelativePath(toplevel,
|
||||||
|
sit->c_str());
|
||||||
|
if ( fileN.empty() )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cmSystemTools::ReplaceString(fileN, "/", "\\");
|
||||||
|
dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
|
||||||
|
}
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str().c_str() << std::endl);
|
||||||
|
this->SetOption("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
|
||||||
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName << " to " << nsisFileName << std::endl);
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName << " to " << nsisFileName << std::endl);
|
||||||
this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());
|
this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());
|
||||||
std::string nsisCmd = "\"";
|
std::string nsisCmd = "\"";
|
||||||
@ -132,3 +161,31 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, std::vector<std::string>& dirs)
|
||||||
|
{
|
||||||
|
cmsys::Directory dir;
|
||||||
|
dir.Load(topdir);
|
||||||
|
size_t fileNum;
|
||||||
|
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
|
||||||
|
{
|
||||||
|
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
|
||||||
|
strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
|
||||||
|
{
|
||||||
|
kwsys_stl::string fullPath = topdir;
|
||||||
|
fullPath += "/";
|
||||||
|
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
||||||
|
if(cmsys::SystemTools::FileIsDirectory(fullPath.c_str()) &&
|
||||||
|
!cmsys::SystemTools::FileIsSymlink(fullPath.c_str()))
|
||||||
|
{
|
||||||
|
if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dirs.push_back(topdir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ protected:
|
|||||||
const std::vector<std::string>& files);
|
const std::vector<std::string>& files);
|
||||||
virtual const char* GetOutputExtension() { return "exe"; }
|
virtual const char* GetOutputExtension() { return "exe"; }
|
||||||
virtual const char* GetOutputPostfix() { return "win32"; }
|
virtual const char* GetOutputPostfix() { return "win32"; }
|
||||||
|
|
||||||
|
bool GetListOfSubdirectories(const char* dir, std::vector<std::string>& dirs);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user