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:
  
  
====[this is no longer obsolete and can not be avoid due to header issues] Bundle Mercurial and Python (only required if no compiler on target host/server and if not using make install-home-bin)====
+
====[this is no longer obsolete and can not be avoid due to header issues] Bundle Mercurial and Python (only required if no compiler on target host/server and if using make install-home-bin is impossible!)====
  
 
<code>
 
<code>
Zeile 148: Zeile 148:
  
 
<code>mkdir mercurial_python_creation/ && mv mercurial.* mercurial_python_creation/ && mv virtual_python.py mercurial_python_creation/ && mv python2* mercurial_python_creation/</code>
 
<code>mkdir mercurial_python_creation/ && mv mercurial.* mercurial_python_creation/ && mv virtual_python.py mercurial_python_creation/ && mv python2* mercurial_python_creation/</code>
 
 
 
  
 
===Upload to server===
 
===Upload to server===

Version vom 13. Januar 2014, 01:42 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


[this is no longer obsolete and can not be avoid due to header issues] Bundle Mercurial and Python (only required if no compiler on target host/server and if using make install-home-bin is impossible!)

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>


Setting up virtual python installation

cd $HOME && tar -xzf mercurial.tar.gz #attention the resulting folder is python<version> in place of mercurial

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

Log on to the server. (see above)

Extracting into a folder requires this folder to already exist! (so then don't omit this step). We chose 'mercurial' as the target directory:

mkdir mercurial #alternatively call it 'hg'

Unpack the downloaded mercurial package:

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

$ cd $HOME/<mercurial_extracted_folder>/

now 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

Alternative: VirtualEnv[ironment]

The third entry from top: http://stackoverflow.com/questions/11249901/creating-a-portable-python-local-install-for-linux



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!)

Another severe problem and showstopper was that there are different mercurial versions around ... some of them use 4byte string representation instead of the common type of 2byte (As also using .tgz ending mercurial files did not stop errors I settled on a trick, see below:)

sudo apt-get source mercurial #called from $HOME

This made me feel strange once again, but at least this resolved the python issues.


The next problem was a old the python header files were missing once again. So that is a strong indicator of missing installation of python<version>-dev package on the target system (server in our case).

Just another trick helped resolve this: A bundled python or PortablePython as long as PortablePython has the header files included! And that may be uncertain.

For the bundled python solution see above: marked as obsolete, but now it no longer is. (- :