Add a post-install script that points the link to the correct revision
This commit is contained in:
38
rakefile
38
rakefile
@@ -1,10 +1,19 @@
|
||||
require 'rake/clean'
|
||||
require 'tempfile'
|
||||
|
||||
# Build Constants
|
||||
REPO_ROOT = File.dirname(__FILE__)
|
||||
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')
|
||||
CLEAN.include("#{BUILD_DIR}/*.deb")
|
||||
CLEAN.include("#{BUILD_DIR}/*.deb", "#{BUILD_DIR}/util")
|
||||
|
||||
task :package do
|
||||
commit = (ENV["GIT_COMMIT"] || `git rev-parse HEAD`).chomp()
|
||||
@@ -13,20 +22,37 @@ task :package do
|
||||
build_number = (ENV["BUILD_NUMBER"] || "dev").chomp()
|
||||
|
||||
if branch == "master"
|
||||
package_name = "mitx"
|
||||
deploy_name = "#{PACKAGE_NAME}-#{commit}"
|
||||
else
|
||||
package_name = "mitx-#{branch}"
|
||||
deploy_name = "#{PACKAGE_NAME}-#{branch}-#{commit}"
|
||||
end
|
||||
INSTALL_DIR_PATH = File.join(DEPLOY_DIR, deploy_name)
|
||||
|
||||
FileUtils.mkdir_p(BUILD_DIR)
|
||||
|
||||
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",
|
||||
"--exclude=build",
|
||||
"--exclude=rakefile",
|
||||
"--exclude=.git",
|
||||
"--exclude=**/*.pyc",
|
||||
"--prefix=/opt/wwc/mitx-#{commit}",
|
||||
"--after-install=#{postinstall.path}",
|
||||
"--prefix=#{INSTALL_DIR_PATH}",
|
||||
"-C", "#{REPO_ROOT}",
|
||||
"--depends=python-mysqldb",
|
||||
"--depends=python-django",
|
||||
@@ -42,8 +68,8 @@ task :package do
|
||||
"--depends=python-markdown",
|
||||
"--depends=python-pygments",
|
||||
"--depends=mysql-client",
|
||||
"--name=#{package_name}-#{commit}",
|
||||
"--version=0.1",
|
||||
"--name=#{deploy_name}",
|
||||
"--version=#{VERSION}",
|
||||
"--iteration=#{build_number}",
|
||||
"-a", "all",
|
||||
"."]
|
||||
|
||||
Reference in New Issue
Block a user