From 47e93ba96f6ca55cb4bf3701d4d5d190f25c0c49 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Mon, 15 Aug 2005 17:16:17 +0100 Subject: [PATCH] Allow StGIT to be installed in a local directory StGIT should no longer rely on being installed under /usr. This has implications in the default python search path, the /etc/stgitrc file and the /usr/share/stgit/templates directory. By default, the 'python setup.py install' command will now install StGIT in the home directory of the current user. Signed-off-by: Catalin Marinas --- MANIFEST.in | 5 +++-- stgitrc => examples/stgitrc | 4 ++++ setup.cfg | 2 ++ setup.py | 6 +++--- stg | 16 ++++++++++++++++ stgit/config.py | 14 +++++++++++++- 6 files changed, 41 insertions(+), 6 deletions(-) rename stgitrc => examples/stgitrc (87%) create mode 100644 setup.cfg diff --git a/MANIFEST.in b/MANIFEST.in index 17d28a7..581d0be 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ -include README MANIFEST.in AUTHORS COPYING INSTALL ChangeLog TODO stgitrc -include examples/*.tmpl +include README MANIFEST.in AUTHORS COPYING INSTALL ChangeLog TODO include templates/*.tmpl +include examples/*.tmpl +include examples/stgitrc diff --git a/stgitrc b/examples/stgitrc similarity index 87% rename from stgitrc rename to examples/stgitrc index 6c2c9a7..a225090 100644 --- a/stgitrc +++ b/examples/stgitrc @@ -1,3 +1,7 @@ +# StGIT configuration file. Copy it to any of /etc/stgitrc, ~/.stgitrc +# or .git/stgitrc and modify as needed. Note that the latter overrides +# the former. + [stgit] # Default author/committer details #authname: Your Name diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..4359033 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[install] +prefix: ~ diff --git a/setup.py b/setup.py index 2e5dd7c..eaf39c1 100755 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup(name = 'stgit', long_description = 'Push/pop utility on top of GIT', scripts = ['stg', 'gitmergeonefile.py'], packages = ['stgit', 'stgit.commands'], - data_files = [('/etc', ['stgitrc']), - ('share/stgit/templates', glob.glob('templates/*.tmpl')), - ('share/stgit/examples', glob.glob('examples/*.tmpl'))] + data_files = [('share/stgit/templates', glob.glob('templates/*.tmpl')), + ('share/stgit/examples', glob.glob('examples/*.tmpl')), + ('share/stgit/examples', ['examples/stgitrc'])] ) diff --git a/stg b/stg index ca9307e..5ec2c22 100755 --- a/stg +++ b/stg @@ -20,6 +20,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ +import sys, os + +# Try to detect where it is run from and set prefix and the search path. +# It is assumed that the user installed StGIT using the --prefix= option +prefix, bin = os.path.split(sys.path[0]) + +if bin == 'bin' and prefix != sys.prefix: + sys.prefix = prefix + sys.exec_prefix = prefix + + major, minor = sys.version_info[0:2] + sys.path += [os.path.join(prefix, 'lib', 'python'), + os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor)), + os.path.join(prefix, 'lib', 'python%s.%s' % (major, minor), + 'site-packages')] + from stgit.main import main main() diff --git a/stgit/config.py b/stgit/config.py index 3bbbd0d..042af63 100644 --- a/stgit/config.py +++ b/stgit/config.py @@ -28,6 +28,18 @@ else: config = ConfigParser.RawConfigParser() -config.readfp(file('/etc/stgitrc')) +# Set the defaults +config.add_section('stgit') +config.set('stgit', 'autoresolved', 'no') +config.set('stgit', 'smtpserver', 'localhost:25') + +config.add_section('gitmergeonefile') +config.set('gitmergeonefile', 'merger', + 'diff3 -L local -L older -L remote -m -E ' \ + '"%(branch1)s" "%(ancestor)s" "%(branch2)s" > "%(output)s"') +config.set('gitmergeonefile', 'keeporig', 'yes') + +# Read the configuration files (if any) and override the default settings +config.read('/etc/stgitrc') config.read(os.path.expanduser('~/.stgitrc')) config.read(os.path.join(__git_dir, 'stgitrc')) -- 2.11.0