4040from vsc .utils .missing import get_subclasses
4141from vsc .utils .patterns import Singleton
4242
43- from easybuild .tools .config import PKG_TOOL_FPM , PKG_TYPE_RPM , build_option , get_package_naming_scheme , log_path
43+ from easybuild .tools .config import PKG_TOOL_DOCKER , PKG_TOOL_FPM , PKG_TOOL_SINGULARITY
44+ from easybuild .tools .config import PKG_TYPE_DEF , PKG_TYPE_IMG , PKG_TYPE_RPM
45+ from easybuild .tools .config import build_option , get_package_naming_scheme , log_path
4446from easybuild .tools .build_log import EasyBuildError
4547from easybuild .tools .filetools import change_dir , which
4648from easybuild .tools .package .package_naming_scheme .pns import PackageNamingScheme
@@ -66,14 +68,37 @@ def package(easyblock):
6668 Package installed software, according to active packaging configuration settings."""
6769 pkgtool = build_option ('package_tool' )
6870
69- if pkgtool == PKG_TOOL_FPM :
71+ if pkgtool == PKG_TOOL_DOCKER :
72+ pkgdir = package_with_docker (easyblock )
73+ elif pkgtool == PKG_TOOL_FPM :
7074 pkgdir = package_with_fpm (easyblock )
75+ elif pkgtool == PKG_TOOL_SINGULARITY :
76+ pkgdir = package_with_singularity (easyblock )
7177 else :
7278 raise EasyBuildError ("Unknown packaging tool specified: %s" , pkgtool )
7379
7480 return pkgdir
7581
7682
83+ def package_with_docker (easyblock ):
84+ """
85+ Package software with Docker,
86+ i.e. either generate a container definition file, or build an actual Docker container image
87+ (depending on the value for --package-type, 'def' or 'img')
88+ """
89+ workdir = tempfile .mkdtemp (prefix = 'eb-pkgs-' )
90+ pkgtype = build_option ('package_type' )
91+
92+ if pkgtype == PKG_TYPE_DEF :
93+ raise NotImplementedError
94+ elif pkgtype == PKG_TYPE_IMG :
95+ raise NotImplementedError
96+ else :
97+ raise EasyBuildError ("Unknown package type '%s' for Docker" , pkgtype )
98+
99+ return workdir
100+
101+
77102def package_with_fpm (easyblock ):
78103 """
79104 This function will build a package using fpm and return the directory where the packages are
@@ -153,6 +178,25 @@ def package_with_fpm(easyblock):
153178 return workdir
154179
155180
181+ def package_with_singularity (easyblock ):
182+ """
183+ Package software with Singularity,
184+ i.e. either generate a container definition file, or build an actual Singularity container image
185+ (depending on the value for --package-type, 'def' or 'img')
186+ """
187+ workdir = tempfile .mkdtemp (prefix = 'eb-pkgs-' )
188+ pkgtype = build_option ('package_type' )
189+
190+ if pkgtype == PKG_TYPE_DEF :
191+ raise NotImplementedError
192+ elif pkgtype == PKG_TYPE_IMG :
193+ raise NotImplementedError
194+ else :
195+ raise EasyBuildError ("Unknown package type '%s' for Singularity" , pkgtype )
196+
197+ return workdir
198+
199+
156200def check_pkg_support ():
157201 """Check whether packaging is possible, if required dependencies are available."""
158202 pkgtool = build_option ('package_tool' )
0 commit comments