All pastes #291810 Raw Edit

Anonymous

public text v1 · immutable
#291810 ·published 2006-12-25 19:56 UTC
rendered paste body
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
# This program 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 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#

import os
import shutil
import glob
import sys
import inspect
from distutils.core import setup
from distutils.command.install import install

sys.path.insert(0, '.')

class Install(install):
    def run(self):

        if not self.check_clit():
            print "Aborting Install"
        install.run(self)
        self.installi18n()
        self.installdoc()
        self.installfiles()
        self.create_menu()
        self.install_binary()

    def check_clit(self):
        if os.path.exists("/usr/bin/clit"):
            print "clit found..."
            return True
        else:
            return False

    def installi18n(self):
        for name in os.listdir('po'):
            if not name.endswith('.po'):
                continue
            lang = name[:-3]
            print "Installing '%s' translations..." % lang
            os.popen("msgfmt po/%s.po -o po/%s.mo" % (lang, lang))
            if not self.root:
                self.root = "/"
            destpath = os.path.join(self.root, "usr/share/locale/%s/LC_MESSAGES" % lang)
            if not os.path.exists(destpath):
                os.makedirs(destpath)
            shutil.copy("po/%s.mo" % lang, os.path.join(destpath, "litconverter.mo"))

    def installdoc(self):
        destpath = os.path.join(self.root, "usr/share/doc/litconverter")
        if not os.path.exists(destpath):
            os.makedirs(destpath)
        os.chdir('doc')
        for files in glob.glob('*'):
            print 'Installing', files
            shutil.copy(files, os.path.join(destpath, files))
        os.chdir('..')

    def installfiles(self):
        destpath = os.path.join(self.root, "usr/share/litconverter")
        if not os.path.exists(destpath):
            os.makedirs(destpath)
        os.chdir('src')
        for py_files in glob.glob('*.py'):
            print 'Installing', py_files
            shutil.copy(py_files, os.path.join(destpath, py_files))
        os.chdir('..')

    def create_menu(self):
        print 'Creating menu entry...'
        destpath = os.path.join(self.root, "usr/share/pixmaps")
        if not os.path.exists(destpath):
            os.makedirs(destpath)
        os.chdir('menu')
        for png_files in glob.glob('*.png'):
            print 'Installing', png_files
            shutil.copy(png_files, os.path.join(destpath, png_files))
        destpath = os.path.join(self.root, "usr/share/applications")
        if not os.path.exists(destpath):
            os.makedirs(destpath)
        for desktop_files in glob.glob('*.desktop'):
            print 'Installing', desktop_files
            shutil.copy(desktop_files, os.path.join(destpath, desktop_files))
        os.chdir('..')

    def install_binary(self):
        destpath = os.path.join(self.root, "usr/bin")
        if not os.path.exists(destpath):
            os.makedirs(destpath)
        os.chdir('src')
        for name in glob.glob('*'):
            if name.endswith('.py'):
                continue
            print 'Installing', name
            os.chmod(name, 0755)
            shutil.copy(name, os.path.join(destpath, name))
        os.chdir('..')

setup(name="litconverter",
    version="1.0",
    description="Lit (Packages Installed Successfully as Intended)",
    long_description="PiSi is the package management system of Pardus Linux.",
    license="GNU GPL2",
    author="Murat Şenel",
    author_email="muratasenel@gmail.com",
    url="http://www.pardus.org.tr/eng/pisi/",
    package_dir = {'': ''},
    cmdclass = {'install' : Install},
    )