Bootstrap: docker
From: debian:bookworm-slim
Stage: np-tmcode-run-dev

%files
	../../src /usr/local/np-tmcode/src
	../../doc /usr/local/np-tmcode/doc
	../../build /usr/local/np-tmcode/build
	../../test_data /usr/local/np-tmcode/test_data

%post
	apt update
	apt -y upgrade
	apt -y install g++ gfortran make gcc-offload-nvptx libhdf5-dev liblapacke-dev liblapacke64-dev libopenblas-dev libopenblas-openmp-dev libopenblas64-dev libopenblas64-openmp-dev
	apt -y install python3 python-is-python3 python3-regex
	apt -y install doxygen
	apt -y install texlive-latex-base texlive-latex-recommended texlive-latex-extra texlive-font-utils
	rm -rf /var/lib/apt/lists/*
	cd /usr/local/np-tmcode/src
	make wipe
	make -j
	make docs -j && make -C ../doc/build/latex -j


Bootstrap: docker
From: debian:bookworm-slim
Stage: np-tmcode-run-minimal

%files from np-tmcode-run-dev
       /usr/local/np-tmcode /usr/local/np-tmcode

%post
	apt update
	apt -y upgrade
	apt -y install libgfortran5 libgcc-s1 libhdf5-103-1 libstdc++6 libssl3 libcurl4 libsz2 zlib1g libnghttp2-14 libidn2-0 librtmp1 libssh2-1 libpsl5 libgssapi-krb5-2 libldap-2.5-0 libzstd1 libbrotli1 libaec0 libunistring2 libgmp10 libkrb5-3 libk5crypto3 libcom-err2 libkrb5support0 libsasl2-2 libp11-kit0 libtasn1-6 libkeyutils1 libffi8 liblapacke64 libopenblas64-0-openmp python3 python-is-python3 python3-regex hdf5-tools
	rm -rf /var/lib/apt/lists/*
	cd /usr/local/np-tmcode
	find build -name "*.o" -exec rm -v \{\} \;
	find build -name "*.gcno" -exec rm -v \{\} \;
	cd src
	rm -rvf cluster libnptm trapping include sphere Makefile make.inc README.md
	cd ..
	rm -rvf containers
	cd doc
	rm -rvf src/cluster /src/include /src/libntpm /src/sphere /src/trapping /src/Makefile /src/make.inc
	cd build/latex
	rm -rvf *.tex *.out *.sty *.ind *.log *.toc *.ilg *.idx *.aux *.eps Makefile class*.pdf
	cp -a /usr/bin/ld.so /usr/bin/sh /usr/bin/dash /usr/bin/mkdir /usr/bin/rm /usr/bin/cp /usr/bin/python* /usr/bin/h5* /usr/local/bin/
	rm -rvf /bin/* /usr/bin/* /sbin /usr/sbin /usr/games /usr/local/games
	/usr/local/bin/mkdir -p /bin
	/usr/local/bin/cp -av /usr/local/bin/* /bin/
	rm -rvf /usr/local/bin/* /bin/cp /bin/rm /bin/mkdir


Bootstrap: scratch
Stage: np-tmcode-run

%files from np-tmcode-run-minimal
       / /

%runscript
	PATH=/bin:/usr/local/np-tmcode/src/scripts:/usr/local/np-tmcode/build/trapping:/usr/local/np-tmcode/build/cluster:/usr/local/np-tmcode/build/sphere $*
