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

Some important fixes get from branch b1ce7

I tried to patch my package manager with eopkg pkgconfig patch but it causes a platform complexity, so I returned branch to 6b83af and i take some fixes from old developing fork.
üst af1472aa
......@@ -40,3 +40,11 @@ Diğer özellikleri:
- Basit düzey ve üst düzey tüm işlemleri aynı kararlılıkla yerine getirir
- Forend uygulamaları tasarlanmasına elverişli bir yapıdadır.
- Terminal arayüzü oldukça anlaşılır ve kullanıcı dostudur.
Kurulum bağımlılıkları:
python3-requests
iksemel (https://gitlab.com/Zaryob/iksemel)
intltool
intltool-debian
......@@ -67,6 +67,7 @@
<!ATTLIST Dependency releaseFrom CDATA #IMPLIED>
<!ATTLIST Dependency releaseTo CDATA #IMPLIED>
<!ATTLIST Dependency release CDATA #IMPLIED>
<!ATTLIST Dependency type CDATA #IMPLIED>
<!ELEMENT Patches (Patch*)>
......@@ -100,9 +101,9 @@
)*>
<!ELEMENT Provides (COMAR)+>
<!ELEMENT COMAR (#PCDATA)>
<!ATTLIST COMAR script CDATA #IMPLIED>
<!ATTLIST COMAR name CDATA #IMPLIED>
<!ELEMENT SCOM (#PCDATA)>
<!ATTLIST SCOM script CDATA #IMPLIED>
<!ATTLIST SCOM name CDATA #IMPLIED>
<!ELEMENT Conflicts (Package)+>
<!-- we have a problem here, this Package tag only contains a package name
......
......@@ -1463,20 +1463,20 @@
<define name="Provides">
<element name="Provides">
<oneOrMore>
<ref name="COMAR"/>
<ref name="SCOM"/>
</oneOrMore>
</element>
</define>
<!-- COMAR -->
<define name="COMAR">
<element name="COMAR">
<ref name="attlist.COMAR"/>
<!-- SCOM -->
<define name="SCOM">
<element name="SCOM">
<ref name="attlist.SCOM"/>
<text/>
</element>
</define>
<!-- attlist.COMAR -->
<define name="attlist.COMAR">
<!-- attlist.SCOM -->
<define name="attlist.SCOM">
<optional>
<attribute name="script"/>
</optional>
......
......@@ -23,7 +23,7 @@ import importlib
__version__ = "1.0"
__all__ = ['api', 'configfile', 'db', 'util']
__all__ = ['api', 'configfile', 'db', 'util', '_cleanup']
import inary.api
import inary.config
......
......@@ -27,11 +27,15 @@ import inary.actionsapi.get as get
from inary.actionsapi.shelltools import system
from inary.actionsapi.shelltools import can_access_file
from inary.actionsapi.shelltools import unlink
from inary.actionsapi.shelltools import export
from inary.actionsapi.libtools import gnuconfig_update
from inary.actionsapi.shelltools import isDirectory
from inary.actionsapi.shelltools import ls
from inary.actionsapi.inarytools import dosed
from inary.actionsapi.inarytools import removeDir
from inary.actionsapi.shelltools import isDirectory
from inary.actionsapi.shelltools import ls
from inary.actionsapi.inarytools import removeDir
class ConfigureError(inary.actionsapi.Error):
def __init__(self, value=''):
......@@ -81,6 +85,9 @@ def configure(parameters = ''):
"--libdir=/usr/lib32 " if get.buildTYPE() == "emul32" else "",
parameters)
if get.buildTYPE() == "emul32":
args += " --libdir=/usr/lib32"
if system(args):
raise ConfigureError(_('Configure failed.'))
else:
......
......@@ -14,6 +14,7 @@
# Standart Python Modules
import os
import sys
import multiprocessing
import gettext
__trans = gettext.translation('inary', fallback=True)
......@@ -122,6 +123,13 @@ def LDFLAGS():
return env.ldflags
def makeJOBS():
# Note: "auto" only works when /sys is mounted.
if env.jobs == "auto":
procs = 4
try:
procs = multiprocessing.cpu_count()
except Exception as e:
ctx.ui.warning("Unable to retrieve CPU count: %s" % e)
return env.jobs
def buildTYPE():
......
......@@ -36,6 +36,8 @@ def exportFlags():
os.environ['USER_LDFLAGS'] = values.build.ldflags
os.environ['JOBS'] = values.build.jobs
os.environ['LD_AS_NEEDED'] = "1"
# http://liste.pardus.org.tr/gelistirici/2009-January/016442.html
os.environ['CC'] = "{}-gcc".format(values.build.host)
os.environ['CXX'] = "{}-g++".format(values.build.host)
......@@ -83,7 +85,7 @@ class Dirs:
localstate = 'var'
libexec = 'usr/libexec'
defaultprefix = 'usr'
emul32prefix = 'emul32'
emul32prefix = 'emul32'
# These should be owned by object not the class. Or else Python
# will bug us with NoneType errors because of uninitialized
......
......@@ -20,9 +20,13 @@ _ = __trans.gettext
import inary.data.relation as relation
from inary.db.packagedb import PackageDB
import inary.sxml.autoxml as autoxml
import os
class Dependency(relation.Relation):
class Dependency(relation.Relation, metaclass = autoxml.autoxml):
a_type = [autoxml.String, autoxml.optional]
def __str__(self):
s = self.package
if self.versionFrom:
......@@ -37,12 +41,15 @@ class Dependency(relation.Relation):
s += _(" release <= ") + self.releaseTo
if self.release:
s += _(" release ") + self.release
if self.type:
s += " (" + self.type + ")"
return s
def name(self):
return self.package
def satisfied_by_dict_repo(self, dict_repo):
if self.package not in dict_repo:
return False
else:
......
......@@ -121,18 +121,13 @@ 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.
Appending is not allowed.
"""
if not compresslevel:
compresslevel = ctx.config.values.build.compressionlevel
if len(mode) > 1 or mode not in "rw":
raise ValueError("mode must be 'r' or 'w'.")
try:
import lzma
except ImportError:
......@@ -141,11 +136,24 @@ class TarFile(tarfile.TarFile):
except ImportError:
raise tarfile.CompressionError("Lzma module is not available")
if fileobj is not None:
fileobj = _LZMAProxy(fileobj, mode)
else:
if not compresslevel:
compresslevel = ctx.config.values.build.compressionlevel
fileobj = lzma.LZMAFile(name, mode, preset=compresslevel)
if len(mode) > 1 or mode not in "rw":
raise ValueError("mode must be 'r' or 'w'.")
if 'w' in mode:
if fileobj is not None:
fileobj = _LZMAProxy(fileobj, mode)
else:
fileobj = lzma.LZMAFile(name, mode, preset=compresslevel)
else:
if fileobj is not None:
fileobj = _LZMAProxy(fileobj, mode)
else:
fileobj = lzma.LZMAFile(name, mode)
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
......@@ -290,6 +298,20 @@ class ArchiveTar(ArchiveBase):
super(ArchiveTar, self).unpack(target_dir, clean_dir)
self.unpack_dir(target_dir)
def maybe_nuke_pip(self, info):
if not info.name.endswith(".egg-info"):
return
if not "site-packages" in info.name:
return
if not "/python" in info.name:
return
if not info.isreg():
return
if not os.path.isdir(info.name):
return
print("Overwriting stale pip install: /{}".format(info.name))
shutil.rmtree(info.name)
def unpack_dir(self, target_dir, callback=None):
rmode = ""
self.tar = None
......@@ -431,7 +453,7 @@ class ArchiveTar(ArchiveBase):
# Try to extract again.
self.tar.extract(tarinfo)
except OSError as e:
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:
......@@ -500,7 +522,8 @@ class ArchiveTar(ArchiveBase):
compresslevel = int(ctx.config.values.build.compressionlevel)
self.tar = TarFile.lzmaopen(self.file_path, "w",
fileobj=self.fileobj,
compresslevel=compresslevel
compresslevel=compresslevel,
compressformat=format
)
else:
raise UnknownArchiveType
......
......@@ -79,7 +79,7 @@ You can also give the name of a component.
ctx.ui.info(_('Outputting binary packages in the package cache.'))
ctx.config.options.output_dir = ctx.config.cached_packages_dir()
repos = inary.db.repodb.RepoDB().list_repos(only_active)
repos = inary.db.repodb.RepoDB().list_repos(only_active=True)
repository.update_repos(repos, ctx.get_option('force'))
emerge.emerge(emerge_up_list)
......@@ -63,7 +63,7 @@ all repositories.
self.print_packages(arg)
else:
# print for all repos
for repo in inary.db.repodb.RepoDB().list_repos(only_active):
for repo in inary.db.repodb.RepoDB().list_repos(only_active=True):
ctx.ui.info(_("\n Repository : {}\n").format(str(repo)), color="blue")
self.print_packages(repo)
......
......@@ -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.context as ctx
......@@ -55,6 +56,6 @@ If no repository is given, all repositories are updated.
if self.args:
repos = self.args
else:
repos = inary.db.repodb.RepoDB().list_repos(only_active)
repos = inary.db.repodb.RepoDB().list_repos(only_active=True)
repository.update_repos(repos, ctx.get_option('force'))
......@@ -21,7 +21,7 @@ _ = __trans.gettext
import inary.cli.command as command
import inary.context as ctx
import inary.db
from inary.operations import operations, remove, upgrade
from inary.operations import remove, upgrade
class Upgrade(command.PackageOp, metaclass=command.autocommand):
__doc__ = _("""Upgrade INARY packages
......
......@@ -71,6 +71,7 @@ class Constants(metaclass=Singleton):
# suffix for auto generated debug packages
self.__c.debug_name_suffix = "-dbginfo"
self.__c.debug_file_suffix = ".debug"
self.__c.debug_file_buildid = ".build-id"
# suffix for auto generated ar packages
self.__c.static_name_suffix = "-static" # an admissible use of constant
......
......@@ -17,6 +17,7 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
from . import *
def invalidate_caches():
# Invalidates inary caches in use and forces to re-fill caches from disk when needed
......
......@@ -33,7 +33,8 @@ class Singleton(object):
return self._the_instances[type(self).__name__]
def _delete(self):
#FIXME: After invalidate, previously initialized db object becomes stale
#FIXME: After invalidate, previously initialized db object becomes
ctx.ui.debug("LazyDB: {0} invalidated.".format(self.__class__.__name__))
del self._the_instances[type(self).__name__]
class LazyDB(Singleton):
......@@ -70,6 +71,8 @@ class LazyDB(Singleton):
pickle.dump(self._instance().__dict__,
open(self.__cache_file(), 'wb'), 1)
ctx.ui.debug("LazyDB: {0} cached.".format(self.__class__.__name__))
def cache_valid(self):
if not self.cachedir:
return True
......@@ -96,6 +99,8 @@ class LazyDB(Singleton):
def cache_flush(self):
if os.path.exists(self.__cache_file()):
os.unlink(self.__cache_file())
ctx.ui.debug("LazyDB: {0} cached.".format(self.__class__.__name__))
def invalidate(self):
self._delete()
......
......@@ -257,7 +257,17 @@ class PackageDB(lazydb.LazyDB):
since_date = datetime.datetime(*time.strptime(historydb.get_last_repo_update(), "%Y-%m-%d")[0:6])
for pkg in self.list_packages(repo):
enter_date = datetime.datetime(*time.strptime(self.get_package(pkg).history[-1].date, "%Y-%m-%d")[0:6])
failed = False
try:
enter_date = datetime.datetime(*time.strptime(self.get_package(pkg).history[-1].date, "%m-%d-%Y")[0:6])
except:
failed = True
if failed:
try:
enter_date = datetime.datetime(*time.strptime(self.get_package(pkg).history[-1].date, "%Y-%m-%d")[0:6])
except:
enter_date = datetime.datetime(*time.strptime(self.get_package(pkg).history[-1].date, "%Y-%d-%m")[0:6])
if enter_date >= since_date:
packages.append(pkg)
return packages
......@@ -53,7 +53,6 @@ class Repo:
medias = (cd, usb, remote, local) = list(range(4))
class RepoOrder:
def __init__(self):
self._doc = None
self.repos = self._get_repos()
......@@ -174,6 +173,7 @@ class RepoDB(lazydb.LazyDB):
def init(self):
self.repoorder = RepoOrder()
def has_repo(self, name):
return name in self.list_repos(only_active=False)
......@@ -198,7 +198,6 @@ class RepoDB(lazydb.LazyDB):
ctx.ui.warning(_("{} repository needs to be updated").format(repo_name))
return xmlext.newDocument("INARY")
try:
return xmlext.parse(index_path)
except Exception as e:
......
File mode changed from 100644 to 100755
......@@ -21,6 +21,37 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
# These guys will change due to depmod calls.
_blessed_kernel_borks = [
"modules.alias",
"modules.alias.bin",
"modules.dep",
"modules.dep.bin",
"modules.symbols",
"modules.symbols.bin",
]
def ignorance_is_bliss(f):
""" Too many complaints about things that are missing. """
p = f
if not p.startswith("/"):
p = "/{}".format(f)
pbas = os.path.basename(p)
p = p.replace("/lib64/", "/lib/")
# Ignore kernel depmod changes?
if p.startswith("/lib/modules"):
if pbas in _blessed_kernel_borks:
return True
# Running eopkg as root will mutate .pyc files. Ignore them.
if p.endswith(".pyc"):
return True
def file_corrupted(pfile):
path = os.path.join(ctx.config.dest_dir(), pfile.path)
if os.path.islink(path):
......@@ -47,6 +78,9 @@ def check_files(files, check_config=False):
continue
if not f.hash:
continue
if ignorance_is_bliss(f.path):
continue
is_file_corrupted = False
......
......@@ -54,6 +54,33 @@ def __listactions(actions):
return beinstalled, beremoved, configs
def __getpackageurl_binman(package):
packagedb = inary.db.packagedb.PackageDB()
repodb = inary.db.repodb.RepoDB()
pkg, ver = inary.util.parse_package_name(package)
reponame = None
try:
reponame = packagedb.which_repo(pkg)
except Exception:
# Maybe this package is obsoluted from repository
for repo in repodb.get_binary_repos():
if pkg in packagedb.get_obsoletes(repo):
reponame = repo
if not reponame:
raise PackageNotFound
package_ = packagedb.get_package (pkg)
repourl = repodb.get_repo_url(reponame)
base_package = os.path.dirname (package_.packageURI)
repo_base = os.path.dirname (repourl)
possible_url = os.path.join (repo_base, base_package, package)
ctx.ui.info(_("Package %s found in repository %s") % (pkg, reponame))
#return _possible_ url for this package
return possible_url
def __getpackageurl(package):
packagedb = inary.db.packagedb.PackageDB()
repodb = inary.db.repodb.RepoDB()
......@@ -80,8 +107,9 @@ def __getpackageurl(package):
package)
def fetch_remote_file(package, errors):
try:
uri = inary.file.File.make_uri(__getpackageurl(package))
uri = inary.file.File.make_uri(__getpackageurlbinman(package))
except PackageNotFound:
errors.append(package)
ctx.ui.info(_("{} could not be found").format(package), color="red")
......@@ -90,12 +118,22 @@ def fetch_remote_file(package, errors):
dest = ctx.config.cached_packages_dir()
filepath = os.path.join(dest, uri.filename())
if not os.path.exists(filepath):
failed = True
try:
inary.fetcher.fetch_url(uri, dest, ctx.ui.Progress)
except inary.fetcher.FetchError:
errors.append(package)
ctx.ui.info(_("{} could not be found").format(package), color="red")
return False
failed = True
if failed:
try:
new_uri = inary.file.File.make_uri(__getpackageurl(package))
inary.fetcher.fetch_url(new_uri, dest, ctx.ui.Progress)
except:
errors.append(package)
ctx.ui.info(_("{} could not be found").format(package), "red")
return False
else:
ctx.ui.info(_('{} [cached]').format(uri.filename()))
return True
......
......@@ -226,10 +226,13 @@ def upgrade(A=None, repo=None):
operations.remove.remove_obsoleted_packages()
for path in paths:
ctx.ui.info(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), color="yellow")
install_op = atomicoperations.Install(path, ignore_file_conflicts = True)
install_op.install(not ctx.get_option('compare_sha1sum'))
try:
for path in paths:
ctx.ui.info(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), color="yellow")
install_op = atomicoperations.Install(path, ignore_file_conflicts = True)
install_op.install(not ctx.get_option('compare_sha1sum'))
except Exception as e:
raise(e)
def plan_upgrade(A, force_replaced=True, replaces=None):
# FIXME: remove force_replaced
......
......@@ -42,6 +42,7 @@ class Package:
formats = ("1.0", "1.1", "1.2")
default_format = "1.2"
timestamp = None
@staticmethod
def archive_name_and_format(package_format):
......@@ -153,6 +154,9 @@ class Package:
self.install_archive.close()
arcpath = self.install_archive_path
arcname = os.path.basename(arcpath)
if self.timestamp is not None:
tstamp = self.timestamp
os.utime(arcpath, (tstamp, tstamp))
self.add_to_package(arcpath, arcname)
self.impl.close()
......
......@@ -42,7 +42,7 @@ def run_batch(cmd, ui_debug=True):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if ui_debug: ctx.ui.debug(_('return value for "{0}" is {1}').format(cmd, p.returncode))
return p.returncode, out, err
return p.returncode, out.decode('utf-8'), err
# TODO: it might be worthwhile to try to remove the
# use of ctx.stdout, and use run_batch()'s return
......
......@@ -37,12 +37,12 @@ MIMEFILE_DIR = "usr/share/mime/packages"
class Build(build):
def run(self):
#Preparing configure file
shutil.copy("config/inary.conf-{}".format(sys.arch), "config/inary.conf")
shutil.copy("config/inary.conf-{}".format(os.uname().machine), "config/inary.conf")
build.run(self)
self.mkpath(self.build_base)
for in_file in IN_FILES:
name, ext = os.path.splitext(in_file)
self.spawn(["intltool-merge", "-x", "po", in_file, os.path.join(self.build_base, name)])
......@@ -212,17 +212,11 @@ setup(name="inary",
'inary.cli',
'inary.data',
'inary.db',
'inary.libraries',
'inary.operations',
'inary.sxml',
'inary.scenarioapi',
'inary.util'],
scripts = ['inary-cli',
'scripts/lsinary',
'scripts/uninary',
'scripts/check-newconfigs.py',
'scripts/inarysh',
'tools/pspec2po'],
# include_package_data=True,
cmdclass = {'build' : Build,
'build_po' : BuildPo,
'install' : Install,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment