Created
September 19, 2014 13:59
-
-
Save jfklingler/5bcc672d41555844dda3 to your computer and use it in GitHub Desktop.
Build RPM with Maven on Windows, OS X, etc. using Vagrant
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
# This quick and dirty vagrant set up will let you build RPMs on systems | |
# that don't (or don't easily) support building RPMs. Just place this | |
# Vagrantfile in your project root, or pull the "rpm-build" VM definition | |
# into your existing Vagrantfile if you're already using vagrant. | |
# | |
# The first 'vagrant up rpm-build' will set up the VM and build the RPMs | |
# Subsequent 'vagrant provision rpm-build' will rebuild the RPMs | |
# You can 'vagrant ssh rpm-build', go to the appropriate target/ for | |
# your project under /vagrant, and inspect your RPM with | |
# 'rpm -qlp --scripts <rpm file name>'. | |
# | |
# Assuming: | |
# rpm-maven-plugin is already configured for your build | |
# VirtualBox (or VMWare, etc.) is installed | |
# Vagrant is installed | |
Vagrant.configure("2") do |config| | |
# | |
# VM for building RPM packages on OS X, Windows, etc. | |
# | |
config.vm.define "rpm-build", autostart: false do |rpm| | |
$mvn_rpm = <<SCRIPT | |
# Only install things the first time up | |
if [ ! -d /root/.m2 ]; then | |
echo "Installing system dependencies..." | |
yum install -y rpm-build java-1.7.0-openjdk-devel | |
echo "Installing maven..." | |
wget http://mirrors.sonic.net/apache/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz -nv | |
gunzip apache-maven-3.2.3-bin.tar.gz | |
tar -xf apache-maven-3.2.3-bin.tar | |
echo "Setting up bash profile..." | |
cat << EOT >> /root/.bash_profile | |
M2_HOME="/home/vagrant/apache-maven-3.2.3" | |
export M2_HOME | |
PATH=$PATH:/home/vagrant/apache-maven-3.2.3/bin | |
export PATH | |
EOT | |
. /root/.bash_profile | |
fi | |
# Build the RPMs | |
echo "Building RPMs..." | |
cd /vagrant | |
mvn clean package -DskipTests | |
SCRIPT | |
# Really and RHEL, CentOS, Fedora, etc. base box will do - I just happened to have this one cached locally | |
rpm.vm.box = "puppetlabs/centos-6.5-64-puppet" | |
rpm.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box" | |
rpm.vm.provision "shell", inline: $mvn_rpm | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment