目次
FreeBSDのパッケージでGitのリモートリポジトリをクイックセットアップ
2017/03/06
FreeBSDのpkgコマンドでお手軽にgitblitをインストール、セットアップし、gitのリモートリポジトリを作る。
portsでソースからコンパイルするより速いし、ちゃちゃっと準備するにはおすすめ。git自体の話はしない。
今回は ezjail でJailをこしらえてその中にインストールします。FreeBSDのパッケージだと、Tomcat7で動作するサーブレットとしてインストールされるので、 既にTomcatを動作させているような場合はJailで隔離してインストールした方が良いです。
gitblitインストール前の準備
Jailにインストールする場合、事前に設定しておく内容。
既にJailインスタンス git が作成され起動しているものとします。
Jailホスト、Jailの設定
Jailの通信許可を設定します。 FreeBSDのJailホスト、Jailで設定する項目のメモを参照。
gitblitインストール
Jailにインストールする場合はJailにログインしておきます。
gitblitパッケージをインストール
pkgコマンドのsearchサブコマンドで git を検索するとわんさか出てきます。 パッケージ gitblit-1.8.0 “Open-source servlet for Git repositories” が見つかります。現時点でこれが無難そうです。 これをインストールします。依存関係のあるパッケージも同時にインストールされます。
root@git:~ # pkg search git
bzr-git-0.6.8_1 Plugin for bzr to work with git trees
cave9-0.4.1.git20150408 Gravity cave-exploration game
cgit-1.1_1 Fast, lightweight web frontend for Git repositories
digitemp-3.6.0 Dallas Semiconductor 1-wire device reading console application
easygit-0.98 Easy wrapper for git
fusefs-gitfs-0.4.5.1 Version controlled file system
geany-plugin-git-changebar-1.29 Geany plugin: highlight changed files tracked with Git
git-2.11.0_3 Distributed source code management tool
git-bzr-ng-git20140423 Bi-directional git to bzr bridge
git-cinnabar-0.4.0 Git remote helper to interact with Mercurial repositories
git-codereview-0.0.0.2016030201 Command-line tool for working with Gerrit
git-cola-2.6 Sleek and powerful Git GUI
git-cvs-0.1.0 Tool to incrementally import changesets from CVS into Git
git-extras-4.2.0 Sub-commands for repo summary, repl, changelog population, and more
git-gui-2.11.0_3 Distributed source code management tool (GUI enabled)
git-lfs-1.5.4 Git extension for versioning large files
git-lite-2.11.0_3 Distributed source code management tool (lite package)
git-merge-changelog-20140202 Git "merge" driver for GNU style ChangeLog files
git-modes-emacs25-1.2.2_1,1 GNU Emacs modes for Git-related files
git-review-1.25.0 Allow to push code to review and interact with a Gerrit server
git-subversion-2.11.0_3 Distributed source code management tool with FreeBSD subversion bindings
gitblit-1.8.0 Open-source servlet for Git repositories
gitea-1.0.0 Compact self-hosted Git service
gitflow-1.8.0 Git extensions to provide high-level repository operations
gitg-3.19.6_1 GTK-based git repository viewer
gitg0-0.0.8_2 GTK-based git repository viewer (gtk2 version)
github-backup-utils-2.7.1 GitHub Enterprise Backup Utilities
gitlab-8.11.11_6 Web GUI for managing git repositories
gitlab-shell-3.4.0_1 GitLab Shell handles git commands for GitLab
gitlab-workhorse-0.7.11 Smart reverse proxy for GitLab
gitlist-0.5.0 Web based Git repository browser written in PHP
gitolite-3.6.6,1 Access control layer on top of git
gitolite2-2.3.1_1 Access control layer on top of git
gitphp-0.2.8_1 Web based git repository browser written in PHP
gittrac-2.0.1_1 Web-Based Bug And Patch-Set Tracking System For Git
griels-quest-git20150512 Griel's Quest for the Sangraal
gtk-digital-cream-theme-1.0_8 Neat and clean theme for GNOME desktop
gtk-digital-harmony-theme-1.1_8 Another popular theme for GNOME desktop
hs-git-annex-5.20150727_1 Manage files with git, without checking their contents into git
hs-gitit-0.11.1 Wiki using happstack, git or darcs, and pandoc
libgit2-0.24.0 Portable, pure C implementation of the Git core
libgit2-glib-0.24.0_1 Glib wrapper library around the libgit2 git access library
libvterm-git20160104 Implementation of a VT220/xterm/ECMA-48 terminal emulator
magit-emacs25-2.8.0 Interface to Git for Emacs
metacity-digital-cream-theme-1.0_8 Neat and clean theme for GNOME desktop
metacity-digital-harmony-theme-1.1_8 Another popular theme for GNOME desktop
multicat-git20161007 Simple and efficient multicast and transport stream manipulation
p5-Algorithm-CheckDigits-1.3.2 Perl extension to generate and test check digits
p5-App-GitGot-1.333 Tool to make it easier to manage multiple git repositories
p5-App-GitHub-1.0.1_1 GitHub Command Tools
p5-Config-GitLike-1.16 Simple git-compatible config file parser for Perl
p5-Git-PurePerl-0.53 Pure Perl interface to Git repositories
p5-Git-Repository-1.320 Perl interface to Git repositories
p5-Git-Repository-Plugin-Log-1.314 Add a log() method to Git::Repository
p5-Git-Sub-0.161810 Git commands imported into the git:: namespace
p5-Git-Version-Compare-1.004 Functions to compare Git versions
p5-Git-Wrapper-0.047 Wrap git(7) command-line interface
p5-GitDDL-0.03 Perl extension for database migration utility by git managed sql
p5-GitDDL-Migrator-0.08 Perl extension to extended p5-GitDDL
p5-Net-GitHub-0.86 Perl interface to github.com
p5-Test-Requires-Git-1.007 Check your test requirements against the available version of Git
p5-WWW-GitHub-Gist-0.17_1 Perl interface to Gist
p5-github_creator-0.15_1 Create a Github repository for your Perl module
pear-SebastianBergmann_Git-1.2.0 Simple wrapper for Git
pear-VersionControl_Git-0.4.4 OO interface to handle Git repository
py27-GitPython-1.0.1 Python Git Library
py27-django-taggit-0.15.0_1 Reusable Django application for simple tagging
py27-git-up-1.3.0 Python implementation of 'git up'
py27-gitdb-0.6.4_2 Pure Python git object database
py27-gitless-0.8.5 Version control system built on top of Git
py27-gitosis-0.2.20090917_1 Software for hosting git repositories
py27-hg-git-0.8.5.20161206 Mercurial extension to pull from or push to a Git repository
py27-pygit2-0.24.1 Python bindings for libgit2
py27-pygithub-1.26.0 Python library implementing the full GitHub API v3
py27-python-digitalocean-1.8 API to manage digitalocean.com droplets
py27-setuptools-git-1.1 Setuptools plugin for git
py27-wsgitools-0.3 Useful middlewares and filters for wsgi as well as scgi servers
qgit-qt4-2.3_1 Graphical interface to git repositories
rubygem-gemnasium-gitlab-service-0.2.6 Gemnasium support for GitLab projects
rubygem-git-1.2.9.1 Ruby wrapper library around git(1)
rubygem-git-version-bump-0.15.1 Manage your app version entirely via git tags
rubygem-github-linguist-5.0.0 GitHub Language detection
rubygem-github-markdown-0.6.9 Self-contained Markdown parser for GitHub
rubygem-github-markup-1.4.0_1 Render any fancy markup
rubygem-github_api-0.14.5 Wrapper that supports all of the GitHub API v3 methods
rubygem-gitlab-flowdock-git-hook-1.0.1 GitLab-patched Git Post-Receive hook for Flowdock
rubygem-gitlab-gollum-lib-1.1.0_3 Simple, Git-powered wiki with a sweet API and local frontend
rubygem-gitlab-grack-2.0.2_2 Ruby/Rack Git Smart-HTTP Server Handler
rubygem-gitlab-grit-2.8.1_1 Library for extracting information from a git repository
rubygem-gitlab-linguist-3.0.1 GitHub Language detection
rubygem-gitlab-markup-1.5.0 Render any fancy GitLab markup
rubygem-gitlab-pygments.rb-0.5.4_1 Exposes the pygments syntax highlighter to Ruby
rubygem-gitlab_emoji-0.3.1_1 Provides Gitlab Emoji assets
rubygem-gitlab_git-10.7.0,1 GitLab wrapper around git objects
rubygem-gitlab_meta-7.0 GitLab meta gem
rubygem-gitlab_omniauth-ldap-1.2.1 LDAP strategy for OmniAuth
rubygem-html-pipeline-gitlab-0.2.0 Extension filters for html-pipeline used by GitLab
rubygem-omniauth-github-1.1.2 Official OmniAuth strategy for GitHub
rubygem-omniauth-github-discourse-1.1.2 Fork of Official OmniAuth strategy for GitHub
rubygem-omniauth-gitlab-1.0.2 OmniAuth strategy for GitLab
rubygem-svn2git-2.4.0 Ruby utilities for exporting SVN repo to git
sagittarius-scheme-0.7.11 R6RS/R7RS Scheme system
stagit-0.4 Static Git page generator
svn2git-1.0.11.a.20151201 Imports svn repositories into git
uwsgitop-0.10 uWSGI top-like app
xtgyoretsu-git20140822 Extended ncurses version of "Renshu-cho gyoretsu"
root@git:~ #
root@git:~ # pkg install gitblit-1.8.0
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 36 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
gitblit: 1.8.0
openjdk8: 8.112.16_2
libXt: 1.1.5,1
xproto: 7.0.31
libSM: 1.2.2_3,1
libICE: 1.0.9_1,1
libX11: 1.6.4,1
libXdmcp: 1.1.2
libxcb: 1.12
libxml2: 2.9.4
libpthread-stubs: 0.3_6
libXau: 1.0.8_3
kbproto: 1.0.7
libXtst: 1.2.3
recordproto: 1.14.2
inputproto: 2.3.2
libXext: 1.3.3_1,1
xextproto: 7.3.0
libXi: 1.7.8,1
libXfixes: 5.0.3
fixesproto: 5.0
giflib: 5.1.4
java-zoneinfo: 2016.j
libXrender: 0.9.10
renderproto: 0.11.1
freetype2: 2.6.3
fontconfig: 2.12.1,1
expat: 2.2.0_1
alsa-lib: 1.1.2
dejavu: 2.37
mkfontdir: 1.0.7
mkfontscale: 1.1.2
libfontenc: 1.1.3
javavmwrapper: 2.5_2
tomcat7: 7.0.73
jakarta-commons-daemon: 1.0.15
Number of packages to be installed: 36
The process will require 260 MiB more space.
110 MiB to be downloaded.
Proceed with this action? [y/N]: y
[git] Fetching gitblit-1.8.0.txz: 100% 36 MiB 3.2MB/s 00:12
[git] Fetching openjdk8-8.112.16_2.txz: 6% 4 MiB 2.3MB/s 00:31 ETA
:
:
[git] [34/36] Installing jakarta-commons-daemon-1.0.15...
[git] [34/36] Extracting jakarta-commons-daemon-1.0.15: 100%
[git] [35/36] Installing tomcat7-7.0.73...
[git] [35/36] Extracting tomcat7-7.0.73: 100%
[git] [36/36] Installing gitblit-1.8.0...
===> Creating groups.
Using existing group 'www'.
===> Creating users
Using existing user 'www'.
[git] [36/36] Extracting gitblit-1.8.0: 100%
Message from dejavu-2.37:
Make sure that the freetype module is loaded. If it is not, add the following
line to the "Modules" section of your X Windows configuration file:
Load "freetype"
Add the following line to the "Files" section of X Windows configuration file:
FontPath "/usr/local/share/fonts/dejavu/"
Note: your X Windows configuration file is typically /etc/X11/XF86Config
if you are using XFree86, and /etc/X11/xorg.conf if you are using X.Org.
Message from openjdk8-8.112.16_2:
======================================================================
This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
procfs(5) mounted on /proc.
If you have not done it yet, please do the following:
mount -t fdescfs fdesc /dev/fd
mount -t procfs proc /proc
To make it permanent, you need the following lines in /etc/fstab:
fdesc /dev/fd fdescfs rw 0 0
proc /proc procfs rw 0 0
======================================================================
Message from gitblit-1.8.0:
************************************************************************
By default, Gitblit stores all data (users, settings,
repositories, etc) in ${contextFolder}/WEB-INF/data.
Specifying an alternate "baseFolder" allows for simple
upgrades in the future.
You can specify "baseFolder":
- via GITBLIT_HOME, or
- via web.xml, or
- via JNDI.
For value of "baseFolder" use value "/usr/local/gitblit".
You can login with the default administrator credentials:
admin / admin
!!!MAKE SURE TO CHANGE THE ADMINISTRATOR USERNAME AND/OR PASSWORD!!!
More informations:
http://gitblit.com/setup_war.html
************************************************************************
root@git:~ #
openJDKがインストールされていることからもわかりますように、gitblitはJava製です。そしてTomcat7がインストールされていることから、このFreeBSDのパッケージではサーブレットとして動作するもののようです。
/etc/rc.confに追記
指示は出てこなかったのですがTomcat7を動作させるために /etc/rc.conf へ追記します。
- /etc/rc.conf
tomcat7_enable="YES"
Tomcat7の tomcat-users.xml ファイルの編集
Tomcat7は /usr/local/apache-tomcat-7.0 にインストールされ、gitblitは /usr/local/apache-tomcat-7.0/webapps/gitblit にインストールされています。
Tomcat7のサーバーステータスアプリやAPPマネージャを使いたい場合には、ユーザ “tomcat” を利用可能にしておきます。
- /usr/local/apache-tomcat-7.0/conf/tomcat-users.xml
<role rolename="tomcat"/> <role rolename="manager-gui"/> <role rolename="role1"/> <user username="tomcat" password="パスワード" roles="tomcat,manager-gui"/> <!-- 以下のユーザは無効のまま <user username="both" password="<must-be-changed>" roles="tomcat,role1"/> <user username="role1" password="<must-be-changed>" roles="role1"/> -->
Tomcat7の起動
service コマンドでtomcat7を起動します。
root@git:~ # service tomcat7 start Starting tomcat7. root@git:~ #
ブラウザからアクセスしてみます。URLは http://host:8080/ です。
gitblitのWebUIにアクセスする
コンテキストルートが gitblit なので URLは http://host:8080/gitblit になります。
adminアカウントのパスワードがadminだと説明表示されていたので、とりあえずログインしてパスワードだけ変更しておきます。

もし更新に失敗するなら、ディレクトリの所有者を変えておきます。
root@git:/usr/local/apache-tomcat-7.0/webapps # ll total 28 drwxr-xr-x 3 www www 1024 Mar 4 19:42 ROOT/ drwxr-xr-x 14 www www 2048 Mar 4 19:42 docs/ drwxr-xr-x 7 www www 512 Mar 4 19:42 examples/ drwxr-xr-x 7 root www 4608 Mar 4 19:42 gitblit/ drwxr-xr-x 5 www www 512 Mar 4 19:42 host-manager/ drwxr-xr-x 5 www www 512 Mar 4 19:42 manager/ root@git:/usr/local/apache-tomcat-7.0/webapps # chown -R www:www gitblit root@git:/usr/local/apache-tomcat-7.0/webapps # ll total 28 drwxr-xr-x 3 www www 1024 Mar 4 19:42 ROOT/ drwxr-xr-x 14 www www 2048 Mar 4 19:42 docs/ drwxr-xr-x 7 www www 512 Mar 4 19:42 examples/ drwxr-xr-x 7 www www 4608 Mar 4 19:42 gitblit/ drwxr-xr-x 5 www www 512 Mar 4 19:42 host-manager/ drwxr-xr-x 5 www www 512 Mar 4 19:42 manager/ root@git:/usr/local/apache-tomcat-7.0/webapps #
リモートリポジトリを作成する
あとはメニューから操作すればいい。