Files
BloomPatched/build/packaging/rpm/package-rpm.sh.in
2023-01-18 00:38:18 +00:00

70 lines
2.5 KiB
Bash

#!/bin/bash
PLAYGROUND_DIR=@CMAKE_BINARY_DIR@/packaging/rpm/playground;
SPECS_DIR=${PLAYGROUND_DIR}/SPECS;
SOURCES_DIR=${PLAYGROUND_DIR}/SOURCES;
RELEASE_DIR_NAME=@BLOOM_PACKAGE_NAME_LOWER@-@CMAKE_PROJECT_VERSION@;
RELEASE_DIR=${PLAYGROUND_DIR}/${RELEASE_DIR_NAME};
BLOOM_INSTALLATION_PREFIX=/opt/bloom/
BLOOM_INSTALLATION_DIR=${RELEASE_DIR}/${BLOOM_INSTALLATION_PREFIX}
BLOOM_PACKAGE_PATH=@CMAKE_BINARY_DIR@/packaging/@BLOOM_PACKAGE_FILE_NAME@.rpm
if [ ! -f @CMAKE_BINARY_DIR@/bin/bloom ]; then
echo "Build files not found. Did you forget to build?"
exit 1;
fi
echo "Preparing playground directory...";
rm -fr ${PLAYGROUND_DIR};
mkdir -p ${PLAYGROUND_DIR};
mkdir -p ${SPECS_DIR};
mkdir -p ${SOURCES_DIR};
mkdir -p ${PLAYGROUND_DIR}/BUILD;
mkdir -p ${PLAYGROUND_DIR}/BUILDROOT;
mkdir -p ${PLAYGROUND_DIR}/RPMS;
mkdir -p ${PLAYGROUND_DIR}/SRPMS;
mkdir -p ${RELEASE_DIR};
mkdir -p ${BLOOM_INSTALLATION_DIR};
mkdir -p ${BLOOM_INSTALLATION_DIR}/bin;
mkdir -p ${RELEASE_DIR}/usr/lib/udev/rules.d/;
mkdir -p ${RELEASE_DIR}/usr/bin/;
echo "Copying RPM spec file...";
cp -a @CMAKE_BINARY_DIR@/packaging/rpm/bloom.spec ${SPECS_DIR}/;
echo "Copying Bloom binary...";
cp -a @CMAKE_BINARY_DIR@/bin/bloom ${BLOOM_INSTALLATION_DIR}/bin/;
echo "Copying resources...";
cp -a @CMAKE_BINARY_DIR@/resources ${BLOOM_INSTALLATION_DIR}/;
cp -a @CMAKE_CURRENT_SOURCE_DIR@/build/distributed/fonts ${BLOOM_INSTALLATION_DIR}/resources/;
echo "Copying distributed binaries...";
cp -a @CMAKE_CURRENT_SOURCE_DIR@/build/distributed/bin/lib ${BLOOM_INSTALLATION_DIR}/;
cp -a @CMAKE_CURRENT_SOURCE_DIR@/build/distributed/bin/plugins ${BLOOM_INSTALLATION_DIR}/;
echo "Copying udev rules...";
cp -a @CMAKE_CURRENT_SOURCE_DIR@/build/distributed/udevrules/99-bloom.rules ${RELEASE_DIR}/usr/lib/udev/rules.d/;
echo "Adjusting permissions...";
chmod u=rwx,g=rx,o=rx -R ${BLOOM_INSTALLATION_DIR}/bin/;
chmod u=rwx,g=rx,o=rx -R ${BLOOM_INSTALLATION_DIR}/lib/;
chmod u=rwx,g=rx,o=rx -R ${BLOOM_INSTALLATION_DIR}/plugins/;
chmod u=rwX,g=rX,o=rX -R ${BLOOM_INSTALLATION_DIR}/resources/;
chmod u=rw,g=r,o=r ${RELEASE_DIR}/usr/lib/udev/rules.d/99-bloom.rules;
echo "Creating symbolic link for Bloom binary..."
ln -s -f ${BLOOM_INSTALLATION_PREFIX}./bin/bloom ${RELEASE_DIR}/usr/bin/;
echo "Creating release tarball..."
tar -zcvf ${SOURCES_DIR}/@BLOOM_PACKAGE_NAME_LOWER@-@CMAKE_PROJECT_VERSION@.tar.gz -C ${PLAYGROUND_DIR} ./${RELEASE_DIR_NAME}
echo "Building RPM package...";
rpmbuild -bb ${SPECS_DIR}/bloom.spec;
mv -f ${PLAYGROUND_DIR}/RPMS/@BLOOM_PACKAGE_FILE_NAME@.rpm @CMAKE_BINARY_DIR@/packaging/;