Merge pull request #29 from Enlik/large-qa-env

[entropy.client,conf] avoid "Argument list too long"
This commit is contained in:
Fabio Erculiani
2016-08-30 20:16:23 +02:00
committed by GitHub
2 changed files with 31 additions and 18 deletions

31
conf/packages/packages.server.qa.exec.example Normal file → Executable file
View File

@@ -7,8 +7,9 @@
#
# It is used by Entropy Server QA routines to perform package metadata
# validation.
# Metadata is export in environmental variables form, and include:
# Metadata is exported as environmental variables and stdin.
#
# Metadata from environment:
# REPOSITORY_ID = repository identifier
# PKG_ID = package identifier
# PKG_ATOM = package atom
@@ -32,13 +33,17 @@
# PKG_SIZE = package size, in bytes
# PKG_REVISION = package entropy revision
# PKG_DEPS = list (\n separated) of package dependencies and conflicts
# PKG_NEEDED_LIBS = list (\n separated) of SONAMES required by package,
# including ELF class, so each item will look like this:
# <soname>|<elfclass>
# PKG_PROVIDED_LIBS = list (\n separated) of SONAMES provided by package,
# note: elf class and path are also provided,
# so each item will look like this:
# <soname>|<path of soname>|<elfclass>
# Metadata on stdin (more can be added in the future, so it's advisable
# to ignore entries well formed but with unknown prefix):
# PKG_NEEDED_LIB:
# SONAME required by package (one per line), including ELF class,
# so each line will look like this:
# PKG_NEEDED_LIB|<soname>|<elfclass>
# PKG_PROVIDED_LIB:
# SONAME provided by package (one per line), note: elf class
# and path are also provided, so each line will look like this:
# PKG_PROVIDED_LIB|<soname>|<path of soname>|<elfclass>
#
# The executable must return 0 for success, 1 for warning, 2 for critical error
@@ -67,8 +72,12 @@ echo "PKG_DATE = ${PKG_DATE}"
echo "PKG_SIZE = ${PKG_SIZE}"
echo "PKG_REVISION = ${PKG_REVISION}"
echo "PKG_DEPS = ${PKG_DEPS}"
echo "PKG_NEEDED_LIBS = ${PKG_NEEDED_LIBS}"
echo "PKG_PROVIDED_LIBS = ${PKG_PROVIDED_LIBS}"
stdin=$(cat)
echo "PKG_NEEDED_LIB = "
echo "${stdin}" | sed -n 's/^PKG_NEEDED_LIB|//p'
echo "PKG_PROVIDED_LIB = "
echo "${stdin}" | sed -n 's/^PKG_PROVIDED_LIB|//p'
echo
exit 0
exit 0

View File

@@ -6664,18 +6664,22 @@ class Server(Client):
env['PKG_SIZE'] = str(pkg_size)
env['PKG_REVISION'] = str(pkg_rev)
env['PKG_DEPS'] = str("\n".join(pkg_deps))
env['PKG_NEEDED_LIBS'] = str("\n".join(
["%s|%s|%s|%s|%s" % (a, b, x, y, c) for a, b, x, y, c in
pkg_needed]))
env['PKG_PROVIDED_LIBS'] = str("\n".join(
["%s|%s|%s" % (x, y, z) for x, y, z in \
pkg_provided_libs]))
# These two are not exposed in environment because they can be large;
# avoid "Argument list too long."
stdin_lines = []
stdin_lines += ["PKG_NEEDED_LIB|%s|%s|%s|%s|%s" % (a, b, x, y, c) \
for a, b, x, y, c in pkg_needed]
stdin_lines += ["PKG_PROVIDED_LIB|%s|%s|%s" % (x, y, z) \
for x, y, z in pkg_provided_libs]
stdin = const_convert_to_rawstring("\n".join(stdin_lines))
# now call the script
try:
proc = subprocess.Popen(
[qa_exec], stdout = sys.stdout, stderr = sys.stderr,
stdin = sys.stdin, env = env)
stdin = subprocess.PIPE, env = env)
proc.communicate(input=stdin)
rc = proc.wait()
except OSError as err:
self.output(