Skip to content

Commit 15c38f6

Browse files
committed
adding optio to remove image
1 parent e999189 commit 15c38f6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

singularity/analysis/classify.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,23 @@ def get_tags(container=None,image_package=None,sudopw=None,search_folders=None,d
177177
###################################################################################
178178

179179

180-
def get_files(container,S=None):
180+
def get_files(container,S=None,tmpdir=None):
181181
'''get_files will return a list of files inside a container, sorted by name
182182
:param container: the container to use, either shub:// or docker:// or actual
183183
'''
184184
files = None
185-
tmpdir = tempfile.mkdtemp()
185+
if tmpdir == None:
186+
tmpdir = tempfile.mkdtemp()
186187
tmpfile = "%s/files.txt" %tmpdir
187188
container_name = remove_uri(container)
188-
command = 'ls -LR >> %s 2>/dev/null' %(tmpfile)
189+
command = ' ls -LR >> %s 2>/dev/null' %(tmpfile)
189190
if S==None:
190191
S = Singularity(sudo=None)
191192
result = S.execute(container,command)
192193
if os.path.exists(tmpfile):
193194
os.system("sed -i '/^$/d' %s" %(tmpfile))
194195
os.system('sort %s -or %s' %(tmpfile,tmpfile))
195196
files = read_file(tmpfile)
196-
rootfs=None
197197
if len(files) > 0:
198198
files = [x for x in files if x.startswith('.')]
199199
files = [x.split(container_name)[1:] for x in files]

singularity/scripts.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def get_parser():
4040
help="package a singularity container for singularity hub",
4141
default=False, action='store_true')
4242

43+
# Does the user want to package an image?
44+
parser.add_argument('--remove-image', dest="remove_image",
45+
help="remove image file from the package",
46+
default=False, action='store_true')
47+
4348
# Does the user want to estimate the os?
4449
parser.add_argument('--os', dest="os",
4550
help="estimate the operating system of your container.",
@@ -165,7 +170,8 @@ def main():
165170
package(image_path=image,
166171
output_folder=output_folder,
167172
runscript=True,
168-
software=True)
173+
software=True,
174+
remove_image=args.remove_image)
169175
else:
170176
print("Not sure what to do?")
171177
parser.print_help()

0 commit comments

Comments
 (0)