2007-08-17 17:13:15 +04:00
|
|
|
# CPack script for creating RPM package
|
2007-10-13 03:33:41 +04:00
|
|
|
# Author: Eric Noulard with the help of Alexander Neundorf.
|
|
|
|
# All variables used by CPackRPM begins with CPACK_RPM_ prefix
|
|
|
|
#
|
|
|
|
# Here comes the list of used variables:
|
|
|
|
#
|
2007-08-17 17:13:15 +04:00
|
|
|
|
2007-08-08 19:33:42 +04:00
|
|
|
IF(CMAKE_BINARY_DIR)
|
|
|
|
MESSAGE(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.")
|
|
|
|
ENDIF(CMAKE_BINARY_DIR)
|
|
|
|
|
|
|
|
IF(NOT UNIX)
|
|
|
|
MESSAGE(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
|
|
|
|
ENDIF(NOT UNIX)
|
|
|
|
|
2007-08-17 17:13:15 +04:00
|
|
|
# rpmbuild is the basic command for building RPM package
|
|
|
|
# it may be a simple (symbolic) link to rpmb command.
|
2007-08-08 19:33:42 +04:00
|
|
|
FIND_PROGRAM(RPMBUILD_EXECUTABLE rpmbuild)
|
|
|
|
|
|
|
|
IF(NOT RPMBUILD_EXECUTABLE)
|
|
|
|
MESSAGE(FATAL_ERROR "RPM package requires rpmbuild executable")
|
|
|
|
ENDIF(NOT RPMBUILD_EXECUTABLE)
|
|
|
|
|
2007-08-30 00:31:46 +04:00
|
|
|
IF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
|
|
|
|
MESSAGE(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
|
|
|
|
ENDIF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
|
|
|
|
|
2007-08-17 17:13:15 +04:00
|
|
|
# If rpmbuild is found
|
|
|
|
# we try to discover alien since we may be on non RPM distro like Debian.
|
|
|
|
# In this case we may try to to use more advanced features
|
|
|
|
# like generating RPM directly from DEB using alien.
|
|
|
|
# FIXME feature not finished (yet)
|
|
|
|
FIND_PROGRAM(ALIEN_EXECUTABLE alien)
|
|
|
|
IF(ALIEN_EXECUTABLE)
|
|
|
|
MESSAGE(STATUS "alien found, we may be on a Debian based distro.")
|
|
|
|
ENDIF(ALIEN_EXECUTABLE)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Use user-defined RPM specific variables value
|
|
|
|
# or generate reasonable default value from
|
|
|
|
# CPACK_xxx generic values.
|
|
|
|
# The variables comes from the needed (mandatory or not)
|
|
|
|
# values found in the RPM specification file aka ".spec" file.
|
|
|
|
# The variables which may/should be defined are:
|
|
|
|
#
|
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_PACKAGE_SUMMARY (mandatory)
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_SUMMARY)
|
2007-08-17 17:13:15 +04:00
|
|
|
# if neither var is defined lets use the name as summary
|
|
|
|
IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
2007-10-13 03:33:41 +04:00
|
|
|
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY)
|
2007-08-17 17:13:15 +04:00
|
|
|
ELSE(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
2007-10-13 03:33:41 +04:00
|
|
|
SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
|
2007-08-17 17:13:15 +04:00
|
|
|
ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
2007-10-13 03:33:41 +04:00
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_SUMMARY)
|
2007-08-17 17:13:15 +04:00
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_PACKAGE_NAME (mandatory)
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_NAME)
|
|
|
|
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_NAME)
|
2007-08-17 17:13:15 +04:00
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_PACKAGE_VERSION (mandatory)
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_VERSION)
|
2007-08-17 17:13:15 +04:00
|
|
|
IF(NOT CPACK_PACKAGE_VERSION)
|
|
|
|
MESSAGE(FATAL_ERROR "RPM package requires a package version")
|
|
|
|
ENDIF(NOT CPACK_PACKAGE_VERSION)
|
2007-10-13 03:33:41 +04:00
|
|
|
SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_VERSION)
|
2007-08-17 17:13:15 +04:00
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_PACKAGE_ARCHITECTURE (optional)
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
2007-08-17 17:13:15 +04:00
|
|
|
# FIXME This should be obtained through 'arch' command
|
|
|
|
# but is it --really necessary-- ?
|
2007-10-13 03:33:41 +04:00
|
|
|
SET(CPACK_RPM_PACKAGE_ARCHITECTURE i386)
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
|
2007-08-17 17:13:15 +04:00
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_PACKAGE_RELEASE
|
2007-08-17 17:13:15 +04:00
|
|
|
# The RPM release is the numbering of the RPM package ITSELF
|
|
|
|
# this is the version of the PACKAGING and NOT the version
|
|
|
|
# of the CONTENT of the package.
|
|
|
|
# You may well need to generate a new RPM package release
|
|
|
|
# without changing the version of the packaged software.
|
|
|
|
# This is the case when the packaging is buggy (not) the software :=)
|
|
|
|
# If not set, 1 is a good candidate
|
2007-10-13 03:33:41 +04:00
|
|
|
IF(NOT CPACK_RPM_PACKAGE_RELEASE)
|
|
|
|
SET(CPACK_RPM_PACKAGE_RELEASE 1)
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_RELEASE)
|
|
|
|
|
|
|
|
# CPACK_RPM_PACKAGE_LICENSE
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_LICENSE)
|
|
|
|
SET(CPACK_RPM_PACKAGE_LICENSE "unknown")
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_LICENSE)
|
|
|
|
|
|
|
|
# CPACK_RPM_PACKAGE_GROUP
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_GROUP)
|
|
|
|
SET(CPACK_RPM_PACKAGE_GROUP "unknown")
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_GROUP)
|
|
|
|
|
|
|
|
# CPACK_RPM_PACKAGE_VENDOR
|
|
|
|
IF(NOT CPACK_RPM_PACKAGE_VENDOR)
|
|
|
|
SET(CPACK_RPM_PACKAGE_VENDOR "unknown")
|
|
|
|
ENDIF(NOT CPACK_RPM_PACKAGE_VENDOR)
|
|
|
|
|
|
|
|
# CPACK_RPM_PACKAGE_SOURCE
|
2007-08-17 17:13:15 +04:00
|
|
|
# The name of the source tarball in case we generate
|
|
|
|
# a source RPM
|
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_PACKAGE_DESCRIPTION
|
2007-08-17 17:13:15 +04:00
|
|
|
# FIXME may be found in CPACK_PACKAGE_DESCRIPTION_FILE
|
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
# CPACK_RPM_USER_BINARY_SPECFILE
|
2007-08-17 17:13:15 +04:00
|
|
|
# FIXME when this is set then CPack should us the
|
|
|
|
# user provided file.
|
|
|
|
|
|
|
|
# Now we may create the RPM build tree structure
|
2007-10-13 03:33:41 +04:00
|
|
|
SET(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}")
|
|
|
|
MESSAGE(STATUS "CPackRPM:: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}")
|
2007-08-17 17:13:15 +04:00
|
|
|
# Prepare RPM build tree
|
2007-10-13 03:33:41 +04:00
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR})
|
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp)
|
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD)
|
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS)
|
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES)
|
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
|
|
|
|
FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
|
|
|
|
|
|
|
|
#SET(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
|
|
|
|
SET(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
|
2007-08-17 17:13:15 +04:00
|
|
|
# it seems rpmbuild can't handle spaces in the path
|
|
|
|
# neither escaping (as below) nor putting quotes around the path seem to help
|
2007-10-13 03:33:41 +04:00
|
|
|
#STRING(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
|
|
|
|
SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
|
2007-08-17 17:13:15 +04:00
|
|
|
|
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec")
|
|
|
|
IF(CPACK_RPM_USER_BINARY_SPECFILE)
|
2007-08-17 17:13:15 +04:00
|
|
|
# User may have specified SPECFILE just use it
|
2007-10-13 03:33:41 +04:00
|
|
|
MESSAGE("CPackRPM: Will use user specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}")
|
2007-08-17 17:13:15 +04:00
|
|
|
# Note that user provided file is processed for @var replacement
|
2007-10-13 03:33:41 +04:00
|
|
|
CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
|
|
|
|
ELSE(CPACK_RPM_USER_BINARY_SPECFILE)
|
2007-08-17 17:13:15 +04:00
|
|
|
# No User specified spec file generate a valid one using var values
|
2007-10-13 03:33:41 +04:00
|
|
|
IF(CPACK_RPM_PACKAGE_DEBUG)
|
2007-08-17 17:13:15 +04:00
|
|
|
MESSAGE("CPackRPM:: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}")
|
|
|
|
MESSAGE("CPackRPM:: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}")
|
|
|
|
MESSAGE("CPackRPM:: CPACK_TEMPORARY_DIRECTORY= ${PACK_TEMPORARY_DIRECTORY}")
|
|
|
|
MESSAGE("CPackRPM:: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}")
|
|
|
|
MESSAGE("CPackRPM:: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}")
|
|
|
|
MESSAGE("CPackRPM:: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
|
2007-10-13 03:33:41 +04:00
|
|
|
MESSAGE("CPackRPM:: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}")
|
2007-08-17 17:13:15 +04:00
|
|
|
MESSAGE("CPackRPM:: CPACK_PACKAGE_INSTALL_DIRECTORY = ${PACK_PACKAGE_INSTALL_DIRECTORY}")
|
|
|
|
MESSAGE("CPackRPM ::CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}")
|
2007-10-13 03:33:41 +04:00
|
|
|
ENDIF(CPACK_RPM_PACKAGE_DEBUG)
|
|
|
|
FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE}
|
2007-08-17 17:13:15 +04:00
|
|
|
"# -*- rpm-spec -*-
|
2007-10-13 03:33:41 +04:00
|
|
|
Buildroot: ${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}
|
|
|
|
Summary: ${CPACK_RPM_PACKAGE_SUMMARY}
|
|
|
|
Name: ${CPACK_RPM_PACKAGE_NAME}
|
|
|
|
Version: ${CPACK_RPM_PACKAGE_VERSION}
|
|
|
|
Release: ${CPACK_RPM_PACKAGE_RELEASE}
|
|
|
|
License: ${CPACK_RPM_PACKAGE_LICENSE}
|
|
|
|
Group: ${CPACK_RPM_PACKAGE_GROUP}
|
|
|
|
Vendor: ${CPACK_RPM_PACKAGE_VENDOR}
|
2007-08-17 17:13:15 +04:00
|
|
|
|
|
|
|
#%define prefix ${CMAKE_INSTALL_PREFIX}
|
2007-10-13 03:33:41 +04:00
|
|
|
%define _rpmdir ${CPACK_RPM_DIRECTORY}
|
|
|
|
%define _rpmfilename ${CPACK_RPM_FILE_NAME}
|
2007-08-17 17:13:15 +04:00
|
|
|
%define _unpackaged_files_terminate_build 0
|
2007-10-13 03:33:41 +04:00
|
|
|
%define _topdir ${CPACK_RPM_DIRECTORY}
|
2007-08-17 17:13:15 +04:00
|
|
|
|
|
|
|
%description
|
2007-10-13 03:33:41 +04:00
|
|
|
${CPACK_RPM_PACKAGE_NAME} : will come soon
|
|
|
|
with the value of CPACK_RPM_PACKAGE_DESCRIPTION
|
2007-08-17 17:13:15 +04:00
|
|
|
or
|
|
|
|
the content of CPACK_PACKAGE_DESCRIPTION_FILE
|
|
|
|
***
|
2007-10-13 03:33:41 +04:00
|
|
|
${CPACK_RPM_PACKAGE_DESCRIPTION}
|
2007-08-17 17:13:15 +04:00
|
|
|
***
|
|
|
|
|
|
|
|
%prep
|
|
|
|
|
|
|
|
%build
|
|
|
|
|
|
|
|
%install
|
|
|
|
|
|
|
|
%clean
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr(-,root,root,-)
|
|
|
|
#%dir %{prefix}
|
|
|
|
#%{prefix}/*
|
|
|
|
/*
|
|
|
|
|
|
|
|
%changelog
|
|
|
|
* Tue Aug 16 2007 Erk <eric.noulard@gmail.com>
|
|
|
|
Generated by CPack RPM Generator and associated macros
|
|
|
|
")
|
|
|
|
|
2007-10-13 03:33:41 +04:00
|
|
|
ENDIF(CPACK_RPM_USER_BINARY_SPECFILE)
|
2007-08-17 17:13:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
IF(RPMBUILD_EXECUTABLE)
|
|
|
|
# Now call rpmbuild using the SPECFILE
|
|
|
|
EXECUTE_PROCESS(
|
2007-10-13 03:33:41 +04:00
|
|
|
COMMAND "${RPMBUILD_EXECUTABLE}" -bb "${CPACK_RPM_BINARY_SPECFILE}"
|
2007-08-17 17:13:15 +04:00
|
|
|
WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}"
|
|
|
|
ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err"
|
|
|
|
OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out")
|
|
|
|
ELSE(RPMBUILD_EXECUTABLE)
|
|
|
|
IF(ALIEN_EXECUTABLE)
|
|
|
|
MESSAGE(FATAL_ERROR "RPM packaging through alien not done (yet)")
|
|
|
|
ENDIF(ALIEN_EXECUTABLE)
|
|
|
|
ENDIF(RPMBUILD_EXECUTABLE)
|