From 82b0275a29c30648e0a229b6f68c36ae478a4fe7 Mon Sep 17 00:00:00 2001 From: Gladys Nalvarte Date: Wed, 29 Nov 2017 10:30:31 +0100 Subject: [PATCH] fixing empty lines and comments in apt.txt --- repo2docker/buildpacks/base.py | 20 +++++++++++++------- tests/venv/apt-packages/apt.txt | 3 ++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/repo2docker/buildpacks/base.py b/repo2docker/buildpacks/base.py index 45b78892..416d7841 100644 --- a/repo2docker/buildpacks/base.py +++ b/repo2docker/buildpacks/base.py @@ -418,13 +418,19 @@ class BaseImage(BuildPack): assemble_scripts = [] try: with open(self.binder_path('apt.txt')) as f: - extra_apt_packages = [l.strip() for l in f] - # Validate that this is, indeed, just a list of packages - # We're doing shell injection around here, gotta be careful. - # FIXME: Add support for specifying version numbers - for p in extra_apt_packages: - if not re.match(r"^[a-z0-9.+-]+", p): - raise ValueError("Found invalid package name {} in apt.txt".format(p)) + + extra_apt_packages = [] + for l in f: + package = l.partition('#')[0].strip() + if not package: + continue + # Validate that this is, indeed, just a list of packages + # We're doing shell injection around here, gotta be careful. + # FIXME: Add support for specifying version numbers + if not re.match(r"^[a-z0-9.+-]+", package): + raise ValueError("Found invalid package name {} in apt.txt".format(package)) + extra_apt_packages.append(package) + assemble_scripts.append(( 'root', diff --git a/tests/venv/apt-packages/apt.txt b/tests/venv/apt-packages/apt.txt index 48e76bee..e45822eb 100644 --- a/tests/venv/apt-packages/apt.txt +++ b/tests/venv/apt-packages/apt.txt @@ -1 +1,2 @@ -gfortran +# testing to skip comments in this file +gfortran \ No newline at end of file