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_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
MACRO(cpack_check_file_exists file description)
IF(NOT EXISTS "${file}")
MESSAGE(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
ENDIF(NOT EXISTS "${file}")
ENDMACRO(cpack_check_file_exists)
macro(cpack_check_file_exists file description)
if(NOT EXISTS "${file}")
message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
endif(NOT EXISTS "${file}")
endmacro(cpack_check_file_exists)
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_README}" "readme resource")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
# Pick a generator
IF(NOT CPACK_GENERATOR)
IF(UNIX)
IF(APPLE)
SET(CPACK_GENERATOR "PackageMaker;STGZ;TGZ")
ELSE(APPLE)
SET(CPACK_GENERATOR "STGZ;TGZ;TZ")
ENDIF(APPLE)
SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
IF(CYGWIN)
SET(CPACK_SOURCE_GENERATOR "CygwinSource")
SET(CPACK_GENERATOR "CygwinBinary")
ENDIF(CYGWIN)
ELSE(UNIX)
SET(CPACK_GENERATOR "NSIS;ZIP")
SET(CPACK_SOURCE_GENERATOR "ZIP")
ENDIF(UNIX)
ENDIF(NOT CPACK_GENERATOR)
macro(cpack_optional_append _list _cond _item)
if(${_cond})
set(${_list} ${${_list}} ${_item})
endif(${_cond})
endmacro(cpack_optional_append _list _cond _item)
# Provide options to choose generators
# we might check here if the required tools for the generates exist
# and set the defaults according to the results
if(NOT CPACK_GENERATOR)
if(UNIX)
if(CYGWIN)
option(CPACK_CYGWIN_BINARY "Enable to build Cygwin binary packages" ON)
else(CYGWIN)
if(APPLE)
option(CPACK_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
option(CPACK_OSXX11 "Enable to build OSX X11 packages" ON)
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
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_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
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}")
cpack_encode_variables()
CONFIGURE_FILE("${cpack_source_input_file}"
configure_file("${cpack_source_input_file}"
"${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)

View File

@ -10,7 +10,7 @@ FIND_PROGRAM(AR_EXECUTABLE ar)
IF(NOT AR_EXECUTABLE)
# 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)
# Let's define the control file found in debian package:
@ -18,13 +18,13 @@ ENDIF(NOT AR_EXECUTABLE)
# Package:
# debian policy enforce lower case for 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)
# Version:
IF(NOT DEBIAN_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)
SET(DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
ENDIF(NOT DEBIAN_PACKAGE_VERSION)
@ -46,7 +46,7 @@ ENDIF(NOT DEBIAN_PACKAGE_DEPENDS)
# Maintainer:
IF(NOT DEBIAN_PACKAGE_MAINTAINER)
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)
SET(DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER)
@ -54,7 +54,7 @@ ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER)
# Description:
IF(NOT DEBIAN_PACKAGE_DESCRIPTION)
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)
SET(DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
ENDIF(NOT DEBIAN_PACKAGE_DESCRIPTION)

View File

@ -653,7 +653,7 @@ int cmCPackGenericGenerator::ProcessGenerator()
tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
}
if ( !this->CompressFiles(tempPackageFileName,
tempDirectory, gl.GetFiles()) )
tempDirectory, gl.GetFiles()) || cmSystemTools::GetErrorOccuredFlag())
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
<< std::endl);
@ -695,7 +695,13 @@ int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf,
"Cannot initialize the generator" << std::endl);
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,
"Cannot initialize CPack generator: "
<< generator.c_str() << std::endl);
<< gen << std::endl);
parsed = 0;
}
if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize the generator" << std::endl);
"Cannot initialize the generator " << gen << std::endl);
parsed = 0;
}
@ -442,7 +442,7 @@ int main (int argc, char *argv[])
}
}
if ( !parsed || help )
if ( help )
{
doc.CheckOptions(argc, argv);
// Construct and print requested documentation.