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
a023336e
Commit
a023336e
authored
Oct 01, 2020
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add .deb file metadata extractor
parent
0882b9ed
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
3 deletions
+88
-3
app/services/packages/debian/extract_deb_metadata_service.rb
app/services/packages/debian/extract_deb_metadata_service.rb
+41
-0
changelogs/unreleased/debian_parsers.yml
changelogs/unreleased/debian_parsers.yml
+5
-0
config/gitlab.yml.example
config/gitlab.yml.example
+1
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+4
-3
spec/services/packages/debian/extract_deb_metadata_service_spec.rb
...ices/packages/debian/extract_deb_metadata_service_spec.rb
+37
-0
No files found.
app/services/packages/debian/extract_deb_metadata_service.rb
0 → 100644
View file @
a023336e
# frozen_string_literal: true
module
Packages
module
Debian
# Returns .deb file metadata
class
ExtractDebMetadataService
CommandFailedError
=
Class
.
new
(
StandardError
)
def
initialize
(
file_path
)
@file_path
=
file_path
end
def
execute
unless
success?
raise
CommandFailedError
,
"The `
#{
cmd
}
` command failed (status:
#{
result
.
status
}
) with the following error:
\n
#{
result
.
stderr
}
"
end
sections
=
ParseDebian822Service
.
new
(
result
.
stdout
).
execute
sections
.
each_value
.
first
end
private
def
cmd
@cmd
||=
begin
dpkg_deb_path
=
Gitlab
.
config
.
packages
.
dpkg_deb_path
[
dpkg_deb_path
,
'--field'
,
@file_path
]
end
end
def
result
@result
||=
Gitlab
::
Popen
.
popen_with_detail
(
cmd
)
end
def
success?
result
.
status
&
.
exitstatus
==
0
end
end
end
end
changelogs/unreleased/debian_parsers.yml
0 → 100644
View file @
a023336e
---
title
:
Debian RFC822 and .deb metadata extractor
merge_request
:
44029
author
:
Mathieu Parent
type
:
added
config/gitlab.yml.example
View file @
a023336e
...
@@ -317,6 +317,7 @@ production: &base
...
@@ -317,6 +317,7 @@ production: &base
## Packages (maven repository, npm registry, etc...)
## Packages (maven repository, npm registry, etc...)
packages:
packages:
enabled: true
enabled: true
dpkg_deb_path: /usr/bin/dpkg-deb
# The location where build packages are stored (default: shared/packages).
# The location where build packages are stored (default: shared/packages).
# storage_path: shared/packages
# storage_path: shared/packages
object_store:
object_store:
...
...
config/initializers/1_settings.rb
View file @
a023336e
...
@@ -355,6 +355,7 @@ Settings.uploads['object_store']['remote_directory'] ||= 'uploads'
...
@@ -355,6 +355,7 @@ Settings.uploads['object_store']['remote_directory'] ||= 'uploads'
#
#
Settings
[
'packages'
]
||=
Settingslogic
.
new
({})
Settings
[
'packages'
]
||=
Settingslogic
.
new
({})
Settings
.
packages
[
'enabled'
]
=
true
if
Settings
.
packages
[
'enabled'
].
nil?
Settings
.
packages
[
'enabled'
]
=
true
if
Settings
.
packages
[
'enabled'
].
nil?
Settings
.
packages
[
'dpkg_deb_path'
]
=
'/usr/bin/dpkg-deb'
if
Settings
.
packages
[
'dpkg_deb_path'
].
nil?
Settings
.
packages
[
'storage_path'
]
=
Settings
.
absolute
(
Settings
.
packages
[
'storage_path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"packages"
))
Settings
.
packages
[
'storage_path'
]
=
Settings
.
absolute
(
Settings
.
packages
[
'storage_path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"packages"
))
Settings
.
packages
[
'object_store'
]
=
ObjectStoreSettings
.
legacy_parse
(
Settings
.
packages
[
'object_store'
])
Settings
.
packages
[
'object_store'
]
=
ObjectStoreSettings
.
legacy_parse
(
Settings
.
packages
[
'object_store'
])
...
...
spec/services/packages/debian/extract_deb_metadata_service_spec.rb
0 → 100644
View file @
a023336e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Packages
::
Debian
::
ExtractDebMetadataService
do
subject
{
described_class
.
new
(
file_path
)
}
let
(
:file_name
)
{
'libsample0_1.2.3~alpha2_amd64.deb'
}
let
(
:file_path
)
{
"spec/fixtures/packages/debian/
#{
file_name
}
"
}
context
'with correct file'
do
it
'return as expected'
do
expected
=
{
'Package'
:
'libsample0'
,
'Source'
:
'sample'
,
'Version'
:
'1.2.3~alpha2'
,
'Architecture'
:
'amd64'
,
'Maintainer'
:
'John Doe <john.doe@example.com>'
,
'Installed-Size'
:
'7'
,
'Section'
:
'libs'
,
'Priority'
:
'optional'
,
'Multi-Arch'
:
'same'
,
'Homepage'
:
'https://gitlab.com/'
,
'Description'
:
"Some mostly empty lib
\n
Used in GitLab tests.
\n\n
Testing another paragraph."
}
expect
(
subject
.
execute
).
to
eq
expected
end
end
context
'with incorrect file'
do
let
(
:file_name
)
{
'README.md'
}
it
'raise error'
do
expect
{
subject
.
execute
}.
to
raise_error
(
described_class
::
CommandFailedError
,
/is not a Debian format archive/i
)
end
end
end
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