rework fixenv-nonstd-libdir script
the script won't create another file (run-nonroot previously) and instead carry out environment setup itself for the binary links pointing at it - it's more readable and smaller this way rework mips32r2.py file copy def - may be useful in other files, eventually transport this functionality to base.py (!?) later on, after this branch is merged to master
This commit is contained in:
parent
615e994d22
commit
26e6b81924
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
BASENAME=`basename $0`
|
||||||
|
SCRIPT=`realpath $0`
|
||||||
|
SCRIPTPATH=`dirname $SCRIPT`
|
||||||
|
|
||||||
|
if ! test -L "$0"
|
||||||
|
then
|
||||||
|
cd "$SCRIPTPATH" && find -type f | grep -v ".real$" | \
|
||||||
|
while read b
|
||||||
|
do
|
||||||
|
if hexdump -C "$b" | head -1 | grep -q ELF
|
||||||
|
then
|
||||||
|
mv -iv "$b" "$b.real"
|
||||||
|
ln -s "$BASENAME" "$b"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for fullarch in "" mips-linux-uclibc
|
||||||
|
do for libdir in usr/lib lib
|
||||||
|
do LD_LIBRARY_PATH="${SCRIPTPATH%/bin}/$libdir/$fullarch:$LD_LIBRARY_PATH"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH
|
||||||
|
exec ${SCRIPTPATH}/$BASENAME.real "$@"
|
||||||
|
fi
|
|
@ -1,39 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if ! test -f kiwix-serve
|
|
||||||
then
|
|
||||||
echo Needs to run in the same directory that hosts kiwix-serve binary.
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
find -type f | \
|
|
||||||
while read
|
|
||||||
do
|
|
||||||
if hexdump -C $REPLY | head -1 | grep -q ELF
|
|
||||||
then
|
|
||||||
mv -iv "$REPLY" "$REPLY.real"
|
|
||||||
ln -s run-nonroot "$REPLY"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
cat <<'EOF' > run-nonroot
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
BASENAME=`basename $0`
|
|
||||||
SCRIPT=`realpath $0`
|
|
||||||
SCRIPTPATH=`dirname $SCRIPT`
|
|
||||||
|
|
||||||
if test x"$BASENAME" != xrun-nonroot
|
|
||||||
then
|
|
||||||
for fullarch in "" ${ARCH_FULL:-mips-linux-gnu}
|
|
||||||
do for libdir in usr/lib lib
|
|
||||||
do LD_LIBRARY_PATH="${SCRIPTPATH%/bin}/$libdir/$fullarch:$LD_LIBRARY_PATH"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
export LD_LIBRARY_PATH
|
|
||||||
exec ${SCRIPTPATH}/$BASENAME.real "$@"
|
|
||||||
fi
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x run-nonroot
|
|
|
@ -2,19 +2,28 @@ from .base import PlatformInfo, _SCRIPT_DIR
|
||||||
|
|
||||||
from kiwixbuild.utils import pj
|
from kiwixbuild.utils import pj
|
||||||
from kiwixbuild._global import get_target_step
|
from kiwixbuild._global import get_target_step
|
||||||
from re import sub as sed
|
|
||||||
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from os import makedirs, chmod, readlink, symlink
|
from os import makedirs, chmod, readlink, symlink
|
||||||
from os.path import basename, islink
|
from os.path import basename, islink
|
||||||
|
from re import sub as subst
|
||||||
from shutil import copy2
|
from shutil import copy2
|
||||||
|
|
||||||
def copy(src, dst):
|
def copy(src, dst, search=None, repl=None, mode=None):
|
||||||
if islink(src):
|
if islink(src):
|
||||||
linkto = readlink(src)
|
linkto = readlink(src)
|
||||||
symlink(linkto, dst)
|
symlink(linkto, dst)
|
||||||
else:
|
else:
|
||||||
copy2(src,dst)
|
if search is None:
|
||||||
|
copy2(src, dst)
|
||||||
|
else:
|
||||||
|
with open(src, "r") as sources:
|
||||||
|
lines = sources.readlines()
|
||||||
|
with open(dst, "w") as sources:
|
||||||
|
for line in lines:
|
||||||
|
sources.write(subst(search, repl, line))
|
||||||
|
if mode is not None:
|
||||||
|
chmod(dst, mode)
|
||||||
|
|
||||||
|
|
||||||
class MIPS32R2PlatformInfo(PlatformInfo):
|
class MIPS32R2PlatformInfo(PlatformInfo):
|
||||||
|
@ -115,7 +124,7 @@ class MIPS32R2Static(MIPS32R2PlatformInfo):
|
||||||
|
|
||||||
|
|
||||||
class MIPS32R2_UC_GCXXPlatformInfo(MIPS32R2PlatformInfo):
|
class MIPS32R2_UC_GCXXPlatformInfo(MIPS32R2PlatformInfo):
|
||||||
build = 'mips32r2_uclibc_gclibcxx' # "shared, heterogeneous"
|
build = 'mips32r2_uclibc_glibcxx' # "shared, heterogeneous"
|
||||||
arch_full = 'mips-linux-uclibc'
|
arch_full = 'mips-linux-uclibc'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -140,12 +149,11 @@ class MIPS32R2_UC_GCXXDyn(MIPS32R2_UC_GCXXPlatformInfo):
|
||||||
d = pj(_SCRIPT_DIR, '..', '..', 'BUILD_'+self.name, 'INSTALL')
|
d = pj(_SCRIPT_DIR, '..', '..', 'BUILD_'+self.name, 'INSTALL')
|
||||||
|
|
||||||
makedirs(pj(d, 'bin'), mode=0o755, exist_ok=True)
|
makedirs(pj(d, 'bin'), mode=0o755, exist_ok=True)
|
||||||
with open(pj(_SCRIPT_DIR, '..', 'patches', 'fixenv-nonstd-libdir.sh'), "r") as sources:
|
copy(pj(_SCRIPT_DIR, '..', 'patches', 'fixenv-nonstd-libdir'),
|
||||||
lines = sources.readlines()
|
pj(d, 'bin', 'fixenv-nonstd-libdir'),
|
||||||
with open(pj(d, 'bin', 'fixenv-nonstd-libdir'), "w") as sources:
|
search=r'\$\{ARCH_FULL[^}]*\}',
|
||||||
for line in lines:
|
repl=self.arch_full,
|
||||||
sources.write(sed(r'\$\{ARCH_FULL[^}]*\}', self.arch_full, line))
|
mode=0o755)
|
||||||
chmod(pj(d, 'bin', 'fixenv-nonstd-libdir'), 0o755)
|
|
||||||
|
|
||||||
d = pj(d, 'lib', self.arch_full)
|
d = pj(d, 'lib', self.arch_full)
|
||||||
makedirs(d, mode=0o755, exist_ok=True)
|
makedirs(d, mode=0o755, exist_ok=True)
|
||||||
|
|
Loading…
Reference in New Issue