Kaydet (Commit) 3f41091c authored tarafından Your Name's avatar Your Name

pep8 fixes and full emerge working without binary repo

üst b080e80a
......@@ -127,3 +127,4 @@ INARY 2.0 Yol Haritası ve Yapılacaklar
6. Long Term
... Zamanla eklenecek ...
#!/bin/bash
set -e
set - e
setcfg(){
echo -ne " $1 [y/n]"
read -sn 1 c
echo -ne "\033[32;1m($c)\033[;0m"
if [ "$c" == "y" ] || [ "$c" == "Y" ] ; then
echo "$2=y" >> .config
echo - ne " $1 [y/n]"
read - sn 1 c
echo - ne "\033[32;1m($c)\033[;0m"
if ["$c" == "y"] | | ["$c" == "Y"]
then
echo "$2=y" >> .config
else
echo "$2=n" >> .config
echo "$2=n" >> .config
fi
echo
}
defconfig="ny"
defconfig = "ny"
ask_cfg(){
echo -e "\033[34;1mInary configure :\033[;0m"
echo - e "\033[34;1mInary configure :\033[;0m"
echo "#inary config file" > .config
setcfg "Native language support" "NLS_SUPPORT"
setcfg "Additional scripts" "ADDITIONAL_SCRIPTS"
echo -e "\033[33;1m\".config\" file changed.\033[;0m"
echo - e "\033[33;1m\".config\" file changed.\033[;0m"
}
ask_check(){
echo -e "\033[34;1mInary check :\033[;0m"
chkfile "/dev/null"
chkfile "/usr/bin/"
chkfile "/var/lib/"
chkfile "/usr/lib/"
chkfile "/etc/"
chkcmd "python3" && chkcmd "python3.8" || chkcmd "python3.7"
chkcmd "intltool-extract"
chkcmd "xgettext"
chkcmd "msgfmt"
echo - e "\033[34;1mInary check :\033[;0m"
chkfile "/dev/null"
chkfile "/usr/bin/"
chkfile "/var/lib/"
chkfile "/usr/lib/"
chkfile "/etc/"
chkcmd "python3" & & chkcmd "python3.8" | | chkcmd "python3.7"
chkcmd "intltool-extract"
chkcmd "xgettext"
chkcmd "msgfmt"
}
chkcmd(){
echo -ne "checking $1 "
if which $1 &>/dev/null ; then
echo -e "\033[32;1m(yes)\033[;0m"
echo - ne "checking $1 "
if which $1 & >/dev/null
then
echo - e "\033[32;1m(yes)\033[;0m"
else
echo -e "\033[33;1m(no)\033[;0m"
echo -e "\033[32;1mERROR:\033[;0m $1 not found in \$PATH"
return 1
echo - e "\033[33;1m(no)\033[;0m"
echo - e "\033[32;1mERROR:\033[;0m $1 not found in \$PATH"
return 1
fi
}
chkfile(){
echo -ne "checking $1 "
if [ -e "$1" ] ; then
echo -e "\033[32;1m(yes)\033[;0m"
echo - ne "checking $1 "
if [-e "$1"]
then
echo - e "\033[32;1m(yes)\033[;0m"
else
echo -e "\033[33;1m(no)\033[;0m"
echo -e "\033[32;1mERROR:\033[;0m $1 not found."
return 1
echo - e "\033[33;1m(no)\033[;0m"
echo - e "\033[32;1mERROR:\033[;0m $1 not found."
return 1
fi
}
yes(){
while true ; do
echo -ne "$1"
while true
do
echo - ne "$1"
done
}
usage(){
cat <<EOF
./configure [OPTIONS]
cat << EOF
./configure[OPTIONS]
Options list:
Options list:
--yes-all : Enable all
--no-all : Disable all
--default : Use default config
--yes-all: Enable all
- -no-all: Disable all
- -default: Use default config
--help : Show this message
--clean : Delete .config file
- -help: Show this message
- -clean: Delete .config file
EOF
EOF
}
for i in $@ ; do
if [ "$i" == "--yes-all" ] ; then
ask_check
yes y | ask_cfg
exit 0
elif [ "$i" == "--no-all" ] ; then
ask_check
yes n | ask_cfg
exit 0
elif [ "$i" == "--clean" ] ; then
[ -f .config ] && rm -f .config
exit 0
elif [ "$i" == "--default" ] ; then
ask_check
echo "$defconfig" | ask_cfg
exit 0
elif [ "$i" == "--help" ] ; then
usage
exit 0
fi
for i in $@
do
if ["$i" == "--yes-all"]
then
ask_check
yes y | ask_cfg
exit 0
elif ["$i" == "--no-all"]
then
ask_check
yes n | ask_cfg
exit 0
elif ["$i" == "--clean"]
then
[-f .config] & & rm - f .config
exit 0
elif ["$i" == "--default"]
then
ask_check
echo "$defconfig" | ask_cfg
exit 0
elif ["$i" == "--help"]
then
usage
exit 0
fi
done
ask_cfg
......@@ -290,7 +290,6 @@ class Install(AtomicOperation):
elif pkg_version < iversion:
ctx.ui.warning(_('Downgrade to old version.'))
pkg_release = int(pkg.release)
irelease = int(irelease_s)
......@@ -311,7 +310,6 @@ class Install(AtomicOperation):
raise Error(_('Package re-install declined'))
self.operation = REINSTALL
# schedule for reinstall
self.old_files = self.installdb.get_files(pkg.name)
......
......@@ -34,4 +34,4 @@ class InitNothing(command.PackageOp, metaclass=command.autocommand):
pass
def run(self):
repodb=inary.db.repodb.RepoDB()
repodb = inary.db.repodb.RepoDB()
......@@ -42,6 +42,7 @@ class PackageDB(lazydb.LazyDB):
def init(self):
self.__package_nodes = {} # Packages
self.__source_nodes = {} # Packages
self.__revdeps = {} # Reverse dependencies
self.__obsoletes = {} # Obsoletes
self.__replaces = {} # Replaces
......@@ -50,6 +51,7 @@ class PackageDB(lazydb.LazyDB):
for repo in repodb.list_repos():
doc = repodb.get_repo_doc(repo)
self.__package_nodes[repo] = self.__generate_packages(doc)
self.__source_nodes[repo] = self.__generate_sources(doc)
self.__revdeps[repo] = self.__generate_revdeps(doc)
self.__obsoletes[repo] = self.__generate_obsoletes(doc)
self.__replaces[repo] = self.__generate_replaces(doc)
......@@ -89,11 +91,17 @@ class PackageDB(lazydb.LazyDB):
compressed_data = gzip.zlib.compress(
xmlext.toString(x).encode('utf-8'))
pdict[name] = compressed_data
return pdict
@staticmethod
def __generate_sources(doc):
pdict = {}
for x in xmlext.getTagByName(doc, "SpecFile"):
source = xmlext.getNode(x, "Source")
name = xmlext.getNodeText(source,"Name")
name = xmlext.getNodeText(source, "Name")
compressed_data = gzip.zlib.compress(
xmlext.toString(source).encode('utf-8'))
xmlext.toString(x).encode('utf-8'))
pdict[name] = compressed_data
return pdict
......
......@@ -41,6 +41,7 @@ class SourceDB(lazydb.LazyDB):
self.__source_nodes = {}
self.__pkgstosrc = {}
self.__revdeps = {}
self.pkg_src_nodes = None
repodb = inary.db.repodb.RepoDB()
for repo in repodb.list_repos():
......@@ -86,9 +87,25 @@ class SourceDB(lazydb.LazyDB):
return revdeps
def get_pkg_src(self, repo=None):
if self.pkg_src_nodes:
return self.pkg_src_nodes
pkg_src = {}
for src in self.list_sources(repo):
for pkg in self.list_package_from_source(src):
pkg_src[pkg] = src
return pkg_src
def list_sources(self, repo=None):
return self.sdb.get_item_keys(repo)
def list_package_from_source(self, source, repo=None):
src = self.get_spec(source, repo)
ret = set()
for pkg in src.packages:
ret.add(pkg.name)
return ret
def which_repo(self, name):
return self.sdb.which_repo(self.pkgtosrc(name))
......@@ -145,7 +162,8 @@ class SourceDB(lazydb.LazyDB):
return spec, repo
def pkgtosrc(self, name, repo=None):
return self.psdb.get_item(name, repo)
src = self.get_pkg_src(repo)[name]
return src or self.psdb.get_item(name, repo)
def get_rev_deps(self, name, repo=None):
try:
......
......@@ -42,4 +42,3 @@ class autoeq(type):
class Struct(metaclass=autoeq):
def __init__(self, **entries):
self.__dict__.update(entries)
......@@ -238,8 +238,8 @@ class Builder:
# Don't wait until creating .inary file for complaining about versioning
# scheme errors
if os.getuid() == 0:
# Compile package as root user is dangerous.
if not self.emerge and not ctx.ui.confirm(
# Compile package as root user is dangerous.
if not self.emerge and not ctx.ui.confirm(
_("Would you like to compile package as root user?")):
raise Error(_("Operation canceled."))
......@@ -299,7 +299,7 @@ class Builder:
spec = Specfile.SpecFile()
if self.emerge:
spec.read("{}/{}".format(self.destdir,
ctx.const.pspec_file), self.specuri)
ctx.const.pspec_file), self.specuri)
else:
spec.read(self.specuri, ctx.config.tmp_dir())
return spec
......
......@@ -50,32 +50,28 @@ def emerge(A):
# FIXME: Errr... order_build changes type conditionally and this
# is not good. - baris
if not ctx.config.get_option('ignore_dependency'):
order_inst, order_build = plan_emerge(A)
need_build, order_build = plan_emerge(A)
else:
order_inst = []
need_build = []
order_build = A
if order_inst:
ctx.ui.info(_("""The following list of packages will be installed
from repository in the respective order to satisfy dependencies:
""") + util.strlist(order_inst))
ctx.ui.info(_("""The following list of packages will be built and
installed in the respective order to satisfy dependencies:
""") + util.strlist(order_build))
if need_build:
ctx.ui.info(_("""The following list of packages will be built:""")+"\n"
+ util.strlist(need_build) + util.strlist(order_build))
if ctx.get_option('dry_run'):
return
if len(order_inst) + len(order_build) > len(A_0):
if len(need_build) + len(order_build) > len(A_0):
if not ctx.ui.confirm(
_('There are extra packages due to dependencies. Would you like to continue?')):
return False
ctx.ui.notify(ui.packagestogo, order=order_inst)
ctx.ui.notify(ui.packagestogo, order=need_build)
# Dependency install from source repo (fully emerge)
sourcedb = inary.db.sourcedb.SourceDB()
inary.operations.emerge.emerge(sourcedb.get_source_names(order_inst))
inary.operations.emerge.emerge(need_build)
# Dependency install from binary repo (half emerge)
# TODO: Add half-emerge support from parameter
......@@ -93,7 +89,7 @@ installed in the respective order to satisfy dependencies:
# FIXME: take a look at the fixme above :(, we have to be sure
# that order_build is a known type...
U = set(order_build)
U.update(order_inst)
U.update(need_build)
def plan_emerge(A):
......@@ -129,7 +125,7 @@ def plan_emerge(A):
B = A
install_list = set()
need_build = set()
while len(B) > 0:
Bp = set()
for x in B:
......@@ -139,9 +135,19 @@ def plan_emerge(A):
# add dependencies
def find_build_dep(A):
for i in A:
if i in need_build:
return
else:
need_build.add(pkgtosrc(i))
src = get_spec(pkgtosrc(i)).source
find_build_dep(src.buildDependencies)
def process_dep(dep):
if not dep.satisfied_by_installed():
if dep.satisfied_by_repo():
# TODO: add half-emerge support
if sourcedb.get_pkg_src()[dep.package] or dep.satisfied_by_repo():
install_list.add(dep.package)
return
srcdep = pkgtosrc(dep.package)
......@@ -157,6 +163,8 @@ def plan_emerge(A):
order_build = G_f.topological_sort()
order_build.reverse()
order_inst = inary.operations.install.plan_install_pkg_names(install_list)
find_build_dep(install_list)
# TODO: add half-emerge bupport
# order_inst = inary.operations.install.plan_install_pkg_names(install_list)
return order_inst, order_build
return need_build, order_build
......@@ -137,7 +137,7 @@ def install_pkg_names(A, reinstall=False, extra=False):
for file in pkg.files.list:
sha = util.sha1_data(file.path)[0:5]
if sha not in install_files:
install_files[sha] = []
install_files[sha] = []
if file not in install_files[sha]:
install_files[sha].append(file)
else:
......
......@@ -712,7 +712,8 @@ class autoxml(oo.autosuper, oo.autoprop):
return value
else:
if req == mandatory:
raise Exception(_('Mandatory token {} not available.').format(token)+"\n {}".format(where))
raise Exception(_('Mandatory token {} not available.').format(
token)+"\n {}".format(where))
return None
def encode(node, value, errs):
......@@ -721,7 +722,9 @@ class autoxml(oo.autosuper, oo.autoprop):
writetext(node, token, str(value))
else:
if req == mandatory:
raise Exception(_('Mandatory token {} not available.').format(token)+"\n {}".format(value))
raise Exception(_('Mandatory token {} not available.').format(
token)+"\n {}".format(value))
def errors(value, where):
errs = []
if value and not isinstance(value, token_type):
......
......@@ -53,7 +53,6 @@ def locked(func):
"""
Decorator for synchronizing privileged functions
"""
def wrapper(*__args, **__kw):
try:
lock = open(join_path(ctx.config.lock_dir(), 'inary'), 'w')
......
......@@ -106,7 +106,8 @@ class BuildPo(build):
# FIXME: enable this block
for item in glob.glob1("po", "*.po"):
print("Updating .. ", item)
os.system("msgmerge --update --no-wrap --sort-by-file po/{0} po/{1}.pot".format(item, PROJECT))
os.system(
"msgmerge --update --no-wrap --sort-by-file po/{0} po/{1}.pot".format(item, PROJECT))
# Cleanup
os.unlink(files)
......
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