两阶段build sif镜像即可
singularity build --fakeroot ubuntu16base.sif ubuntu16base.def
singularity build --fakeroot p4vasp.sif p4vasp.def
Bootstrap: docker
From: ubuntu:16.04
%post
# Update the package repository
apt-get update && apt-get upgrade -y
# Install basic packages and tools
apt-get install python-dev g++ libx11-dev mesa-common-dev libglu1-mesa-dev python-opengl python-numpy python-glade2 python-epydoc doxygen -y
# Clean up
apt-get clean
%environment
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
%runscript
# The runscript is the default command that will be executed
# when the container is run. Replace the following command
# with whatever is appropriate for your container.
exec echo "This is a basic Ubuntu 16.04.7 LTS container, replace this echo with your application's start command."
Bootstrap: localimage
From: ubuntu16base.sif
%post
# Install dependencies for building p4vasp
apt-get update && apt-get install -y
# Clone the p4vasp repository
apt install -y git libfltk1.3-dev libgl1-mesa-dev libglu1-mesa-dev make
apt install -y sudo libxft-dev libfontconfig1-dev libxinerama-dev
git clone https://github.com/orest-d/p4vasp.git /opt/p4vasp_source
cd /opt/p4vasp_source
# ##################################
# Specifying the filename
FILENAME="/opt/p4vasp_source/src/fltk-config.py" # Specify the correct path if needed
# Writing the content to the file
rm -rf /opt/p4vasp_source/src/fltk-config.py
cat > ${FILENAME} <<EOL
#!/usr/bin/env python2
import os
import os.path
import sys
from string import *
def run(cmd):
os.system("%s >fltk-config.tmp" % cmd) # Ensure proper formatting here
return open("fltk-config.tmp").read()
print(run("fltk-config " + " ".join(sys.argv[1:]))) # Adjusted for proper Python syntax
EOL
# ##################################
make P4VASP_HOME=/usr/share/p4vasp PYTHON_HOME=/usr/lib64/python2.7 PYINCLUDE=/usr/include/python2.7
make P4VASP_HOME=/usr/share/p4vasp \
PYTHON_HOME=/usr/lib64/python2.7 \
PYINCLUDE=/usr/include/python2.7 \
SITE_PACKAGES=/usr/lib64/python2.7/site-packages \
INCLUDEDIR=/usr/include \
LIBDIR="/usr/lib64:/usr/lib/x86_64-linux-gnu" \
BINDIR=/usr/bin \
LDFLAGS="-L/usr/lib/x86_64-linux-gnu" \
install
%environment
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
%runscript
# Command to run p4vasp
#exec p4vasp "$@"

使用方法:
以windterm为例,打开x11转发,运行以下命令调用容器内的p4v二进制文件即可
singularity exec p4vasp.sif p4v