Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
c84005b5
D
Dak
项目概览
喜羊羊3508
/
Dak
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
c84005b5
编写于
9月 21, 2015
作者:
J
Joerg Jaspert
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move a bunch of commands into their own daklib files
上级
0a838972
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
352 addition
and
316 deletion
+352
-316
dak/admin.py
dak/admin.py
+21
-316
daklib/admin.py
daklib/admin.py
+331
-0
未找到文件。
dak/admin.py
浏览文件 @
c84005b5
...
...
@@ -25,6 +25,7 @@ import apt_pkg
import
daklib.archive
import
daklib.gpg
import
daklib.admin
from
daklib
import
utils
from
daklib.dbconn
import
*
...
...
@@ -139,7 +140,7 @@ Perform administrative work on the dak database.
v-c rm SUITE CHECK REFERENCE remove a version check
where
CHECK is one of Enhances, MustBeNewerThan, MustBeOlderThan
REFERENCE is another suite name
REFERENCE is another suite name
change-component:
change-component SUITE COMPONENT source SOURCE...
...
...
@@ -297,169 +298,28 @@ dispatch['component'] = component
################################################################################
def
__suite_list
(
d
,
args
):
s
=
d
.
session
()
for
j
in
s
.
query
(
Suite
).
join
(
Suite
.
archive
).
order_by
(
Archive
.
archive_name
,
Suite
.
suite_name
).
all
():
if
len
(
args
)
>
2
and
args
[
2
]
==
"--print-archive"
:
print
"{0} {1}"
.
format
(
j
.
archive
.
archive_name
,
j
.
suite_name
)
else
:
print
"{0}"
.
format
(
j
.
suite_name
)
def
__suite_show
(
d
,
args
):
if
len
(
args
)
<
2
:
die
(
"E: showing an suite entry requires a suite"
)
s
=
d
.
session
()
su
=
get_suite
(
args
[
2
].
lower
())
if
su
is
None
:
die
(
"E: can't find suite entry for %s"
%
(
args
[
2
].
lower
()))
print
su
.
details
()
def
__suite_add
(
d
,
args
,
addallarches
=
False
):
die_arglen
(
args
,
4
,
"E: adding a suite requires at least a name and a version"
)
suite_name
=
args
[
2
].
lower
()
version
=
args
[
3
]
rest
=
args
[
3
:]
if
len
(
version
)
==
0
:
version
=
None
def
get_field
(
field
):
for
varval
in
args
:
if
varval
.
startswith
(
field
+
'='
):
return
varval
.
split
(
'='
)[
1
]
return
None
print
"Adding suite %s"
%
suite_name
if
not
dryrun
:
try
:
s
=
d
.
session
()
suite
=
Suite
()
suite
.
suite_name
=
suite_name
suite
.
overridecodename
=
suite_name
suite
.
version
=
version
suite
.
label
=
get_field
(
'label'
)
suite
.
description
=
get_field
(
'description'
)
suite
.
origin
=
get_field
(
'origin'
)
suite
.
codename
=
get_field
(
'codename'
)
signingkey
=
get_field
(
'signingkey'
)
if
signingkey
is
not
None
:
suite
.
signingkeys
=
[
signingkey
.
upper
()]
archive_name
=
get_field
(
'archive'
)
if
archive_name
is
not
None
:
suite
.
archive
=
get_archive
(
archive_name
,
s
)
else
:
suite
.
archive
=
s
.
query
(
Archive
).
filter
(
~
Archive
.
archive_name
.
in_
([
'build-queues'
,
'new'
,
'policy'
])).
one
()
suite
.
srcformats
=
s
.
query
(
SrcFormat
).
all
()
s
.
add
(
suite
)
s
.
flush
()
except
IntegrityError
as
e
:
die
(
"E: Integrity error adding suite %s (it probably already exists)"
%
suite_name
)
except
SQLAlchemyError
as
e
:
die
(
"E: Error adding suite %s (%s)"
%
(
suite_name
,
e
))
print
"Suite %s added"
%
(
suite_name
)
if
addallarches
:
arches
=
[]
q
=
s
.
query
(
Architecture
).
order_by
(
Architecture
.
arch_string
)
for
arch
in
q
.
all
():
suite
.
architectures
.
append
(
arch
)
arches
.
append
(
arch
.
arch_string
)
print
"Architectures %s added to %s"
%
(
','
.
join
(
arches
),
suite_name
)
s
.
commit
()
def
__suite_rm
(
d
,
args
):
die_arglen
(
args
,
3
,
"E: removing a suite requires at least a name"
)
name
=
args
[
2
]
print
"Removing suite {0}"
.
format
(
name
)
if
not
dryrun
:
try
:
s
=
d
.
session
()
su
=
get_suite
(
name
.
lower
())
if
su
is
None
:
die
(
"E: Cannot find suite {0}"
.
format
(
name
))
s
.
delete
(
su
)
s
.
commit
()
except
IntegrityError
as
e
:
die
(
"E: Integrity error removing suite {0} (suite-arch entries probably still exist)"
.
format
(
name
))
except
SQLAlchemyError
as
e
:
die
(
"E: Error removing suite {0} ({1})"
.
format
(
name
,
e
))
print
"Suite {0} removed"
.
format
(
name
)
def
__suite_add_build_queue
(
d
,
args
):
session
=
d
.
session
()
die_arglen
(
args
,
6
,
"E: Adding a build queue needs four parameters."
)
suite_name
=
args
[
2
]
build_queue_name
=
args
[
3
]
build_queue_codename
=
args
[
4
]
build_queue_archive_name
=
args
[
5
]
try
:
suite
=
session
.
query
(
Suite
).
filter_by
(
suite_name
=
suite_name
).
one
()
except
NoResultFound
:
die
(
"E: Unknown suite '{0}'"
.
format
(
suite_name
))
try
:
build_queue_archive
=
session
.
query
(
Archive
).
filter_by
(
archive_name
=
build_queue_archive_name
).
one
()
except
NoResultFound
:
die
(
"E: Unknown archive '{0}'"
.
format
(
build_queue_archive_name
))
# Create suite
s
=
Suite
()
s
.
suite_name
=
build_queue_name
s
.
origin
=
suite
.
origin
s
.
label
=
suite
.
label
s
.
description
=
"buildd {0} incoming"
.
format
(
suite_name
)
s
.
codename
=
build_queue_codename
s
.
notautomatic
=
suite
.
notautomatic
s
.
overridesuite
=
suite
.
overridesuite
or
suite
.
suite_name
s
.
butautomaticupgrades
=
suite
.
butautomaticupgrades
s
.
signingkeys
=
suite
.
signingkeys
s
.
include_long_description
=
False
s
.
archive
=
build_queue_archive
s
.
architectures
.
extend
(
suite
.
architectures
)
s
.
components
.
extend
(
suite
.
components
)
s
.
srcformats
.
extend
(
suite
.
srcformats
)
session
.
add
(
s
)
session
.
flush
()
bq
=
BuildQueue
()
bq
.
queue_name
=
build_queue_codename
bq
.
suite
=
s
session
.
add
(
bq
)
session
.
flush
()
suite
.
copy_queues
.
append
(
bq
)
session
.
commit
()
def
suite
(
command
):
args
=
[
str
(
x
)
for
x
in
command
]
Cnf
=
utils
.
get_conf
()
d
=
DBConn
()
am
=
daklib
.
admin
.
ArchiveMaint
()
die_arglen
(
args
,
2
,
"E: suite needs at least a command"
)
mode
=
args
[
1
].
lower
()
if
mode
==
'list'
:
__
suite_list
(
d
,
args
)
am
.
suite_list
(
d
,
args
)
elif
mode
==
'show'
:
__
suite_show
(
d
,
args
)
am
.
suite_show
(
d
,
args
)
elif
mode
==
'rm'
:
__
suite_rm
(
d
,
args
)
am
.
suite_rm
(
d
,
args
)
elif
mode
==
'add'
:
__
suite_add
(
d
,
args
,
False
)
am
.
suite_add
(
d
,
args
,
False
)
elif
mode
==
'add-all-arches'
:
__
suite_add
(
d
,
args
,
True
)
am
.
suite_add
(
d
,
args
,
True
)
elif
mode
==
'add-build-queue'
:
__
suite_add_build_queue
(
d
,
args
)
am
.
suite_add_build_queue
(
d
,
args
)
else
:
die
(
"E: suite command unknown"
)
...
...
@@ -468,104 +328,26 @@ dispatch['s'] = suite
################################################################################
def
__suite_architecture_list
(
d
,
args
):
s
=
d
.
session
()
for
j
in
s
.
query
(
Suite
).
order_by
(
Suite
.
suite_name
):
architectures
=
j
.
get_architectures
(
skipsrc
=
True
,
skipall
=
True
)
print
j
.
suite_name
+
': '
+
\
', '
.
join
([
a
.
arch_string
for
a
in
architectures
])
def
__suite_architecture_listarch
(
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-architecture list-arch requires a suite"
)
suite
=
get_suite
(
args
[
2
].
lower
(),
d
.
session
())
if
suite
is
None
:
die
(
'E: suite %s is invalid'
%
args
[
2
].
lower
())
a
=
suite
.
get_architectures
(
skipsrc
=
True
,
skipall
=
True
)
for
j
in
a
:
print
j
.
arch_string
def
__suite_architecture_listsuite
(
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-architecture list-suite requires an arch"
)
architecture
=
get_architecture
(
args
[
2
].
lower
(),
d
.
session
())
if
architecture
is
None
:
die
(
"E: architecture %s is invalid"
%
args
[
2
].
lower
())
for
j
in
architecture
.
suites
:
print
j
.
suite_name
def
__suite_architecture_add
(
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: adding a suite-architecture entry requires a suite and arch"
)
s
=
d
.
session
()
suite
=
get_suite
(
args
[
2
].
lower
(),
s
)
if
suite
is
None
:
die
(
"E: Can't find suite %s"
%
args
[
2
].
lower
())
for
arch_name
in
args
[
3
:]:
arch
=
get_architecture
(
arch_name
.
lower
(),
s
)
if
arch
is
None
:
die
(
"E: Can't find architecture %s"
%
args
[
3
].
lower
())
try
:
suite
.
architectures
.
append
(
arch
)
s
.
flush
()
except
IntegrityError
as
e
:
die
(
"E: Can't add suite-architecture entry (%s, %s) - probably already exists"
%
(
args
[
2
].
lower
(),
arch_name
))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't add suite-architecture entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
arch_name
,
e
))
print
"Added suite-architecture entry for %s, %s"
%
(
args
[
2
].
lower
(),
arch_name
)
if
not
dryrun
:
s
.
commit
()
s
.
close
()
def
__suite_architecture_rm
(
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: removing an suite-architecture entry requires a suite and arch"
)
s
=
d
.
session
()
if
not
dryrun
:
try
:
suite_name
=
args
[
2
].
lower
()
suite
=
get_suite
(
suite_name
,
s
)
if
suite
is
None
:
die
(
'E: no such suite %s'
%
suite_name
)
arch_string
=
args
[
3
].
lower
()
architecture
=
get_architecture
(
arch_string
,
s
)
if
architecture
not
in
suite
.
architectures
:
die
(
"E: architecture %s not found in suite %s"
%
(
arch_string
,
suite_name
))
suite
.
architectures
.
remove
(
architecture
)
s
.
commit
()
except
IntegrityError
as
e
:
die
(
"E: Can't remove suite-architecture entry (%s, %s) - it's probably referenced"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
()))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't remove suite-architecture entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
(),
e
))
print
"Removed suite-architecture entry for %s, %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
())
def
suite_architecture
(
command
):
args
=
[
str
(
x
)
for
x
in
command
]
Cnf
=
utils
.
get_conf
()
d
=
DBConn
()
am
=
daklib
.
admin
.
ArchiveMaint
()
die_arglen
(
args
,
2
,
"E: suite-architecture needs at least a command"
)
mode
=
args
[
1
].
lower
()
if
mode
==
'list'
:
__
suite_architecture_list
(
d
,
args
)
am
.
suite_architecture_list
(
d
,
args
)
elif
mode
==
'list-arch'
:
__
suite_architecture_listarch
(
d
,
args
)
am
.
suite_architecture_listarch
(
d
,
args
)
elif
mode
==
'list-suite'
:
__
suite_architecture_listsuite
(
d
,
args
)
am
.
suite_architecture_listsuite
(
d
,
args
)
elif
mode
==
'add'
:
__
suite_architecture_add
(
d
,
args
)
am
.
suite_architecture_add
(
d
,
args
)
elif
mode
==
'rm'
:
__
suite_architecture_rm
(
d
,
args
)
am
.
suite_architecture_rm
(
d
,
args
)
else
:
die
(
"E: suite-architecture command unknown"
)
...
...
@@ -574,103 +356,26 @@ dispatch['s-a'] = suite_architecture
################################################################################
def
__suite_component_list
(
d
,
args
):
s
=
d
.
session
()
for
j
in
s
.
query
(
Suite
).
order_by
(
Suite
.
suite_name
):
components
=
j
.
components
print
j
.
suite_name
+
': '
+
\
', '
.
join
([
c
.
component_name
for
c
in
components
])
def
__suite_component_listcomponent
(
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-component list-component requires a suite"
)
suite
=
get_suite
(
args
[
2
].
lower
(),
d
.
session
())
if
suite
is
None
:
die
(
'E: suite %s is invalid'
%
args
[
2
].
lower
())
for
c
in
suite
.
components
:
print
c
.
component_name
def
__suite_component_listsuite
(
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-component list-suite requires an component"
)
component
=
get_component
(
args
[
2
].
lower
(),
d
.
session
())
if
component
is
None
:
die
(
"E: component %s is invalid"
%
args
[
2
].
lower
())
for
s
in
component
.
suites
:
print
s
.
suite_name
def
__suite_component_add
(
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: adding a suite-component entry requires a suite and component"
)
s
=
d
.
session
()
suite
=
get_suite
(
args
[
2
].
lower
(),
s
)
if
suite
is
None
:
die
(
"E: Can't find suite %s"
%
args
[
2
].
lower
())
for
component_name
in
args
[
3
:]:
component
=
get_component
(
component_name
.
lower
(),
s
)
if
component
is
None
:
die
(
"E: Can't find component %s"
%
args
[
3
].
lower
())
try
:
suite
.
components
.
append
(
component
)
s
.
flush
()
except
IntegrityError
as
e
:
die
(
"E: Can't add suite-component entry (%s, %s) - probably already exists"
%
(
args
[
2
].
lower
(),
component_name
))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't add suite-component entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
component_name
,
e
))
print
"Added suite-component entry for %s, %s"
%
(
args
[
2
].
lower
(),
component_name
)
if
not
dryrun
:
s
.
commit
()
s
.
close
()
def
__suite_component_rm
(
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: removing an suite-component entry requires a suite and component"
)
s
=
d
.
session
()
if
not
dryrun
:
try
:
suite_name
=
args
[
2
].
lower
()
suite
=
get_suite
(
suite_name
,
s
)
if
suite
is
None
:
die
(
'E: no such suite %s'
%
suite_name
)
component_string
=
args
[
3
].
lower
()
component
=
get_component
(
arch_string
,
s
)
if
component
not
in
suite
.
components
:
die
(
"E: component %s not found in suite %s"
%
(
component_string
,
suite_name
))
suite
.
components
.
remove
(
component
)
s
.
commit
()
except
IntegrityError
as
e
:
die
(
"E: Can't remove suite-component entry (%s, %s) - it's probably referenced"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
()))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't remove suite-component entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
(),
e
))
print
"Removed suite-component entry for %s, %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
())
def
suite_component
(
command
):
args
=
[
str
(
x
)
for
x
in
command
]
Cnf
=
utils
.
get_conf
()
d
=
DBConn
()
am
=
daklib
.
admin
.
ArchiveMaint
()
die_arglen
(
args
,
2
,
"E: suite-component needs at least a command"
)
mode
=
args
[
1
].
lower
()
if
mode
==
'list'
:
__
suite_component_list
(
d
,
args
)
am
.
suite_component_list
(
d
,
args
)
elif
mode
==
'list-component'
:
__
suite_component_listcomponent
(
d
,
args
)
am
.
suite_component_listcomponent
(
d
,
args
)
elif
mode
==
'list-suite'
:
__
suite_component_listsuite
(
d
,
args
)
am
.
suite_component_listsuite
(
d
,
args
)
elif
mode
==
'add'
:
__
suite_component_add
(
d
,
args
)
am
.
suite_component_add
(
d
,
args
)
# elif mode == 'rm':
#
__
suite_architecture_rm(d, args)
#
am.
suite_architecture_rm(d, args)
else
:
die
(
"E: suite-component command unknown"
)
...
...
daklib/admin.py
0 → 100644
浏览文件 @
c84005b5
# Copyright (C) 2012, Ansgar Burchardt <ansgar@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""module for administrative tasks in a dak install.
This module provides classes to do administrative tasks in a dak install,
eg. creating/modifying archives, suites, architectures, etc..
"""
from
daklib
import
utils
from
daklib.dbconn
import
*
################################################################################
class
ArchiveMaint
(
object
):
"""Handle low-level archive changes
"""
def
__init__
(
self
):
pass
def
suite_list
(
self
,
d
,
args
):
s
=
d
.
session
()
for
j
in
s
.
query
(
Suite
).
join
(
Suite
.
archive
).
order_by
(
Archive
.
archive_name
,
Suite
.
suite_name
).
all
():
if
len
(
args
)
>
2
and
args
[
2
]
==
"--print-archive"
:
print
"{0} {1}"
.
format
(
j
.
archive
.
archive_name
,
j
.
suite_name
)
else
:
print
"{0}"
.
format
(
j
.
suite_name
)
def
suite_show
(
self
,
d
,
args
):
if
len
(
args
)
<
2
:
die
(
"E: showing an suite entry requires a suite"
)
s
=
d
.
session
()
su
=
get_suite
(
args
[
2
].
lower
())
if
su
is
None
:
die
(
"E: can't find suite entry for %s"
%
(
args
[
2
].
lower
()))
print
su
.
details
()
def
suite_add
(
self
,
d
,
args
,
addallarches
=
False
):
die_arglen
(
args
,
4
,
"E: adding a suite requires at least a name and a version"
)
suite_name
=
args
[
2
].
lower
()
version
=
args
[
3
]
rest
=
args
[
3
:]
if
len
(
version
)
==
0
:
version
=
None
def
get_field
(
field
):
for
varval
in
args
:
if
varval
.
startswith
(
field
+
'='
):
return
varval
.
split
(
'='
)[
1
]
return
None
print
"Adding suite %s"
%
suite_name
if
not
dryrun
:
try
:
s
=
d
.
session
()
suite
=
Suite
()
suite
.
suite_name
=
suite_name
suite
.
overridecodename
=
suite_name
suite
.
version
=
version
suite
.
label
=
get_field
(
'label'
)
suite
.
description
=
get_field
(
'description'
)
suite
.
origin
=
get_field
(
'origin'
)
suite
.
codename
=
get_field
(
'codename'
)
signingkey
=
get_field
(
'signingkey'
)
if
signingkey
is
not
None
:
suite
.
signingkeys
=
[
signingkey
.
upper
()]
archive_name
=
get_field
(
'archive'
)
if
archive_name
is
not
None
:
suite
.
archive
=
get_archive
(
archive_name
,
s
)
else
:
suite
.
archive
=
s
.
query
(
Archive
).
filter
(
~
Archive
.
archive_name
.
in_
([
'build-queues'
,
'new'
,
'policy'
])).
one
()
suite
.
srcformats
=
s
.
query
(
SrcFormat
).
all
()
s
.
add
(
suite
)
s
.
flush
()
except
IntegrityError
as
e
:
die
(
"E: Integrity error adding suite %s (it probably already exists)"
%
suite_name
)
except
SQLAlchemyError
as
e
:
die
(
"E: Error adding suite %s (%s)"
%
(
suite_name
,
e
))
print
"Suite %s added"
%
(
suite_name
)
if
addallarches
:
arches
=
[]
q
=
s
.
query
(
Architecture
).
order_by
(
Architecture
.
arch_string
)
for
arch
in
q
.
all
():
suite
.
architectures
.
append
(
arch
)
arches
.
append
(
arch
.
arch_string
)
print
"Architectures %s added to %s"
%
(
','
.
join
(
arches
),
suite_name
)
s
.
commit
()
def
suite_rm
(
self
,
d
,
args
):
die_arglen
(
args
,
3
,
"E: removing a suite requires at least a name"
)
name
=
args
[
2
]
print
"Removing suite {0}"
.
format
(
name
)
if
not
dryrun
:
try
:
s
=
d
.
session
()
su
=
get_suite
(
name
.
lower
())
if
su
is
None
:
die
(
"E: Cannot find suite {0}"
.
format
(
name
))
s
.
delete
(
su
)
s
.
commit
()
except
IntegrityError
as
e
:
die
(
"E: Integrity error removing suite {0} (suite-arch entries probably still exist)"
.
format
(
name
))
except
SQLAlchemyError
as
e
:
die
(
"E: Error removing suite {0} ({1})"
.
format
(
name
,
e
))
print
"Suite {0} removed"
.
format
(
name
)
def
suite_add_build_queue
(
self
,
d
,
args
):
session
=
d
.
session
()
die_arglen
(
args
,
6
,
"E: Adding a build queue needs four parameters."
)
suite_name
=
args
[
2
]
build_queue_name
=
args
[
3
]
build_queue_codename
=
args
[
4
]
build_queue_archive_name
=
args
[
5
]
try
:
suite
=
session
.
query
(
Suite
).
filter_by
(
suite_name
=
suite_name
).
one
()
except
NoResultFound
:
die
(
"E: Unknown suite '{0}'"
.
format
(
suite_name
))
try
:
build_queue_archive
=
session
.
query
(
Archive
).
filter_by
(
archive_name
=
build_queue_archive_name
).
one
()
except
NoResultFound
:
die
(
"E: Unknown archive '{0}'"
.
format
(
build_queue_archive_name
))
# Create suite
s
=
Suite
()
s
.
suite_name
=
build_queue_name
s
.
origin
=
suite
.
origin
s
.
label
=
suite
.
label
s
.
description
=
"buildd {0} incoming"
.
format
(
suite_name
)
s
.
codename
=
build_queue_codename
s
.
notautomatic
=
suite
.
notautomatic
s
.
overridesuite
=
suite
.
overridesuite
or
suite
.
suite_name
s
.
butautomaticupgrades
=
suite
.
butautomaticupgrades
s
.
signingkeys
=
suite
.
signingkeys
s
.
include_long_description
=
False
s
.
archive
=
build_queue_archive
s
.
architectures
.
extend
(
suite
.
architectures
)
s
.
components
.
extend
(
suite
.
components
)
s
.
srcformats
.
extend
(
suite
.
srcformats
)
session
.
add
(
s
)
session
.
flush
()
bq
=
BuildQueue
()
bq
.
queue_name
=
build_queue_codename
bq
.
suite
=
s
session
.
add
(
bq
)
session
.
flush
()
suite
.
copy_queues
.
append
(
bq
)
session
.
commit
()
def
suite_architecture_list
(
self
,
d
,
args
):
s
=
d
.
session
()
for
j
in
s
.
query
(
Suite
).
order_by
(
Suite
.
suite_name
):
architectures
=
j
.
get_architectures
(
skipsrc
=
True
,
skipall
=
True
)
print
j
.
suite_name
+
': '
+
\
', '
.
join
([
a
.
arch_string
for
a
in
architectures
])
def
suite_architecture_listarch
(
self
,
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-architecture list-arch requires a suite"
)
suite
=
get_suite
(
args
[
2
].
lower
(),
d
.
session
())
if
suite
is
None
:
die
(
'E: suite %s is invalid'
%
args
[
2
].
lower
())
a
=
suite
.
get_architectures
(
skipsrc
=
True
,
skipall
=
True
)
for
j
in
a
:
print
j
.
arch_string
def
suite_architecture_listsuite
(
self
,
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-architecture list-suite requires an arch"
)
architecture
=
get_architecture
(
args
[
2
].
lower
(),
d
.
session
())
if
architecture
is
None
:
die
(
"E: architecture %s is invalid"
%
args
[
2
].
lower
())
for
j
in
architecture
.
suites
:
print
j
.
suite_name
def
suite_architecture_add
(
self
,
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: adding a suite-architecture entry requires a suite and arch"
)
s
=
d
.
session
()
suite
=
get_suite
(
args
[
2
].
lower
(),
s
)
if
suite
is
None
:
die
(
"E: Can't find suite %s"
%
args
[
2
].
lower
())
for
arch_name
in
args
[
3
:]:
arch
=
get_architecture
(
arch_name
.
lower
(),
s
)
if
arch
is
None
:
die
(
"E: Can't find architecture %s"
%
args
[
3
].
lower
())
try
:
suite
.
architectures
.
append
(
arch
)
s
.
flush
()
except
IntegrityError
as
e
:
die
(
"E: Can't add suite-architecture entry (%s, %s) - probably already exists"
%
(
args
[
2
].
lower
(),
arch_name
))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't add suite-architecture entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
arch_name
,
e
))
print
"Added suite-architecture entry for %s, %s"
%
(
args
[
2
].
lower
(),
arch_name
)
if
not
dryrun
:
s
.
commit
()
s
.
close
()
def
suite_architecture_rm
(
self
,
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: removing an suite-architecture entry requires a suite and arch"
)
s
=
d
.
session
()
if
not
dryrun
:
try
:
suite_name
=
args
[
2
].
lower
()
suite
=
get_suite
(
suite_name
,
s
)
if
suite
is
None
:
die
(
'E: no such suite %s'
%
suite_name
)
arch_string
=
args
[
3
].
lower
()
architecture
=
get_architecture
(
arch_string
,
s
)
if
architecture
not
in
suite
.
architectures
:
die
(
"E: architecture %s not found in suite %s"
%
(
arch_string
,
suite_name
))
suite
.
architectures
.
remove
(
architecture
)
s
.
commit
()
except
IntegrityError
as
e
:
die
(
"E: Can't remove suite-architecture entry (%s, %s) - it's probably referenced"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
()))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't remove suite-architecture entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
(),
e
))
print
"Removed suite-architecture entry for %s, %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
())
def
suite_component_list
(
self
,
d
,
args
):
s
=
d
.
session
()
for
j
in
s
.
query
(
Suite
).
order_by
(
Suite
.
suite_name
):
components
=
j
.
components
print
j
.
suite_name
+
': '
+
\
', '
.
join
([
c
.
component_name
for
c
in
components
])
def
suite_component_listcomponent
(
self
,
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-component list-component requires a suite"
)
suite
=
get_suite
(
args
[
2
].
lower
(),
d
.
session
())
if
suite
is
None
:
die
(
'E: suite %s is invalid'
%
args
[
2
].
lower
())
for
c
in
suite
.
components
:
print
c
.
component_name
def
suite_component_listsuite
(
self
,
d
,
args
):
die_arglen
(
args
,
3
,
"E: suite-component list-suite requires an component"
)
component
=
get_component
(
args
[
2
].
lower
(),
d
.
session
())
if
component
is
None
:
die
(
"E: component %s is invalid"
%
args
[
2
].
lower
())
for
s
in
component
.
suites
:
print
s
.
suite_name
def
suite_component_add
(
self
,
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: adding a suite-component entry requires a suite and component"
)
s
=
d
.
session
()
suite
=
get_suite
(
args
[
2
].
lower
(),
s
)
if
suite
is
None
:
die
(
"E: Can't find suite %s"
%
args
[
2
].
lower
())
for
component_name
in
args
[
3
:]:
component
=
get_component
(
component_name
.
lower
(),
s
)
if
component
is
None
:
die
(
"E: Can't find component %s"
%
args
[
3
].
lower
())
try
:
suite
.
components
.
append
(
component
)
s
.
flush
()
except
IntegrityError
as
e
:
die
(
"E: Can't add suite-component entry (%s, %s) - probably already exists"
%
(
args
[
2
].
lower
(),
component_name
))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't add suite-component entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
component_name
,
e
))
print
"Added suite-component entry for %s, %s"
%
(
args
[
2
].
lower
(),
component_name
)
if
not
dryrun
:
s
.
commit
()
s
.
close
()
def
suite_component_rm
(
self
,
d
,
args
):
if
len
(
args
)
<
3
:
die
(
"E: removing an suite-component entry requires a suite and component"
)
s
=
d
.
session
()
if
not
dryrun
:
try
:
suite_name
=
args
[
2
].
lower
()
suite
=
get_suite
(
suite_name
,
s
)
if
suite
is
None
:
die
(
'E: no such suite %s'
%
suite_name
)
component_string
=
args
[
3
].
lower
()
component
=
get_component
(
arch_string
,
s
)
if
component
not
in
suite
.
components
:
die
(
"E: component %s not found in suite %s"
%
(
component_string
,
suite_name
))
suite
.
components
.
remove
(
component
)
s
.
commit
()
except
IntegrityError
as
e
:
die
(
"E: Can't remove suite-component entry (%s, %s) - it's probably referenced"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
()))
except
SQLAlchemyError
as
e
:
die
(
"E: Can't remove suite-component entry (%s, %s) - %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
(),
e
))
print
"Removed suite-component entry for %s, %s"
%
(
args
[
2
].
lower
(),
args
[
3
].
lower
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录