From 3bf4a635d4a89ad5e7670acffcca480f7b12e87c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Thu, 8 Jul 2021 13:53:50 +0200 Subject: [PATCH] Implement TEST=debians --- industrial_ci/src/tests/debians.sh | 64 ++++++++++++++++++++++++++++++ industrial_ci/src/util.sh | 5 +++ 2 files changed, 69 insertions(+) create mode 100644 industrial_ci/src/tests/debians.sh diff --git a/industrial_ci/src/tests/debians.sh b/industrial_ci/src/tests/debians.sh new file mode 100644 index 000000000..b4859e226 --- /dev/null +++ b/industrial_ci/src/tests/debians.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Copyright (c) 2021, Mathias Lüdtke +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Based on https://github.com/ros-industrial/industrial_ci/issues/697#issuecomment-876293987 + +function prepare_debians() { + true +} + +function build_and_install_debian() ( + local pkg_path=$1 + shift + cd "$pkg_path" + ici_quiet_echo bloom-generate rosdebian --ros-distro="$ROS_DISTRO" --debian-inc="ici~" + ici_quiet_echo dpkg-buildpackage -b -uc -us + mv ../*.{buildinfo,changes,deb} . + ici_quiet_echo ici_asroot dpkg -i *.deb +) + +function run_debians() { + export BUILDER=colcon + ici_source_builder + ici_run "${BUILDER}_setup" ici_quiet builder_setup + ici_run "setup_bloom" ici_quiet ici_install_pkgs_for_command bloom-generate python3-bloom debhelper + ici_run "setup_dpkg_dev" ici_quiet ici_install_pkgs_for_command dpkg-buildpackage dpkg-dev + + ici_run "setup_rosdep" ici_setup_rosdep + + if [ ! -f "$_ROS_KEYRING" ]; then + ici_run "setup_gpg_key" ici_setup_gpg_key + fi + + local ws + ici_make_temp_dir ws + + local sourcespace + ici_make_temp_dir sourcespace + + for name in upstream target downstream; do + local sources=() + local current="$sourcespace/$name" + ici_parse_env_array sources "${name^^}_WORKSPACE" + ici_run "prepare_${name}_sourcespace" ici_prepare_sourcespace "$current" "${sources[@]}" + ici_run "install_${name}_dependencies" ici_quiet ici_install_dependencies "$UNDERLAY" "$ROSDEP_SKIP_KEYS" "$sourcespace" + + while read -r -a pkg; do + ici_run "${pkg[0]}_debian" build_and_install_debian "$current/${pkg[1]}" + done < <(cd "$current" && colcon list -t) + done +} diff --git a/industrial_ci/src/util.sh b/industrial_ci/src/util.sh index 5ecc61842..f02a11aa8 100644 --- a/industrial_ci/src/util.sh +++ b/industrial_ci/src/util.sh @@ -313,6 +313,11 @@ function ici_quiet { return "$err" } +function ici_quiet_echo { + echo "Running '$*'..." + ici_quiet "$@" +} + function ici_asroot { if [ "$EUID" -ne 0 ] && command -v sudo > /dev/null; then sudo "$@"