From 22dd63b851b41f38193b5c8f60c58364582b46ec Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 21 Jan 2021 14:12:46 +0100 Subject: [PATCH 01/11] Debian CRUD group distribution endpoints Create/Read/Update/Delete group distributions --- app/policies/group_policy.rb | 2 ++ lib/api/debian_group_packages.rb | 7 ++++ .../api/debian_group_packages_spec.rb | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index ba06b98e906600..5f8e9dcd14ec67 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -117,6 +117,7 @@ class GroupPolicy < BasePolicy enable :delete_metrics_dashboard_annotation enable :update_metrics_dashboard_annotation enable :create_custom_emoji + enable :create_package enable :create_package_settings end @@ -134,6 +135,7 @@ class GroupPolicy < BasePolicy end rule { maintainer }.policy do + enable :destroy_package enable :create_projects enable :admin_pipeline enable :admin_build diff --git a/lib/api/debian_group_packages.rb b/lib/api/debian_group_packages.rb index c6116a8b28f4c4..ff8a2ae94c19b5 100644 --- a/lib/api/debian_group_packages.rb +++ b/lib/api/debian_group_packages.rb @@ -24,6 +24,13 @@ class DebianGroupPackages < ::API::Base end namespace ':id/-' do + helpers do + def project_or_group + user_group + end + end + + include ::API::Concerns::Packages::DebianDistributionEndpoints include ::API::Concerns::Packages::DebianPackageEndpoints end end diff --git a/spec/requests/api/debian_group_packages_spec.rb b/spec/requests/api/debian_group_packages_spec.rb index c3abb06c5c170e..6e9d185ddbbd86 100644 --- a/spec/requests/api/debian_group_packages_spec.rb +++ b/spec/requests/api/debian_group_packages_spec.rb @@ -6,6 +6,41 @@ include WorkhorseHelpers include_context 'Debian repository shared context', :group, false do + describe 'POST groups/:id/-/debian_distributions' do + let(:method) { :post } + let(:url) { "/groups/#{container.id}/-/debian_distributions" } + let(:api_params) { { 'codename': 'my-codename' } } + + it_behaves_like 'Debian repository write endpoint', 'POST distribution request', :created, /^{.*"codename":"my-codename",.*"components":\["main"\],.*"architectures":\["all","amd64"\]/, authenticate_non_public: false + end + + describe 'GET groups/:id/-/debian_distributions' do + let(:url) { "/groups/#{container.id}/-/debian_distributions" } + + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^\[{.*"codename":"existing-codename",.*"components":\["existing-component"\],.*"architectures":\["all","existing-arch"\]/, authenticate_non_public: false + end + + describe 'GET groups/:id/-/debian_distributions/:codename' do + let(:url) { "/groups/#{container.id}/-/debian_distributions/#{distribution.codename}" } + + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^{.*"codename":"existing-codename",.*"components":\["existing-component"\],.*"architectures":\["all","existing-arch"\]/, authenticate_non_public: false + end + + describe 'PUT groups/:id/-/debian_distributions/:codename' do + let(:method) { :put } + let(:url) { "/groups/#{container.id}/-/debian_distributions/#{distribution.codename}" } + let(:api_params) { { suite: 'my-suite' } } + + it_behaves_like 'Debian repository write endpoint', 'PUT distribution request', :success, /^{.*"codename":"existing-codename",.*"suite":"my-suite",/, authenticate_non_public: false + end + + describe 'DELETE groups/:id/-/debian_distributions/:codename' do + let(:method) { :delete } + let(:url) { "/groups/#{container.id}/-/debian_distributions/#{distribution.codename}" } + + it_behaves_like 'Debian repository maintainer write endpoint', 'DELETE distribution request', :success, /^{"message":"202 Accepted"}$/, authenticate_non_public: false + end + describe 'GET groups/:id/-/packages/debian/dists/*distribution/Release.gpg' do let(:url) { "/groups/#{container.id}/-/packages/debian/dists/#{distribution.codename}/Release.gpg" } -- GitLab From a22d0fffc74a25f486809b02ba944025bab6b285 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Sat, 23 Jan 2021 14:17:15 +0100 Subject: [PATCH 02/11] Add Debian API endpoint for {In,}Release files --- .../packages/debian_package_endpoints.rb | 17 ++++++++++++++--- spec/requests/api/debian_group_packages_spec.rb | 4 ++-- .../api/debian_project_packages_spec.rb | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/api/concerns/packages/debian_package_endpoints.rb b/lib/api/concerns/packages/debian_package_endpoints.rb index c79ae3068b4533..7609f84e909d43 100644 --- a/lib/api/concerns/packages/debian_package_endpoints.rb +++ b/lib/api/concerns/packages/debian_package_endpoints.rb @@ -40,6 +40,18 @@ module DebianPackageEndpoints .sent_through(:http_basic_auth) end + helpers do + def present_release_file + distribution = ::Packages::Debian::DistributionsFinder.new(project_or_group, codename_or_suite: params[:distribution]).execute.last! + + if distribution.needs_update? + ::Packages::Debian::GenerateDistributionService.new(distribution).execute + end + + present_carrierwave_file!(distribution.file) + end + end + format :txt content_type :txt, 'text/plain' @@ -65,8 +77,7 @@ module DebianPackageEndpoints route_setting :authentication, authenticate_non_public: true get 'Release' do - # https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286 - 'TODO Release' + present_release_file end # GET {projects|groups}/:id/packages/debian/dists/*distribution/InRelease @@ -76,7 +87,7 @@ module DebianPackageEndpoints route_setting :authentication, authenticate_non_public: true get 'InRelease' do - not_found! + present_release_file end params do diff --git a/spec/requests/api/debian_group_packages_spec.rb b/spec/requests/api/debian_group_packages_spec.rb index 6e9d185ddbbd86..f1c7777f352760 100644 --- a/spec/requests/api/debian_group_packages_spec.rb +++ b/spec/requests/api/debian_group_packages_spec.rb @@ -50,13 +50,13 @@ describe 'GET groups/:id/-/packages/debian/dists/*distribution/Release' do let(:url) { "/groups/#{container.id}/-/packages/debian/dists/#{distribution.codename}/Release" } - it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^TODO Release$/ + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^Codename: existing-codename\nDate: .*\nArchitectures: all existing-arch\nComponents: existing-component\nMD5Sum:\n / end describe 'GET groups/:id/-/packages/debian/dists/*distribution/InRelease' do let(:url) { "/groups/#{container.id}/-/packages/debian/dists/#{distribution.codename}/InRelease" } - it_behaves_like 'Debian repository read endpoint', 'GET request', :not_found + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^Codename: existing-codename\nDate: .*\nArchitectures: all existing-arch\nComponents: existing-component\nMD5Sum:\n / end describe 'GET groups/:id/-/packages/debian/dists/*distribution/:component/binary-:architecture/Packages' do diff --git a/spec/requests/api/debian_project_packages_spec.rb b/spec/requests/api/debian_project_packages_spec.rb index c11c4ecc12a642..509173aaaa5a9e 100644 --- a/spec/requests/api/debian_project_packages_spec.rb +++ b/spec/requests/api/debian_project_packages_spec.rb @@ -15,13 +15,13 @@ describe 'GET projects/:id/packages/debian/dists/*distribution/Release' do let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/Release" } - it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^TODO Release$/ + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^Codename: existing-codename\nDate: .*\nArchitectures: all existing-arch\nComponents: existing-component\nMD5Sum:\n / end describe 'GET projects/:id/packages/debian/dists/*distribution/InRelease' do let(:url) { "/projects/#{container.id}/packages/debian/dists/#{distribution.codename}/InRelease" } - it_behaves_like 'Debian repository read endpoint', 'GET request', :not_found + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^Codename: existing-codename\nDate: .*\nArchitectures: all existing-arch\nComponents: existing-component\nMD5Sum:\n / end describe 'GET projects/:id/packages/debian/dists/*distribution/:component/binary-:architecture/Packages' do -- GitLab From 477911a978d735ef14eef76c2a334b2791582ab2 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Tue, 26 Jan 2021 12:59:31 +0100 Subject: [PATCH 03/11] Add Debian API endpoint for Packages files --- .../packages/debian_package_endpoints.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/api/concerns/packages/debian_package_endpoints.rb b/lib/api/concerns/packages/debian_package_endpoints.rb index 7609f84e909d43..412640b27b576d 100644 --- a/lib/api/concerns/packages/debian_package_endpoints.rb +++ b/lib/api/concerns/packages/debian_package_endpoints.rb @@ -103,8 +103,20 @@ def present_release_file route_setting :authentication, authenticate_non_public: true get 'Packages' do - # https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286 - 'TODO Packages' + relation = "::Packages::Debian::#{project_or_group.class.name}ComponentFile".constantize + + component_file = relation + .preload_distribution + .with_container(project_or_group) + .with_codename_or_suite(params[:distribution]) + .with_component_name(params[:component]) + .with_file_type(:packages) + .with_architecture_name(params[:architecture]) + .with_compression_type(nil) + .order_created_asc + .last! + + present_carrierwave_file!(component_file.file) end end end -- GitLab From 25c0bd13e5d3ed9831abf78560806950513d4a1b Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Thu, 28 Jan 2021 12:00:25 +0100 Subject: [PATCH 04/11] Add Debian API endpoint for deb, udeb, ... files --- .../packages/debian_package_endpoints.rb | 29 +++++++++++++++---- .../api/debian_group_packages_spec.rb | 21 ++++++++++++-- .../api/debian_project_packages_spec.rb | 21 ++++++++++++-- .../api/debian_packages_shared_examples.rb | 4 +++ 4 files changed, 64 insertions(+), 11 deletions(-) diff --git a/lib/api/concerns/packages/debian_package_endpoints.rb b/lib/api/concerns/packages/debian_package_endpoints.rb index 412640b27b576d..2191111c172d87 100644 --- a/lib/api/concerns/packages/debian_package_endpoints.rb +++ b/lib/api/concerns/packages/debian_package_endpoints.rb @@ -122,13 +122,14 @@ def present_release_file end params do - requires :component, type: String, desc: 'The Debian Component', regexp: Gitlab::Regex.debian_component_regex + requires :codename, type: String, desc: 'The Debian Distribution Codename', regexp: Gitlab::Regex.debian_distribution_regex + requires :project_id, type: Integer, desc: 'The Debian Project Distribution Id' requires :letter, type: String, desc: 'The Debian Classification (first-letter or lib-first-letter)' requires :source_package, type: String, desc: 'The Debian Source Package Name', regexp: Gitlab::Regex.debian_package_name_regex end - namespace 'pool/:component/:letter/:source_package', requirements: COMPONENT_LETTER_SOURCE_PACKAGE_REQUIREMENTS do - # GET {projects|groups}/:id/packages/debian/pool/:component/:letter/:source_package/:file_name + namespace 'pool/:codename/:project_id/:letter/:source_package', requirements: COMPONENT_LETTER_SOURCE_PACKAGE_REQUIREMENTS do + # GET {projects|groups}/:id/packages/debian/pool/:codename/:project_id/:letter/:source_package/:file_name params do requires :file_name, type: String, desc: 'The Debian File Name' end @@ -138,8 +139,26 @@ def present_release_file route_setting :authentication, authenticate_non_public: true get ':file_name', requirements: FILE_NAME_REQUIREMENTS do - # https://gitlab.com/gitlab-org/gitlab/-/issues/5835#note_414103286 - 'TODO File' + not_found! unless params[:source_package].start_with?(params[:letter]) + + distribution = ::Packages::Debian::DistributionsFinder.new(project_or_group, codename: params[:codename]).execute.last! + + case project_or_group + when Project + not_found! unless project_or_group.id == params[:project_id] + + project = distribution.project + else + project = ProjectsFinder.new(current_user: current_user, project_ids_relation: params[:project_id]) + .execute + .for_group_and_its_subgroups(project_or_group) + .last! + end + + package = project.packages.debian.with_name(params[:source_package]).last! + package_file = package.package_files.with_file_name(params[:file_name]).last! + + present_carrierwave_file!(package_file.file) end end end diff --git a/spec/requests/api/debian_group_packages_spec.rb b/spec/requests/api/debian_group_packages_spec.rb index f1c7777f352760..8789997b555abb 100644 --- a/spec/requests/api/debian_group_packages_spec.rb +++ b/spec/requests/api/debian_group_packages_spec.rb @@ -65,10 +65,25 @@ it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^TODO Packages$/ end - describe 'GET groups/:id/-/packages/debian/pool/:component/:letter/:source_package/:file_name' do - let(:url) { "/groups/#{container.id}/-/packages/debian/pool/#{component}/#{letter}/#{source_package}/#{package_name}_#{package_version}_#{architecture}.deb" } + describe 'GET groups/:id/-/packages/debian/pool/:codename/:project_id/:letter/:source_package/:file_name' do + let(:url) { "/groups/#{container.id}/-/packages/debian/pool/#{package.debian_distribution.codename}/#{project.id}/#{letter}/#{package.name}/#{file_name}" } - it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^TODO File$/ + using RSpec::Parameterized::TableSyntax + + where(:file_name, :success_body) do + 'sample_1.2.3~alpha2.tar.xz' | /^.7zXZ/ + 'sample_1.2.3~alpha2.dsc' | /^Format: 3.0 \(native\)/ + 'libsample0_1.2.3~alpha2_amd64.deb' | /^!/ + 'sample-udeb_1.2.3~alpha2_amd64.udeb' | /^!/ + 'sample_1.2.3~alpha2_amd64.buildinfo' | /Build-Tainted-By/ + 'sample_1.2.3~alpha2_amd64.changes' | /urgency=medium/ + end + + with_them do + include_context 'with file_name', params[:file_name] + + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, params[:success_body] + end end end end diff --git a/spec/requests/api/debian_project_packages_spec.rb b/spec/requests/api/debian_project_packages_spec.rb index 509173aaaa5a9e..9c390a87569f8b 100644 --- a/spec/requests/api/debian_project_packages_spec.rb +++ b/spec/requests/api/debian_project_packages_spec.rb @@ -30,10 +30,25 @@ it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^TODO Packages$/ end - describe 'GET projects/:id/packages/debian/pool/:component/:letter/:source_package/:file_name' do - let(:url) { "/projects/#{container.id}/packages/debian/pool/#{component}/#{letter}/#{source_package}/#{package_name}_#{package_version}_#{architecture}.deb" } + describe 'GET projects/:id/packages/debian/pool/:codename/:project_id/:letter/:source_package/:file_name' do + let(:url) { "/projects/#{container.id}/packages/debian/pool/#{package.debian_distribution.codename}/#{container.id}/#{letter}/#{package.name}/#{file_name}" } + + using RSpec::Parameterized::TableSyntax + + where(:file_name, :success_body) do + 'sample_1.2.3~alpha2.tar.xz' | /^.7zXZ/ + 'sample_1.2.3~alpha2.dsc' | /^Format: 3.0 \(native\)/ + 'libsample0_1.2.3~alpha2_amd64.deb' | /^!/ + 'sample-udeb_1.2.3~alpha2_amd64.udeb' | /^!/ + 'sample_1.2.3~alpha2_amd64.buildinfo' | /Build-Tainted-By/ + 'sample_1.2.3~alpha2_amd64.changes' | /urgency=medium/ + end + + with_them do + include_context 'with file_name', params[:file_name] - it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^TODO File$/ + it_behaves_like 'Debian repository read endpoint', 'GET request', :success, params[:success_body] + end end describe 'PUT projects/:id/packages/debian/:file_name' do diff --git a/spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb b/spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb index 0530aa8c760ac2..6cd9eb6959db15 100644 --- a/spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb @@ -91,6 +91,10 @@ end end +RSpec.shared_context 'with file_name' do |file_name| + let(:file_name) { file_name } +end + RSpec.shared_context 'Debian repository auth headers' do |user_role, user_token, auth_method = :token| let(:token) { user_token ? personal_access_token.token : 'wrong' } -- GitLab From 717d53fc89e69fecd9598dddfd9cdbdd0d9fbed7 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Tue, 26 Jan 2021 17:27:47 +0100 Subject: [PATCH 05/11] Add doc for Debian distributions APIs --- doc/api/api_resources.md | 2 + doc/api/debian_group_distributions.md | 217 ++++++++++++++++++++++++ doc/api/debian_project_distributions.md | 217 ++++++++++++++++++++++++ 3 files changed, 436 insertions(+) create mode 100644 doc/api/debian_group_distributions.md create mode 100644 doc/api/debian_project_distributions.md diff --git a/doc/api/api_resources.md b/doc/api/api_resources.md index 9200d47effe2ce..b1d64d098480f2 100644 --- a/doc/api/api_resources.md +++ b/doc/api/api_resources.md @@ -34,6 +34,7 @@ The following API resources are available in the project context: | [Dependencies](dependencies.md) **(ULTIMATE)** | `/projects/:id/dependencies` | | [Deploy keys](deploy_keys.md) | `/projects/:id/deploy_keys` (also available standalone) | | [Freeze Periods](freeze_periods.md) | `/projects/:id/freeze_periods` | +| [Debian distributions](debian_project_distributions.md) | `/projects/:id/debian_distributions` (also available for groups) | | [Deployments](deployments.md) | `/projects/:id/deployments` | | [Discussions](discussions.md) (threaded comments) | `/projects/:id/issues/.../discussions`, `/projects/:id/snippets/.../discussions`, `/projects/:id/merge_requests/.../discussions`, `/projects/:id/commits/.../discussions` (also available for groups) | | [Environments](environments.md) | `/projects/:id/environments` | @@ -99,6 +100,7 @@ The following API resources are available in the group context: |:-----------------------------------------------------------------|:---------------------------------------------------------------------------------| | [Access requests](access_requests.md) | `/groups/:id/access_requests/` (also available for projects) | | [Custom attributes](custom_attributes.md) | `/groups/:id/custom_attributes` (also available for projects and users) | +| [Debian distributions](debian_group_distributions.md) | `/groups/:id/debian_distributions` (also available for projects) | | [Discussions](discussions.md) (threaded comments) **(ULTIMATE)** | `/groups/:id/epics/.../discussions` (also available for projects) | | [Epic issues](epic_issues.md) **(ULTIMATE)** | `/groups/:id/epics/.../issues` | | [Epic links](epic_links.md) **(ULTIMATE)** | `/groups/:id/epics/.../epics` | diff --git a/doc/api/debian_group_distributions.md b/doc/api/debian_group_distributions.md new file mode 100644 index 00000000000000..9756b0afe66a53 --- /dev/null +++ b/doc/api/debian_group_distributions.md @@ -0,0 +1,217 @@ +--- +stage: Package +group: Package +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Debian group distributions API + +## Enable Debian repository feature + +Debian repository support is gated behind a feature flag that is **disabled by default**. +[GitLab administrators with access to the GitLab Rails console](../administration/feature_flags.md) +can opt to disable it. + +To enable it: + +```ruby +Feature.enable(:debian_packages) +``` + +To disable it: + +```ruby +Feature.disable(:debian_packages) +``` + +## List all Debian distributions in a group + +Lists Debian distributions in the given group. + +```plaintext +GET /groups/:id/debian_distributions +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) | +| `codename` | string | no | Filter with specific `codename` | +| `suite` | string | no | Filter with specific `suite` | + +```shell +curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/5/debian_distributions" +``` + +Example response: + +```json +[ + { + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] + } +] +``` + +## Single Debian group distribution + +Gets a single Debian group distribution. + +```plaintext +GET /groups/:id/debian_distributions/:codename +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | integer | yes | The `codename` of a distribution | + +```shell +curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/5/debian_distributions/unstable" +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +## Create a Debian group distribution + +Creates a Debian group distribution. + +```plaintext +POST /groups/:id/debian_distributions +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | string | yes | The *codename* of a Debian distribution | +| `suite` | string | no | The *suite* of the new Debian distribution | +| `origin` | string | no | The *origin* of the new Debian distribution | +| `label` | string | no | The *label* of the new Debian distribution | +| `version` | string | no | The *version* of the new Debian distribution | +| `description` | string | no | The *description* of the new Debian distribution | +| `valid_time_duration_seconds` | integer | no | The *valid_time_duration_seconds* of the new Debian distribution | +| `components` | architectures | no | The list of *components* of the new Debian distribution | +| `architectures` | architectures | no | The list of *architectures* of the new Debian distribution | + +```shell +curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/5/debian_distributions?codename=unstable" +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +## Update a Debian group distribution + +Updates a Debian group distribution. + +```plaintext +PUT /groups/:id/debian_distributions/:codename +``` + +| Attribute | Type | Required | Description | +| ----------------------------- | -------------- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | string | yes | The *codename* of a Debian distribution | +| `suite` | string | no | The new *suite* of the Debian distribution | +| `origin` | string | no | The new *origin* of the Debian distribution | +| `label` | string | no | The new *label* of the Debian distribution | +| `version` | string | no | The new *version* of the Debian distribution | +| `description` | string | no | The new *description* of the Debian distribution | +| `valid_time_duration_seconds` | integer | no | The new *valid_time_duration_seconds* of the Debian distribution | +| `components` | architectures | no | The new list of *components* of the Debian distribution | +| `architectures` | architectures | no | The new list of *architectures* of the Debian distribution | + +```shell +curl --request PUT --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/5/debian_distributions/unstable?suite=new-suite&valid_time_duration_seconds=604800" +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": "new-suite", + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": 604800, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +## Delete a Debian group distribution + +Deletes a Debian group distribution. + +```plaintext +DELETE /groups/:id/debian_distributions/:codename +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | integer | yes | The *codename* of a Debian distribution | + +```shell +curl --request DELETE --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/5/debian_distributions/unstable" +``` diff --git a/doc/api/debian_project_distributions.md b/doc/api/debian_project_distributions.md new file mode 100644 index 00000000000000..e7e05194803858 --- /dev/null +++ b/doc/api/debian_project_distributions.md @@ -0,0 +1,217 @@ +--- +stage: Package +project: Package +info: To determine the technical writer assigned to the Stage/Project associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Debian project distributions API + +## Enable Debian repository feature + +Debian repository support is gated behind a feature flag that is **disabled by default**. +[GitLab administrators with access to the GitLab Rails console](../administration/feature_flags.md) +can opt to disable it. + +To enable it: + +```ruby +Feature.enable(:debian_packages) +``` + +To disable it: + +```ruby +Feature.disable(:debian_packages) +``` + +## List all Debian distributions in a project + +Lists Debian distributions in the given project. + +```plaintext +GET /projects/:id/debian_distributions +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) | +| `codename` | string | no | Filter with specific `codename` | +| `suite` | string | no | Filter with specific `suite` | + +```shell +curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/debian_distributions" +``` + +Example response: + +```json +[ + { + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] + } +] +``` + +## Single Debian project distribution + +Gets a single Debian project distribution. + +```plaintext +GET /projects/:id/debian_distributions/:codename +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | integer | yes | The `codename` of a distribution | + +```shell +curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/debian_distributions/unstable" +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +## Create a Debian project distribution + +Creates a Debian project distribution. + +```plaintext +POST /projects/:id/debian_distributions +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | string | yes | The *codename* of a Debian distribution | +| `suite` | string | no | The *suite* of the new Debian distribution | +| `origin` | string | no | The *origin* of the new Debian distribution | +| `label` | string | no | The *label* of the new Debian distribution | +| `version` | string | no | The *version* of the new Debian distribution | +| `description` | string | no | The *description* of the new Debian distribution | +| `valid_time_duration_seconds` | integer | no | The *valid_time_duration_seconds* of the new Debian distribution | +| `components` | architectures | no | The list of *components* of the new Debian distribution | +| `architectures` | architectures | no | The list of *architectures* of the new Debian distribution | + +```shell +curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/debian_distributions?codename=unstable" +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +## Update a Debian project distribution + +Updates a Debian project distribution. + +```plaintext +PUT /projects/:id/debian_distributions/:codename +``` + +| Attribute | Type | Required | Description | +| ----------------------------- | -------------- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | string | yes | The *codename* of a Debian distribution | +| `suite` | string | no | The new *suite* of the Debian distribution | +| `origin` | string | no | The new *origin* of the Debian distribution | +| `label` | string | no | The new *label* of the Debian distribution | +| `version` | string | no | The new *version* of the Debian distribution | +| `description` | string | no | The new *description* of the Debian distribution | +| `valid_time_duration_seconds` | integer | no | The new *valid_time_duration_seconds* of the Debian distribution | +| `components` | architectures | no | The new list of *components* of the Debian distribution | +| `architectures` | architectures | no | The new list of *architectures* of the Debian distribution | + +```shell +curl --request PUT --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/debian_distributions/unstable?suite=new-suite&valid_time_duration_seconds=604800" +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": "new-suite", + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": 604800, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +## Delete a Debian project distribution + +Deletes a Debian project distribution. + +```plaintext +DELETE /projects/:id/debian_distributions/:codename +``` + +| Attribute | Type | Required | Description | +| --------- | ---- | -------- | ----------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `codename` | integer | yes | The *codename* of a Debian distribution | + +```shell +curl --request DELETE --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/debian_distributions/unstable" +``` -- GitLab From 22caacff03055345a3c3c2b50354c670d9647889 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Tue, 26 Jan 2021 21:00:13 +0100 Subject: [PATCH 06/11] Initial "Debian packages in the Package Registry" documentation --- doc/user/packages/debian_repository/index.md | 124 +++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 doc/user/packages/debian_repository/index.md diff --git a/doc/user/packages/debian_repository/index.md b/doc/user/packages/debian_repository/index.md new file mode 100644 index 00000000000000..557ee5c7dfdead --- /dev/null +++ b/doc/user/packages/debian_repository/index.md @@ -0,0 +1,124 @@ +--- +stage: Package +group: Package +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments +--- + +# Debian packages in the Package Registry + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/5835) in GitLab Core 13.10. + +Publish Debian packages in your project's Package Registry. Then install the +packages whenever you need to use them as a dependency. + +Project's and Group's packages are supported. + +## Enable Debian repository feature + +Debian repository support is gated behind a feature flag that is **disabled by default**. +[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md) +can opt to disable it. + +To enable it: + +```ruby +Feature.enable(:debian_packages) +``` + +To disable it: + +```ruby +Feature.disable(:debian_packages) +``` + +## Build a Debian package + +Creating a Debian package is documented [on the Debian Wiki](https://wiki.debian.org/Packaging). + +## Create a Distribution + +Debian packages are published using *Debian Distributions* on **project-level**. + +Packages can also be published on **group-level**, by creating a distribution with the same `codename`. + +To create a **project-level** distribution: + +```shell +curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects//debian_distributions?codename=unstable +``` + +Example response: + +```json +{ + "id": 1, + "codename": "unstable", + "suite": null, + "origin": null, + "label": null, + "version": null, + "description": null, + "valid_time_duration_seconds": null, + "components": [ + "main" + ], + "architectures": [ + "all", + "amd64" + ] +} +``` + +More information on Debian distribution APIs: + +- [Debian project distributions API](../../../api/debian_project_distributions.md) +- [Debian group distributions API](../../../api/debian_group_distributions.md) + +## Publish a package + +Once built, several files are created: + +- `.deb` files: the binary packages +- `.udeb` files: lightened .deb files, used for Debian-Installer (if needed) +- `.tar.{gz,bz2,xz,...}` files: Source files +- `.dsc` file: Source metadata, and list of source files (with hashes) +- `.buildinfo` file: Used for Reproducible builds (optional) +- `.changes` file: Upload metadata, and list of uploaded files (all the above) + +To upload those, you can use `dput-ng >= 1.32` (Debian bullseye). + +```shell +cat < dput.cf +[gitlab] +method = https +fqdn = :@gitlab.example.com +incoming = /api/v4/projects//packages/debian +EOF + +dput --config=dput.cf --unchecked --no-upload-log gitlab .changes +``` + +## Install a package + +To install a package: + +1. Configure the repository: + + ```shell + echo 'deb [trusted=yes] https://gitlab.example.com/api/v4/projects//packages/debian ' \ + | sudo tee /etc/apt/sources.list.d/gitlab_project.list + sudo apt-get update + ``` + +1. If the repository is not public: + + ```shell + echo 'machine gitlab.example.com login password ' \ + | sudo tee /etc/apt/auth.conf.d/gitlab_project.conf + ``` + +1. Install the package: + + ```shell + sudo apt-get -y install -t + ``` -- GitLab From d9ade42448aa748510fcfdc335129b379da21053 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Mon, 23 Nov 2020 12:04:29 +0100 Subject: [PATCH 07/11] Show additionnal Debian distribution metadata --- .../components/additional_metadata.vue | 117 ++++++++++++++++++ .../packages/detail/package_presenter.rb | 56 ++++++--- locale/gitlab.pot | 24 ++++ 3 files changed, 183 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/packages/details/components/additional_metadata.vue b/app/assets/javascripts/packages/details/components/additional_metadata.vue index 4e99099b0a19f9..9c9684b7674220 100644 --- a/app/assets/javascripts/packages/details/components/additional_metadata.vue +++ b/app/assets/javascripts/packages/details/components/additional_metadata.vue @@ -11,6 +11,14 @@ export default { recipeText: s__('PackageRegistry|Recipe: %{recipe}'), appGroup: s__('PackageRegistry|App group: %{group}'), appName: s__('PackageRegistry|App name: %{name}'), + distributionId: s__('PackageRegistry|Distribution Id: %{id}'), + distributionCodename: s__('PackageRegistry|Distribution Codename: %{codename}'), + distributionSuite: s__('PackageRegistry|Distribution Suite: %{suite}'), + distributionOrigin: s__('PackageRegistry|Distribution Origin: %{origin}'), + distributionLabel: s__('PackageRegistry|Distribution Label: %{label}'), + distributionDescription: s__('PackageRegistry|Distribution Description: %{description}'), + distributionComponents: s__('PackageRegistry|Distribution Components: %{components}'), + distributionArchitectures: s__('PackageRegistry|Distribution Architectures: %{architectures}'), }, components: { DetailsRow, @@ -28,6 +36,7 @@ export default { const visibilityConditions = { [PackageType.NUGET]: this.packageEntity.nuget_metadatum, [PackageType.CONAN]: this.packageEntity.conan_metadatum, + [PackageType.DEBIAN]: this.packageEntity.debian_distributions, [PackageType.MAVEN]: this.packageEntity.maven_metadatum, }; return visibilityConditions[this.packageEntity.package_type]; @@ -73,6 +82,114 @@ export default { + +