-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from ZeroCM/deb-packaging
Deb packaging
- Loading branch information
Showing
8 changed files
with
144 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Package: zcm | ||
Version: @version@ | ||
Maintainer: Jonathan Bendes <[email protected]> | ||
Section: devel | ||
Priority: optional | ||
Build-Essential: yes | ||
Architecture: amd64 | ||
Depends: default-jre, libzmq5, python, python3, libc6, libelf1 | ||
Description: Zero Communications and Marshalling Library | ||
Communication middleware for various transport layers. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /usr/bin/env python | ||
# encoding: utf-8 | ||
from waflib import Utils | ||
|
||
def build(ctx): | ||
ctx(features='subst', | ||
source='control.in', | ||
target='control', | ||
always=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
## SETUP | ||
|
||
# In this directory we assemble the deb package. Later we call dpkg-deb on it to pack the package. | ||
DEB_PACKAGE_ASSEMBLY_DIR=./build/deb_package_root | ||
mkdir -p $DEB_PACKAGE_ASSEMBLY_DIR/usr/ | ||
|
||
# Required to find java | ||
if [ -z ${JAVA_HOME+x} ]; then | ||
export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") | ||
fi | ||
|
||
# Change to the directory containing the source code | ||
THISDIR=$(dirname "$(readlink -f "$0")") | ||
BASEDIR=$(dirname $THISDIR) | ||
cd $BASEDIR | ||
|
||
|
||
## BUILD | ||
|
||
./waf configure distclean | ||
|
||
# Build with python2 support and install to temporary $DEB_PACKAGE_ASSEMBLY_DIR/usr directory | ||
export PYTHON=/usr/bin/python2 | ||
./waf configure --use-all --use-third-party --prefix=$DEB_PACKAGE_ASSEMBLY_DIR/usr/ | ||
./waf build | ||
./waf install | ||
|
||
# Build again for python3 and install to the temporary $DEB_PACKAGE_ASSEMBLY_DIR/usr directory. | ||
# Note 1: This overrides most of the already existing files except for the python2 | ||
# files in usr/lib/python2.7 <- this is to be considered an ugly hack but | ||
# I found no other way to make waf build for python2 AND python3 | ||
# Note 2: we use --targets=pyzcm to hopefully not build everything again | ||
export PYTHON=/usr/bin/python3 | ||
./waf configure --use-all --use-third-party --prefix=$DEB_PACKAGE_ASSEMBLY_DIR/usr/ | ||
./waf build --targets=pyzcm | ||
./waf install | ||
|
||
|
||
### HACKS TO PREPARE DEBIAN PACKAGE STRUCTURE | ||
|
||
# Move the debian control files directory to the temporary $DEB_PACKAGE_ASSEMBLY_DIR | ||
cp -r ./build/DEBIAN $DEB_PACKAGE_ASSEMBLY_DIR | ||
|
||
|
||
cd $DEB_PACKAGE_ASSEMBLY_DIR | ||
# Unfortunately waf automatically installs to 'pythonX.X/site-packages' as soon as the | ||
# root directory is not contained in the install prefix. | ||
# We need it in 'dist-packages' so we just rename it manually here. | ||
# Note: since this modifies the folder structure that 'find' is iterating, it causes | ||
# find to print an error such as: | ||
# "find: ‘./usr/lib/python3.6/site-packages’: No such file or directory". | ||
# It works anyways ... | ||
find -type d -wholename '*python*/site-packages' -execdir mv ./site-packages ./dist-packages \; || true | ||
|
||
# There are a number of files in which the install prefix appears such as the java | ||
# launchers in usr/bin and the package-config files. | ||
# This is undesirable since the temporary install prefix in $DEB_PACKAGE_ASSEMBLY_DIR | ||
# is obviously wrong after the files have been installed. | ||
# The following lines replaces all occurences of the $DEB_PACKAGE_ASSEMBLY_DIR as | ||
# path with '/usr' which is our actual install prefix with the debian package. | ||
find -type f -exec sed -i "s+$PWD++g" {} + | ||
cd - | ||
|
||
### PACK DEBIAN PACKAGE | ||
## Debian compliance: fakeroot is required to get correct uids and gids for all installed files | ||
fakeroot dpkg-deb -b $DEB_PACKAGE_ASSEMBLY_DIR | ||
dpkg-name $DEB_PACKAGE_ASSEMBLY_DIR.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /usr/bin/env python | ||
|
||
""" | ||
Strip executables upon installation | ||
""" | ||
|
||
import shutil, os | ||
from waflib import Build, Utils, Context | ||
|
||
def copy_fun(self, src, tgt): | ||
if Utils.is_win32 and len(tgt) > 259 and not tgt.startswith('\\\\?\\'): | ||
tgt = '\\\\?\\' + tgt | ||
shutil.copy2(src, tgt) | ||
os.chmod(tgt, self.chmod) | ||
|
||
if getattr(self.generator, 'link_task', None): | ||
if self.generator.link_task.outputs[0] in self.inputs: | ||
self.generator.bld.cmd_and_log('strip %s' % tgt, quiet=Context.BOTH) | ||
Build.inst.copy_fun = copy_fun | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters