Warning, /multimedia/kwave/cmake/KwaveRPMSupport.cmake is written in an unsupported language. File is not indexed.

0001 #############################################################################
0002 ##    Kwave                - KwaveRPMSupport.cmake
0003 ##                           -------------------
0004 ##    begin                : Sun Jun 10 2007
0005 ##    copyright            : (C) 2007 by Thomas Eschenbacher
0006 ##    email                : Thomas.Eschenbacher@gmx.de
0007 #############################################################################
0008 #
0009 #############################################################################
0010 #                                                                           #
0011 # Redistribution and use in source and binary forms, with or without        #
0012 # modification, are permitted provided that the following conditions        #
0013 # are met:                                                                  #
0014 #                                                                           #
0015 # 1. Redistributions of source code must retain the above copyright         #
0016 #    notice, this list of conditions and the following disclaimer.          #
0017 # 2. Redistributions in binary form must reproduce the above copyright      #
0018 #    notice, this list of conditions and the following disclaimer in the    #
0019 #    documentation and/or other materials provided with the distribution.   #
0020 #                                                                           #
0021 # For details see the accompanying cmake/COPYING-CMAKE-SCRIPTS file.        #
0022 #                                                                           #
0023 #############################################################################
0024 
0025 #############################################################################
0026 ### some needed programs                                                  ###
0027 
0028 FIND_PROGRAM(TAR_EXECUTABLE NAMES tar) # we need tar-1.16 or newer !
0029 FIND_PROGRAM(RPM_EXECUTABLE NAMES rpm)
0030 FIND_PROGRAM(RPMBUILD_EXECUTABLE NAMES rpmbuild)
0031 FIND_PROGRAM(BZIP2_EXECUTABLE NAMES bzip2)
0032 
0033 #############################################################################
0034 ### determine all variables in the kwave.spec.in                          ###
0035 
0036 SET(RPM_RELEASE "1")
0037 SET(RPM_FULL_VERSION "${KWAVE_VERSION}-${RPM_RELEASE}")
0038 
0039 #############################################################################
0040 ### generate the .changes file                                            ###
0041 
0042 SET(_changes ${DISTFILES_DIR}/kwave.changes)
0043 ADD_CUSTOM_COMMAND(OUTPUT ${_changes}
0044     COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/make-specfile-changelog.pl
0045         ${CMAKE_CURRENT_SOURCE_DIR}/CHANGES
0046         ${_changes}
0047     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CHANGES
0048     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/make-specfile-changelog.pl
0049 )
0050 
0051 SET(KWAVE_ADDITIONAL_CLEAN_FILES ${KWAVE_ADDITIONAL_CLEAN_FILES} ${_changes})
0052 
0053 #############################################################################
0054 ### generate the .spec file                                               ###
0055 
0056 SET(_specfile_without_changelog ${CMAKE_CURRENT_BINARY_DIR}/kwave.spec.no-chglog)
0057 SET(_specfile ${DISTFILES_DIR}/kwave.spec)
0058 CONFIGURE_FILE(
0059     ${CMAKE_CURRENT_SOURCE_DIR}/kwave.spec.in
0060     ${_specfile_without_changelog}
0061     @ONLY
0062 )
0063 
0064 ADD_CUSTOM_COMMAND(OUTPUT ${_specfile}
0065     COMMAND ${CAT_EXECUTABLE} ${_specfile_without_changelog} > ${_specfile}
0066     COMMAND ${CAT_EXECUTABLE} ${_changes} >> ${_specfile}
0067     DEPENDS ${_specfile_without_changelog} ${_changes}
0068 )
0069 
0070 ADD_CUSTOM_TARGET(specfile
0071     DEPENDS ${_specfile}
0072 )
0073 
0074 #############################################################################
0075 ### "make tarball"                                                        ###
0076 
0077 SET(_tarball ${DISTFILES_DIR}/kwave-${RPM_FULL_VERSION}.tar)
0078 SET(_tarball_bz2 ${_tarball}.bz2)
0079 
0080 SET(_git "${CMAKE_SOURCE_DIR}/.git")
0081 IF (EXISTS ${_git})
0082     FIND_PROGRAM(GIT_EXECUTABLE NAMES git)
0083     IF (GIT_EXECUTABLE)
0084         MESSAGE(STATUS "Found git: ${GIT_EXECUTABLE}")
0085         SET(files_lst "${CMAKE_BINARY_DIR}/files.lst")
0086         ADD_CUSTOM_COMMAND(OUTPUT ${files_lst}
0087             COMMENT "Building file list from local .git repository"
0088             COMMAND "${GIT_EXECUTABLE}" ls-tree -r --name-only HEAD ">" ${files_lst}
0089             COMMAND test -e po && find po -name \\*.po ">>" ${files_lst}
0090             COMMAND find doc -type f -name \\*.txt ">>" ${files_lst}
0091             COMMAND find doc -type f -name index.docbook ">>" ${files_lst}
0092             COMMAND find doc -type f -name \\*.png ">>" ${files_lst}
0093             COMMAND find . -type f -name \\*.spec ">>" ${files_lst}
0094             COMMAND cat ${files_lst} | sort | uniq > ${files_lst}.tmp
0095             COMMAND mv ${files_lst}.tmp ${files_lst}
0096             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
0097         )
0098         SET(file_selection "--files-from=${files_lst}")
0099     ELSE (GIT_EXECUTABLE)
0100         MESSAGE(STATUS "Warning: .git exists but git program not found")
0101     ENDIF (GIT_EXECUTABLE)
0102 ELSE (EXISTS ${_git})
0103     MESSAGE(STATUS "No git version control files")
0104 ENDIF (EXISTS ${_git})
0105 IF (NOT file_selection)
0106     SET(file_selection ".")
0107 ENDIF (NOT file_selection)
0108 
0109 ADD_CUSTOM_COMMAND(OUTPUT ${_tarball_bz2}
0110     COMMAND ${TAR_EXECUTABLE}
0111         -c
0112         --exclude=.git --exclude=testfiles --exclude=*~
0113         --transform=s+^./++g
0114         --transform=s+^+kwave-${KWAVE_VERSION}/+g
0115         --owner=root --group=root --mode=a+rX,go-w
0116         -C ${CMAKE_SOURCE_DIR}
0117         -f ${_tarball}
0118         ${file_selection}
0119     COMMAND ${TAR_EXECUTABLE} --append -f ${_tarball}
0120         --owner=root --group=root --mode=a+rX,go-w
0121         -C ${DISTFILES_DIR}
0122         --transform=s+^+kwave-${KWAVE_VERSION}/+g
0123         kwave.spec
0124     COMMAND ${CMAKE_COMMAND} -E remove -f ${_tarball_bz2}
0125     COMMAND ${BZIP2_EXECUTABLE} ${_tarball}
0126     DEPENDS ${_specfile} ${files_lst}
0127 )
0128 
0129 ADD_CUSTOM_TARGET(tarball
0130     DEPENDS ${_tarball_bz2}
0131 )
0132 
0133 SET(KWAVE_ADDITIONAL_CLEAN_FILES ${KWAVE_ADDITIONAL_CLEAN_FILES} ${_tarball_bz2})
0134 
0135 #############################################################################
0136 ### source RPM                                                            ###
0137 
0138 EXECUTE_PROCESS(
0139     COMMAND ${RPM_EXECUTABLE} -E %{_topdir}
0140     OUTPUT_VARIABLE _rpm_topdir
0141     OUTPUT_STRIP_TRAILING_WHITESPACE
0142 )
0143 
0144 SET(_src_rpm ${_rpm_topdir}/SRPMS/kwave-${RPM_FULL_VERSION}.src.rpm)
0145 
0146 ADD_CUSTOM_COMMAND(OUTPUT ${_src_rpm}
0147     COMMAND ${CMAKE_COMMAND} -E make_directory ${_rpm_topdir}/{SPECS,SOURCES,RPMS,SRPMS,BUILD}
0148     COMMAND ${CMAKE_COMMAND} -E copy_if_different
0149         ${_specfile} ${_rpm_topdir}/SPECS/kwave-${RPM_FULL_VERSION}.spec
0150     COMMAND ${CMAKE_COMMAND} -E copy_if_different
0151         ${_tarball_bz2} ${_rpm_topdir}/SOURCES/kwave-${RPM_FULL_VERSION}.tar.bz2
0152     COMMAND ${RPMBUILD_EXECUTABLE} -bs --nodeps
0153         ${_rpm_topdir}/SPECS/kwave-${RPM_FULL_VERSION}.spec
0154     DEPENDS ${_specfile} ${_tarball_bz2}
0155 )
0156 
0157 ADD_CUSTOM_TARGET(src_rpm
0158     DEPENDS ${_src_rpm} ${_specfile} ${_changes}
0159 )
0160 
0161 #############################################################################
0162 ### binary RPM for this architecture                                      ###
0163 
0164 ADD_CUSTOM_TARGET(rpm
0165     COMMAND ${RPMBUILD_EXECUTABLE} --rebuild --nodeps ${_src_rpm}
0166     DEPENDS ${_src_rpm} ${_specfile}
0167 )
0168 
0169 #############################################################################
0170 ### add files to the list of distribution files                           ###
0171 
0172 SET(KWAVE_DISTFILES
0173     ${KWAVE_DISTFILES}
0174     ${_tarball_bz2}
0175     ${_specfile}
0176     ${_changes}
0177 )
0178 
0179 #############################################################################
0180 #############################################################################