Kaydet (Commit) c36f9be7 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Merge branch 'reator' into develop

<!-- Document Type Declaration file for INARY pspec.xml files -->
<!-- http://www.sulin.org.tr/projeler/inary/ -->
<!-- https://gitlab.com/sulinos/devel/inary -->
<!ELEMENT INARY (Source,Package+,History)>
......@@ -104,10 +104,18 @@
Provides
)*>
<!ELEMENT Provides (SCOM)+>
<!ELEMENT SCOM (#PCDATA)>
<!ATTLIST SCOM script CDATA #IMPLIED>
<!ATTLIST SCOM name CDATA #IMPLIED>
<!ELEMENT Provides (CMAKE)>
<!ELEMENT CMAKE (#PCDATA)>
<!ELEMENT Provides (PkgConfig)>
<!ELEMENT PkgConfig (#PCDATA)>
<!ELEMENT Provides (Command)>
<!ELEMENT Command (#PCDATA)>
<!ELEMENT Provides (SharedObject)>
<!ELEMENT SharedObject (#PCDATA)>
<!ELEMENT Provides (Service)>
<!ELEMENT Service (#PCDATA)>
<!ATTLIST Service runlevel CDATA #IMPLIED>
<!ELEMENT Conflicts (Package)+>
<!-- we have a problem here, this Package tag only contains a package name
......
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" ?>
<!-- RELAX NG schema file for INARY pspec.xml files -->
<!-- http://www.pardus.org.tr/projeler/inary/ -->
<!-- https://gitlab.com/sulinos/devel/inary -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<!-- Start Document -->
......@@ -132,7 +131,7 @@
<!-- Name -->
<define name="Name">
<element name="Name">
<data type="string" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" type="string">
<param name="pattern">[0-9a-zA-Z\-_+]*</param>
<param name="maxLength">255</param>
</data>
......@@ -171,7 +170,7 @@
<!-- Packager.Name -->
<define name="Packager.Name">
<element name="Name">
<data type="string" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" type="string">
<param name="maxLength">255</param>
</data>
</element>
......@@ -1305,7 +1304,7 @@
</element>
</define>
<!-- attlist.Summary -->
<define name="attlist.Summary" combine="interleave">
<define combine="interleave" name="attlist.Summary">
<optional>
<attribute name="xml:lang"/>
</optional>
......@@ -1319,7 +1318,7 @@
</element>
</define>
<!-- attlist.Description -->
<define name="attlist.Description" combine="interleave">
<define combine="interleave" name="attlist.Description">
<optional>
<attribute name="xml:lang"/>
</optional>
......@@ -1333,7 +1332,7 @@
</element>
</define>
<!-- attlist.Archive -->
<define name="attlist.Archive" combine="interleave">
<define combine="interleave" name="attlist.Archive">
<group>
<attribute name="sha1sum"/>
<optional>
......@@ -1459,7 +1458,7 @@
</element>
</define>
<!-- attlist.Patch -->
<define name="attlist.Patch" combine="interleave">
<define combine="interleave" name="attlist.Patch">
<group>
<optional>
<attribute name="compressionType"/>
......@@ -1480,25 +1479,49 @@
<define name="Provides">
<element name="Provides">
<oneOrMore>
<ref name="SCOM"/>
<ref name="Command"/>
<ref name="SharedObject"/>
<ref name="CMAKE"/>
<ref name="PkgConfig"/>
<ref name="Service"/>
</oneOrMore>
</element>
</define>
<!-- SCOM -->
<define name="SCOM">
<element name="SCOM">
<ref name="attlist.SCOM"/>
<!-- Command -->
<define name="Command">
<element name="Command">
<text/>
</element>
</define>
<!-- attlist.SCOM -->
<define name="attlist.SCOM">
<optional>
<attribute name="script"/>
</optional>
<!-- SharedObject -->
<define name="SharedObject">
<element name="SharedObject">
<text/>
</element>
</define>
<!-- CMAKE -->
<define name="CMAKE">
<element name="CMAKE">
<text/>
</element>
</define>
<!-- PkgConfig -->
<define name="PkgConfig">
<element name="PkgConfig">
<text/>
</element>
</define>
<!-- Service -->
<define name="Service">
<element name="Service">
<ref name="attlist.Service"/>
<text/>
</element>
</define>
<!-- attlist.Service -->
<define name="attlist.Service">
<optional>
<attribute name="name"/>
<attribute name="runlevel"/>
</optional>
</define>
......@@ -1514,7 +1537,7 @@
<define name="Conflicts.Package">
<element name="Package">
<ref name="attlist.VersionReleaseToFrom"/>
<text />
<text/>
</element>
</define>
......@@ -1529,7 +1552,7 @@
<define name="Replaces.Package">
<element name="Package">
<text />
<text/>
</element>
</define>
......@@ -1602,7 +1625,7 @@
</element>
</define>
<!-- attlist.Path -->
<define name="attlist.Path" combine="interleave">
<define combine="interleave" name="attlist.Path">
<group>
<attribute name="fileType">
<choice>
......@@ -1657,7 +1680,7 @@
</define>
<!-- attlist.Update -->
<define name="attlist.Update" combine="interleave">
<define combine="interleave" name="attlist.Update">
<attribute name="release"/>
<optional>
<attribute name="type">
......@@ -1672,7 +1695,7 @@
<!-- Date -->
<define name="Date">
<element name="Date">
<data type="date" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
<data datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" type="date"/>
</element>
</define>
......@@ -1702,7 +1725,7 @@
</define>
<!-- attlist.Type -->
<define name="attlist.Type" combine="interleave">
<define combine="interleave" name="attlist.Type">
<optional>
<attribute name="package"/>
</optional>
......@@ -1730,7 +1753,7 @@
</define>
<!-- attlist.Action -->
<define name="attlist.Action" combine="interleave">
<define combine="interleave" name="attlist.Action">
<optional>
<attribute name="package"/>
</optional>
......
......@@ -61,24 +61,6 @@ import inary.operations.upgrade
import inary.uri
import inary.util
def set_scom(enable):
"""
Set scom usage
False means no preremove and postinstall scripts will be run
@param enable: Flag indicating scom usage
"""
ctx.scom = enable
def set_scom_updated(updated):
"""
Set scom package update status
@param updated: True if SCOM package is updated, else False
"""
ctx.scom_updated = updated
def set_userinterface(ui):
"""
Set the user interface where the status information will be send
......
......@@ -391,6 +391,7 @@ class ArchiveTar(ArchiveBase):
if path.endswith("dbus") and "pid" in files:
startservices.append("dbus")
for service in ("NetworkManager", "connman", "wicd"):
#FIXME: It needs a quick fix for openrc
if os.path.isfile("/etc/scom/services/enabled/{}".format(service)):
startservices.append(service)
os.system("service {} stop".format(service))
......
......@@ -37,11 +37,13 @@ import inary.uri
import inary.ui
import inary.util as util
import inary.version
import inary.trigger
class Error(inary.errors.Error):
pass
class PostOpsError(inary.errors.Error):
pass
class NotfoundError(inary.errors.Error):
pass
......@@ -152,6 +154,7 @@ class Install(AtomicOperation):
self.installdb = inary.db.installdb.InstallDB()
self.operation = INSTALL
self.store_old_paths = None
self.trigger=inary.trigger.Trigger()
def install(self, ask_reinstall=True):
......@@ -167,8 +170,10 @@ class Install(AtomicOperation):
self.check_operation()
ctx.disable_keyboard_interrupts()
self.store_inary_files()
self.preinstall()
self.extract_install()
self.postinstall()
self.update_databases()
......@@ -188,15 +193,9 @@ class Install(AtomicOperation):
# Check free space
total_size, symbol = util.human_readable_size(util.free_space())
if util.free_space() < self.installedSize:
raise Error(_("Is there enought free space in your disk."))
raise Error(_("Is there enought free space in your disk?"))
ctx.ui.info(_("Free space in \'destinationdirectory\': {:.2f} {} ".format(total_size, symbol)), verbose=True)
# 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()
def check_replaces(self):
for replaced in self.pkginfo.replaces:
if self.installdb.has_package(replaced.package):
......@@ -304,33 +303,15 @@ class Install(AtomicOperation):
return not self.operation == INSTALL
def preinstall(self):
if self.metadata.package.providesScom:
if ctx.scom and not ctx.get_option("ignore_scom"):
import inary.scomiface
try:
if self.operation == UPGRADE or self.operation == DOWNGRADE:
fromVersion = self.old_pkginfo.version
fromRelease = self.old_pkginfo.release
else:
fromVersion = None
fromRelease = None
ctx.ui.action(_("Working on package preInstall operations."))
inary.scomiface.pre_install(
self.pkginfo.name,
self.metadata.package.providesScom,
self.package.scom_dir(),
os.path.join(self.package.pkg_dir(), ctx.const.metadata_xml),
os.path.join(self.package.pkg_dir(), ctx.const.files_xml),
fromVersion,
fromRelease,
self.metadata.package.version,
self.metadata.package.release
)
ctx.ui.notify(inary.ui.configured, package=self.pkginfo, files=self.files)
except inary.scomiface.Error:
pass
else:
pass
try:
if self.metadata.package.postOps == "PositivE":
self.trigger.preinstall(self.package.pkg_dir())
except PostOpsError:
util.clean_dir(self.package.pkg_dir())
ctx.ui.error(_('Configuration of \"{}\" package failed.').format(self.pkginfo.name))
def postinstall(self):
self.config_later = False
......@@ -343,33 +324,13 @@ class Install(AtomicOperation):
# else:
# ctx.ui.info(_("Chowning in postinstall {0} ({1}:{2})").format(_file.path, _file.uid, _file.gid), verbose=True)
# 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
try:
if self.operation == UPGRADE or self.operation == DOWNGRADE:
fromVersion = self.old_pkginfo.version
fromRelease = self.old_pkginfo.release
else:
fromVersion = None
fromRelease = None
ctx.ui.notify(inary.ui.configuring, package=self.pkginfo, files=self.files)
inary.scomiface.post_install(
self.pkginfo.name,
os.path.join(self.package.pkg_dir(), ctx.const.metadata_xml),
os.path.join(self.package.pkg_dir(), ctx.const.files_xml),
fromVersion,
fromRelease,
self.metadata.package.version,
self.metadata.package.release
)
ctx.ui.notify(inary.ui.configured, package=self.pkginfo, files=self.files)
except inary.scomiface.Error:
ctx.ui.warning(_('Configuration of \"{}\" package failed.').format(self.pkginfo.name))
self.config_later = True
else:
self.config_later = True
try:
if self.metadata.package.postOps == "PositivE":
self.trigger.postinstall(self.package.pkg_dir())
except:
self.config_later = True
def extract_install(self):
"""unzip package in place"""
......@@ -544,21 +505,14 @@ class Install(AtomicOperation):
clean_leftovers()
def store_inary_files(self):
"""put files.xml, metadata.xml, scom scripts
somewhere in the file system. We'll need these in future..."""
"""put files.xml, metadata.xml, postoperations.py, somewhere in the file system. We'll need these in future..."""
if self.reinstall():
util.clean_dir(self.old_path)
self.package.extract_file_synced(ctx.const.files_xml, self.package.pkg_dir())
self.package.extract_file_synced(ctx.const.metadata_xml, self.package.pkg_dir())
for pscom in self.metadata.package.providesScom:
fpath = os.path.join(ctx.const.scom_dir, pscom.script)
# comar prefix is added to the pkg_dir while extracting comar
# script file. so we'll use pkg_dir as destination.
ctx.ui.info(_('Storing files of \"{}\" package.').format(fpath), verbose=True)
self.package.extract_file_synced(fpath, self.package.pkg_dir())
if self.metadata.package.postOps:
self.package.extract_file_synced(ctx.const.postops, self.package.pkg_dir())
def update_databases(self):
"""update databases"""
......@@ -626,6 +580,7 @@ class Remove(AtomicOperation):
self.package_name = package_name
self.package = self.installdb.get_package(self.package_name)
self.store_old_paths = store_old_paths
self.trigger=inary.trigger.Trigger()
try:
self.files = self.installdb.get_files(self.package_name)
except inary.errors.Error as e:
......@@ -721,25 +676,13 @@ class Remove(AtomicOperation):
dpath = os.path.dirname(dpath)
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(
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),
)
if self.package.postOps == "PositivE":
self.trigger.preremove(self.package.pkg_dir())
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(
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),
provided_scripts=self.package.providesScom,
)
if self.package.postOps == "PositivE":
self.trigger.postremove(self.package.pkg_dir())
def update_databases(self):
self.remove_db()
......
......@@ -41,7 +41,6 @@ class Build(command.Command, metaclass=command.autocommand):
def __init__(self, args):
super(Build, self).__init__(args)
self.scom = True
name = ("build", "bi")
......
......@@ -85,7 +85,6 @@ class Command(object):
def __init__(self, args=None):
# now for the real parser
import inary
self.scom = False
self.parser = optparse.OptionParser(usage=getattr(self, "__doc__"),
version="%prog " + inary.__version__,
formatter=InaryHelpFormatter())
......@@ -175,7 +174,6 @@ class Command(object):
os.path.join(ctx.config.info_dir(), ctx.const.files_db), os.W_OK))):
raise inary.cli.Error(_("You have to be root for this operation."))
inary.api.set_scom(self.scom and not ctx.get_option('ignore_scom'))
inary.api.set_userinterface(ui)
inary.api.set_options(self.options)
......@@ -207,7 +205,6 @@ class PackageOp(Command):
def __init__(self, args):
super(PackageOp, self).__init__(args)
self.scom = True
def options(self, group):
group.add_option("--ignore-dependency", action="store_true",
......@@ -215,8 +212,6 @@ class PackageOp(Command):
help=_("Do not take dependency information into account."))
group.add_option("--ignore-safety", action="store_true",
default=False, help=_("Bypass safety switch."))
group.add_option("--ignore-scom", action="store_true",
default=False, help=_("Bypass scom configuration agent."))
group.add_option("-n", "--dry-run", action="store_true", default=False,
help=_("Do not perform any action, just show what would be done."))
......
......@@ -19,6 +19,7 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import os
import inary.util as util
import inary.cli.command as command
import inary.ui
......@@ -28,9 +29,6 @@ import inary.context as ctx
def configure_pending(packages=None):
# Import SCOM
import inary.scomiface
# start with pending packages
# configure them in reverse topological order of dependency
installdb = inary.db.installdb.InstallDB()
......@@ -40,33 +38,24 @@ def configure_pending(packages=None):
packages = set(packages).intersection(installdb.list_pending())
order = inary.data.pgraph.generate_pending_order(packages)
try:
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.scomiface.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)
except ImportError:
raise inary.errors.Error(_("scom package is not fully installed."))
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)
command=m.package.postopsPostInstall[0]
if os.system(command) != 0:
ctx.ui.warning(_('Configuration of \"{}\" package failed.').format(pkginfo.name))
else:
installdb.clear_pending(x)
ctx.ui.notify(inary.ui.configured, package=pkginfo, files=None)
class ConfigurePending(command.PackageOp, metaclass=command.autocommand):
__doc__ = _("""Configure pending packages
......
......@@ -39,7 +39,6 @@ You can also give the name of a component.
def __init__(self, args):
super(Emerge, self).__init__(args)
self.scom = True
name = ("emerge", "em")
......@@ -52,8 +51,6 @@ You can also give the name of a component.
default=False, help=_("Ignore file conflicts."))
group.add_option("--ignore-package-conflicts", action="store_true",
default=False, help=_("Ignore package conflicts."))
group.add_option("--ignore-scom", action="store_true",
default=False, help=_("Bypass scom configuration agent."))
self.parser.add_option_group(group)
def run(self):
......
......@@ -39,7 +39,6 @@ You can also give the name of a component.
def __init__(self, args):
super(EmergeUp, self).__init__(args)
self.scom = True
name = ("emergeup", "emup")
......@@ -52,8 +51,6 @@ You can also give the name of a component.
default=False, help=_("Ignore file conflicts."))
group.add_option("--ignore-package-conflicts", action="store_true",
default=False, help=_("Ignore package conflicts."))
group.add_option("--ignore-scom", action="store_true",
default=False, help=_("Bypass scom configuration agent."))
self.parser.add_option_group(group)
def run(self):
......
......@@ -100,9 +100,9 @@ class Constants(metaclass=Singleton):
self.__c.files_dir = "files"
self.__c.metadata_dir = "metadata"
self.__c.translations_file = "translations.xml"
self.__c.scom_dir = "scom"
self.__c.files_xml = "files.xml"
self.__c.metadata_xml = "metadata.xml"
self.__c.postops = "postoperations.py"
self.__c.install_tar = "install.tar"
self.__c.mirrors_conf = "/etc/inary/mirrors.conf"
self.__c.sandbox_conf = "/etc/inary/sandbox.conf"
......
......@@ -45,11 +45,6 @@ ui = inary.ui.UI()
stdout = None
stderr = None
scom = True
scom_updated = False
dbus_sockname = None
dbus_timeout = 60 * 60 # in seconds
# Bug #2879
# FIXME: Maybe we can create a simple rollback mechanism. There are other
# places which need this, too.
......
......@@ -58,6 +58,7 @@ class Package(specfile.Package, xmlfile.XmlFile, metaclass=autoxml.autoxml):
t_DeltaPackages = [[Delta], autoxml.optional]
t_PackageFormat = [autoxml.String, autoxml.optional]
t_Rfp = [autoxml.String, autoxml.optional]
t_PostOps = [autoxml.String, autoxml.optional]
t_Source = [Source, autoxml.optional]
......@@ -123,7 +124,11 @@ class MetaData(xmlfile.XmlFile, metaclass=autoxml.autoxml):
self.package.packageAnyDependencies = pkg.packageAnyDependencies
self.package.componentDependencies = pkg.componentDependencies
self.package.files = pkg.files
self.package.providesScom = pkg.providesScom
# Provides
self.package.providesCommand = pkg.providesCommand
self.package.providesCMAKE = pkg.providesCMAKE
self.package.providesPkgConfig = pkg.providesPkgConfig
self.package.providesService = pkg.providesService
# FIXME: no need to copy full history with comments
self.package.history = history
self.package.conflicts = pkg.conflicts
......
......@@ -141,15 +141,14 @@ class Path(metaclass=autoxml.autoxml):
return s
class ScomProvide(metaclass=autoxml.autoxml):
class ServiceProvide(metaclass=autoxml.autoxml):
s_om = [autoxml.String, autoxml.mandatory]
a_script = [autoxml.String, autoxml.mandatory]
a_name = [autoxml.String, autoxml.optional]
a_runlevel = [autoxml.String, autoxml.optional]
def __str__(self):
# FIXME: descriptive enough?
s = self.script
s += ' (' + self.om + '{}'.format(' for {}'.format(self.name) if self.name else '') + ')'
s = self.om
s += ' ( ' + self.runlevel + ' )'
return s
......@@ -245,7 +244,11 @@ class Package(metaclass=autoxml.autoxml):
t_Files = [[Path], autoxml.optional]
t_Conflicts = [[inary.analyzer.conflict.Conflict], autoxml.optional, "Conflicts/Package"]
t_Replaces = [[inary.data.replace.Replace], autoxml.optional, "Replaces/Package"]
t_ProvidesScom = [[ScomProvide], autoxml.optional, "Provides/SCOM"]
t_ProvidesCommand = [[autoxml.String], autoxml.optional, "Provides/Command"]
t_ProvidesCMAKE = [[autoxml.String], autoxml.optional, "Provides/CMAKE"]
t_ProvidesPkgConfig = [[autoxml.String], autoxml.optional, "Provides/PkgConfig"]
t_ProvidesSharedObject = [[autoxml.String], autoxml.optional, "Provides/SharedObject"]
t_ProvidesService = [[ServiceProvide], autoxml.optional, "Provides/Service"]
t_AdditionalFiles = [[AdditionalFile], autoxml.optional]
t_History = [[Update], autoxml.optional]
......@@ -377,9 +380,28 @@ class Package(metaclass=autoxml.autoxml):
s += _('Description: {}\n').format(str(self.description))
s += _('Licenses: {}\n').format(", ".join(self.license))
s += _('Component: {}\n').format(str(self.partOf))
s += _('Provides: ')
for x in self.providesScom:
s += x.om + ' '
s += _('Provides: \n')
if(self.providesCommand):
s += _(' - Commands: \n')
for x in self.providesCommand:
s+= ' * {}\n'.format(x)
if(self.providesCMAKE):
s += _(' - CMAKE Needs: \n')
for x in self.providesCMAKE:
s+= ' * {}\n'.format(x)
if(self.providesPkgConfig):
s += _(' - PkgConfig Needs: \n')
for x in self.providesPkgConfig:
s+= ' * {}\n'.format(x)
if(self.providesService):
s += _(' - Services: \n')
for x in self.providesService:
s+= ' * {}\n'.format(x)
s += '\n'
s += _('Dependencies: ')
for x in self.componentDependencies:
......
......@@ -125,7 +125,6 @@ def rebuild_db():
# save parameters and shutdown inary
options = ctx.config.options
ui = ctx.ui
scom = ctx.scom
from inary import _cleanup
_cleanup()
......@@ -137,4 +136,3 @@ def rebuild_db():
# reinitialize everything
ctx.ui = ui
ctx.config.set_options(options)
ctx.scom = scom
......@@ -459,7 +459,7 @@ class Builder: