Merge branch 'develop' into 'master'

1.4.2

See merge request sulinos/devel/inary!43
......@@ -116,3 +116,5 @@ config/inary.conf
MANIFEST
.config
DESTDIR=/
all: build
all: clean build
clean:
`find | grep pycache | sed 's/^/rm -rf /g'`
......
......@@ -63,6 +63,9 @@ def _cleanup():
ctx.enable_keyboard_interrupts()
# we need umask 0x022 (0x027 may broke so we need force 0x022)
os.umask(18)
# Hack for inary to work with non-patched Python. inary needs
# lots of work for not doing this.
importlib.reload(sys)
......
......@@ -106,8 +106,8 @@ def installDIR():
def lsbINFO():
"""Returns a dictionary filled through /etc/lsb-release."""
return dict([(l.split("=")[0], l.split("=")[1].strip("'\""))
for l in open("/etc/lsb-release").read().strip().split("\n") if "=" in l])
return dict([(line.split("=")[0], line.split("=")[1].strip("'\""))
for line in open("/etc/lsb-release").read().strip().split("\n") if "=" in line])
def kernelVERSION():
......
......@@ -249,8 +249,8 @@ def installModuleHeaders(extraHeaders=None, distro=""):
# First create the skel
find_cmd = "find . -path %s -prune -o -type f \( -name %s \) -print" % \
(
" -prune -o -path ".join(["'./%s/*'" % l for l in pruned]),
" -o -name ".join(["'%s'" % k for k in wanted])
" -prune -o -path ".join(["'./%s/*'" % prune for prune in pruned]),
" -o -name ".join(["'%s'" % want for want in wanted])
) + " | cpio -pVd --preserve-modification-time %s" % destination
shelltools.system(find_cmd)
......
......@@ -114,7 +114,12 @@ def auto_dodoc():
def install(parameters=''):
"""does ruby setup.rb install"""
if system(
'ruby -w setup.rb --prefix=/{0}/{1} --destdir={1} {2}'.format(get.defaultprefixDIR(), get_gemdir(), get.installDIR(), parameters)):
'ruby -w setup.rb --prefix=/{0}/{1} --destdir={1} {2}'.format(
get.defaultprefixDIR(),
get_gemdir(),
get.installDIR(),
parameters
)):
raise InstallError(_('Install failed.'))
auto_dodoc()
......
......@@ -123,9 +123,8 @@ def unlink(pattern):
ctx.ui.error(
_('ActionsAPI [unlink]: Permission denied: \"{}\"').format(filePath))
elif isDirectory(filePath):
ctx.ui.warning(_(
'ActionsAPI [unlink]: \"{}\" is not a file, use \'unlinkDir\' or \'removeDir\' to remove directories.').format(
filePath))
ctx.ui.warning(
_('ActionsAPI [unlink]: \"{}\" is not a file, use \'unlinkDir\' or \'removeDir\' to remove directories.').format(filePath))
else:
ctx.ui.error(
......
......@@ -186,8 +186,9 @@ def handleConfigFiles():
ctx.ui.info(
_('Creating \"/etc/texmf/{}.d\"').format(dirname))
dodir("/etc/texmf/{}.d".format(dirname))
ctx.ui.info(_('Moving (and symlinking) \"/usr/share/texmf/{0}\" to \"/etc/texmf/{1}.d\"').format(configFile,
dirname))
ctx.ui.info(
_('Moving (and symlinking) \"/usr/share/texmf/{0}\" to \"/etc/texmf/{1}.d\"').format(configFile,
dirname))
domove("/usr/share/texmf/{0}/{1}".format(dirname,
configFile), "/etc/texmf/{}.d".format(dirname))
dosym("/etc/texmf/{0}.d/{1}".format(dirname, configFile),
......
......@@ -449,13 +449,11 @@ class ArchiveTar(ArchiveBase):
if not os.path.isdir(tarinfo.name) and not os.path.islink(tarinfo.name):
try:
os.unlink(tarinfo.name)
except:
except Exception:
# TODO: review this block
pass
self.tar.extract(tarinfo)
except IOError as e:
os.remove(tarinfo.name)
self.tar.extract(tarinfo)
except OSError as e:
# Handle the case where an upper directory cannot
# be created because of a conflict with an existing
......
......@@ -163,6 +163,7 @@ class Install(AtomicOperation):
self.store_old_paths = None
self.old_path = None
self.trigger = inary.trigger.Trigger()
self.ask_reinstall=False
def install(self, ask_reinstall=True):
......@@ -338,13 +339,13 @@ class Install(AtomicOperation):
def postinstall(self):
# Chowning for additional files
# for _file in self.package.get_files().list:
# fpath = util.join_path(ctx.config.dest_dir(), _file.path)
# if os.path.islink(fpath):
# ctx.ui.info(_("Added symlink '{}' ").format(fpath), verbose=True)
# 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))
for _file in self.package.get_files().list:
fpath = util.join_path(ctx.config.dest_dir(), _file.path)
if os.path.islink(fpath):
if os.path.lexists(fpath) and os.path.exists(fpath):
ctx.ui.info(_("Added symlink '{}' ").format(fpath), verbose=True)
else:
ctx.ui.warning(_("Broken or missing symlink '{}'").format(fpath))
if 'postOps' in self.metadata.package.isA:
if ctx.config.get_option(
......@@ -437,12 +438,19 @@ class Install(AtomicOperation):
new_paths.append(f.path)
for old_file in self.old_files.list:
if old_file.path in new_paths:
continue
old_file_path = os.path.join(
ctx.config.dest_dir(), old_file.path)
if old_file.path in new_paths:
continue
if old_file_path not in new_paths:
if os.path.islink(old_file_path):
os.unlink(old_file_path)
continue
try:
old_file_stat = os.lstat(old_file_path)
except OSError:
......@@ -523,7 +531,7 @@ class Install(AtomicOperation):
try:
self.package.extract_file_synced(
postops, ctx.config.tmp_dir())
except:
except Exception:
pass
def store_inary_files(self):
......@@ -539,7 +547,7 @@ class Install(AtomicOperation):
try:
self.package.extract_file_synced(
postops, self.package.pkg_dir())
except:
except Exception:
pass
def update_databases(self):
......
......@@ -43,6 +43,7 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
super(AddRepo, self).__init__(args)
self.repodb = inary.db.repodb.RepoDB()
name = ("add-repo", "ar")
def options(self):
......@@ -66,31 +67,9 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
if len(self.args) == 2:
self.init()
name, indexuri = self.args
self.just_add = False
if ctx.get_option('no_fetch'):
if ctx.ui.confirm(_('Add \"{}\" repository without updating the database?\nBy confirming '
'this you are also adding the repository to your system without '
'checking the distribution of the repository.\n'
'Would you like to continue?').format(name)):
self.just_add = True
if indexuri.endswith(".xml.xz") or indexuri.endswith(".xml"):
repository.add_repo(name, indexuri, ctx.get_option('at'))
if not self.just_add:
try:
repository.update_repos([name])
except (inary.errors.Error, IOError) as e:
ctx.ui.info(
_("Error: {0} repository could not be reached: \n{1}").format(
name, e), color="red")
self.warn_and_remove(
_("Removing {0} from system.").format(name), name)
else:
ctx.ui.warning(
_("Couldn't trust \"{0}\" repository. It is deactivated.").format(name))
repository.set_repo_activity(name, False)
else:
raise Exception(
_("Extension of repository URI must be \".xml.xz\" or \".xml\"."))
......
......@@ -71,7 +71,7 @@ Usage: check-relation
installed.sort()
need_reinstall = []
broken_packages=[]
broken_packages = []
for pkg in installed:
for p in self.installdb.get_package(pkg).runtimeDependencies():
......@@ -79,7 +79,7 @@ Usage: check-relation
if not self.installdb.has_package(str(p.package)):
need_reinstall.append(p.package)
sys.stderr.write(
_("Missing: - {} : Needed by: - {}").format(p.package,pkg)+"\n")
_("Missing: - {} : Needed by: - {}").format(p.package, pkg)+"\n")
if self.options.force:
for pkg in installed:
......
......@@ -60,8 +60,8 @@ class Command(object):
@staticmethod
def commands_string():
s = ''
l = sorted([x.name[0] for x in Command.cmd])
for name in l:
lst = sorted([x.name[0] for x in Command.cmd])
for name in lst:
commandcls = Command.cmd_dict[name]
trans = gettext.translation('inary', fallback=True)
summary = trans.gettext(commandcls.__doc__).split('\n')[0]
......
......@@ -53,7 +53,8 @@ You can also give the name of a component.
group.add_option("--ignore-sysconf", action="store_true",
default=False, help=_("Skip sysconf operations after installation."))
group.add_option("--force-sysconf", action="store_true",
default=False, help=_("Force sysconf operations after installation. Applies all sysconf operations"))
default=False, help=_("Force sysconf operations after installation."
"Applies all sysconf operations"))
self.parser.add_option_group(group)
......
......@@ -53,7 +53,8 @@ You can also give the name of a component.
group.add_option("--ignore-sysconf", action="store_true",
default=False, help=_("Skip sysconf operations after installation."))
group.add_option("--force-sysconf", action="store_true",
default=False, help=_("Force sysconf operations after installation. Applies all sysconf operations"))
default=False, help=_("Force sysconf operations after installation. "
"Applies all sysconf operations"))
self.parser.add_option_group(group)
......
......@@ -68,8 +68,7 @@ Lists previous operations.""")
history.takeback(operation)
def print_history(self):
ordered_history = []
ordered_history.append(_("Inary Transaction History: "))
ordered_history = [_("Inary Transaction History: ")]
for operation in self.historydb.get_last(ctx.get_option('last')):
msg_oprt = util.colorize(_("Operation "), 'yellow') \
......
......@@ -61,7 +61,8 @@ expanded to package names.
group.add_option("--ignore-sysconf", action="store_true",
default=False, help=_("Skip sysconf operations after installation."))
group.add_option("--force-sysconf", action="store_true",
default=False, help=_("Force sysconf operations after installation. Applies all sysconf operations"))
default=False, help=_("Force sysconf operations after installation."
"Applies all sysconf operations"))
group.add_option("-c", "--component", action="append",
default=None, help=_("Install component's and recursive components' packages."))
group.add_option("-r", "--repository", action="store",
......
......@@ -80,21 +80,21 @@ all repositories.
component = ctx.get_option('component')
if component:
try:
l = self.componentdb.get_packages(
packages = self.componentdb.get_packages(
component, repo=repo, walk=True)
except BaseException:
return
else:
l = self.packagedb.list_packages(repo)
packages = self.packagedb.list_packages(repo)
installed_list = inary.db.installdb.InstallDB().list_installed()
# maxlen is defined dynamically from the longest package name (#9021)
if l:
maxlen = max([len(_p) for _p in l])
if packages:
maxlen = max([len(_p) for _p in packages])
l.sort()
for p in l:
packages.sort()
for p in packages:
if ctx.config.get_option('uninstalled') and p in installed_list:
continue
......
......@@ -50,11 +50,11 @@ 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:
components = self.componentdb.list_components(ctx.get_option('repository'))
if components:
maxlen = max([len(_p) for _p in components])
components.sort()
for p in components:
component = self.componentdb.get_component(p)
if self.options.long:
ctx.ui.info(str(component))
......
......@@ -71,8 +71,8 @@ packages from all repositories.
int(ctx.config.get_option('last')))
else:
since = None
l = self.packagedb.list_newest(repo, since, self.historydb)
if not l:
newests = self.packagedb.list_newest(repo, since, self.historydb)
if not newests:
return
if since:
ctx.ui.info(
......@@ -82,10 +82,10 @@ packages from all repositories.
ctx.ui.info(_("Packages added to \'{}\':").format(repo))
# maxlen is defined dynamically from the longest package name (#9021)
maxlen = max([len(_p) for _p in l])
maxlen = max([len(_p) for _p in newests])
l.sort()
for p in l:
newests.sort()
for p in newests:
pkgsum = self.packagedb.get_summary(p)
lenp = len(p)
p += ' ' * max(0, maxlen - lenp)
......
......@@ -48,15 +48,15 @@ Gives a brief list of sources published in the repositories.
self.init(database=True, write=False)
l = self.sourcedb.list_sources()
sources = self.sourcedb.list_sources()
if l:
if sources:
maxlen = max([len(_p) for _p in l])
installed_list = inary.db.sourcedb.SourceDB().list_sources()
l.sort()
sources.sort()
for p in l:
for p in sources:
sf, repo = self.sourcedb.get_spec_repo(p)
if self.options.long:
ctx.ui.info(_('[Repository: ') + repo + ']')
......
......@@ -47,7 +47,8 @@ expanded to package names.
group.add_option("--ignore-sysconf", action="store_true",
default=False, help=_("Skip sysconf operations after installation."))
group.add_option("--force-sysconf", action="store_true",
default=False, help=_("Force sysconf operations after installation. Applies all sysconf operations"))
default=False, help=_("Force sysconf operations after installation."
"Applies all sysconf operations"))
group.add_option("--purge", action="store_true",
default=False, help=_("Removes everything including changed config files of the package."))
group.add_option("-c", "--component", action="append",
......
......@@ -48,7 +48,8 @@ Remove all orphaned packages from the system.
group.add_option("--ignore-sysconf", action="store_true",
default=False, help=_("Skip sysconf operations after installation."))
group.add_option("--force-sysconf", action="store_true",
default=False, help=_("Force sysconf operations after installation. Applies all sysconf operations"))
default=False, help=_("Force sysconf operations after installation."
"Applies all sysconf operations"))
self.parser.add_option_group(group)
......
......@@ -54,8 +54,6 @@ expanded to package names.
super(Upgrade, self).options(group)
group.add_option("--security-only", action="store_true",
default=False, help=_("Security related package upgrades only."))
group.add_option("-b", "--bypass-update-repo", action="store_true",
default=False, help=_("Do not update repositories."))
group.add_option("--ignore-file-conflicts", action="store_true",
default=False, help=_("Ignore file conflicts."))
group.add_option("--ignore-package-conflicts", action="store_true",
......@@ -63,7 +61,8 @@ expanded to package names.
group.add_option("--ignore-sysconf", action="store_true",
default=False, help=_("Skip sysconf operations after installation."))
group.add_option("--force-sysconf", action="store_true",
default=False, help=_("Force sysconf operations after installation. Applies all sysconf operations"))
default=False, help=_("Force sysconf operations after installation. "
"Applies all sysconf operations"))
group.add_option("--preserve-permanent", action="store_true",
default=False,
help=_("Preserves permanent tagged files on upgrade action "
......@@ -97,13 +96,6 @@ expanded to package names.
else:
self.init()
if not ctx.get_option('bypass_update_repo'):
ctx.ui.info(_('Updating repositories.'), color='green')
repos = inary.db.repodb.RepoDB().list_repos(only_active=True)
repository.update_repos(repos)
else:
ctx.ui.info(_('Will not update repositories.'))
reposit = ctx.get_option('repository')
components = ctx.get_option('component')
packages = []
......
......@@ -176,7 +176,6 @@ class Index(xmlfile.XmlFile, metaclass=autoxml.autoxml):
pool.terminate()
pool.join()
ctx.ui.info("")
raise
latest_packages = []
......
......@@ -70,8 +70,10 @@ class PGraph:
if self.installdb.has_package(dep):
self.packages.append(dep)
else:
if self.installdb.has_package(pkg) and not self.reinstall:
return
if self.installdb.has_package(pkg):
if self.packagedb.get_package(pkg).release == self.installdb.get_package(pkg).release:
if not self.reinstall:
return
if pkg not in self.packages:
self.packages.append(pkg)
for dep in self.packagedb.get_package(pkg).runtimeDependencies():
......
......@@ -37,7 +37,7 @@ def flush_caches():
def update_caches():
# Updates ondisk caches
# Updates on disk caches
for db in [packagedb.PackageDB(), sourcedb.SourceDB(), componentdb.ComponentDB(),
installdb.InstallDB(), groupdb.GroupDB()]:
if db.is_initialized():
......@@ -47,6 +47,9 @@ def update_caches():
def regenerate_caches():
flush_caches()
# Force cache regeneration
for db in [packagedb.PackageDB(), sourcedb.SourceDB(),
try:
for db in [packagedb.PackageDB(), sourcedb.SourceDB(),
componentdb.ComponentDB(), groupdb.GroupDB()]:
db.cache_regenerate()
db.cache_regenerate()
except Exception: # TODO: warning message needed
pass
......@@ -139,7 +139,7 @@ class HistoryDB(lazydb.LazyDB):
yield hist.operation
def get_last_repo_update(self, last=1):
repoupdates = [l for l in self.__logs if l.endswith("repoupdate.xml")]
repoupdates = [log for log in self.__logs if log.endswith("repoupdate.xml")]
repoupdates.reverse()
if last != 1 and len(repoupdates) <= last:
......
......@@ -175,7 +175,7 @@ class RepoDB(lazydb.LazyDB):
index_path = os.path.splitext(index_path)[0]
if not os.path.exists(index_path):
#ctx.ui.warning(_("{} repository needs to be updated").format(repo_name))
# ctx.ui.warning(_("{} repository needs to be updated").format(repo_name))
return xmlext.newDocument("INARY")
try:
......@@ -291,8 +291,13 @@ class RepoDB(lazydb.LazyDB):
if not compatible:
self.deactivate_repo(name)
raise IncompatibleRepoError(
_("Repository \"{}\" is not compatible with your distribution. Repository is disabled.\nYour distribution is {} release {}\nRepository distribution is {} release {}\n\nIf you want add this repository please use \"--ignore-check\" parameter with this command.").format(name,
ctx.config.values.general.distribution,
ctx.config.values.general.distribution_release,
dist_name,
dist_release))
_("Repository \"{}\" is not compatible with your distribution. Repository is disabled."
"Your distribution is {} release {}"
"Repository distribution is {} release {}\n"
"If you want add this repository please use \"--ignore-check\" parameter with this command.").format(
name,
ctx.config.values.general.distribution,
ctx.config.values.general.distribution_release,
dist_name,
dist_release)
)
......@@ -269,7 +269,12 @@ class Fetcher:
c.close()
def _get_wget(self):
return os.system("busybox wget -c --user-agent \"{}\" \"{}\" -O \"{}\" 2>&1".format(self.useragent, self.url.get_uri(), self.partial_file))
return os.system("busybox wget -c --user-agent \"{}\" \"{}\" -O \"{}\" 2>&1".format(
self.useragent,
self.url.get_uri(),
self.partial_file
)
)
def _get_requests(self):
from requests import get
......@@ -397,7 +402,8 @@ class Fetcher:
return True
else:
ctx.ui.debug(
_("Server doesn't support partial downloads. Previously downloaded part of the file will be over-written."))
_("Server doesn't support partial downloads."
"Previously downloaded part of the file will be over-written."))
os.remove(self.partial_file)
return False
......
......@@ -9,7 +9,9 @@
#
# Please read the COPYING file.
#
def sort_bubble(array=[], reverse=False):
def sort_bubble(array=None, reverse=False):
if array is None:
array = []
mlen = len(array)
cout_i = 0
while cout_i < mlen:
......@@ -76,7 +78,9 @@ def sort_min_max(x, reverse=False):
return array
def sort_auto(array=[], reverse=False):
def sort_auto(array=None, reverse=False):
if array is None:
array = []
if len(array) <= 10:
return sort_bubble(array, reverse)
elif len(array) <= 500:
......
......@@ -210,22 +210,34 @@ class Builder:
_("Source \"{}\" not found in any active repository.").format(name))
def __init__(self, specuri):
self.emerge=False
if "://" in specuri:
self.emerge=True
self.componentdb = inary.db.componentdb.ComponentDB()
self.installdb = inary.db.installdb.InstallDB()
self.specuri=specuri
self.specdiruri = os.path.dirname(self.specuri)
if len(self.specdiruri) > 0 and self.emerge:
self.pkgname = os.path.basename(self.specdiruri)
self.destdir = util.join_path(ctx.config.tmp_dir(), self.pkgname)
else:
self.destdir=None
# process args
if not isinstance(specuri, inary.uri.URI):
specuri = inary.uri.URI(specuri)
if self.emerge:
self.fetch_pspecfile()
# read spec file, we'll need it :)
self.set_spec_file(specuri)
self.spec = self.set_spec_file(specuri)
if specuri.is_remote_file():
self.specdir = self.fetch_files()
else:
self.specdir = os.path.dirname(self.specuri.get_uri())
# Don't wait until creating .inary file for complaining about versioning
# scheme errors
self.package_rfp = None
......@@ -245,7 +257,10 @@ class Builder:
self.target_package_format = ctx.get_option("package_format") \
or inary.package.Package.default_format
self.read_translations(self.specdir)
try:
self.read_translations(self.specdir)
except Exception:
ctx.ui.output(_("Translation cannot readed.")+"\n")
self.sourceArchives = inary.archive.SourceArchives(self.spec)
......@@ -270,15 +285,20 @@ class Builder:
self.has_ccache = False
self.has_icecream = False
self.variable_buffer = {}
self.destdir=os.getcwd()
def set_spec_file(self, specuri):
if not specuri.is_remote_file():
# FIXME: doesn't work for file://
specuri = inary.uri.URI(os.path.realpath(specuri.get_uri()))
self.specuri = specuri
spec = Specfile.SpecFile()
spec.read(self.specuri, ctx.config.tmp_dir())
self.spec = spec
if self.emerge:
spec.read("{}/{}".format(self.destdir,ctx.const.pspec_file),self.specuri)
else:
spec.read(self.specuri, ctx.config.tmp_dir())
return spec
def read_translations(self, specdir):
self.spec.read_translations(util.join_path(specdir,
......@@ -356,7 +376,12 @@ class Builder:
self.check_patches()
self.check_build_dependencies()
self.fetch_component()
try:
self.fetch_component()
except:
ctx.ui.output(_("Component cannot readed.")+"\n")
self.fetch_source_archives()
util.clean_dir(self.pkg_install_dir())
......@@ -468,9 +493,6 @@ class Builder:
os.environ["CCACHE_DIR"] = "/tmp/.ccache"
def fetch_files(self):
self.specdiruri = os.path.dirname(self.specuri.get_uri())
pkgname = os.path.basename(self.specdiruri)
self.destdir = util.join_path(ctx.config.tmp_dir(), pkgname)
# self.location = os.path.dirname(self.url.uri)
self.fetch_actionsfile()
......@@ -479,7 +501,6 @@ class Builder:
self.fetch_patches()
self.fetch_additionalFiles()
self.fetch_postops()
return self.destdir
def fetch_pspecfile(self):
......@@ -523,9 +544,8 @@ class Builder:
def fetch_postops(self):
for postops in ctx.const.postops:
postops_script = util.join_path(self.specdiruri, postops)
if util.check_file(postops_script, noerr=True):
self.download(postops_script, util.join_path(self.specdir))
ctx.ui.info(_("PostOps Script Fetched."))
if util.check_file(postops_script, noerr=True) or "://" in postops_script:
self.download(postops_script, util.join_path(self.destdir))
@staticmethod
def download(uri, transferdir):
......@@ -703,11 +723,11 @@ class Builder:
"""Returns the real path of WorkDir for an unpacked archive."""
dirname = self.<