<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/gitserve/gitweb.cgi</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -31,10 +31,12 @@ Usage pretty easy::
       -q, --quiet           don't print anything to stdout
       -p PORT, --port=PORT  port to listen on (default: 8000)
       -a ADDRESS, --address=ADDRESS
-                            address to listen on (default: all interfaces)
+                            address to listen on (default: hostname)
+      -l, --local           only listen on 127.0.0.1
       -b, --browser         open default browser automatically
       -d, --daemon          detach from terminal and become a daemon
       --pid-file=PIDFILE    write the spawned process-id to this file
+      --gitweb=GITWEB       use this gitweb cgi file instead of the included
 
 As the only argument you can specify a directory that contains your git
 projects. If you leave this argument blank ``git-serve`` will automatically uses
@@ -52,7 +54,8 @@ port 8000, for example: http://127.0.0.1:8000/
 
 If you provide a ``--port`` or ``--address`` option while starting ``git-serve``
 you can have ``git-serve`` listen on your choices. You need to be root to run it
-on port 80 or any other port below 1024.
+on port 80 or any other port below 1024. The ``--local`` option tells
+``git-serve`` to listen only on ``127.0.0.1``.
 
 The ``--browser`` option tells ``git-serve`` to automatically start your system's
 default web browser with the URL of the ``git-serve`` server while starting it.
@@ -62,3 +65,5 @@ current shell session, becoming a daemon process that runs in background. This
 is very useful in combination with the ``--pid-file`` option that write the
 process id in the given file.
 
+You can specify the location of the gitweb.cgi file that ``git-serve`` uses
+with the ``--gitweb`` option (e.g. /home/jannis/lib/git/gitweb.cgi).</diff>
      <filename>README.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,33 @@
 #!/usr/bin/env python
 
-import os, sys, stat
-from setuptools import setup, find_packages
+import os, sys
+try:
+    from setuptools import find_packages, setup
+    from setuptools.command.easy_install import easy_install
+except ImportError:
+    sys.exit(&quot;Please install a recent version of setuptools&quot;)
+
+easy_install.real_process_distribution = easy_install.process_distribution
+def process_distribution(self, *args, **kwargs):
+    &quot;&quot;&quot;Brutally ugly hack to have post_install functionality. oh. my. god.&quot;&quot;&quot;
+    easy_install.real_process_distribution(self, *args, **kwargs)
+
+    import pkg_resources
+    try:
+        pkg_resources.require(&quot;gitserve&quot;)
+        gitweb_cgi = pkg_resources.resource_filename(&quot;gitserve&quot;, &quot;gitweb.cgi&quot;)
+        os.chmod(gitweb_cgi, 0755)
+    except:
+        print &quot;Chmodding failed. Try 'chmod +x /path/to/gitserve/gitweb.cgi'&quot;
+easy_install.process_distribution = process_distribution
 
 setup(
     name='gitserve',
-    version='0.1.1',
-    license='GPL2',
+    version='0.2.0',
+    license='GPL-2',
     description=&quot;A helper tool for git that mimics mercurial\'s serve command&quot;,
-    long_description=open(os.path.join(os.path.dirname(__file__), 'README.txt')).read(),
+    long_description=open('README.txt', 'r').read(),
+    maintainer='Jannis Leidel',
     author='Jannis Leidel',
     author_email='jannis@leidel.info',
     url='http://github.com/jezdez/git-serve/',
@@ -26,10 +45,9 @@ setup(
         'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
         'Topic :: Internet :: WWW/HTTP :: HTTP Servers',
     ],
-    install_requires=[&quot;setuptools&quot;],
     packages=find_packages('src'),
     package_dir={'':'src'},
-    package_data={'': ['media/*.*', '*.so', '*.conf'],},
+    package_data={'': ['media/*.*', '*.cgi', '*.conf'],},
     entry_points={'console_scripts': ['git-serve = gitserve:main',],},
     zip_safe=False,
     include_package_data = True,</diff>
      <filename>setup.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # encoding: utf-8
 
-__version__ = '0.1.1'
+__version__ = '0.2.0'
 
 import os
 import sys
@@ -11,10 +11,10 @@ from urllib import unquote
 from urlparse import urljoin
 from optparse import OptionParser
 from BaseHTTPServer import HTTPServer
-from socket import gethostname, gethostbyaddr
+from pkg_resources import resource_filename
 from CGIHTTPServer import CGIHTTPRequestHandler
-
-gitserve_dir = os.path.dirname(os.path.abspath(__file__))
+from socket import error as SocketError
+from socket import gethostname, gethostbyaddr
 
 def become_daemon(home='.', out_log='/dev/null', err_log='/dev/null'):
     &quot;Robustly turn into a UNIX daemon, running in our_home_dir.&quot;
@@ -48,9 +48,8 @@ def become_daemon(home='.', out_log='/dev/null', err_log='/dev/null'):
 
 class GitWebRequestHandler(CGIHTTPRequestHandler):
     cgi_directories = []
-    aliases = [
-        ('/media', os.path.join(gitserve_dir, &quot;media&quot;)),
-    ]
+    gitserve_media = resource_filename(&quot;gitserve&quot;, &quot;media&quot;)
+    aliases = [('/media', gitserve_media),]
     verbose = False
     
     def log_message(self, format, *args):
@@ -119,7 +118,10 @@ def main():
                       help=&quot;port to listen on (default: 8000)&quot;, default=8000)
     parser.add_option(&quot;-a&quot;, &quot;--address&quot;,
                       dest=&quot;address&quot;, default=&quot;&quot;,
-                      help=&quot;address to listen on (default: all interfaces)&quot;)
+                      help=&quot;address to listen on (default: hostname)&quot;)
+    parser.add_option(&quot;-l&quot;, &quot;--local&quot;,
+                      action=&quot;store_true&quot;, dest=&quot;local&quot;, default=False,
+                      help=&quot;only listen on 127.0.0.1&quot;)
     parser.add_option(&quot;-b&quot;, &quot;--browser&quot;,
                       action=&quot;store_true&quot;, dest=&quot;browser&quot;, default=False,
                       help=&quot;open default browser automatically&quot;)
@@ -129,8 +131,18 @@ def main():
     parser.add_option(&quot;--pid-file&quot;,
                       dest=&quot;pidfile&quot;, default=&quot;&quot;,
                       help=&quot;write the spawned process-id to this file&quot;)
+    parser.add_option(&quot;--gitweb&quot;,
+                      dest=&quot;gitweb&quot;, default=&quot;&quot;,
+                      help=&quot;use this gitweb cgi file instead of the included version&quot;)
     (options, args) = parser.parse_args()
 
+    # get path to gitweb.cgi file
+    gitweb_cgi = options.gitweb
+    if not gitweb_cgi:
+        gitweb_cgi = resource_filename('gitserve', 'gitweb.cgi')
+    if not os.access(gitweb_cgi, os.X_OK):
+        parser.error(&quot;Your gitweb.cgi is not executable. Try 'chmod +x %s'&quot; % gitweb_cgi)
+
     if len(args) &gt; 1:
         parser.error(&quot;incorrect number of arguments&quot;)
     if args:
@@ -155,19 +167,21 @@ def main():
     if os.path.exists(os.path.expanduser('~/.gitwebconfig')):
         gitweb_conf = os.path.expanduser('~/.gitwebconfig')
     else:
-        gitweb_conf = os.path.join(gitserve_dir, 'gitweb.conf')
+        gitweb_conf = resource_filename('gitserve', 'gitweb.conf')
     os.environ['GITWEB_CONFIG'] = gitweb_conf
 
-    # get hostname from the system and build urls and path to cgi
-    if not options.address:
-        options.address = gethostname()
-    else:
-        options.address = gethostbyaddr(options.address)[0]
-
-    listen = options.address, options.port
+    # get hostname from the system and build url
+    try:
+        if options.local:
+            options.address = '127.0.0.1'
+        elif not options.address:
+            options.address = gethostname()
+        else:
+            options.address = gethostbyaddr(options.address)[0]
+    except SocketError, e:
+        parser.error(e)
     gitweb_url = &quot;http://%s:%d/%s/&quot; % (options.address, options.port, repo_name)
-    gitweb_cgi = os.path.join(gitserve_dir, 'gitweb.cgi.so')
-
+    
     # start daemon mode
     if options.daemon:
         options.verbose = False
@@ -183,8 +197,7 @@ def main():
     GitWebRequestHandler.verbose = options.verbose
     GitWebRequestHandler.cgi_directories.append('/%s' % repo_name)
     GitWebRequestHandler.aliases.append(('/%s' % repo_name, gitweb_cgi))
-
-    httpd = HTTPServer(listen, GitWebRequestHandler)
+    httpd = HTTPServer((options.address, options.port), GitWebRequestHandler)
 
     if options.verbose:
         print &quot;starting gitweb at: %s&quot; % gitweb_url
@@ -197,6 +210,9 @@ def main():
         httpd.serve_forever()
     except KeyboardInterrupt:
         pass
+    except SocketError:
+        if options.verbose:
+            raise
 
 if __name__ == &quot;__main__&quot;:
     main()</diff>
      <filename>src/gitserve/__init__.py</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>src/gitserve/gitweb.cgi.so</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>0f1e2c09203b1d405d68391ceaaa647fb1a2a4b2</id>
    </parent>
  </parents>
  <author>
    <name>Jannis Leidel</name>
    <email>jannis@leidel.info</email>
  </author>
  <url>http://github.com/jezdez/git-serve/commit/bb250f9978798fdd9b64239dda981c290080ca88</url>
  <id>bb250f9978798fdd9b64239dda981c290080ca88</id>
  <committed-date>2008-04-28T03:12:32-07:00</committed-date>
  <authored-date>2008-04-28T03:12:32-07:00</authored-date>
  <message>(hopefully) fixed weird behaviour of setuptools' easy_install.
added option to specify an own version of gitweb.cgi
added option to listen only locally (not on hostname)
made resource handling (media files) more robust using pkg_resources</message>
  <tree>04fc38d02e5b3eb4be7cce9c8d3a77a0be16bada</tree>
  <committer>
    <name>Jannis Leidel</name>
    <email>jannis@leidel.info</email>
  </committer>
</commit>
