You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
3.8 KiB

4 years ago
#!/bin/bash
4 years ago
configureCMake() {
4 years ago
4 years ago
cmake -S "${productRepoPath}" -B "${productBuildPath}" \
-D CMAKE_BUILD_TYPE=Release \
-D SYNERGY_ENTERPRISE=ON \
4 years ago
-D SYNERGY_REVISION="${productRevision}" \
4 years ago
|| exit 1
4 years ago
4 years ago
}
4 years ago
4 years ago
buildBinaries() {
4 years ago
4 years ago
cmake --build "${productBuildPath}" --parallel || exit 1
4 years ago
4 years ago
}
4 years ago
4 years ago
buildAppImage() {
4 years ago
4 years ago
pushd "${toolsPath}" || exit 1
4 years ago
4 years ago
wget -O linuxdeploy -c "${linuxdeployURL}" || exit 1
chmod a+x linuxdeploy || exit 1
4 years ago
4 years ago
# Needed by linuxdeploy
export VERSION="${productVersion}-${productStage}"
4 years ago
4 years ago
appImagePath="${productBuildPath}/${productPackageName}.AppDir"
4 years ago
4 years ago
./linuxdeploy \
--appdir "${appImagePath}" \
--executable "${productBuildPath}/bin/synergy" \
--executable "${productBuildPath}/bin/synergyc" \
--executable "${productBuildPath}/bin/synergyd" \
--executable "${productBuildPath}/bin/synergys" \
--executable "${productBuildPath}/bin/syntool" \
--create-desktop-file \
--icon-file "${productRepoPath}/res/synergy.svg" \
--output appimage || exit 1
4 years ago
4 years ago
mv "${toolsPath}/"*.AppImage "${binariesPath}/${productPackageName}.AppImage"
4 years ago
4 years ago
popd
4 years ago
4 years ago
}
4 years ago
4 years ago
buildDeb() {
4 years ago
4 years ago
pushd "${productRepoPath}" || exit 1
4 years ago
4 years ago
if [ ! -f "./debian/changelog" ]; then
4 years ago
4 years ago
# Make the productName lowercase
packageName=$( echo "${productName}" | tr "[:upper:]" "[:lower:]" )
4 years ago
4 years ago
dch --create --controlmaint --distribution unstable \
--package "${packageName}" \
--newversion "${productVersion}" \
"Snapshot release." \
|| exit 1
4 years ago
4 years ago
fi
4 years ago
4 years ago
debuild \
--preserve-envvar SYNERGY_* \
--set-envvar CMAKE_BUILD_TYPE=Release \
--set-envvar SYNERGY_ENTERPRISE=ON \
--set-envvar DEB_BUILD_OPTIONS="parallel=8" \
-us -uc \
|| exit 1
4 years ago
4 years ago
git clean -fd
4 years ago
4 years ago
popd
4 years ago
4 years ago
mv "${productRepoPath}/../"*.deb "${binariesPath}/${productPackageName}.deb"
mv "${productRepoPath}/../synergy_${productVersion}"* "${productBuildPath}"
mv "${productRepoPath}/../synergy-dbgsym_${productVersion}"* "${productBuildPath}"
4 years ago
4 years ago
}
4 years ago
4 years ago
buildRPM() {
4 years ago
4 years ago
# rpmbuild is very flaky with paths containing spaces,
# so we set up a temporary build path and make sure no spaces
4 years ago
# are present in any paths.
temporaryPath=$( mktemp -d -t "${productPackageName}-XXXXXXXX" )
4 years ago
4 years ago
if [[ ! "${temporaryPath}" || ! -d "${temporaryPath}" ]]; then
print "error: Failed to create temporary path."
exit 1
fi
4 years ago
4 years ago
trap "{ rm -fR '${temporaryPath}'; }" EXIT
4 years ago
4 years ago
printf "Created temporary path:\n\t${temporaryPath}\n"
4 years ago
4 years ago
# We will symlink RPM build paths to our temporary location
4 years ago
# and we'll do work in there.
rpmToplevelPath="${temporaryPath}/rpm"
4 years ago
4 years ago
ln -s "${productBuildPath}/rpm" "${rpmToplevelPath}"
4 years ago
4 years ago
rpmBuildrootPath="${rpmToplevelPath}/BUILDROOT"
installPath="${rpmBuildrootPath}/usr"
4 years ago
4 years ago
if [[ ${rpmToplevelPath} = *" "* ]]; then
4 years ago
printf "error: RPM top-level path contained spaces:\n\t${rpmToplevelPath}\n"
exit 1
4 years ago
fi
4 years ago
4 years ago
# Reconfigure with new install path
4 years ago
cmake -S "${productRepoPath}" -B "${productBuildPath}" \
-D CMAKE_BUILD_TYPE=Release \
-D SYNERGY_ENTERPRISE=ON \
4 years ago
-D SYNERGY_REVISION="${productRevision}" \
4 years ago
-D CMAKE_INSTALL_PREFIX:PATH="${installPath}" \
|| exit 1
4 years ago
4 years ago
# Rebuild and deploy to install path
4 years ago
pushd "${productBuildPath}" || exit 1
4 years ago
4 years ago
make -j || exit 1
make install/strip || exit 1
4 years ago
4 years ago
popd
4 years ago
4 years ago
pushd "${rpmToplevelPath}" || exit 1
4 years ago
4 years ago
rpmbuild -bb \
--define "_topdir ${rpmToplevelPath}" \
--buildroot "${rpmBuildrootPath}" \
synergy.spec \
|| exit 1
4 years ago
4 years ago
mv "RPMS/x86_64/"*.rpm "${binariesPath}/${productPackageName}.rpm"
4 years ago
4 years ago
popd
4 years ago
}
4 years ago
4 years ago
set -o nounset
4 years ago
4 years ago
configureCMake
buildBinaries
buildAppImage
4 years ago
buildDeb
buildRPM
exit 0