Skip to content

Commit

Permalink
switch k tools to d tools
Browse files Browse the repository at this point in the history
  • Loading branch information
opiethehokie committed Jun 16, 2015
1 parent 9b66c40 commit 5e37482
Show file tree
Hide file tree
Showing 23 changed files with 369 additions and 219 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloud Foundry buildpack: ASP.NET 5

A Cloud Foundry buildpack for ASP.NET 5 ([beta3][]) apps. For more information about ASP.NET 5 see:
A Cloud Foundry buildpack for ASP.NET 5 ([beta4][]) apps. For more information about ASP.NET 5 see:

* https://github.com/aspnet/home
* http://docs.asp.net/en/latest/conceptual-overview/aspnet.html
Expand Down Expand Up @@ -68,4 +68,4 @@ Open an issue on this project.


[Hello World sample]: https://github.com/opiethehokie/asp.net5-helloworld
[beta3]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta3
[beta4]: https://github.com/aspnet/Home/releases/tag/v1.0.0-beta4
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0
6 changes: 3 additions & 3 deletions lib/buildpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def self.compiler(build_dir, cache_dir)
cache_dir,
MonoInstaller.new(build_dir, shell),
File.expand_path("../../resources/Nowin.vNext", __FILE__),
KvmInstaller.new(shell),
DnvmInstaller.new(shell),
Mozroots.new(shell),
KreInstaller.new(shell),
KPM.new(shell),
DnxInstaller.new(shell),
DNU.new(shell),
ReleaseYmlWriter.new,
Copier.new,
out)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2014-2015 the original author or authors.
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,13 +15,14 @@
# limitations under the License.

module AspNet5Buildpack
class KreInstaller
class DNU
def initialize(shell)
@shell = shell
end

def install(dir, out)
@shell.exec("bash -c 'source #{dir}/.k/kvm/kvm.sh; kvm install 1.0.0-beta3'", out)
def restore(dir, out)
@shell.env['HOME'] = dir
@shell.exec("bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm use default -r mono -a x64; cd #{dir}; dnu restore'", out)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2014-2015 the original author or authors.
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,14 @@
# limitations under the License.

module AspNet5Buildpack
class KvmInstaller
class DnvmInstaller
def initialize(shell)
@shell = shell
end

def install(dir, out)
@shell.env["KRE_USER_HOME"] = File.join(dir, ".k")
@shell.exec("curl -s https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh", out)
@shell.env['HOME'] = dir
@shell.exec('touch ~/.bashrc; curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh; rm -rf ~/.bashrc', out)
end
end
end
56 changes: 56 additions & 0 deletions lib/buildpack/compile/dnx_installer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Encoding: utf-8
# ASP.NET 5 Buildpack
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'json'

module AspNet5Buildpack
class DnxInstaller

DNX_VERSION_FILE_NAME = 'global.json'.freeze
DEFAULT_DNX_VERSION = 'latest'.freeze

def initialize(shell)
@shell = shell
end

def install(dir, out)
@shell.env['HOME'] = dir
version = dnx_version(dir, out)
@shell.exec("bash -c 'source #{dir}/.dnx/dnvm/dnvm.sh; dnvm install #{version} -p -r mono'", out)
end

private

def dnx_version(dir, out)
dnx_version = DEFAULT_DNX_VERSION
version_file = File.expand_path(File.join(dir, DNX_VERSION_FILE_NAME))
if File.exists?(version_file)
begin
global_props = JSON.parse(File.read(version_file, :encoding => 'bom|utf-8'))
if global_props.has_key?('sdk')
sdk = global_props['sdk']
if sdk.has_key?('version')
dnx_version = sdk['version']
end
end
rescue
out.warn("File #{version_file} is not valid JSON")
end
end
dnx_version
end
end
end
28 changes: 0 additions & 28 deletions lib/buildpack/compile/kpm.rb

This file was deleted.

7 changes: 5 additions & 2 deletions lib/buildpack/compile/mono_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
module AspNet5Buildpack
class MonoInstaller

DEFAULT_VERSION = '3.12.1'
# really 4.0.1.44 fix release - needed for mozroots error
DEFAULT_VERSION = '4.0.1'

def initialize(app_dir, shell)
@app_dir = app_dir
@shell = shell
end

def extract(dest_dir, out)
out.print("Mono version: #{version}")
run_common_cmd("mkdir -p #{dest_dir}; curl -L `translate_dependency_url #{dependency_name}` -s | tar zxv -C #{dest_dir} &> /dev/null", out)
end

Expand All @@ -39,7 +41,8 @@ def mono_tar_gz(out)
private

def run_common_cmd(cmd, out)
shell.exec("bash -c 'export BUILDPACK_PATH=#{buildpack_root}; source $BUILDPACK_PATH/compile-extensions/lib/common &> /dev/null; #{cmd}'", out)
commoncmd = "bash -c 'export BUILDPACK_PATH=#{buildpack_root}; source $BUILDPACK_PATH/compile-extensions/lib/common &> /dev/null; #{cmd}'"
shell.exec(commoncmd, out)
end

def buildpack_root
Expand Down
15 changes: 9 additions & 6 deletions lib/buildpack/compile/release_yml_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require "fileutils"
require 'fileutils'
require 'json'

module AspNet5Buildpack
class ReleaseYmlWriter
Expand Down Expand Up @@ -42,20 +43,22 @@ def write_yml(dirs)
end

def add_cfweb_command(project_json)
json = JSON.parse(IO.read(project_json))
json = JSON.parse(IO.read(project_json, :encoding => 'bom|utf-8'))
json["dependencies"] ||= {}
json["dependencies"]["Nowin.vNext"] = "1.0.0-*" unless json["dependencies"]["Nowin.vNext"]
json["commands"] ||= {}
json["commands"]["cf-web"] = "Microsoft.AspNet.Hosting --server Nowin.vNext"
IO.write(project_json, json.to_json)
IO.write(project_json, JSON.pretty_generate(json))
end

def write_startup_script(path)
FileUtils.mkdir_p(File.dirname(path))
File.open(path, 'w') do |f|
f.write "export PATH=/app/mono/bin:$PATH;"
f.write "export HOME=/app;"
f.write "source /app/.k/kvm/kvm.sh; kvm use 1.0.0-beta3;"
f.write "source /app/.dnx/dnvm/dnvm.sh;"
f.write "dnvm use default -r mono -a x64;"
f.write "dnu restore;"
end
end

Expand All @@ -64,7 +67,7 @@ def write_yml_for(ymlPath, web_dir, cmd)
f.write <<EOT
---
default_process_types:
web: cd #{web_dir}; sleep 999999 | k #{cmd}
web: cd #{web_dir}; sleep 999999 | dnx . #{cmd}
EOT
end
end
Expand Down Expand Up @@ -105,7 +108,7 @@ def with_project_json
end

def commands(dir)
JSON.load(IO.read(project_json(dir))).fetch("commands", {})
JSON.load(IO.read(project_json(dir), :encoding => 'bom|utf-8')).fetch("commands", {})
end

def project_json(dir)
Expand Down
42 changes: 21 additions & 21 deletions lib/buildpack/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

require_relative 'compile/mozroots.rb'
require_relative 'compile/mono_installer.rb'
require_relative 'compile/kre_installer.rb'
require_relative 'compile/kvm_installer.rb'
require_relative 'compile/kpm.rb'
require_relative 'compile/dnvm_installer.rb'
require_relative 'compile/dnx_installer.rb'
require_relative 'compile/dnu.rb'
require_relative 'compile/release_yml_writer.rb'
require_relative "version.rb"

Expand All @@ -27,17 +27,17 @@

module AspNet5Buildpack
class Compiler
WARNING_MESSAGE = "This is an experimental buildpack. It is not supported. Do not expect it to work reliably. Please, do not contact support about issues with this buildpack."
WARNING_MESSAGE = "This is an experimental buildpack. It is not supported. Do not expect it to work reliably. Please, do not contact support about issues with this buildpack.".freeze

def initialize(build_dir, cache_dir, mono_binary, nowin_dir, kvm_installer, mozroots, kre_installer, kpm, release_yml_writer, copier, out)
def initialize(build_dir, cache_dir, mono_binary, nowin_dir, dnvm_installer, mozroots, dnx_installer, dnu, release_yml_writer, copier, out)
@build_dir = build_dir
@cache_dir = cache_dir
@mono_binary = mono_binary
@nowin_dir = nowin_dir
@kvm_installer = kvm_installer
@kre_installer = kre_installer
@dnvm_installer = dnvm_installer
@dnx_installer = dnx_installer
@mozroots = mozroots
@kpm = kpm
@dnu = dnu
@release_yml_writer = release_yml_writer
@copier = copier
@out = out
Expand All @@ -51,9 +51,9 @@ def compile
step("Extracting mono", method(:extract_mono))
step("Adding Nowin.vNext", method(:copy_nowin))
step("Importing Mozilla Root Certificates", method(:install_mozroot_certs))
step("Installing KVM", method(:install_kvm))
step("Installing KRE with KVM", method(:install_kre))
step("Restoring dependencies with KPM", method(:restore_dependencies))
step("Installing DNVM", method(:install_dnvm))
step("Installing DNX with DNVM", method(:install_dnx))
step("Restoring dependencies with DNU", method(:restore_dependencies))
step("Moving files in to place", method(:move_to_app_dir))
step("Saving to buildpack cache", method(:save_cache))
step("Writing Release YML", method(:write_release_yml))
Expand Down Expand Up @@ -83,28 +83,28 @@ def install_mozroot_certs(out)
end

def restore_cache(out)
copier.cp(File.join(cache_dir, ".k"), build_dir, out) if File.exist? File.join(cache_dir, ".k")
copier.cp(File.join(cache_dir, ".dnx"), build_dir, out) if File.exist? File.join(cache_dir, ".dnx")
copier.cp(File.join(cache_dir, "mono"), File.join("/", "app"), out) if File.exist? File.join(cache_dir, "mono")
end

def install_kvm(out)
kvm_installer.install(build_dir, out)
def install_dnvm(out)
dnvm_installer.install(build_dir, out)
end

def install_kre(out)
kre_installer.install(build_dir, out)
def install_dnx(out)
dnx_installer.install(build_dir, out)
end

def restore_dependencies(out)
kpm.restore(build_dir, out)
dnu.restore(build_dir, out)
end

def move_to_app_dir(out)
copier.cp(File.join("/app", "mono"), build_dir, out)
end

def save_cache(out)
copier.cp(File.join(build_dir, ".k"), cache_dir, out)
copier.cp(File.join(build_dir, ".dnx"), cache_dir, out)
copier.cp(File.join("/app", "mono"), cache_dir, out) unless File.exists? File.join(cache_dir, "mono")
end

Expand All @@ -128,10 +128,10 @@ def step(description, method)
attr_reader :cache_dir
attr_reader :mono_binary
attr_reader :nowin_dir
attr_reader :kvm_installer
attr_reader :kre_installer
attr_reader :dnvm_installer
attr_reader :dnx_installer
attr_reader :mozroots
attr_reader :kpm
attr_reader :dnu
attr_reader :release_yml_writer
attr_reader :copier
attr_reader :out
Expand Down
1 change: 1 addition & 0 deletions lib/buildpack/copier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module AspNet5Buildpack
class Copier
def cp(from, to, out)
before = files_in_dest(to)
FileUtils.mkdir_p(to)
FileUtils.cp_r(from, to)
after = files_in_dest(to)

Expand Down
12 changes: 6 additions & 6 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ url_to_dependency_map:

dependencies:
- name: mono
version: 3.12.1
version: 4.0.1
cf_stacks:
- lucid64
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.1/mono-lucid64-3.12.1.tar.gz
md5: 386e88cadea67669e7731d4238cefb53
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.2/mono-lucid64-4.0.1.tar.gz
md5: 3d020ca4a4bc2afd6e803eeb18ff5551
- name: mono
version: 3.12.1
version: 4.0.1
cf_stacks:
- cflinuxfs2
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.1/mono-cflinuxfs2-3.12.1.tar.gz
md5: 7f992e9d13c608487937988b465be19a
uri: https://github.com/cloudfoundry-community/asp.net5-buildpack/releases/download/v0.2/mono-cflinuxfs2-4.0.1.tar.gz
md5: 98de7244bd6a91ea4d0acc9104b82a59

exclude_files:
- .git/
Expand Down
Loading

0 comments on commit 5e37482

Please sign in to comment.