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
6dcb5abf
Kaydet (Commit)
6dcb5abf
authored
Şub 06, 2020
tarafından
Ali Rıza Keskin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
scomiface yerine reactor koyduk çalışıyor.
üst
bcb7d02c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
168 additions
and
251 deletions
+168
-251
atomicoperations.py
inary/atomicoperations.py
+8
-9
configurepending.py
inary/cli/configurepending.py
+2
-3
inarycli.py
inary/cli/inarycli.py
+1
-0
reconfigure.py
inary/cli/reconfigure.py
+82
-0
reactor.py
inary/reactor.py
+75
-0
scomiface.py
inary/scomiface.py
+0
-239
No files found.
inary/atomicoperations.py
Dosyayı görüntüle @
6dcb5abf
...
...
@@ -194,8 +194,7 @@ class Install(AtomicOperation):
# what to do if / is split into /usr, /var, etc.
# check scom
if
self
.
metadata
.
package
.
providesScom
and
ctx
.
scom
and
not
ctx
.
get_option
(
"ignore_scom"
):
import
inary.scomiface
as
scomiface
scomiface
.
get_link
()
import
inary.reactor
as
reactor
def
check_replaces
(
self
):
for
replaced
in
self
.
pkginfo
.
replaces
:
...
...
@@ -316,7 +315,7 @@ class Install(AtomicOperation):
# os.chown(fpath, int(_file.uid), int(_file.gid))
if
self
.
metadata
.
package
.
providesScom
:
if
ctx
.
scom
and
not
ctx
.
get_option
(
"ignore_scom"
):
import
inary.
scomiface
import
inary.
reactor
try
:
if
self
.
operation
==
UPGRADE
or
self
.
operation
==
DOWNGRADE
:
fromVersion
=
self
.
old_pkginfo
.
version
...
...
@@ -325,7 +324,7 @@ class Install(AtomicOperation):
fromVersion
=
None
fromRelease
=
None
ctx
.
ui
.
notify
(
inary
.
ui
.
configuring
,
package
=
self
.
pkginfo
,
files
=
self
.
files
)
inary
.
scomiface
.
post_install
(
inary
.
reactor
.
post_install
(
self
.
pkginfo
.
name
,
self
.
metadata
.
package
.
providesScom
,
self
.
package
.
scom_dir
(),
...
...
@@ -337,7 +336,7 @@ class Install(AtomicOperation):
self
.
metadata
.
package
.
release
)
ctx
.
ui
.
notify
(
inary
.
ui
.
configured
,
package
=
self
.
pkginfo
,
files
=
self
.
files
)
except
inary
.
scomiface
.
Error
:
except
:
ctx
.
ui
.
warning
(
_
(
'Configuration of
\"
{}
\"
package failed.'
)
.
format
(
self
.
pkginfo
.
name
))
self
.
config_later
=
True
else
:
...
...
@@ -695,8 +694,8 @@ class Remove(AtomicOperation):
def
run_preremove
(
self
):
if
self
.
package
.
providesScom
:
if
ctx
.
scom
and
not
ctx
.
get_option
(
"ignore_scom"
):
import
inary.
scomiface
inary
.
scomiface
.
pre_remove
(
import
inary.
reactor
inary
.
reactor
.
pre_remove
(
self
.
package_name
,
os
.
path
.
join
(
self
.
package
.
pkg_dir
(),
ctx
.
const
.
metadata_xml
),
os
.
path
.
join
(
self
.
package
.
pkg_dir
(),
ctx
.
const
.
files_xml
),
...
...
@@ -705,8 +704,8 @@ class Remove(AtomicOperation):
def
run_postremove
(
self
):
if
self
.
package
.
providesScom
:
if
ctx
.
scom
and
not
ctx
.
get_option
(
"ignore_scom"
):
import
inary.
scomiface
inary
.
scomiface
.
post_remove
(
import
inary.
reactor
inary
.
reactor
.
post_remove
(
self
.
package_name
,
os
.
path
.
join
(
self
.
package
.
pkg_dir
(),
ctx
.
const
.
metadata_xml
),
os
.
path
.
join
(
self
.
package
.
pkg_dir
(),
ctx
.
const
.
files_xml
),
...
...
inary/cli/configurepending.py
Dosyayı görüntüle @
6dcb5abf
...
...
@@ -25,11 +25,10 @@ import inary.ui
import
inary.data
import
inary.errors
import
inary.context
as
ctx
import
inary.reactor
def
configure_pending
(
packages
=
None
):
# Import SCOM
import
inary.scomiface
# start with pending packages
# configure them in reverse topological order of dependency
...
...
@@ -51,7 +50,7 @@ def configure_pending(packages=None):
# FIXME: we need a full package info here!
pkginfo
.
name
=
x
ctx
.
ui
.
notify
(
inary
.
ui
.
configuring
,
package
=
pkginfo
,
files
=
None
)
inary
.
scomiface
.
post_install
(
inary
.
reactor
.
post_install
(
pkginfo
.
name
,
m
.
package
.
providesScom
,
util
.
join_path
(
pkg_path
,
ctx
.
const
.
scom_dir
),
...
...
inary/cli/inarycli.py
Dosyayı görüntüle @
6dcb5abf
...
...
@@ -52,6 +52,7 @@ import inary.cli.listrepo
import
inary.cli.listsources
import
inary.cli.listupgrades
import
inary.cli.rebuilddb
import
inary.cli.reconfigure
import
inary.cli.remove
import
inary.cli.removerepo
import
inary.cli.removeorphaned
...
...
inary/cli/reconfigure.py
0 → 100644
Dosyayı görüntüle @
6dcb5abf
# -*- coding:utf-8 -*-
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
# Copyright (C) 2016 - 2018, Suleyman POYRAZ (Zaryob)
#
# 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 3 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import
optparse
import
gettext
__trans
=
gettext
.
translation
(
'inary'
,
fallback
=
True
)
_
=
__trans
.
gettext
import
inary.util
as
util
import
inary.cli.command
as
command
import
inary.ui
import
inary.data
import
inary.errors
import
inary.context
as
ctx
import
inary.reactor
def
configure_pending
(
packages
=
None
):
# start with pending packages
# configure them in reverse topological order of dependency
installdb
=
inary
.
db
.
installdb
.
InstallDB
()
order
=
packages
if
True
:
for
x
in
order
:
if
installdb
.
has_package
(
x
):
pkginfo
=
installdb
.
get_package
(
x
)
pkg_path
=
installdb
.
package_path
(
x
)
m
=
inary
.
data
.
metadata
.
MetaData
()
metadata_path
=
util
.
join_path
(
pkg_path
,
ctx
.
const
.
metadata_xml
)
m
.
read
(
metadata_path
)
# FIXME: we need a full package info here!
pkginfo
.
name
=
x
ctx
.
ui
.
notify
(
inary
.
ui
.
configuring
,
package
=
pkginfo
,
files
=
None
)
inary
.
reactor
.
post_install
(
pkginfo
.
name
,
m
.
package
.
providesScom
,
util
.
join_path
(
pkg_path
,
ctx
.
const
.
scom_dir
),
util
.
join_path
(
pkg_path
,
ctx
.
const
.
metadata_xml
),
util
.
join_path
(
pkg_path
,
ctx
.
const
.
files_xml
),
None
,
None
,
m
.
package
.
version
,
m
.
package
.
release
)
ctx
.
ui
.
notify
(
inary
.
ui
.
configured
,
package
=
pkginfo
,
files
=
None
)
installdb
.
clear_pending
(
x
)
class
ConfigurePending
(
command
.
PackageOp
,
metaclass
=
command
.
autocommand
):
__doc__
=
_
(
"""Reconfigure pending packages
If SCOM configuration of some packages were not
done at installation time, they are added to a list
of packages waiting to be configured. This command
configures those packages.
"""
)
def
__init__
(
self
,
args
):
super
(
ConfigurePending
,
self
)
.
__init__
(
args
)
name
=
(
_
(
"reconfigure"
),
"rp"
)
def
options
(
self
):
group
=
optparse
.
OptionGroup
(
self
.
parser
,
_
(
"configure-pending options"
))
super
(
ConfigurePending
,
self
)
.
options
(
group
)
self
.
parser
.
add_option_group
(
group
)
def
run
(
self
):
self
.
init
(
database
=
True
,
write
=
False
)
configure_pending
(
self
.
args
)
inary/reactor.py
0 → 100644
Dosyayı görüntüle @
6dcb5abf
# -*- coding: utf-8 -*-
#
#Copyright (C) 2019, Ali Rıza KESKİN (sulincix)
#
# 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 3 of the License, or (at your option)
# any later version.
#
import
gettext
__trans
=
gettext
.
translation
(
'inary'
,
fallback
=
True
)
_
=
__trans
.
gettext
import
inary.context
as
ctx
import
inary.db
import
inary.util
as
util
import
os
import
sys
installdb
=
inary
.
db
.
installdb
.
InstallDB
()
def
post_install
(
package_name
,
provided_scripts
,
scriptpath
,
metapath
,
filepath
,
fromVersion
,
fromRelease
,
toVersion
,
toRelease
):
"""Do package's post install operations"""
pkg_path
=
installdb
.
package_path
(
package_name
)
if
(
os
.
path
.
isfile
(
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
+
"/package.py"
)):
sys
.
path
.
insert
(
0
,
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
)
else
:
return
0
import
package
as
package_py
package_py
.
postInstall
(
fromVersion
,
fromRelease
,
toVersion
,
toRelease
)
del
package_py
sys
.
path
.
pop
(
0
)
def
pre_install
(
package_name
,
provided_scripts
,
scriptpath
,
metapath
,
filepath
,
fromVersion
,
fromRelease
,
toVersion
,
toRelease
):
"""Do package's pre install operations"""
pkg_path
=
installdb
.
package_path
(
package_name
)
if
(
os
.
path
.
isfile
(
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
+
"/package.py"
)):
sys
.
path
.
insert
(
0
,
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
)
else
:
return
0
import
package
as
package_py
if
"preInstall"
in
dir
(
package_py
):
package_py
.
preInstall
(
fromVersion
,
fromRelease
,
toVersion
,
toRelease
)
del
package_py
sys
.
path
.
pop
(
0
)
def
post_remove
(
package_name
,
metapath
,
filepath
,
provided_scripts
=
None
):
"""Do package's post removal operations"""
pkg_path
=
installdb
.
package_path
(
package_name
)
if
(
os
.
path
.
isfile
(
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
+
"/package.py"
)):
sys
.
path
.
insert
(
0
,
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
)
else
:
return
0
import
package
as
package_py
if
"postInstall"
in
dir
(
package_py
):
package_py
.
postRemove
(
timeout
=
ctx
.
dbus_timeout
)
del
package_py
sys
.
path
.
pop
(
0
)
def
pre_remove
(
package_name
,
metapath
,
filepath
):
"""Do package's post removal operations"""
pkg_path
=
installdb
.
package_path
(
package_name
)
if
(
os
.
path
.
isfile
(
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
+
"/package.py"
)):
sys
.
path
.
insert
(
0
,
pkg_path
+
"/"
+
ctx
.
const
.
scom_dir
)
else
:
return
0
import
package
as
package_py
if
"postInstall"
in
dir
(
package_py
):
package_py
.
preRemove
(
timeout
=
ctx
.
dbus_timeout
)
del
package_py
sys
.
path
.
pop
(
0
)
inary/scomiface.py
deleted
100644 → 0
Dosyayı görüntüle @
bcb7d02c
# -*- coding: utf-8 -*-
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
# Copyright (C) 2016 - 2018, Suleyman POYRAZ (Zaryob)
#
# 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 3 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import
os
import
time
import
gettext
__trans
=
gettext
.
translation
(
'inary'
,
fallback
=
True
)
_
=
__trans
.
gettext
import
inary.api
import
inary.context
as
ctx
import
inary.errors
import
inary.util
as
util
class
Error
(
inary
.
errors
.
Error
):
pass
try
:
import
scom
import
dbus
except
ImportError
:
raise
Error
(
_
(
"scom package is not fully installed."
))
def
is_char_valid
(
char
):
"""Test if char is valid object path character."""
return
char
in
util
.
ascii_letters
+
util
.
digits
+
"_"
def
is_method_missing
(
exception
):
"""Tells if exception is about missing method in SCOM script"""
if
(
"tr.org.sulin.scom.Missing"
or
"tr.org.sulin.scom.python.missing"
)
in
str
(
exception
):
ctx
.
ui
.
debug
(
str
(
exception
)
.
split
(
":"
)[
-
1
])
return
True
return
False
def
safe_script_name
(
package
):
"""Generates DBus-safe object name for package script names."""
object
=
package
for
char
in
package
:
if
not
is_char_valid
(
char
):
object
=
object
.
replace
(
char
,
'_'
)
if
object
[
0
]
.
isdigit
():
object
=
'_{}'
.
format
(
object
)
return
object
def
get_link
():
"""Connect to the SCOM daemon and return the link."""
sockname
=
"/var/run/dbus/system_bus_socket"
if
ctx
.
dbus_sockname
:
sockname
=
ctx
.
dbus_sockname
alternate
=
False
# If SCOM package is updated, all new configuration requests should be
# made through new SCOM service. Passing alternate=True to Link() class
# will ensure this.
if
ctx
.
scom_updated
:
alternate
=
True
# This function is sometimes called when scom has recently started
# or restarting after an update. So we give scom a chance to become
# active in a reasonable time.
timeout
=
7
exceptions
=
[]
while
timeout
>
0
:
try
:
link
=
scom
.
Link
(
socket
=
sockname
,
alternate
=
alternate
)
link
.
setLocale
()
return
link
except
dbus
.
exceptions
.
DBusException
as
e
:
if
str
(
e
)
in
exceptions
:
pass
else
:
exceptions
.
append
(
str
(
e
))
except
Exception
as
e
:
if
str
(
e
)
in
exceptions
:
pass
else
:
exceptions
.
append
(
str
(
e
))
time
.
sleep
(
0.2
)
timeout
-=
0.2
raise
Error
(
_
(
"Cannot connect to SCOM:
\n
\"
{}
\"\n
"
)
.
format
(
"
\n
"
.
join
(
exceptions
)))
def
post_install
(
package_name
,
provided_scripts
,
scriptpath
,
metapath
,
filepath
,
fromVersion
,
fromRelease
,
toVersion
,
toRelease
):
"""Do package's post install operations"""
self_post
=
False
package_name
=
safe_script_name
(
package_name
)
if
package_name
==
'scom'
:
ctx
.
ui
.
debug
(
_
(
"SCOM package updated. From now on,"
" using new SCOM daemon."
))
inary
.
api
.
set_scom_updated
(
True
)
link
=
get_link
()
for
script
in
provided_scripts
:
ctx
.
ui
.
debug
(
_
(
"Registering
\"
{0}
\"
named scom script for
\"
{1}
\"
."
)
.
format
(
script
.
om
,
package_name
))
script_name
=
safe_script_name
(
script
.
name
)
\
if
script
.
name
else
package_name
if
script
.
om
==
"System.Package"
:
self_post
=
True
try
:
link
.
register
(
script_name
,
script
.
om
,
os
.
path
.
join
(
scriptpath
,
script
.
script
))
except
dbus
.
exceptions
.
DBusException
as
exception
:
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
if
script
.
om
==
"System.Service"
:
try
:
link
.
System
.
Service
[
script_name
]
.
registerState
()
except
dbus
.
exceptions
.
DBusException
as
exception
:
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
ctx
.
ui
.
debug
(
_
(
"Calling post install handlers for
\"
{}
\"
package."
)
.
format
(
package_name
))
for
handler
in
link
.
System
.
PackageHandler
:
try
:
link
.
System
.
PackageHandler
[
handler
]
.
setupPackage
(
metapath
,
filepath
,
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
# Do nothing if setupPackage method is not defined
# in package script
if
not
is_method_missing
(
exception
):
raise
Error
(
_
(
"Script error for
\"
{0}
\"
package: {1}."
)
.
format
(
package_name
,
exception
))
if
(
self_post
and
hasattr
(
link
.
System
.
Package
[
package_name
],
"postInstall"
)):
if
not
fromVersion
:
fromVersion
=
""
if
not
fromRelease
:
fromRelease
=
""
ctx
.
ui
.
debug
(
_
(
"Running package's post install script for
\"
{0}
\"
package."
)
.
format
(
package_name
))
try
:
link
.
System
.
Package
[
package_name
]
.
postInstall
(
fromVersion
,
fromRelease
,
toVersion
,
toRelease
,
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
# Do nothing if postInstall method is not defined in package script
if
not
is_method_missing
(
exception
):
raise
Error
(
_
(
"Script error for
\"
{0}
\"
package: {1}"
)
.
format
(
package_name
,
exception
))
def
pre_remove
(
package_name
,
metapath
,
filepath
):
"""Do package's pre removal operations"""
ctx
.
ui
.
info
(
_
(
"Running pre removal operations for
\"
{}
\"
package."
)
.
format
(
package_name
))
link
=
get_link
()
package_name
=
safe_script_name
(
package_name
)
if
package_name
in
list
(
link
.
System
.
Package
):
if
hasattr
(
link
.
System
.
Package
[
package_name
],
"preRemove"
):
ctx
.
ui
.
debug
(
_
(
"Running package's pre remove script for
\"
{}
\"
package."
)
.
format
(
package_name
))
try
:
link
.
System
.
Package
[
package_name
]
.
preRemove
(
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
# Do nothing if preRemove method is not defined in package script
if
not
is_method_missing
(
exception
):
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
ctx
.
ui
.
debug
(
_
(
"Calling pre remove handlers for
\"
{}
\"
package."
)
.
format
(
package_name
))
for
handler
in
list
(
link
.
System
.
PackageHandler
):
try
:
link
.
System
.
PackageHandler
[
handler
]
.
cleanupPackage
(
metapath
,
filepath
,
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
# Do nothing if cleanupPackage method is not defined
# in package script
if
not
is_method_missing
(
exception
):
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
def
post_remove
(
package_name
,
metapath
,
filepath
,
provided_scripts
=
None
):
"""Do package's post removal operations"""
if
provided_scripts
is
None
:
provided_scripts
=
[]
ctx
.
ui
.
info
(
_
(
"Running post removal operations for
\"
{}
\"
package."
)
.
format
(
package_name
))
link
=
get_link
()
package_name
=
safe_script_name
(
package_name
)
scripts
=
set
([
safe_script_name
(
s
.
name
)
for
s
\
in
provided_scripts
if
s
.
name
])
scripts
.
add
(
package_name
)
if
package_name
in
list
(
link
.
System
.
Package
):
if
hasattr
(
link
.
System
.
Package
[
package_name
],
"postRemove"
):
ctx
.
ui
.
debug
(
_
(
"Running package's postremove script for
\"
{}
\"
package."
)
.
format
(
package_name
))
try
:
link
.
System
.
Package
[
package_name
]
.
postRemove
(
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
# Do nothing if postRemove method is not defined in package script
if
not
is_method_missing
(
exception
):
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
ctx
.
ui
.
debug
(
_
(
"Calling post remove handlers for
\"
{}
\"
package."
)
.
format
(
package_name
))
for
handler
in
list
(
link
.
System
.
PackageHandler
):
try
:
link
.
System
.
PackageHandler
[
handler
]
.
postCleanupPackage
(
metapath
,
filepath
,
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
# Do nothing if postCleanupPackage method is not defined
# in package script
if
not
is_method_missing
(
exception
):
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
ctx
.
ui
.
debug
(
_
(
"Unregistering scom scripts of
\"
{}
\"
package."
)
.
format
(
package_name
))
for
scr
in
scripts
:
try
:
ctx
.
ui
.
debug
(
_
(
"Unregistering {} script."
)
.
format
(
scr
))
link
.
remove
(
scr
,
timeout
=
ctx
.
dbus_timeout
)
except
dbus
.
exceptions
.
DBusException
as
exception
:
raise
Error
(
_
(
"Script error: {}"
)
.
format
(
exception
))
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