diff --git a/.gitignore b/.gitignore index 62a9338..c11b073 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,6 @@ dmypy.json .pyre/ # Other -.vscode \ No newline at end of file +.vscode +*.tar.gz +deb_dist \ No newline at end of file diff --git a/dangerzone/common.py b/dangerzone/common.py index e1c9e0e..b66db2d 100644 --- a/dangerzone/common.py +++ b/dangerzone/common.py @@ -222,7 +222,8 @@ class Common(object): "share", ) else: - print("Error, can only run in dev mode so far") + # In linux... + prefix = os.path.join(sys.prefix, "share/dangerzone") resource_path = os.path.join(prefix, filename) return resource_path diff --git a/install/linux/build_deb.py b/install/linux/build_deb.py new file mode 100755 index 0000000..31b8de0 --- /dev/null +++ b/install/linux/build_deb.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import sys +import inspect +import subprocess +import shutil + +sys.path.insert( + 0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +) +import dangerzone + +version = dangerzone.dangerzone_version +root = os.path.dirname( + os.path.dirname( + os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + ) +) + + +def run(cmd): + subprocess.run(cmd, cwd=root, check=True) + + +def main(): + dist_path = os.path.join(root, "dist") + deb_dist_path = os.path.join(root, "deb_dist") + + print("* Deleting old dist and deb_dist") + if os.path.exists(dist_path): + shutil.rmtree(dist_path) + if os.path.exists(deb_dist_path): + shutil.rmtree(deb_dist_path) + + print("* Building DEB package") + run(["python3", "setup.py", "--command-packages=stdeb.command", "bdist_deb"]) + run(["python3", "setup.py", "--command-packages=stdeb.command", "sdist_dsc"]) + + print("") + print("* To install run:") + print("sudo dpkg -i deb_dist/dangerzone_{}-1_all.deb".format(version)) + + +if __name__ == "__main__": + main() diff --git a/install/linux/media.firstlook.dangerzone.desktop b/install/linux/media.firstlook.dangerzone.desktop new file mode 100644 index 0000000..d0dd840 --- /dev/null +++ b/install/linux/media.firstlook.dangerzone.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=dangerzone +GenericName=dangerzone +Comment=Take potentially dangerous PDFs, office documents, or images and convert them to a safe PDF +Exec=dangerzone %f +Terminal=false +Type=Application +Icon=media.firstlook.dangerzone +Categories=Office;Utility;OCR;Security +MimeType=application/pdf;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet diff --git a/install/linux/media.firstlook.dangerzone.png b/install/linux/media.firstlook.dangerzone.png new file mode 100644 index 0000000..4e8b27e Binary files /dev/null and b/install/linux/media.firstlook.dangerzone.png differ diff --git a/setup.py b/setup.py index 437bf22..7eb3f48 100644 --- a/setup.py +++ b/setup.py @@ -5,17 +5,33 @@ import sys from dangerzone import dangerzone_version +def file_list(path): + files = [] + for filename in os.listdir(path): + if os.path.isfile(os.path.join(path, filename)): + files.append(os.path.join(path, filename)) + return files + + setuptools.setup( name="dangerzone", version=dangerzone_version, author="Micah Lee", author_email="micah.lee@theintercept.com", license="MIT", - description="Take arbitrary untrusted PDFs, office documents, or images and convert them to a trusted PDF", + description="Take potentially dangerous PDFs, office documents, or images and convert them to a safe PDF", url="https://github.com/firstlookmedia/dangerzone", packages=["dangerzone"], + data_files=[ + ("share/applications", ["install/linux/media.firstlook.dangerzone.desktop"],), + ( + "share/icons/hicolor/64x64/apps", + ["install/linux/media.firstlook.dangerzone.png"], + ), + ("share/dangerzone", file_list("share")), + ("share/dangerzone/container", file_list("share/container")), + ], classifiers=( - "Development Status :: 4 - Beta", "Programming Language :: Python", "Intended Audience :: End Users/Desktop", "Operating System :: OS Independent", diff --git a/stdeb.cfg b/stdeb.cfg new file mode 100644 index 0000000..aff747a --- /dev/null +++ b/stdeb.cfg @@ -0,0 +1,6 @@ +[DEFAULT] +Package3: dangerzone +Depends3: python3, python3-pyqt5, python3-appdirs, python3-click, python3-xdg +Build-Depends: python3, python3-all +Suite: bionic +X-Python3-Version: >= 3.7 \ No newline at end of file