Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
f2cda332
Commit
f2cda332
authored
Aug 15, 2012
by
Clément Schreiner
Browse files
Update native and buildsystem plugins to the latest API.
(amended because missing template)
parent
3a4fe08e
Changes
3
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/buildsystem.py
View file @
f2cda332
...
...
@@ -7,6 +7,7 @@
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
# Copyright © 2012 Nicolas Dandrimont <nicolas.dandrimont@crans.org>
# Copyright © 2012 Clément Schreiner <clement@mux.me>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
...
...
@@ -38,60 +39,83 @@ __copyright__ = ', '.join([
'Copyright © 2008 Jonny Lamb'
,
'Copyright © 2010 Jan Dittberner'
,
'Copyright © 2012 Nicolas Dandrimont'
,
'Copyright © 2012 Clément Schreiner'
,
])
__license__
=
'MIT'
from
debexpo.lib
import
constants
from
debexpo.plugins.api
import
*
import
logging
import
os
from
debian
import
deb822
from
debexpo.lib
import
constants
from
debexpo.plugins
import
BasePlugin
from
debexpo.models.plugin_results
import
PluginResult
,
plugin_result_mapper
from
sqlalchemy
import
orm
log
=
logging
.
getLogger
(
__name__
)
class
BuildSystemResult
(
PluginResult
):
pass
@
test_result
class
BuildsystemTest
(
PluginResult
):
"""
Result of the 'buildsystem' plugin.
"""
orm
.
mapper
(
BuildSystemResult
,
inherits
=
plugin_result_mapper
,
polymorphic_identity
=
'buildsystem_result'
)
@
property
def
known
(
self
):
return
self
[
'buildsystem'
]
!=
'unknown'
class
BuildSystemPlugin
(
BasePlugin
):
model
=
BuildSystemResult
def
__str__
(
self
):
if
self
.
known
:
msg
=
'Package uses %s'
%
self
[
'buildsystem'
]
else
:
msg
=
'Unknown'
return
'Build system: %s'
%
msg
class
BuildSystemPlugin
(
QAPlugin
):
@
importercmd
def
test_build_system
(
self
):
"""
Finds the build system of the package.
"""
log
.
debug
(
'
Finding the package
\
'
s build system
'
)
log
.
debug
(
"
Finding the package's build system
"
)
dsc
=
deb822
.
Dsc
(
file
(
self
.
changes
.
get_dsc
()))
log
.
debug
(
'Opening dsc file in %s'
%
os
.
getcwd
())
dsc_path
=
os
.
path
.
join
(
self
.
changes
.
get_pool_path
(),
self
.
changes
.
get_dsc
())
with
open
(
dsc_path
,
'r'
)
as
dsc_file
:
dsc
=
deb822
.
Dsc
(
dsc_file
)
build_depends
=
dsc
.
get
(
'Build-Depends'
,
''
)
result
=
self
.
new_test_result
()
if
'cdbs'
in
build_depends
:
self
.
_add_data
(
buildsystem
=
'cdbs'
)
result
[
'buildsystem'
]
=
'cdbs'
elif
'debhelper'
in
build_depends
:
self
.
_add_data
(
buildsystem
=
'debhelper'
)
result
[
'
buildsystem
'
]
=
'debhelper'
# Retrieve the debhelper compat level
compatpath
=
os
.
path
.
join
(
self
.
tempdir
,
"extracted/debian/compat"
)
try
:
with
open
(
compatpath
,
"rb"
)
as
f
:
compat_level
=
int
(
f
.
read
().
strip
())
except
IOError
:
if
hasattr
(
self
,
'tempdir'
):
compatpath
=
os
.
path
.
join
(
self
.
tempdir
,
"extracted/debian/compat"
)
try
:
with
open
(
compatpath
,
"rb"
)
as
f
:
compat_level
=
int
(
f
.
read
().
strip
())
except
IOError
:
compat_level
=
'unknown'
else
:
compat_level
=
'unknown'
self
.
_add_data
(
compat
-
level
=
compat_level
)
result
[
'
compat
_
level
'
]
=
compat_level
# Warn on old compatibility levels
if
compat_level
is
None
or
compat_level
<=
4
:
self
.
_add_data
(
severity
=
constants
.
PLUGIN_SEVERITY_WARNING
)
result
[
'
severity
'
]
=
constants
.
PLUGIN_SEVERITY_WARNING
else
:
self
.
_add_data
(
build
-
system
=
'unknown'
,
severity
=
constants
.
PLUGIN_SEVERITY_WARNING
)
result
[
'buildsystem'
]
=
'unknown'
result
[
'severity'
]
=
constants
.
PLUGIN_SEVERITY_WARNING
plugin
=
BuildSystemPlugin
models
=
[
BuildsystemTest
,
]
debexpo/plugins/native.py
View file @
f2cda332
...
...
@@ -44,18 +44,17 @@ __license__ = 'MIT'
import
logging
from
debexpo.lib
import
constants
,
filesystem
from
debexpo.plugins
import
QAPlugin
from
debexpo.model.plugin_results
import
PluginResult
from
debexpo.plugins.api
import
*
log
=
logging
.
getLogger
(
__name__
)
class
Test
(
PluginResult
):
@
test_result
class
NativeTest
(
PluginResult
):
"""
Result of the 'native' plugin for a package.
"""
plugin
=
'native'
@
property
def
is_native
(
self
):
return
self
[
'native'
]
==
'true'
...
...
@@ -68,13 +67,8 @@ class NativePlugin(QAPlugin):
"""
Plugin checking whether a package is a native package.
"""
plugin
=
'native'
# entity representing the result of the QA test
# (yes, this is ugly)
test_entity
=
'native_test'
@
importercmd
def
test_native
(
self
):
"""
Test to see whether the package is a native package.
...
...
@@ -84,7 +78,7 @@ class NativePlugin(QAPlugin):
is_native
=
filecheck
.
is_native_package
(
self
.
changes
)
result
=
self
.
_
new_result
(
Test
)
result
=
self
.
new_
test_
result
()
if
is_native
:
# Most uploads will not be native, and especially on mentors, a native
# package is almost probably in error.
...
...
@@ -97,3 +91,6 @@ class NativePlugin(QAPlugin):
result
[
'severity'
]
=
constants
.
PLUGIN_SEVERITY_INFO
plugin
=
NativePlugin
models
=
[
NativeTest
,
]
debexpo/templates/plugins/buildsystem/html.mako
View file @
f2cda332
<div class="qa-header">
Buildsystem: ${o.outcome
}
${test_result
}
</div>
%if o.rich_data["build-system"] == "debhelper":
<div class="qa-content">
%if o.rich_data["compat-level"]:
Debhelper compatibility level ${o.rich_data["compat-level"]}
%else:
No compatibility level set!
%endif
</div>
%endif
% if test_result['buildsystem'] == "debhelper":
<div class="qa-content">
<%
compat_level = test_result.get('compat_level', None)
%>
% if compat_level is not None:
Debhelper compatibility level ${compat_level}
% else:
No compatibility level set!
% endif
</div>
% endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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