Commits

Josh VanderLinden  committed 18a6de8

Making some headway I think

  • Participants
  • Parent commits 968dd83

Comments (0)

Files changed (3)

 # Maintainer: Josh VanderLinden <arch@cloudlery.com>
-pkgname=gitlab-git
-pkgver=20121121
+pkgname=gitlab
+pkgver=20121214
 pkgrel=1
 pkgdesc="Fast, secure and stable solution based on Rails & Gitolite."
 arch=('any')
 url="https://bitbucket.org/instarch/gitlab-git/"
 license=('MIT')
-depends=('ruby' 'mysql' 'git' 'gitolite' 'redis')
-makedepends=('git')
+depends=(
+  'ruby>=1.9.3'
+  'mysql'
+  'git'
+  'redis'
+  'nginx'
+  'ruby-unicorn'
+  'sudo'
+  'python-pygments'
+)
+makedepends=('rubygems' 'pkgtools' 'ruby-charlock_holmes' 'ruby-bundler')
 provides=('gitlab')
-source=()
-md5sums=() #generate with 'makepkg -g'
+install=gitlab.install
+
+source=(
+  "https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab"
+  "gitlab.install"
+)
+
+md5sums=('69f907465eb663072bc1e8911ae795d1'
+         '30b5e098bfb069446e913656315f1c47')
 
 _gitroot=https://github.com/gitlabhq/gitlabhq.git
-_gitname=gitlab
+_gitname=gitlab-repo
+
+_gitoliteroot=https://github.com/gitlabhq/gitolite.git
+_gitolitename=gitolite
 
 build() {
   cd "$srcdir"
-  msg "Connecting to GIT server...."
+  msg "Cloning GitLab...."
 
   if [[ -d "$_gitname" ]]; then
-    cd "$_gitname" && git pull origin
+    cd "$_gitname" && git pull origin stable
     msg "The local files are updated."
+    cd ..
   else
-    git clone "$_gitroot" "$_gitname"
+    git clone -b stable "$_gitroot" "$_gitname"
   fi
+  msg "GitLab checkout done or server timeout"
 
-  msg "GIT checkout done or server timeout"
-  msg "Starting build..."
+  msg "Cloning the GitLab fork of Gitolite..."
+  if [[ -d "$_gitolitename" ]]; then
+    cd "$_gitolitename" && git pull origin gl-v304
+    msg "The local files are updated."
+    cd ..
+  else
+    git clone -b gl-v304 "$_gitoliteroot" "$_gitolitename"
+  fi
+  msg "GitLab fork of Gitolite checkout done or server timeout"
 
-  rm -rf "$srcdir/$_gitname-build"
+  rm -rf "$srcdir/$_gitname-build" "$srcdir/$_gitolitename-build"
   git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
-  cd "$srcdir/$_gitname-build"
-
-  pwd
+  git clone "$srcdir/$_gitolitename" "$srcdir/$_gitolitename-build"
 }
 
 package() {
-  cd "$srcdir/$_gitname-build"
+  install -d "${pkgdir}/etc/nginx/sites-available"
+  install -d "${pkgdir}/etc/nginx/sites-enabled"
+  install -d "${pkgdir}/home/gitlab/gitlab"
+  install -d "${pkgdir}/home/git/bin"
+  install -d "${pkgdir}/home/git/gitolite"
+  install -d "${pkgdir}/home/git/repositories"
+  install -d "${pkgdir}/home/git/.gitolite/hooks/common"
+
+  install -D $_gitname/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+
+  msg "Copying files..."
+  cp -a $srcdir/$_gitname-build/* "$pkgdir/home/gitlab/gitlab/"
+  cp -a $srcdir/$_gitolitename-build/* "$pkgdir/home/git/gitolite/"
+
+  cd "${pkgdir}/home/gitlab"
+
+  msg "Copying configuration files..."
+  cp "${pkgdir}"/home/gitlab/gitlab/config/gitlab.yml{.example,}
+  cp "${pkgdir}"/home/gitlab/gitlab/config/database.yml{.mysql,}
+  cp "${pkgdir}"/home/gitlab/gitlab/config/unicorn.rb{.example,}
 
-  install -D LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+  install -D "${pkgdir}/home/gitlab/gitlab/lib/hooks/post-receive" "${pkgdir}/home/git/.gitolite/hooks/common/post-receive"
+  install -D "$srcdir/gitlab" "${pkgdir}/etc/nginx/sites-available/"
+  ln -s /etc/nginx/sites-available/gitlab "${pkgdir}/etc/nginx/sites-enabled/gitlab"
 }
 
 # vim:set ts=2 sw=2 et:

File charlock_holmes/PKGBUILD

+# Maintainer: Josh VanderLinden <arch@cloudlery.com>
+pkgname=ruby-charlock_holmes
+_gemname=${pkgname#ruby-}
+pkgver=0.6.9
+pkgrel=1
+pkgdesc="Character encoding detection, brought to you by ICU"
+arch=('any')
+url="http://github.com/brianmario/charlock_holmes"
+license=('MIT')
+depends=('ruby' 'rubygems')
+source=(http://rubygems.org/downloads/${_gemname}-${pkgver}.gem)
+noextract=(${_gemname}-${pkgver}.gem)
+md5sums=('d79060416f9efca1feb9d831662d048b')
+
+build() {
+  cd "${srcdir}"
+  export HOME=/tmp
+  local _gemdir="$(ruby -rubygems -e'puts Gem.default_dir')"
+  gem install --no-user-install --ignore-dependencies -i "${pkgdir}${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
+}

File gitlab.install

+pre_install() {
+  useradd -r -s /bin/sh -c 'git version control' -U -m git
+  useradd -s /bin/false -c 'gitlab system' -U -m gitlab
+  usermod -a -G git gitlab
+  usermod -a -G gitlab git
+
+  passwd -d git
+  passwd -d gitlab
+}
+
+post_install() {
+  chown -R git:git /home/git
+
+  cd /home/git
+  sudo -u git sh -c 'echo -e "export PATH=\$PATH:/home/git/bin" >> /home/git/.profile'
+  sudo -u git sh -c 'gitolite/install -ln /home/git/bin'
+  cd -
+
+  sudo -H -u gitlab ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
+  install -D /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
+  chmod 0444 /home/git/gitlab.pub
+  su - git -c 'sh "PATH=/home/git/bin:\$PATH gitolite setup -pk /home/git/gitlab.pub"'
+
+  chmod -R g+rwX /home/git/repositories/
+  chown -R git:git /home/git/repositories/
+
+  # clone admin repo to add localhost to known_hosts
+  # & be sure your user has access to gitolite
+  sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
+  [ $? -ne 0 ] && exit 1
+
+  # if succeed  you can remove it
+  sudo rm -rf /tmp/gitolite-admin
+
+  cd /home/gitlab/gitlab
+
+  sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment
+  sudo -u gitlab -H git config --global user.email "gitlab@localhost"
+  sudo -u gitlab -H git config --global user.name "Gitlab"
+
+  sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
+
+  chown git:git /home/git/.gitolite/hooks/common/post-receive
+
+  echo <<EOT
+>>> Now run the following commands in MySQL:
+
+    CREATE DATABASE IF NOT EXISTS \`gitlabhq_production\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;
+    CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'Your Secret Password';
+    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \`gitlabhq_production\`.* TO 'gitlab'@'localhost';
+
+>>> When you've done that, run the following commands as user gitlab
+
+    bundle exec rake gitlab:app:setup RAILS_ENV=production
+    bundle exec rake gitlab:app:status RAILS_ENV=production
+
+>>> After doing that, you'll probably want to (re)start Nginx and visit your new Gitlab instance. You may login as:
+
+    admin@local.host
+    5iveL!fe
+EOT
+
+}
+
+post_upgrade() {
+  chmod -R g+rwX /home/git/repositories/
+  chown -R git:git /home/git/repositories/
+}
+
+post_remove() {
+  userdel git
+  userdel gitlab
+  groupdel git
+  groupdel gitlab
+}
+
+# vim:set ts=2 sw=2 et: