from distutils.core import setup
from distutils.command.build import build
import os, glob

from version import *

class BuildQm(build):    
  for po in glob.glob('po/*.po'):
    os.system('lconvert {} -o i18n/mageiawelcome_{}.ts'.format(po, os.path.splitext(os.path.basename(po))[0]))
  for ts in glob.glob('i18n/*.ts'):
    os.system('lrelease {0} -qm {1}'.format(ts, (ts[:-2]+'qm')))
  os.system("rm -f i18n/*.ts")
  os.system('msgfmt --desktop --template=usr/share/applications/template_mageiawelcome.desktop -d po -o usr/share/applications/mageiawelcome.desktop')


data_files = [("bin",["usr/bin/mageiawelcome","usr/bin/mageiawelcome"]),
              ("share/applications/", ["usr/share/applications/mageiawelcome.desktop"]),
              ("share/icons/hicolor/32x32/apps/", ["src/icons/32x32/apps/mageiawelcome.png"]),
              ("share/icons/hicolor/scalable/apps/", ["src/icons/scalable/apps/mageiawelcome.svg"]),
              ("share/mageiawelcome/",glob.glob('src/*.py')),
              ("share/mageiawelcome/",['version.py']),
              ("share/mageiawelcome/img",glob.glob('src/img/*.png')),
	          ("share/mageiawelcome/translations/",glob.glob('i18n/*.qm')),
              ("/etc/xdg/autostart/",["etc/xdg/autostart/mageiawelcome.desktop"]),
              ]

setup(
        name = 'mageiawelcome',
        version = version,
        license = 'GNU General Public License v3 (GPLv3)',
        url = 'http://gitweb.mageia.org/software/mageiawelcome',
        description = 'Welcome Screen shows important information of the Mageia distribution.',
        platforms = ['Linux'],
        author = 'Daniel Napora',
        author_email = 'napcok@gmail.com',
        data_files = data_files,
        cmdclass = {'build_qm': BuildQm,},
        py_modules = []
        )
