Skip to content

Commit

Permalink
Merge pull request #299 from goodwillcoding/toolchain-cleanup
Browse files Browse the repository at this point in the history
Development toolchain cleanup
  • Loading branch information
gornostal committed Oct 2, 2018
2 parents 613e57d + 0bc418e commit 1c173c0
Show file tree
Hide file tree
Showing 20 changed files with 175 additions and 54 deletions.
2 changes: 1 addition & 1 deletion build-utils/build-deb.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

######################
# Builds Ulauncher.deb
Expand Down
4 changes: 2 additions & 2 deletions build-utils/build-doc.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex

cd `dirname $0`/../docs

sphinx-apidoc -d 5 -o source ../ulauncher
make html
make html
2 changes: 1 addition & 1 deletion build-utils/build-preferences.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#############################################
# Builds Ulauncher Preferences UI with nodejs
Expand Down
2 changes: 1 addition & 1 deletion build-utils/build-rpm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

######################
# Builds Ulauncher.rpm
Expand Down
2 changes: 1 addition & 1 deletion build-utils/build-targz.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

##############################################################
# Builds tar.gz file with (un)install script and Ulauncher src
Expand Down
2 changes: 1 addition & 1 deletion build-utils/create-build-images.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

################################################
# Creates Docker images for building and testing
Expand Down
2 changes: 1 addition & 1 deletion build-utils/dev-container.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

##########################################################
# Runs Docker container to run build scripts from this dir
Expand Down
2 changes: 1 addition & 1 deletion build-utils/extract-launchpad-ssh.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# extracts ~/.shh for uploading package to ppa.launchpad.net via sftp

Expand Down
2 changes: 1 addition & 1 deletion build-utils/functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

export BUILD_IMAGE=ulauncher/build-image:3.1
export RPM_BUILD_IMAGE=ulauncher/rpm-build-image:3.0
Expand Down
2 changes: 1 addition & 1 deletion build-utils/release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#############################
# Build tar.gz in a container
Expand Down
2 changes: 1 addition & 1 deletion build-utils/send-sighup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

kill -HUP $(ps aux | grep '[u]launcher' | awk '{print $2}')

Expand Down
2 changes: 1 addition & 1 deletion build-utils/travis-cli-container.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# To encrypt AUR key:
# $ cd ulauncher
Expand Down
2 changes: 1 addition & 1 deletion build-utils/travis-test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

#####################################
# Runs pytests and builds preferences
Expand Down
2 changes: 1 addition & 1 deletion build-utils/watch-doc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

cd `dirname $0`/..

Expand Down
25 changes: 25 additions & 0 deletions dev-clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# remove icons
rm \
-v \
"${HOME}/.local/share/icons/hicolor/48x48/apps/ulauncher.svg" \
"${HOME}/.local/share/icons/hicolor/48x48/apps/ulauncher-indicator.svg" \
"${HOME}/.local/share/icons/hicolor/scalable/apps/ulauncher.svg" \
"${HOME}/.local/share/icons/hicolor/scalable/apps/ulauncher-indicator.svg" \
"${HOME}/.local/share/icons/gnome/scalable/apps/ulauncher.svg" \
"${HOME}/.local/share/icons/gnome/scalable/apps/ulauncher-indicator.svg" \
"${HOME}/.local/share/icons/breeze/apps/48/ulauncher-indicator.svg" \
"${HOME}/.local/share/icons/ubuntu-mono-dark/scalable/apps/ulauncher-indicator.svg" \
"${HOME}/.local/share/icons/ubuntu-mono-light/scalable/apps/ulauncher-indicator.svg" \
"${HOME}/.local/share/icons/elementary/scalable/apps/ulauncher-indicator.svg";

# remove application folder
rm \
-rv \
"${HOME}/.local/share/ulauncher";

# remove launcher
rm \
-v \
"${HOME}/.local/share/applications/ulauncher.desktop";
4 changes: 4 additions & 0 deletions dev-nkpy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

find . \( -type f -name "*.pyc" -o -type f -name "*.pyo" \) -exec rm {} \;
find . -type d -name "__pycache__" -prune -exec rm -rf {} \;
2 changes: 1 addition & 1 deletion dev-run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

echo "installing media files to ~/.local to be able to load icons by name"
python setup.py install_data --install-dir="$HOME/.local" || exit 1
Expand Down
4 changes: 2 additions & 2 deletions glade
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
#!/usr/bin/env bash

GLADE_CATALOG_SEARCH_PATH=./data/ui glade $@
GLADE_CATALOG_SEARCH_PATH=./data/ui glade $@
162 changes: 127 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

import os
import sys

from itertools import takewhile, dropwhile

try:
import DistUtilsExtra.auto
except ImportError:
print >> sys.stderr, 'To build ulauncher you need https://launchpad.net/python-distutils-extra'
print >> sys.stderr, "To build ulauncher you need"\
"https://launchpad.net/python-distutils-extra"
sys.exit(1)
assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'

assert DistUtilsExtra.auto.__version__ >= '2.18', \
'needs DistUtilsExtra.auto >= 2.18'


def update_config(libdir, values={}):
Expand All @@ -32,9 +36,10 @@ def update_config(libdir, values={}):
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError), e:
except (OSError, IOError):
print ("ERROR: Can't find %s" % filename)
sys.exit(1)

return oldvalues


Expand All @@ -44,7 +49,8 @@ def move_desktop_file(root, target_data, prefix):
# normal data files anywhere we want, the desktop file needs to exist in
# the main system to be found. Only actually useful for /opt installs.

old_desktop_path = os.path.normpath(root + target_data + '/share/applications')
old_desktop_path = os.path.normpath(root + target_data +
'/share/applications')
old_desktop_file = old_desktop_path + '/ulauncher.desktop'
desktop_path = os.path.normpath(root + prefix + '/share/applications')
desktop_file = desktop_path + '/ulauncher.desktop'
Expand All @@ -68,6 +74,9 @@ def move_desktop_file(root, target_data, prefix):

def update_desktop_file(filename, target_pkgdata, target_scripts):

def is_env(p):
return p == 'env' or '=' in p

try:
fin = file(filename, 'r')
fout = file(filename + '.new', 'w')
Expand All @@ -79,8 +88,8 @@ def update_desktop_file(filename, target_pkgdata, target_scripts):
# persist env vars
env_vars = ''
if cmd.startswith('env '):
is_env = lambda p: p == 'env' or '=' in p
env_vars = ' '.join(list(takewhile(is_env, cmd.split()))) + ' '
env_vars = ' '.join(list(takewhile(is_env, cmd.split()))) \
+ ' '
cmd = ' '.join(list(dropwhile(is_env, cmd.split())))

cmd = cmd.split(None, 1)
Expand All @@ -93,7 +102,7 @@ def update_desktop_file(filename, target_pkgdata, target_scripts):
fout.close()
fin.close()
os.rename(fout.name, fin.name)
except (OSError, IOError), e:
except (OSError, IOError):
print ("ERROR: Can't find %s" % filename)
sys.exit(1)

Expand All @@ -104,7 +113,8 @@ def run(self):

target_data = '/' + os.path.relpath(self.install_data, self.root) + '/'
target_pkgdata = target_data + 'share/ulauncher/'
target_scripts = '/' + os.path.relpath(self.install_scripts, self.root) + '/'
target_scripts = '/' + os.path.relpath(self.install_scripts,
self.root) + '/'

values = {'__ulauncher_data_directory__': "'%s'" % (target_pkgdata),
'__version__': "'%s'" % self.distribution.get_version()}
Expand All @@ -117,35 +127,117 @@ def run(self):
class DataFileList(list):

def append(self, item):
# don't add node_modules to data_files that DistUtilsExtra tries to add automatically
# don't add node_modules to data_files that DistUtilsExtra tries to
# add automatically
filename = item[1][0]
if 'node_modules' in filename or 'bower_components' in filename or '.tmp' in filename:
if 'node_modules' in filename \
or 'bower_components' in filename or '.tmp' in filename:
return
else:
return super(DataFileList, self).append(item)

DistUtilsExtra.auto.setup(
name='ulauncher',
version='%VERSION%',
license='GPL-3',
author='Aleksandr Gornostal',
author_email='ulauncher.app@gmail.com',
description='Application launcher for Linux',
url='http://ulauncher.io',
data_files=DataFileList([
('share/icons/hicolor/48x48/apps', ['data/media/icons/hicolor/ulauncher.svg']),
('share/icons/hicolor/48x48/apps', ['data/media/icons/hicolor/ulauncher-indicator.svg']),
('share/icons/hicolor/scalable/apps', ['data/media/icons/hicolor/ulauncher.svg']),
('share/icons/hicolor/scalable/apps', ['data/media/icons/hicolor/ulauncher-indicator.svg']),

# these two are fore Fedora+gnome
('share/icons/gnome/scalable/apps', ['data/media/icons/hicolor/ulauncher.svg']),
('share/icons/gnome/scalable/apps', ['data/media/icons/hicolor/ulauncher-indicator.svg']),

('share/icons/breeze/apps/48', ['data/media/icons/ubuntu-mono-light/ulauncher-indicator.svg']),
('share/icons/ubuntu-mono-dark/scalable/apps', ['data/media/icons/ubuntu-mono-dark/ulauncher-indicator.svg']),
('share/icons/ubuntu-mono-light/scalable/apps', ['data/media/icons/ubuntu-mono-light/ulauncher-indicator.svg']),
('share/icons/elementary/scalable/apps', ['data/media/icons/elementary/ulauncher-indicator.svg']),
]),
cmdclass={'install': InstallAndUpdateDataDirectory}
)

def exclude_files(patterns=[]):
"""
Suppress completely useless warning about files DistUtilsExta.aut does
recognize because require developer to scroll past them to get to useful
output.
Example of the useless warnings:
WARNING: the following files are not recognized by DistUtilsExtra.auto:
Dockerfile.build
Dockerfile.build-arch
Dockerfile.build-rpm
PKGBUILD.template
build-utils/aur-update.py
"""

# it's maddening the DistUtilsExtra does not offer a way to exclude globs
# from it's scans and just using "print" to print the warning instead of
# using warning module which has a mechanism for suppressions
# it forces us to take the approach of monkeypatching their src_find
# function.
original_src_find = DistUtilsExtra.auto.src_find

def src_find_with_excludes(attrs):
src = original_src_find(attrs)

for pattern in patterns:
DistUtilsExtra.auto.src_markglob(src, pattern)

return src

DistUtilsExtra.auto.src_find = src_find_with_excludes

return original_src_find


def main():

# exclude files/folder patterns from being considered by distutils-extra
# this returns the original DistUtilsExtra.auto.src_find function
# so we can patch bit back in later
original_find_src = exclude_files([
"*.sh",
"Dockerfile.build*",
"PKGBUILD.template",
"build-utils/*",
"docs/*",
"glade",
"test",
"ulauncher.desktop.*",
"requirements.txt",
])

DistUtilsExtra.auto.setup(
name='ulauncher',
version='%VERSION%',
license='GPL-3',
author='Aleksandr Gornostal',
author_email='ulauncher.app@gmail.com',
description='Application launcher for Linux',
url='http://ulauncher.io',
data_files=DataFileList([
('share/icons/hicolor/48x48/apps', [
'data/media/icons/hicolor/ulauncher.svg'
]),
('share/icons/hicolor/48x48/apps', [
'data/media/icons/hicolor/ulauncher-indicator.svg'
]),
('share/icons/hicolor/scalable/apps', [
'data/media/icons/hicolor/ulauncher.svg'
]),
('share/icons/hicolor/scalable/apps', [
'data/media/icons/hicolor/ulauncher-indicator.svg'
]),
# for fedora + GNOME
('share/icons/gnome/scalable/apps', [
'data/media/icons/hicolor/ulauncher.svg'
]),
('share/icons/gnome/scalable/apps', [
'data/media/icons/hicolor/ulauncher-indicator.svg'
]),
# for ubuntu
('share/icons/breeze/apps/48', [
'data/media/icons/ubuntu-mono-light/ulauncher-indicator.svg'
]),
('share/icons/ubuntu-mono-dark/scalable/apps', [
'data/media/icons/ubuntu-mono-dark/ulauncher-indicator.svg'
]),
('share/icons/ubuntu-mono-light/scalable/apps', [
'data/media/icons/ubuntu-mono-light/ulauncher-indicator.svg'
]),
('share/icons/elementary/scalable/apps', [
'data/media/icons/elementary/ulauncher-indicator.svg'
]),
]),
cmdclass={'install': InstallAndUpdateDataDirectory}
)

# unpatch distutils-extra src_find
DistUtilsExtra.auto.src_find = original_find_src


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Some tests will fail in Docker unless virtual frame buffer is running
if [ -f /.dockerenv ]; then
Expand Down

0 comments on commit 1c173c0

Please sign in to comment.