diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /app/models/packages/debian | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'app/models/packages/debian')
-rw-r--r-- | app/models/packages/debian/file_metadatum.rb | 56 | ||||
-rw-r--r-- | app/models/packages/debian/group_architecture.rb | 9 | ||||
-rw-r--r-- | app/models/packages/debian/group_distribution.rb | 9 | ||||
-rw-r--r-- | app/models/packages/debian/project_architecture.rb | 9 | ||||
-rw-r--r-- | app/models/packages/debian/project_distribution.rb | 9 |
5 files changed, 92 insertions, 0 deletions
diff --git a/app/models/packages/debian/file_metadatum.rb b/app/models/packages/debian/file_metadatum.rb new file mode 100644 index 00000000000..7c9f4f5f3f1 --- /dev/null +++ b/app/models/packages/debian/file_metadatum.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +class Packages::Debian::FileMetadatum < ApplicationRecord + belongs_to :package_file, inverse_of: :debian_file_metadatum + + validates :package_file, presence: true + validate :valid_debian_package_type + + enum file_type: { + unknown: 1, source: 2, dsc: 3, deb: 4, udeb: 5, buildinfo: 6, changes: 7 + } + + validates :file_type, presence: true + validates :file_type, inclusion: { in: %w[unknown] }, if: -> { package_file&.package&.debian_incoming? } + validates :file_type, + inclusion: { in: %w[source dsc deb udeb buildinfo changes] }, + if: -> { package_file&.package&.debian_package? } + + validates :component, + presence: true, + format: { with: Gitlab::Regex.debian_component_regex }, + if: :requires_component? + validates :component, absence: true, unless: :requires_component? + + validates :architecture, + presence: true, + format: { with: Gitlab::Regex.debian_architecture_regex }, + if: :requires_architecture? + validates :architecture, absence: true, unless: :requires_architecture? + + validates :fields, + presence: true, + json_schema: { filename: "debian_fields" }, + if: :requires_fields? + validates :fields, absence: true, unless: :requires_fields? + + private + + def valid_debian_package_type + return if package_file&.package&.debian? + + errors.add(:package_file, _('Package type must be Debian')) + end + + def requires_architecture? + deb? || udeb? + end + + def requires_component? + source? || dsc? || requires_architecture? || buildinfo? + end + + def requires_fields? + dsc? || requires_architecture? || buildinfo? || changes? + end +end diff --git a/app/models/packages/debian/group_architecture.rb b/app/models/packages/debian/group_architecture.rb new file mode 100644 index 00000000000..570f6accd3c --- /dev/null +++ b/app/models/packages/debian/group_architecture.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Packages::Debian::GroupArchitecture < ApplicationRecord + def self.container_type + :group + end + + include Packages::Debian::Architecture +end diff --git a/app/models/packages/debian/group_distribution.rb b/app/models/packages/debian/group_distribution.rb new file mode 100644 index 00000000000..eea7acacc96 --- /dev/null +++ b/app/models/packages/debian/group_distribution.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Packages::Debian::GroupDistribution < ApplicationRecord + def self.container_type + :group + end + + include Packages::Debian::Distribution +end diff --git a/app/models/packages/debian/project_architecture.rb b/app/models/packages/debian/project_architecture.rb new file mode 100644 index 00000000000..44a38dfaf44 --- /dev/null +++ b/app/models/packages/debian/project_architecture.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Packages::Debian::ProjectArchitecture < ApplicationRecord + def self.container_type + :project + end + + include Packages::Debian::Architecture +end diff --git a/app/models/packages/debian/project_distribution.rb b/app/models/packages/debian/project_distribution.rb new file mode 100644 index 00000000000..a73c12d172d --- /dev/null +++ b/app/models/packages/debian/project_distribution.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class Packages::Debian::ProjectDistribution < ApplicationRecord + def self.container_type + :project + end + + include Packages::Debian::Distribution +end |