LoginSignup
1
1

More than 5 years have passed since last update.

ソースからOmnibus Gitlabのrpm/debパッケージを生成する

Last updated at Posted at 2016-06-15

この記事は

omnibus-gitlabのパッケージをソースから生成する手順です。

背景

  • omnibus-gitlabをつかうとOSのパッケージマネージャからGitlabをオールインワンで簡単にインストールできます。
  • ただ、本気でomnibus-gitlabを使ってインストールしたサーバを保守していくとなった場合に、個別にミドルウェアのバージョンを上げるなどの選択肢がとれるのかどうかが気になります。
    • omnibus-gitlabは単一のrpm/debパッケージをインストールするとPostgresやらRedisやらRailsやらもろもろ含めて全部/optの下にインストールします。
    • Gitlabのパッケージをアップデートして対応する想定ということなのですが、数年にわたり本当に迅速にメンテし続けてくれるのかは誰にもわかりません。
  • そこでomnibus-gitlabそのものはソースが公開されていますので、自力でパッケージを生成してみることにしました。

手順

ビルド環境の準備

  • まず生成するパッケージを動かすOSに合わせてビルド環境を準備します。
  • 下記の手順でchefを使ってビルドに必要なライブラリ類をセットアップします。
bash
set -e
set -u
curl -L https://www.chef.io/chef/install.sh | sudo bash
chef_root=/tmp/gitlab-omnibus-builder.$$
mkdir "$chef_root"
cd "$chef_root"
mkdir cookbooks
git clone https://gitlab.com/gitlab-org/gitlab-omnibus-builder.git cookbooks/gitlab-omnibus-builder
git clone https://gitlab.com/gitlab-org/gitlab-attributes-with-secrets.git cookbooks/gitlab-attributes-with-secrets
/opt/chef/bin/chef-client -z -r 'recipe[gitlab-omnibus-builder::default]'
  • 成功
Running handlers:
Running handlers complete
Chef Client finished, 29/39 resources updated in 08 minutes 59 seconds

ビルドの実施

  • 下記手順でパッケージを生成します。
    • が、そのままではエラーが発生します。(後述)
  • 基本的にすべてコンパイルからなので、生成までに数時間かかります。
bash
sudo locale-gen en_US.UTF-8
sudo su - gitlab_ci_multi_runner
git config --global user.email "email@example.com"
git config --global user.name "Example name"
export LC_ALL=en_US.UTF-8
git clone https://gitlab.com/gitlab-org/omnibus-gitlab.git
cd omnibus-gitlab
bundle install --path .bundle --binstubs
bin/omnibus build gitlab
  • 成功
[Packager::DEB] I | Creating .deb file
                       [Compressor] I | No compressor defined for `debian'.
               [Project: gitlab-ce] I | Building version manifest
$ ls pkg/
gitlab-ce_8.1.0+20160615025454.git.890.b9131bf-rc1.ce.0_amd64.deb
version-manifest.json
gitlab-ce_8.1.0+20160615025454.git.890.b9131bf-rc1.ce.0_amd64.deb.metadata.json
  • pkgディレクトリにdebパッケージが生成されています。

メモ

修正パッチ

  • 上記はすんなり生成できたかのように書いていますが、実際にはビルド時にエラーが発生しました。
    • エラー内容を確認すると、git ls-remote "git@dev.gitlab.org:gitlab/gitlabhq.git" master*の実行に失敗していました。
    • このdev.gitlab.orgというサーバをブラウザで開いてみると、どうもgitlabの中の人たち向けのリポジトリのようで、アクセス自体が不可能でした
    • ここになんかアジャストしろとかなんとか書いてあります。
  • そこで、下記の修正をいれて、dev.gitlab.orgではなくgitlab.org及びgithub.com上に公開されているリポジトリを指すようにしたところ、無事ビルドできるようになりました。
diff --git a/lib/gitlab/version.rb b/lib/gitlab/version.rb
index 3e095a9..33a9db2 100644
--- a/lib/gitlab/version.rb
+++ b/lib/gitlab/version.rb
@@ -28,14 +28,14 @@ module Gitlab
         if @read_version.include?('-ee')
           "git@dev.gitlab.org:gitlab/gitlab-ee.git"
         else
-          "git@dev.gitlab.org:gitlab/gitlabhq.git"
+          "https://github.com/gitlabhq/gitlabhq.git"
         end
       when "GITLAB_SHELL_VERSION"
-        "git@dev.gitlab.org:gitlab/gitlab-shell.git"
+        "https://github.com/gitlabhq/gitlab-shell.git"
       when "GITLAB_WORKHORSE_VERSION"
-        "git@dev.gitlab.org:gitlab/gitlab-workhorse.git"
+        "https://gitlab.com/gitlab-org/gitlab-workhorse.git"
       when "GITLAB_PAGES_VERSION"
-        "https://gitlab.com/gitlab-org/gitlab-pages.git"
+        "https://github.com/gitlabhq/gitlab-pages.git"
       else
         nil
       end
diff --git a/support/set-revisions b/support/set-revisions
index e9b5bf4..044e670 100755
--- a/support/set-revisions
+++ b/support/set-revisions
@@ -8,10 +8,10 @@ main() {
   if [[ "$gitlab_rails_ref" == *"-ee"* ]] ; then
     gitlab_rails_repo=git@dev.gitlab.org:gitlab/gitlab-ee.git
   else
-    gitlab_rails_repo=git@dev.gitlab.org:gitlab/gitlabhq.git
+    gitlab_rails_repo=https://github.com/gitlabhq/gitlabhq.git
   fi
-  gitlab_shell_repo=git@dev.gitlab.org:gitlab/gitlab-shell.git
-  gitlab_workhorse_repo=git@dev.gitlab.org:gitlab/gitlab-workhorse.git
+  gitlab_shell_repo=https://github.com/gitlabhq/gitlab-shell.git
+  gitlab_workhorse_repo=https://gitlab.com/gitlab-org/gitlab-workhorse.git

   gitlab_rails_ref_id=$(check_remote_ref gitlab_rails)
   assert_non_empty gitlab_rails_ref_id

ビルドするGitlabバージョンの指定

  • 上記ではomnibus-gitlabのmasterブランチのままでビルドを開始しています
  • バージョン名のブランチがあるのでそこにcheckoutした後にビルドするとそのバージョンのパッケージが生成されます
  • バージョン自体はルート直下のVERSIONとかGITLAB_SHELL_VERSIONとかのファイルに書いてあるので、そこを変えれば任意のバージョンを指定できます

ビルドする各種ミドルウェアバージョンの変更

  • ミドルウェアはomnibus-gitlabのconfig/projects/gitlab.rbに書かれているので、バージョン指定をカスタム化したい場合は、このへんを修正して明示します。

おわりに

これでオレオレgitlabパッケージが作り放題ですね!

https://gitlab.com/gitlab-org/gitlab-omnibus-builder/blob/master/README.md#recipe-default
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/build/README.md#usage

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1