#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of Karesansui.
#
# Copyright (C) 2009 HDE, Inc.
#
# 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.
#

import os
import sys

from installer.trans import _, N_
import installer

""" Product Information """
TITLE     = installer.__name__
VERSION   = installer.__version__
RELEASE   = installer.__release__
COPYRIGHT = "Copyright (C) 2009 Karesansui Project"

""" Paths """
INITRDDIR = "/etc/init.d"

SCRIPT_DIR            = "%s" % os.path.dirname(os.path.realpath(sys.argv[0]))
DEFAULT_INSTALL_LOG   = "/root/karesansui-install.log"
DEFAULT_INSTALL_INI   = "/root/karesansui-install.ini"
DEFAULT_UNINSTALL_LOG = "/root/karesansui-uninstall.log"
DEFAULT_INITDB_LOG    = "/root/karesansui-initdb.log"
RPMBUILD_TMPFILE_PREFIX = "/tmp/karesansui-rpmbuild"
GENERATE_RPMDIR       = "/root/karesansui-rpm"

SUPPORTED_DISTROS = [
   ("centos",  "5-3"),
   ("redhat",  "5Server-5.3"),
]

VENDOR_PREFIX     = "/opt/hde"
VENDOR_SYSCONFDIR = "/etc/opt/hde"
VENDOR_DATADIR    = "/var/opt/hde"
VENDOR_PYTHONPATH = "%s/lib/python" % VENDOR_PREFIX

SILHOUETTE_PREFIX     = "/opt/pysilhouette"
SILHOUETTE_SYSCONFDIR = "/etc/opt/pysilhouette"
SILHOUETTE_DATADIR    = "/var/opt/pysilhouette"
SILHOUETTE_PYTHONPATH = "%s/lib/python" % SILHOUETTE_PREFIX
DEFAULT_SILHOUETTE_CONF   = "%s/silhouette.conf" % SILHOUETTE_SYSCONFDIR
DEFAULT_SILHOUETTE_DB_URI = "sqlite:///%s/pysilhouette.db" % SILHOUETTE_DATADIR
SILHOUETTE_SYSCONFIG = "/etc/sysconfig/silhouetted"

KARESANSUI_PREFIX     = "/opt/karesansui"
KARESANSUI_SYSCONFDIR = "/etc/opt/karesansui"
KARESANSUI_DATADIR    = "/var/opt/karesansui"
KARESANSUI_PYTHONPATH = "%s/lib/python" % KARESANSUI_PREFIX
DEFAULT_KARESANSUI_CONF   = "%s/application.conf" % KARESANSUI_SYSCONFDIR
DEFAULT_KARESANSUI_DB_URI = "sqlite:///%s/karesansui.db"   % KARESANSUI_DATADIR

DEFAULT_PYTHONPATH="%s:%s:%s:%s" % (SCRIPT_DIR,VENDOR_PYTHONPATH,SILHOUETTE_PYTHONPATH,KARESANSUI_PYTHONPATH,)

LIGHTY_SSL_CONF  = "%s/lighttpd/conf.d/karesansui/ssl.conf"  % VENDOR_SYSCONFDIR
LIGHTY_PORT_CONF = "%s/lighttpd/conf.d/karesansui/port.conf" % VENDOR_SYSCONFDIR

COMMAND_CHKCONFIG = "/sbin/chkconfig"
COMMAND_SERVICE   = "/sbin/service"
COMMAND_IPTABLES  = "/sbin/iptables"

REQUIRE_SERVICES = [
    "hde-libvirtd",
    "hde-lighttpd",
    "silhouetted",
]

CORE_PKGS = [
    "karesansui",
    "pysilhouette",
    "hde-libvirt",
    "hde-libvirt-python",
    "hde-lighttpd",
]

DEFAULT_BUILD_PKGS_LINENUM = 1000
BUILD_PKGS_LINENUMS = {
                          "hde-python-pysqlite":250,
                          "hde-lighttpd"       :1500,
                          "hde-libvirt"        :2500,
                         }

#UNINSTALL_PKGS_REGEX = [
#    "^karesansui",
#    "^hde-libvirt",
#    "^hde-python-",
#    "^pysilhouette",
#]
UNINSTALL_PKGS_REGEX = [
    "^karesansui",
    "^hde-libvirt",
]

DATABASE_MODULES = {
    "ibase":["kinterbasdb"],
    "maxdb":["sapdb"],
    "mysql":["MySQLdb"],
    "oracle":["cx_Oracle"],
    "pgsql":["psycopg2"],
    "sqlite":["pysqlite2","sqlite3"],
}

RPM_VERIFY = False
BUTTON_COMPACT = False
NEWT_MONO = False

FLAG_RPM_INST    = 1<<0
FLAG_WRITE_CONF  = 1<<1
FLAG_CREATE_ADM  = 1<<2
FLAG_START_SERV  = 1<<3
FLAG_RPM_REBUILD = 1<<4
FLAG_DO_ALL = FLAG_RPM_INST|FLAG_WRITE_CONF|FLAG_CREATE_ADM|FLAG_START_SERV
try:
    import platform
    if platform.processor() == "x86_64":
        FLAG_DO_ALL |= FLAG_RPM_REBUILD
except:
    pass

OK_VALUE     = 0
CANCEL_VALUE = 1
BACK_VALUE   = 2
YES_VALUE    = 3
NO_VALUE     = 4
EXIT_VALUE   = 5
F12_VALUE    = 6

OK_BUTTON     = [ _("OK"),     OK_VALUE ]
CANCEL_BUTTON = [ _("Cancel"), CANCEL_VALUE ]
BACK_BUTTON   = [ _("Back"),   BACK_VALUE ]
YES_BUTTON    = [ _("Yes"),    YES_VALUE ]
NO_BUTTON     = [ _("No"),     NO_VALUE ]
EXIT_BUTTON   = [ _("Exit"),   EXIT_VALUE ]

FLOW_PANEL = [OK_BUTTON, BACK_BUTTON, CANCEL_BUTTON]
