summaryrefslogtreecommitdiff
path: root/ci/ciimage/gentoo/install.sh
blob: c1e15efbfaee8fe3d01e4fb37273bb779550deec (plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
set -e

source /ci/common.sh

# We divide the package list into 'pkgs_stable' and 'pkgs_latest'. The trade-off
# is that latest stuff may not have a binpkg available, but of course we get
# better test coverage with the bleeding edge then.
pkgs_stable=(
  app-portage/portage-utils
  dev-build/cmake
  dev-vcs/git

  # language support
  dev-python/cython
  dev-python/lxml
  dev-python/pip
  virtual/fortran
  dev-lang/nasm
  dev-lang/vala
  dev-lang/python:2.7
  dev-java/openjdk-bin
  dev-util/bindgen

  dev-libs/elfutils
  dev-libs/protobuf

  # modules
  dev-util/gdbus-codegen
  dev-util/glib-utils
  dev-libs/gobject-introspection
  dev-util/itstool
  dev-util/wayland-scanner
  dev-libs/wayland-protocols
  dev-libs/wayland

  # custom deps
  dev-libs/boost
  net-libs/libpcap
  dev-util/gtk-doc
  media-libs/libwmf
  sys-cluster/openmpi
  sci-libs/netcdf
  media-libs/libsdl2
  dev-cpp/gtest
  sci-libs/hdf5
  dev-qt/linguist-tools
  dev-qt/qtwidgets:5
  llvm-core/llvm
  dev-qt/qtdeclarative:6
  dev-qt/qttools
  net-print/cups
  dev-util/vulkan-headers
  media-libs/vulkan-loader

  # misc
  app-admin/sudo
  app-text/doxygen
  sys-devel/bison
  sys-devel/reflex
  sys-devel/gettext
  # needed by vala
  x11-libs/gtk+

  # TODO: vulkan-validation-layers
  # TODO: cuda
  #dev-cpp/gtkmm:3.0
  #dev-java/openjdk-bin:8
  #dev-lang/go
  #dev-lang/mono
  #dev-lang/python
  #dev-lang/rust-bin
  #dev-libs/wayland
  #dev-libs/wayland-protocols
  #dev-python/pypy3
  #dev-vcs/mercurial
  #gnustep-base/gnustep-base
  #media-gfx/graphviz
  #sci-libs/netcdf-fortran
  #llvm-core/clang
  #x11-libs/gtk+:3
)
pkgs_latest=(
  dev-build/autoconf
  dev-build/automake

  # ~arch only
  sci-libs/scalapack
)
pkgs=( "${pkgs_stable[@]}" "${pkgs_latest[@]}" )

emerge-webrsync --quiet

# This means we can't really take advantage of the binhost but a lot of the
# advantages of using Gentoo in CI come from the bleeding edge side.
# With full ~arch, we don't get binpkgs for much at all. Instead, let's just
# do ~arch for the test deps we have.
#echo 'ACCEPT_KEYWORDS="~amd64"' >> /etc/portage/make.conf

printf "%s\n" ${pkgs[@]} >> /var/lib/portage/world
printf "%s\n" ${pkgs_latest[@]} >> /etc/portage/package.accept_keywords/meson
cat /etc/portage/package.accept_keywords/meson

cat <<-EOF > /etc/portage/package.accept_keywords/misc
	dev-lang/python
EOF

mkdir /etc/portage/binrepos.conf || true
mkdir /etc/portage/profile || true
cat <<-EOF > /etc/portage/package.use/ci
	dev-cpp/gtkmm X
	media-libs/libglvnd X
	media-libs/freetype harfbuzz
	x11-libs/cairo X
	x11-libs/libxkbcommon X
	dev-lang/rust clippy rustfmt
	dev-lang/rust-bin clippy rustfmt
	dev-libs/boost python
	sci-libs/hdf5 cxx

	# slimmed binpkg, nomesa
	media-libs/libsdl2 -opengl -wayland -alsa -dbus -gles2 -udev -vulkan

	# Some of these settings are needed just to get the binpkg but
	# aren't negative to have anyway
	sys-devel/gcc ada d jit
	>=sys-devel/gcc-13 ada objc objc++
	sys-devel/gcc pgo lto

	sys-libs/zlib static-libs
EOF

cat <<-EOF >> /etc/portage/make.conf
	EMERGE_DEFAULT_OPTS="--complete-graph --quiet=y --quiet-build=y --jobs=$(nproc) --load-average=$(nproc)"
	EMERGE_DEFAULT_OPTS="\${EMERGE_DEFAULT_OPTS} --autounmask-write --autounmask-continue --autounmask-keep-keywords=y --autounmask-use=y"
	EMERGE_DEFAULT_OPTS="\${EMERGE_DEFAULT_OPTS} --binpkg-respect-use=y"

	# prevent painfully verbose Github Actions logs.
	FETCHCOMMAND='wget --no-show-progress -t 3 -T 60 --passive-ftp -O "\\\${DISTDIR}/\\\${FILE}" "\\\${URI}"'

	# Fortran is no longer enabled by default in 23.0, but we do need and use it.
	USE="\${USE} fortran"

	FEATURES="\${FEATURES} parallel-fetch parallel-install -merge-sync"
	FEATURES="\${FEATURES} getbinpkg binpkg-request-signature"

	# These don't work in Docker, so reduce noise in logs
	FEATURES="\${FEATURES} -ipc-sandbox -network-sandbox -pid-sandbox"
EOF

# Maybe we could enable all Pythons / add multiple jobs with diff. Python impls?
#echo '*/* PYTHON_TARGETS: python3_10 python3_11 python3_12' >> /etc/portage/package.use/python

# The below is for cases where we want non-default Python (either to get
# better coverage from something older, or something newer)
#echo '*/* PYTHON_TARGETS: python3_12' >> /etc/portage/package.use/python
#cat <<-EOF >> /etc/portage/profile/use.mask
#-python_targets_python3_12
#-python_single_target_python3_12
#EOF
#cat <<-EOF >> /etc/portage/profile/use.stable.mask
#-python_targets_python3_12
#-python_single_target_python3_12
#EOF

echo 'dev-lang/python ensurepip' >> /etc/portage/package.use/python

# Silly mono circular dep
#USE=minimal emerge --oneshot dev-lang/mono

# If we don't want to do this, we could use the 'portage' container instead
# so the stage3/repo match.
emerge --update --deep --changed-use @world
qlop -d 'yesterday'

env-update && . /etc/profile

rm /usr/lib/python/EXTERNALLY-MANAGED
python3 -m ensurepip
install_python_packages
python3 -m pip install "${base_python_pkgs[@]}"

echo "source /etc/profile" >> /ci/env_vars.sh

# For inexplicable reasons, Gentoo only packages valac as valac-$(version) so
# no software can locate it. Parse the installed version out of portage and
# export it to meson.
VALA_VER=$(portageq best_version / dev-lang/vala)
VALA_VER=${VALA_VER#dev-lang/vala-}
VALA_VER=${VALA_VER%.*}
echo "export VALAC=/usr/bin/valac-${VALA_VER}" >> /ci/env_vars.sh
echo "export VAPIGEN=/usr/bin/vapigen-${VALA_VER}" >> /ci/env_vars.sh

# Cleanup to avoid including large contents in the docker image.
# We don't need cache files that are side artifacts of installing packages.
# We also don't need the gentoo tree -- the official docker image doesn't
# either, and expects you to use emerge-webrsync once you need it.
rm -rf /var/cache/binpkgs
rm -rf /var/cache/distfiles
rm -rf /var/db/repos/gentoo