Skip to content

Commit

Permalink
Hopefully working on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmorley committed Oct 12, 2016
1 parent 6e70aa4 commit ea5ee04
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 83 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'files/client.rb'

# Offense count: 2
Metrics/AbcSize:
Max: 27
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.0
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

# Specify your gem's dependencies in workup.gemspec
Expand Down
22 changes: 17 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rubocop/rake_task'
require 'rspec/core/rake_task'
require 'kitchen/rake_tasks'

task test: ['test:lint', 'test:spec']
namespace :test do
RuboCop::RakeTask.new(:lint)
RSpec::Core::RakeTask.new(:spec)
end

task test: ['test:lint', 'test:spec']

task :files do
FileUtils.cp_r 'files/.', File.join(ENV['HOME'], '.workup')
end

task :package do
`rm -rf ./pkg`
`vagrant up
Dir.chdir('omnibus') do
Kitchen::RakeTasks.new
task 'kitchen:default-windows': 'kitchen:default-windows-i386'
CLOBBER << '.kitchen'
end

omnibus_platforms = [:windows, :macos]

desc 'Build omnibus packages'
task omnibus: omnibus_platforms.map { |platform| "omnibus:#{platform}" }
namespace :omnibus do
omnibus_platforms.each do |platform|
task platform => [:clobber, :test, :build, "kitchen:default-#{platform}"]
end
end

task default: :test
1 change: 1 addition & 0 deletions exe/workup
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'workup'
require 'io/console'
Expand Down
1 change: 1 addition & 0 deletions files/Policyfile.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
name 'workup'

default_source :community
Expand Down
3 changes: 2 additions & 1 deletion files/client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
chef_repo_path File.join __dir__, 'chef-zero'
file_cache_path File.join __dir__, 'local-cache'

Expand All @@ -6,7 +7,7 @@
chef_zero.enabled true
log_level :error
add_formatter 'doc'
node_name (ENV['SUDO_USER'] || ENV['USER'] || ENV['USERNAME']).downcase
node_name((ENV['SUDO_USER'] || ENV['USER'] || ENV['USERNAME']).downcase)

## Policyfile settings
policy_name 'workup'
Expand Down
1 change: 1 addition & 0 deletions lib/workup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Copyright:: Copyright (c) 2016 Cvent Inc.
# License:: Apache License, Version 2.0
Expand Down
14 changes: 6 additions & 8 deletions lib/workup/application.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Copyright:: Copyright (c) 2016 Cvent Inc.
# License:: Apache License, Version 2.0
Expand Down Expand Up @@ -75,13 +76,10 @@ def default
def chef_zero
raise 'Workup directory does not exist' unless File.exist?(options[:workup_dir])
policy_path = File.join(options[:workup_dir], 'Policyfile.rb')
lock_path = File.join(options[:workup_dir], 'Policyfile.lock.json')
chefzero_path = File.join(options[:workup_dir], 'chef-zero')

log.info 'Updating lock file... '
Workup::Helpers.silence do
ChefDK::Command::Update.new.run([policy_path])
end
Workup::Helpers.silence { ChefDK::Command::Update.new.run([policy_path]) }
log.debug "OK\n"

log.info 'Creating chef-zero directory... '
Expand All @@ -97,10 +95,10 @@ def chef_client
clientrb_path = File.join(options[:workup_dir], 'client.rb')

chef_client_dir = if Gem.win_platform?
'C:/opscode/workup/embedded/bin'
else
'/opt/workup/embedded/bin'
end
'C:/opscode/workup/embedded/bin'
else
'/opt/workup/embedded/bin'
end

client_cmd = ['./chef-client', '--no-fork', '--config', clientrb_path]
client_cmd << '-A' if Gem.win_platform?
Expand Down
1 change: 1 addition & 0 deletions lib/workup/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Copyright:: Copyright (c) 2016 Cvent Inc.
# License:: Apache License, Version 2.0
Expand Down
1 change: 1 addition & 0 deletions lib/workup/logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Copyright:: Copyright (c) 2016 Cvent Inc.
# License:: Apache License, Version 2.0
Expand Down
3 changes: 2 additions & 1 deletion lib/workup/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Copyright:: Copyright (c) 2016 Cvent Inc.
# License:: Apache License, Version 2.0
Expand All @@ -16,5 +17,5 @@
#

module Workup
VERSION = '0.1.0'.freeze
VERSION = '0.1.0'
end
6 changes: 4 additions & 2 deletions omnibus/.kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ driver:
cpus: 2
memory: 4096
synced_folders:
- ['..', '/home/vagrant/workup']
- ['..', '/vagrant/code/workup']

provisioner:
name: chef_zero
Expand All @@ -24,10 +24,12 @@ platforms:
network:
- ["private_network", {ip: "192.168.33.33"}]
synced_folders:
- ['..', '/Users/vagrant/workup', ':type => :nfs, :mount_options => ["nolock,vers=3,udp,noatime"]']
- ['..', '/vagrant/code/workup', ':type => :nfs, :mount_options => ["nolock,vers=3,udp,noatime"]']
- name: windows-i386
driver:
box: mwrock/Windows2016
synced_folders:
- ['..', '/Users/vagrant/workup']
attributes:
omnibus:
build_user_group: Administrators
Expand Down
1 change: 1 addition & 0 deletions omnibus/Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://supermarket.chef.io'

cookbook 'workup_build', path: 'workup_build'
5 changes: 0 additions & 5 deletions omnibus/Berksfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ GRAPH
windows-sdk (>= 0.0.0)
wix (>= 0.0.0)
remote_install (1.0.2)
rubyinstaller (0.1.3)
chef-sugar (~> 3.3.0)
windows (~> 1.44.1)
seven_zip (2.0.2)
windows (>= 1.2.2)
windows (1.44.3)
Expand All @@ -50,9 +47,7 @@ GRAPH
wix (3.0.0)
windows (>= 1.38.2)
workup_build (0.0.1)
git (>= 0.0.0)
omnibus (>= 0.0.0)
rubyinstaller (>= 0.0.0)
yum (4.0.0)
yum-epel (1.0.1)
yum (>= 3.6)
1 change: 1 addition & 0 deletions omnibus/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'http://rubygems.org'

# Install omnibus
Expand Down
21 changes: 14 additions & 7 deletions omnibus/config/projects/workup.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true
#
# Copyright 2016 YOUR NAME
#
# All Rights Reserved.
#

name "workup"
maintainer "Cvent"
homepage "https://github.com/cvent/workup"
name 'workup'
maintainer 'Cvent'
homepage 'https://github.com/cvent/workup'

# Defaults to C:/workup on Windows
# and /opt/workup on all other platforms
Expand All @@ -16,12 +17,18 @@
build_iteration 1

# Creates required build directories
dependency "preparation"
dependency 'preparation'

# workup dependencies/components
dependency "workup"
dependency 'workup'

override :"ruby-windows-devkit", version: '4.5.2-20111229-1559' if windows? && windows_arch_i386?

dependency 'shebang-cleanup'

exclude "**/.git"
exclude "**/bundler/git"
exclude '**/.git'
exclude '**/bundler/git'

package :msi do
upgrade_code '769d8737-c798-49d1-bab0-0a31da3ee7df'.capitalize
end
50 changes: 23 additions & 27 deletions omnibus/config/software/workup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Copyright 2016 YOUR NAME
#
Expand All @@ -15,54 +16,49 @@
#

# These options are required for all software definitions
name "workup"
default_version "local_source"
name 'workup'
default_version 'local_source'

# For the specific super-special version "local_source", build the source from
# the local git checkout. This is what you'd want to occur by default if you
# just ran omnibus build locally.
version("local_source") do
source path: File.expand_path("../..", project.files_path),
version('local_source') do
source path: File.expand_path('../..', project.files_path),
# Since we are using the local repo, we try to not copy any files
# that are generated in the process of bundle installing omnibus.
# If the install steps are well-behaved, this should not matter
# since we only perform bundle and gem installs from the
# omnibus cache source directory, but we do this regardless
# to maintain consistency between what a local build sees and
# what a github based build will see.
options: { exclude: [ "omnibus/vendor" ] }
options: { exclude: ['omnibus/vendor'] }
end

# For any version other than "local_source", fetch from github.
if version != "local_source"
source git: "git://github.com/cvent/workup.git"
end
source git: 'git://github.com/cvent/workup.git' if version != 'local_source'

# For nokogiri
dependency "libxml2"
dependency "libxslt"
dependency "libiconv"
dependency "liblzma"
dependency "zlib"

# For psych
dependency 'libyaml'
dependency 'libxml2'
dependency 'libxslt'
dependency 'libiconv'
dependency 'liblzma'
dependency 'zlib'

# ruby and bundler and friends
dependency "ruby"
dependency "ruby-windows-devkit" if windows?
dependency "rubygems"
dependency "bundler"

#dependency "chef"
dependency 'ruby'
dependency 'ruby-windows-devkit' if windows?
dependency 'rubygems'
dependency 'bundler'

# dependency "chef"

# Version manifest file
dependency "version-manifest"
dependency 'version-manifest'

build do
bundle 'install'
bundle 'check'
gem 'build workup.gemspec'
gem 'install ./workup-0.1.0.gem'
command 'cat C:\workup\embedded\bin\gem'

env = with_standard_compiler_flags(with_embedded_path)

gem 'install pkg/workup-0.1.0.gem', env: env
end
8 changes: 6 additions & 2 deletions omnibus/omnibus.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# This file is used to configure the workup project. It contains
# some minimal configuration examples for working with Omnibus. For a full list
Expand Down Expand Up @@ -49,5 +50,8 @@

# Windows architecture defaults
# ------------------------------
windows_arch %w{x86 x64}.include?((ENV['OMNIBUS_WINDOWS_ARCH'] || '').downcase) ?
ENV['OMNIBUS_WINDOWS_ARCH'].downcase.to_sym : :x86
if %w(x86 x64).include?((ENV['OMNIBUS_WINDOWS_ARCH'] || '').downcase)
windows_arch ENV['OMNIBUS_WINDOWS_ARCH'].downcase.to_sym
else
windows_arch :x86
end
2 changes: 2 additions & 0 deletions omnibus/workup_build/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true
default['omnibus']['build_user'] = 'vagrant'
default['omnibus']['build_user_home'] = '/Users/vagrant'
default['omnibus']['build_user_password'] = 'vagrant'
default['omnibus']['ruby_version'] = '2.3.0'

case node['os']
when 'windows'
Expand Down
3 changes: 1 addition & 2 deletions omnibus/workup_build/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
name 'workup_build'
maintainer 'Morley, Jonathan'
maintainer_email '[email protected]'
Expand All @@ -7,5 +8,3 @@
version '0.0.1'

depends 'omnibus'
depends 'rubyinstaller'
depends 'git'
Loading

0 comments on commit ea5ee04

Please sign in to comment.