Skip to content

Commit 8142820

Browse files
Merge branch 'main' into 380-is-arch_gen-archgen-backend-used-anymore
2 parents fd312c9 + 61c0e72 commit 8142820

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

bin/build_container

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ if [ -v GITHUB_ACTIONS ]; then
99
CONTAINER_PATH=${ROOT}/.singularity/image.sif
1010
HOME_PATH=${GITHUB_WORKSPACE}
1111
SINGULARITY_CACHE=--disable-cache
12+
13+
# needed to get singularity working on Ubuntu 24.04
14+
# see https://github.com/lima-vm/lima/issues/2319
15+
sudo /bin/bash -c "echo \"kernel.apparmor_restrict_unprivileged_userns = 0\" >/etc/sysctl.d/99-userns.conf"
16+
sudo sysctl --system
1217
else
1318
CONTAINER_PATH=${ROOT}/.singularity/image-$CONTAINER_TAG.sif
1419
HOME_PATH=${HOME}

bin/setup

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ CONTAINER_TAG=`cat ${ROOT}/bin/.container-tag`
2222
# An apptainer/singularity container. All commands on the host (using ./do or ./bin/*) are run in the context of an Apptainer/Singularity image.
2323
#
2424
#
25-
# ALL THREE CONTAINERS ARE IDENTICAL. Which one you use is a preference of your setup and installed
25+
# ALL THREE CONTAINERS ARE (in theory) IDENTICAL. Which one you use is a preference of your setup and installed
2626
# software.
2727

2828

2929
# get the container type
3030
#
3131
# use, in priority order:
32-
# 1. devcontainer, if DEVCONTAINER_ENV is set in the enviornment
32+
# 1. devcontainer, if DEVCONTAINER_ENV is set in the environment
3333
# 2. the type stored in .container-type
34-
# 3. Docker, if DOCKER is set in the enviornment
35-
# 4. Singularity, if SINGULARITY is set in the enviornment
34+
# 3. Docker, if DOCKER is set in the environment
35+
# 4. Singularity, if SINGULARITY is set in the environment
3636
# 5. The choice made by the user, which will be cached in .container-type
3737
if [ -v DEVCONTAINER_ENV ]; then
3838
CONTAINER_TYPE=devcontainer
@@ -55,30 +55,28 @@ else
5555
done
5656
fi
5757

58-
if [ "${CONTAINER_TYPE}" != "docker" -a "${CONTAINER_TYPE}" != "singularity" ]; then
58+
if [ "${CONTAINER_TYPE}" != "docker" -a "${CONTAINER_TYPE}" != "singularity" -a "${CONTAINER_TYPE}" != "devcontainer" ]; then
5959
echo "BAD CONTAINER TYPE: ${CONTAINER_TYPE}"
6060
fi
6161

6262
if [ ! -f ${ROOT}/.container-type ]; then
6363
echo ${CONTAINER_TYPE} > ${ROOT}/.container-type
6464
fi
6565

66-
print_env() {
67-
if [ "${CONTAINER_TYPE}" == "docker" ]; then
68-
echo "Using Docker environment"
69-
else
70-
echo "Using Singularity environment"
71-
fi
72-
}
66+
echo "Using ${CONTAINER_TYPE} environment"
7367

7468
if [ -v GITHUB_ACTIONS ]; then
75-
echo "ACTIONS"
69+
echo "Running in a GitHub Action"
7670
CONTAINER_PATH=${ROOT}/.singularity/image.sif
7771
HOME_PATH=${GITHUB_WORKSPACE}
7872
HOME_OPT="--home ${ROOT}/.home"
7973
SINGULARITY_CACHE=--disable-cache
74+
75+
# needed to get singularity working on Ubuntu 24.04
76+
# see https://github.com/lima-vm/lima/issues/2319
77+
sudo /bin/bash -c "echo \"kernel.apparmor_restrict_unprivileged_userns = 0\" >/etc/sysctl.d/99-userns.conf"
78+
sudo sysctl --system
8079
elif [ "${CONTAINER_TYPE}" == "docker" ]; then
81-
print_env
8280
if ! docker images riscvintl/udb:${CONTAINER_TAG} | grep -q udb ; then
8381
# TODO: pull the image if it can be found
8482
echo "Building Docker image..."
@@ -90,8 +88,7 @@ elif [ "${CONTAINER_TYPE}" == "docker" ]; then
9088
DOCKER_BASE="docker run -v $(ROOT):$(ROOT) -w $(ROOT) riscvintl/udb:${CONTAINER_TAG}"
9189
fi
9290
RUN="${DOCKER_BASE}"
93-
else
94-
print_env
91+
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
9592
CONTAINER_PATH=${ROOT}/.singularity/image-$CONTAINER_TAG.sif
9693
HOME_PATH=${HOME}
9794
HOME_OPT="--bind ${ROOT}/.home:${HOME_PATH}"
@@ -103,6 +100,11 @@ else
103100
fi
104101
singularity pull ${SINGULARITY_CACHE} ${CONTAINER_PATH} oras://docker.io/riscvintl/spec-generator:$CONTAINER_TAG
105102
fi
103+
elif [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
104+
HOME_PATH=${HOME}
105+
else
106+
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
107+
exit 1
106108
fi
107109

108110
if [ -f $ROOT/.git ]; then
@@ -111,12 +113,15 @@ if [ -f $ROOT/.git ]; then
111113
HOME_OPT="${HOME_OPT} --bind ${GIT_PATH}:${GIT_PATH}"
112114
fi
113115

114-
if [ -v DEVCONTAINER_ENV ]; then
116+
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
115117
RUN=""
116118
elif [ "${CONTAINER_TYPE}" == "docker" ]; then
117119
RUN="${DOCKER_BASE}"
118-
else
120+
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
119121
RUN="singularity run ${HOME_OPT} ${CONTAINER_PATH}"
122+
else
123+
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
124+
exit 1
120125
fi
121126

122127
if [ ! -d $ROOT/.home ]; then
@@ -164,7 +169,7 @@ if [ ! -d ${ROOT}/node_modules ]; then
164169
${RUN} npm i
165170
fi
166171

167-
if [ -v DEVCONTAINER_ENV ]; then
172+
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
168173
BUNDLE="bundle"
169174
RUBY="bundle exec ruby"
170175
RAKE="bundle exec rake"
@@ -184,7 +189,7 @@ elif [ "${CONTAINER_TYPE}" == "docker" ]; then
184189
PYTHON="${DOCKER_BASE} ${ROOT}/.home/.venv/bin/python3"
185190
PIP="${DOCKER_BASE} ${ROOT}/.home/.venv/bin/pip"
186191
BASH="${DOCKER_BASE} bash"
187-
else
192+
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
188193
BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
189194
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
190195
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
@@ -194,6 +199,9 @@ else
194199
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/python3"
195200
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/pip"
196201
BASH="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
202+
else
203+
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
204+
exit 1
197205
fi
198206

199207
if [ ! -f $ROOT/.git/hooks/pre-commit ]; then

0 commit comments

Comments
 (0)