Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
I
inary
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
1
Konular (issue)
1
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
inary
Commits
fc65be1e
Kaydet (Commit)
fc65be1e
authored
Nis 24, 2006
tarafından
Faik Uygur
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Conflict kodu revize edildi. Depo'dan ve Dosya'dan kurulumda çalışsın. (#2548)
Conflict kodu için unittest yazıldı.
üst
17fc0eda
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
23 deletions
+119
-23
operations.py
pisi/operations.py
+52
-23
conflicttests.py
tests/conflicttests.py
+67
-0
No files found.
pisi/operations.py
Dosyayı görüntüle @
fc65be1e
...
...
@@ -147,6 +147,7 @@ in the respective order to satisfy extra dependencies:
if
ctx
.
config
.
get_option
(
'debug'
):
G_f
.
write_graphviz
(
sys
.
stdout
)
order
=
G_f
.
topological_sort
()
check_conflicts
(
order
,
packagedb
)
order
.
reverse
()
ctx
.
ui
.
info
(
_
(
'Installation order: '
)
+
util
.
strlist
(
order
)
)
...
...
@@ -158,28 +159,56 @@ in the respective order to satisfy extra dependencies:
for
x
in
order
:
atomicoperations
.
install_single_file
(
dfn
[
x
])
def
check_conflicts
(
order
):
"""check if upgrading to the latest versions will cause havoc
done in a simple minded way without regard for dependencies of
conflicts, etc."""
B_0
=
B
=
set
(
order
)
C
=
set
()
# calculate conflict closure
while
len
(
B
)
>
0
:
Bp
=
set
()
for
x
in
B
:
pkg
=
ctx
.
packagedb
.
get_package
(
x
)
# get latest version!
#TODO: read conflicts from a conflicts db...
for
conflict
in
pkg
.
conflicts
:
if
ctx
.
installdb
.
is_installed
(
self
.
pkginfo
):
Bp
.
add
(
conflict
)
C
.
add
(
conflict
)
B
=
Bp
if
B_0
.
intersection
(
C
):
raise
Error
(
_
(
"Selected packages
%
s and
%
s are in conflict."
)
%
(
x
,
pkg
))
if
C
:
def
check_conflict
(
pkg
):
conflicts
=
[]
for
c
in
pkg
.
conflicts
:
if
ctx
.
installdb
.
is_installed
(
c
):
conflicts
.
append
(
c
)
return
conflicts
def
calculate_conflicts
(
order
,
packagedb
):
B_0
=
set
(
order
)
C
=
D
=
set
()
pkg_conflicts
=
{}
for
x
in
order
:
pkg
=
packagedb
.
get_package
(
x
)
B_p
=
set
(
check_conflict
(
pkg
))
if
B_p
:
pkg_conflicts
[
x
]
=
B_p
C
=
C
.
union
(
B_p
)
B_i
=
B_0
.
intersection
(
set
(
pkg
.
conflicts
))
# check if there are any conflicts within the packages that are
# going to be installed
if
B_i
:
D
=
D
.
union
(
B_i
)
D
.
add
(
pkg
.
name
)
return
(
C
,
D
,
pkg_conflicts
)
def
check_conflicts
(
order
,
packagedb
):
(
C
,
D
,
pkg_conflicts
)
=
calculate_conflicts
(
order
,
packagedb
)
if
D
:
raise
Error
(
_
(
"Selected packages [
%
s] are in conflict with each other."
)
%
util
.
strlist
(
list
(
D
)))
if
pkg_conflicts
:
conflicts
=
""
for
pkg
in
pkg_conflicts
.
keys
():
conflicts
+=
"[
%
s conflicts with:
%
s]"
%
(
pkg
,
util
.
strlist
(
pkg_conflicts
[
pkg
]))
ctx
.
ui
.
info
(
_
(
"The following packages have conflicts:
%
s"
)
%
conflicts
)
if
not
ctx
.
ui
.
confirm
(
_
(
'Remove the following conflicting packages?'
)):
#raise Error(_("Package %s conflicts installed package %s") % (x, pkg))
raise
Error
(
_
(
"Conflicts remain"
))
if
remove
(
list
(
C
))
==
False
:
raise
Error
(
_
(
"Conflicts remain"
))
def
expand_components
(
A
):
...
...
@@ -273,7 +302,7 @@ def plan_install_pkg_names(A):
G_f
.
write_graphviz
(
sys
.
stdout
)
order
=
G_f
.
topological_sort
()
order
.
reverse
()
check_conflicts
(
order
)
check_conflicts
(
order
,
ctx
.
packagedb
)
return
G_f
,
order
def
upgrade
(
A
):
...
...
@@ -423,7 +452,7 @@ def plan_upgrade(A):
G_f
.
write_graphviz
(
sys
.
stdout
)
order
=
G_f
.
topological_sort
()
order
.
reverse
()
check_conflicts
(
order
)
check_conflicts
(
order
,
ctx
.
packagedb
)
return
G_f
,
order
def
remove
(
A
):
...
...
tests/conflicttests.py
0 → 100644
Dosyayı görüntüle @
fc65be1e
# Copyright (C) 2006, TUBITAK/UEKAE
#
# 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.
#
# Please read the COPYING file.
#
# Author: Faik Uygur <faik@pardus.org.tr>
import
unittest
import
pisi.api
import
pisi
class
ConflictTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
pisi
.
api
.
init
(
write
=
False
)
d_t
=
{}
packages
=
{
"a"
:
[
"z"
,
"t"
,
"d"
],
"b"
:
[
"a"
,
"e"
,
"f"
],
"c"
:
[
"g"
,
"h"
],
"d"
:
[],
"e"
:
[
"j"
],
"amigo"
:
[
"pciutils"
,
"agimo"
,
"libpng"
,
"ncurses"
,
"soniga"
],
"imago"
:
[
"less"
],
"gomia"
:
[
"hede"
,
"hodo"
,
"libpng"
],
"omiga"
:
[]}
for
name
in
packages
.
keys
():
pkg
=
pisi
.
specfile
.
Package
()
pkg
.
name
=
name
pkg
.
conflicts
=
packages
[
name
]
d_t
[
name
]
=
pkg
class
PackageDB
:
def
get_package
(
self
,
key
):
return
d_t
[
str
(
key
)]
self
.
packagedb
=
PackageDB
()
def
tearDown
(
self
,
):
pisi
.
api
.
finalize
()
def
testConflictWithEachOther
(
self
):
packages
=
[
"a"
,
"b"
,
"c"
,
"d"
,
"e"
]
(
C
,
D
,
pkg_conflicts
)
=
pisi
.
operations
.
calculate_conflicts
(
packages
,
self
.
packagedb
)
self
.
assert_
([
'a'
,
'b'
,
'e'
,
'd'
]
==
list
(
D
))
def
testConflictWithInstalled
(
self
):
packages
=
[
"amigo"
,
"imago"
,
"omiga"
]
(
C
,
D
,
pkg_conflicts
)
=
pisi
.
operations
.
calculate_conflicts
(
packages
,
self
.
packagedb
)
self
.
assert_
(
not
D
)
self
.
assert_
([
'libpng'
,
'ncurses'
,
'less'
,
'pciutils'
]
==
list
(
C
))
self
.
assert_
([
'libpng'
,
'ncurses'
,
'pciutils'
]
==
list
(
pkg_conflicts
[
"amigo"
]))
self
.
assert_
(
"agimo"
not
in
list
(
pkg_conflicts
[
"amigo"
]))
def
testConflictWithEachOtherAndInstalled
(
self
):
packages
=
[
"amigo"
,
"imago"
,
"a"
,
"b"
,
"c"
]
(
C
,
D
,
pkg_conflicts
)
=
pisi
.
operations
.
calculate_conflicts
(
packages
,
self
.
packagedb
)
self
.
assert_
([
'a'
,
'b'
]
==
list
(
D
))
self
.
assert_
([
'libpng'
,
'ncurses'
,
'less'
,
'pciutils'
]
==
list
(
C
))
self
.
assert_
([
'libpng'
,
'ncurses'
,
'pciutils'
]
==
list
(
pkg_conflicts
[
"amigo"
]))
self
.
assert_
(
"agimo"
not
in
list
(
pkg_conflicts
[
"amigo"
]))
suite
=
unittest
.
makeSuite
(
ConflictTestCase
)
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