Commit 309e5a9e authored by Vivek Das Mohapatra's avatar Vivek Das Mohapatra

Add a new none-or-some element <allowbuilddep> to project meta config

These patches merely add the new element which has no effect as of
this commit.

The new element is added to:
• the RNG xml declarations
• BSXML.pm (which serves a similar purpose for the back end code)
• bs_srcserver which supplies the parsed metadata to backend services
• the database
  ◦ initial schema (structure.sql)
  ◦ migration file
• the rails model(s)
  ◦ the project,rb model
  ◦ a new allowbuilddep.rb model for the element iteslf
  ◦ _project.xml.builder which generates XML from the database
parent e220e271
...@@ -149,6 +149,14 @@ ...@@ -149,6 +149,14 @@
</element> </element>
</define> </define>
<define ns="" name="allowbuilddep-element">
<element name="allowbuilddep">
<attribute name="name">
<data type="string" />
</attribute>
</element>
</define>
<define ns="" name="group-element"> <define ns="" name="group-element">
<element name="group"> <element name="group">
<attribute name="groupid"> <attribute name="groupid">
......
...@@ -95,6 +95,10 @@ ...@@ -95,6 +95,10 @@
</element> </element>
</optional> </optional>
<zeroOrMore>
<ref name="allowbuilddep-element"/>
</zeroOrMore>
<zeroOrMore> <zeroOrMore>
<ref name="person-element"/> <ref name="person-element"/>
</zeroOrMore> </zeroOrMore>
......
class Allowbuilddep < ActiveRecord::Base
belongs_to :project, foreign_key: :db_project_id, inverse_of: :allowbuilddeps
end
...@@ -51,6 +51,8 @@ class Project < ActiveRecord::Base ...@@ -51,6 +51,8 @@ class Project < ActiveRecord::Base
end end
has_many :attribs, :dependent => :destroy has_many :attribs, :dependent => :destroy
has_many :allowbuilddeps, :dependent => :destroy, foreign_key: :db_project_id
has_many :repositories, :dependent => :destroy, foreign_key: :db_project_id has_many :repositories, :dependent => :destroy, foreign_key: :db_project_id
has_many :repository_architectures, -> { order("position") }, through: :repositories has_many :repository_architectures, -> { order("position") }, through: :repositories
has_many :architectures, -> { order("position").distinct }, :through => :repository_architectures has_many :architectures, -> { order("position").distinct }, :through => :repository_architectures
...@@ -575,6 +577,7 @@ class Project < ActiveRecord::Base ...@@ -575,6 +577,7 @@ class Project < ActiveRecord::Base
#--- update repositories ---# #--- update repositories ---#
update_repositories(xmlhash, force) update_repositories(xmlhash, force)
#--- end update repositories ---# #--- end update repositories ---#
update_allowbuilddep_from_xml(xmlhash)
end end
def update_from_xml(xmlhash, force = nil) def update_from_xml(xmlhash, force = nil)
...@@ -584,6 +587,13 @@ class Project < ActiveRecord::Base ...@@ -584,6 +587,13 @@ class Project < ActiveRecord::Base
{ error: e.message } { error: e.message }
end end
def update_allowbuilddep_from_xml(xmlhash)
self.allowbuilddeps.destroy_all
xmlhash.elements('allowbuilddep') do |abd|
self.allowbuilddeps.create(name: abd['name'])
end
end
def update_repositories(xmlhash, force) def update_repositories(xmlhash, force)
fill_repo_cache fill_repo_cache
......
...@@ -20,6 +20,11 @@ xml.project(project_attributes) do ...@@ -20,6 +20,11 @@ xml.project(project_attributes) do
my_model.render_relationships(xml) my_model.render_relationships(xml)
adbs = my_model.allowbuilddeps.sort { |a, b| b.name <=> a.name }
adbs.each do |adb|
xml.allowbuilddep(name: adb.name)
end
repos = my_model.repositories.not_remote.sort { |a, b| b.name <=> a.name } repos = my_model.repositories.not_remote.sort { |a, b| b.name <=> a.name }
FlagHelper.flag_types.each do |flag_name| FlagHelper.flag_types.each do |flag_name|
flaglist = my_model.type_flags(flag_name) flaglist = my_model.type_flags(flag_name)
......
class CreateAllowbuilddeps < ActiveRecord::Migration
def self.up
create_table :allowbuilddeps do |t|
t.integer :db_project_id, :null => false
t.string :name, :null => false
t.index [ :db_project_id, :name ]
end
end
def self.down
drop_table :allowbuilddeps
end
end
CREATE TABLE `allowbuilddeps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`db_project_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `index_allowbuilddeps_on_db_project_id_and_name` (`db_project_id`,`name`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `architectures` ( CREATE TABLE `architectures` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 NOT NULL, `name` varchar(255) CHARACTER SET utf8 NOT NULL,
...@@ -1682,6 +1690,8 @@ INSERT INTO schema_migrations (version) VALUES ('20160518105300'); ...@@ -1682,6 +1690,8 @@ INSERT INTO schema_migrations (version) VALUES ('20160518105300');
INSERT INTO schema_migrations (version) VALUES ('20160824132643'); INSERT INTO schema_migrations (version) VALUES ('20160824132643');
INSERT INTO schema_migrations (version) VALUES ('20191011000000');
INSERT INTO schema_migrations (version) VALUES ('21'); INSERT INTO schema_migrations (version) VALUES ('21');
INSERT INTO schema_migrations (version) VALUES ('22'); INSERT INTO schema_migrations (version) VALUES ('22');
......
...@@ -115,6 +115,10 @@ our @flags = ( ...@@ -115,6 +115,10 @@ our @flags = (
[ 'access' => @disableenable ], [ 'access' => @disableenable ],
); );
our @allowbuilddep = (
[[ 'allowbuilddep' => 'name' ]],
);
our @roles = ( our @roles = (
[[ 'person' => [[ 'person' =>
'userid', 'userid',
...@@ -151,6 +155,7 @@ our $proj = [ ...@@ -151,6 +155,7 @@ our $proj = [
'project', 'project',
], ],
@roles, @roles,
@allowbuilddep,
$maintenance, $maintenance,
@flags, @flags,
[ $repo ], [ $repo ],
...@@ -292,6 +297,7 @@ our $projpack = [ ...@@ -292,6 +297,7 @@ our $projpack = [
[], [],
'title', 'title',
'description', 'description',
@allowbuilddep,
'config', 'config',
'patternmd5', 'patternmd5',
[[ 'link' => [[ 'link' =>
......
...@@ -3266,7 +3266,7 @@ sub getprojpack { ...@@ -3266,7 +3266,7 @@ sub getprojpack {
} }
next if $repoids && !grep {$repoids->{$_->{'name'}}} @{$proj->{'repository'} || []}; next if $repoids && !grep {$repoids->{$_->{'name'}}} @{$proj->{'repository'} || []};
next if $packids && !grep {$packids->{$_}} @packages; next if $packids && !grep {$packids->{$_}} @packages;
for (qw{title description build publish debuginfo useforbuild remoteurl remoteproject download link sourceaccess privacy access lock}) { for (qw{title description build publish debuginfo useforbuild remoteurl remoteproject download link sourceaccess privacy access lock allowbuilddep}) {
$jinfo->{$_} = $proj->{$_} if exists $proj->{$_}; $jinfo->{$_} = $proj->{$_} if exists $proj->{$_};
} }
if ($proj->{'access'}) { if ($proj->{'access'}) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment