2012年6月21日木曜日

Ubuntu 12.04 LTS のプロキシで無視リストを設定

Ubuntuを10.04LTSから12.04LTSに移行したらプロキシ設定のUIが変わってた。

めちゃくちゃシンプルになっていて、今まであったプロキシの例外設定を加える項目が見当たらない。

調べてみると見つかった。
Where to set proxy ignore list?

まず、設定するためのソフトウェアdconf-toolsを入れる。
sudo apt-get install dconf-tools

Superキー(Winキー)を押してUbuntuメニューを表示し、dconfと入力すると、「dconf Editor」というものが出てくるのでそれを実行。

gconf editor設定画面

proxyのところにignore-hostsという項目があるので、Valueのところをクリックして、無視リストを追加する。例えば、['localhost','127.0.0/8','*.example.com']とか。

以上。

2012年6月15日金曜日

管理者権限のない人がpip, virtualenv, virtualenvwrapperをhomeにインストールする

管理者権限のない人がPython2.7とPython3.2.3をインストールしたときのやり方はコチラ

目的

virtualenv環境を入れて、複数の仮想python環境を構築する。

やり方

基本的には以前に書いた記事と同じやり方。setuptools入れるときは、どのバージョンのpythonでもいいはずなので、とりあえずpython2.7を使うことにする。
まずは、ちゃんとhomeのpythonにパスが通す。(bashrcとかで通している人はOK)
export PATH=$HOME/.local/bin:$PATH
つぎに、setuptoolsのインストーラをダウンロード。ちゃんと2.7用のものをダウンロード。
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
sh setuptools-0.6c11-py2.7.egg
easy_install-2.7 pip
pip install vitualenv virtualenvwrapper
ここで、easy_installでpipをinstallするときに、easy_install-2.7を呼ぶようにしないとダメだった。
次に、virtualenvwrapperを設定する。 次を実行するか。(次回起動時にも反映させるために.bashrcや.zshrcなどに追加しておくべき)
source $HOME/.local/bin/virtualenvwrapper.sh
python仮想環境を作成。例えば、python27用をpy27という名前で作成。
mkvirtualenv py27 -p python2.7
python3.2だったら
mkvirtualenv py32 -p python3.2
仮想環境に有効にするには
workon py32
抜けるときは
deactivate

追記

ログイン時に反映させたい場合は.bashrcなどに
export VIRTUALENVWRAPPER_PYTHON=$HOME/.local/bin/python
source $HOME/.local/bin/virtualenvwrapper.sh
virtualenvをインストールしたときのpythonへのパスを書かなくてはならないっぽい。

2012年6月14日木曜日

ユーザーhomeにpython2.7.3(ついでにPython3.2.3も)をインストールしたときのメモ

目的

職場のRHEL5上のhomeにpython2.7をインストールしたい。管理者権限はない。

やり方

インストール先は$HOME/.localとする。.local/以下にbin, libなどが作成される。

Pythonをインストール

pythonのソースを本家からwgetして持ってきて、configure(インストール先の指定は--prefix)してmake installすれば良いかと思ったが、
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar xvzf Python-2.7.3.tgz
cd Python-2.7.3
.configure --prefix=$HOME/.local
make install
ここで、
hg identify: option -i not recognized
hg identify: option -t not recognized
hg identify: option -b not recognized
./Modules/getbuildinfo.c: In function ‘Py_GetBuildInfo’:
./Modules/getbuildinfo.c:45: error: missing terminating " character
./Modules/getbuildinfo.c:45: error: expected expression before ‘)’ token
./Modules/getbuildinfo.c:46: error: missing terminating " character
./Modules/getbuildinfo.c:46: error: missing terminating " character
./Modules/getbuildinfo.c:47: error: missing terminating " character
./Modules/getbuildinfo.c:47: error: missing terminating " character
./Modules/getbuildinfo.c:53: error: ‘buildinfo’ undeclared (first use in this function)
./Modules/getbuildinfo.c:53: error: (Each undeclared identifier is reported only once
./Modules/getbuildinfo.c:53: error: for each function it appears in.)
./Modules/getbuildinfo.c: In function ‘_Py_hgversion’:
./Modules/getbuildinfo.c:72: error: missing terminating " character
./Modules/getbuildinfo.c:72: warning: ‘return’ with no value, in function returning non-void
./Modules/getbuildinfo.c: In function ‘_Py_hgidentifier’:
./Modules/getbuildinfo.c:79: error: missing terminating " character
./Modules/getbuildinfo.c:79: error: expected expression before ‘;’ token
./Modules/getbuildinfo.c:83: error: missing terminating " character
./Modules/getbuildinfo.c:83: error: expected expression before ‘;’ token
make: *** [Modules/getbuildinfo.o] Error 1
こんな感じのエラーがでた。調べてみると、自分の環境では、Mercurialのバージョンが古いらしい。
$ hg --version
Mercurial Distributed SCM (version 0.9.3)

Copyright (C) 2005, 2006 Matt Mackall 
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Mercurialの新しいのをインストール

今は2.2とからしい。古すぎだろw。ということで、先にMercurialの2.2.2をhomeにインストールする。
cd ..
wget http://mercurial.selenic.com/release/mercurial-2.2.2.tar.gz
tar xzvf mercurial-2.2.2.tar.gz
cd mercurial-2.2.2
PREFIX=$HOME/.local make install
インストール先はPREFIXに指定するらしい。なんか最後の方にpython-docutilsかなんかをinstallしろ、とerrorがでるが無視。一応インストール完了。インストール先のbinディレクトリをPATHの先頭に加えれば、2.2.2のhgが呼ばれる。
$ export PATH=$HOME/.local/bin:$PATH
$ $HOME/.local/bin/hg --version
Mercurial Distributed SCM (version 2.2.2)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2012 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Pythonのインストール続き

Pythonのディレクトリに戻り、再度make installする。
cd ../Python-2.7.3
make install
インストールできた。 $HOME/.local/bin/pythonにaliasもしくはPATHを通せば、使えます。
alias python=$HOME/.local/bin/python
# OR
export PATH=$HOME/.local/bin:$PATH
$ python --version
Python 2.7.3

ついでにPython3.2.3もインストール

wget http://www.python.org/ftp/python/3.2.3/Python-3.2.3.tgz
tar xvzf Python-3.2.3.tgz
cd Python-3.2.3
./configure --prefix=$HOME/.local
make install
何の問題もなくインストール完了。$HOME/.localにはパスを通してあったので、
$ python3
Python 3.2.3 (default, Jun 15 2012, 11:09:08) 
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
とpython3で呼べる。
ソースファイルへのリンクが切れていたらコチラ。Python mercurial Python-3.2.3

2012年6月13日水曜日

ユーザーhomeにsubversionインストールしたときのメモ

管理者権限がないのにシステムにインストールされているsubversionが自分の使いたいバージョンと違うことってありますよね。例えば、v1.4以下とv1.5以降でこんなふうに違いがあります。
http://www.asahi-net.or.jp/~iu9m-tcym/svndoc/svn_externals_relative.html
  • 相対リンク設定可能
  • URLとディレクトリの順番が逆
  • など
ということで、homeに自分の使いたいsubversionをいれて使いましょう。 ちなみに、ここではRHEL5でやったやり方を書きます。 他でも同様にやれば、まぁ動くと思います。 ここではv1.6.18とv1.7.5でやったやり方を書いておきます。
※wgetのリンクが切れてたら適宜自分でさがしてください。subversionは本家から

v1.6.18のインストール

wget http://subversion.tigris.org/downloads/subversion-1.6.18.tar.gz
wget http://subversion.tigris.org/downloads/subversion-deps-1.6.18.tar.gz
tar xvzf subversion-1.6.18.tar.gz
tar xvzf subversion-deps-1.6.18.tar.gz
cd subversion-1.6.18
depsはdependenciesのことで、依存パッケージを同じディレクトリに展開してくれる(sqlite,neonなど)。
./configure --prefix=$HOME/mybin/subversion-1.6.18 --without-apxs --with-ssl --without-serf
make install
基本的にクライアント機能だけでいいので、apxsとかはずす。じつは、あまり良く解っていない。neonを入れるのでserfはいれていないっぽい。もし、何か足りなくてconfigureで怒られたら、INSTALLを読んで、必要なものをとってきてください。prefixでインストール先を指定する。prefixで指定した先に、bin,share,libなどのディレクトリが作られます。

v1.7.15のインストール

wget http://mirrors.axint.net/apache/subversion/subversion-1.7.5.tar.gz
tar xvzf subversion-1.7.5.tar.gz
cd subversion-1.7.5
wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
tar xvzf sqlite-amalgamation-3.6.13.tar.gz
mv sqlite-3.6.13 sqlite-amalgamation
wget http://www.webdav.org/neon/neon-0.29.0.tar.gz
tar xvzf neon-0.29.0.tar.gz
mv neon-0.29.0 neon
1.7.5は2012.06.12現在ではdepsは存在しないので自分でとってくる。v1.6のdepsからコピってきても良いと思われる。
cd neon
./configure --prefix=$HOME/mybin/subversion-1.7.5 --with-ssl
make install
cd ../
neonはv1.6と違い、なぜか普通にconfigureしても、インストールしてくれないので、自分でインストールする。--with-neonでneonをインストールしたディレクトリを指定してsubversionをインストール。
./configure --prefix=$HOME/mybin/subversion-1.7.5 --with-neon=$HOME/mybin/subversion-1.7.5 --without-apxs --with-ssl --without-serf
make install

使用するsvnを指定する

svnへのコマンドのエイリアスを付ければ良いので、ターミナルで
alias svn=$HOME/mybin/subversion-1.6.18/bin/svn
と打てば、指定したバージョンのsvnを使える。または、
export PATH=$HOME/mybin/subversion-1.6.18/bin:$PATH
としてパスを通してしまう。(通すディレクトリが先。後ろにつなぐとシステムの方のsubversionが呼ばれる。)
$ svn --version
svn, version 1.6.18 (r1303927)
   compiled Jun 12 2012, 20:08:51

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
もちろん、.bashrcなどに書いてしまった方がいい
ソースファイルへのリンクが切れていたらコチラ。 v1.6 v1.6deps v1.7。 v1.7のneon,sqliteはdepsの中のものをコピーして配置すれば使えると思います。