libreoffice-online/loolwsd-systemplate-setup
Andras Timar 017f82a84d no error if systemplate dir is existing
Change-Id: I10aba648688ba92150efa41449190a3ba425f03c
Reviewed-on: https://gerrit.libreoffice.org/42663
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
2017-09-22 17:10:26 +02:00

91 lines
2.7 KiB
Bash
Executable file

#!/bin/bash
test $# -eq 2 || { echo "Usage: $0 <chroot template directory for system libs to create> <LO installation directory>"; exit 1; }
# No provision for spaces or other weird characters in pathnames. So sue me.
CHROOT=$1
INSTDIR=$2
test -d "$INSTDIR" || { echo "No such directory: $INSTDIR"; exit 1; }
mkdir -p $CHROOT || exit 1
CHROOT=`cd $CHROOT && /bin/pwd`
INSTDIR=`cd $INSTDIR && /bin/pwd`
cd / || exit 1
(
# Produce a list of file names, one per line, that will be copied
# into the template tree of system files for the chroot jails.
# First essential files and shared objects
find etc/passwd etc/group etc/hosts \
etc/resolv.conf \
lib/ld-* lib64/ld-* \
lib/libcap* lib64/libcap* lib/*-linux-gnu/libcap* \
lib/libattr* lib/*-linux-gnu/libattr* \
etc/ld.so.* \
lib/libnss_* lib64/libnss_* lib/*-linux-gnu/libnss*\
var/cache/fontconfig \
etc/fonts \
etc/localtime \
usr/lib/locale/en_US.utf8 \
usr/lib/locale/C.UTF-8 \
usr/lib/locale/locale_archive \
usr/share/zoneinfo/* \
usr/share/liblangtag \
usr/lib/libpng* usr/lib64/libpng* lib/*-linux-gnu/libpng* \
usr/lib/*-linux-gnu/liblcms2* \
-type f
find etc/fonts \
lib/ld-* lib64/ld-* \
lib/libnss_* lib64/libnss_* lib/*-linux-gnu/libnss*\
lib/libcap* lib64/libcap* lib/*-linux-gnu/libcap* \
lib/libattr* lib/*-linux-gnu/libattr* \
usr/lib/libpng* usr/lib64/libpng* lib/*-linux-gnu/libpng* \
usr/lib/*-linux-gnu/liblcms2* \
-type l
# Go through the LO shared objects and check what system libraries
# they link to.
find $INSTDIR -name '*.so' -o -name '*.so.[0-9]*' -o -name 'xpdfimport' |
while read file; do
ldd $file 2>/dev/null
done |
grep -v dynamic | cut -d " " -f 3 | grep -E '^(/lib|/usr)' | sort -u | sed -e 's,^/,,'
) |
# Can't use -l because then symlinks won't be handled well enough.
# This will now copy the file a symlink points to, but whatever.
cpio -p -d -L $CHROOT
mkdir -p $CHROOT/tmp
# /usr/share/fonts needs to be taken care of separately because the
# directory time stamps must be preserved for fontconfig to trust
# its cache.
cd $CHROOT || exit 1
mkdir -p usr/share || exit 1
cp -r -p -L /usr/share/fonts usr/share
if [ -h usr/share/fonts/ghostscript ]; then
mkdir usr/share/ghostscript || exit 1
cp -r -p -L /usr/share/ghostscript/fonts usr/share/ghostscript
fi
# Debugging only hackery to avoid confusion.
if test "z$ENABLE_DEBUG" != "z" -a "z$HOME" != "z"; then
echo "Copying development users's fonts into systemplate"
mkdir -p $CHROOT/$HOME
mkdir -p $CHROOT/$HOME/docs
test -d $HOME/.fonts && cp -r -p -L $HOME/.fonts $CHROOT/$HOME
test -d $HOME/docs && cp -r -p -L $HOME/docs $CHROOT/$HOME
fi
exit 0