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

Kodlar detaylı analiz edildi. Sıkıntılar giderildi detaya yazıldı.

* fetcher:
	pycurl bir handikapa sahip. process bar tamamlandıktan sonra aşağı satıra indirmiyor. (C syntax stdin mantığı). 
* repodb:
	repodb içerisindeki xml parserlere uyumsuzluk hatası giderildi. her bir parser için farklı bir if else yapısına giriyordu. 
* pgrapg:
	add_vertex eski ve kadim bir assert geleneği ile yazılmış. Python3 bu geleneği es geçtiği için program çakılma yaşıyordu.
* Eksik moduller:
	eksik modullerin koda eklenmesi yapıldı. runtime çakılmalar giderildi.
* Gereksiz değişkenler ve moduller:
	bazı ara değişkenler ve eklenip zamanla kaldırılmayan moduller silindi.
üst 1b5bcbd5
......@@ -2,9 +2,9 @@ Metadata-Version: 1.0
Name: inary
Version: 1.0
Summary: Inary (Special Package Manager)
Home-page: http://www.aquilanipalensis.github.com/inary/
Author: Suleyman POYRAZ (AquilaNipalensis)
Home-page: https://gitlab.com/sulinos/sulinproject/inary
Author: Sulin Project Developers
Author-email: zaryob.dev@gmail.com
License: GNU GPL2
License: GNU GPL3
Description: Inary is the package management system of Sulin Linux and use with Mac OS, Solaris and FreeBSD
Platform: UNKNOWN
......@@ -100,7 +100,7 @@
Provides
)*>
<!ELEMENT Provides (COMAR)+>
<!ELEMENT Provides (SCOM)+>
<!ELEMENT SCOM (#PCDATA)>
<!ATTLIST SCOM script CDATA #IMPLIED>
<!ATTLIST SCOM name CDATA #IMPLIED>
......
......@@ -160,6 +160,7 @@ def makeJOBS():
procs = 4
try:
procs = multiprocessing.cpu_count()
env.jobs = procs
except Exception as e:
ctx.ui.warning("Unable to retrieve CPU count: %s" % e)
return env.jobs
......
import inary.actionsapi
import inary.util as util
import inary.context as ctx
from inary.actionsapi import get
from inary.actionsapi.shelltools import can_access_file
from inary.actionsapi.shelltools import system
import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
class MesonError(inary.actionsapi.Error):
def __init__(self, value=''):
inary.actionsapi.Error.__init__(self, value)
......@@ -48,5 +53,5 @@ def ninja_install(parameters=""):
def ninja_check():
if system('ninja test {} -C inaryPackageBuild'.format(get.makeJobs())):
if system('ninja test {} -C inaryPackageBuild'.format(get.makeJOBS())):
raise MesonError(_("[Ninja]: Test failed"))
......@@ -87,7 +87,7 @@ def install(parameters=''):
# Handle config files
if handleConfigFiles():
raise Installing(_('Handle config files failed'))
raise InstallError(_('Handle config files failed'))
def createSymlinksFormat2Engines():
......
......@@ -59,8 +59,10 @@ class Dependency(relation.Relation, metaclass=autoxml.autoxml):
def satisfied_by_installed(self):
return relation.installed_package_satisfies(self)
def satisfied_by_repo(self):
packagedb = PackageDB()
def satisfied_by_repo(self, packagedb=None):
if not packagedb:
packagedb = PackageDB()
if not packagedb.has_package(self.package):
return False
else:
......@@ -68,5 +70,5 @@ class Dependency(relation.Relation, metaclass=autoxml.autoxml):
return self.satisfies_relation(pkg.version, pkg.release)
# Added for AnyDependency, single Dependency always returns False
def satisfied_by_any_installed_other_than():
def satisfied_by_any_installed_other_than(self):
pass
......@@ -10,7 +10,6 @@
# Please read the COPYING file.
#
import sys
import glob
import os
import sys
......
......@@ -121,7 +121,6 @@ class TarFile(tarfile.TarFile):
name=None,
mode="r",
fileobj=None,
compressformat = None,
compresslevel = None,
**kwargs):
"""Open lzma/xz compressed tar archive name for reading or writing.
......@@ -158,7 +157,7 @@ class TarFile(tarfile.TarFile):
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
except IOError:
raise ReadError(_(" {} is not a lzma file").format(name))
raise tarfile.ReadError(_(" {} is not a lzma file").format(name))
t._extfileobj = False
return t
......@@ -453,7 +452,6 @@ class ArchiveTar(ArchiveBase):
# Try to extract again.
self.tar.extract(tarinfo)
except IOError as e:
# Handle the case where new path is file, but old path is directory
# due to not possible touch file c in /a/b if directory /a/b/c exists.
if not e.errno == errno.EISDIR:
......@@ -928,7 +926,7 @@ class SourceArchive:
# check hash
if util.check_file_hash(self.archiveFile, self.archive.sha1sum):
if interactive:
ctx.ui.info(_('{} [cached]').format(self.archive.name))
ctx.ui.info(_('{} [cached]').format(self.archive.name),noln=True)
return True
return False
......
......@@ -252,7 +252,6 @@ class Install(AtomicOperation):
pkg = self.pkginfo
if self.installdb.has_package(pkg.name): # is this a reinstallation?
ipkg = self.installdb.get_package(pkg.name)
(iversion_s, irelease_s, ibuild) = self.installdb.get_version(pkg.name)
# determine if same version
......@@ -551,10 +550,10 @@ class Install(AtomicOperation):
actions = self.pkginfo.get_update_actions("1")
for package_name in actions.get("serviceRestart", []):
inary.db.installdb.InstallDB().mark_needs_restart(package)
inary.db.installdb.InstallDB().mark_needs_restart(package_name)
for package_name in actions.get("systemRestart", []):
inary.db.installdb.InstallDB().mark_needs_reboot(package)
inary.db.installdb.InstallDB().mark_needs_reboot(package_name)
# filesdb
ctx.ui.info(_('-> Adding \'{}\' to db...').format(self.metadata.package.name), color='purple')
......
......@@ -205,7 +205,7 @@ class PackageOp(Command):
def __init__(self, args):
super(PackageOp, self).__init__(args)
self.scom = True
self.scom = False
def options(self, group):
group.add_option("--ignore-dependency", action="store_true",
......
......@@ -18,6 +18,7 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import inary.db
import inary.cli.command as command
import inary.cli.build as build
import inary.context as ctx
......
......@@ -50,14 +50,13 @@ repositories.
self.init(database=True, write=False)
l = self.componentdb.list_components(ctx.get_option('repository'))
if l:
maxlen = max([len(_p) for _p in l])
l.sort()
for p in l:
component = self.componentdb.get_component(p)
if self.options.long:
ctx.ui.info(str(component))
else:
lenp = len(p)
# if p in installed_list:
# p = util.colorize(p, 'cyan')
# p = p + ' ' * max(0, 15 - lenp)
component.name += ' ' * max(0, maxlen - len(p))
ctx.ui.info('{0} - {1} '.format(component.name, str(component.summary)))
......@@ -13,6 +13,7 @@
#
import optparse
import sys
import gettext
__trans = gettext.translation('inary', fallback=True)
......
......@@ -43,7 +43,6 @@ class Repo(metaclass=autoxml.autoxml):
def __str__(self):
# "update", "remove", "add"
operation = ""
if self.operation == "update":
return _("{0} repository is updated.").format(self.name)
elif self.operation == "add":
......@@ -62,7 +61,6 @@ class Package(metaclass=autoxml.autoxml):
def __str__(self):
# "upgrade", "remove", "install", "reinstall", "downgrade"
operation = ""
if self.operation == "upgrade":
if self.type == "delta":
return _("{0} is upgraded from {1} to {2} with delta.").format(self.name, self.before, self.after)
......
......@@ -68,7 +68,7 @@ class Index(xmlfile.XmlFile, metaclass=autoxml.autoxml):
urlfile.write(uri) # uri
urlfile.close()
doc = self.read_uri(uri, tmpdir, force)
doc = self.read_uri(uri, tmpdir, force) # Fixme: Fuck
if not repo:
repo = self.distribution.name()
......@@ -215,7 +215,7 @@ def add_package(params):
if md.errors():
ctx.ui.info("")
ctx.ui.error(_('Package {}: metadata corrupt, skipping...').format(md.package.name))
ctx.ui.error(str(Error(*errs)))
ctx.ui.error(str(*errs))
else:
# No need to carry these with index (#3965)
md.package.files = None
......
......@@ -55,12 +55,12 @@ class Digraph(object):
def add_vertex(self, u, data=None):
"""add vertex u, optionally with data"""
assert not u in self.__v
self.__v.add(u)
self.__adj[u] = set()
if data:
self.__vdata[u] = data
self.__edata[u] = {}
if not u in self.__v:
self.__v.add(u)
self.__adj[u] = set()
if data:
self.__vdata[u] = data
self.__edata[u] = {}
def add_edge(self, u, v, edata=None, udata=None, vdata=None):
"""add edge u -> v"""
......
......@@ -226,12 +226,12 @@ class InstallDB(lazydb.LazyDB):
found = []
for name in self.list_installed():
xml = open(os.path.join(self.package_path(name), ctx.const.metadata_xml)).read()
if terms == [term for term in terms if (fields['name'] and \
if terms == [term for term in terms if (fields['name'] and
re.compile(term, re.I).search(name)) or \
(fields['summary'] and \
(fields['summary'] and
re.compile(resum.format(lang, term), 0 if cs else re.I).search(
xml)) or \
(fields['desc'] and \
(fields['desc'] and
re.compile(redesc.format(lang, term), 0 if cs else re.I).search(
xml))]:
found.append(name)
......
......@@ -23,6 +23,7 @@ class ItemByRepo:
def __init__(self, dbobj, compressed=False):
self.dbobj = dbobj
self.compressed = compressed
self.repolist = inary.db.repodb.RepoDB().list_repos()
def has_repo(self, repo):
return repo in self.dbobj
......@@ -35,7 +36,7 @@ class ItemByRepo:
return False
def which_repo(self, item):
for r in inary.db.repodb.RepoDB().list_repos():
for r in self.repolist:
if r in self.dbobj and item in self.dbobj[r]:
return r
......@@ -89,9 +90,9 @@ class ItemByRepo:
for item in list(self.dbobj[r].keys()):
yield str(item), str(self.dbobj[r][item])
@staticmethod
def item_repos(repo=None):
repos = inary.db.repodb.RepoDB().list_repos()
def item_repos(self, repo=None):
if repo:
repos = [repo]
return repos
return repos
else:
return self.repolist
......@@ -137,12 +137,12 @@ class PackageDB(lazydb.LazyDB):
fields = {'name': True, 'summary': True, 'desc': True}
found = []
for name, xml in self.pdb.get_items_iter(repo):
if terms == [term for term in terms if (fields['name'] and \
if terms == [term for term in terms if (fields['name'] and
re.compile(term, re.I).search(name)) or \
(fields['summary'] and \
(fields['summary'] and
re.compile(resum.format(lang, term), 0 if cs else re.I).search(
xml)) or \
(fields['desc'] and \
(fields['desc'] and
re.compile(redesc.format(lang, term), 0 if cs else re.I).search(
xml))]:
found.append(name)
......
......@@ -34,16 +34,6 @@ import inary.util as util
xmlext içine tag için remove eklenene kadar böyle
"""
try:
import iksemel
parser = "iksemel"
except:
import xml.dom.minidom as minidom
parser = "minidom"
class RepoError(inary.errors.Error):
pass
......@@ -82,29 +72,15 @@ class RepoOrder:
def set_status(self, repo_name, status):
repo_doc = self._get_doc()
for r in xmlext.getTagByName(repo_doc, "Repo"):
if xmlext.getNodeText(r, "Name") == repo_name:
status_node = xmlext.getNode(r, "Status")
if status_node:
xmlext.removeChild(status_node, r)
xmlext.addText(r, "Status", status)
else:
xmlext.addText(r, "Status", status)
if parser == "iksemel":
for r in repo_doc.tags("Repo"):
if r.getTagData("Name") == repo_name:
status_node = r.getTag("Status")
if status_node:
status_node.firstChild().hide()
status_node.insertData(status)
else:
status_node = r.insertTag("Status")
status_node.insertData(status)
else:
for r in repo_doc.childNodes:
if r.nodeType == r.ELEMENT_NODE and r.tagName == "Repo":
if r.getElementsByTagName("Name")[0].firstChild.data == repo_name:
status_node = r.getElementsByTagName("Status")[0]
if status_node:
status_node.childNodes[0].nodeValue = status
else:
status_node = repo_node.createElement("Status")
status_node.appendChild(repo_doc.createTextNode("active"))
r.appendChild(status_node)
self._update(repo_doc)
......@@ -120,17 +96,12 @@ class RepoOrder:
return "inactive"
def remove(self, repo_name):
repo_doc = self._get_doc()
if parser == "iksemel":
for r in repo_doc.tags("Repo"):
if r.getTagData("Name") == repo_name:
r.hide()
else:
for r in repo_doc.getElementsByTagName("Repo"):
if r.getElementsByTagName("Name")[0].firstChild.data == repo_name:
repo_doc.removeChild(r)
for r in xmlext.getChildElts(repo_doc):
if xmlext.getNodeText(r, "Name") == repo_name:
xmlext.removeChild(r, repo_doc)
self._update(repo_doc)
......@@ -222,6 +193,7 @@ class RepoDB(lazydb.LazyDB):
return uri.rstrip()
def add_repo(self, name, repo_info, at=None):
#Fixme: Fucking at
repo_path = util.join_path(ctx.config.index_dir(), name)
###########
try:
......
......@@ -12,7 +12,6 @@
# Please read the COPYING file.
#
import re
import gzip
import re
......@@ -113,12 +112,12 @@ class SourceDB(lazydb.LazyDB):
lang = autoxml.LocalText.get_lang()
found = []
for name, xml in self.sdb.get_items_iter(repo):
if terms == [term for term in terms if (fields['name'] and \
if terms == [term for term in terms if (fields['name'] and
re.compile(term, re.I).search(name)) or \
(fields['summary'] and \
(fields['summary'] and
re.compile(resum.format(lang, term), 0 if cs else re.I).search(
xml)) or \
(fields['desc'] and \
(fields['desc'] and
re.compile(redesc.format(lang, term), 0 if cs else re.I).search(
xml))]:
found.append(name)
......
......@@ -198,6 +198,8 @@ class Fetcher:
try:
c.perform()
ctx.ui.info("\n", noln=True) #This is not a bug. This is a new feature. ŞAka bir yana bu hata
#pycurl yüzünden kaynaklanıyor
file_id.close()
ctx.ui.debug(_("Downloaded from:" + str(c.getinfo(c.EFFECTIVE_URL))))
c.close()
......@@ -223,7 +225,7 @@ class Fetcher:
def _get_ftp_headers(self):
headers = []
if self.url.auth_info() and self.url.scheme() == "ftp":
enc = encodesbytes('{0}:{0}'.format(self.url.auth_info()).encode('utf-8'))
enc = encodebytes('{0}:{0}'.format(self.url.auth_info()).encode('utf-8'))
headers.append(('Authorization', 'Basic {}'.format(enc)))
return headers
......@@ -283,7 +285,7 @@ def fetch(packages=None, path=os.path.curdir):
ctx.ui.warning(_("{} package already fetched").format(uri.path()))
continue
if uri.is_absolute_path():
url = str(pkg_uri)
url = str(uri.path())
else:
url = os.path.join(os.path.dirname(repodb.get_repo_url(repo)), str(uri.path()))
......
......@@ -113,7 +113,7 @@ def __getpackageurl(package):
def fetch_remote_file(package, errors):
try:
uri = inary.file.File.make_uri(__getpackageurlbinman(package))
uri = inary.file.File.make_uri(__getpackageurl_binman(package))
except PackageNotFound:
errors.append(package)
ctx.ui.info(_("{} could not be found").format(package), color="red")
......
......@@ -29,7 +29,6 @@ import inary.data.pgraph as pgraph
import inary.ui as ui
import inary.db
def install_pkg_names(A, reinstall=False, extra=False):
"""This is the real thing. It installs packages from
the repository, trying to perform a minimum number of
......@@ -88,7 +87,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
ctx.ui.notify(ui.packagestogo, order=order)
ignore_dep = ctx.config.get_option('ignore_dependency')
ignore_dep = ctx.config.get_option('ignore_dependency') # Fixme: Fuck
conflicts = []
if not ctx.get_option('ignore_package_conflicts'):
......@@ -296,7 +295,7 @@ def plan_install_pkg_names(A):
ctx.ui.debug(' -> checking {}'.format(str(dep)))
# we don't deal with already *satisfied* dependencies
if not dep.satisfied_by_installed():
if not dep.satisfied_by_repo():
if not dep.satisfied_by_repo(packagedb=packagedb):
raise Exception(_('{0} dependency of package {1} is not satisfied').format(dep, pkg.name))
if not dep.package in G_f.vertices():
Bp.add(str(dep.package))
......
......@@ -32,8 +32,8 @@ import inary.ui as ui
def remove(A, ignore_dep=False, ignore_safety=False):
"""
Removes the given packages from the system
@param packages: list of package names -> list_of_strings
@param ignore_dependency: removes packages without looking into theirs reverse deps if True
@param A: list of package names -> list_of_strings
@param ignore_dep: removes packages without looking into theirs reverse deps if True
@param ignore_safety: system.base packages can also be removed if True
"""
inary.db.historydb.HistoryDB().create_history("remove")
......@@ -105,6 +105,7 @@ def plan_remove(A):
# install / reinstall
installdb = inary.db.installdb.InstallDB()
packagedb = inary.db.packagedb.PackageDB()
G_f = pgraph.PGraph(installdb) # construct G_f
......
......@@ -17,13 +17,17 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import inary.errors
import inary.context as ctx
import inary.db
import inary.data
import inary.errors
import inary.file
import inary.ui
import inary.uri
import inary.util as util
@util.locked
def add_repo(name, indexuri, at=None):
import re
......@@ -103,7 +107,7 @@ def __update_repo(repo, force=False):
repouri = repodb.get_repo(repo).indexuri.get_uri()
try:
index.read_uri_of_repo(repouri, repo)
except inary.file.AlreadyHaveException as e:
except inary.file.AlreadyHaveException:
ctx.ui.info(_('{} repository information is up-to-date.').format(repo))
if force:
ctx.ui.info(_('Updating database at any rate as requested'))
......
......@@ -72,6 +72,7 @@ def search_file(term):
packages -> list_of_tuples
@param term: used to search file -> list_of_strings
>>> import inary.operations
>>> files = inary.operation.search.search_file("kvm-")
>>> print files
......
......@@ -15,12 +15,15 @@
import inary.context as ctx
import inary.errors
class Error(inary.errors.Error):
pass
class Exception(inary.errors.Exception):
pass
def error(msg):
if ctx.config.get_option('ignore_action_errors'):
ctx.ui.error(msg)
......
......@@ -13,7 +13,6 @@
#
class Actions:
template = """
from inary.actionsapi import inarytools
......
......@@ -13,6 +13,7 @@
class _constant:
"""Constant members implementation"""
class ConstError(TypeError):
pass
......@@ -28,8 +29,8 @@ class _constant:
# we don't have an attribute by this name
raise NameError(name)
class Constants:
class Constants:
__c = _constant()
def __getattr__(self, attr):
......@@ -41,6 +42,7 @@ class Constants:
def __delattr__(self, attr):
delattr(self.__c, attr)
consts = Constants()
consts.scenarios_path = "scenarios/"
......
#!/usr/bin/python
#-*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
......@@ -14,29 +14,37 @@
#
import os
import inary.util as util
from inary.scenarioapi.constants import *
def inary_upgraded(*args):
packages = util.strlist(args).rstrip()
os.system("inary -D{0} upgrade {1}".format(consts.inary_db, packages))
def inary_info(package):
os.system("inary -D{0} info {1}".format(consts.inary_db, package))
def inary_removed(*args):
packages = util.strlist(args).rstrip()
os.system("inary -D{0} remove {1}".format(consts.inary_db, packages))
def inary_added_repo(name, url):
os.system("inary -D{0} add-repo -y {1} {2}".format(consts.inary_db, name, url))
def inary_updated_repo():
os.system("inary -D{0} update-repo".fotmat(consts.inary_db))
def inary_installed(*args):
packages = util.strlist(args).rstrip()
os.system("inary -D{0} install {1}".format(consts.inary_db, packages))
def inary_reinstalled(package):
os.system("inary -D{0} install --reinstall {1}".format(consts.inary_db, package))
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
......@@ -13,20 +13,21 @@
# Please read the COPYING file.
#
import os
import gettext
import glob
import os
from inary.scenarioapi.pspec import Pspec
from inary.scenarioapi.actions import Actions
from inary.scenarioapi.constants import *
from inary.scenarioapi.pspec import Pspec
from inary.scenarioapi.withops import *
import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
class Package:
def __init__(self, name, deps=None, cons=None, date ="2006-18-18", ver ="1.0", partOf="None"):
def __init__(self, name, deps=None, cons=None, date="2006-18-18", ver="1.0", partOf="None"):
if deps is None:
deps = []
if cons is None:
......@@ -102,6 +103,7 @@ class Package:
self.actions.write()
self.create_inary()
if __name__ == "__main__":
p = Package("w0rmux", [], [], "0.7")
p.version_bump()
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
......@@ -13,11 +13,13 @@
# Please read the COPYING file.
#
from inary.specfile import SpecFile, Package, Update, Path, Action, Archive, AnyDependency
from inary.dependency import Dependency
from inary.conflict import Conflict
from inary.dependency import Dependency
from inary.specfile import SpecFile, Package, Update, Path, Action, Archive
from inary.sxml.autoxml import LocalText
class Pspec:
def __init__(self, pkgname, filepath):
self.pspec = SpecFile()
......@@ -158,7 +160,7 @@ class Pspec:
self.pspec.packages.append(self.package)
def set_history(self, date, version, comment = "No Comment", release = "1"):
def set_history(self, date, version, comment="No Comment", release="1"):
self.update.date = date
self.update.version = version
self.update.comment = comment
......