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

Aus Open Source Ecology - Germany
Zur Navigation springen Zur Suche springen
Zeile 22: Zeile 22:
 
For Windows there currently is PortablePython as a ready made option.  
 
For Windows there currently is PortablePython as a ready made option.  
  
===UNIX===
+
===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).  
 
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.
 
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==
+
====Virtual / bundled installation of Python====
 
To create a virtual/bundled installation of Python and Mercurial there are two or more quite similar ways.
 
To create a virtual/bundled installation of Python and Mercurial there are two or more quite similar ways.
  
Zeile 32: Zeile 32:
  
 
<code>
 
<code>
 +
cd $HOME    #cd ~ also works
 +
</code>
 +
 +
 +
<code>
 +
sudo apt-get install python2.7 python2.7-dev #if unmet dependencies problem occurs see [http://wiki.opensourceecology.de/Mercurial_%28hg%29_Installation_Without_Being_Root#Problems_that_might_occur_.28and_occurred_for_me.29 below]
 +
</code>
 +
 +
 +
<code>
 +
wget peak.telecommunity.com/dist/virtual-python.py    #if it can't be resolved, search the web for virtual-python.py .
 +
</code>
 +
 +
 +
<code>
 +
export PYTHONPATH=$HOME/python2.7/lib/python2.7/site-packages/   
 +
</code>
 +
 +
 +
<code>
 +
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!
 +
</code>
 +
 +
Because of <code>cd $HOME</code> in our case it becomes:
 +
<code>
 +
python2.7 ./virtual-python.py --prefix=$HOME/python2.7/
 +
</code>
 +
 +
 +
<code>
 +
python2.7 ./virtual-python.py --prefix=$HOME/python2.7/
 +
</code>
 +
 +
 +
Two possibilities:
 +
 +
1.  Fetch the relevant part of setuptools package: (if another python version is required look [https://pypi.python.org/packages/2.7/s/setuptools/ here] for the .egg file):
 +
 +
<code>
 +
$ wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
 +
</code>
 +
 +
 +
I figured that one command was missing to get a successful install:
 +
<code>
 +
chmod +x ./setuptools-0.6c11-py2.7.egg
 +
</code>
 +
Now make sure that the PYTHONPATH is pointing to the correct python directory: $HOME/python2.7/lib/python2.7/site-packages/ .
 +
Check it using: <code>echo $PYTHONPATH</code> (If it's not correct, once again: <code>export PYTHONPATH=$HOME/python2.7/lib/python2.7/site-packages/</code>.
 +
 +
 +
Then install easy_install binaries et alia using:
 +
<code>
 +
$ ./setuptools-0.6c11-py2.7.egg --prefix=$HOME/python2.7/
 +
</code>
 +
 +
(Note that this is a required step - it must not fail! Check the terminal output.)
 +
 +
 +
 +
<!--
 +
2. Use complete setuptools. Fetch setup tools sources:
 +
<code>
 +
$ wget https://bitbucket.org/pypa/setuptools/get/default.tar.gz#egg=setuptools-dev
 +
</code>
 +
 +
Unzip the downloaded package:
 +
 +
<code>
 +
$ tar -xf pypa-setuptools<press Tab key for autocomplete or proposals>
 +
</code>
 +
 +
 +
<code>
 +
$ cd <setuptools source directory></code>
 +
 +
 +
<code>
 +
$ $HOME/python2.7/bin/python ./setup.py install
 +
</code>
 +
http://stackoverflow.com/questions/11249901/creating-a-portable-python-local-install-for-linux
 +
-->
 +
 +
<code>
 +
python2.7/bin/easy_install-2.7 --prefix=$HOME/python2.7/ mercurial
 +
</code>
 +
 +
 +
Change the rights of all types (user[read:owner], group, other) at once:
 +
<code>
 +
find python2.7 -type d | xargs chmod a+rx
 +
</code>
 +
 +
Ensure files loose write permissions:
 +
 +
<code>
 +
find python2.7 -type f | xargs chmod a+r
 +
</code>
 +
 +
 +
===Bundle Mercurial and Python===
 +
<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. ; )
 +
</code>
 +
 +
 +
Remove no longer needed temporary files if desired:
 +
<code>
 +
rm -rf python2.7 setuptools-0.6c11-py2.7.egg virtual-python.py    #f: force : ignore non-existant files, never prompt. (so non-interruptable)
 +
</code>
 +
 +
 +
Alternatively:
 +
 +
<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===
 +
 +
<code>scp ~/mercurial.tar.gz <user>@<server>:mercurial.tar.gz</code>
 +
 +
Eventually accept and store the server key footprint. Enter password and extract the uploaded file remotely via a shell session.
 +
 +
<code>
 +
ssh <user>@<server>
 +
</code>
 +
 +
 +
<code>
 +
cd $HOME && tar -xzf mercurial.tar.gz
 +
</code>
 +
 +
Check for hg in the binary folder:
  
 +
<code>
 +
ls -a mercurial/bin/    # -a for all files (including hidden ones)
 
</code>
 
</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.
 
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.
  
Zeile 66: Zeile 206:
 
$ ./hg --version  # should show the latest version
 
$ ./hg --version  # should show the latest version
 
</code>
 
</code>
 +
-->
 +
 +
  
 
==Problems that might occur (and occurred for me)==
 
==Problems that might occur (and occurred for me)==

Version vom 12. Januar 2014, 23:05 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


Bundle Mercurial and Python

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)




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