musikcube/script/archive-standalone-nix.sh

132 lines
3.2 KiB
Bash
Raw Normal View History

2022-02-10 08:19:54 +00:00
#!/bin/bash
2022-02-16 00:55:28 +00:00
# set -x
2022-02-10 08:19:54 +00:00
VERSION=$1
if [[ -z "$VERSION" ]]; then
2022-02-10 08:19:54 +00:00
echo "usage: archive-nix.sh <version>"
exit
fi
OS=$(uname)
JOBS="-j8"
FRIENDLY_OS_NAME="linux"
if [[ $OS == "Darwin" ]]; then
FRIENDLY_OS_NAME="macos"
JOBS="-j$(sysctl -n hw.ncpu)"
fi
2022-02-10 08:19:54 +00:00
ARCH=$(uname -m)
DEB_ARCH=$ARCH
VENDOR=$ARCH
if [[ -n $CROSSCOMPILE ]]; then
2022-12-25 22:00:11 +00:00
FRIENDLY_OS_NAME="linux_${CROSSCOMPILE}"
VENDOR=${CROSSCOMPILE}
2022-12-25 22:00:11 +00:00
ARCH="armhf"
DEB_ARCH="armhf"
elif [[ $ARCH == "x86_64" ]]; then
DEB_ARCH="amd64"
fi
OS_ARCH="${FRIENDLY_OS_NAME}_${ARCH}"
OUTNAME="musikcube_${OS_ARCH}_$VERSION"
OUTDIR="dist/$VERSION/$OUTNAME"
2022-02-10 08:19:54 +00:00
SCRIPTDIR=`dirname "$0"`
CMAKE_TOOLCHAIN=""
2022-02-10 08:19:54 +00:00
DLL_EXT="so"
if [[ $OS == "Darwin" ]]; then
2022-02-10 08:19:54 +00:00
DLL_EXT="dylib"
fi
OS_SPECIFIC_BUILD_FLAGS=""
if [[ $OS == "Linux" ]]; then
OS_SPECIFIC_BUILD_FLAGS="-DGENERATE_DEB=true -DDEB_ARCHITECTURE=${DEB_ARCH} -DCMAKE_INSTALL_PREFIX=/usr"
if [[ $CROSSCOMPILE == "rpi" ]]; then
# for now we don't support pipewire when cross compiling...
OS_SPECIFIC_BUILD_FLAGS="$OS_SPECIFIC_BUILD_FLAGS -DENABLE_PIPEWIRE=false"
fi
2022-02-10 08:19:54 +00:00
fi
if [[ $CROSSCOMPILE == "rpi" ]]; then
CMAKE_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=.cmake/RaspberryPiToolchain.cmake"
fi
rm vendor
ln -s ../vendor-$VENDOR/ ./vendor
printf "\nsetup symlink:\n"
ls -ald vendor
2022-02-10 08:33:41 +00:00
printf "\n"
read -p 'clean and rebuild [y]? ' CLEAN
2022-02-10 08:33:41 +00:00
if [[ $CLEAN == 'n' || $CLEAN == 'N' ]]; then
printf "\n\n\n ***** SKIPPING REBUILD *****\n\n\n"
2022-02-13 05:30:33 +00:00
./script/stage-vendor-libraries.sh || exit $?
sleep 3
2022-02-10 08:33:41 +00:00
else
printf "\n\n\n ***** REBUILDING NOW *****\n\n\n"
sleep 3
2022-02-10 08:33:41 +00:00
${SCRIPTDIR}/clean-nix.sh
rm -rf bin/ 2> /dev/null
2022-02-11 04:08:26 +00:00
./script/stage-vendor-libraries.sh || exit $?
2022-02-17 18:57:24 +00:00
cmake ${CMAKE_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release -DBUILD_STANDALONE=true -DENABLE_PCH=true ${OS_SPECIFIC_BUILD_FLAGS} . || exit $?
make ${JOBS} || exit $?
2022-02-10 08:33:41 +00:00
fi
2022-02-10 08:19:54 +00:00
2022-12-14 05:07:07 +00:00
./script/patch-rpath.sh || exit $?
rm -rf dist/$VERSION/*${OS_ARCH}_$VERSION* 2> /dev/null
2022-02-10 08:19:54 +00:00
mkdir -p $OUTDIR/lib
mkdir -p $OUTDIR/plugins
mkdir -p $OUTDIR/locales
mkdir -p $OUTDIR/themes
2022-02-14 06:45:17 +00:00
mkdir -p $OUTDIR/share/terminfo
2022-02-10 08:19:54 +00:00
cp bin/musikcube $OUTDIR
cp bin/musikcubed $OUTDIR
cp bin/libmusikcore.${DLL_EXT} $OUTDIR
cp bin/lib/* $OUTDIR/lib
cp bin/plugins/*.${DLL_EXT} $OUTDIR/plugins
cp bin/locales/*.json $OUTDIR/locales
cp bin/themes/*.json $OUTDIR/themes
2022-02-14 06:45:17 +00:00
cp -rfp bin/share/terminfo/* $OUTDIR/share/terminfo/
2022-02-10 08:19:54 +00:00
if [[ $CROSSCOMPILE == "rpi" ]]; then
printf "\n\n\n ***** CROSSCOMPILE DETECTED, **NOT** SCANNING DEPENDENCIES! *****\n\n\n"
sleep 1
else
printf "\n\n\n ***** SCANNING DEPENDENCIES *****\n\n\n"
sleep 1
node ./script/scan-standalone dist/$VERSION/$OUTNAME || exit $?
fi
2022-02-10 08:19:54 +00:00
strip $OUTDIR/musikcube
strip $OUTDIR/musikcubed
strip $OUTDIR/libmusikcore.${DLL_EXT}
strip $OUTDIR/lib/*
strip $OUTDIR/libmusikcore.${DLL_EXT}
strip $OUTDIR/plugins/*.${DLL_EXT}
cd dist/$VERSION/
2022-02-10 08:19:54 +00:00
tar cvf $OUTNAME.tar $OUTNAME
bzip2 $OUTNAME.tar
cd ../../
if [[ $OS == "Linux" ]]; then
# hack so the pre-install script doesn't re-run, clobbering binaries that
# have had their rpaths updated and symbols stripped.
# https://stackoverflow.com/a/57531164
perl -i.bak -0pe "s|Unix Makefiles|Ninja|" CPackConfig.cmake
cpack
mv *.deb dist/$VERSION/
2022-02-16 02:41:43 +00:00
mv *.rpm dist/$VERSION/
fi
2022-02-10 08:39:29 +00:00
printf "\n\n\n ***** DONE *****\n\n\n"
ls -al dist/$VERSION
2022-02-10 08:39:29 +00:00
printf "\n\n"