mirror of https://gitlab.com/openlp/packaging.git
112 lines
4.1 KiB
Python
112 lines
4.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
|
|
|
##########################################################################
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
# ---------------------------------------------------------------------- #
|
|
# Copyright (c) 2008-2024 OpenLP Developers #
|
|
# ---------------------------------------------------------------------- #
|
|
# This program is free software: you can redistribute it and/or modify #
|
|
# it under the terms of the GNU General Public License as published by #
|
|
# the Free Software Foundation, either version 3 of the License, or #
|
|
# (at your option) any later version. #
|
|
# #
|
|
# This program is distributed in the hope that it will be useful, #
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
# GNU General Public License for more details. #
|
|
# #
|
|
# You should have received a copy of the GNU General Public License #
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
|
##########################################################################
|
|
|
|
"""
|
|
Linux Build Script
|
|
--------------------
|
|
|
|
This script is used to build the Linux app bundle.
|
|
|
|
Look in setup.py in the openlp code repo for dependencies
|
|
|
|
Other dependencies:
|
|
|
|
PyInstaller
|
|
PyInstaller can be installed with pip
|
|
|
|
Git
|
|
You need the command line "git" client installed.
|
|
|
|
config.ini.default
|
|
The configuration file contains settings of the version string to include
|
|
in the bundle as well as directory and file settings for different
|
|
purposes (e.g. PyInstaller location or installer background image)
|
|
|
|
"""
|
|
|
|
import glob
|
|
import os
|
|
import platform
|
|
from pathlib import Path
|
|
from shutil import copy, copytree, move, rmtree
|
|
|
|
from builder import Builder
|
|
|
|
|
|
class LinuxBuilder(Builder):
|
|
"""
|
|
The :class:`LinuxBuilder` class encapsulates everything that is needed
|
|
to build a Linux app bundle.
|
|
"""
|
|
|
|
def get_platform(self):
|
|
"""
|
|
Return the plaform we're building for
|
|
"""
|
|
return 'Linux'
|
|
|
|
def get_qt_translations_path(self):
|
|
"""
|
|
Return the path to Qt translation files on macOS
|
|
"""
|
|
from PyQt5.QtCore import QCoreApplication
|
|
qt_library_path = QCoreApplication.libraryPaths()[0]
|
|
return os.path.join(os.path.dirname(qt_library_path), 'translations')
|
|
|
|
def setup_paths(self):
|
|
"""
|
|
Set up a variety of paths that we use throughout the build process.
|
|
"""
|
|
super().setup_paths()
|
|
self.dist_path = os.path.join(self.work_path, 'dist', 'OpenLP')
|
|
|
|
def copy_extra_files(self):
|
|
"""
|
|
Copy any extra files which are particular to a platform
|
|
"""
|
|
self._print('Copying extra files for Linux...')
|
|
self._print_verbose('... LICENSE.txt')
|
|
copy(self.license_path, os.path.join(self.dist_path, 'LICENSE.txt'))
|
|
|
|
random_vlc_file = glob.glob('/usr/**/vlc-cache-gen', recursive = True)
|
|
if random_vlc_file:
|
|
vlc_lib_folder = os.path.dirname(random_vlc_file[0])
|
|
vlc_plugin_dest = os.path.join(self.dist_path, '_internal')
|
|
if os.path.exists(os.path.join(vlc_plugin_dest, 'vlc')):
|
|
rmtree(os.path.join(vlc_plugin_dest, 'vlc'))
|
|
self._print_verbose('... copying VLC plugins')
|
|
copytree(vlc_lib_folder, os.path.join(vlc_plugin_dest, 'vlc'))
|
|
|
|
def build_package(self):
|
|
"""
|
|
Build the tar.gz
|
|
"""
|
|
self._print('Creating tar.gz bundle...')
|
|
# TODO: rename OpenLP folder to include version number?
|
|
cmd = 'tar -zcf OpenLP-bin-linux-{machine}.tar.gz OpenLP'.format(machine=platform.machine())
|
|
os.system(cmd)
|
|
self._print('Created tar.gz bundle.')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
LinuxBuilder().main()
|