Add script to generate Debian package files for static applications
authorHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 10 Feb 2016 15:55:48 +0000 (16:55 +0100)
committerHenning Rogge <henning.rogge@fkie.fraunhofer.de>
Wed, 10 Feb 2016 15:55:48 +0000 (16:55 +0100)
.gitignore
CMakeLists.txt
cmake/generate_archive.cmake
debian/compat [new file with mode: 0644]
debian/rules [new file with mode: 0644]
debian/source/format [new file with mode: 0644]
files/create_debian_package.sh [new file with mode: 0755]
src/olsrd2/debian_changelog [new file with mode: 0644]
src/olsrd2/debian_control [new file with mode: 0644]

index a7afb14..3e57424 100644 (file)
@@ -1,13 +1,13 @@
 /.cproject
 /.project
 /.settings
-/html
 /cmake/version.cmake
 /.kdev4/
 /*.kdev4
 /*.tar.gz
 /*.tar.bz2
 /*.zip
+/*.deb
 /doxygen_sqlite3.db
 /doxygen_objdb_*.tmp
 /doxygen_entrydb_*.tmp
index b94c410..6a4d99f 100644 (file)
@@ -44,6 +44,8 @@ ADD_CUSTOM_TARGET(targz  COMMAND ${CMAKE_COMMAND}
                                  -D BINARY:STRING=${PROJECT_BINARY_DIR}
                                  -D VERSION:STRING=${VERSION}
                                  -D FORMAT:STRING=tar.gz
+                                 -D TARBALL:STRING=${TARBALL}
+                                 -D TARPREFIX:STRING=${TARPREFIX}
                                  -P ${CMAKE_SOURCE_DIR}/cmake/generate_archive.cmake)
                                 
 ADD_CUSTOM_TARGET(tarbz2 COMMAND ${CMAKE_COMMAND}
@@ -51,12 +53,16 @@ ADD_CUSTOM_TARGET(tarbz2 COMMAND ${CMAKE_COMMAND}
                                  -D BINARY:STRING=${PROJECT_BINARY_DIR}
                                  -D VERSION:STRING=${VERSION}
                                  -D FORMAT:STRING=tar.bz2
+                                 -D TARBALL:STRING=${TARBALL}
+                                 -D TARPREFIX:STRING=${TARPREFIX}
                                  -P ${CMAKE_SOURCE_DIR}/cmake/generate_archive.cmake)
 ADD_CUSTOM_TARGET(zip    COMMAND ${CMAKE_COMMAND}
                                  -D SOURCE:STRING=${CMAKE_SOURCE_DIR}
                                  -D BINARY:STRING=${PROJECT_BINARY_DIR}
                                  -D VERSION:STRING=${VERSION}
                                  -D FORMAT:STRING=zip
+                                 -D TARBALL:STRING=${TARBALL}
+                                 -D TARPREFIX:STRING=${TARPREFIX}
                                  -P ${CMAKE_SOURCE_DIR}/cmake/generate_archive.cmake)
 
 #########################
index 980a6fc..857dd72 100644 (file)
@@ -23,9 +23,19 @@ FILE (COPY ${BINARY}/${VERSIONFILE} DESTINATION ${SOURCE})
 execute_process(COMMAND git add ${SOURCE}/${VERSIONFILE} WORKING_DIRECTORY ${SOURCE})
 execute_process(COMMAND git stash create OUTPUT_VARIABLE COMMIT WORKING_DIRECTORY ${SOURCE} OUTPUT_STRIP_TRAILING_WHITESPACE)
 
+IF (NOT TARBALL)
+    SET(TARBALL "${SOURCE}/oonf_${VERSION}.${FORMAT}")
+ENDIF (NOT TARBALL)
+
+IF (NOT TARPREFIX)
+    SET (TARPREFIX "oonf_${VERSION}")
+ENDIF (NOT TARPREFIX)
+
 # generate archive
-execute_process(COMMAND git archive --prefix=oonf_${VERSION}/ -o ${SOURCE}/oonf_${VERSION}.${FORMAT} ${COMMIT} WORKING_DIRECTORY ${SOURCE})
+execute_process(COMMAND git archive --prefix=${TARPREFIX}/ -o ${TARBALL} ${COMMIT} WORKING_DIRECTORY ${SOURCE})
 
 # remove version file
 FILE (REMOVE ${SOURCE}/${VERSIONFILE})
 execute_process(COMMAND git rm --quiet ${SOURCE}/${VERSIONFILE} WORKING_DIRECTORY ${SOURCE})
+
+message ("created ${TARBALL}")
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..ec63514
--- /dev/null
@@ -0,0 +1 @@
+9
diff --git a/debian/rules b/debian/rules
new file mode 100644 (file)
index 0000000..643487f
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/make -f
+%:
+       dh $@
+
+override_dh_auto_configure:
+       cmake   -D CMAKE_INSTALL_PREFIX=/usr \
+               -D CMAKE_VERBOSE_MAKEFILE=ON \
+               -D CMAKE_BUILD_TYPE=DEBUG \
+               -D OONF_LOGGING_LEVEL=debug \
+               -D OONF_NO_WERROR:Bool=true \
+               SOURCETOOLCHAIN \
+               SOURCEDIR
+
+override_dh_auto_install:
+       make -j1 install_TARGETNAME_static DESTDIR=INSTALLDESTDIR AM_UPDATE_INFO_DIR=no
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..163aaf8
--- /dev/null
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/files/create_debian_package.sh b/files/create_debian_package.sh
new file mode 100755 (executable)
index 0000000..12634ad
--- /dev/null
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+# store source directory
+SOURCE=$(git rev-parse --show-toplevel)
+
+# handle script input and variables
+: ${BUILD:=oonf_build_debian}
+
+BUILDDIR=/tmp/${BUILD}
+
+if [ "$#" -eq "0" ]
+then
+        TARGET=olsrd2
+else
+        TARGET=${1}
+fi
+
+if [ "${TOOLCHAIN}" != "" ]
+then
+    echo "Using toolchain file: ${TOOLCHAIN}"
+    TOOLCHAIN="-D CMAKE_TOOLCHAIN_FILE=`realpath ${TOOLCHAIN}`"
+fi
+
+if [ "${ARCH}" != "" ]
+then
+    echo "Using architecture: ${ARCH}"
+    ARCH="-a${ARCH}"
+fi
+
+# calculate version and tarball names
+VERSION=`git describe --abbrev=0| sed -e "s/^v//"`
+FULLVERSION=`git describe`
+
+TARPREFIX=${TARGET}_${VERSION}
+TARBALL=${BUILDDIR}/${TARPREFIX}.orig.tar.gz
+
+# check if target is there and prepared for a debian package
+if [ ! -d ${SOURCE}/src/${TARGET} ]
+then
+    echo "Could not find target '${TARGET}'"
+    exit 1
+fi
+
+if [ ! -f ${SOURCE}/src/${TARGET}/debian_changelog ]
+then
+    echo "Could not find target '${TARGET}' debian changelog"
+    exit 1
+fi
+
+# create clean build directory
+if [ -d ${BUILDDIR} ]
+then
+    echo "remove ${BUILDDIR}"
+    rm -r ${BUILDDIR}
+fi
+
+mkdir -p ${BUILDDIR}
+cd ${BUILDDIR}
+
+# create directory structure
+mkdir build
+
+# build tarball of current source
+cd build
+
+cmake -DTARBALL=${TARBALL} -DTARPREFIX=${TARPREFIX} ${SOURCE}
+make targz
+
+cd ${BUILDDIR}
+
+# uncompress tarball
+tar xf ${TARBALL}
+
+# build debian directory from template
+cd ${TARPREFIX}
+
+cp ${SOURCE}/src/${TARGET}/debian_changelog ./debian/changelog
+cp ${SOURCE}/src/${TARGET}/debian_control ./debian/control
+cp ${SOURCE}/files/default_licence.txt ./debian/copyright
+
+# adapt changelog template
+sed -i  -e "s@SHORTVERSION@${VERSION}@" \
+        -e "s@FULLVERSION@${FULLVERSION}@" \
+        -e "s@DATETIME@`date -R`@" \
+        ./debian/changelog
+
+# adapt rules template
+sed -i  -e "s@SOURCEDIR@${BUILDDIR}/${TARPREFIX}@" \
+        -e "s@SOURCETOOLCHAIN@${TOOLCHAIN}@" \
+        -e "s@TARGETNAME@${TARGET}@" \
+        -e "s@INSTALLDESTDIR@${BUILDDIR}/${TARPREFIX}/debian/${TARGET}@" \
+        ./debian/rules
+
+# create debian package
+debuild -us -uc ${ARCH}
+
+# copy package to source directory
+cp ${BUILDDIR}/*.deb ${SOURCE}
diff --git a/src/olsrd2/debian_changelog b/src/olsrd2/debian_changelog
new file mode 100644 (file)
index 0000000..0301812
--- /dev/null
@@ -0,0 +1,5 @@
+olsrd2 (SHORTVERSION-1) UNRELEASED; urgency=medium
+
+  * Git version FULLVERSION
+
+ -- Henning Rogge <henning.rogge@fkie.fraunhofer.de>  DATETIME
diff --git a/src/olsrd2/debian_control b/src/olsrd2/debian_control
new file mode 100644 (file)
index 0000000..0e93020
--- /dev/null
@@ -0,0 +1,12 @@
+Source: olsrd2
+Maintainer: Henning Rogge <henning.rogge@fkie.fraunhofer.de>
+Section: misc
+Priority: optional
+Standards-Version: 3.9.6
+Build-Depends: debhelper (>= 9)
+
+Package: olsrd2
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: routing agent for OLSRv2 routing protocol
+ see http://www.olsr.org for more information