From 9c90a0fa33f87cd3eeeb960bd1b8ea9e246a460e Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 9 Apr 2020 13:58:22 -0700 Subject: [PATCH 1/4] Rename dangerzone-container commands to remove hiphens and underscores, because old and new versions of click treat them differently --- dangerzone/container.py | 6 +++--- dangerzone/docker_installer.py | 2 +- dangerzone/gui.py | 4 +--- dangerzone/settings_widget.py | 6 +----- dangerzone/tasks.py | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dangerzone/container.py b/dangerzone/container.py index 878e10b..ab1bd98 100644 --- a/dangerzone/container.py +++ b/dangerzone/container.py @@ -52,7 +52,7 @@ def container_main(): @container_main.command() @click.option("--container-name", default="flmcode/dangerzone") -def image_ls(container_name): +def ls(container_name): """docker image ls [container_name]""" sys.exit(exec_container(["image", "ls", container_name])) @@ -67,7 +67,7 @@ def pull(): @click.option("--document-filename", required=True) @click.option("--pixel-dir", required=True) @click.option("--container-name", default="flmcode/dangerzone") -def document_to_pixels(document_filename, pixel_dir, container_name): +def documenttopixels(document_filename, pixel_dir, container_name): """docker run --network none -v [document_filename]:/tmp/input_file -v [pixel_dir]:/dangerzone [container_name] document-to-pixels""" sys.exit( exec_container( @@ -92,7 +92,7 @@ def document_to_pixels(document_filename, pixel_dir, container_name): @click.option("--container-name", default="flmcode/dangerzone") @click.option("--ocr", required=True) @click.option("--ocr-lang", required=True) -def pixels_to_pdf(pixel_dir, safe_dir, container_name, ocr, ocr_lang): +def pixelstopdf(pixel_dir, safe_dir, container_name, ocr, ocr_lang): """docker run --network none -v [pixel_dir]:/dangerzone -v [safe_dir]:/safezone [container_name] -e OCR=[ocr] -e OCR_LANGUAGE=[ocr_lang] pixels-to-pdf""" sys.exit( exec_container( diff --git a/dangerzone/docker_installer.py b/dangerzone/docker_installer.py index db07a23..6a7596d 100644 --- a/dangerzone/docker_installer.py +++ b/dangerzone/docker_installer.py @@ -33,7 +33,7 @@ def is_docker_installed(global_common): def is_docker_ready(global_common): # Run `docker image ls` without an error - with global_common.exec_dangerzone_container(["image-ls"]) as p: + with global_common.exec_dangerzone_container(["ls"]) as p: p.communicate() # The user canceled, or permission denied diff --git a/dangerzone/gui.py b/dangerzone/gui.py index 9d2d7db..ec83a1e 100644 --- a/dangerzone/gui.py +++ b/dangerzone/gui.py @@ -52,9 +52,7 @@ def gui_main(custom_container, filename): if custom_container: # Do we have this container? - with global_common.exec_dangerzone_container( - ["image-ls", "--container-name", custom_container] - ) as p: + with global_common.exec_dangerzone_container(["ls", custom_container]) as p: stdout_data, stderr_data = p.communicate() # The user canceled, or permission denied diff --git a/dangerzone/settings_widget.py b/dangerzone/settings_widget.py index ec7305c..c3cbfc3 100644 --- a/dangerzone/settings_widget.py +++ b/dangerzone/settings_widget.py @@ -143,11 +143,7 @@ class SettingsWidget(QtWidgets.QWidget): self.update_checkbox.hide() else: with self.global_common.exec_dangerzone_container( - [ - "image-ls", - "--container-name", - self.global_common.get_container_name(), - ] + ["ls", self.global_common.get_container_name(),] ) as p: stdout_data, stderror_data = p.communicate() diff --git a/dangerzone/tasks.py b/dangerzone/tasks.py index 1398203..e3aaea0 100644 --- a/dangerzone/tasks.py +++ b/dangerzone/tasks.py @@ -72,7 +72,7 @@ class ConvertToPixels(TaskBase): def run(self): self.update_label.emit("Converting document to pixels") args = [ - "document-to-pixels", + "documenttopixels", "--document-filename", self.common.document_filename, "--pixel-dir", @@ -173,7 +173,7 @@ class ConvertToPDF(TaskBase): ] args = [ - "pixels-to-pdf", + "pixelstopdf", "--pixel-dir", self.common.pixel_dir.name, "--safe-dir", From a0758fb549145a790c36affd3ba4b62c94c4845b Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 9 Apr 2020 13:58:44 -0700 Subject: [PATCH 2/4] Change absolute path of systemctl to /bin/systemctl, so it will work in ubuntu 18.04 --- share/enable_docker_service.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/enable_docker_service.sh b/share/enable_docker_service.sh index 3e394f9..ca0f29d 100755 --- a/share/enable_docker_service.sh +++ b/share/enable_docker_service.sh @@ -1,3 +1,3 @@ #!/bin/sh -/usr/bin/systemctl restart docker.service -/usr/bin/systemctl enable docker.service \ No newline at end of file +/bin/systemctl restart docker.service +/bin/systemctl enable docker.service \ No newline at end of file From 8b813729e5a9ac7e8d7cf95ce1280c582b4ffc97 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 9 Apr 2020 14:02:11 -0700 Subject: [PATCH 3/4] Drop python version to >= 3.6 --- stdeb.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdeb.cfg b/stdeb.cfg index b667571..3f5db49 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -3,4 +3,4 @@ Package3: dangerzone Depends3: docker.io | docker-ce, python3, python3-pyqt5, python3-appdirs, python3-click, python3-xdg, python3-requests Build-Depends: python3, python3-all Suite: bionic -X-Python3-Version: >= 3.7 \ No newline at end of file +X-Python3-Version: >= 3.6 \ No newline at end of file From 4ec123f1c565147af91286ed0337da6a6bd1ced0 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 9 Apr 2020 14:27:43 -0700 Subject: [PATCH 4/4] Make CI build packages for Ubuntu 18.04 and 18.10 --- .circleci/config.yml | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index a463ac1..ba8969a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,6 +2,54 @@ version: 2.1 jobs: + build-ubuntu-bionic: + docker: + - image: ubuntu:18.04 + steps: + - run: + name: Install dependencies + command: | + apt-get update + apt-get install -y git ssh ruby-dev rubygems python-all dh-python python3-stdeb docker.io python3 python3-pyqt5 python3-appdirs python3-click python3-xdg + gem install --no-ri --no-rdoc rake + gem install --no-ri --no-rdoc package_cloud + - checkout + - run: + name: Create the .deb package + command: | + ./install/linux/build_deb.py + dpkg -i deb_dist/dangerzone_*-1_all.deb + - run: + name: Deploy to packagecloud.io + command: | + VERSION=$(cat dangerzone/__init__.py |grep "dangerzone_version = " |cut -d '"' -f2) + package_cloud push firstlookmedia/code/ubuntu/bionic deb_dist/dangerzone_${VERSION}-1_all.deb + package_cloud push firstlookmedia/code/ubuntu/bionic deb_dist/dangerzone_${VERSION}-1.dsc + + build-ubuntu-cosmic: + docker: + - image: ubuntu:18.10 + steps: + - run: + name: Install dependencies + command: | + apt-get update + apt-get install -y git ssh ruby-dev rubygems python-all dh-python python3-stdeb docker.io python3 python3-pyqt5 python3-appdirs python3-click python3-xdg + gem install --no-ri --no-rdoc rake + gem install --no-ri --no-rdoc package_cloud + - checkout + - run: + name: Create the .deb package + command: | + ./install/linux/build_deb.py + dpkg -i deb_dist/dangerzone_*-1_all.deb + - run: + name: Deploy to packagecloud.io + command: | + VERSION=$(cat dangerzone/__init__.py |grep "dangerzone_version = " |cut -d '"' -f2) + package_cloud push firstlookmedia/code/ubuntu/cosmic deb_dist/dangerzone_${VERSION}-1_all.deb + package_cloud push firstlookmedia/code/ubuntu/cosmic deb_dist/dangerzone_${VERSION}-1.dsc + build-ubuntu-disco: docker: - image: ubuntu:19.04 @@ -146,6 +194,18 @@ workflows: version: 2 build-tags: jobs: + - build-ubuntu-bionic: + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ + - build-ubuntu-cosmic: + filters: + tags: + only: /^v.*/ + branches: + ignore: /.*/ - build-ubuntu-disco: filters: tags: