Skip to content

Commit b447e72

Browse files
Merging in fixes for running in devcontainer to Derek's changes to setup to fix smoke test.
1 parent dfe7416 commit b447e72

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
diag-ditaa-*
1212
arch/manual/isa/**/riscv-isa-manual
1313
gen
14+
gen.*
1415
node_modules
1516
_site
1617
images

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: 26 additions & 15 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
@@ -56,7 +56,7 @@ else
5656
fi
5757

5858
if [ "${CONTAINER_TYPE}" != "docker" -a "${CONTAINER_TYPE}" != "singularity" -a "${CONTAINER_TYPE}" != "devcontainer" ]; then
59-
echo "BAD CONTAINER TYPE: ${CONTAINER_TYPE}"
59+
echo "BAD CONTAINER TYPE: ${CONTAINER_TYPE}" 1>&2
6060
exit 1
6161
fi
6262

@@ -72,19 +72,25 @@ print_env() {
7272
elif [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
7373
echo "Using devcontainer environment"
7474
else
75-
echo "Unknown container type of ${CONTAINER_TYPE}"
75+
echo "Unknown container type of ${CONTAINER_TYPE}" 1>&2
7676
exit 1
7777
fi
7878
}
7979

80+
print_env
81+
8082
if [ -v GITHUB_ACTIONS ]; then
81-
echo "ACTIONS"
83+
echo "Running in a GitHub Action"
8284
CONTAINER_PATH=${ROOT}/.singularity/image.sif
8385
HOME_PATH=${GITHUB_WORKSPACE}
8486
HOME_OPT="--home ${ROOT}/.home"
8587
SINGULARITY_CACHE=--disable-cache
88+
89+
# needed to get singularity working on Ubuntu 24.04
90+
# see https://github.com/lima-vm/lima/issues/2319
91+
sudo /bin/bash -c "echo \"kernel.apparmor_restrict_unprivileged_userns = 0\" >/etc/sysctl.d/99-userns.conf"
92+
sudo sysctl --system
8693
elif [ "${CONTAINER_TYPE}" == "docker" ]; then
87-
print_env
8894
if ! docker images riscvintl/udb:${CONTAINER_TAG} | grep -q udb ; then
8995
# TODO: pull the image if it can be found
9096
echo "Building Docker image..."
@@ -97,7 +103,6 @@ elif [ "${CONTAINER_TYPE}" == "docker" ]; then
97103
fi
98104
RUN="${DOCKER_BASE}"
99105
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
100-
print_env
101106
CONTAINER_PATH=${ROOT}/.singularity/image-$CONTAINER_TAG.sif
102107
HOME_PATH=${HOME}
103108
HOME_OPT="--bind ${ROOT}/.home:${HOME_PATH}"
@@ -110,9 +115,9 @@ elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
110115
singularity pull ${SINGULARITY_CACHE} ${CONTAINER_PATH} oras://docker.io/riscvintl/spec-generator:$CONTAINER_TAG
111116
fi
112117
elif [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
113-
print_env
118+
HOME_PATH=${HOME}
114119
else
115-
echo "Unknown container type of ${CONTAINER_TYPE}"
120+
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
116121
exit 1
117122
fi
118123

@@ -122,12 +127,15 @@ if [ -f $ROOT/.git ]; then
122127
HOME_OPT="${HOME_OPT} --bind ${GIT_PATH}:${GIT_PATH}"
123128
fi
124129

125-
if [ -v DEVCONTAINER_ENV ]; then
130+
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
126131
RUN=""
127132
elif [ "${CONTAINER_TYPE}" == "docker" ]; then
128133
RUN="${DOCKER_BASE}"
129-
else
134+
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
130135
RUN="singularity run ${HOME_OPT} ${CONTAINER_PATH}"
136+
else
137+
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
138+
exit 1
131139
fi
132140

133141
if [ ! -d $ROOT/.home ]; then
@@ -175,7 +183,7 @@ if [ ! -d ${ROOT}/node_modules ]; then
175183
${RUN} npm i
176184
fi
177185

178-
if [ -v DEVCONTAINER_ENV ]; then
186+
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
179187
BUNDLE="bundle"
180188
RUBY="bundle exec ruby"
181189
RAKE="bundle exec rake"
@@ -195,7 +203,7 @@ elif [ "${CONTAINER_TYPE}" == "docker" ]; then
195203
PYTHON="${DOCKER_BASE} ${ROOT}/.home/.venv/bin/python3"
196204
PIP="${DOCKER_BASE} ${ROOT}/.home/.venv/bin/pip"
197205
BASH="${DOCKER_BASE} bash"
198-
else
206+
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
199207
BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
200208
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
201209
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
@@ -205,6 +213,9 @@ else
205213
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/python3"
206214
PIP="singularity run ${HOME_OPT} ${CONTAINER_PATH} ${ROOT}/.home/.venv/bin/pip"
207215
BASH="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash"
216+
else
217+
echo "Bad container type: ${CONTAINER_TYPE}" 1>&2
218+
exit 1
208219
fi
209220

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

0 commit comments

Comments
 (0)