#--
# Copyright (c) 2009, 2010 Novell, Inc.
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#++
#
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))
$:.unshift File.join(File.dirname(__FILE__), "..", "webyast-tasks", "lib")


require 'rake'
require 'rake/testtask'
require 'rdoc/task'

#include in doc:app also shared test enhancements for plugins
#FIXME find way how to change original rails task app:doc we only need include some files to it
namespace :doc do
  Rake::RDocTask.new("app") { |rdoc|
    rdoc.rdoc_dir = 'doc/app'
    rdoc.title    = "Rails Application Documentation"
    rdoc.options << '--line-numbers' << '--inline-source'
    rdoc.rdoc_files.include('doc/README_FOR_APP')
    rdoc.rdoc_files.include('app/**/*.rb')
    rdoc.rdoc_files.include('lib/**/*.rb')
#include shared test functionality in documentation
    rdoc.rdoc_files.include('test/plugin_basic_tests.rb')
  }
end

# load the shared rake files from the package itself
# skip 'deploy_local' task, it's redefined here
require 'tasks/webyast_tasks'
WebyastTasks.loadTasks(:exclude => ["deploy_local.rake"])

# this call also loads WebyastTasks but the second call is ignored there
# so this 'require' must be called _after_ WebyastTasks.loadTasks
require File.expand_path('../config/application', __FILE__)
Webyast::Application.load_tasks #   <<<< = require 'tasks/rails'


require 'fileutils'

desc "Deploy for development - create basic dirs and install grantwebyastrights."
task :deploy_local do
  FileUtils.mkdir_p "/etc/webyast"
  FileUtils.mkdir_p "/var/lib/webyast"
  FileUtils.mkdir_p "/usr/share/webyast"
  FileUtils.mkdir_p "/var/log/webyast"
  FileUtils.install "package/grantwebyastrights", "/usr/sbin", :mode => 0555
  mkdir_p "/etc/dbus-1/system.d/"
  cp_r    "package/webyast.permissions.conf", "/etc/dbus-1/system.d/"
  cp_r    "package/webyastPermissionsService.rb", "/usr/sbin/"
  chmod  0744, "/usr/sbin/webyastPermissionsService.rb"
  mkdir_p "/usr/share/dbus-1/system-services/"
  cp_r    "package/webyast.permissions.service.service", "/usr/share/dbus-1/system-services/"
  Rake::Task['install_policies'].invoke
end

