Back to 2006/開発環境



はじめに

環境

  • Ubuntu 12.04

目的

  • gitolite と cgitの共存

gitolite インストール

一般ユーザで作業

  • $ sudo apt-get install gitolite
  • $ cd ssh
  • $ ssh-keygen -> admin用
  • $ cp admin.pub /tmp
  • $ ssh-keygen -> usr1用
  • $ ssh-keygen -> usr2用
  • $ mv *.pub ~/pubkeys
  • $ sudo useradd -m gitolite

gitolite で作業

  • $ sudo su - gitolite
  • $ gl-setup /tmp/admin.pub
  • cgitに備えて、以下だけ修正
- $REPO_UMASK = 0077;
+ $REPO_UMASK = 0027;
  • こうなる
itolite@Ubuntu1204:~$ ls -asl repositories/
合計 16
4 drwxr-x--- 4 gitolite gitolite 4096  4月 13 00:36 .
4 drwxr-xr-x 5 gitolite gitolite 4096  4月 13 00:36 ..
4 drwxr-x--- 8 gitolite gitolite 4096  4月 13 00:36 gitolite-admin.git
4 drwxr-x--- 7 gitolite gitolite 4096  4月 13 00:36 testing.git
  • $ exit

管理者として

  • $ cat .ssh/config
host gitserver
        user gitolite
        hostname localhost
        identityfile ~/.ssh/admin

gitolite-admin

  • $ git clone ssh://gitserver/gitolite-admin
  • keydir 以下に user1.pub , user2.pub をコピーして、git add ,git commit
  • $ git push
Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.03 KiB, done.
Total 5 (delta 0), reused 0 (delta 0)
remote:
remote:                 ***** WARNING *****
remote:         the following users (pubkey files in parens) do not appear in the config file:
remote: user1(user1.pub),user2(user2.pub)
To ssh://gitserver/gitolite-admin
   d0a686f..8cdab7e  master -> master

newrepo

  • gitolite-admin$ git diff
diff --git a/conf/gitolite.conf b/conf/gitolite.conf
index 2d55bf8..e13cac1 100644
--- a/conf/gitolite.conf
+++ b/conf/gitolite.conf
@@ -3,3 +3,7 @@ repo    gitolite-admin

 repo    testing
         RW+     =   @all
+
+repo   newrepo
+        R       =   @all
+        RW      =   user2

  • git add, git commit, git push

cgit

  • gitolite-admin/conf$ git diff
diff --git a/conf/gitolite.conf b/conf/gitolite.conf
index e13cac1..5764732 100644
--- a/conf/gitolite.conf
+++ b/conf/gitolite.conf
@@ -7,3 +7,6 @@ repo    testing
 repo   newrepo
         R       =   @all
         RW      =   user2
+
+repo   cgit
+        RW      =   user2
  • git add, git commit, git push

ユーザ1として

  • $ cat .ssh/config
host gituser1
        user gitolite
        hostname localhost
        identityfile ~/.ssh/user1
  • $ ssh gituser1
PTY allocation request failed on channel 0
hello user1, this is gitolite 2.2-1 (Debian) running on git 1.7.9.5
the gitolite config gives you the following access:
    @R_         newrepo
    @R_ @W_     testing
Connection to localhost closed.

testing

  • $ git clone ssh://gituser1/testing
  • ファイルを作成して、git add, git commit
  • $ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 232 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://gituser1/testing
 * [new branch]      master -> master
  • ファイルを修正して、git add, git commit
  • $ git push origin master
  • $ git push
Counting objects: 5, done.
Writing objects: 100% (3/3), 272 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://gituser1/testing
   5be9648..202da94  master -> master

newrepo

  • $ git clone ssh://gituser1/newrepo
  • 編集して、git add , git commit
  • $ git push origin master
W access for newrepo DENIED to user1
(Or there may be no repository at the given path. Did you spell it correctly?)
fatal: The remote end hung up unexpectedly
  • "W"権限がないので、失敗して正しい。

ユーザ2として

  • $ cat .ssh/config
host gituser2
        user gitolite
        hostname localhost
        identityfile ~/.ssh/user2

testing

  • $ git clone ssh://gituser2/testing
  • ファイルを修正して、git add, git commit
  • $ git push
Counting objects: 5, done.
Writing objects: 100% (3/3), 281 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://gituser2/testing
   202da94..1039296  master -> master

newrepo

  • $ git clone ssh://gituser2/newrepo
  • 編集して、git add , git commit
  • $ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://gituser2/newrepo
 * [new branch]      master -> master

cgit

  • $ git clone ssh://gituser2/cgit
  • $ cd cgit/
  • $ git remote add zx2c4 http://git.zx2c4.com/cgit
  • $ git fetch -all
  • $ git checkout remotes/zx2c4/master -b master
  • $ git push origin master

cgit インストール

  • $ git log
commit 389cc17357e2040c9542d3e085f64a8d2f085e9a
Author: Jason A. Donenfeld <Jason@zx2c4.com>
Date:   Mon Apr 8 16:57:12 2013 +0200
  • READMEに従う。
  • $ sudo apt-get install libssl-dev
  • $ git submodule init
  • $ git submodule update
  • $ make
  • $ sudo make install

設定

  • $ cat /etc/cgitrc
# Specify the css url
css=/htdocs/cgit/cgit.css
# Use a custom logo
logo=/htdocs/cgit/cgit.png
# Enable statistics per week, month and quarter
max-stats=quarter
# Set the title and heading of the repository index page
root-title=git repositories
# Set a subheading for the repository index page
root-desc=tracking
# Allow download of tar.gz, tar.bz2 and zip-files
snapshots=tar.gz tar.bz2 zip
##
## List of common mimetypes
##
mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml
##
## List of repositories.
## PS: Any repositories listed when section is unset will not be
##     displayed under a section heading
## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos')
##      and included like this:
##        include=/etc/cgitrepos
##
repo.url=cgit
repo.path=/home/gitolite/repositories/cgit.git
repo.desc=cgit
  • /etc/apache2$ git diff
diff --git a/sites-available/default b/sites-available/default
index c131197..f8dd5db 100644
--- a/sites-available/default
+++ b/sites-available/default
@@ -12,6 +12,13 @@
                Order allow,deny
                allow from all
        </Directory>
+       ScriptAlias /cgit/ /var/www/htdocs/cgit/
+       <Directory "/var/www/htdocs/cgit/">
+               AllowOverride None
+               Options +ExecCGI
+               Order allow,deny
+               Allow from all
+       </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
  • $ sudo vipw -g
gitolite:x:1002:www-data
+       ScriptAlias /cgit/ /var/www/htdocs/cgit/cgit.cgi/

memo


  • RW+ は、RWよりもできることが多い。

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

×

この広告は60日間更新がないwikiに表示されております。

管理人/副管理人のみ編集できます