header

Torsten Curdt’s weblog

Star Trek on Joost

If you are a Star Trek fan you might be happy to hear that the original series is available on Joost now …at least for people in the US. (Bah!)

From subversion to git (part3 – gitosis)

In order to have proper permission management with git you will have to install gitosis. Unfortunately there is no Debian package for it yet. For convenience you can download my build here. But building the package yourself is easy as the sources are already debianized.

sudo apt-get install build-essential fakeroot
git clone git://eagain.net/gitosis.git
cd gitosis.git
./debian/rules generate
dpkg-checkbuilddeps

Of course you will have to install the packages checkbuilddeps has found missing. Once it’s satisfied you can build the package and install it.

dpkg-buildpackage -us -uc -rfakeroot
sudo dpkg -i gitosis_0.2_all.deb

Note: The dependencies will require your system to be sort of up-to-date. It basically gave me a reason to upgrade from Edgy to Gutsy.

What’s left to do is to configure gitosis. Assuming you already have a public ssh key on your machine you can use that to initalize the repository.

$ scp .ssh/id_dsa.pub [email protected]:/tmp
$ sudo -H -u git gitosis-init < /tmp/id_dsa.pub
Initialized empty Git repository in ./
Initialized empty Git repository in ./
$ rm /tmp/id_dsa.pub

Then you will have to checkout the gitosis admin project

git clone [email protected]:gitosis-admin.git
cd gitosis-admin
vi gitosis.conf

and adjust the configuration to your needs.

[gitosis]

[repo testproject]
gitweb = yes
description = Project description
owner = [email protected]

[group team]
writable = testproject
members = [email protected]

[group gitosis-admin]
writable = gitosis-admin
members = [email protected]

Also check the keydir. It should include “[email protected]” and all members that are listed in your config. Don’t forget to git-add them. And then commit and push the configuration to the server.

git commit -a -m "Inital configuration"
git push

Adding projects is easy now. Just add them through the gitosis-admin project. When you push the changes you will get a warning

WARNING:gitosis.gitweb.set_descriptions:Cannot find 'testproject' in '/home/git/repositories'
WARNING:gitosis.gitweb.generate_projects_list:Cannot find 'testproject' in '/home/git/repositories'

Then initialize your project and push it out.

git init
git add .
git commit -m "initial import"
git remote add origin [email protected]:testproject.git
git push --all

Thanks to Garry for the help in getting this up and running.

From subversion to git (part2 – gitweb)

Assuming you have installed the Debian gitweb package

sudo apt-get install gitweb

you will find the gitweb configuration under “/etc/gitweb.conf”. Let’s configure it to point to the previously created git repository and disable some of the expensive features.

$my_uri = "http://yourserver.com/gitweb";
$site_name = "yourserver.com/gitweb";
$projectroot = "/home/git/repositories";

$git_temp = "/tmp";
$home_link = $my_uri;
$home_text = "indextext.html";
$projects_list = $projectroot;
$stylesheet = "/gitweb/gitweb.css";
$logo = "/gitweb/git-logo.png";
$favicon = "/gitweb/git-favicon.png";
$projects_list_description_width = 40;

$feature{'pathinfo'}{'default'} = [1];

$feature{'search'}{'default'} = [undef];
$feature{'blame'}{'default'} = [undef];
$feature{'pickaxe'}{'default'} = [undef];
$feature{'grep'}{'default'} = [undef];

The package installs the actual CGI under “/usr/lib/cgi-bin/gitweb.cgi”. So make sure your httpd config includes the proper script alias

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

and include the following segment into your virtual host configuration.

RewriteEngine on
RewriteRule ^/gitweb/([a-zA-Z0-9_\-]+\.git)/?(\?.*)?$ /cgi-bin/gitweb.cgi/$1 [L,PT]

Alias /gitweb /home/git/gitweb
<Directory /home/git/gitweb>
  Options Indexes FollowSymlinks ExecCGI
  DirectoryIndex /cgi-bin/gitweb.cgi
  AllowOverride None
</Directory>
<Directory /home/git>
  Order allow,deny
  Allow from all
  AllowOverride None
</Directory>

When you now hit http://yourserver.com/gitweb/ you should see your repositories listed. What you will notice though are the missing images and the missing stylesheet. As I like to keep things in one place I’ve moved them into the git home directory

sudo -u git mkdir /home/git/gitweb
sudo cp /var/www/git* /home/git/gitweb
sudo -u git chown -R git:git /home/git/gitweb

You will also need to make sure your project is accessible from the httpd user. Usually this means just making the top directory readable and executable for everyone.

sudo chmod a+rx /home/git/repositories/testproject.git

The stylesheet and images should get served now.
Now let’s setup permissions for accessing the repositories….

From subversion to git (part1 – git)

You read it everywhere – obviously git must be the best since sliced bread. But replacing subversion with git is not exactly just as easy as one would hope. Installing git itself is simple. On Ubuntu just have to install the “git-core” package. But I would recommend some other packages as well.

apt-get install git-core git-svn gitweb

Done. You can already use git and push a git repository onto the server via ssh protocol. You would only need to expose the directory via http. If you want shared repository with permission administration you will need a slightly more complex setup. At least if you don’t want to hand out ssh account for every person. So I’d suggest you create your repository directory in the home directory of a separate “git” user

sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
    git
sudo -u git mkdir /home/git/repositories

Copy your public ssh key onto the machine as “/home/git/.ssh/authorized_keys” and you should be able to log into the machine with “ssh [email protected]”.

In order to make the repositories available we now start the git daemon.

sudo -u git git-daemon
  --reuseaddr \
  --verbose \
  --base-path=/home/git/repositories/ \
  --detach

There is also a package called “git-daemon-run” to start the daemon on system start. Frankly speaking I found it way too complicated and just created a simple init.d script that does the trick.

sudo cat > /etc/init.d/git-daemon << EOF
#!/bin/sh

test -f /usr/bin/git-daemon || exit 0

. /lib/lsb/init-functions

GITDAEMON_OPTIONS="--reuseaddr --verbose --base-path=/home/git/repositories/ --detach"

case "$1" in
start)  log_daemon_msg "Starting git-daemon"

        start-stop-daemon --start -c git:git --quiet --background \
                     --exec /usr/bin/git-daemon -- ${GITDAEMON_OPTIONS}

        log_end_msg $?
        ;;
stop)   log_daemon_msg "Stopping git-daemon"

        start-stop-daemon --stop --quiet --name git-daemon

        log_end_msg $?
        ;;
*)      log_action_msg "Usage: /etc/init.d/git-daemon {start|stop}"
        exit 2
        ;;
esac
exit 0
EOF
update-rc.d git-daemon defaults

Once started you can create a new project

cd testproject
git init
git add .
git commit -m "initial import"
git remote add origin [email protected]:repositories/testproject.git
touch .git/git-daemon-export-ok
scp -rp .git [email protected]:repositories/testproject.git
git push --all

which pushes the initial project to the git server via ssh protocol. The “git-daemon-export-ok” makes it accessible to the outside world via git daemon. Now everyone can clone the repository which is the initial checkout and the first step to follow your work.

git clone git://yourserver.com/testproject.git

Now let’s also expose the git repository over http similar to viewvc

How stupid is Radiohead?

radiohead - in rainbowsSome people seem to think that making their new album “In Rainbows” available on their website was a really stupid move. According to ComScore only 38% voluntarily forked over an average of 6 US$ for the album. Still a fair amount of music magazines consider this album to be one of the best albums in 2007. They would have made so much more money! Did they lose their minds releasing it at the mercy of their customers? I personally don’t think so. Let me explain why I think it was breakthrough and a success.
Read the rest of this entry »