diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93ad78fa..cc0b452d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: | @@ -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 diff --git a/DEBIAN/control.in b/DEBIAN/control.in new file mode 100644 index 00000000..03112359 --- /dev/null +++ b/DEBIAN/control.in @@ -0,0 +1,11 @@ +Package: zcm +Version: @version@ +Maintainer: Jonathan Bendes +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. + diff --git a/DEBIAN/wscript b/DEBIAN/wscript new file mode 100644 index 00000000..90484a9a --- /dev/null +++ b/DEBIAN/wscript @@ -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) diff --git a/config/zcm-tools.pc.in b/config/zcm-tools.pc.in index fc9a9a11..8a8d0121 100644 --- a/config/zcm-tools.pc.in +++ b/config/zcm-tools.pc.in @@ -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 diff --git a/config/zcm.pc.in b/config/zcm.pc.in index e54376d1..21f196bd 100644 --- a/config/zcm.pc.in +++ b/config/zcm.pc.in @@ -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 diff --git a/scripts/make_debian_package.sh b/scripts/make_debian_package.sh new file mode 100755 index 00000000..2f71fb92 --- /dev/null +++ b/scripts/make_debian_package.sh @@ -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 diff --git a/waftools/strip_on_install.py b/waftools/strip_on_install.py new file mode 100644 index 00000000..9990b814 --- /dev/null +++ b/waftools/strip_on_install.py @@ -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 + diff --git a/wscript b/wscript index 3884e1e1..dce43a9c 100644 --- a/wscript +++ b/wscript @@ -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'] @@ -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)