From f5fee9ae355ab67cadcd440bc2d3455d10368e5c Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Fri, 1 Oct 2021 16:36:58 +0200 Subject: [PATCH] Fixing a lot of bugs of packages. --- linux/debian/compat | 1 - linux/debian/install | 1 - linux/flatpak/eu.ad5001.LogarithmPlotter.json | 2 +- linux/sign-deb.sh | 24 ++++++++++ package-linux.sh | 4 +- setup.py | 44 +++++++++++++------ 6 files changed, 58 insertions(+), 18 deletions(-) delete mode 100644 linux/debian/compat delete mode 100644 linux/debian/install create mode 100755 linux/sign-deb.sh diff --git a/linux/debian/compat b/linux/debian/compat deleted file mode 100644 index b4de394..0000000 --- a/linux/debian/compat +++ /dev/null @@ -1 +0,0 @@ -11 diff --git a/linux/debian/install b/linux/debian/install deleted file mode 100644 index a93c044..0000000 --- a/linux/debian/install +++ /dev/null @@ -1 +0,0 @@ -logarithmplotter usr/bin/ diff --git a/linux/flatpak/eu.ad5001.LogarithmPlotter.json b/linux/flatpak/eu.ad5001.LogarithmPlotter.json index 5648e3a..4ca208e 100644 --- a/linux/flatpak/eu.ad5001.LogarithmPlotter.json +++ b/linux/flatpak/eu.ad5001.LogarithmPlotter.json @@ -23,12 +23,12 @@ ], "modules": [ "python3-pyside2.json", - { "name": "LogarithmPlotter", "buildsystem": "simple", "config-opts": ["no-debuginfo-compression"], "build-commands": [ + "rm -rf .git", "PREFIX=\"/app/share\" FLATPAK_INSTALL=1 python3 setup.py install --prefix=/app" ], "sources": [ diff --git a/linux/sign-deb.sh b/linux/sign-deb.sh new file mode 100755 index 0000000..ff11a01 --- /dev/null +++ b/linux/sign-deb.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# This script is used to sign the LogarithmPlotter deb directly from it's DSC file. +# Adapted from https://github.com/astraw/stdeb/issues/181 + +PPA_ARCHIVE="ppa:ad5001/logarithmplotter" + +cd ../deb_dist + +# create a temporary folder +mkdir tmp -p +cd tmp +rm -rf * + +# DSC file variables +dsc_file="$(find ../ -regextype sed -regex ".*/*\-ppa[0-9]*.dsc" | cut -c 4-)" +source_package_name="$(echo $dsc_file | cut -c -$(expr ${#dsc_file} - 4))" + +# extract and sign the files +dpkg-source -x "../$dsc_file" +cd "$(find . -type d | head -n 2 | tail -n 1 | cut -c 3-)" # go to the (only) directory. +debuild -S -sa -k"mail@ad5001.eu" + +# upload package to my PPA +dput $PPA_ARCHIVE "../${source_package_name}_source.changes" diff --git a/package-linux.sh b/package-linux.sh index 7760b08..506c5df 100755 --- a/package-linux.sh +++ b/package-linux.sh @@ -1,6 +1,8 @@ #!/bin/bash -python3 setup.py --command-packages=stdeb.command sdist_dsc --package logarithmplotter --copyright-file linux/debian/copyright --suite hirsute --recommends "$(cat linux/debian/recommends)" --depends "$(cat linux/debian/depends)" --section science bdist_deb +python3 setup.py --remove-git-version --command-packages=stdeb.command sdist_dsc \ + --package logarithmplotter --copyright-file linux/debian/copyright --suite hirsute --depends3 "$(cat linux/debian/depends)" --section science \ + --upstream-version-suffix "-patch1" --debian-version "ppa1" bdist_deb # Flatpak building FLATPAK_BUILDER=$(which flatpak-builder) diff --git a/setup.py b/setup.py index 8b47858..ef20ae4 100644 --- a/setup.py +++ b/setup.py @@ -20,23 +20,35 @@ import setuptools import os import sys +print(sys.argv) + current_dir = os.path.realpath(os.path.dirname(os.path.realpath(__file__))) if "PREFIX" not in os.environ and sys.platform == 'linux': - if "XDG_DATA_HOME" in os.environ: - os.environ["PREFIX"] = os.environ["XDG_DATA_HOME"] - else : - try: - # Checking if we have permission to write to root. - from os import makedirs, rmdir - makedirs("/usr/share/applications/test") - rmdir("/usr/share/applications/test") - os.environ["PREFIX"] = "/usr/share" - except: - os.environ["PREFIX"] = os.environ["HOME"] + "/.local/share" + from getopt import getopt + optlist, args = getopt(sys.argv, '', ['prefix=', 'root=']) + for arg,value in optlist: + if arg == "prefix": + os.environ["PREFIX"] = value + if "PREFIX" not in os.environ and sys.platform == 'linux': + if "XDG_DATA_HOME" in os.environ: + os.environ["PREFIX"] = os.environ["XDG_DATA_HOME"] + else: + try: + # Checking if we have permission to write to root. + from os import makedirs, rmdir + makedirs("/usr/share/applications/test") + rmdir("/usr/share/applications/test") + os.environ["PREFIX"] = "/usr/share" + except: + os.environ["PREFIX"] = os.environ["HOME"] + "/.local/share" from LogarithmPlotter import __VERSION__ as pkg_version +if "--remove-git-version" in sys.argv: + pkg_version = pkg_version.split(".dev0")[0] + sys.argv.remove("--remove-git-version") + CLASSIFIERS = """ Environment :: Graphic Environment :: X11 Applications :: Qt @@ -70,7 +82,11 @@ def package_data(): data_files = [] if sys.platform == 'linux': - data_files.append((os.environ["PREFIX"] + '/applications/', ['linux/logarithmplotter.desktop'])) + data_files.append(('share/applications/', ['linux/logarithmplotter.desktop'])) + data_files.append(('share/mime/packages/', ['linux/x-logarithm-plot.xml'])) + data_files.append(('share/icons/hicolor/scalable/mimetypes/', ['linux/application-x-logarithm-plot.svg'])) + data_files.append(('share/icons/hicolor/scalable/apps/', ['logplotter.svg'])) + """data_files.append((os.environ["PREFIX"] + '/applications/', ['linux/logarithmplotter.desktop'])) data_files.append((os.environ["PREFIX"] + '/mime/packages/', ['linux/x-logarithm-plot.xml'])) data_files.append((os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/', ['linux/application-x-logarithm-plot.svg'])) data_files.append((os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/', ['logplotter.svg'])) @@ -94,7 +110,7 @@ if sys.platform == 'linux': os.remove(os.environ["PREFIX"] + '/applications/logarithmplotter.desktop') os.remove(os.environ["PREFIX"] + '/mime/packages/x-logarithm-plot.xml') os.remove(os.environ["PREFIX"] + '/icons/hicolor/scalable/mimetypes/application-x-logarithm-plot.svg') - os.remove(os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/logplotter.svg') + os.remove(os.environ["PREFIX"] + '/icons/hicolor/scalable/apps/logplotter.svg')""" setuptools.setup( install_requires=([] if "FLATPAK_INSTALL" in os.environ else ["PySide2"]), @@ -111,7 +127,7 @@ setuptools.setup( author_email='mail@ad5001.eu', license=('GPLv3'), - url='https://apps.ad5001.eu/logarithmplotter', + url='https://apps.ad5001.eu/logarithmplotter/', classifiers=CLASSIFIERS, zip_safe=False,