Merge branch 'master' of github.com:warpc/rosa-build
This commit is contained in:
commit
1a62895fd5
|
@ -12,13 +12,13 @@ class PersonalRepositoriesController < ApplicationController
|
||||||
|
|
||||||
#TODO: Add git repo move into private repos path.
|
#TODO: Add git repo move into private repos path.
|
||||||
def change_visibility
|
def change_visibility
|
||||||
@repository.change_visibility
|
@repository.platform.change_visibility
|
||||||
|
|
||||||
redirect_to settings_personal_repository_path(@repository)
|
redirect_to settings_personal_repository_path(@repository)
|
||||||
end
|
end
|
||||||
|
|
||||||
def settings
|
def settings
|
||||||
if @repository.hidden?
|
if @repository.platform.hidden?
|
||||||
@urmpi_command = "urpmi -add http://login@password:#{ request.host }/privates/#{ @repository.platform.name }/main/"
|
@urmpi_command = "urpmi -add http://login@password:#{ request.host }/privates/#{ @repository.platform.name }/main/"
|
||||||
else
|
else
|
||||||
@urmpi_command = "urpmi -add http://#{ request.host }/downloads/#{ @repository.platform.name }/main/"
|
@urmpi_command = "urpmi -add http://#{ request.host }/downloads/#{ @repository.platform.name }/main/"
|
||||||
|
|
|
@ -13,13 +13,13 @@ module PersonalRepository
|
||||||
pl.unixname = "#{self.uname}_personal"
|
pl.unixname = "#{self.uname}_personal"
|
||||||
pl.platform_type = 'personal'
|
pl.platform_type = 'personal'
|
||||||
pl.distrib_type = 'mandriva2011'
|
pl.distrib_type = 'mandriva2011'
|
||||||
|
pl.visibility = 'open'
|
||||||
pl.save
|
pl.save
|
||||||
|
|
||||||
rep = pl.repositories.build
|
rep = pl.repositories.build
|
||||||
rep.owner = pl.owner
|
rep.owner = pl.owner
|
||||||
rep.name = 'main'
|
rep.name = 'main'
|
||||||
rep.unixname = 'main'
|
rep.unixname = 'main'
|
||||||
rep.visibility = 'open'
|
|
||||||
rep.save
|
rep.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#require 'lib/build_server.rb'
|
#require 'lib/build_server.rb'
|
||||||
class Platform < ActiveRecord::Base
|
class Platform < ActiveRecord::Base
|
||||||
|
DOWNLOADS_PATH = RAILS_ROOT + '/public/downloads'
|
||||||
VISIBILITIES = ['open', 'hidden']
|
VISIBILITIES = ['open', 'hidden']
|
||||||
|
|
||||||
relationable :as => :target
|
relationable :as => :target
|
||||||
|
|
||||||
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
|
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
|
||||||
|
@ -31,10 +33,18 @@ class Platform < ActiveRecord::Base
|
||||||
|
|
||||||
#attr_accessible :visibility
|
#attr_accessible :visibility
|
||||||
|
|
||||||
|
after_create lambda {
|
||||||
|
add_downloads_symlink unless self.hidden?
|
||||||
|
}
|
||||||
|
|
||||||
def path
|
def path
|
||||||
build_path(unixname)
|
build_path(unixname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hidden?
|
||||||
|
self.visibility == 'hidden'
|
||||||
|
end
|
||||||
|
|
||||||
def clone(new_name, new_unixname)
|
def clone(new_name, new_unixname)
|
||||||
p = Platform.new
|
p = Platform.new
|
||||||
p.name = new_name
|
p.name = new_name
|
||||||
|
@ -63,6 +73,16 @@ class Platform < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def change_visibility
|
||||||
|
if !self.hidden?
|
||||||
|
self.update_attribute(:visibility, 'hidden')
|
||||||
|
remove_downloads_symlink
|
||||||
|
else
|
||||||
|
self.update_attribute(:visibility, 'open')
|
||||||
|
add_downloads_symlink
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def build_path(dir)
|
def build_path(dir)
|
||||||
|
@ -131,4 +151,21 @@ class Platform < ActiveRecord::Base
|
||||||
BuildServer.freeze_platform self.unixname
|
BuildServer.freeze_platform self.unixname
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def symlink_downloads_path
|
||||||
|
"#{ DOWNLOADS_PATH }/#{ self.unixname }"
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_downloads_symlink
|
||||||
|
#raise "Personal platform path #{ symlink_downloads_path } already exists!" if File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path)
|
||||||
|
return true if File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path)
|
||||||
|
FileUtils.symlink path, symlink_downloads_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_downloads_symlink
|
||||||
|
#raise "Personal platform path #{ symlink_downloads_path } does not exists!" if !(File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path))
|
||||||
|
return true if !(File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path))
|
||||||
|
FileUtils.rm_rf symlink_downloads_path
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Project < ActiveRecord::Base
|
||||||
validates :owner, :presence => true
|
validates :owner, :presence => true
|
||||||
validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
|
validate {errors.add(:base, I18n.t('flash.project.save_warning_ssh_key')) if owner.ssh_key.blank?}
|
||||||
|
|
||||||
attr_accessible :category_id, :name, :unixname, :description, :visibility
|
#attr_accessible :category_id, :name, :unixname, :description, :visibility
|
||||||
attr_readonly :unixname
|
attr_readonly :unixname
|
||||||
|
|
||||||
scope :recent, order("name ASC")
|
scope :recent, order("name ASC")
|
||||||
|
@ -28,11 +28,12 @@ class Project < ActiveRecord::Base
|
||||||
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
||||||
scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") }
|
scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") }
|
||||||
|
|
||||||
before_create :create_git_repo, :make_owner_rel
|
before_create :make_owner_rel
|
||||||
before_update :update_git_repo
|
|
||||||
before_destroy :destroy_git_repo
|
|
||||||
before_create :xml_rpc_create
|
before_create :xml_rpc_create
|
||||||
before_destroy :xml_rpc_destroy
|
before_destroy :xml_rpc_destroy
|
||||||
|
before_create :create_git_repo
|
||||||
|
before_update :update_git_repo
|
||||||
|
before_destroy :destroy_git_repo
|
||||||
after_create :attach_to_personal_repository
|
after_create :attach_to_personal_repository
|
||||||
|
|
||||||
def project_versions
|
def project_versions
|
||||||
|
@ -72,7 +73,7 @@ class Project < ActiveRecord::Base
|
||||||
if result == BuildServer::SUCCESS
|
if result == BuildServer::SUCCESS
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
raise "Failed to add project #{name} to repo #{repo.name} of platform #{platf.name}."
|
raise "Failed to add project #{name} to repo #{repo.name} of platform #{platf.name} with code #{result}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ class Project < ActiveRecord::Base
|
||||||
if result == BuildServer::SUCCESS
|
if result == BuildServer::SUCCESS
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
raise "Failed to create project #{name} (repo #{repository.name}) inside platform #{repository.platform.name}."
|
raise "Failed to create project #{name} (repo #{repository.name}) inside platform #{repository.platform.name} with code #{result}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,12 +133,21 @@ class Project < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def xml_rpc_destroy
|
def xml_rpc_create
|
||||||
result = BuildServer.delete_project unixname, repository.platform.unixname
|
result = BuildServer.create_project unixname, "#{owner.uname}_personal", 'main', path
|
||||||
if result == BuildServer::SUCCESS
|
if result == BuildServer::SUCCESS
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
raise "Failed to delete repository #{name} (repo #{repository.name}) inside platform #{repository.platform.name}."
|
raise "Failed to create project #{name} (repo main) inside platform #{owner.uname}_personal with code #{result}."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def xml_rpc_destroy
|
||||||
|
result = BuildServer.delete_project unixname, "#{owner.uname}_personal"
|
||||||
|
if result == BuildServer::SUCCESS
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
raise "Failed to delete repository #{name} (repo main) inside platform #{owner.uname}_personal with code #{result}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,35 +2,59 @@ class ProjectToRepository < ActiveRecord::Base
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :repository
|
belongs_to :repository
|
||||||
|
|
||||||
before_save :create_link
|
delegate :path, :to => :project
|
||||||
after_destroy :remove_link
|
|
||||||
|
#before_save :create_link
|
||||||
|
#before_save :add_compability_link
|
||||||
|
#after_destroy :remove_link
|
||||||
|
#after_destroy :remove_compability_link
|
||||||
|
|
||||||
after_create lambda {
|
after_create lambda {
|
||||||
project.xml_rpc_create
|
project.xml_rpc_create
|
||||||
}
|
}
|
||||||
|
|
||||||
def path
|
#def path
|
||||||
build_path(project.unixname)
|
# build_path(project.unixname)
|
||||||
|
#end
|
||||||
|
|
||||||
|
# This is symbolink to /git_projects/<owner.uname>/<unixname>.git
|
||||||
|
def sym_path
|
||||||
|
"#{ repository.platform.path }/projects/#{ project.unixname }.git"
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def build_path(dir)
|
#def build_path(dir)
|
||||||
File.join(repository.path, dir)
|
# File.join(repository.path, dir)
|
||||||
end
|
#end
|
||||||
|
|
||||||
def create_link
|
#def create_link
|
||||||
exists = File.exists?(path) && File.directory?(path)
|
# exists = File.exists?(path) && File.directory?(path)
|
||||||
raise "Symlink #{path} already exists" if exists
|
# raise "Symlink #{path} already exists" if exists
|
||||||
|
# if new_record?
|
||||||
|
# FileUtils.ln_s(project.path, path)
|
||||||
|
# end
|
||||||
|
#end
|
||||||
|
#
|
||||||
|
#def remove_link
|
||||||
|
# exists = File.exists?(path) && File.directory?(path)
|
||||||
|
# raise "Directory #{path} didn't exists" unless exists
|
||||||
|
# FileUtils.rm_rf(path)
|
||||||
|
#end
|
||||||
|
|
||||||
|
def add_compability_link
|
||||||
|
exists = File.exists?(sym_path) && File.directory?(sym_path)
|
||||||
|
return false if exists
|
||||||
if new_record?
|
if new_record?
|
||||||
FileUtils.ln_s(project.path, path)
|
#FileUtils.ln_s(path, sym_path)
|
||||||
|
system("sudo ln -s #{ path } #{ sym_path }")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_link
|
def remove_compability_link
|
||||||
exists = File.exists?(path) && File.directory?(path)
|
exists = File.exists?(sym_path) && File.directory?(sym_path)
|
||||||
raise "Directory #{path} didn't exists" unless exists
|
return false unless exists
|
||||||
FileUtils.rm_rf(path)
|
#FileUtils.rm_rf(sym_path)
|
||||||
|
system("sudo rm -rf #{ sym_path }")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
class Repository < ActiveRecord::Base
|
class Repository < ActiveRecord::Base
|
||||||
|
|
||||||
DOWNLOADS_PATH = RAILS_ROOT + '/public/downloads'
|
|
||||||
|
|
||||||
VISIBILITIES = ['open', 'hidden']
|
VISIBILITIES = ['open', 'hidden']
|
||||||
relationable :as => :target
|
relationable :as => :target
|
||||||
|
|
||||||
|
@ -29,19 +27,11 @@ class Repository < ActiveRecord::Base
|
||||||
before_create :xml_rpc_create
|
before_create :xml_rpc_create
|
||||||
before_destroy :xml_rpc_destroy
|
before_destroy :xml_rpc_destroy
|
||||||
|
|
||||||
after_create lambda {
|
|
||||||
add_downloads_symlink unless self.hidden?
|
|
||||||
}
|
|
||||||
|
|
||||||
attr_accessible :visibility, :name, :unixname, :platform_id
|
attr_accessible :visibility, :name, :unixname, :platform_id
|
||||||
|
|
||||||
def path
|
# def path
|
||||||
build_path(unixname)
|
# build_path(unixname)
|
||||||
end
|
# end
|
||||||
|
|
||||||
def hidden?
|
|
||||||
self.visibility == 'hidden'
|
|
||||||
end
|
|
||||||
|
|
||||||
def clone
|
def clone
|
||||||
r = Repository.new
|
r = Repository.new
|
||||||
|
@ -51,16 +41,6 @@ class Repository < ActiveRecord::Base
|
||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_visibility
|
|
||||||
if !self.hidden?
|
|
||||||
self.update_attribute(:visibility, 'hidden')
|
|
||||||
remove_downloads_symlink
|
|
||||||
else
|
|
||||||
self.update_attribute(:visibility, 'open')
|
|
||||||
add_downloads_symlink
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def make_owner_rel
|
def make_owner_rel
|
||||||
|
@ -70,26 +50,26 @@ class Repository < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_path(dir)
|
# def build_path(dir)
|
||||||
File.join(platform.path, dir)
|
# File.join(platform.path, dir)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def create_directory
|
# def create_directory
|
||||||
exists = File.exists?(path) && File.directory?(path)
|
# exists = File.exists?(path) && File.directory?(path)
|
||||||
raise "Directory #{path} already exists" if exists
|
# raise "Directory #{path} already exists" if exists
|
||||||
if new_record?
|
# if new_record?
|
||||||
FileUtils.mkdir_p(path)
|
# FileUtils.mkdir_p(path)
|
||||||
%w(release updates).each { |subrep| FileUtils.mkdir_p(path + subrep) }
|
# %w(release updates).each { |subrep| FileUtils.mkdir_p(path + subrep) }
|
||||||
elsif unixname_changed?
|
# elsif unixname_changed?
|
||||||
FileUtils.mv(build_path(unixname_was), buildpath(unixname))
|
# FileUtils.mv(build_path(unixname_was), buildpath(unixname))
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
def remove_directory
|
# def remove_directory
|
||||||
exists = File.exists?(path) && File.directory?(path)
|
# exists = File.exists?(path) && File.directory?(path)
|
||||||
raise "Directory #{path} didn't exists" unless exists
|
# raise "Directory #{path} didn't exists" unless exists
|
||||||
FileUtils.rm_rf(path)
|
# FileUtils.rm_rf(path)
|
||||||
end
|
# end
|
||||||
|
|
||||||
def xml_rpc_create
|
def xml_rpc_create
|
||||||
result = BuildServer.create_repo unixname, platform.unixname
|
result = BuildServer.create_repo unixname, platform.unixname
|
||||||
|
@ -109,20 +89,4 @@ class Repository < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def symlink_downloads_path
|
|
||||||
"#{ DOWNLOADS_PATH }/#{ self.platform.unixname }"
|
|
||||||
end
|
|
||||||
|
|
||||||
def add_downloads_symlink
|
|
||||||
#raise "Personal platform path #{ symlink_downloads_path } already exists!" if File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path)
|
|
||||||
return true if File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path)
|
|
||||||
FileUtils.symlink platform.path, symlink_downloads_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def remove_downloads_symlink
|
|
||||||
#raise "Personal platform path #{ symlink_downloads_path } does not exists!" if !(File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path))
|
|
||||||
return true if !(File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path))
|
|
||||||
FileUtils.rm_rf symlink_downloads_path
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
.group
|
.group
|
||||||
%span= t("activerecord.attributes.repository.visibility") + ":"
|
%span= t("activerecord.attributes.repository.visibility") + ":"
|
||||||
%span
|
%span
|
||||||
%i= t("activerecord.attributes.repository.visibility_types.#{ @repository.visibility }")
|
%i= t("activerecord.attributes.repository.visibility_types.#{ @repository.platform.visibility }")
|
||||||
.group
|
.group
|
||||||
= link_to t("layout.personal_repositories.change_visibility_from_#{ @repository.visibility }"), change_visibility_personal_repository_path(@repository)
|
= link_to t("layout.personal_repositories.change_visibility_from_#{ @repository.platform.visibility }"), change_visibility_personal_repository_path(@repository)
|
||||||
|
|
||||||
%br
|
%br
|
||||||
.group
|
.group
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class RemoveVisibilityFromRepositories < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
remove_column :repositories, :visibility
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
add_column :repositories, :visibility, :string, :default => "open"
|
||||||
|
end
|
||||||
|
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20111027230610) do
|
ActiveRecord::Schema.define(:version => 20111028070604) do
|
||||||
|
|
||||||
create_table "arches", :force => true do |t|
|
create_table "arches", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
|
@ -208,20 +208,18 @@ ActiveRecord::Schema.define(:version => 20111027230610) do
|
||||||
t.string "object_type"
|
t.string "object_type"
|
||||||
t.integer "target_id"
|
t.integer "target_id"
|
||||||
t.string "target_type"
|
t.string "target_type"
|
||||||
t.integer "role_id"
|
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "repositories", :force => true do |t|
|
create_table "repositories", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
t.integer "platform_id", :null => false
|
t.integer "platform_id", :null => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "unixname", :null => false
|
t.string "unixname", :null => false
|
||||||
t.integer "owner_id"
|
t.integer "owner_id"
|
||||||
t.string "owner_type"
|
t.string "owner_type"
|
||||||
t.string "visibility", :default => "open"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "rights", :force => true do |t|
|
create_table "rights", :force => true do |t|
|
||||||
|
@ -271,9 +269,8 @@ ActiveRecord::Schema.define(:version => 20111027230610) do
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "uname"
|
|
||||||
t.text "ssh_key"
|
t.text "ssh_key"
|
||||||
t.integer "role_id"
|
t.string "uname"
|
||||||
t.integer "global_role_id"
|
t.integer "global_role_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ class BuildServer
|
||||||
self.client.call('delete_container', container_id)
|
self.client.call('delete_container', container_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_project name, platform_name, repo_name
|
def self.create_project name, platform_name, repo_name, git_project_path
|
||||||
self.client.call('create_project', name, repo_name, platform_name)
|
self.client.call('create_project', name, repo_name, platform_name, git_project_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_project name, platform_name
|
def self.delete_project name, platform_name
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/var/rosa/platforms/test2_personal
|
Loading…
Reference in New Issue