From d885e019b3033627ddb8a5d642f3df2e7b9359cb Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Fri, 20 Jan 2012 18:02:01 -0800 Subject: [PATCH] Add Debian packaging. --- Rakefile | 8 +++- dist/deb.rake | 48 +++++++++++++++++++++++ dist/resources/deb/control | 12 ++++++ dist/resources/deb/foreman | 18 +++++++++ dist/resources/deb/heroku-release-key.txt | 30 ++++++++++++++ dist/resources/deb/postinst | 3 ++ 6 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 dist/deb.rake create mode 100644 dist/resources/deb/control create mode 100644 dist/resources/deb/foreman create mode 100644 dist/resources/deb/heroku-release-key.txt create mode 100755 dist/resources/deb/postinst diff --git a/Rakefile b/Rakefile index 2c90ae5..c196193 100644 --- a/Rakefile +++ b/Rakefile @@ -102,9 +102,13 @@ def clean(file) rm file if File.exists?(file) end -def distribution_files +def distribution_files(type=nil) require "foreman/distribution" - Foreman::Distribution.files + base_files = Foreman::Distribution.files + type_files = type ? + Dir[File.expand_path("../dist/resources/#{type}/**/*", __FILE__)] : + [] + base_files.concat(type_files) end def mkchdir(dir) diff --git a/dist/deb.rake b/dist/deb.rake new file mode 100644 index 0000000..368d9de --- /dev/null +++ b/dist/deb.rake @@ -0,0 +1,48 @@ +file pkg("/apt-#{version}/foreman-#{version}.deb") => distribution_files("deb") do |t| + mkchdir(File.dirname(t.name)) do + mkchdir("usr/local/foreman") do + assemble_distribution + assemble_gems + assemble resource("deb/foreman"), "bin/foreman", 0755 + File.chmod 0755, "bin/runner" + end + + assemble resource("deb/control"), "control" + assemble resource("deb/postinst"), "postinst" + + sh "tar czvf data.tar.gz usr/local/foreman --owner=root --group=root" + sh "tar czvf control.tar.gz control postinst" + + File.open("debian-binary", "w") do |f| + f.puts "2.0" + end + + deb = File.basename(t.name) + + sh "ar -r #{t.name} debian-binary control.tar.gz data.tar.gz" + + touch "Sources" + sh "apt-ftparchive packages . > Packages" + sh "gzip -c Packages > Packages.gz" + sh "apt-ftparchive release . > Release" + sh "gpg -abs -u 0F1B0520 -o Release.gpg Release" + end +end + +desc "Build a .deb package" +task "deb:build" => pkg("/apt-#{version}/foreman-#{version}.deb") + +desc "Remove build artifacts for .deb" +task "deb:clean" do + clean pkg("foreman-#{version}.deb") + FileUtils.rm_rf("pkg/apt-#{version}") if Dir.exists?("pkg/apt-#{version}") +end + +desc "Publish .deb to S3." +task "deb:release" => "deb:build" do |t| + Dir["pkg/apt-#{version}/*"].each do |file| + unless File.directory?(file) + store file, "apt/#{File.basename(file)}", "foreman" + end + end +end diff --git a/dist/resources/deb/control b/dist/resources/deb/control new file mode 100644 index 0000000..43c87f1 --- /dev/null +++ b/dist/resources/deb/control @@ -0,0 +1,12 @@ +Package: foreman +Version: <%= version %> +Section: main +Priority: standard +Architecture: all +Depends: ruby1.9.1 +Maintainer: Heroku +Description: Manage Procfile-based applications. + Foreman is a manager for Procfile-based applications. Its aim is to + abstract away the details of the Procfile format, and allow you to + either run your application directly or export it to some other + process management format. diff --git a/dist/resources/deb/foreman b/dist/resources/deb/foreman new file mode 100644 index 0000000..f698b11 --- /dev/null +++ b/dist/resources/deb/foreman @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby1.9.1 + +# resolve bin path, ignoring symlinks +require "pathname" +bin_file = Pathname.new(__FILE__).realpath + +# add locally vendored gems to libpath +gem_dir = File.expand_path("../../vendor/gems", bin_file) +Dir["#{gem_dir}/**/lib"].each do |libdir| + $:.unshift libdir +end + +# add self to libpath +$:.unshift File.expand_path("../../lib", bin_file) + +require "foreman/cli" + +Foreman::CLI.start diff --git a/dist/resources/deb/heroku-release-key.txt b/dist/resources/deb/heroku-release-key.txt new file mode 100644 index 0000000..e22a1c2 --- /dev/null +++ b/dist/resources/deb/heroku-release-key.txt @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.11 (Darwin) + +mQENBE5SfAEBCADLp056ZgfdtAMXLWpEuL9zY+dIHIY5qLQcDmUivjHLVE4l3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IFLbCw9NeN65pI9ePs2mSPM7DYkhhKSXWMwJNXFzn1blOGiwAwKb48P +a/QpE6TG3PQzbYyTTP0Td1XgKAHcprvbc89a/nAk3a+PJQ/MqvDzABEBAAGJAR8E +GAECAAkFAk5SfAECGwwACgkQySfr4A8bBSD4mAgAnCT5WRiDl0259Px9Z9J9Wk8Z +SxugDct2Yhzca4aw1Ou4cfaIFCDXzFlBzSJfqk0HoVhp9r2gzEPUCKnSjRDyxaMo +wZCUtqigBua+z4NB4AWgeOl/2S06I2ki1K7pfl4piYcHtEThHamnhVPJ2Hi6HsHq +mUU+8SxleHE4GCXmKkuvxelUq9jrhHikIkm1RoqFOPb9zV3WRy4YzVHQSYfHmfk0 +9kXlM/CS0sfNv2UKCX+5e6eFIZv0rdtpp6VEh0tsFmsIClY6Z9MX7bgp8MnUJpyk +OeIzOzQgkb4aeT0Whl+EPcTeDZfqIhVBoNXupUanmWNppFcMngxfqG2NGi1vvQ== +=aUAq +-----END PGP PUBLIC KEY BLOCK----- diff --git a/dist/resources/deb/postinst b/dist/resources/deb/postinst new file mode 100755 index 0000000..72681f0 --- /dev/null +++ b/dist/resources/deb/postinst @@ -0,0 +1,3 @@ +#!/bin/sh +set -e +ln -sf /usr/local/foreman/bin/foreman /usr/bin/foreman