Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deb packaging #299

Merged
merged 11 commits into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ jobs:
build:
name: Create Release
runs-on: ubuntu-16.04
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout code
uses: actions/checkout@master
- name: env
run: |
echo "::add-path::$(pwd)/deps/julia/bin"
- name: deps
run: ./scripts/install-deps.sh -i -s
- name: Build Deb
id: builddeb
run: |
./scripts/make_debian_package.sh
echo "::set-output name=pkgpath::$(find build -name '*.deb')"
echo "::set-output name=pkgname::$(basename $(find build -name '*.deb'))"
- name: Read CHANGELOG
id: changelog
run: |
Expand All @@ -20,10 +34,20 @@ jobs:
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.changelog.outputs.body }}
draft: true
prerelease: true
draft: false
prerelease: false
- name: Upload Deb
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.builddeb.outputs.pkgpath }}
asset_name: ${{ steps.builddeb.outputs.pkgname }}
asset_content_type: application/octet-stream
11 changes: 11 additions & 0 deletions DEBIAN/control.in
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.

9 changes: 9 additions & 0 deletions DEBIAN/wscript
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)
2 changes: 1 addition & 1 deletion config/zcm-tools.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ jardir=${datarootdir}/java
Name: zcm
Description: Zero Communications and Marshalling (ZCM) Java Tools
Requires:
Version: 1.0.0
Version: @version@
classpath=${jardir}/zcm-tools.jar
2 changes: 1 addition & 1 deletion config/zcm.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jardir=${datarootdir}/java
Name: zcm
Description: Zero Communications and Marshalling (ZCM)
Requires:
Version: 1.0.0
Version: @version@
Libs: -L${libdir} -lzcm
Cflags: -I${includedir}
classpath=${jardir}/zcm.jar
72 changes: 72 additions & 0 deletions scripts/make_debian_package.sh
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
20 changes: 20 additions & 0 deletions waftools/strip_on_install.py
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

3 changes: 3 additions & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def configure(ctx):
ctx.load('compiler_c')
ctx.load('compiler_cxx')
ctx.recurse('config')
ctx.load('strip_on_install')

ctx.env.variantsEnabledByConfigure = ['examples', 'tests']

Expand Down Expand Up @@ -414,6 +415,8 @@ def build(ctx):
ctx.recurse('config')
ctx.recurse('gen')
ctx.recurse('tools')
ctx.recurse('DEBIAN')
ctx.install_as('${PREFIX}/share/doc/zcm/copyright', 'LICENSE')
generate_signature(ctx)


Expand Down