summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/download/__init__.py2
-rwxr-xr-xbuild/download/clean_docker_images.py71
-rwxr-xr-xbuild/download/command_downloader.py1
-rw-r--r--build/download/concurrent_downloader.py1
-rwxr-xr-xbuild/download/docker_downloader.py2
-rwxr-xr-xbuild/download/download.py2
-rw-r--r--build/download/downloader.py5
-rwxr-xr-xbuild/download/git_downloader.py2
-rw-r--r--build/download/http_downloader.py2
-rwxr-xr-xbuild/download/npm_downloader.py2
-rwxr-xr-xbuild/download/pypi_downloader.py2
-rwxr-xr-xbuild/download/rpm_downloader.py2
-rwxr-xr-x[-rw-r--r--]build/package.py0
13 files changed, 80 insertions, 14 deletions
diff --git a/build/download/__init__.py b/build/download/__init__.py
index f0efbc15..b1ef8d99 100644
--- a/build/download/__init__.py
+++ b/build/download/__init__.py
@@ -1,5 +1,3 @@
-
-#! /usr/bin/env python
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/clean_docker_images.py b/build/download/clean_docker_images.py
new file mode 100755
index 00000000..186bfd60
--- /dev/null
+++ b/build/download/clean_docker_images.py
@@ -0,0 +1,71 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# COPYRIGHT NOTICE STARTS HERE
+
+# Copyright 2019 © Samsung Electronics Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# COPYRIGHT NOTICE ENDS HERE
+
+
+import argparse
+import docker
+import logging
+import sys
+
+from downloader import AbstractDownloader
+from docker_downloader import DockerDownloader
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('image_lists', nargs='+', help='Images to keep')
+ parser.add_argument('--debug', '-d', action='store_true', help='Debugging messages')
+ args = parser.parse_args()
+
+ if args.debug:
+ logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
+ else:
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout, format='%(message)s')
+
+ target = set()
+ for lst in args.image_lists:
+ target = target.union(AbstractDownloader.load_list(lst))
+
+ target = set(map(DockerDownloader.image_registry_name, target))
+
+ client = docker.client.DockerClient(version='auto')
+
+ errors = 0
+ for image in client.images.list():
+ for tag in image.tags:
+ logging.debug('Checking {}'.format(tag))
+ if tag not in target:
+ logging.debug('Image \'{}\' not in lists'.format(tag))
+ logging.info('Removing: {}'.format(tag))
+ try:
+ client.images.remove(tag)
+ logging.info('Removed: {}'.format(tag))
+ except docker.errors.APIError as err:
+ errors += 1
+ logging.exception(err)
+ else:
+ logging.debug('Image \'{}\' found in lists.'.format(tag))
+ sys.exit(errors)
+
+
+if __name__ == '__main__':
+ main()
+
diff --git a/build/download/command_downloader.py b/build/download/command_downloader.py
index 5efc8b0f..835d218d 100755
--- a/build/download/command_downloader.py
+++ b/build/download/command_downloader.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/concurrent_downloader.py b/build/download/concurrent_downloader.py
index c84dac86..a150db73 100644
--- a/build/download/concurrent_downloader.py
+++ b/build/download/concurrent_downloader.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/docker_downloader.py b/build/download/docker_downloader.py
index 13323d3b..d83f682c 100755
--- a/build/download/docker_downloader.py
+++ b/build/download/docker_downloader.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/download.py b/build/download/download.py
index 0af12989..6d76b369 100755
--- a/build/download/download.py
+++ b/build/download/download.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/downloader.py b/build/download/downloader.py
index 64403300..6bbab35d 100644
--- a/build/download/downloader.py
+++ b/build/download/downloader.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
@@ -32,7 +31,7 @@ class AbstractDownloader(ABC):
def __init__(self, list_type, *list_args):
self._list_type = list_type
self._data_list = {item: list_arg[1] for list_arg in list_args
- for item in self._load_list(list_arg[0])}
+ for item in self.load_list(list_arg[0])}
self._missing = self.missing()
@property
@@ -43,7 +42,7 @@ class AbstractDownloader(ABC):
return self._list_type
@staticmethod
- def _load_list(path):
+ def load_list(path):
"""
Load list from file.
:param path: path to file
diff --git a/build/download/git_downloader.py b/build/download/git_downloader.py
index 46faa8f8..ed7a3956 100755
--- a/build/download/git_downloader.py
+++ b/build/download/git_downloader.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/http_downloader.py b/build/download/http_downloader.py
index ba2c0f7e..c6b7c6e9 100644
--- a/build/download/http_downloader.py
+++ b/build/download/http_downloader.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/npm_downloader.py b/build/download/npm_downloader.py
index 369af72a..ed4152b8 100755
--- a/build/download/npm_downloader.py
+++ b/build/download/npm_downloader.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/pypi_downloader.py b/build/download/pypi_downloader.py
index 4ab6b1f4..10ac7b9f 100755
--- a/build/download/pypi_downloader.py
+++ b/build/download/pypi_downloader.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/download/rpm_downloader.py b/build/download/rpm_downloader.py
index 92ae6a78..415f9483 100755
--- a/build/download/rpm_downloader.py
+++ b/build/download/rpm_downloader.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# COPYRIGHT NOTICE STARTS HERE
diff --git a/build/package.py b/build/package.py
index 8a1808b3..8a1808b3 100644..100755
--- a/build/package.py
+++ b/build/package.py