From fc42e8d894d485beb232d368d569d415df2ddfd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20M=C3=A9ndez?= Date: Sat, 6 Jul 2024 23:10:22 -0600 Subject: [PATCH] Fixing lint issues on debian packaging and adding python files --- README.md | 49 ++++++++++++++++++++++- audiosourcecd.cpp | 5 ++- debian/control | 6 +-- debian/copyright | 8 ++-- debian/rules | 4 ++ linamp.desktop | 1 + player.pro | 7 ++-- python/__init__.py | 0 python/linamp-mock/__init__.py | 1 + python/{ => linamp-mock}/mock_cdplayer.py | 0 python/linamp/__init__.py | 1 + python/{ => linamp}/cdplayer.py | 8 ++-- python/requirements.txt | 2 +- 13 files changed, 74 insertions(+), 18 deletions(-) delete mode 100644 python/__init__.py create mode 100644 python/linamp-mock/__init__.py rename python/{ => linamp-mock}/mock_cdplayer.py (100%) create mode 100644 python/linamp/__init__.py rename python/{ => linamp}/cdplayer.py (99%) diff --git a/README.md b/README.md index 3c685b7..904acb6 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,54 @@ pip install -r python/requirements.txt ### Building a Debian package -Install [sbuild](https://wiki.debian.org/sbuild) using option 3 (change `unstable` to your distro, eg `bookworm` and create the `.sbuildrc` manually instead of `tee`). +Install and setup [sbuild](https://wiki.debian.org/sbuild) running the following commands: -Then simply run `sbuild --no-run-piuparts --lintian-opt="--suppress-tags=bad-distribution-in-changes-file"` in the cloned repository directory. The `.deb` packages will be in your home directory afterwards if everything went well. +```bash +sudo apt-get install sbuild schroot debootstrap apt-cacher-ng devscripts piuparts +sudo tee ~/.sbuildrc << EOF +############################################################################## +# PACKAGE BUILD RELATED (additionally produce _source.changes) +############################################################################## +# -d +$distribution = 'bookworm'; +# -A +$build_arch_all = 1; +# -s +$build_source = 1; +# --source-only-changes (applicable for dput. irrelevant for dgit push-source). +$source_only_changes = 1; +# -v +$verbose = 1; +# parallel build +$ENV{'DEB_BUILD_OPTIONS'} = 'parallel=5'; +############################################################################## +# POST-BUILD RELATED (turn off functionality by setting variables to 0) +############################################################################## +$run_lintian = 1; +$lintian_opts = ['-i', '-I']; +$run_piuparts = 1; +$piuparts_opts = ['--schroot', '%r-%a-sbuild', '--no-eatmydata']; +$run_autopkgtest = 1; +$autopkgtest_root_args = ''; +$autopkgtest_opts = [ '--', 'schroot', '%r-%a-sbuild' ]; +############################################################################## +# PERL MAGIC +############################################################################## +1; +EOF +sudo sbuild-adduser $LOGNAME +newgrp sbuild +sudo ln -sf ~/.sbuildrc /root/.sbuildrc +sudo sbuild-createchroot --include=eatmydata,ccache bookworm /srv/chroot/bookworm-amd64-sbuild http://127.0.0.1:3142/ftp.us.debian.org/debian +``` + +Then simply run `sbuild --no-run-piuparts --lintian-opt="--suppress-tags=bad-distribution-in-changes-file"` in the cloned repository directory. The `.deb` packages will be in your home directory afterwards if everything went well. + +You can install the newly built packages with the following command (replace placeholders accordingly): + +```bash +sudo apt install ./linamp_[version]_[arch].deb +``` ### Known issues diff --git a/audiosourcecd.cpp b/audiosourcecd.cpp index f979c64..6942a17 100644 --- a/audiosourcecd.cpp +++ b/audiosourcecd.cpp @@ -13,8 +13,9 @@ AudioSourceCD::AudioSourceCD(QObject *parent) auto state = PyGILState_Ensure(); - PyObject *pModuleName = PyUnicode_DecodeFSDefault("cdplayer"); - //PyObject *pModuleName = PyUnicode_DecodeFSDefault("mock_cdplayer"); + // Import 'linamp' python module, see python folder in the root of this repo + PyObject *pModuleName = PyUnicode_DecodeFSDefault("linamp"); + //PyObject *pModuleName = PyUnicode_DecodeFSDefault("linamp-mock"); cdplayerModule = PyImport_Import(pModuleName); Py_DECREF(pModuleName); diff --git a/debian/control b/debian/control index a6d0488..1ecb73c 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: linamp -Section: Sound +Section: sound Priority: optional -Maintainer: Rodrigo Méndez +Maintainer: Rodrigo Méndez Rules-Requires-Root: no Build-Depends: debhelper-compat (= 13), @@ -36,6 +36,6 @@ Depends: python3-musicbrainzngs, python3-cdio, python3-vlc -Description: Music player app for Linamp - Your favorite music player of the 90s, but in real life. +Description: Your favorite music player of the 90s, but in real life Music player app for Linamp - Your favorite music player of the 90s, but in real life. Built with QT6. diff --git a/debian/copyright b/debian/copyright index d73243a..99122c8 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,16 +1,16 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: Upstream-Name: linamp -Upstream-Contact: Rodrigo Méndez +Upstream-Contact: Rodrigo Méndez Files: * Copyright: - 2024 Rodrigo Méndez -License: See LICENSE in parent directory + 2024 Rodrigo Méndez +License: GPL-3 Files: debian/* Copyright: 2024 Taneli Leppä -License: See LICENSE in parent directory +License: GPL-3 diff --git a/debian/rules b/debian/rules index 69f5faa..600f913 100755 --- a/debian/rules +++ b/debian/rules @@ -13,6 +13,10 @@ override_dh_auto_configure: override_dh_auto_install: mkdir -p debian/linamp/usr/bin cp player debian/linamp/usr/bin/linamp-player + + mkdir -p debian/linamp/usr/lib/python3/dist-packages/linamp + cp python/linamp/__init__.py debian/linamp/usr/lib/python3/dist-packages/linamp/__init__.py + cp python/linamp/cdplayer.py debian/linamp/usr/lib/python3/dist-packages/linamp/cdplayer.py mkdir -p debian/linamp/usr/share/applications/ cp linamp.desktop debian/linamp/usr/share/applications/ diff --git a/linamp.desktop b/linamp.desktop index 0f16858..6bb57c8 100644 --- a/linamp.desktop +++ b/linamp.desktop @@ -8,3 +8,4 @@ Terminal=false #StartupWMClass=name of application Type=Application Categories=Audio +Keywords=linamp;music;sound;audio;player; \ No newline at end of file diff --git a/player.pro b/player.pro index b150fd0..a695fa0 100644 --- a/player.pro +++ b/player.pro @@ -88,9 +88,10 @@ RESOURCES += \ DISTFILES += \ README.md \ install.sh \ - python/__init__.py \ - python/cdplayer.py \ - python/mock_cdplayer.py \ + python/linamp/__init__.py \ + python/linamp/cdplayer.py \ + python/linamp-mock/__init__.py \ + python/linamp-mock/mock_cdplayer.py \ python/requirements.txt \ scale-skin.sh \ setup.sh \ diff --git a/python/__init__.py b/python/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/python/linamp-mock/__init__.py b/python/linamp-mock/__init__.py new file mode 100644 index 0000000..e5dab56 --- /dev/null +++ b/python/linamp-mock/__init__.py @@ -0,0 +1 @@ +from .mock_cdplayer import * diff --git a/python/mock_cdplayer.py b/python/linamp-mock/mock_cdplayer.py similarity index 100% rename from python/mock_cdplayer.py rename to python/linamp-mock/mock_cdplayer.py diff --git a/python/linamp/__init__.py b/python/linamp/__init__.py new file mode 100644 index 0000000..2916948 --- /dev/null +++ b/python/linamp/__init__.py @@ -0,0 +1 @@ +from .cdplayer import * diff --git a/python/cdplayer.py b/python/linamp/cdplayer.py similarity index 99% rename from python/cdplayer.py rename to python/linamp/cdplayer.py index 796348f..7f4738e 100644 --- a/python/cdplayer.py +++ b/python/linamp/cdplayer.py @@ -2,10 +2,11 @@ import vlc import cdio, pycdio -import discid +import libdiscid import musicbrainzngs import threading + # Debounce function from https://github.com/salesforce/decorator-operations/blob/master/decoratorOperations/debounce_functions/debounce.py def debounce(wait_time): """ @@ -31,6 +32,7 @@ def call_function(): return decorator + def search_exact_tracklist(data): # function to find exalctly which cd was inserted for x in range(0, len(data["disc"]["release-list"])): for y in range(0, len(data["disc"]["release-list"][x]["medium-list"])): @@ -68,7 +70,7 @@ def fetchdata(): is_data_tracks[t - i_first_track] = True musicbrainzngs.set_useragent("Small_diy_cd_player", "0.1") - disc = discid.read() # id read + disc = libdiscid.read() # id read try: result = musicbrainzngs.get_releases_by_discid( disc.id, includes=["artists", "recordings"] @@ -205,7 +207,7 @@ def load(self): print(f"Unknown exception: {e}") return - #print(f">>>> {artists}, {track_titles}, {album}, {n_tracks}") + # print(f">>>> {artists}, {track_titles}, {album}, {n_tracks}") self._set_track_info(artists, track_titles, album, durations, is_data_tracks) diff --git a/python/requirements.txt b/python/requirements.txt index 83c5f08..91b114b 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,4 +1,4 @@ -discid==1.2.0 +python-libdiscid==2.0.3 musicbrainzngs==0.7.1 pycdio==2.1.1 python-vlc==3.0.20123