commit 763da991e7aa3655ce1beccbee05fea9ac954b70 Author: Achilleas Pipinellis Date: Thu Nov 21 13:06:42 2013 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..175143d41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.gem +.bundle +vendor/bundle +pkg/* +.vagrant +bin/* +files/**/cache/ +vendor/cookbooks diff --git a/Berksfile b/Berksfile new file mode 100644 index 000000000..d91b9f953 --- /dev/null +++ b/Berksfile @@ -0,0 +1,3 @@ +site :opscode + +cookbook "omnibus" diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..948d96d6c --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem 'omnibus', '~> 1.2.0' +gem 'omnibus-software', :git => 'git://github.com/opscode/omnibus-software.git', :branch => 'master' diff --git a/README.md b/README.md new file mode 100644 index 000000000..3ebf540cb --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +# gitlab Omnibus project + +This project creates full-stack platform-specific packages for +`gitlab`! + +## Installation + +We'll assume you have Ruby 1.9+ and Bundler installed. First ensure all +required gems are installed and ready to use: + +```shell +$ bundle install --binstubs +``` + +## Usage + +### Build + +You create a platform-specific package using the `build project` command: + +```shell +$ bin/omnibus build project gitlab +``` + +The platform/architecture type of the package created will match the platform +where the `build project` command is invoked. So running this command on say a +MacBook Pro will generate a Mac OS X specific package. After the build +completes packages will be available in `pkg/`. + +### Clean + +You can clean up all temporary files generated during the build process with +the `clean` command: + +```shell +$ bin/omnibus clean +``` + +Adding the `--purge` purge option removes __ALL__ files generated during the +build including the project install directory (`/opt/gitlab`) and +the package cache directory (`/var/cache/omnibus/pkg`): + +```shell +$ bin/omnibus clean --purge +``` + +### Help + +Full help for the Omnibus command line interface can be accessed with the +`help` command: + +```shell +$ bin/omnibus help +``` + +## Vagrant-based Virtualized Build Lab + +Every Omnibus project ships will a project-specific +[Berksfile](http://berkshelf.com/) and [Vagrantfile](http://www.vagrantup.com/) +that will allow you to build your projects on the following platforms: + +* CentOS 5 64-bit +* CentOS 6 64-bit +* Ubuntu 10.04 64-bit +* Ubuntu 11.04 64-bit +* Ubuntu 12.04 64-bit + +Please note this build-lab is only meant to get you up and running quickly; +there's nothing inherent in Omnibus that restricts you to just building CentOS +or Ubuntu packages. See the Vagrantfile to add new platforms to your build lab. + +The only requirements for standing up this virtualized build lab are: + +* VirtualBox - native packages exist for most platforms and can be downloaded +from the [VirtualBox downloads page](https://www.virtualbox.org/wiki/Downloads). +* Vagrant 1.2.1+ - native packages exist for most platforms and can be downloaded +from the [Vagrant downloads page](http://downloads.vagrantup.com/). + +The [vagrant-berkshelf](https://github.com/RiotGames/vagrant-berkshelf) and +[vagrant-omnibus](https://github.com/schisamo/vagrant-omnibus) Vagrant plugins +are also required and can be installed easily with the following commands: + +```shell +$ vagrant plugin install vagrant-berkshelf +$ vagrant plugin install vagrant-omnibus +``` + +Once the pre-requisites are installed you can build your package across all +platforms with the following command: + +```shell +$ vagrant up +``` + +If you would like to build a package for a single platform the command looks like this: + +```shell +$ vagrant up PLATFORM +``` + +The complete list of valid platform names can be viewed with the +`vagrant status` command. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..084308f41 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,95 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +require "vagrant" + +if Vagrant::VERSION < "1.2.1" + raise "The Omnibus Build Lab is only compatible with Vagrant 1.2.1+" +end + +host_project_path = File.expand_path("..", __FILE__) +guest_project_path = "/home/vagrant/#{File.basename(host_project_path)}" +project_name = "gitlab" + +Vagrant.configure("2") do |config| + + config.vm.hostname = "#{project_name}-omnibus-build-lab" + + config.vm.define 'ubuntu-10.04' do |c| + c.berkshelf.berksfile_path = "./Berksfile" + c.vm.box = "opscode-ubuntu-10.04" + c.vm.box_url = "http://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_chef-11.2.0.box" + end + + config.vm.define 'ubuntu-11.04' do |c| + c.berkshelf.berksfile_path = "./Berksfile" + c.vm.box = "opscode-ubuntu-11.04" + c.vm.box_url = "http://opscode-vm.s3.amazonaws.com/vagrant/boxes/opscode-ubuntu-11.04.box" + end + + config.vm.define 'ubuntu-12.04' do |c| + c.berkshelf.berksfile_path = "./Berksfile" + c.vm.box = "canonical-ubuntu-12.04" + c.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box" + end + + config.vm.define 'centos-5' do |c| + c.berkshelf.berksfile_path = "./Berksfile" + c.vm.box = "opscode-centos-5.8" + c.vm.box_url = "http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.8_chef-11.2.0.box" + end + + config.vm.define 'centos-6' do |c| + c.berkshelf.berksfile_path = "./Berksfile" + c.vm.box = "opscode-centos-6.3" + c.vm.box_url = "http://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.3_chef-11.2.0.box" + end + + config.vm.provider :virtualbox do |vb| + # Give enough horsepower to build without taking all day. + vb.customize [ + "modifyvm", :id, + "--memory", "1536", + "--cpus", "2" + ] + end + + # Ensure a recent version of the Chef Omnibus packages are installed + config.omnibus.chef_version = :latest + + # Enable the berkshelf-vagrant plugin + config.berkshelf.enabled = true + # The path to the Berksfile to use with Vagrant Berkshelf + config.berkshelf.berksfile_path = "./Berksfile" + + config.ssh.max_tries = 40 + config.ssh.timeout = 120 + config.ssh.forward_agent = true + + host_project_path = File.expand_path("..", __FILE__) + guest_project_path = "/home/vagrant/#{File.basename(host_project_path)}" + + config.vm.synced_folder host_project_path, guest_project_path + + # prepare VM to be an Omnibus builder + config.vm.provision :chef_solo do |chef| + chef.json = { + "omnibus" => { + "build_user" => "vagrant", + "build_dir" => guest_project_path, + "install_dir" => "/opt/#{project_name}" + } + } + + chef.run_list = [ + "recipe[omnibus::default]" + ] + end + + config.vm.provision :shell, :inline => <<-OMNIBUS_BUILD + export PATH=/usr/local/bin:$PATH + cd #{guest_project_path} + su vagrant -c "bundle install --binstubs" + su vagrant -c "bin/omnibus build project #{project_name}" + OMNIBUS_BUILD +end diff --git a/config/projects/gitlab.rb b/config/projects/gitlab.rb new file mode 100644 index 000000000..c311b1c1a --- /dev/null +++ b/config/projects/gitlab.rb @@ -0,0 +1,21 @@ + +name "gitlab" +maintainer "CHANGE ME" +homepage "CHANGEME.com" + +replaces "gitlab" +install_path "/opt/gitlab" +build_version Omnibus::BuildVersion.new.semver +build_iteration 1 + +# creates required build directories +dependency "preparation" + +# gitlab dependencies/components +# dependency "somedep" + +# version manifest file +dependency "version-manifest" + +exclude "\.git*" +exclude "bundler\/git" diff --git a/config/software/c-example.rb b/config/software/c-example.rb new file mode 100644 index 000000000..0a140dac1 --- /dev/null +++ b/config/software/c-example.rb @@ -0,0 +1,42 @@ +# This is an example software definition for a C project. +# +# Lots of software definitions for popular open source software +# already exist in `opscode-omnibus`: +# +# https://github.com/opscode/omnibus-software/tree/master/config/software +# +name "c-example" +version "1.0.0" + +dependency "zlib" +dependency "openssl" + +source :url => "http://itchy.neckbeard.se/download/c-example-1.0.0.tar.gz", + :md5 => "8e23151f569fb54afef093ac0695077d" + +relative_path 'c-example-1.0.0' + +env = { + "LDFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include", + "CFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include", + "LD_RUN_PATH" => "#{install_dir}/embedded/lib" +} + +build do + command ["./configure", + "--prefix=#{install_dir}/embedded", + "--disable-debug", + "--enable-optimize", + "--disable-ldap", + "--disable-ldaps", + "--disable-rtsp", + "--enable-proxy", + "--disable-dependency-tracking", + "--enable-ipv6", + "--without-libidn", + "--with-ssl=#{install_dir}/embedded", + "--with-zlib=#{install_dir}/embedded"].join(" "), :env => env + + command "make -j #{max_build_jobs}", :env => env + command "make install" +end diff --git a/config/software/erlang-example.rb b/config/software/erlang-example.rb new file mode 100644 index 000000000..8916b92b7 --- /dev/null +++ b/config/software/erlang-example.rb @@ -0,0 +1,38 @@ +# This is an example software definition for an Erlang project. +# +# Lots of software definitions for popular open source software +# already exist in `opscode-omnibus`: +# +# https://github.com/opscode/omnibus-software/tree/master/config/software +# +name "erlang-example" +version "1.0.0" + +dependency "erlang" +dependency "rebar" +dependency "rsync" + +source :git => "git://github.com/example/erlang.git" + +relative_path "erlang-example" + +env = { + "PATH" => "#{install_dir}/embedded/bin:#{ENV["PATH"]}", + "LDFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include", + "CFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include", + "LD_RUN_PATH" => "#{install_dir}/embedded/lib" +} + +build do + command "make distclean", :env => env + command "make rel", :env => env + command "mkdir -p #{install_dir}/embedded/service/example-erlang" + command ["#{install_dir}/embedded/bin/rsync", + "-a", + "--delete", + "--exclude=.git/***", + "--exclude=.gitignore", + "./rel/erlang-example/", + "#{install_dir}/embedded/service/erlang-example/"].join(" ") + command "rm -rf #{install_dir}/embedded/service/erlang-example/log" +end diff --git a/config/software/ruby-example.rb b/config/software/ruby-example.rb new file mode 100644 index 000000000..31bc0db09 --- /dev/null +++ b/config/software/ruby-example.rb @@ -0,0 +1,24 @@ +# This is an example software definition for a Ruby project. +# +# Lots of software definitions for popular open source software +# already exist in `opscode-omnibus`: +# +# https://github.com/opscode/omnibus-software/tree/master/config/software +# +name "ruby-example" +version "1.0.0" + +dependency "ruby" +dependency "rubygems" +dependency "bundler" +dependency "rsync" + +source :git => "git://github.com/example/ruby.git" + +relative_path "ruby-example" + +build do + bundle "install --path=#{install_dir}/embedded/service/gem" + command "mkdir -p #{install_dir}/embedded/service/ruby-example" + command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/ruby-example/" +end diff --git a/omnibus.rb.example b/omnibus.rb.example new file mode 100644 index 000000000..e600558f4 --- /dev/null +++ b/omnibus.rb.example @@ -0,0 +1,5 @@ +# s3_access_key "something" +# s3_secret_key "something" +# s3_bucket "some-bucket" +# use_s3_caching true +# solaris_compiler "gcc" diff --git a/package-scripts/gitlab/makeselfinst b/package-scripts/gitlab/makeselfinst new file mode 100755 index 000000000..0fbd25349 --- /dev/null +++ b/package-scripts/gitlab/makeselfinst @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Install a full gitlab +# + +PROGNAME=`basename $0` +INSTALLER_DIR=`dirname $0` +DEST_DIR=/opt/gitlab +CONFIG_DIR=/etc/gitlab +USAGE="usage: $0" + +error_exit() +{ + echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 + exit 1 +} + +# move the actual files into place +rm -rf $DEST_DIR/* || error_exit "Cannot remove contents of $DEST_DIR" +mkdir -p $DEST_DIR || error_exit "Cannot create $DEST_DIR" +cp -R $INSTALLER_DIR $DEST_DIR || error_exit "Cannot install to $DEST_DIR" +rm -f $DEST_DIR/$PROGNAME + +# You may want to symlink your packages bin files into /usr/bin +# ln -sf $DEST_DIR/bin/gitlab /usr/bin || error_exit "Cannot link gitlab to /usr/bin" + +exit 0 diff --git a/package-scripts/gitlab/postinst b/package-scripts/gitlab/postinst new file mode 100755 index 000000000..b7db9fd2b --- /dev/null +++ b/package-scripts/gitlab/postinst @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Perform necessary gitlab setup steps +# after package is installed. +# + +PROGNAME=$(basename $0) + +function error_exit +{ + echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 + exit 1 +} + +echo "Thank you for installing gitlab!" + +exit 0 diff --git a/package-scripts/gitlab/postrm b/package-scripts/gitlab/postrm new file mode 100755 index 000000000..f5a4af996 --- /dev/null +++ b/package-scripts/gitlab/postrm @@ -0,0 +1,9 @@ +#!/bin/bash +# +# Perform necessary gitlab removal steps +# after package is uninstalled. +# + +echo "gitlab has been uninstalled!" + +exit 0