You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.9 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # setup.py --- Setup script for calculate-client
  4. #Copyright 2010 Calculate Pack, http://www.calculate-linux.org
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. import os
  17. import stat
  18. from distutils.core import setup, Extension
  19. __version__ = "2.2.0.0"
  20. __app__ = "calculate-ldap"
  21. data_files = []
  22. var_data_files = []
  23. data_dirs_template = ['templates']
  24. data_dirs_ldif = ['ldif']
  25. data_dirs_share = ['i18n']
  26. share_calculate_dir = "/usr/share/calculate"
  27. template_calculate_dir = os.path.join(share_calculate_dir, "templates")
  28. template_replace_dirname = "ldap"
  29. def __scanDir(scanDir, prefix, replace_dirname, dirData, flagDir=False):
  30. """Scan directory"""
  31. files = []
  32. dirs = []
  33. if flagDir or stat.S_ISDIR(os.stat(scanDir)[stat.ST_MODE]):
  34. for fileOrDir in os.listdir(scanDir):
  35. absPath = os.path.join(scanDir,fileOrDir)
  36. statInfo = os.stat(absPath)[stat.ST_MODE]
  37. if stat.S_ISREG(statInfo):
  38. files.append(absPath)
  39. elif stat.S_ISDIR(statInfo):
  40. dirs.append(absPath)
  41. if replace_dirname:
  42. listDirs = list(scanDir.partition("/"))[1:]
  43. listDirs.insert(0,replace_dirname)
  44. scanDir = "".join(listDirs)
  45. if prefix:
  46. scanDir = os.path.join(prefix,scanDir)
  47. dirData.append((scanDir, files))
  48. for sDir in dirs:
  49. __scanDir(sDir, prefix, replace_dirname, dirData, True)
  50. return dirData
  51. def create_data_files(data_dirs, prefix="", replace_dirname=""):
  52. """Create data_files"""
  53. data_files = []
  54. for data_dir in data_dirs:
  55. data = []
  56. data_files += __scanDir(data_dir, prefix, replace_dirname, data)
  57. return data_files
  58. data_files += create_data_files (data_dirs_template, template_calculate_dir,
  59. template_replace_dirname)
  60. data_files += create_data_files (data_dirs_share, share_calculate_dir)
  61. data_files += create_data_files (data_dirs_ldif)
  62. setup(
  63. name = __app__,
  64. version = __version__,
  65. description = "The program for configuring LDAP server",
  66. author = "Mir Calculate Ltd.",
  67. author_email = "support@calculate.ru",
  68. url = "http://calculate-linux.org",
  69. license = "http://www.apache.org/licenses/LICENSE-2.0",
  70. package_dir = {'calculate-ldap': "."},
  71. packages = ['calculate-ldap.pym'],
  72. data_files = data_files,
  73. scripts=["./scripts/cl-ldap-setup"]
  74. )