You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by Chris Lalancette <cl...@redhat.com> on 2011/05/26 17:44:44 UTC

[PATCHv2 2/5] Update the Fedora spec file to match the one in Fedora.

Signed-off-by: Chris Lalancette <cl...@redhat.com>
---
 server/support/fedora/deltacloud-core.spec |  127 +++++++++++++++------------
 server/support/fedora/deltacloudd          |  128 ----------------------------
 server/support/fedora/deltacloudd-fedora   |    5 +
 3 files changed, 75 insertions(+), 185 deletions(-)
 delete mode 100755 server/support/fedora/deltacloudd
 create mode 100644 server/support/fedora/deltacloudd-fedora

diff --git a/server/support/fedora/deltacloud-core.spec b/server/support/fedora/deltacloud-core.spec
index c4b783d..9d765ba 100644
--- a/server/support/fedora/deltacloud-core.spec
+++ b/server/support/fedora/deltacloud-core.spec
@@ -1,16 +1,14 @@
-%global ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
-%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
-%global geminstdir %{gemdir}/gems/deltacloud-core-%{version}
+%global app_root %{_datadir}/%{name}
 
 Summary: Deltacloud REST API
 Name: deltacloud-core
 Version: 0.3.0
-Release: 1%{?dist}
+Release: 5%{?dist}
 Group: Development/Languages
 License: ASL 2.0 and MIT
 URL: http://incubator.apache.org/deltacloud
-Source0: http://gems.rubyforge.org/gems/deltacloud-core-%{version}.gem
-# Note: This would be needed only for EPEL branches:
+Source0: http://gems.rubyforge.org/gems/%{name}-%{version}.gem
+Source1: deltacloudd-fedora
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires: rubygems
 Requires: ruby(abi) = 1.8
@@ -18,28 +16,29 @@ Requires: rubygem(haml)
 Requires: rubygem(sinatra) >= 1.0
 Requires: rubygem(rack) >= 1.1.0
 Requires: rubygem(thin)
-Requires: rubygem(haml)
+Requires: rubygem(net-ssh)
 Requires: rubygem(json) >= 1.4.0
-Requires: rubygem(net-ssh) >= 2.0.0
 Requires: rubygem(rack-accept)
-Requires(post): chkconfig
-Requires(preun): chkconfig
-Requires(preun): initscripts
+Requires: rubygem(nokogiri)
+Requires(post):   chkconfig
+Requires(preun):  chkconfig
+Requires(preun):  initscripts
 Requires(postun): initscripts
 BuildRequires: rubygems
 BuildRequires: ruby(abi) = 1.8
-BuildRequires: rubygem(sinatra) >= 1.0
 BuildRequires: rubygem(haml)
-BuildRequires: rubygem(rack) >= 1.1.0
-BuildRequires: rubygem(nokogiri) >= 1.4.3
-BuildRequires: rubygem(net-ssh) >= 2.0.0
+BuildRequires: rubygem(sinatra) >= 1.0
+BuildRequires: rubygem(nokogiri)
+BuildRequires: rubygem(net-ssh)
+BuildRequires: rubygem(aws)
 BuildRequires: rubygem(rack-accept)
-BuildRequires: rubygem(json) >= 1.4.0
 BuildRequires: rubygem(rake) >= 0.8.7
+BuildRequires: rubygem(rack) >= 1.1.0
 BuildRequires: rubygem(rack-test) >= 0.5.0
 BuildRequires: rubygem(rspec) >= 1.3.0
+BuildRequires: rubygem(json) >= 1.4.0
 BuildArch: noarch
-Provides: deltacloud-core = %{version}
+Obsoletes: rubygem-deltacloud-core
 
 %description
 The Deltacloud API is built as a service-based REST API.
@@ -50,33 +49,35 @@ which implements the REST interface.
 %package doc
 Summary: Documentation for %{name}
 Group: Documentation
-Requires:%{name} = %{version}-%{release}
+Requires: %{name} = %{version}-%{release}
 
 %description doc
 Documentation for %{name}
 
 %prep
+%setup -q -c -T
+gem unpack -V --target=%{_builddir} %{SOURCE0}
+pushd %{_builddir}/%{name}-%{version}
+popd
 
 %build
 
 %install
 rm -rf %{buildroot}
-mkdir -p %{buildroot}%{gemdir}
+mkdir -p %{buildroot}%{app_root}
 mkdir -p %{buildroot}%{_initddir}
-gem install --local --install-dir %{buildroot}%{gemdir} \
-            --force --rdoc %{SOURCE0}
-mkdir -p %{buildroot}/%{_bindir}
-mkdir -p %{buildroot}/config
-mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
-mv %{buildroot}%{geminstdir}/support/fedora/deltacloud-core %{buildroot}%{_initddir}
-mv -f %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}%{geminstdir}/bin
-rmdir %{buildroot}%{gemdir}/bin
-find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
-find %{buildroot}%{geminstdir}/lib -type f | xargs chmod -x
-chmod 755 %{buildroot}%{_initddir}/deltacloud-core
+mkdir -p %{buildroot}%{_bindir}
+cp -r %{_builddir}/%{name}-%{version}/* %{buildroot}%{app_root}
+mv %{buildroot}%{app_root}/support/fedora/%{name} %{buildroot}%{_initddir}
+install -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/deltacloudd
+find %{buildroot}%{app_root}/lib -type f | xargs chmod -x
+chmod 0755 %{buildroot}%{_initddir}/%{name}
+chmod 0755 %{buildroot}%{app_root}/bin/deltacloudd
+rm -rf %{buildroot}%{app_root}/support
+rdoc --op %{buildroot}%{_defaultdocdir}/%{name}
 
 %check
-pushd %{buildroot}%{geminstdir}
+pushd %{buildroot}%{app_root}
 rake test:mock
 popd
 
@@ -85,50 +86,62 @@ rm -rf %{buildroot}
 
 %post
 # This adds the proper /etc/rc*.d links for the script
-/sbin/chkconfig --add deltacloud-core
+/sbin/chkconfig --add %{name}
 
 %preun
 if [ $1 -eq 0 ] ; then
-    /sbin/service deltacloud-core stop >/dev/null 2>&1
-    /sbin/chkconfig --del deltacloud-core
+    /sbin/service %{name} stop >/dev/null 2>&1
+    /sbin/chkconfig --del %{name}
 fi
 
 %postun
 if [ "$1" -ge "1" ] ; then
-    /sbin/service deltacloud-core condrestart >/dev/null 2>&1 || :
+    /sbin/service %{name} condrestart >/dev/null 2>&1 || :
 fi
 
 %files
 %defattr(-, root, root, -)
-%{_initddir}/deltacloud-core
+%{_initddir}/%{name}
 %{_bindir}/deltacloudd
-%dir %{geminstdir}/
-%{geminstdir}/bin
-%{geminstdir}/LICENSE
-%{geminstdir}/DISCLAIMER
-%{geminstdir}/NOTICE
-%{geminstdir}/config.ru
-%{geminstdir}/*.rb
-%{geminstdir}/Rakefile
-%{geminstdir}/views
-%{geminstdir}/lib
-%{geminstdir}/public/images
-%{geminstdir}/public/stylesheets
-%{geminstdir}/public/favicon.ico
-%{gemdir}/cache/deltacloud-core-%{version}.gem
-%{gemdir}/specifications/deltacloud-core-%{version}.gemspec
-%{geminstdir}/config/drivers.yaml
+%dir %{app_root}/
+%{app_root}/bin
+%{app_root}/config.ru
+%{app_root}/*.rb
+%{app_root}/views
+%{app_root}/lib
+%{app_root}/config
+%dir %{app_root}/public
+%{app_root}/public/images
+%{app_root}/public/stylesheets
+%{app_root}/public/favicon.ico
+%doc %{app_root}/DISCLAIMER
+%doc %{app_root}/NOTICE
+%doc %{app_root}/LICENSE
 # MIT
-%{gemdir}/gems/deltacloud-core-%{version}/public/javascripts
+%{app_root}/public/javascripts
 
 %files doc
 %defattr(-, root, root, -)
-%{gemdir}/doc/deltacloud-core-%{version}
-%{geminstdir}/tests
-%{geminstdir}/support
-%{geminstdir}/deltacloud-core.gemspec
+%{_defaultdocdir}/%{name}
+%{app_root}/tests
+%{app_root}/%{name}.gemspec
+%{app_root}/Rakefile
 
 %changelog
+* Fri May 20 2011 Michal Fojtik <mf...@redhat.com> - 0.3.0-5
+- Obsoleted rubygem-deltacloud-core
+
+* Wed May 11 2011 Michal Fojtik <mf...@redhat.com> - 0.3.0-4
+- Fixed memory calculation for RHEV-M (client)
+
+* Wed May 11 2011 Michal Fojtik <mf...@redhat.com> - 0.3.0-3
+- Fixed loadbalancer bug
+
+* Thu May 5 2011 Michal Fojtik <mf...@redhat.com> - 0.3.0-2
+- Fixed documentation generation
+- Replaced moving with copying
+- Removed support folder from doc subpackage
+
 * Fri Apr  8 2011 David Lutterkort <lu...@redhat.com> - 0.3.0-1
 - Renamed COPYING to LICENSE, include NOTICE and DISCLAIMER
 
diff --git a/server/support/fedora/deltacloudd b/server/support/fedora/deltacloudd
deleted file mode 100755
index 70be6ca..0000000
--- a/server/support/fedora/deltacloudd
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'rubygems'
-require 'optparse'
-
-# See if we can require +name+ and return +true+ if the library is there,
-# +false+ otherwise. Note that, as a side effect, the library will be
-# loaded
-def library_present?(name)
-  begin
-    require name
-    true
-  rescue LoadError
-    false
-  end
-end
-
-options = {
-  :env => 'development'
-}
-optparse = OptionParser.new do |opts|
-
-opts.banner = <<BANNER
-Usage:
-deltacloudd -i <driver> [options]
-
-Options:
-BANNER
-  opts.on( '-i', '--driver DRIVER', 'Driver to use') do |driver|
-    ENV["API_DRIVER"] = driver
-  end
-  opts.on( '-r', '--hostname HOSTNAME',
-           'Bind to HOST address (default: localhost)') do |host|
-    ENV["API_HOST"] = host
-  end
-  opts.on( '-p', '--port PORT', 'Use PORT (default: 3001)') do |port|
-    ENV["API_PORT"] = port
-  end
-  opts.on( '-P', '--provider PROVIDER', 'Use PROVIDER (default is set in the driver)') do |provider|
-    ENV['API_PROVIDER'] = provider
-  end
-  opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env] = env }
-  opts.on( '-h', '--help', '') { options[:help] = true }
-end
-
-optparse.parse!
-
-if options[:help]
- puts optparse
- exit(0)
-end
-
-unless ENV["API_DRIVER"]
-  puts "You need to specify a driver to use (-i <driver>)"
-  exit(1)
-end
-
-ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
-ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
-
-msg = "Starting Deltacloud API :: #{ENV["API_DRIVER"]} "
-msg << ":: #{ENV['API_PROVIDER']} " if ENV['API_PROVIDER']
-msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
-puts msg
-puts
-
-dirname="#{File.dirname(__FILE__)}/.."
-
-have_thin = library_present?('thin')
-have_rerun = library_present?('rerun')
-
-unless have_thin
-  require 'rack'
-
-  # We can't chdir with webrick so add our root directory
-  # onto the load path
-  $: << dirname
-
-  # Read in config.ru and convert it to an instance of Rack::Builder
-  cfgfile = File.read(File.join(dirname, 'config.ru'))
-  inner_app = eval("Rack::Builder.new {(" + cfgfile + "\n )}.to_app",
-                   nil, 'config.ru')
-
-  app = Rack::Builder.new {
-    use Rack::CommonLogger # apache-like logging
-    use Rack::Reloader if options[:env] == "development"
-    set :root, dirname # Set Sinatra root since we can't chdir to ../
-    run inner_app
-  }.to_app
-
-  # There's a bug with string ports on JRuby so convert to int
-  # http://jira.codehaus.org/browse/JRUBY-4868
-  port = ENV["API_PORT"].to_i
-
-  puts "=> Ctrl-C to shutdown server"
-  Rack::Handler::WEBrick.run(app,
-                             :Host => ENV["API_HOST"],
-                             :Port => port,
-                             :AccessLog => [])
-else
-  argv_opts = ARGV.clone
-  argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
-  argv_opts << ['--address', ENV["API_HOST"] ]
-  argv_opts << ['--port', ENV["API_PORT"] ]
-  argv_opts << ['--rackup', 'config.ru' ]
-  argv_opts << ['--chdir', dirname ]
-  argv_opts << ['-e', options[:env] ]
-  argv_opts << ['--threaded', '-D', '--stats', '/stats']
-
-  argv_opts.flatten!
-
-  if have_rerun && options[:env] == "development"
-    argv_opts.unshift "thin"
-    command = argv_opts.join(" ")
-    topdir = File::expand_path(File::join(File::dirname(__FILE__), ".."))
-    rerun = Rerun::Runner.new(command, :dir => topdir)
-    rerun.start
-    rerun.join
-  else
-    thin = Thin::Runner.new(argv_opts)
-
-    begin
-      thin.run!
-    rescue Exception => e
-      puts "ERROR: #{e.message}"
-    end
-  end
-end
diff --git a/server/support/fedora/deltacloudd-fedora b/server/support/fedora/deltacloudd-fedora
new file mode 100644
index 0000000..2afbee4
--- /dev/null
+++ b/server/support/fedora/deltacloudd-fedora
@@ -0,0 +1,5 @@
+#!/usr/bin/ruby
+
+root_path = File.join('/', 'usr', 'share', 'deltacloud-core')
+$:.unshift File.join(root_path, 'lib')
+load File.join(root_path, 'bin', 'deltacloudd')
-- 
1.7.4.4