2020-05-27 11:36:36 -04:00
|
|
|
"""
|
2014-01-13 23:09:51 -06:00
|
|
|
@file
|
2014-06-18 22:57:40 -05:00
|
|
|
@brief Setup script to install OpenShot (on Linux and without any dependencies such as libopenshot)
|
2014-01-13 23:09:51 -06:00
|
|
|
@author Jonathan Thomas <jonathan@openshot.org>
|
2020-05-27 11:36:36 -04:00
|
|
|
|
2014-01-13 23:09:51 -06:00
|
|
|
@section LICENSE
|
2020-05-27 11:36:36 -04:00
|
|
|
|
2016-01-09 15:45:02 -06:00
|
|
|
Copyright (c) 2008-2016 OpenShot Studios, LLC
|
2014-01-13 23:09:51 -06:00
|
|
|
(http://www.openshotstudios.com). This file is part of
|
|
|
|
|
OpenShot Video Editor (http://www.openshot.org), an open-source project
|
|
|
|
|
dedicated to delivering high quality video editing and animation solutions
|
|
|
|
|
to the world.
|
2020-05-27 11:36:36 -04:00
|
|
|
|
2014-01-13 23:09:51 -06:00
|
|
|
OpenShot Video Editor 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.
|
2020-05-27 11:36:36 -04:00
|
|
|
|
2014-01-13 23:09:51 -06:00
|
|
|
OpenShot Video Editor 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.
|
2020-05-27 11:36:36 -04:00
|
|
|
|
2014-01-13 23:09:51 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
"""
|
2014-01-13 17:18:36 -06:00
|
|
|
|
2015-10-06 16:58:15 -05:00
|
|
|
import os
|
|
|
|
|
import sys
|
2015-10-21 00:35:28 -05:00
|
|
|
import fnmatch
|
2015-10-06 16:58:15 -05:00
|
|
|
import subprocess
|
2015-10-21 00:35:28 -05:00
|
|
|
from setuptools import setup
|
|
|
|
|
from shutil import copytree, rmtree, copy
|
2015-10-06 16:58:15 -05:00
|
|
|
|
2015-10-27 23:59:08 -05:00
|
|
|
|
2015-10-21 00:35:28 -05:00
|
|
|
# Determine absolute PATH of OpenShot folder
|
|
|
|
|
PATH = os.path.dirname(os.path.realpath(__file__)) # Primary openshot folder
|
|
|
|
|
|
|
|
|
|
# Make a copy of the src tree (temporary for naming reasons only)
|
|
|
|
|
if os.path.exists(os.path.join(PATH, "src")):
|
2015-10-22 12:21:46 -05:00
|
|
|
print("Copying modules to openshot_qt directory: %s" % os.path.join(PATH, "openshot_qt"))
|
2015-10-21 00:35:28 -05:00
|
|
|
# Only make a copy if the SRC directory is present (otherwise ignore this)
|
|
|
|
|
copytree(os.path.join(PATH, "src"), os.path.join(PATH, "openshot_qt"))
|
|
|
|
|
|
2015-10-22 12:21:46 -05:00
|
|
|
if os.path.exists(os.path.join(PATH, "openshot_qt")):
|
|
|
|
|
# Append path to system path
|
|
|
|
|
sys.path.append(os.path.join(PATH, "openshot_qt"))
|
|
|
|
|
print("Loaded modules from openshot_qt directory: %s" % os.path.join(PATH, "openshot_qt"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from classes import info
|
|
|
|
|
from classes.logger import log
|
2014-01-13 17:18:36 -06:00
|
|
|
|
2014-01-13 23:09:51 -06:00
|
|
|
log.info("Execution path: %s" % os.path.abspath(__file__))
|
|
|
|
|
|
2014-01-13 17:18:36 -06:00
|
|
|
# Boolean: running as root?
|
|
|
|
|
ROOT = os.geteuid() == 0
|
|
|
|
|
# For Debian packaging it could be a fakeroot so reset flag to prevent execution of
|
|
|
|
|
# system update services for Mime and Desktop registrations.
|
|
|
|
|
# The debian/openshot.postinst script must do those.
|
2020-09-24 17:51:13 +02:00
|
|
|
if os.getenv("FAKEROOTKEY") is not None:
|
2015-10-06 16:58:15 -05:00
|
|
|
log.info("NOTICE: Detected execution in a FakeRoot so disabling calls to system update services.")
|
|
|
|
|
ROOT = False
|
2014-01-13 17:18:36 -06:00
|
|
|
|
|
|
|
|
os_files = [
|
2015-10-06 16:58:15 -05:00
|
|
|
# XDG application description
|
2019-08-07 20:43:37 +02:00
|
|
|
('share/applications', ['xdg/org.openshot.OpenShot.desktop']),
|
2018-08-08 20:11:57 +02:00
|
|
|
# AppStream metadata
|
2019-08-07 20:43:37 +02:00
|
|
|
('share/metainfo', ['xdg/org.openshot.OpenShot.appdata.xml']),
|
2018-09-10 21:31:37 -04:00
|
|
|
# Debian menu system application icon
|
2016-01-12 00:38:22 -06:00
|
|
|
('share/pixmaps', ['xdg/openshot-qt.svg']),
|
2018-09-10 21:31:37 -04:00
|
|
|
# XDG Freedesktop icon paths
|
|
|
|
|
('share/icons/hicolor/scalable/apps', ['xdg/openshot-qt.svg']),
|
2020-05-27 11:36:36 -04:00
|
|
|
('share/icons/hicolor/scalable/mimetypes', ['xdg/openshot-qt-doc.svg']),
|
2019-06-15 11:39:29 +02:00
|
|
|
('share/icons/hicolor/64x64/apps', ['xdg/icon/64/openshot-qt.png']),
|
2020-04-14 11:45:00 +02:00
|
|
|
('share/icons/hicolor/128x128/apps', ['xdg/icon/128/openshot-qt.png']),
|
2019-06-15 11:39:29 +02:00
|
|
|
('share/icons/hicolor/256x256/apps', ['xdg/icon/256/openshot-qt.png']),
|
|
|
|
|
('share/icons/hicolor/512x512/apps', ['xdg/icon/512/openshot-qt.png']),
|
2015-10-06 16:58:15 -05:00
|
|
|
# XDG desktop mime types cache
|
2019-08-07 20:43:37 +02:00
|
|
|
('share/mime/packages', ['xdg/org.openshot.OpenShot.xml']),
|
2015-10-06 16:58:15 -05:00
|
|
|
# launcher (mime.types)
|
2016-01-12 00:38:22 -06:00
|
|
|
('lib/mime/packages', ['xdg/openshot-qt']),
|
2014-01-13 17:18:36 -06:00
|
|
|
]
|
|
|
|
|
|
2015-10-21 00:35:28 -05:00
|
|
|
# Find files matching patterns
|
|
|
|
|
def find_files(directory, patterns):
|
|
|
|
|
""" Recursively find all files in a folder tree """
|
|
|
|
|
for root, dirs, files in os.walk(directory):
|
|
|
|
|
for basename in files:
|
|
|
|
|
if ".pyc" not in basename and "__pycache__" not in basename:
|
|
|
|
|
for pattern in patterns:
|
|
|
|
|
if fnmatch.fnmatch(basename, pattern):
|
|
|
|
|
filename = os.path.join(root, basename)
|
|
|
|
|
yield filename
|
2015-10-06 16:58:15 -05:00
|
|
|
|
2014-01-13 17:18:36 -06:00
|
|
|
|
2015-10-21 00:35:28 -05:00
|
|
|
package_data = {}
|
|
|
|
|
|
|
|
|
|
# Find all project files
|
|
|
|
|
src_files = []
|
|
|
|
|
for filename in find_files(os.path.join(PATH, "openshot_qt"), ["*"]):
|
|
|
|
|
src_files.append(filename.replace(os.path.join(PATH, "openshot_qt"), ""))
|
|
|
|
|
package_data["openshot_qt"] = src_files
|
|
|
|
|
|
2014-01-13 17:18:36 -06:00
|
|
|
# Call the main Distutils setup command
|
|
|
|
|
# -------------------------------------
|
|
|
|
|
dist = setup(
|
2015-10-21 00:35:28 -05:00
|
|
|
packages=[('openshot_qt')],
|
|
|
|
|
package_data=package_data,
|
2015-10-06 16:58:15 -05:00
|
|
|
data_files=os_files,
|
2015-10-21 00:35:28 -05:00
|
|
|
include_package_data=True,
|
2015-10-06 16:58:15 -05:00
|
|
|
**info.SETUP
|
2014-01-13 17:18:36 -06:00
|
|
|
)
|
|
|
|
|
# -------------------------------------
|
|
|
|
|
|
2015-10-21 00:35:28 -05:00
|
|
|
# Remove temporary folder (if SRC folder present)
|
|
|
|
|
if os.path.exists(os.path.join(PATH, "src")):
|
2016-01-14 02:10:01 -06:00
|
|
|
rmtree(os.path.join(PATH, "openshot_qt"), True)
|
2014-01-13 17:18:36 -06:00
|
|
|
|
|
|
|
|
FAILED = 'Failed to update.\n'
|
|
|
|
|
|
|
|
|
|
if ROOT and dist != None:
|
2015-10-06 16:58:15 -05:00
|
|
|
# update the XDG Shared MIME-Info database cache
|
|
|
|
|
try:
|
|
|
|
|
sys.stdout.write('Updating the Shared MIME-Info database cache.\n')
|
|
|
|
|
subprocess.call(["update-mime-database", os.path.join(sys.prefix, "share/mime/")])
|
|
|
|
|
except:
|
|
|
|
|
sys.stderr.write(FAILED)
|
2014-01-13 17:18:36 -06:00
|
|
|
|
2015-10-06 16:58:15 -05:00
|
|
|
# update the mime.types database
|
|
|
|
|
try:
|
|
|
|
|
sys.stdout.write('Updating the mime.types database\n')
|
|
|
|
|
subprocess.call("update-mime")
|
|
|
|
|
except:
|
|
|
|
|
sys.stderr.write(FAILED)
|
2014-01-13 17:18:36 -06:00
|
|
|
|
2015-10-06 16:58:15 -05:00
|
|
|
# update the XDG .desktop file database
|
|
|
|
|
try:
|
|
|
|
|
sys.stdout.write('Updating the .desktop file database.\n')
|
|
|
|
|
subprocess.call(["update-desktop-database"])
|
|
|
|
|
except:
|
|
|
|
|
sys.stderr.write(FAILED)
|
|
|
|
|
sys.stdout.write("\n-----------------------------------------------")
|
|
|
|
|
sys.stdout.write("\nInstallation Finished!")
|
2016-01-25 01:09:23 -06:00
|
|
|
sys.stdout.write("\nRun OpenShot by typing 'openshot-qt' or through the Applications menu.")
|
2015-10-06 16:58:15 -05:00
|
|
|
sys.stdout.write("\n-----------------------------------------------\n")
|