-
Notifications
You must be signed in to change notification settings - Fork 24
/
prepare
executable file
·89 lines (73 loc) · 3.23 KB
/
prepare
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
#!/bin/sh
# SPDX-License-Identifier: BSD-3-Clause
# defaults
. /etc/os-release
DEB_DISTRO="${DEB_DISTRO:-$VERSION_CODENAME}"
DEB_ARCH="${DEB_ARCH:-$(dpkg --print-architecture)}"
while getopts a:d:h OPTCHAR; do
case "$OPTCHAR" in
a)
DEB_ARCH="$OPTARG"
;;
d)
DEB_DISTRO="$OPTARG"
;;
h)
echo "usage: $0 [-a] [-d]"
echo " -a To specify the architecture of the chroot."
echo " -d To specify the distribution of the chroot."
exit
;;
*)
echo "Error parsing arguments"
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
echo "Install dependencies"
set -ex
test "$VERSION_CODENAME" = "jammy" && sudo cp "$(dirname "$0")/jammy-sbuild.sources" /etc/apt/sources.list.d/
test "$VERSION_CODENAME" = "noble" && sudo cp "$(dirname "$0")/noble-ros.sources" /etc/apt/sources.list.d/
sudo apt update
sudo DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends sbuild mmdebstrap distro-info debian-archive-keyring ccache uidmap curl git-lfs
if [ "$DEB_ARCH" != "$(dpkg --print-architecture)" ]; then
# use qemu to translate architecture
sudo apt install -y --no-install-recommends qemu-user-static arch-test
if [ "$VERSION_CODENAME" = "jammy" ]; then
# manally enable binfmt_misc on Ubuntu 22.04 Docker images
sudo apt install -y --no-install-recommends binfmt-support
arch-test "$DEB_ARCH" || sudo update-binfmts --enable
fi
fi
# Try different package combinations:
# first is for a clean jammy with the PPA
# second is for Debian bookworm and newer
# third is for OSRF package names
# TODO: get OSRF to add proper package relations
sudo DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends vcstool python3-rosdep2 catkin python3-bloom || \
sudo DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends vcstool python3-rosdep2 colcon python3-colcon-package-information python3-colcon-ros python3-bloom || \
sudo DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends python3-vcstool python3-rosdep python3-colcon-cmake python3-colcon-installed-package-information python3-colcon-library-path python3-colcon-package-information python3-colcon-pkg-config python3-colcon-recursive-crawl python3-colcon-test-result python3-bloom
echo "Setup build environment"
mkdir -p "$HOME/.cache/sbuild"
mmdebstrap --variant=buildd --include=apt,ccache,ca-certificates --arch="$DEB_ARCH" \
--customize-hook='chroot "$1" update-ccache-symlinks' \
--components=main,universe "$DEB_DISTRO" "$HOME/.cache/sbuild/$DEB_DISTRO-$DEB_ARCH.tar"
ccache --zero-stats --max-size=10.0G
# allow ccache access from sbuild
chmod a+X "$HOME" "$HOME/.cache"
chmod -R a+rwX "$HOME/.cache/ccache"
cat << "EOF" > "$HOME/.sbuildrc"
$build_environment = { "CCACHE_DIR" => "/build/ccache" };
$path = "/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games";
$build_path = "/build/package/";
$dsc_dir = "package";
$unshare_bind_mounts = [ { directory => "$HOME/.cache/ccache", mountpoint => "/build/ccache" } ];
$verbose = 1;
EOF
echo "$SBUILD_CONF" >> "$HOME/.sbuildrc"
test -z "$REPOS_FILE" -a ! -f sources.repos && exit
REPOS_FILE="${REPOS_FILE:-sources.repos}"
echo "Checkout workspace"
mkdir src
vcs import --recursive --input "$REPOS_FILE" src