overte/pkg-scripts/make-deb-server
2025-05-29 08:46:34 +02:00

96 lines
3.7 KiB
Bash
Executable File

#!/bin/sh
# Copyright 2020-2021 Vircadia contributors.
# Copyright 2022-2025 Overte e.V.
# SPDX-License-Identifier: Apache-2.0
if [ "$OVERTE" = "" ]; then
OVERTE=`realpath ..`
fi
sudo apt-get install chrpath binutils dh-make
DEB_BUILD_ROOT=temp-make-deb/overte-server_$DEBVERSION
if [ -d temp-make-deb ]; then
rm -r temp-make-deb
fi
mkdir -p $DEB_BUILD_ROOT
# copy the files over
cp $OVERTE/build/assignment-client/assignment-client $DEB_BUILD_ROOT
cp $OVERTE/build/domain-server/domain-server $DEB_BUILD_ROOT
cp $OVERTE/build/tools/oven/oven $DEB_BUILD_ROOT # Oven is required for pre-baking assets
cp $OVERTE/build/libraries/*/*.so $DEB_BUILD_ROOT
chrpath -d $DEB_BUILD_ROOT/*
# TODO: get Qt from Conan if building without system Qt
# Hack: Create libnode.so from libnode.so.108
# We don't fail on error, in case libnode is provided by the system already.
ln -s $OVERTE/build/conanlibs/Release/libnode.so.* $OVERTE/build/conanlibs/Release/libnode.so || True
cp $OVERTE/build/conanlibs/Release/*.so $DEB_BUILD_ROOT
strip --strip-all $DEB_BUILD_ROOT/*
cp $OVERTE/pkg-scripts/new-server $DEB_BUILD_ROOT
cp -a $OVERTE/domain-server/resources $DEB_BUILD_ROOT
find $DEB_BUILD_ROOT/resources -name ".gitignore" -delete
find $DEB_BUILD_ROOT/resources -type f -executable -exec sh -c 'chmod -x {}' \;
cp $OVERTE/README.md $DEB_BUILD_ROOT
cp -a $OVERTE/build/assignment-client/plugins $DEB_BUILD_ROOT
strip --strip-all $DEB_BUILD_ROOT/plugins/*.so
strip --strip-all $DEB_BUILD_ROOT/plugins/*/*.so
#begin the debian package construction
cd $DEB_BUILD_ROOT
dh_make -p overte-server_$DEBVERSION -c apache -s --createorig -y
cp $OVERTE/pkg-scripts/overte-assignment-client.service debian
cp $OVERTE/pkg-scripts/overte-assignment-client@.service debian
cp $OVERTE/pkg-scripts/overte-domain-server.service debian
cp $OVERTE/pkg-scripts/overte-domain-server@.service debian
cp $OVERTE/pkg-scripts/overte-server.target debian
cp $OVERTE/pkg-scripts/overte-server@.target debian
cp $OVERTE/pkg-scripts/server-compat debian/compat
cp $OVERTE/pkg-scripts/server-control debian/control
cp $OVERTE/pkg-scripts/server-prerm debian/prerm
cp $OVERTE/pkg-scripts/server-postinst debian/postinst
cp $OVERTE/pkg-scripts/server-postrm debian/postrm
cp $OVERTE/LICENSE debian/copyright
echo /etc/opt/overte > debian/dirs
echo /var/lib/overte >> debian/dirs
echo README.md > debian/docs
echo assignment-client opt/overte > debian/install
echo domain-server opt/overte >> debian/install
echo oven opt/overte >> debian/install
echo new-server opt/overte >> debian/install
for so in *.so*; do
echo $so opt/overte/lib >> debian/install
done
#for service in *.service; do
# echo $service opt/overte/systemd >> debian/install
#done
#for target in *.target; do
# echo $target opt/overte/systemd >> debian/install
#done
find resources -type f -exec sh -c 'echo {} opt/overte/$(dirname "{}") >> debian/install' \;
find plugins -type f -exec sh -c 'echo {} opt/overte/$(dirname "{}") >> debian/install' \;
# We look for *.so.*.*.* as well, in case Qt is there.
SOFILES=`ls *.so *.so.*.*.* | grep -Po '^(.+\.so(\.\d+)?)' | sed 's/\./\\\./g' | paste -d'|' -s`
# dpkg -S can only find packages which are already installed on the system.
DEPENDS=`find * -path debian -prune -o -type f -executable -exec sh -c 'objdump -p {} | grep NEEDED' \; \
| awk '{print $2}' | sort | uniq | egrep -v "^($SOFILES)$" \
| xargs -n 1 -I {} sh -c 'dpkg -S {} | head -n 1' | cut -d ':' -f 1 | sort | uniq | paste -d',' -s`
cp $OVERTE/pkg-scripts/server-rules debian/rules
sed "s/{DEPENDS}/$DEPENDS/" $OVERTE/pkg-scripts/server-control > debian/control
dpkg-buildpackage -us -uc
mv $OVERTE/pkg-scripts/temp-make-deb/*.deb $OVERTE/pkg-scripts/ # move package out of temp-make-deb