2015-05-19 03:44:54 +00:00
## Debian Source Package Generator
#
# Copyright (c) 2010 Daniel Pfeifer <daniel@pfeifer-mail.de>
# Many modifications by Rosen Diankov <rosen.diankov@gmail.com>
#
# Creates source debian files and manages library dependencies
#
# Features:
#
# - Automatically generates symbols and run-time dependencies from the build dependencies
# - Custom copy of source directory via CPACK_DEBIAN_PACKAGE_SOURCE_COPY
# - Simultaneous output of multiple debian source packages for each distribution
# - Can specificy distribution-specific dependencies by suffixing DEPENDS with _${DISTRO_NAME}, for example: CPACK_DEBIAN_PACKAGE_DEPENDS_LUCID, CPACK_COMPONENT_MYCOMP0_DEPENDS_LUCID
#
# Usage:
#
# set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake)
# set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
# set(CPACK_DEBIAN_PACKAGE_SECTION devel)
# set(CPACK_DEBIAN_CMAKE_OPTIONS "-DMYOPTION=myvalue")
# set(CPACK_DEBIAN_PACKAGE_DEPENDS mycomp0 mycomp1 some_ubuntu_package)
# set(CPACK_DEBIAN_PACKAGE_DEPENDS_UBUNTU_LUCID mycomp0 mycomp1 lucid_specific_package)
# set(CPACK_DEBIAN_PACKAGE_NAME mypackage)
# set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES unnecessary_file unnecessary_dir/file0)
# set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force) # if using subversion
# set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
# set(CPACK_DEBIAN_DISTRIBUTION_RELEASES karmic lucid maverick natty)
# set(CPACK_DEBIAN_CHANGELOG " * Extra change log lines")
# set(CPACK_DEBIAN_PACKAGE_SUGGESTS "ipython")
# set(CPACK_COMPONENT_X_RECOMMENDS "recommended-package")
##
find_program ( DEBUILD_EXECUTABLE debuild )
find_program ( DPUT_EXECUTABLE dput )
if ( NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE )
return ( )
endif ( NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE )
# DEBIAN/control
# debian policy enforce lower case for package name
# Package: (mandatory)
IF ( NOT CPACK_DEBIAN_PACKAGE_NAME )
STRING ( TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME )
ENDIF ( NOT CPACK_DEBIAN_PACKAGE_NAME )
# Section: (recommended)
IF ( NOT CPACK_DEBIAN_PACKAGE_SECTION )
SET ( CPACK_DEBIAN_PACKAGE_SECTION "devel" )
ENDIF ( NOT CPACK_DEBIAN_PACKAGE_SECTION )
# Priority: (recommended)
IF ( NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
ENDIF ( NOT CPACK_DEBIAN_PACKAGE_PRIORITY )
file ( STRINGS ${ CPACK_PACKAGE_DESCRIPTION_FILE } DESC_LINES )
foreach ( LINE ${ DESC_LINES } )
set ( DEB_LONG_DESCRIPTION "${DEB_LONG_DESCRIPTION} ${LINE}\n" )
endforeach ( LINE ${ DESC_LINES } )
file ( REMOVE_RECURSE "${CMAKE_BINARY_DIR}/Debian" )
file ( MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Debian" )
set ( DEBIAN_SOURCE_ORIG_DIR "${CMAKE_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}" )
if ( CPACK_DEBIAN_PACKAGE_SOURCE_COPY )
execute_process ( COMMAND ${ CPACK_DEBIAN_PACKAGE_SOURCE_COPY } "${CMAKE_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig" )
else ( )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E copy_directory ${ CMAKE_SOURCE_DIR } "${DEBIAN_SOURCE_ORIG_DIR}.orig" )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.git" )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.svn" )
endif ( )
# remove unnecessary folders
foreach ( REMOVE_DIR ${ CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES } )
file ( REMOVE_RECURSE ${ DEBIAN_SOURCE_ORIG_DIR } .orig/ ${ REMOVE_DIR } )
endforeach ( )
# create the original source tar
execute_process ( COMMAND ${ CMAKE_COMMAND } -E tar czf "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.orig.tar.gz" "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.orig" WORKING_DIRECTORY ${ CMAKE_BINARY_DIR } /Debian )
set ( DEB_SOURCE_CHANGES )
foreach ( RELEASE ${ CPACK_DEBIAN_DISTRIBUTION_RELEASES } )
set ( DEBIAN_SOURCE_DIR "${DEBIAN_SOURCE_ORIG_DIR}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1" )
set ( RELEASE_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1" )
string ( TOUPPER ${ RELEASE } RELEASE_UPPER )
string ( TOUPPER ${ CPACK_DEBIAN_DISTRIBUTION_NAME } DISTRIBUTION_NAME_UPPER )
file ( MAKE_DIRECTORY ${ DEBIAN_SOURCE_DIR } /debian )
##############################################################################
# debian/control
set ( DEBIAN_CONTROL ${ DEBIAN_SOURCE_DIR } /debian/control )
file ( WRITE ${ DEBIAN_CONTROL }
" S o u r c e : $ { C P A C K _ D E B I A N _ P A C K A G E _ N A M E } \ n "
" S e c t i o n : $ { C P A C K _ D E B I A N _ P A C K A G E _ S E C T I O N } \ n "
" P r i o r i t y : $ { C P A C K _ D E B I A N _ P A C K A G E _ P R I O R I T Y } \ n "
" D M - U p l o a d - A l l o w e d : y e s \ n "
" M a i n t a i n e r : $ { C P A C K _ P A C K A G E _ C O N T A C T } \ n "
" B u i l d - D e p e n d s : "
)
if ( CPACK_DEBIAN_BUILD_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_DEBIAN_BUILD_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_DEBIAN_BUILD_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_DEBIAN_BUILD_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_BUILD_DEPENDS } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_BUILD_DEPENDS } )
endif ( CPACK_DEBIAN_BUILD_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_DEBIAN_BUILD_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
file ( APPEND ${ DEBIAN_CONTROL } "\n"
" S t a n d a r d s - V e r s i o n : 3 . 8 . 4 \ n "
" H o m e p a g e : $ { C P A C K _ P A C K A G E _ V E N D O R } \ n "
" \ n "
" P a c k a g e : $ { C P A C K _ D E B I A N _ P A C K A G E _ N A M E } \ n "
" A r c h i t e c t u r e : a n y \ n "
" D e p e n d s : "
)
if ( CPACK_DEBIAN_PACKAGE_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_DEBIAN_PACKAGE_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_DEBIAN_PACKAGE_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_DEBIAN_PACKAGE_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_DEPENDS } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_DEPENDS } )
endif ( CPACK_DEBIAN_PACKAGE_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_DEBIAN_PACKAGE_DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
file ( APPEND ${ DEBIAN_CONTROL } "\nRecommends: " )
if ( CPACK_DEBIAN_PACKAGE_RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_DEBIAN_PACKAGE_RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_DEBIAN_PACKAGE_RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_DEBIAN_PACKAGE_RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_RECOMMENDS } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_RECOMMENDS } )
endif ( CPACK_DEBIAN_PACKAGE_RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_DEBIAN_PACKAGE_RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
file ( APPEND ${ DEBIAN_CONTROL } "\nSuggests: " )
if ( CPACK_DEBIAN_PACKAGE_SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_DEBIAN_PACKAGE_SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_DEBIAN_PACKAGE_SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER } } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_DEBIAN_PACKAGE_SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_DEBIAN_PACKAGE_SUGGESTS } )
file ( APPEND ${ DEBIAN_CONTROL } "${DEP}, " )
endforeach ( DEP ${ CPACK_DEBIAN_PACKAGE_SUGGESTS } )
endif ( CPACK_DEBIAN_PACKAGE_SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_DEBIAN_PACKAGE_SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
file ( APPEND ${ DEBIAN_CONTROL } "\n"
" D e s c r i p t i o n : $ { C P A C K _ P A C K A G E _ D I S P L A Y _ N A M E } $ { C P A C K _ P A C K A G E _ D E S C R I P T I O N _ S U M M A R Y } \ n "
" $ { D E B _ L O N G _ D E S C R I P T I O N } "
)
foreach ( COMPONENT ${ CPACK_COMPONENTS_ALL } )
string ( TOUPPER ${ COMPONENT } UPPER_COMPONENT )
set ( DEPENDS "\${shlibs:Depends}" )
if ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
set ( DEPENDS "${DEPENDS}, ${DEP}" )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } } )
set ( DEPENDS "${DEPENDS}, ${DEP}" )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _DEPENDS} )
set ( DEPENDS "${DEPENDS}, ${DEP}" )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _DEPENDS} )
endif ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _DEPENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
set ( RECOMMENDS )
if ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
set ( RECOMMENDS "${RECOMMENDS} ${DEP}, " )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } } )
set ( RECOMMENDS "${RECOMMENDS} ${DEP}, " )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _RECOMMENDS} )
set ( RECOMMENDS "${RECOMMENDS} ${DEP}, " )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _RECOMMENDS} )
endif ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _RECOMMENDS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
set ( SUGGESTS )
if ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
set ( SUGGESTS "${SUGGESTS} ${DEP}, " )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } } )
else ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
if ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } } )
set ( SUGGESTS "${SUGGESTS} ${DEP}, " )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } } )
else ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } )
foreach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _SUGGESTS} )
set ( SUGGESTS "${SUGGESTS} ${DEP}, " )
endforeach ( DEP ${ CPACK_COMPONENT_${UPPER_COMPONENT } _SUGGESTS} )
endif ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } )
endif ( CPACK_COMPONENT_ ${ UPPER_COMPONENT } _SUGGESTS_ ${ DISTRIBUTION_NAME_UPPER } _ ${ RELEASE_UPPER } )
file ( APPEND ${ DEBIAN_CONTROL } "\n"
" P a c k a g e : $ { C O M P O N E N T } \ n "
" A r c h i t e c t u r e : a n y \ n "
" D e p e n d s : $ { D E P E N D S } \ n "
" R e c o m m e n d s : $ { R E C O M M E N D S } \ n "
" S u g g e s t s : $ { S U G G E S T S } \ n "
" D e s c r i p t i o n : $ { C P A C K _ P A C K A G E _ D I S P L A Y _ N A M E } $ { C P A C K _ C O M P O N E N T _ $ { U P P E R _ C O M P O N E N T } _ D I S P L A Y _ N A M E } \ n "
" $ { D E B _ L O N G _ D E S C R I P T I O N } "
" . \ n "
" $ { C P A C K _ C O M P O N E N T _ $ { U P P E R _ C O M P O N E N T } _ D E S C R I P T I O N } \ n "
)
endforeach ( COMPONENT ${ CPACK_COMPONENTS_ALL } )
##############################################################################
# debian/copyright
set ( DEBIAN_COPYRIGHT ${ DEBIAN_SOURCE_DIR } /debian/copyright )
execute_process ( COMMAND ${ CMAKE_COMMAND } -E
c o p y $ { C P A C K _ R E S O U R C E _ F I L E _ L I C E N S E } $ { D E B I A N _ C O P Y R I G H T }
)
##############################################################################
# debian/rules
set ( DEBIAN_RULES ${ DEBIAN_SOURCE_DIR } /debian/rules )
file ( WRITE ${ DEBIAN_RULES }
" #!/usr/bin/make -f\n"
" \ n "
" B U I L D D I R = b u i l d _ d i r \ n "
" \ n "
" b u i l d : \ n "
" m k d i r $ ( B U I L D D I R ) \ n "
" c d $ ( B U I L D D I R ) ; c m a k e - D C M A K E _ B U I L D _ T Y P E = R e l e a s e $ { C P A C K _ D E B I A N _ C M A K E _ O P T I O N S } - D C M A K E _ I N S T A L L _ P R E F I X = / u s r . . \ n "
" $ ( M A K E ) - C $ ( B U I L D D I R ) p r e i n s t a l l \ n "
" t o u c h b u i l d \ n "
" \ n "
" b i n a r y : b i n a r y - i n d e p b i n a r y - a r c h \ n "
" \ n "
" b i n a r y - i n d e p : b u i l d \ n "
" \ n "
" b i n a r y - a r c h : b u i l d \ n "
" c d $ ( B U I L D D I R ) ; c m a k e - D C O M P O N E N T = U n s p e c i f i e d - D C M A K E _ I N S T A L L _ P R E F I X = . . / d e b i a n / t m p / u s r - P c m a k e _ i n s t a l l . c m a k e \ n "
" m k d i r - p d e b i a n / t m p / D E B I A N \ n "
" d p k g - g e n s y m b o l s - p $ { C P A C K _ D E B I A N _ P A C K A G E _ N A M E } \ n "
)
foreach ( COMPONENT ${ CPACK_COMPONENTS_ALL } )
set ( PATH debian/ ${ COMPONENT } )
file ( APPEND ${ DEBIAN_RULES }
" c d $ ( B U I L D D I R ) ; c m a k e - D C O M P O N E N T = $ { C O M P O N E N T } - D C M A K E _ I N S T A L L _ P R E F I X = . . / $ { P A T H } / u s r - P c m a k e _ i n s t a l l . c m a k e \ n "
" m k d i r - p $ { P A T H } / D E B I A N \ n "
" d p k g - g e n s y m b o l s - p $ { C O M P O N E N T } - P $ { P A T H } \ n "
)
endforeach ( COMPONENT ${ CPACK_COMPONENTS_ALL } )
file ( APPEND ${ DEBIAN_RULES }
" d h _ s h l i b d e p s \ n "
" d h _ s t r i p \ n " # for reducing size
" d p k g - g e n c o n t r o l - p $ { C P A C K _ D E B I A N _ P A C K A G E _ N A M E } \ n "
" d p k g - - b u i l d d e b i a n / t m p . . \ n "
)
foreach ( COMPONENT ${ CPACK_COMPONENTS_ALL } )
set ( PATH debian/ ${ COMPONENT } )
file ( APPEND ${ DEBIAN_RULES }
" d p k g - g e n c o n t r o l - p $ { C O M P O N E N T } - P $ { P A T H } - T d e b i a n / $ { C O M P O N E N T } . s u b s t v a r s \ n "
" d p k g - - b u i l d $ { P A T H } . . \ n "
)
endforeach ( COMPONENT ${ CPACK_COMPONENTS_ALL } )
file ( APPEND ${ DEBIAN_RULES }
" \ n "
" c l e a n : \ n "
" r m - f b u i l d \ n "
" r m - r f $ ( B U I L D D I R ) \ n "
" \ n "
" . P H O N Y : b i n a r y b i n a r y - a r c h b i n a r y - i n d e p c l e a n \ n "
)
execute_process ( COMMAND chmod +x ${ DEBIAN_RULES } )
##############################################################################
# debian/compat
file ( WRITE ${ DEBIAN_SOURCE_DIR } /debian/compat "7" )
##############################################################################
# debian/source/format
file ( WRITE ${ DEBIAN_SOURCE_DIR } /debian/source/format "3.0 (quilt)" )
##############################################################################
# debian/changelog
set ( DEBIAN_CHANGELOG ${ DEBIAN_SOURCE_DIR } /debian/changelog )
execute_process ( COMMAND date -R OUTPUT_VARIABLE DATE_TIME )
file ( WRITE ${ DEBIAN_CHANGELOG }
" $ { C P A C K _ D E B I A N _ P A C K A G E _ N A M E } ( $ { R E L E A S E _ P A C K A G E _ V E R S I O N } ) $ { R E L E A S E } ; u r g e n c y = m e d i u m \ n \ n "
" * P a c k a g e b u i l t w i t h C M a k e \ n \ n "
" $ { C P A C K _ D E B I A N _ C H A N G E L O G } "
" - - $ { C P A C K _ P A C K A G E _ C O N T A C T } $ { D A T E _ T I M E } "
)
##############################################################################
# debuild -S
if ( DEB_SOURCE_CHANGES )
set ( DEBUILD_OPTIONS "-sd" )
else ( )
set ( DEBUILD_OPTIONS "-sa" )
endif ( )
set ( SOURCE_CHANGES_FILE "${CPACK_DEBIAN_PACKAGE_NAME}_${RELEASE_PACKAGE_VERSION}_source.changes" )
set ( DEB_SOURCE_CHANGES ${ DEB_SOURCE_CHANGES } "${SOURCE_CHANGES_FILE}" )
add_custom_command ( OUTPUT "${SOURCE_CHANGES_FILE}" COMMAND ${ DEBUILD_EXECUTABLE } -S ${ DEBUILD_OPTIONS } WORKING_DIRECTORY ${ DEBIAN_SOURCE_DIR } )
endforeach ( RELEASE ${ CPACK_DEBIAN_DISTRIBUTION_RELEASES } )
##############################################################################
# dput ppa:your-lp-id/ppa <source.changes>
add_custom_target ( dput ${ DPUT_EXECUTABLE } ${ DPUT_HOST } ${ DEB_SOURCE_CHANGES } DEPENDS ${ DEB_SOURCE_CHANGES } WORKING_DIRECTORY ${ CMAKE_BINARY_DIR } /Debian )