Commit 79476eca by Calen Pennington

Add a post-install script that points the link to the correct revision

parent e5dba8c9
require 'rake/clean' require 'rake/clean'
require 'tempfile' require 'tempfile'
# Build Constants
REPO_ROOT = File.dirname(__FILE__) REPO_ROOT = File.dirname(__FILE__)
BUILD_DIR = File.join(REPO_ROOT, "build") BUILD_DIR = File.join(REPO_ROOT, "build")
# Packaging constants
DEPLOY_DIR = "/opt/wwc"
PACKAGE_NAME = "mitx"
LINK_PATH = File.join(DEPLOY_DIR, PACKAGE_NAME)
VERSION = "0.1"
# Set up the clean and clobber tasks
CLOBBER.include('build') CLOBBER.include('build')
CLEAN.include("#{BUILD_DIR}/*.deb") CLEAN.include("#{BUILD_DIR}/*.deb", "#{BUILD_DIR}/util")
task :package do task :package do
commit = (ENV["GIT_COMMIT"] || `git rev-parse HEAD`).chomp() commit = (ENV["GIT_COMMIT"] || `git rev-parse HEAD`).chomp()
...@@ -13,20 +22,37 @@ task :package do ...@@ -13,20 +22,37 @@ task :package do
build_number = (ENV["BUILD_NUMBER"] || "dev").chomp() build_number = (ENV["BUILD_NUMBER"] || "dev").chomp()
if branch == "master" if branch == "master"
package_name = "mitx" deploy_name = "#{PACKAGE_NAME}-#{commit}"
else else
package_name = "mitx-#{branch}" deploy_name = "#{PACKAGE_NAME}-#{branch}-#{commit}"
end end
INSTALL_DIR_PATH = File.join(DEPLOY_DIR, deploy_name)
FileUtils.mkdir_p(BUILD_DIR) FileUtils.mkdir_p(BUILD_DIR)
Dir.chdir(BUILD_DIR) do Dir.chdir(BUILD_DIR) do
postinstall = Tempfile.new('postinstall')
postinstall.write <<-POSTINSTALL.gsub(/^\s*/, '')
#! /bin/sh
set -e
set -x
service gunicorn stop
rm #{LINK_PATH}
ln -s #{INSTALL_DIR_PATH} #{LINK_PATH}
service gunicorn start
POSTINSTALL
postinstall.close()
FileUtils.chmod(0755, postinstall.path)
args = ["fakeroot", "fpm", "-s", "dir", "-t", "deb", args = ["fakeroot", "fpm", "-s", "dir", "-t", "deb",
"--exclude=build", "--exclude=build",
"--exclude=rakefile", "--exclude=rakefile",
"--exclude=.git", "--exclude=.git",
"--exclude=**/*.pyc", "--exclude=**/*.pyc",
"--prefix=/opt/wwc/mitx-#{commit}", "--after-install=#{postinstall.path}",
"--prefix=#{INSTALL_DIR_PATH}",
"-C", "#{REPO_ROOT}", "-C", "#{REPO_ROOT}",
"--depends=python-mysqldb", "--depends=python-mysqldb",
"--depends=python-django", "--depends=python-django",
...@@ -42,8 +68,8 @@ task :package do ...@@ -42,8 +68,8 @@ task :package do
"--depends=python-markdown", "--depends=python-markdown",
"--depends=python-pygments", "--depends=python-pygments",
"--depends=mysql-client", "--depends=mysql-client",
"--name=#{package_name}-#{commit}", "--name=#{deploy_name}",
"--version=0.1", "--version=#{VERSION}",
"--iteration=#{build_number}", "--iteration=#{build_number}",
"-a", "all", "-a", "all",
"."] "."]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment