This repository is currently being migrated. It's locked while the migration is in progress.
forked from jspricke/ros-deb-builder-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·137 lines (115 loc) · 5 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/sh
# SPDX-License-Identifier: BSD-3-Clause
while getopts cd:hr: OPTCHAR; do
case "$OPTCHAR" in
c)
CONTINUE_PACKAGE_GENERATION=1
;;
d)
DEB_DISTRO="$OPTARG"
;;
h)
echo "usage: $0 [-c]"
echo " -c To continue at the last package and skip those already built."
echo " -d The Debian/Ubuntu distribution codename to compile for."
echo " -r The ROS distribution codename to compile for."
exit
;;
r)
ROS_DISTRO="$OPTARG"
;;
*)
echo "Error parsing arguments"
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
# make output directory
test -z "$CONTINUE_PACKAGE_GENERATION" && rm -rf apt_repo
mkdir -p apt_repo
APT_REPO="$(pwd)/apt_repo"
if [ -z "$DISTRIBUTION" ]; then
if debian-distro-info --all | grep -q "$DEB_DISTRO"; then
DISTRIBUTION=debian
elif ubuntu-distro-info --all | grep -q "$DEB_DISTRO"; then
DISTRIBUTION=ubuntu
else
echo "Unknown DEB_DISTRO: $DEB_DISTRO"
exit 1
fi
fi
case $ROS_DISTRO in
debian)
;;
boxturtle|cturtle|diamondback|electric|fuerte|groovy|hydro|indigo|jade|kinetic|lunar)
echo "Unsupported ROS 1 version: $ROS_DISTRO"
exit 1
;;
melodic|noetic)
BLOOM=ros
ROS_DEB="$ROS_DISTRO-"
if [ -z "$SKIP_ROS_REPOSITORY" ]; then
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o "$APT_REPO/ros-archive-keyring.gpg"
set -- --extra-repository="deb http://packages.ros.org/ros/ubuntu $DEB_DISTRO main" --extra-repository-key="$APT_REPO/ros-archive-keyring.gpg" "$@"
fi
;;
*)
# assume ROS 2 so we don't have to list versions
BLOOM=ros
ROS_DEB="$ROS_DISTRO-"
if [ -z "$SKIP_ROS_REPOSITORY" ]; then
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o "$APT_REPO/ros-archive-keyring.gpg"
set -- --extra-repository="deb http://packages.ros.org/ros2/ubuntu $DEB_DISTRO main" --extra-repository-key="$APT_REPO/ros-archive-keyring.gpg" "$@"
fi
;;
esac
echo "Add unreleased packages to rosdep"
set -ex
for PKG in $(catkin_topological_order --only-names || colcon list --topological-order --names-only); do
printf "%s:\n %s:\n - %s\n" "$PKG" "$DISTRIBUTION" "ros-$ROS_DEB$(printf '%s' "$PKG" | tr '_' '-')" >> "$APT_REPO/local.yaml"
done
echo "yaml file://$APT_REPO/local.yaml $ROS_DISTRO" > "$APT_REPO/1-local.list"
echo "$ROSDEP_SOURCE" > "$APT_REPO/2-remote.list"
ROS_HOME="$APT_REPO/ros" ROSDEP_SOURCE_PATH="$APT_REPO:/etc/ros/rosdep/sources.list.d/" rosdep update
echo "Run sbuild"
# Workaround: If the /etc/subuid, /etc/subgid is empty file, the sbuild fails
(cat /etc/subuid | grep $(whoami)) || (echo "$(whoami):165536:65536" | sudo tee -a /etc/subuid)
(cat /etc/subgid | grep $(whoami)) || (echo "$(whoami):165536:65536" | sudo tee -a /etc/subgid)
# Workaround: If the /dev/console does not exist, the error message is constantly displayed during running sbuild
test -e /dev/console || sudo ln -s /dev/null /dev/console
# Don't build tests
export DEB_BUILD_OPTIONS=nocheck
TOTAL="$( (catkin_topological_order --only-names || colcon list --topological-order --names-only) | wc -l)"
COUNT=1
for PKG_PATH in $(catkin_topological_order --only-folders || colcon list --topological-order --paths-only); do
echo "::group::Building $COUNT/$TOTAL: $PKG_PATH"
(
cd "$PKG_PATH"
ROS_PACKAGE="$(catkin_topological_order --only-names || colcon list --topological-order --names-only)"
test -f "$PKG_PATH/CATKIN_IGNORE" && echo "$ROS_PACKAGE Skipped (CATKIN_IGNORE)" && exit
test -f "$PKG_PATH/COLCON_IGNORE" && echo "$ROS_PACKAGE Skipped (COLCON_IGNORE)" && exit
case " $SKIP_PACKAGES " in *" $ROS_PACKAGE "*) echo "$ROS_PACKAGE Skipped (in \$SKIP_PACKAGES)"; exit ;; esac
GENERATED_DEBIAN_PACKAGE="ros-${ROS_DEB}$( echo "$ROS_PACKAGE" | tr '_' '-')"
if [ -n "$CONTINUE_PACKAGE_GENERATION" ] && ls "$APT_REPO/${GENERATED_DEBIAN_PACKAGE}_"*.deb >/dev/null 2>&1; then
echo " Skipping already generated package: ${GENERATED_DEBIAN_PACKAGE}"
exit
fi
ROS_HOME="$APT_REPO/ros" BLOOM_SKIP_ROSDEP_UPDATE=1 bloom-generate "${BLOOM}debian" --os-name="$DISTRIBUTION" --os-version="$DEB_DISTRO" --ros-distro="$ROS_DISTRO"
# Set the version based on the checked out tag that contain at least on digit
# strip any leading non digits as they are not part of the version number
sed -i "1 s@([^)]*)@($( (git describe --tag --match "*[0-9]*" 2>/dev/null || echo 0) | sed -e 's@^[^0-9]*@@' -e 's@_@~@g')-$(date +%Y.%m.%d.%H.%M))@" debian/changelog
# https://github.com/ros-infrastructure/bloom/pull/643
echo 11 > debian/compat
# dpkg-source-opts: no need for upstream.tar.gz
sbuild --chroot-mode=unshare --no-clean-source --no-run-lintian \
--dpkg-source-opts="-Zgzip -z1 --format=1.0 -sn" --build-dir="$APT_REPO" \
--extra-package="$APT_REPO" "$@"
rm -f debian/rules debian/compat debian/changelog debian/control debian/copyright debian/source/format debian/source/options
rmdir -p debian/source || true
)
COUNT=$((COUNT+1))
echo "::endgroup::"
done
rm -r "$APT_REPO/ros"
ccache -sv