Skip to content

Commit 8389d63

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
container: update build.sh with ability to install dependencies
Most of the logic around building and testing sambacc was in the build.sh script already, so why not include the ability to install the os packages too. When called with `--install` as the first argument instead of a revision id, we assume that the script is being called specifically and only to install the package dependencies. Signed-off-by: John Mulligan <[email protected]>
1 parent f426c23 commit 8389d63

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

tests/container/build.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,59 @@ setup_update() {
7979
fi
8080
}
8181

82+
task_sys_deps() {
83+
info "installing system packages"
84+
OS_VER=$(source /etc/os-release && echo "${ID}-${VERSION_ID}")
85+
case "${OS_VER}" in
86+
centos*)
87+
info "detected centos (stream): ${OS_VER}"
88+
use_centos=true
89+
;;
90+
fedora*)
91+
info "detected fedora: ${OS_VER}"
92+
use_centos=
93+
;;
94+
*)
95+
info "unknown platform: ${OS_VER}"
96+
return 1
97+
;;
98+
esac
99+
100+
yum_args=("--setopt=install_weak_deps=False")
101+
pkgs=(\
102+
git \
103+
mercurial \
104+
python-pip \
105+
python-pip-wheel \
106+
python-setuptools \
107+
python-setuptools-wheel \
108+
python-tox \
109+
python3-samba \
110+
python3-wheel \
111+
python3-pyxattr \
112+
python3-devel \
113+
python3.9 \
114+
samba-common-tools \
115+
rpm-build \
116+
'python3dist(flake8)' \
117+
'python3dist(inotify-simple)' \
118+
'python3dist(mypy)' \
119+
'python3dist(pytest)' \
120+
'python3dist(pytest-cov)' \
121+
'python3dist(setuptools-scm)' \
122+
'python3dist(tox-current-env)' \
123+
'python3dist(wheel)' \
124+
)
125+
126+
if [ "$use_centos" ]; then
127+
yum install -y epel-release
128+
yum_args=(--enablerepo=crb)
129+
pkgs+=(pyproject-rpm-macros)
130+
fi
131+
yum "${yum_args[@]}" install -y "${pkgs[@]}"
132+
yum clean all
133+
}
134+
82135
task_test_tox() {
83136
# Run tox with sitepackages enabled to allow access to system installed samba
84137
# modules. The container env already provides us control over the env.
@@ -150,7 +203,23 @@ export WRITABLE_PASSWD=yes
150203
export NSS_WRAPPER_PASSWD=/etc/passwd
151204
export NSS_WRAPPER_GROUP=/etc/group
152205

206+
# when called with --install as the first argument, go into a special mode
207+
# typically used to just install the container's dependency packages
208+
if [[ "$1" = "--install" ]]; then
209+
task_sys_deps
210+
exit $?
211+
fi
212+
213+
# if critical packages (currently just git) are missing we assume that
214+
# we need to automatically enable the task_sys_deps step.
215+
# this step is not enabled by default due to the overhead that updating
216+
# the dnf repos creates on the overall build time.
217+
if ! command -v git &>/dev/null ; then
218+
tasks="$tasks task_sys_deps"
219+
fi
220+
153221

222+
chk task_sys_deps
154223
setup_fetch "$2"
155224
cd "${bdir}"
156225
setup_update "$1"

0 commit comments

Comments
 (0)