Last active
December 25, 2015 20:49
-
-
Save benwtr/7037915 to your computer and use it in GitHub Desktop.
Vagrantfile that fpm's up some ruby and svn debs that I needed. Optionally puts them in a apt repo on s3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Abuse of vagrant to build some debs. optionally also uploads to an apt repo on s3. | |
# | |
# Tested with: | |
# squeeze64 https://dl.dropboxusercontent.com/u/13054557/vagrant_boxes/debian-squeeze.box | |
# squeeze32 http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box | |
# Debian-7.1.0-64 (built with veewee, not shared on a public url. this is also the default) | |
# | |
# Usage: | |
# # vagrant box add squeeze32 http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box | |
# # mkdir /tmp/build_debs ; cd !$ ; cp /path/to/this/Vagrantfile . | |
# # VAGRANT_BOX=squeeze32 vagrant up | |
# | |
# Environment variables: | |
# VAGRANT_BOX - The box to use, defaults to Debian-7.1.0-64. It must be installed in vagrant | |
# S3_UPLOAD - Enable deb repo on s3 feature (uses deb-s3 rubygem) | |
# AMAZON_ACCESS_KEY_ID - For s3 upload | |
# AMAZON_SECRET_ACCESS_KEY - For s3 upload | |
# S3_BUCKET - For s3 upload | |
# | |
vagrant_box = ENV['VAGRANT_BOX'] || 'Debian-7.1.0-64' | |
script = <<"SCRIPT" | |
#!/bin/bash | |
SCRIPT | |
if ENV['S3_UPLOAD'] | |
if ( ENV['AMAZON_ACCESS_KEY_ID'].nil? || ENV['AMAZON_SECRET_ACCESS_KEY'].nil? || ENV['S3_BUCKET'].nil? ) | |
puts 'Must set AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY and S3_BUCKET environmnet variables if S3_UPLOAD set' | |
exit 1 | |
end | |
script += <<"SCRIPT" | |
export AMAZON_ACCESS_KEY_ID=#{ENV['AMAZON_ACCESS_KEY_ID']} | |
export AMAZON_SECRET_ACCESS_KEY=#{ENV['AMAZON_SECRET_ACCESS_KEY']} | |
export S3_BUCKET=#{ENV['S3_BUCKET']} | |
export S3_UPLOAD=1 | |
SCRIPT | |
end | |
script += <<'SCRIPT'; | |
sudo apt-get update | |
sudo apt-get install -y lsb-release | |
sudo gem install fpm --no-ri --no-rdoc | |
# ruby patch version | |
rev=448 | |
# subversion version | |
svn_ver='1.8.3' | |
os_codename=`lsb_release -cs` | |
arch=`dpkg --print-architecture` | |
# Install ruby | |
sudo apt-get install -y autoconf build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev libffi-dev libgdbm-dev git | |
mkdir -p /tmp/build_ruby-1.9.3-p$rev | |
cd /tmp/build_ruby-1.9.3-p$rev | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p$rev.tar.bz2 | |
tar -xjf ruby-1.9.3-p$rev.tar.bz2 | |
git clone https://github.com/skaes/rvm-patchsets.git | |
export CFLAGS="-O3 -march=native" | |
cd ruby-1.9.3-p$rev | |
for i in ../rvm-patchsets/patches/ruby/1.9.3/p$rev/railsexpress/* ; do cat $i| patch -p1 ; done | |
autoconf | |
./configure --prefix=/usr --with-ruby-version=1.9.3-p$rev --enable-shared && make && make install DESTDIR=/tmp/ruby1.9.3-p$rev | |
cd /tmp/ruby1.9.3-p$rev/usr/bin | |
mv ruby ruby-1.9.3-p$rev | |
( cat <<END | |
#!/bin/sh | |
export RUBY_HEAP_MIN_SLOTS=1000000 | |
export RUBY_HEAP_SLOTS_INCREMENT=1000000 | |
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | |
export RUBY_GC_MALLOC_LIMIT=100000000 | |
export RUBY_HEAP_FREE_MIN=500000 | |
#export LD_PRELOAD=/usr/lib64/libtcmalloc_minimal.so.0.0.0 | |
exec "/usr/bin/ruby-1.9.3-p$rev" "\$@" | |
END | |
) > ruby_wrapper_script | |
chmod +x ruby_wrapper_script | |
ln -s ruby_wrapper_script ruby | |
cd /tmp/build_ruby-1.9.3-p$rev | |
if [ "$os_codename" == "squeeze" ]; then libssl_dep='libssl0.9.8'; else libssl_dep='libssl1.0.0'; fi | |
OLD_PATH=$PATH | |
export PATH=/var/lib/gems/1.8/bin:$PATH # necessary in some vagrant boxes | |
fpm -s dir -t deb --name ruby_custom --version 1.9.3p${rev} --iteration 1 --description "Ruby 1.9.3-p$rev" --deb-user=root --deb-group=root -C /tmp/ruby1.9.3-p$rev -p ruby_custom-1.9.3-p${rev}_${arch}_${os_codename}.deb --provides ruby --conflicts ruby --replaces ruby --provides libruby --conflicts libruby --replaces libruby --provides ri --conflicts ri --replaces ri --provides irb --conflicts irb --replaces irb -d "libstdc++6 (>= 4.4.3)" -d "libc6 (>= 2.6)" -d "libffi5 (>= 3.0.4)" -d "libgdbm3 (>= 1.8.3)" -d "libncurses5 (>= 5.7)" -d "libreadline6 (>= 6.1)" -d "$libssl_dep" -d "zlib1g (>= 1:1.2.2)" -d "libyaml-0-2 (>= 0.1.3)" usr/bin usr/lib usr/share/man usr/include | |
mv ruby_custom-1.9.3-p${rev}_${arch}_${os_codename}.deb /vagrant/ | |
export PATH=$OLD_PATH | |
# kill old ruby stuff on system | |
sudo apt-get remove -y '.*ruby.*' | |
# Install new ruby | |
sudo dpkg -i /vagrant/ruby_custom-1.9.3-p${rev}_${arch}_${os_codename}.deb | |
# hold package version | |
echo 'ruby hold' | sudo dpkg --set-selections | |
echo 'ruby_custom hold' | sudo dpkg --set-selections | |
sudo gem install --no-ri --no-rdoc bundler rake fpm | |
# Subversion | |
# remove svn from system | |
sudo apt-get remove -y '.*svn.*' | |
sudo apt-get remove -y '.*subversion.*' | |
mkdir -p /tmp/build_subversion-${svn_ver} | |
cd /tmp/build_subversion-${svn_ver} | |
wget http://apache.mirror.vexxhost.com/subversion/subversion-${svn_ver}.tar.gz | |
tar xvzpf subversion-${svn_ver}.tar.gz | |
cd subversion-${svn_ver} | |
sudo apt-get install -y build-essential libaprutil1-dev libapr1-dev zlib1g-dev apache2-threaded-dev libsqlite3-dev swig apache2-utils libaprutil1-dbd-sqlite3 libdb4.8-dev libneon27-gnutls-dev libsasl2-dev | |
# sqlite 3.7.15.1 amalgamation | |
if [ "$os_codename" == "squeeze" ] | |
then | |
sudo apt-get install -y unzip | |
wget http://www.sqlite.org/sqlite-amalgamation-3071501.zip | |
unzip sqlite-amalgamation-3071501.zip | |
mv sqlite-amalgamation-3071501 sqlite-amalgamation | |
else | |
extra_configure_flags='--with-sqlite=/usr' | |
fi | |
./configure --prefix=/usr --with-apxs=/usr/bin/apxs2 --disable-mod-activation --with-apache-libexecdir=/usr/lib/apache2/modules --with-ruby-sitedir=/usr/lib/ruby --enable-shared $extra_configure_flags | |
make | |
make apache-mod | |
make install DESTDIR=/tmp/subversion-${svn_ver} | |
make swig-rb EXTRA_SWIG_LDFLAGS='-L/usr/lib -fPIC' | |
make install-swig-rb DESTDIR=/tmp/subversion-${svn_ver} | |
mkdir -p /tmp/subversion-$svn_ver/etc/apache2/mods-available | |
echo 'LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so' > /tmp/subversion-${svn_ver}/etc/apache2/mods-available/dav_svn.load | |
fpm -s dir -t deb --name subversion_custom --version=$svn_ver --iteration=1 --description 'Subversion' --package subversion_custom-${svn_ver}_${arch}_${os_codename}.deb --deb-user=root --deb-group=root -C /tmp/subversion-$svn_ver --provides subversion --conflicts subversion --replaces subversion --provides libsvn1 --conflicts libsvn1 --replaces libsvn1 --provides libapache2-svn --conflicts libapache2-svn --replaces libapache2-svn --conflicts libsvn-ruby --provides libsvn-ruby --replaces libsvn-ruby -d 'libapr1' -d 'libaprutil1' -d 'libc6 (>= 2.3)' -d 'libsasl2-2' -d 'libsqlite3-0' -d 'zlib1g' -d "ruby_custom (>= 1.9.3p${rev})" usr/share usr/bin usr/lib usr/include etc/apache2/mods-available | |
mv subversion_custom-${svn_ver}_${arch}_${os_codename}.deb /vagrant/ | |
cd /vagrant | |
if [ $S3_UPLOAD ]; then | |
sudo gem install --no-ri --no-rdoc deb-s3 | |
deb-s3 upload --bucket $S3_BUCKET --codename=$os_codename --arch=$arch --component=main subversion_custom-${svn_ver}_${arch}_${os_codename}.deb ruby_custom-1.9.3-p${rev}_${arch}_${os_codename}.deb | |
fi | |
SCRIPT | |
Vagrant.configure("2") do |config| | |
config.vm.box = vagrant_box | |
config.vm.provision 'shell', inline: script | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
probably should have used omnibus