Irc-Unix.net

Главная | Actual Topics | Обратная связь | Guest Book | В избранное | Сделать домашней
Категории
 System & Utilities
 Unix News
 OS Emulator
 Developing
 Learning/Education
 Games
 Humour
Каталог статей
Все статьи

Antispam
Статьи
Биллу Гейтсу тоже предлагают избавиться ...
Вымогательство в борьбе со спамом
Календарь

September, 2017
ПнВтСрЧтПтСбВс
123
45678910
11121314151617
18192021222324
252627282930
Опросы
Какой из этих ОС Вы отдаете большее предпочтение?

QNX
FreeBSD
Linux(any)
Solaris
Mac OS
Windows XP
Windows 2003
Что такое ОС? :)


Результаты
Другие опросы

Всего голосов: 325
Комментарии: 0
Ссылки

Архив Новостей
 September 2017 (11)
 August 2017 (13)
 February 2017 (14)
 January 2017 (19)
 December 2016 (16)
 November 2016 (16)
 October 2016 (21)
 September 2016 (18)
 August 2016 (16)
 July 2016 (16)
 June 2016 (20)
 May 2016 (18)
 April 2016 (15)
 March 2016 (22)
 February 2016 (17)
 January 2016 (15)
 December 2015 (15)
 November 2015 (22)
 October 2015 (20)
 September 2015 (17)
 August 2015 (25)
 July 2015 (20)
 June 2015 (23)
 May 2015 (21)
 April 2015 (17)
 March 2015 (19)
 February 2015 (9)
 January 2015 (23)
 December 2014 (9)
 November 2014 (13)
 October 2014 (12)
 September 2014 (18)
 August 2014 (20)
 July 2014 (10)
 June 2014 (12)
 May 2014 (12)
 April 2014 (10)
 March 2014 (22)
 February 2014 (10)
 January 2014 (8)
 December 2013 (26)
 November 2013 (53)
 October 2013 (40)
 September 2013 (48)
 August 2013 (63)
 July 2013 (56)
 June 2013 (52)
 May 2013 (49)
 April 2013 (67)
 March 2013 (74)
 February 2013 (63)
 January 2013 (62)
 December 2012 (62)
 November 2012 (66)
 October 2012 (68)
 September 2012 (48)
 August 2012 (75)
 July 2012 (60)
 June 2012 (71)
 May 2012 (69)
 April 2012 (85)
 March 2012 (86)
 February 2012 (90)
 January 2012 (81)
 December 2011 (103)
 November 2011 (118)
 October 2011 (74)
 September 2011 (2)
 June 2011 (110)
 May 2011 (118)
 April 2011 (111)
 March 2011 (112)
 February 2011 (101)
 January 2011 (119)
 December 2010 (117)
 November 2010 (118)
 October 2010 (131)
 September 2010 (117)
 August 2010 (226)
 July 2010 (351)
 June 2010 (305)
 May 2010 (319)
 April 2010 (343)
 March 2010 (329)
 February 2010 (311)
 January 2010 (312)
 December 2009 (266)
 November 2009 (156)
 July 2009 (101)
 June 2009 (279)
 May 2009 (365)
 April 2009 (348)
 March 2009 (347)
 February 2009 (323)
 January 2009 (318)
 December 2008 (237)
 November 2008 (155)
 October 2008 (334)
 September 2008 (310)
 August 2008 (343)
 July 2008 (362)
 June 2008 (322)
 May 2008 (636)
 April 2008 (1276)
 March 2008 (1658)
 February 2008 (250)
 January 2008 (6)
 November 2007 (1)
 September 2007 (1)
 June 2007 (1)
 May 2007 (1)
 March 2007 (1)
 January 2007 (2)
 December 2006 (1)
 October 2006 (2)
 September 2006 (1)
 August 2006 (2)

Jason A. Donenfeld (zx2c4/jdonenfeld): Interfacing CGit and Gitolite

System & Utilities

As many of you know, the KDE Project is transitioning to using Git with Gitolite and CGit. As such, I thought I’d update my aging Gitweb/posix-permissions installation of git to use CGit and Gitolite, and now my public git repository is kicking away. (If you’d like commit access any place or would like to host your own repo on my server, drop me a line.)

Since Gitolite manages git repositories, it has the option of generating the necessary information for Git’s shipped gitweb. This includes making a static list of repository names that should be included in gitweb as well as optionally adding the gitweb.owner entry inside .git/config and the description file at .git/description. The static list of repository names is boring and standard and easy. The owner and description specifications are standards set by the Git project for this kind of information. Hence, Gitolite supports interfacing with them.

Meanwhile, CGit uses its own configuration format for determining the owner and description and repository path. For interfacing with Gitolite, in the past I have created a hook that writes out a CGit-formated configuration file, which is then included in the main cgitrc with the include directive. Essentially I had to do this:

gitcode@starfox ~ $ cat web/cgit/generaterepos.sh
#!/bin/sh
 
cd $(dirname "$0")
rm -f repos.tmp
 
cat ~/projects.list | while read gitname; do
name=${gitname%.*}
fullpath=/home/gitcode/repositories/$gitname
owner=$(git --git-dir=$fullpath config --get gitweb.owner)
desc=$(cat $fullpath/description)
(
echo repo.url=$name
echo repo.name=$name
echo repo.path=$fullpath
echo repo.desc=$desc
echo repo.owner=$owner
echo repo.enable-log-filecount=1
echo repo.enable-log-linecount=1
) >> repos.tmp
done
 
mv repos.tmp repos
 
gitcode@starfox ~ $ tail -n 1 web/cgit/cgitrc
include=/home/gitcode/web/cgit/repos
 
gitcode@starfox ~ $ cat repositories/gitolite-admin.git/hooks/post-update.secondary
#!/bin/sh
exec /home/gitcode/web/cgit/generaterepos.sh

This worked decently, but it was cumbersome and ugly, and was likely not to scale as features in both Gitolite and CGit are added and changed. Luckily, CGit supports the scan-path option, which builds an internal list of repositories automatically by scanning a directory for git folders. One such solution for integrating with Gitolite would be to simply point scan-path at Gitolite’s repository directory. This works fine, but it has three main shortcomings, which I’ve addressed this in a generic non-Gitolite-specific way in three patches. Let’s walk through them one by one.

projects-list

We don’t want all Gitolite repositories showing up on CGit, and Gitolite provides a generic mechanism for controlling this: it writes a list of all the repositories selected for Gitweb to a file called projects.list. It’s just a flat file with each repository’s name written on a new line:


CheeseWhiz.git
Geoemail.git
MyCoolThangs.git

So, what about augmenting CGit’s scan-path feature with another setting called “project-list” that points to this file? That’s what this patch does. If project-list is set before scan-path is set, then scan-path only scans the git folders at project-list/${a line in the project-list file}. Problem solved, and this is a pretty generic way of doing it too.

git-suffix

Most people store git repositories on disk at MyGitRepository.git. Notice the .git ending. However, most people prefer to see it listed as just “MyGitRepository” and they especially would like to clone it at gituser@domain.com:MyGitRepository, without needing the .git ending. Usually, CGit’s scan-path infers the repository name directly from the folder name. This patch adds a setting called “remove-suffix” that, if set to 1 (default is 0) before scan-path is set, will remove the .git suffix from the repository name and url while still pointing to the correct physical path. This as well is fairly generic and not specific to Gitolite or Gitweb, but rather Git’s usual conventions.

config-owner

CGit’s scan-path infers the owner of the repository from the posix owner’s UID name. But there is an additional Git standard for overriding this for any interface: the “gitweb.owner” configuration key in .git/config, which Gitolite understands and respects, as well as Gitweb. This patch simply calls Git’s internal C functions for fetching this information from the current repository’s config, and prefers this as the owner to the posix owner’s UID name. If gitweb.owner is not set in the configuration, it falls back to the posix owner’s UID name. This is a standard Git behavior. This occurs only for scan-path — cgitrc specified owners are preferred over these former two, obviously. Again, this configuration standard has been determined by the Git project, and both Gitolite and Gitweb respect it. So, this patch adds support inside CGit for it.

it works

Now instead of the include and the ugly set of scripts and hooks, I can just place this at the bottom of my cgitrc:


remove-suffix=1
project-list=/home/gitcode/projects.list
scan-path=/home/gitcode/repositories

and this integrates perfectly with Gitolite. All is harmonious in the Git universe.

On top of all this, I’ve cooked up a wicked good .htaccess file for CGit that allows me to have anonymous http pull at the same time as it rewrites the CGit urls to be pretty. Check it out:

Options FollowSymlinks ExecCGI
 
DirectoryIndex cgit.cgi
Allow from all
Order allow,deny
 
RewriteEngine on
 
SetEnv GIT_PROJECT_ROOT=/home/gitcode/repositories
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule "^(.*)/(.*)/(HEAD|info/refs|objects/(info/[^/]+|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}.(pack|idx))|git-(upload|receive)-pack)$" /git-http-backend.cgi/$1.git/$2 [NS,L,QSA]
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /cgit.cgi/$0 [L,PT,NS]

A strange combination of stopping internal redirects and partial rewritings and odd stop conditions has made it so that the request gets forwarded and reformatted to git-http-backend if and only if it is first valid with cgit.cgi. Is this crackable? Can anyone figure out a backdoor to grab a repository that isn’t in projects.list?

I’ve also written a super generic script for uploading new repositories to my gitolite/cgit installation. From a git working directory, I run ~/Projects/uploadNewGit.sh "This is a description of my new git repo.", and wham-shabam, all the permissions get set and everything is uploaded just fine. Here is uploadNewGit, the latest version of which you can always find in my GitTools repository:

#!/bin/sh
 
GITOLITE_ADMIN="$HOME/Projects/gitolite-admin"
 
gitdir=$(readlink -f "$(pwd)")
name=`basename "$gitdir" | cut -d / -f 2 | cut -d ' ' -f 1`
description="$1"
 
if [ ! -d "$gitdir/.git" ]; then
echo Not a git repo.
exit 1
fi
if [ -z "$description" ]; then
echo You need to specify a description argument.
exit 1
fi
 
pushd "$GITOLITE_ADMIN/conf" > /dev/null
echo "Writing config.."
(echo
echo " repo $name"
echo " RW+CD = $(whoami)"
echo " R = @all"
echo " $name "$(git config --get user.name)" = "$description"") >> gitolite.conf
git commit -a -m "Adding $name to repository."
git push
popd > /dev/null
 
url=`git --git-dir=$GITOLITE_ADMIN/.git remote -v | grep push | cut -f 2 | cut -d ' ' -f 1 | sed "s/$(basename $GITOLITE_ADMIN)/$name/"`
git remote add origin $url
git push origin master
git push --all
git push --tags

(As a side note, I’m not really sure the best way to quote commands inside of commands with variables that have spaces. something=$(command $(othercommand $argument)) has issues if argument has a space or if othercommand produces something with a space or if command produces something with a space (not totally certain about the latter two — I should check). But I can’t do this: something=”$(command “$(othercommand “$argument”)”)” because of obvious quoting problems. What’s the common solution to this? I’ve been using an awkward combination of the backtick operator `..` and the $(..) syntax but the backtick has some weird rules too. What’s the deal? Can somebody point me in a good place to read about this?)

Anyway, most of what I’ve written about in this post is new to me. Or at the very least, I’m a bit uneasy. So if you have any suggestions, by all means please tell me. I’m looking forward to seeing what the KDE sysadmins do in the end. Hopefully the CGit authors accept my patches.





  


Разместил: Planet KDE | Дата: 30.07.2010 | Прочитано: 5445 | Раздел: System & Utilities   

Рейтинг статьи

Средняя оценка: 0.00/0Средняя оценка: 0Всего голосов:0

Отлично
Хорошо Нормально Пойдёт Плохо


Смотрите также связанные темы

01.07.2008 We need contributors
Submitted by jason harris on Thu, 06/26/2008 - 22:35. KDE General Have to say, I totally agree with the sentiments expressed by Troy.
05.09.2008 VirtuallyCrazy: Importing OVF File From the Internet in VirtualCenter
Jason Wiley tries out the Virtual Appliance Import feature in VirtualCenter. OVF really takes the virtual appliance concept to a new (and better) level. Link: VirtuallyCrazy: Importing OVF File From the Internet in VirtualCenter. Once this process is complete you...
07.11.2008 VI admins sleep easier: HA in action
From Jason Boche yesterday morning on Twitter. Check out his new blog, now on Planet V12n. "Lost power this morning to an ESX blade @ 9:44:15. VMware HA powers on downed VMs @ 9:45:17 after migrating them to a different...
12.12.2008 xf86-video-radeonhd 1.2.4
До версии 1.2.4 обновился открытый драйвер для карт от AMD/ATiОсновные изменения: Поддержка HDMI Поддержка чипов RV710, RV730 Улучшена поддержка RandR 1.3 (поворот, смещение экрана) Исправлено огромное количество ошибок >>> Скачать
27.12.2008 MPD 0.14.0
Вышла новая версия музыкального плеера с клиент-серверной архитектурой.Основные изменения: Теперь умеет выводить звук в fifo, null. Переписан вывод в shout. Теперь поддерживается стриминг в mp3. Добавлена поддержка ffmpeg, wavpack, aac; libmikmod по умолчанию отключен. Поддержка новых команд "addid" и "idle". Множество других приятных изменений; исправлены некоторые баги. Полный список можно почитать тут.
18.05.2009 Comment by Jason Bourne
The KDE team has pushed out the first beta release of KDE 4.3 . The highlights of this release are the integration of many new technologies, such as PolicyKit and Geolocation services, new window animation effects, a more usable run command popup, many new and improved addons in Plasma, Many bugfixes and improvements across all applications, and ...
12.10.2014 Music Player Daemon 0.19
Состоялся выпуск MPD версии 0.19, гибконастраиваемого мощного server-side приложения для проигрывания музыки. В этой версии добавлено много новых возможностей, плагинов и улучшений, основные из них: Доступ к NFS и SMB/CIFS как music_directory без монтирования gzip сжатие базы данных медиа Нативное проигрывание DSD Поддержка мультиканального DSD и DSD512 Новый mp3 encoder: libshine Новый resampler: libsoxr Различные оптимизации энергопотребления и задержки >>> Полный список изменений  mpd
22.01.2010 White boxes and home labs - Community Podcast #79
White boxes and home labs - Community Podcast #79 We haven't posted a post with podcast notes in quite a while, but we're still going strong. If you aren't familiar with our curious tradition, every Wednesday at noon California time a gang of motley VMware admins, gurus, newbies, troublemakers, jokers, kibitzers, and seekers of knowledge gather around a virtual campfire and record a podcast. All are welcome, and a good time is had by all. You can listen to the podcast via the widget on the right, the mp3, or via iTunes. If you ask those in the know, however, they'll tell y...
15.02.2010 Top 5 Planet V12n blog posts week 06
Top 5 Planet V12n blog posts week 06 VMware PEX 2010 was great... but it did mean I was extremely busy and didn't have time to create the top-5. I just picked the 5 best reads this week. Check it out: Jason Boche - My VCDX defense experienceThe first 75 minutes is spent “defending” my design.  I’ve got about a 15 slide deck to get through and to use as reference throughout the design defense.  I’d highly recommend putting as much reference as you can in the slide deck which you can yourself refer to during the defense.  It will help illustrate design choices and jog y...
21.02.2010 Top 5 Planet V12n blog posts week 07
Top 5 Planet V12n blog posts week 07 Let me start by congratulating two well known community members with achieving the VCDX certification. Congrats Jason Boche and Scott Lowe, well done. These two guys just received the news that they passed the final stage and I am already been preparing the upcoming VCDX Defense Panels in Munich. Upcoming week is an exciting one for me personally, shifting jobroles... As of Monday I will be a vCloud Architect for VMware Advanced Services. My focus, in terms of blogging, will remain the same but of course will include more cloud related topics. But enough...
Нет комментариев. Почему бы Вам не оставить свой?
Вы не можете отправить комментарий анонимно, пожалуйста зарегистрируйтесь.
Google Search
Google

Web irc-unix.net

Топ Новостей
1: KDE Community announces fully open source Plasma Mobile
Hot NEWS!
Просмотров - 545


2: Using Digikam and ownCloud to share family pictures
Просмотров - 515

3: Apply agile methodologies to upstream development environments.... if you can.
Просмотров - 487

4: KWallet5 can be auto-unlocked during login again
Просмотров - 477

5: Interview with Laura
Просмотров - 451

6: Use ownCloud provided Packages, then VM, then Zip, no distro packages.
Просмотров - 449

7: Plasma Components on Android: Accelerating Subsurface Mobile Development
Просмотров - 438

8: debian/rake: Ruby DH Sequencing?
Просмотров - 418

9: VMware Workstation 11 and kwin - hangs and hiccups (solved?)
Просмотров - 414

10: Plasma 5 Powers KaOS Productivity
Просмотров - 405

11: KWrite on Mac – Application Bundle
Просмотров - 402

12: One year old: Document Liberation Project
Просмотров - 383

13: New Year Calligra Words Sprint
Просмотров - 379

14: FOSDEM Desktops DevRoom 2016 Call for Participation
Просмотров - 379

15: digiKam 5.0.0-beta2 is released
Просмотров - 376

Google 120X240
Ссылки

Главная | Actual Topics | Статьи | Обратная связь | Guest Book
Генерация: 1.354 сек. и 13 запросов к базе данных за 1.295 сек.
Powered by SLAED CMS © 2005-2007 SLAED. All rights reserved.