Add snow-chibi and akku install

This commit is contained in:
retropikzel 2026-01-27 18:39:26 +02:00
parent 50820236cf
commit dd305a45ab
6 changed files with 122 additions and 145 deletions

View File

@ -1,28 +1,12 @@
ARG IMG=chibi ARG SCHEME=chibi
FROM docker.io/schemers/${IMG} FROM docker.io/schemers/${SCHEME}:head
RUN apt-get update && apt-get install -y \ ARG SCHEME=chibi
build-essential git wget ca-certificates guile-3.0 guile-3.0-dev libcurl4 \ ENV SCHEME=${SCHEME}
xz-utils ARG RNRS=r7rs
ENV RNRS=${RNRS}
WORKDIR /build RUN apt-get update && apt-get install -y gcc curl make git
RUN wget https://gitlab.com/-/project/6808260/uploads/094ce726ce3c6cf8c14560f1e31aaea0/akku-1.1.0.amd64-linux.tar.xz && tar -xf akku-1.1.0.amd64-linux.tar.xz
RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1
WORKDIR /build/akku-1.1.0.amd64-linux
RUN ./install.sh
WORKDIR /build/chibi-scheme
RUN make
RUN make install
WORKDIR /workdir
RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
ENV PATH=/root/.local/bin:${PATH}
ENV LD_LIBRARY_PATH=/root/.local/lib
COPY Makefile . COPY Makefile .
COPY test.scm .
COPY test.sps . COPY test.sps .
COPY compile-test.scm . COPY test.scm .
COPY compile-test.sps .
COPY scheme-venv . COPY scheme-venv .
ENV SCHEME_VENV_DEBUG=true RUN ./scheme-venv ${SCHEME} ${RNRS} testvenv

8
Jenkinsfile vendored
View File

@ -29,7 +29,7 @@ pipeline {
params.R6RS_SCHEMES.split().each { SCHEME -> params.R6RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") { stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=${SCHEME} test-r6rs-script-docker | grep 'scheme-venv-script-test-success-Hello' || exit 1" sh "make SCHEME=${SCHEME} RNRS=r6rs test-script-docker | grep 'scheme-venv-script-test-success-Hello' || exit 1"
} }
} }
} }
@ -42,7 +42,7 @@ pipeline {
params.R6RS_SCHEMES.split().each { SCHEME -> params.R6RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") { stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=${SCHEME} test-r6rs-compile-docker | grep 'scheme-venv-compile-test-success-Hello' || exit 1" sh "make SCHEME=${SCHEME} RNRS=r6rs test-compile-docker | grep 'scheme-venv-compile-test-success-Hello' || exit 1"
} }
} }
} }
@ -55,7 +55,7 @@ pipeline {
params.R7RS_SCHEMES.split().each { SCHEME -> params.R7RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") { stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=${SCHEME} test-r7rs-script-docker | grep 'scheme-venv-script-test-success-Hello' || exit 1" sh "make SCHEME=${SCHEME} RNRS=r7rs test-script-docker | grep 'scheme-venv-script-test-success-Hello' || exit 1"
} }
} }
} }
@ -68,7 +68,7 @@ pipeline {
params.R7RS_SCHEMES.split().each { SCHEME -> params.R7RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") { stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=${SCHEME} test-r7rs-compile-docker | grep 'scheme-venv-compile-test-success-Hello' || exit 1" sh "make SCHEME=${SCHEME} RNRS=r7rs test-compile-docker | grep 'scheme-venv-compile-test-success-Hello' || exit 1"
} }
} }
} }

View File

@ -1,5 +1,6 @@
PREFIX=/usr/local PREFIX=/usr/local
SCHEME=chibi SCHEME=chibi
RNRS=r7rs
DOCKER_IMG=scheme-venv-test-${SCHEME} DOCKER_IMG=scheme-venv-test-${SCHEME}
all: build all: build
@ -7,50 +8,29 @@ all: build
build: build:
@echo "No build step, just install" @echo "No build step, just install"
test-r6rs-script: testvenv:
@echo "Starting test Scheme: ${SCHEME}, RNRS: R6RS" ./scheme-venv ${SCHEME} ${RNRS} testvenv
@rm -rf testvenv/ \
&& ./scheme-venv ${SCHEME} r6rs testvenv \
&& ./testvenv/bin/akku install chez-srfi \
&& ./testvenv/bin/scheme-script test.sps
test-r6rs-compile: test-script: testvenv
@echo "Starting test Scheme: ${SCHEME}, RNRS: R6RS" @if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/akku install chez-srfi; fi
@rm -rf testvenv/ \ @if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/scheme-script test.sps; fi
&& ./scheme-venv ${SCHEME} r6rs testvenv \ @if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello; fi
&& ./testvenv/bin/akku install chez-srfi \ @if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/scheme-script test.scm; fi
&& ./testvenv/bin/scheme-compile compile-test.sps \
&& ./compile-test
test-r7rs-script: test-compile: testvenv
@echo "Starting test Scheme: ${SCHEME}, RNRS: R7RS" @if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/akku install chez-srfi; fi
@rm -rf testvenv/ \ @if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/scheme-compile test.sps && ./test; fi
&& ./scheme-venv ${SCHEME} r7rs testvenv \ @if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello; fi
&& ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello \ @if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/scheme-compile test.scm && ./test; fi
&& ./testvenv/bin/scheme-script test.scm
test-r7rs-compile:
@echo "Starting test Scheme: ${SCHEME}, RNRS: R7RS"
@rm -rf testvenv/ \
&& ./scheme-venv ${SCHEME} r7rs testvenv \
&& ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello \
&& ./testvenv/bin/scheme-compile compile-test.scm \
&& ./compile-test
build-test-docker-image: build-test-docker-image:
docker build --build-arg IMG=${SCHEME}:head -f Dockerfile.test --tag=${DOCKER_IMG} . docker build --build-arg SCHEME=${SCHEME} --build-arg RNRS=${RNRS} -f Dockerfile.test --tag=${DOCKER_IMG} .
test-r6rs-script-docker: build-test-docker-image test-script-docker: build-test-docker-image
@docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} test-r6rs-script" docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} RNRS=${RNRS} test-script"
test-r6rs-compile-docker: build-test-docker-image test-compile-docker: build-test-docker-image testvenv
@docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} test-r6rs-compile" @docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} RNRS=${RNRS} test-compile"
test-r7rs-script-docker: build-test-docker-image
@docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} test-r7rs-script"
test-r7rs-compile-docker: build-test-docker-image
@docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} test-r7rs-compile"
install: install:
@mkdir -p ${PREFIX}/bin @mkdir -p ${PREFIX}/bin
@ -58,3 +38,6 @@ install:
uninstall: uninstall:
@-rm ${PREFIX}/bin/scheme-venv @-rm ${PREFIX}/bin/scheme-venv
clean:
rm -rf testvenv

View File

@ -1,8 +0,0 @@
(import (scheme base)
(scheme write)
(scheme process-context)
(retropikzel hello))
(display "scheme-venv-compile-test-success-")
(hello)
(exit 0)

View File

@ -1,6 +0,0 @@
(import (rnrs)
(srfi :64))
(display "scheme-venv-compile-test-success-Hello")
(newline)
(exit 0)

View File

@ -1,7 +1,8 @@
#!/bin/sh #!/bin/sh
# vi: ft=bash # vi: ft=bash
set -eu
stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;} stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;}
supported_rnrs="r6rs r7rs" supported_rnrs="r6rs r7rs"
@ -52,12 +53,15 @@ fi
implementation="${1}" implementation="${1}"
rnrs="${2}" rnrs="${2}"
venvpath=$(realpath "${3}") venvpath=$(realpath "${3}")
schemebinpath="${venvpath}/bin/scheme" downloadpath="${venvpath}/downloads"
toolinstallprefix="${venvpath}/tools"
scheme_compile_cmd="" scheme_compile_cmd=""
scheme_cmd="" scheme_cmd=""
scheme_script_cmd="" scheme_script_cmd=""
scheme_type="interpreter" scheme_type="interpreter"
echo "scheme-venv version 1.0.0, scheme: ${implementation}, rnrs: ${rnrs}"
## Create venv directories ## Create venv directories
mkdir "${venvpath}" mkdir "${venvpath}"
mkdir "${venvpath}/bin" mkdir "${venvpath}/bin"
@ -69,64 +73,9 @@ case "${implementation}" in
"gambit") scheme_type=compiler ;; "gambit") scheme_type=compiler ;;
esac esac
## bin/snow-chibi
if [ "${rnrs}" = "r6rs" ]; then
{
cat << EOF
#!/bin/sh
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
if [ "\${1}" = "install" ]; then
shift
PATH="${PATH}" $(which snow-chibi) install \
--impls=generic \
--install-source-dir=${venvpath}/lib \
--install-library-dir=${venvpath}/lib \
--install-data-dir=${venvpath}/lib \
--install-binary-dir=${venvpath}/bin \
"\$@"
else
snow-chibi "\$@"
fi
EOF
} > "${venvpath}/bin/snow-chibi"
chmod +x "${venvpath}/bin/snow-chibi"
else
{
cat << EOF
#!/bin/sh
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
if [ "\${1}" = "install" ]; then
shift
PATH="${PATH}" $(which snow-chibi) install \
--impls=${implementation} \
--install-source-dir=${venvpath}/lib \
--install-library-dir=${venvpath}/lib \
--install-data-dir=${venvpath}/lib \
"\$@"
else
snow-chibi "\$@"
fi
EOF
} > "${venvpath}/bin/snow-chibi"
chmod +x "${venvpath}/bin/snow-chibi"
fi
## bin/akku
{
cat << EOF
#!/bin/sh
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
cd "${venvpath}/lib"
$(which akku) update
$(which akku) "\$@"
EOF
} > "${venvpath}/bin/akku"
chmod +x "${venvpath}/bin/akku"
## bin/activate ## bin/activate
{ {
cat << EOF cat << EOF
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
deactivate () { deactivate () {
unset SCHEME unset SCHEME
unset COMPILE_R7RS unset COMPILE_R7RS
@ -264,8 +213,8 @@ else
scheme_cmd="meevax -I \"${venvpath}/lib\" \"\${IF}\"" scheme_cmd="meevax -I \"${venvpath}/lib\" \"\${IF}\""
;; ;;
"mit-scheme") "mit-scheme")
#scheme_cmd="mit-scheme --prepend-library \"${venvpath}/lib/\" --batch-mode --load \"\${IF}\" --eval \"(exit 0)\" --args" scheme_cmd="mit-scheme --prepend-library=\"${venvpath}/lib/\" --batch-mode --load \"\${IF}\" --eval \"(exit 0)\" --args"
scheme_cmd="echo \"MIT-scheme script not supported\" && exit 1" #scheme_cmd="echo \"MIT-scheme script not supported\" && exit 1"
scheme_compile_cmd="echo \"MIT-scheme compile not supported\" && exit 1" scheme_compile_cmd="echo \"MIT-scheme compile not supported\" && exit 1"
;; ;;
"mosh") "mosh")
@ -300,7 +249,6 @@ fi
## bin/scheme-script ## bin/scheme-script
{ {
echo "#!/bin/sh" echo "#!/bin/sh"
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
echo "if [ \"\${1}\" = \"\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi" echo "if [ \"\${1}\" = \"\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
echo "if [ \"\${1}\" = \"--help\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi" echo "if [ \"\${1}\" = \"--help\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
echo "IF=\"\${1}\"" echo "IF=\"\${1}\""
@ -313,9 +261,9 @@ chmod +x "${venvpath}/bin/scheme-script"
if [ "${scheme_type}" = "interpreter" ]; then if [ "${scheme_type}" = "interpreter" ]; then
{ {
echo "#!/bin/sh" echo "#!/bin/sh"
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
echo "IF=\"\$(realpath \"\${1}\")\"" echo "IF=\"\$(realpath \"\${1}\")\""
echo "if [ "${rnrs}" = "r6rs" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi" echo "if [ \"${rnrs}\" = \"r6rs\" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi"
# shellcheck disable=SC2028
echo "printf \"\n#|\nexec ${venvpath}/bin/scheme-script \\\"\\\${0}\\\" \\\"\\\$@\\\"\n|#\n\" > \"\${OF}\"" echo "printf \"\n#|\nexec ${venvpath}/bin/scheme-script \\\"\\\${0}\\\" \\\"\\\$@\\\"\n|#\n\" > \"\${OF}\""
echo "cat \"\${IF}\" >> \"\${OF}\"" echo "cat \"\${IF}\" >> \"\${OF}\""
echo "chmod +x \"\${OF}\"" echo "chmod +x \"\${OF}\""
@ -324,12 +272,88 @@ if [ "${scheme_type}" = "interpreter" ]; then
else else
{ {
echo "#!/bin/sh" echo "#!/bin/sh"
echo "if [ ! \"\${SCHEME_VENV_DEBUG}\" = \"\" ]; then set -x; fi"
echo "IF=\$(realpath \"\${1}\")" echo "IF=\$(realpath \"\${1}\")"
echo "if [ "${rnrs}" = "r6rs" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi" echo "if [ \"${rnrs}\" = \"r6rs\" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi"
echo "cd ${venvpath}/lib" echo "cd ${venvpath}/lib"
echo "${scheme_compile_cmd}" echo "${scheme_compile_cmd}"
} > "${venvpath}/bin/scheme-compile" } > "${venvpath}/bin/scheme-compile"
chmod +x "${venvpath}/bin/scheme-compile" chmod +x "${venvpath}/bin/scheme-compile"
fi fi
if [ "${rnrs}" = "r6rs" ];then
sleep 0
fi
## Check if system has snow-chibi
if command -v snow-chibi >/dev/null 2>&1; then
echo "Found local snow-chibi at $(which snow-chibi)"
snow_chibi_path=$(which snow-chibi)
snow_chibi_prefix=""
else
echo "Did not found local snow-chibi, installing"
mkdir -p "${downloadpath}"
mkdir -p "${toolinstallprefix}"
git clone https://github.com/ashinn/chibi-scheme.git "${downloadpath}/chibi-scheme" --depth=1
make -C "${downloadpath}/chibi-scheme" PREFIX="${toolinstallprefix}"
make -C "${downloadpath}/chibi-scheme" PREFIX="${toolinstallprefix}" install
snow_chibi_path="${toolinstallprefix}/bin/snow-chibi"
snow_chibi_prefix="LD_LIBRARY_PATH=\"${toolinstallprefix}/lib\" PATH=\"${toolinstallprefix}/bin:${PATH}\""
fi
## bin/snow-chibi
impls=${implementation}
if [ "${rnrs}" = "r6rs" ]; then
impls=generic
fi
{
cat << EOF
#!/bin/sh
if [ "\${1}" = "install" ]; then
shift
${snow_chibi_prefix} "${snow_chibi_path}" install \
--impls=${impls} \
--install-source-dir=${venvpath}/lib \
--install-library-dir=${venvpath}/lib \
--install-data-dir=${venvpath}/lib \
--install-binary-dir=${venvpath}/bin \
"\$@"
else
${snow_chibi_prefix} "${snow_chibi_path}" "\$@"
fi
EOF
} > "${venvpath}/bin/snow-chibi"
chmod +x "${venvpath}/bin/snow-chibi"
if [ "${rnrs}" = "r6rs" ]; then
## Check if system has akku
if command -v akku >/dev/null 2>&1; then
echo "Found local akku at $(which akku)"
akku_path=$(which akku)
akku_prefix=""
else
echo "Did not found local akku, installing"
mkdir -p "${downloadpath}"
mkdir -p "${toolinstallprefix}/akku"
mkdir -p "${toolinstallprefix}/bin"
curl -o "${downloadpath}/akku.tar.xz" https://gitlab.com/-/project/6808260/uploads/094ce726ce3c6cf8c14560f1e31aaea0/akku-1.1.0.amd64-linux.tar.xz
tar -C "${toolinstallprefix}/akku" --strip-components 1 -xf "${downloadpath}/akku.tar.xz"
akku_install_path="${toolinstallprefix}/akku/lib/x86_64-linux-gnu/akku"
echo "exec \"${akku_install_path}/petite\" -b \"${akku_install_path}/petite.boot\" --program \"${akku_install_path}/akku\" \"\$@\"" > "${toolinstallprefix}/bin/akku"
chmod +x "${toolinstallprefix}/bin/akku"
akku_path="${toolinstallprefix}/bin/akku"
akku_prefix="PATH=\"${toolinstallprefix}/bin:${PATH}\""
fi
## bin/akku
{
cat << EOF
#!/bin/sh
cd "${venvpath}/lib"
"${akku_prefix}" "${akku_path}" update
${akku_prefix} "${akku_path}" "\$@"
EOF
} > "${venvpath}/bin/akku"
chmod +x "${venvpath}/bin/akku"
fi