ENH: better error messages from the debian package generator

-don't display the cpack help if a generator failed with some problem
-check for cmSystemTools::GetErrorOccuredFlag()

Alex
This commit is contained in:
Alexander Neundorf 2007-08-03 15:26:30 -04:00
parent bf0c200f0a
commit 68674bd0d7
4 changed files with 89 additions and 35 deletions

View File

@ -80,34 +80,82 @@ cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
MACRO(cpack_check_file_exists file description) macro(cpack_check_file_exists file description)
IF(NOT EXISTS "${file}") if(NOT EXISTS "${file}")
MESSAGE(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.") message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
ENDIF(NOT EXISTS "${file}") endif(NOT EXISTS "${file}")
ENDMACRO(cpack_check_file_exists) endmacro(cpack_check_file_exists)
cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description") cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource") cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource") cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource") cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
# Pick a generator macro(cpack_optional_append _list _cond _item)
IF(NOT CPACK_GENERATOR) if(${_cond})
IF(UNIX) set(${_list} ${${_list}} ${_item})
IF(APPLE) endif(${_cond})
SET(CPACK_GENERATOR "PackageMaker;STGZ;TGZ") endmacro(cpack_optional_append _list _cond _item)
ELSE(APPLE)
SET(CPACK_GENERATOR "STGZ;TGZ;TZ") # Provide options to choose generators
ENDIF(APPLE) # we might check here if the required tools for the generates exist
SET(CPACK_SOURCE_GENERATOR "TGZ;TZ") # and set the defaults according to the results
IF(CYGWIN) if(NOT CPACK_GENERATOR)
SET(CPACK_SOURCE_GENERATOR "CygwinSource") if(UNIX)
SET(CPACK_GENERATOR "CygwinBinary") if(CYGWIN)
ENDIF(CYGWIN) option(CPACK_CYGWIN_BINARY "Enable to build Cygwin binary packages" ON)
ELSE(UNIX) else(CYGWIN)
SET(CPACK_GENERATOR "NSIS;ZIP") if(APPLE)
SET(CPACK_SOURCE_GENERATOR "ZIP") option(CPACK_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
ENDIF(UNIX) option(CPACK_OSXX11 "Enable to build OSX X11 packages" ON)
ENDIF(NOT CPACK_GENERATOR) else(APPLE)
option(CPACK_TZ "Enable to build TZ packages" ON)
endif(APPLE)
option(CPACK_STGZ "Enable to build STGZ packages" ON)
option(CPACK_TGZ "Enable to build TGZ packages" ON)
option(CPACK_TBZ2 "Enable to build TBZ2 packages" ON)
option(CPACK_DEB "Enable to build Debian packages" OFF)
option(CPACK_NSIS "Enable to build NSIS packages" OFF)
endif(CYGWIN)
else(UNIX)
option(CPACK_NSIS "Enable to build NSIS packages" ON)
option(CPACK_ZIP "Enable to build ZIP packages" ON)
endif(UNIX)
cpack_optional_append(CPACK_GENERATOR CPACK_PACKAGEMAKER PackageMaker)
cpack_optional_append(CPACK_GENERATOR CPACK_OSXX11 OSXX11)
cpack_optional_append(CPACK_GENERATOR CPACK_CYGWIN_BINARY CygwinBinary)
cpack_optional_append(CPACK_GENERATOR CPACK_DEB DEB)
cpack_optional_append(CPACK_GENERATOR CPACK_NSIS NSIS)
cpack_optional_append(CPACK_GENERATOR CPACK_STGZ STGZ)
cpack_optional_append(CPACK_GENERATOR CPACK_TGZ TGZ)
cpack_optional_append(CPACK_GENERATOR CPACK_TBZ2 TBZ2)
cpack_optional_append(CPACK_GENERATOR CPACK_TZ TZ)
cpack_optional_append(CPACK_GENERATOR CPACK_ZIP ZIP)
endif(NOT CPACK_GENERATOR)
# Provide options to choose source generators
if(NOT CPACK_SOURCE_GENERATOR)
if(UNIX)
if(CYGWIN)
option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
else(CYGWIN)
option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
endif(CYGWIN)
else(UNIX)
option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
endif(UNIX)
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
endif(NOT CPACK_SOURCE_GENERATOR)
# Set some other variables # Set some other variables
cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
@ -127,7 +175,7 @@ cpack_set_if_not_set(CPACK_USE_DESTDIR ON)
cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
cpack_encode_variables() cpack_encode_variables()
CONFIGURE_FILE("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE) configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
# Generate source file # Generate source file
cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES
@ -146,5 +194,5 @@ SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}") SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
cpack_encode_variables() cpack_encode_variables()
CONFIGURE_FILE("${cpack_source_input_file}" configure_file("${cpack_source_input_file}"
"${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE) "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)

View File

@ -10,7 +10,7 @@ FIND_PROGRAM(AR_EXECUTABLE ar)
IF(NOT AR_EXECUTABLE) IF(NOT AR_EXECUTABLE)
# Is there a *NIX out there without ar ? # Is there a *NIX out there without ar ?
MESSAGE(FATAL_ERROR "debian package require a ar executable") MESSAGE(FATAL_ERROR "Debian package requires ar executable")
ENDIF(NOT AR_EXECUTABLE) ENDIF(NOT AR_EXECUTABLE)
# Let's define the control file found in debian package: # Let's define the control file found in debian package:
@ -18,13 +18,13 @@ ENDIF(NOT AR_EXECUTABLE)
# Package: # Package:
# debian policy enforce lower case for package name # debian policy enforce lower case for package name
IF(NOT DEBIAN_PACKAGE_NAME) IF(NOT DEBIAN_PACKAGE_NAME)
STRING(TOLOWER ${CPACK_PACKAGE_NAME} DEBIAN_PACKAGE_NAME) STRING(TOLOWER "${CPACK_PACKAGE_NAME}" DEBIAN_PACKAGE_NAME)
ENDIF(NOT DEBIAN_PACKAGE_NAME) ENDIF(NOT DEBIAN_PACKAGE_NAME)
# Version: # Version:
IF(NOT DEBIAN_PACKAGE_VERSION) IF(NOT DEBIAN_PACKAGE_VERSION)
IF(NOT CPACK_PACKAGE_VERSION) IF(NOT CPACK_PACKAGE_VERSION)
MESSAGE(FATAL_ERROR "debian package require a package version") MESSAGE(FATAL_ERROR "Debian package requires a package version")
ENDIF(NOT CPACK_PACKAGE_VERSION) ENDIF(NOT CPACK_PACKAGE_VERSION)
SET(DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) SET(DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
ENDIF(NOT DEBIAN_PACKAGE_VERSION) ENDIF(NOT DEBIAN_PACKAGE_VERSION)
@ -46,7 +46,7 @@ ENDIF(NOT DEBIAN_PACKAGE_DEPENDS)
# Maintainer: # Maintainer:
IF(NOT DEBIAN_PACKAGE_MAINTAINER) IF(NOT DEBIAN_PACKAGE_MAINTAINER)
IF(NOT CPACK_PACKAGE_CONTACT) IF(NOT CPACK_PACKAGE_CONTACT)
MESSAGE(FATAL_ERROR "debian package require a maintainer for a package") MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or DEBIAN_PACKAGE_MAINTAINER")
ENDIF(NOT CPACK_PACKAGE_CONTACT) ENDIF(NOT CPACK_PACKAGE_CONTACT)
SET(DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) SET(DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER) ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER)
@ -54,7 +54,7 @@ ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER)
# Description: # Description:
IF(NOT DEBIAN_PACKAGE_DESCRIPTION) IF(NOT DEBIAN_PACKAGE_DESCRIPTION)
IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
MESSAGE(FATAL_ERROR "debian package require a summary for a package") MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or DEBIAN_PACKAGE_DESCRIPTION")
ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
SET(DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) SET(DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
ENDIF(NOT DEBIAN_PACKAGE_DESCRIPTION) ENDIF(NOT DEBIAN_PACKAGE_DESCRIPTION)

View File

@ -653,7 +653,7 @@ int cmCPackGenericGenerator::ProcessGenerator()
tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
} }
if ( !this->CompressFiles(tempPackageFileName, if ( !this->CompressFiles(tempPackageFileName,
tempDirectory, gl.GetFiles()) ) tempDirectory, gl.GetFiles()) || cmSystemTools::GetErrorOccuredFlag())
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
<< std::endl); << std::endl);
@ -695,7 +695,13 @@ int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf,
"Cannot initialize the generator" << std::endl); "Cannot initialize the generator" << std::endl);
return 0; return 0;
} }
return this->InitializeInternal(); int result = this->InitializeInternal();
if (cmSystemTools::GetErrorOccuredFlag())
{
return 0;
}
return result;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -377,13 +377,13 @@ int main (int argc, char *argv[])
{ {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize CPack generator: " "Cannot initialize CPack generator: "
<< generator.c_str() << std::endl); << gen << std::endl);
parsed = 0; parsed = 0;
} }
if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) ) if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
{ {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize the generator" << std::endl); "Cannot initialize the generator " << gen << std::endl);
parsed = 0; parsed = 0;
} }
@ -442,7 +442,7 @@ int main (int argc, char *argv[])
} }
} }
if ( !parsed || help ) if ( help )
{ {
doc.CheckOptions(argc, argv); doc.CheckOptions(argc, argv);
// Construct and print requested documentation. // Construct and print requested documentation.