Mercurial (hg) Installation Without Being Root: Unterschied zwischen den Versionen

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
Zeile 132: Zeile 132:
  
  
===Bundle Mercurial and Python===
+
===[now obsolete, skip this one] Bundle Mercurial and Python (only required if no compiler on target host/server and if not using make install-home-bin)===
 
<code>
 
<code>
 
tar -cvzhf mercurial.tar.gz python2.7/    #compress, verbose, z: use gzip2, h: dump files that symbolic links point to instead of using the symbolic link, files, -C or --directory <target_directory>; if you have compatibility issues omit the '-' after the tar or use another archiver like 'pax' which is standard-compliant. tar might well come from times where dinosaurs were around. ; )
 
tar -cvzhf mercurial.tar.gz python2.7/    #compress, verbose, z: use gzip2, h: dump files that symbolic links point to instead of using the symbolic link, files, -C or --directory <target_directory>; if you have compatibility issues omit the '-' after the tar or use another archiver like 'pax' which is standard-compliant. tar might well come from times where dinosaurs were around. ; )
Zeile 172: Zeile 172:
 
</code>
 
</code>
  
 +
<code>
 +
$ cd $HOME/python2.7/
 +
</code>
 +
 +
 +
Create wrapper shell script:
 +
 +
<code>
 +
#!/bin/sh
 +
export PYTHONPATH=/home/fgiudici/python2.4/lib/python2.4/site-packages
 +
/home/fgiudici/python2.4/bin/hg *
  
 +
and pointed Hudson to it. I also edited python2.4/bin/hg so the "dang bash" line is #!/home/fgiudici/python2.4/bin/python in place of #!/usr/bin/python2.4. It just works.
 +
</code>
  
<!--
 
For now it turned out that the blog post is no longer up to date as there will not be a binary for mercurial, namely 'python2/bin/hg' is missing.
 
  
To fix this:
+
==Configure Mercurial for a Python installation or PortablePython:==
  
 
<code>
 
<code>
$ tar -xvf mercurial_bundled_python.tar.gz
+
$ wget http://mercurial.selenic.com/release/mercurial-2.8.tar.gz
 
</code>
 
</code>
  
 
<code>
 
<code>
$ cd mercurial_bundled_python/
+
$ scp ~/mercurial-2.8.tar.gz ftp118002-2629078@dragontale.de:mercurial-2.8.tar.gz
 +
</code>
 +
 
 +
<code>
 +
$ tar -xzf mercurial-2.8.tar.gz --directory mercurial    # -C is a synonym=alias for --directory
 +
</code>
 +
 
 +
<code>
 +
$ cd $HOME/<mercurial_extracted_folder>/
 
</code>
 
</code>
  
Zeile 190: Zeile 209:
  
 
<code>
 
<code>
$ make install-home-bin
+
$ make PYTHON=$HOME/python2.7/bin/python PREFIX=/usr/local/ install-home-bin
 
</code>
 
</code>
  
Zeile 197: Zeile 216:
 
</code>
 
</code>
  
or
+
'''OR
 
+
'''
 
<code>
 
<code>
$ make local     # build for inplace usage
+
$ make PYTHON=$HOME/python2.7/bin/python local   # build for inplace usage (only within current folder) and only if a compiler is available.
 
</code>
 
</code>
  
Zeile 206: Zeile 225:
 
$ ./hg --version  # should show the latest version
 
$ ./hg --version  # should show the latest version
 
</code>
 
</code>
-->
+
 
  
  

Version vom 12. Januar 2014, 23:31 Uhr

Solutions for installing mercurial from a package repository or via a self-extracting or any other installer for all operating system distribution can easily be found. So this is not the topic of thise Wiki entry. Here we cover the installation of a mercurial versioning system without root access. It is a necessary step for the creation of our synergetic hard and software development system that at a later point shall be mirrored by the Wiki to keep it up to date and to keep development efforts bundled in our versioning system (mercurial, git, svn, bzr, ...).


With a Python installation readily available or with rights to install a python environment:

If a python installation is available or you have a server where you have adminsitrative rights for installing the python and still want to have a local installation of mercurial into your home directory, this also is no problem by using the Mercurial script: make install-home (to include documentation) or make install-home-bin (for the executable only). If you used a custom python location for the script it is required to add the following to the command to communicate it to hg:

$ PYTHON=/path/to/python2.4-or-newer

$ make install-home

Source: http://mercurial.selenic.com/wiki/UnixInstall#Per-user_installation


Without Root access and no Python available:

To install mercurial without being root, needs us to bundle Python 2.x (as Python 3 is not yet supported as there is only one advantage in favour of upgrading, so it's not worth the effort currently).

Windows

For Windows there currently is PortablePython as a ready made option.

UNIX/POSIX

For UNIX systems (Mac OS, GNU/Linux, Android, ...) or FreeBSD there are some packages floating around in the net, but it's sometimes hard to find the correct one for a certain architecture and operating system (what is needed to match the server's arch and os).

So if you have a system similar to the web server available where you have root access, the following is an option of how to get a working mercurial and python.

Virtual / bundled installation of Python

To create a virtual/bundled installation of Python and Mercurial there are two or more quite similar ways.

We will proceed in adapting this splendid blog entry of Fabrizio: https://weblogs.java.net/blog/fabriziogiudici/archive/2009/07/installing_merc.html .

cd $HOME #cd ~ also works


sudo apt-get install python2.7 python2.7-dev #if unmet dependencies problem occurs see below


wget peak.telecommunity.com/dist/virtual-python.py #if it can't be resolved, search the web for virtual-python.py .


export PYTHONPATH=$HOME/python2.7/lib/python2.7/site-packages/


python2.7 </path/to/>virtual-python.py --prefix=$HOME/python2.7/ #Note: This in conjunction with the following command copies the python files to the specified path in the $HOME directory!

Because of cd $HOME in our case it becomes: python2.7 ./virtual-python.py --prefix=$HOME/python2.7/


python2.7 ./virtual-python.py --prefix=$HOME/python2.7/


Two possibilities:

1. Fetch the relevant part of setuptools package: (if another python version is required look here for the .egg file):

$ wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg


I figured that one command was missing to get a successful install: chmod +x ./setuptools-0.6c11-py2.7.egg Now make sure that the PYTHONPATH is pointing to the correct python directory: $HOME/python2.7/lib/python2.7/site-packages/ . Check it using: echo $PYTHONPATH (If it's not correct, once again: export PYTHONPATH=$HOME/python2.7/lib/python2.7/site-packages/.


Then install easy_install binaries et alia using: $ ./setuptools-0.6c11-py2.7.egg --prefix=$HOME/python2.7/

(Note that this is a required step - it must not fail! Check the terminal output.)



python2.7/bin/easy_install-2.7 --prefix=$HOME/python2.7/ mercurial


Change the rights of all types (user[read:owner], group, other) at once: find python2.7 -type d | xargs chmod a+rx

Ensure files loose write permissions:

find python2.7 -type f | xargs chmod a+r


[now obsolete, skip this one] Bundle Mercurial and Python (only required if no compiler on target host/server and if not using make install-home-bin)

tar -cvzhf mercurial.tar.gz python2.7/ #compress, verbose, z: use gzip2, h: dump files that symbolic links point to instead of using the symbolic link, files, -C or --directory <target_directory>; if you have compatibility issues omit the '-' after the tar or use another archiver like 'pax' which is standard-compliant. tar might well come from times where dinosaurs were around. ; )


Remove no longer needed temporary files if desired: rm -rf python2.7 setuptools-0.6c11-py2.7.egg virtual-python.py #f: force : ignore non-existant files, never prompt. (so non-interruptable)


Alternatively:

mkdir mercurial_python_creation/ && mv mercurial.* mercurial_python_creation/ && mv virtual_python.py mercurial_python_creation/ && mv python2* mercurial_python_creation/



Upload to server

scp ~/mercurial.tar.gz <user>@<server>:mercurial.tar.gz

Eventually accept and store the server key footprint. Enter password and extract the uploaded file remotely via a shell session.

ssh <user>@<server>


cd $HOME && tar -xzf mercurial.tar.gz

Check for hg in the binary folder:

ls -a mercurial/bin/ # -a for all files (including hidden ones)

$ cd $HOME/python2.7/


Create wrapper shell script:

  1. !/bin/sh

export PYTHONPATH=/home/fgiudici/python2.4/lib/python2.4/site-packages /home/fgiudici/python2.4/bin/hg *

and pointed Hudson to it. I also edited python2.4/bin/hg so the "dang bash" line is #!/home/fgiudici/python2.4/bin/python in place of #!/usr/bin/python2.4. It just works.


Configure Mercurial for a Python installation or PortablePython:

$ wget http://mercurial.selenic.com/release/mercurial-2.8.tar.gz

$ scp ~/mercurial-2.8.tar.gz ftp118002-2629078@dragontale.de:mercurial-2.8.tar.gz

$ tar -xzf mercurial-2.8.tar.gz --directory mercurial # -C is a synonym=alias for --directory

$ cd $HOME/<mercurial_extracted_folder>/

either

$ make PYTHON=$HOME/python2.7/bin/python PREFIX=/usr/local/ install-home-bin

$ hg # should show version

OR $ make PYTHON=$HOME/python2.7/bin/python local # build for inplace usage (only within current folder) and only if a compiler is available.

$ ./hg --version # should show the latest version



Problems that might occur (and occurred for me)

If a 'dependency unmet' error occurs when trying to install python2.7-dev then follow the solution I proposed in this thread:

1. sudo apt-get install aptitude
2. sudo aptitude install python2.7-dev
3. skip first proposed solution [Not installed] and wait for the next solution to be proposed:
4. take the solution to downgrade the dependencies.

Also a bunch of i386 programms will propably be removed during the process. (just trust Linux!)