Skip to content

Commit

Permalink
fix data installation
Browse files Browse the repository at this point in the history
data/wscript_build:
- removed misleading #!/usr/bin/env python2
- wildcards need ant_glob now

wscript:
- help is excluded for now.
- gnome feature is no longer available in waf.
  => postinstall_icons and postinstall_scrollkeeper commented out for now.
- hamster-time-tracker.schemas is first generated in the build root,
  and subsequently installed to /etc/gconf/schemas/.
  The destination can be changed with the new --gconf-dir option.
  So packagers would use something like
  ./waf configure build --gconf-dir=%{_sysconfdir}/gconf <...>
- gconf schemas are now correctly registered globally with
  --makefile-install-rule
  this should reduce the risk of facing issue 265 again
  ("Tracking settings don't save")
- bld.new_task_gen(...) is not available any longer,
  replaced with bld(...)
  • Loading branch information
ederag committed Jul 9, 2019
1 parent e6d0d5b commit 9a157c0
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 57 deletions.
15 changes: 8 additions & 7 deletions data/wscript_build
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python2
# encoding: utf-8
# This file is meant to be included in the root wscript,
# through the recurse("data") command

bld.install_files('${DATADIR}/hamster-time-tracker', '*.ui')
start_dir = bld.path.find_dir('.')
bld.install_files('${DATADIR}/hamster-time-tracker', start_dir.ant_glob('*.ui'))
bld.install_files('${DATADIR}/hamster-time-tracker', 'hamster.db')
bld.install_files('${DATADIR}/hamster-time-tracker/art', 'art/*.png')
bld.install_files('${DATADIR}/hamster-time-tracker/art', start_dir.ant_glob('art/*.png'))
bld.install_files('${DATADIR}/hamster-time-tracker', 'report_template.html')

bld.install_files('${DATADIR}/icons/hicolor/16x16/apps', 'art/16x16/hamster-time-tracker.png')
Expand All @@ -28,14 +29,14 @@ bld.add_group()
# process .in files with intl_tool
bld(features = 'intltool_in',
source = 'hamster-time-tracker.schemas.in',
install_path = '${SYSCONFDIR}/gconf/schemas',
install_path = 'hamster-time-tracker.schemas',
podir = '../po',
flags = ['-s', '-u', '-c'])
flags = ['-s', '-u'])

bld(features = 'intltool_in',
source = """hamster-time-tracker-overview.desktop.in
hamster-time-tracker.desktop.in
hamster-windows-service.desktop.in""",
install_path = '${DATADIR}/applications',
podir = '../po',
flags = ['-d', '-q', '-u', '-c'])
flags = ['-d', '-q', '-u'])
120 changes: 70 additions & 50 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,37 @@ APPNAME = 'hamster-time-tracker'
top = '.'
out = 'build'

import intltool, gnome
import os
from waflib import Logs, Utils

def manage_gconf_schemas(ctx, action):
"""Install or uninstall hamster gconf schemas.
Requires the stored hamster-time-tracker.schemas
(usually in /etc/gconf/schemas/) to be present.
Hence install should be a post-fun,
and uninstall a pre-fun.
"""

assert action in ("install", "uninstall")
if ctx.cmd == action:
schemas_file = "{}/hamster-time-tracker.schemas".format(ctx.env.schemas_destination)
cmd = 'GCONF_CONFIG_SOURCE=$(gconftool-2 --get-default-source) gconftool-2 --makefile-{}-rule {} 1> /dev/null'.format(action, schemas_file)
err = ctx.exec_command(cmd)
if err:
Logs.warn('The following command failed:\n{}'.format(cmd))
else:
Logs.pprint('YELLOW', 'Successfully {}ed gconf schemas'.format(action))


def configure(conf):
conf.check_tool('python')
conf.check_tool('misc')
conf.check_python_version((2,4,2))
conf.load('gnu_dirs') # for DATADIR
conf.load('python')
conf.check_python_version(minver=(3,4,0))

conf.check_tool('gnome intltool dbus')
conf.load('intltool')
conf.load('dbus')

conf.define('ENABLE_NLS', 1)
conf.define('HAVE_BIND_TEXTDOMAIN_CODESET', 1)
Expand All @@ -22,23 +44,21 @@ def configure(conf):
conf.define('PACKAGE', "hamster-time-tracker")
conf.define('PYEXECDIR', conf.env["PYTHONDIR"]) # i don't know the difference

# avoid case when we want to install globally (prefix=/usr) but sysconfdir
# was not specified
if conf.env['SYSCONFDIR'] == '/usr/etc':
conf.define('SYSCONFDIR', '/etc')
else:
conf.define('SYSCONFDIR', conf.env['SYSCONFDIR'])
# SYSCONFDIR default should not be /usr/etc, but /etc
# TODO: should not be necessary any longer, with the --gconf-dir option
if conf.env.SYSCONFDIR == '/usr/etc':
conf.env.SYSCONFDIR = '/etc'

conf.define('prefix', conf.env["PREFIX"]) # to keep compatibility for now

conf.sub_config("help")
# gconf_dir is defined in options
conf.env.schemas_destination = '{}/schemas'.format(conf.options.gconf_dir)

#conf.recurse("help")


def set_options(opt):
# options for disabling pyc or pyo compilation
opt.tool_options("python")
opt.tool_options("misc")
opt.tool_options("gnu_dirs")
def options(opt):
opt.add_option('--gconf-dir', action='store', default='/etc/gconf', dest='gconf_dir', help='gconf base directory [default: /etc/gconf]')


def build(bld):
Expand All @@ -57,40 +77,40 @@ def build(bld):
'src/hamster.bash')


bld(features='py',
source=bld.path.ant_glob('src/**/*.py'),
install_from='src')

# set correct flags in defs.py
bld.new_task_gen("subst",
source= "src/hamster/defs.py.in",
target= "src/hamster/defs.py",
install_path="${PYTHONDIR}/hamster",
dict = bld.env
)

bld.install_files('${PYTHONDIR}/hamster', 'src/hamster/*.py')
for folder in ("lib", "storage", "widgets"):
bld.install_files('${PYTHONDIR}/hamster/%s' % folder,
'src/hamster/%s/*.py' % folder)

bld.new_task_gen("subst",
source= "org.gnome.hamster.service.in",
target= "org.gnome.hamster.service",
install_path="${DATADIR}/dbus-1/services",
dict = bld.env
)
bld.new_task_gen("subst",
source= "org.gnome.hamster.Windows.service.in",
target= "org.gnome.hamster.Windows.service",
install_path="${DATADIR}/dbus-1/services",
dict = bld.env
)

bld.add_subdirs("po help data")


def post(ctx):
bld(features="subst",
source="src/hamster/defs.py.in",
target="src/hamster/defs.py",
install_path="${PYTHONDIR}/hamster"
)

bld(features="subst",
source= "org.gnome.hamster.service.in",
target= "org.gnome.hamster.service",
install_path="${DATADIR}/dbus-1/services",
)

bld(features="subst",
source= "org.gnome.hamster.Windows.service.in",
target= "org.gnome.hamster.Windows.service",
install_path="${DATADIR}/dbus-1/services",
)

bld.install_files(bld.env.schemas_destination,
"data/hamster-time-tracker.schemas")

#bld.add_subdirs("po help data")
bld.recurse("po data")

#def post(bld):
# Postinstall tasks:
# gnome.postinstall_scrollkeeper('hamster-time-tracker') # Installing the user docs
gnome.postinstall_schemas('hamster-time-tracker') # Installing GConf schemas
gnome.postinstall_icons() # Updating the icon cache

#postinstall_schemas(bld) # Installing GConf schemas
#postinstall_icons() # Updating the icon cache

bld.add_post_fun(post)
bld.add_post_fun(lambda bld: manage_gconf_schemas(bld, "install"))
bld.add_pre_fun(lambda bld: manage_gconf_schemas(bld, "uninstall"))

0 comments on commit 9a157c0

Please sign in to comment.