Commit 46c31ddf authored by Kevin Funk's avatar Kevin Funk

install_colorschemes: Rework script

Changes:
- Make it work under Windows
- Extract only interesting paths (optimization)
- Pass the install dir, not prefix (thus /usr/share instead of /usr)
parent 278ec086
......@@ -222,7 +222,7 @@ build_project kdev-clang-tidy $KDEV_CLANG_TIDY_VERSION
# Install some colorschemes
cd $BUILD
$SCRIPT_DIR/../release-scripts/install_colorschemes.py /kdevelop.appdir/usr
$SCRIPT_DIR/../release-scripts/install_colorschemes.py /kdevelop.appdir/usr/share
cd /kdevelop.appdir
......
#!/usr/bin/env python3
#
# Downloads color schemes from download.kde.org and installs them into the desired prefix
# Usage: install_colorschemes.py [INSTALL_PREFIX]
# Usage: install_colorschemes.py [INSTALL_DIR]
import distutils.dir_util
import os
......@@ -10,11 +10,11 @@ import sys
import tarfile
import urllib.request
installPrefix = sys.argv[1] if len(sys.argv) > 1 else None
installDir = sys.argv[1] if len(sys.argv) > 1 else None
ver = "5.13.4" # Plasma version
colorSchemesDir = "share/color-schemes"
colorSchemesDir = "color-schemes"
def downloadAndExtract(url):
def downloadAndExtract(url, extractPath):
fname = os.path.basename(url)
if not os.path.exists(fname):
print("Downloading {0}".format(url))
......@@ -24,18 +24,20 @@ def downloadAndExtract(url):
print("Unpacking {0}".format(fname))
dirname = fname.replace(".tar.xz", "")
shutil.rmtree(dirname)
shutil.rmtree(dirname, ignore_errors=True)
with tarfile.open(fname) as tar:
tar.extractall()
for tarinfo in tar.getmembers():
if tarinfo.name.startswith(extractPath):
tarinfo.name = os.path.basename(tarinfo.name) # remove the path by reset it
tar.extract(member=tarinfo, path=colorSchemesDir)
downloadAndExtract('https://download.kde.org/stable/plasma/{0}/breeze-{0}.tar.xz'.format(ver))
downloadAndExtract('https://download.kde.org/stable/plasma/{0}/plasma-desktop-{0}.tar.xz'.format(ver))
distutils.dir_util.copy_tree(os.path.join("breeze-{0}".format(ver), "colors"), colorSchemesDir)
distutils.dir_util.copy_tree(os.path.join("plasma-desktop-{0}".format(ver), "kcms/colors/schemes"), colorSchemesDir)
downloadAndExtract('https://download.kde.org/stable/plasma/{0}/breeze-{0}.tar.xz'.format(ver),
"breeze-{0}/colors/".format(ver))
downloadAndExtract('https://download.kde.org/stable/plasma/{0}/plasma-desktop-{0}.tar.xz'.format(ver),
"plasma-desktop-{0}/kcms/colors/schemes/".format(ver))
print("Available color schemes: {0}".format(", ".join(os.listdir(colorSchemesDir))))
if installPrefix:
print("Installing to: {0}".format(installPrefix))
distutils.dir_util.copy_tree(colorSchemesDir, os.path.join(installPrefix, colorSchemesDir))
if installDir:
print("Installing to: {0}".format(installDir))
distutils.dir_util.copy_tree(colorSchemesDir, os.path.join(installDir, colorSchemesDir))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment