|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) Murilo M. Marinho (www.murilomarinho.info) |
| 3 | +set -e |
| 4 | + |
| 5 | +#################################################################### |
| 6 | +# Helper functions and parameters |
| 7 | +#################################################################### |
| 8 | + |
| 9 | +# Change this to define the number of parallel jobs for this builder |
| 10 | +export DEB_BUILD_OPTIONS=parallel=4 |
| 11 | + |
| 12 | +# ROS2 version |
| 13 | +rosv="jazzy" |
| 14 | +# Ubuntu version |
| 15 | +ubuntuv="noble" |
| 16 | +# Architecture |
| 17 | +archname="amd64" |
| 18 | + |
| 19 | +PRE_BUILD() { |
| 20 | +# Remove the debian folder just in case. In ROS1 and catkin this was an issue |
| 21 | +rm -rf debian |
| 22 | +# Use the --all just in case, otherwise it returns with an error if there are multiple commits without a changelog |
| 23 | +# wow, with the --all it also complains if the package already has a changelog. Nice, thanks a lot |
| 24 | +catkin_generate_changelog --all || true |
| 25 | +catkin_generate_changelog || true |
| 26 | +# If we don't commit the modified CHANGELOG.rst, the catkin_prepare_release doesn't shut up about it |
| 27 | +git add CHANGELOG.rst |
| 28 | +git commit -a -m "Shut up catkin" |
| 29 | +# Apparently this doesn't work for python-only packages, but we not care cause we cmake boyz |
| 30 | +catkin_prepare_release --no-push -y --version "$VERSION" |
| 31 | +# Automagically create the debian packagking directives |
| 32 | +bloom-generate rosdebian --os-name ubuntu --os-version "$ubuntuv" --ros-distro "rosv" |
| 33 | +} |
| 34 | + |
| 35 | +BUILD_DEB(){ |
| 36 | +# Parallel builds |
| 37 | +sed -i -e 's/dh $@/dh $@ --parallel/g' debian/rules |
| 38 | +# A hack so that shlibdeps does not complain about qpOases not being a ubuntu package. Well, it is being installed purely using CMAKE. |
| 39 | +# This might create other problems, but for now we worry about being able build the package at all. |
| 40 | +sed -i -e 's/dh_shlibdeps /dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info /g' debian/rules |
| 41 | +fakeroot debian/rules binary |
| 42 | +} |
| 43 | + |
| 44 | +#################################################################### |
| 45 | +# Array of packages |
| 46 | +#################################################################### |
| 47 | +pkg_array=( |
| 48 | +"sas_core" |
| 49 | +"sas_msgs" |
| 50 | +"sas_common" |
| 51 | +"sas_conversions" |
| 52 | +"sas_datalogger" |
| 53 | +"sas_robot_driver" |
| 54 | +"sas_robot_kinematics" |
| 55 | +) |
| 56 | + |
| 57 | +#################################################################### |
| 58 | +# Create tmp folder |
| 59 | +#################################################################### |
| 60 | + |
| 61 | +rm -rf tmp_ros2 |
| 62 | +mkdir tmp_ros2 |
| 63 | +cd tmp_ros2 |
| 64 | + |
| 65 | +#################################################################### |
| 66 | +# Clone all packages |
| 67 | +#################################################################### |
| 68 | + |
| 69 | +#Example "git@github.com:SmartArmStack/sas_core.git" |
| 70 | +for pkg_name in "${pkg_array[@]}"; do |
| 71 | + echo "Cloning ${pkg_name}" |
| 72 | + git clone -b "$rosv" git@github.com:SmartArmStack/"$pkg_name".git --recurse-submodules |
| 73 | +done |
| 74 | + |
| 75 | +#################################################################### |
| 76 | +# Define version number |
| 77 | +#################################################################### |
| 78 | + |
| 79 | +# Remove any leading zeros otherwise the version name will not fit the bloom requirements |
| 80 | +# https://unix.stackexchange.com/questions/79371/removing-leading-zeros-from-date-output |
| 81 | +VERSION=$(date +"%-y.%-m.%-d%H%M%S") |
| 82 | + |
| 83 | +#################################################################### |
| 84 | +# Remove current installation |
| 85 | +#################################################################### |
| 86 | + |
| 87 | +# Remove all related packages. The || true is so that it doesn't annoy us when something wasn't installed to begin with. |
| 88 | +sudo apt remove ros-"$rosv"-sas* -y || true |
| 89 | + |
| 90 | +#################################################################### |
| 91 | +# Build and install incrementally |
| 92 | +#################################################################### |
| 93 | + |
| 94 | +for pkg_name in "${pkg_array[@]}"; do |
| 95 | + echo "Building ${pkg_name}" |
| 96 | + cd "$pkg_name" |
| 97 | + PRE_BUILD |
| 98 | + BUILD_DEB |
| 99 | + cd .. |
| 100 | + # Install package but replace _ by -. E.g. sas_core becomes sas-core. |
| 101 | + # https://stackoverflow.com/questions/3306007/replace-a-string-in-shell-script-using-a-variable |
| 102 | + sudo dpkg -i ros-"$rosv"-"${pkg_name//_/-}"_*"$ubuntuv"_"$archname".deb |
| 103 | + ${var//12345678/$replace} |
| 104 | +done |
0 commit comments