root/trunk/install_scripts/linux/setup.py @ 1306

Revision 1306, 8.5 kB (checked in by boltrix, 6 years ago)

More work on installers, umitCore.Paths and umitCore.Logging which now has been renamed to umitCore.UmitLogging?. Windows installers are working fine, yet, a script updating the Paths's configuration is need as well as more test on it. Also, Linux installers seens to be working fine. The Mac OS X App generator is half-way done, and have some issues while importing cairo yet. Also, hardcoded the paths to umitCore.Paths and made a basic test suite to ensure that it is working. More testing is needed, and probably some minor bugs shal raise.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2# Copyright (C) 2005 Insecure.Com LLC.
3#
4# Authors: Adriano Monteiro Marques <py.adriano@gmail.com>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20import os
21import re
22
23from distutils.core import setup
24from distutils.command.install import install
25from distutils.command.sdist import sdist
26
27from glob import glob
28from stat import ST_MODE
29
30
31VERSION = "0.9.4"
32REVISION = "1288"
33
34# Directories for POSIX operating systems
35# These are created after a "install" or "py2exe" command
36# These directories are relative to the installation or dist directory
37# Ex: python setup.py install --prefix=/tmp/umit
38# Will create the directory /tmp/umit with the following directories
39pixmaps_dir = os.path.join('share', 'pixmaps')
40icons_dir = os.path.join('share', 'icons')
41locale_dir = os.path.join('share', 'umit', 'locale')
42config_dir = os.path.join('share', 'umit', 'config')
43docs_dir = os.path.join('share', 'umit', 'docs')
44misc_dir = os.path.join('share', 'umit', 'misc')
45
46
47def mo_find(result, dirname, fnames):
48    files = []
49    for f in fnames:
50        p = os.path.join(dirname, f)
51        if os.path.isfile(p) and f.endswith(".mo"):
52            files.append(p)
53       
54    if files:
55        result.append((dirname, files))
56
57
58################################################################################
59# Installation variables
60
61svg = glob(os.path.join('share', 'pixmaps', '*.svg'))
62data_files = [ (pixmaps_dir, svg + glob(os.path.join(pixmaps_dir, '*.png')) +
63                             glob(os.path.join(pixmaps_dir, 'umit.o*'))),
64
65               (config_dir, [os.path.join(config_dir, 'umit.conf')] +
66                            [os.path.join(config_dir, 'scan_profile.usp')] +
67                            [os.path.join(config_dir, 'umit_version')] +
68                            [os.path.join(config_dir, 'umit.db')] + 
69                            glob(os.path.join(config_dir, '*.xml'))+
70                            glob(os.path.join(config_dir, '*.txt'))),
71
72               (misc_dir, glob(os.path.join(misc_dir, '*.dmp'))), 
73
74               (icons_dir, glob(os.path.join('share', 'icons', '*.ico'))+
75                           glob(os.path.join('share', 'icons', '*.png'))),
76
77               (docs_dir, glob(os.path.join(docs_dir, '*.html'))+
78                          glob(os.path.join(docs_dir,
79                                            'comparing_results', '*.xml'))+
80                          glob(os.path.join(docs_dir,
81                                            'profile_editor', '*.xml'))+
82                          glob(os.path.join(docs_dir,
83                                            'scanning', '*.xml'))+
84                          glob(os.path.join(docs_dir,
85                                            'searching', '*.xml'))+
86                          glob(os.path.join(docs_dir,
87                                            'wizard', '*.xml'))+
88                          glob(os.path.join(docs_dir,
89                                            'screenshots', '*.png')))]
90
91# Add i18n files to data_files list
92os.path.walk(locale_dir, mo_find, data_files)
93
94
95
96################################################################################
97# Distutils subclasses
98
99class umit_install(install):
100    def run(self):
101        install.run(self)
102
103        self.fix_paths()
104        self.create_uninstaller()
105        self.finish_banner()
106
107    def create_uninstaller(self):
108        uninstaller_filename = os.path.join(self.install_scripts, "uninstall_umit")
109        uninstaller = """#!/usr/bin/env python
110import os, sys
111
112print
113print '%(line)s Uninstall Umit %(version)s-%(revision)s %(line)s'
114print
115
116answer = raw_input('Are you sure that you want to completly uninstall Umit %(version)s? \
117(yes/no) ')
118
119if answer != 'yes' and answer != 'y':
120    sys.exit(0)
121
122print
123print '%(line)s Uninstalling Umit %(version)s... %(line)s'
124print
125""" % {'version':VERSION, 'revision':REVISION, 'line':'-'*10}
126
127        for output in self.get_outputs():
128            uninstaller += "print 'Removing %s...'\n" % output
129            uninstaller += "os.remove('%s')\n" % output
130
131        uninstaller += "print 'Removing uninstaller itself...'\n"
132        uninstaller += "os.remove('%s')\n" % uninstaller_filename
133
134        uninstaller_file = open(uninstaller_filename, 'w')
135        uninstaller_file.write(uninstaller)
136        uninstaller_file.close()
137
138        # Set exec bit for uninstaller
139        mode = ((os.stat(uninstaller_filename)[ST_MODE]) | 0555) & 07777
140        os.chmod(uninstaller_filename, mode)
141
142    def fix_paths(self):
143        su = os.path.join("share", "umit")
144        interesting_paths = {"CONFIG_DIR":os.path.join(su, "config"),
145                             "DOCS_DIR":os.path.join(su, "docs"),
146                             "LOCALE_DIR":os.path.join(su, "locale"),
147                             "MISC_DIR":os.path.join(su, "misc"),
148                             "PIXMAPS_DIR":os.path.join("share", "pixmaps"),
149                             "ICONS_DIR":os.path.join("share", "icons"),
150                             "UMIT_ICON":"umit_48.ico"}
151
152        pcontent = ""
153        paths_file = os.path.join("umitCore", "Paths.py")
154        installed_files = self.get_outputs()
155        for f in installed_files:
156            #print ">>> PATHS FILE:", re.findall("(%s)" % \
157            #                                    re.escape(paths_file), f)
158            if re.findall("(%s)" % re.escape(paths_file), f):
159                #print ">>>>> FOUND PATHS FILE! <<<<<"
160                paths_file = f
161                pf = open(paths_file)
162                pcontent = pf.read()
163                pf.close()
164                break
165
166        for path in interesting_paths:
167            for f in installed_files:
168                #print ">>> PATH:",
169                #print re.findall("(%s)" % re.escape(interesting_paths[path]), f)
170                if re.findall("(%s)" % re.escape(interesting_paths[path]), f):
171                    #print ">>>>> FOUND! <<<<<"
172                    pcontent = re.sub("%s\s+=\s+.+" % path,
173                                      "%s = \"%s\"" % (path, f),
174                                      pcontent)
175                    break
176
177        pf = open(paths_file, "w")
178        pf.write(pcontent)
179        pf.close()
180
181    def finish_banner(self):
182        print 
183        print "%s Thanks for using Umit %s-%s %s" % \
184              ("#"*10, VERSION, REVISION, "#"*10)
185        print
186
187
188class umit_sdist(sdist):
189    def run(self):
190        sdist.run(self)
191        self.finish_banner()
192
193    def finish_banner(self):
194        print 
195        print "%s The packages for Umit %s-%s are in ./dist %s" % \
196              ("#" * 10, VERSION, REVISION, "#" * 10)
197        print
198
199
200##################### Umit banner ########################
201print
202print "%s Umit for Linux %s-%s %s" % ("#" * 10, VERSION, REVISION, "#" * 10)
203print
204##########################################################
205
206setup(name = 'umit',
207      license = 'GNU GPL (version 2 or later)',
208      url = 'http://umit.sourceforge.net',
209      download_url = 'http://sourceforge.net/project/showfiles.php?group_id=142490',
210      author = 'Adriano Monteiro & Cleber Rodrigues',
211      author_email = 'py.adriano@gmail.com, cleber@globalred.com.br',
212      maintainer = 'Adriano Monteiro',
213      maintainer_email = 'py.adriano@gmail.com',
214      description = """UMIT is a nmap frontend, developed in Python and GTK and was \
215started with the sponsoring of Google's Summer of Code.""",
216      long_description = """The project goal is to develop a nmap frontend that \
217is really useful for advanced users and easy to be used by newbies. With UMIT, a network admin \
218could create scan profiles for faster and easier network scanning or even compare \
219scan results to easily see any changes. A regular user will also be able to construct \
220powerful scans with UMIT command creator wizards.""",
221      version = VERSION,
222      scripts = ['umit'],
223      packages = ['', 'umitCore', 'umitGUI', 'higwidgets'],
224      data_files = data_files,
225      cmdclass = {"install":umit_install,
226                  "sdist":umit_sdist})
Note: See TracBrowser for help on using the browser.