Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4457d342
Commit
4457d342
authored
Jul 28, 2021
by
Mathieu Parent
Committed by
David Fernandez
Jul 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plug Debian SignDistributionService in GenerateDistributionService
Changelog: added
parent
54e345fb
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
182 deletions
+198
-182
app/services/packages/debian/generate_distribution_service.rb
...services/packages/debian/generate_distribution_service.rb
+24
-15
app/services/packages/debian/sign_distribution_service.rb
app/services/packages/debian/sign_distribution_service.rb
+3
-3
spec/services/packages/debian/generate_distribution_service_spec.rb
...ces/packages/debian/generate_distribution_service_spec.rb
+1
-7
spec/services/packages/debian/sign_distribution_service_spec.rb
...ervices/packages/debian/sign_distribution_service_spec.rb
+2
-3
spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb
.../packages/debian/generate_distribution_shared_examples.rb
+168
-154
No files found.
app/services/packages/debian/generate_distribution_service.rb
View file @
4457d342
...
...
@@ -161,28 +161,37 @@ module Packages
end
def
generate_release
@distribution
.
file
=
CarrierWaveStringFile
.
new
(
release_header
+
release_sums
)
@distribution
.
key
||
@distribution
.
create_key
(
GenerateDistributionKeyService
.
new
.
execute
)
@distribution
.
file
=
CarrierWaveStringFile
.
new
(
release_content
)
@distribution
.
file_signature
=
SignDistributionService
.
new
(
@distribution
,
release_content
,
detach:
true
).
execute
@distribution
.
signed_file
=
CarrierWaveStringFile
.
new
(
SignDistributionService
.
new
(
@distribution
,
release_content
).
execute
)
@distribution
.
updated_at
=
release_date
@distribution
.
save!
end
def
release_header
strong_memoize
(
:release_header
)
do
[
%w[origin label suite version codename]
.
map
do
|
attribute
|
rfc822_field
(
attribute
.
capitalize
,
@distribution
.
attributes
[
attribute
])
end
,
rfc822_field
(
'Date'
,
release_date
.
to_formatted_s
(
:rfc822
)),
valid_until_field
,
rfc822_field
(
'NotAutomatic'
,
!
@distribution
.
automatic
,
!
@distribution
.
automatic
),
rfc822_field
(
'ButAutomaticUpgrades'
,
@distribution
.
automatic_upgrades
,
!
@distribution
.
automatic
&&
@distribution
.
automatic_upgrades
),
rfc822_field
(
'Architectures'
,
@distribution
.
architectures
.
map
{
|
architecture
|
architecture
.
name
}.
sort
.
join
(
' '
)),
rfc822_field
(
'Components'
,
@distribution
.
components
.
map
{
|
component
|
component
.
name
}.
sort
.
join
(
' '
)),
rfc822_field
(
'Description'
,
@distribution
.
description
)
].
flatten
.
compact
.
join
(
''
)
def
release_content
strong_memoize
(
:release_content
)
do
release_header
+
release_sums
end
end
def
release_header
[
%w[origin label suite version codename]
.
map
do
|
attribute
|
rfc822_field
(
attribute
.
capitalize
,
@distribution
.
attributes
[
attribute
])
end
,
rfc822_field
(
'Date'
,
release_date
.
to_formatted_s
(
:rfc822
)),
valid_until_field
,
rfc822_field
(
'NotAutomatic'
,
!
@distribution
.
automatic
,
!
@distribution
.
automatic
),
rfc822_field
(
'ButAutomaticUpgrades'
,
@distribution
.
automatic_upgrades
,
!
@distribution
.
automatic
&&
@distribution
.
automatic_upgrades
),
rfc822_field
(
'Architectures'
,
@distribution
.
architectures
.
map
{
|
architecture
|
architecture
.
name
}.
sort
.
join
(
' '
)),
rfc822_field
(
'Components'
,
@distribution
.
components
.
map
{
|
component
|
component
.
name
}.
sort
.
join
(
' '
)),
rfc822_field
(
'Description'
,
@distribution
.
description
)
].
flatten
.
compact
.
join
(
''
)
end
def
release_date
strong_memoize
(
:release_date
)
do
Time
.
now
.
utc
...
...
app/services/packages/debian/sign_distribution_service.rb
View file @
4457d342
...
...
@@ -5,10 +5,10 @@ module Packages
class
SignDistributionService
include
Gitlab
::
Utils
::
StrongMemoize
def
initialize
(
distribution
,
content
,
params:
{}
)
def
initialize
(
distribution
,
content
,
detach:
false
)
@distribution
=
distribution
@content
=
content
@
params
=
params
@
detach
=
detach
end
def
execute
...
...
@@ -16,7 +16,7 @@ module Packages
sig_mode
=
GPGME
::
GPGME_SIG_MODE_CLEAR
sig_mode
=
GPGME
::
GPGME_SIG_MODE_DETACH
if
@
params
[
:detach
]
sig_mode
=
GPGME
::
GPGME_SIG_MODE_DETACH
if
@
detach
Gitlab
::
Gpg
.
using_tmp_keychain
do
GPGME
::
Ctx
.
new
(
...
...
spec/services/packages/debian/generate_distribution_service_spec.rb
View file @
4457d342
...
...
@@ -12,13 +12,7 @@ RSpec.describe Packages::Debian::GenerateDistributionService do
context
"for
#{
container_type
}
"
do
include_context
'with Debian distribution'
,
container_type
context
'with Debian components and architectures'
do
it_behaves_like
'Generate Debian Distribution and component files'
end
context
'without components and architectures'
do
it_behaves_like
'Generate minimal Debian Distribution'
end
it_behaves_like
'Generate Debian Distribution and component files'
end
end
end
...
...
spec/services/packages/debian/sign_distribution_service_spec.rb
View file @
4457d342
...
...
@@ -6,12 +6,11 @@ RSpec.describe Packages::Debian::SignDistributionService do
let_it_be
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:content
)
{
FFaker
::
Lorem
.
paragraph
}
let
(
:params
)
{
{}
}
let
(
:service
)
{
described_class
.
new
(
distribution
,
content
,
params:
params
)
}
let
(
:service
)
{
described_class
.
new
(
distribution
,
content
,
detach:
detach
)
}
shared_examples
'Sign Distribution'
do
|
container_type
,
detach:
false
|
context
"for
#{
container_type
}
detach=
#{
detach
}
"
do
let
(
:
params
)
{
{
detach:
detach
}
}
let
(
:
detach
)
{
detach
}
if
container_type
==
:group
let_it_be
(
:distribution
)
{
create
(
'debian_group_distribution'
,
container:
group
)
}
...
...
spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb
View file @
4457d342
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment