Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
4d3066e6
D
Dak
项目概览
喜羊羊3508
/
Dak
12 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dak
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4d3066e6
编写于
10月 28, 2009
作者:
M
Mark Hymers
浏览文件
操作
浏览文件
下载
差异文件
Merge commit 'ftpmaster/master'
上级
1fa1f22b
05c002af
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
208 addition
and
41 deletion
+208
-41
dak/override.py
dak/override.py
+1
-1
dak/process_accepted.py
dak/process_accepted.py
+1
-1
dak/process_new.py
dak/process_new.py
+1
-1
dak/process_unchecked.py
dak/process_unchecked.py
+1
-1
dak/rm.py
dak/rm.py
+1
-1
daklib/queue.py
daklib/queue.py
+2
-2
daklib/srcformats.py
daklib/srcformats.py
+80
-0
daklib/utils.py
daklib/utils.py
+15
-34
tests/test_srcformats.py
tests/test_srcformats.py
+106
-0
未找到文件。
dak/override.py
浏览文件 @
4d3066e6
...
...
@@ -240,7 +240,7 @@ def main ():
Subst
[
"__BCC__"
]
=
"Bcc: "
+
", "
.
join
(
bcc
)
else
:
Subst
[
"__BCC__"
]
=
"X-Filler: 42"
Subst
[
"__CC__"
]
=
"Cc: "
+
package
+
"@"
+
Cnf
[
"Dinstall::PackagesServer"
]
+
"
\n
X-DAK: dak override
\n
X-Katie: alicia
"
Subst
[
"__CC__"
]
=
"Cc: "
+
package
+
"@"
+
Cnf
[
"Dinstall::PackagesServer"
]
+
"
\n
X-DAK: dak override"
Subst
[
"__ADMIN_ADDRESS__"
]
=
Cnf
[
"Dinstall::MyAdminAddress"
]
Subst
[
"__DISTRO__"
]
=
Cnf
[
"Dinstall::MyDistribution"
]
Subst
[
"__WHOAMI__"
]
=
utils
.
whoami
()
...
...
dak/process_accepted.py
浏览文件 @
4d3066e6
...
...
@@ -582,7 +582,7 @@ def stable_install(u, session, summary, short_summary, fromsuite_name="proposed-
if
not
Options
[
"No-Mail"
]
and
u
.
pkg
.
changes
[
"architecture"
].
has_key
(
"source"
):
u
.
Subst
[
"__SUITE__"
]
=
" into %s"
%
(
tosuite
)
u
.
Subst
[
"__SUMMARY__"
]
=
summary
u
.
Subst
[
"__BCC__"
]
=
"X-DAK: dak process-accepted
\n
X-Katie: $Revision: 1.18 $
"
u
.
Subst
[
"__BCC__"
]
=
"X-DAK: dak process-accepted"
if
cnf
.
has_key
(
"Dinstall::Bcc"
):
u
.
Subst
[
"__BCC__"
]
+=
"
\n
Bcc: %s"
%
(
cnf
[
"Dinstall::Bcc"
])
...
...
dak/process_new.py
浏览文件 @
4d3066e6
...
...
@@ -845,7 +845,7 @@ def do_pkg(changes_file, session):
u
.
update_subst
()
cnf
=
Config
()
bcc
=
"X-DAK: dak process-new
\n
X-Katie: lisa $Revision: 1.31 $
"
bcc
=
"X-DAK: dak process-new"
if
cnf
.
has_key
(
"Dinstall::Bcc"
):
u
.
Subst
[
"__BCC__"
]
=
bcc
+
"
\n
Bcc: %s"
%
(
cnf
[
"Dinstall::Bcc"
])
else
:
...
...
dak/process_unchecked.py
浏览文件 @
4d3066e6
...
...
@@ -455,7 +455,7 @@ def process_it(changes_file):
u
.
pkg
.
changes
[
"changedby2047"
]
=
cnf
[
"Dinstall::MyEmailAddress"
]
# debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header
bcc
=
"X-DAK: dak process-unchecked
\n
X-Katie: $Revision: 1.65 $
"
bcc
=
"X-DAK: dak process-unchecked"
if
cnf
.
has_key
(
"Dinstall::Bcc"
):
u
.
Subst
[
"__BCC__"
]
=
bcc
+
"
\n
Bcc: %s"
%
(
cnf
[
"Dinstall::Bcc"
])
else
:
...
...
dak/rm.py
浏览文件 @
4d3066e6
...
...
@@ -550,7 +550,7 @@ def main ():
Subst
[
"__BCC__"
]
=
"Bcc: "
+
", "
.
join
(
bcc
)
else
:
Subst
[
"__BCC__"
]
=
"X-Filler: 42"
Subst
[
"__CC__"
]
=
"X-DAK: dak rm
\n
X-Katie: melanie
"
Subst
[
"__CC__"
]
=
"X-DAK: dak rm"
if
carbon_copy
:
Subst
[
"__CC__"
]
+=
"
\n
Cc: "
+
", "
.
join
(
carbon_copy
)
Subst
[
"__SUITE_LIST__"
]
=
suites_list
...
...
daklib/queue.py
浏览文件 @
4d3066e6
...
...
@@ -1929,7 +1929,7 @@ distribution."""
if
not
manual
:
self
.
Subst
[
"__REJECTOR_ADDRESS__"
]
=
cnf
[
"Dinstall::MyEmailAddress"
]
self
.
Subst
[
"__MANUAL_REJECT_MESSAGE__"
]
=
""
self
.
Subst
[
"__CC__"
]
=
"X-DAK-Rejection: automatic (moo)
\n
X-Katie-Rejection: automatic (moo)
"
self
.
Subst
[
"__CC__"
]
=
"X-DAK-Rejection: automatic (moo)"
os
.
write
(
reason_fd
,
reject_message
)
reject_mail_message
=
utils
.
TemplateSubst
(
self
.
Subst
,
rej_template
)
else
:
...
...
@@ -2385,7 +2385,7 @@ distribution."""
self
.
Subst
[
"__REJECTOR_ADDRESS__"
]
=
cnf
[
"Dinstall::MyEmailAddress"
]
self
.
Subst
[
"__REJECT_MESSAGE__"
]
=
self
.
package_info
()
self
.
Subst
[
"__CC__"
]
=
"Cc: "
+
cnf
[
"Dinstall::MyEmailAddress"
]
self
.
Subst
[
"__BCC__"
]
=
"X-DAK: dak process-accepted
\n
X-Katie: $Revision: 1.18 $
"
self
.
Subst
[
"__BCC__"
]
=
"X-DAK: dak process-accepted"
if
cnf
.
has_key
(
"Dinstall::Bcc"
):
self
.
Subst
[
"__BCC__"
]
+=
"
\n
Bcc: %s"
%
(
cnf
[
"Dinstall::Bcc"
])
...
...
daklib/srcformats.py
浏览文件 @
4d3066e6
import
re
from
regexes
import
re_verwithext
from
dak_exceptions
import
UnknownFormatError
srcformats
=
[]
def
get_format_from_string
(
txt
):
"""
Returns the SourceFormat class that corresponds to the specified .changes
Format value. If the string does not match any class, UnknownFormatError
is raised.
"""
for
format
in
srcformats
:
if
format
.
re_format
.
match
(
txt
):
return
format
raise
UnknownFormatError
,
"Unknown format %r"
%
txt
def
parse_format
(
txt
):
"""
Parse a .changes Format string into a tuple representation for easy
comparison.
>>> parse_format('1.0')
(1, 0)
>>> parse_format('8.4 (hardy)')
(8, 4, 'hardy')
If the format doesn't match these forms, raises UnknownFormatError.
"""
format
=
re_verwithext
.
search
(
txt
)
if
format
is
None
:
raise
UnknownFormatError
,
txt
format
=
format
.
groups
()
if
format
[
1
]
is
None
:
format
=
int
(
float
(
format
[
0
])),
0
,
format
[
2
]
else
:
format
=
int
(
format
[
0
]),
int
(
format
[
1
]),
format
[
2
]
if
format
[
2
]
is
None
:
format
=
format
[:
2
]
return
format
class
SourceFormat
(
type
):
def
__new__
(
cls
,
name
,
bases
,
attrs
):
klass
=
super
(
SourceFormat
,
cls
).
__new__
(
cls
,
name
,
bases
,
attrs
)
...
...
@@ -24,6 +70,15 @@ class SourceFormat(type):
if
has
[
key
]:
yield
"contains source files not allowed in format %s"
%
cls
.
name
@
classmethod
def
validate_format
(
cls
,
format
,
is_a_dsc
=
False
,
field
=
'files'
):
"""
Raises UnknownFormatError if the specified format tuple is not valid for
this format (for example, the format (1, 0) is not valid for the
"3.0 (quilt)" format). Return value is undefined in all other cases.
"""
pass
class
FormatOne
(
SourceFormat
):
__metaclass__
=
SourceFormat
...
...
@@ -46,6 +101,19 @@ class FormatOne(SourceFormat):
for
msg
in
super
(
FormatOne
,
cls
).
reject_msgs
(
has
):
yield
msg
@
classmethod
def
validate_format
(
cls
,
format
,
is_a_dsc
=
False
,
field
=
'files'
):
msg
=
"Invalid format %s definition: %r"
%
(
cls
.
name
,
format
)
if
is_a_dsc
:
if
format
!=
(
1
,
0
):
raise
UnknownFormatError
,
msg
else
:
if
(
format
<
(
1
,
5
)
or
format
>
(
1
,
8
)):
raise
UnknownFormatError
,
msg
if
field
!=
"files"
and
format
<
(
1
,
8
):
raise
UnknownFormatError
,
msg
class
FormatThree
(
SourceFormat
):
__metaclass__
=
SourceFormat
...
...
@@ -55,6 +123,12 @@ class FormatThree(SourceFormat):
requires
=
(
'native_tar'
,)
disallowed
=
(
'orig_tar'
,
'debian_diff'
,
'debian_tar'
,
'more_orig_tar'
)
@
classmethod
def
validate_format
(
cls
,
format
,
**
kwargs
):
if
format
!=
(
3
,
0
,
'native'
):
raise
UnknownFormatError
,
"Invalid format %s definition: %r"
%
\
(
cls
.
name
,
format
)
class
FormatThreeQuilt
(
SourceFormat
):
__metaclass__
=
SourceFormat
...
...
@@ -63,3 +137,9 @@ class FormatThreeQuilt(SourceFormat):
requires
=
(
'orig_tar'
,
'debian_tar'
)
disallowed
=
(
'debian_diff'
,
'native_tar'
)
@
classmethod
def
validate_format
(
cls
,
format
,
**
kwargs
):
if
format
!=
(
3
,
0
,
'quilt'
):
raise
UnknownFormatError
,
"Invalid format %s definition: %r"
%
\
(
cls
.
name
,
format
)
daklib/utils.py
浏览文件 @
4d3066e6
...
...
@@ -44,11 +44,10 @@ from dbconn import DBConn, get_architecture, get_component, get_suite
from
dak_exceptions
import
*
from
textutils
import
fix_maintainer
from
regexes
import
re_html_escaping
,
html_escaping
,
re_single_line_field
,
\
re_multi_line_field
,
re_srchasver
,
re_verwithext
,
\
re_taint_free
,
re_gpg_uid
,
re_re_mark
,
\
re_whitespace_comment
,
re_issource
re_multi_line_field
,
re_srchasver
,
re_taint_free
,
\
re_gpg_uid
,
re_re_mark
,
re_whitespace_comment
,
re_issource
from
srcformats
import
srcformats
from
srcformats
import
get_format_from_string
from
collections
import
defaultdict
################################################################################
...
...
@@ -417,12 +416,15 @@ def check_dsc_files(dsc_filename, dsc=None, dsc_files=None):
rejmsg
.
append
(
"%s: lists multiple %s"
%
(
dsc_filename
,
file_type
))
# Source format specific tests
for
format
in
srcformats
:
if
format
.
re_format
.
match
(
dsc
[
'format'
]):
rejmsg
.
extend
([
'%s: %s'
%
(
dsc_filename
,
x
)
for
x
in
format
.
reject_msgs
(
has
)
])
break
try
:
format
=
get_format_from_string
(
dsc
[
'format'
])
rejmsg
.
extend
([
'%s: %s'
%
(
dsc_filename
,
x
)
for
x
in
format
.
reject_msgs
(
has
)
])
except
UnknownFormatError
:
# Not an error here for now
pass
return
rejmsg
...
...
@@ -524,30 +526,9 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"):
if
not
changes
.
has_key
(
field
):
raise
NoFilesFieldError
# Make sure we recognise the format of the Files: field
format
=
re_verwithext
.
search
(
changes
.
get
(
"format"
,
"0.0"
))
if
not
format
:
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
format
=
format
.
groups
()
if
format
[
1
]
==
None
:
format
=
int
(
float
(
format
[
0
])),
0
,
format
[
2
]
else
:
format
=
int
(
format
[
0
]),
int
(
format
[
1
]),
format
[
2
]
if
format
[
2
]
==
None
:
format
=
format
[:
2
]
if
is_a_dsc
:
# format = (0,0) are missing format headers of which we still
# have some in the archive.
if
format
!=
(
1
,
0
)
and
format
!=
(
0
,
0
)
and
\
format
!=
(
3
,
0
,
"quilt"
)
and
format
!=
(
3
,
0
,
"native"
):
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
else
:
if
(
format
<
(
1
,
5
)
or
format
>
(
1
,
8
)):
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
if
field
!=
"files"
and
format
<
(
1
,
8
):
raise
UnknownFormatError
,
"%s"
%
(
changes
.
get
(
"format"
,
"0.0"
))
# Get SourceFormat object for this Format and validate it
format
=
get_format_from_string
(
changes
.
get
[
'format'
])
format
.
validate_format
(
is_a_dsc
=
is_a_dsc
,
field
=
field
)
includes_section
=
(
not
is_a_dsc
)
and
field
==
"files"
...
...
tests/test_srcformats.py
浏览文件 @
4d3066e6
...
...
@@ -8,6 +8,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from
collections
import
defaultdict
from
daklib
import
srcformats
from
daklib.dak_exceptions
import
UnknownFormatError
class
SourceFormatTestCase
(
unittest
.
TestCase
):
def
get_rejects
(
self
,
has_vars
):
...
...
@@ -102,5 +103,110 @@ class FormatTreeQuiltTestCase(SourceFormatTestCase):
'native_tar'
:
1
,
})
##
class
ParseFormatTestCase
(
unittest
.
TestCase
):
def
assertParse
(
self
,
format
,
expected
):
self
.
assertEqual
(
srcformats
.
parse_format
(
format
),
expected
)
def
assertParseFail
(
self
,
format
):
self
.
assertRaises
(
UnknownFormatError
,
lambda
:
srcformats
.
parse_format
(
format
)
)
def
testParse
(
self
):
self
.
assertParse
(
'1.0'
,
(
1
,
0
))
def
testEmpty
(
self
):
self
.
assertParseFail
(
''
)
self
.
assertParseFail
(
' '
)
self
.
assertParseFail
(
' '
)
def
textText
(
self
):
self
.
assertParse
(
'1.2 (three)'
,
(
1
,
2
,
'three'
))
self
.
assertParseFail
(
'0.0 ()'
)
class
ValidateFormatTestCase
(
unittest
.
TestCase
):
def
assertValid
(
self
,
format
,
**
kwargs
):
kwargs
[
'is_a_dsc'
]
=
kwargs
.
get
(
'is_a_dsc'
,
True
)
self
.
fmt
.
validate_format
(
format
,
**
kwargs
)
def
assertInvalid
(
self
,
*
args
,
**
kwargs
):
self
.
assertRaises
(
UnknownFormatError
,
lambda
:
self
.
assertValid
(
*
args
,
**
kwargs
),
)
class
ValidateFormatOneTestCase
(
ValidateFormatTestCase
):
fmt
=
srcformats
.
FormatOne
def
testValid
(
self
):
self
.
assertValid
((
1
,
0
))
def
testInvalid
(
self
):
self
.
assertInvalid
((
0
,
1
))
self
.
assertInvalid
((
3
,
0
,
'quilt'
))
##
def
testBinary
(
self
):
self
.
assertValid
((
1
,
5
),
is_a_dsc
=
False
)
self
.
assertInvalid
((
1
,
0
),
is_a_dsc
=
False
)
def
testRange
(
self
):
self
.
assertInvalid
((
1
,
3
),
is_a_dsc
=
False
)
self
.
assertValid
((
1
,
5
),
is_a_dsc
=
False
)
self
.
assertValid
((
1
,
8
),
is_a_dsc
=
False
)
self
.
assertInvalid
((
1
,
9
),
is_a_dsc
=
False
)
def
testFilesField
(
self
):
self
.
assertInvalid
((
1
,
7
),
is_a_dsc
=
False
,
field
=
'notfiles'
)
self
.
assertValid
((
1
,
8
),
is_a_dsc
=
False
,
field
=
'notfiles'
)
class
ValidateFormatThreeTestCase
(
ValidateFormatTestCase
):
fmt
=
srcformats
.
FormatThree
def
testValid
(
self
):
self
.
assertValid
((
3
,
0
,
'native'
))
def
testInvalid
(
self
):
self
.
assertInvalid
((
1
,
0
))
self
.
assertInvalid
((
0
,
0
))
self
.
assertInvalid
((
3
,
0
,
'quilt'
))
class
ValidateFormatThreeQuiltTestCase
(
ValidateFormatTestCase
):
fmt
=
srcformats
.
FormatThreeQuilt
def
testValid
(
self
):
self
.
assertValid
((
3
,
0
,
'quilt'
))
def
testInvalid
(
self
):
self
.
assertInvalid
((
1
,
0
))
self
.
assertInvalid
((
0
,
0
))
self
.
assertInvalid
((
3
,
0
,
'native'
))
class
FormatFromStringTestCase
(
unittest
.
TestCase
):
def
assertFormat
(
self
,
txt
,
klass
):
self
.
assertEqual
(
srcformats
.
get_format_from_string
(
txt
),
klass
)
def
assertInvalid
(
self
,
txt
):
self
.
assertRaises
(
UnknownFormatError
,
lambda
:
srcformats
.
get_format_from_string
(
txt
),
)
def
testFormats
(
self
):
self
.
assertFormat
(
'1.0'
,
srcformats
.
FormatOne
)
self
.
assertFormat
(
'3.0 (native)'
,
srcformats
.
FormatThree
)
self
.
assertFormat
(
'3.0 (quilt)'
,
srcformats
.
FormatThreeQuilt
)
def
testInvalidFormats
(
self
):
self
.
assertInvalid
(
''
)
self
.
assertInvalid
(
'.'
)
self
.
assertInvalid
(
'3.0 (cvs)'
)
self
.
assertInvalid
(
' 1.0 '
)
self
.
assertInvalid
(
'8.4 (hardy)'
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录