mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
build: convert the run script to use Python
This fits with the goal of eliminating non-Python scripting languages, and makes forthcoming changes far easier. Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
caaadd28a1
commit
d9dd94711d
45
run.in
45
run.in
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env python3
|
||||||
# libvirt 'run' programs locally script
|
# libvirt 'run' programs locally script
|
||||||
# Copyright (C) 2012-2013 Red Hat, Inc.
|
# Copyright (C) 2012-2021 Red Hat, Inc.
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
@ -40,35 +40,42 @@
|
|||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
# Function to intelligently prepend a path to an environment variable.
|
# Function to intelligently prepend a path to an environment variable.
|
||||||
# See https://stackoverflow.com/a/9631350
|
# See https://stackoverflow.com/a/9631350
|
||||||
prepend()
|
def prepend(env, varname, extradir):
|
||||||
{
|
if varname in os.environ:
|
||||||
eval $1="$2\${$1:+:\$$1}"
|
env[varname] = extradir + ":" + env[varname]
|
||||||
}
|
else:
|
||||||
|
env[varname] = extradir
|
||||||
|
|
||||||
# Find this script.
|
here = "@abs_builddir@"
|
||||||
b=@abs_builddir@
|
|
||||||
|
|
||||||
prepend LD_LIBRARY_PATH "$b/src"
|
if len(sys.argv) < 2:
|
||||||
export LD_LIBRARY_PATH
|
print("syntax: %s BINARY [ARGS...]" % sys.argv[0], file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
prepend PKG_CONFIG_PATH "$b/src"
|
prog = sys.argv[1]
|
||||||
export PKG_CONFIG_PATH
|
args = sys.argv[1:]
|
||||||
|
env = os.environ
|
||||||
|
|
||||||
prepend PATH "$b/tools"
|
|
||||||
export PATH
|
prepend(env, "LD_LIBRARY_PATH", os.path.join(here, "src"))
|
||||||
|
prepend(env, "PKG_CONFIG_PATH", os.path.join(here, "src"))
|
||||||
|
prepend(env, "PATH", os.path.join(here, "tools"))
|
||||||
|
|
||||||
# Ensure that any 3rd party apps using libvirt.so from the build tree get
|
# Ensure that any 3rd party apps using libvirt.so from the build tree get
|
||||||
# files resolved to the build/source tree too. Typically useful for language
|
# files resolved to the build/source tree too. Typically useful for language
|
||||||
# bindings running tests against non-installed libvirt.
|
# bindings running tests against non-installed libvirt.
|
||||||
LIBVIRT_DIR_OVERRIDE=1
|
env["LIBVIRT_DIR_OVERRIDE"] = "1"
|
||||||
export LIBVIRT_DIR_OVERRIDE
|
|
||||||
|
|
||||||
# This is a cheap way to find some use-after-free and uninitialized
|
# This is a cheap way to find some use-after-free and uninitialized
|
||||||
# read problems when using glibc.
|
# read problems when using glibc.
|
||||||
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
|
env["MALLOC_PERTURB_"] = "%d" % random.randint(1, 255)
|
||||||
export MALLOC_PERTURB_=$random_val
|
|
||||||
|
|
||||||
# Run the program.
|
# Run the program.
|
||||||
exec "$@"
|
os.execvpe(prog, args, env)
|
||||||
|
Loading…
Reference in New Issue
Block a user