Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation of RPM package builder. #4525

Merged
merged 2 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,17 @@ if( UNIX AND NOT APPLE )
COMMAND ${CMAKE_COMMAND} -E echo ${CMAKE_SOURCE_DIR}/installer_linux/make_deb.sh "${SURGE_PRODUCT_DIR}" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/${SURGE_XT_DIST_OUTPUT_DIR}" "${SXTVER}"
COMMAND ${CMAKE_SOURCE_DIR}/scripts/installer_linux/make_deb.sh "${SURGE_PRODUCT_DIR}" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/${SURGE_XT_DIST_OUTPUT_DIR}" "${SXTVER}"
)

add_custom_target(surge-xt-rpm)
add_dependencies(surge-xt-rpm surge-staged-assets)

add_custom_command(TARGET surge-xt-rpm
POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${SURGE_XT_DIST_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E echo ${CMAKE_SOURCE_DIR}/installer_linux/make_rpm.sh "${SURGE_PRODUCT_DIR}" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/${SURGE_XT_DIST_OUTPUT_DIR}" "${SXTVER}"
COMMAND ${CMAKE_SOURCE_DIR}/scripts/installer_linux/make_rpm.sh "${SURGE_PRODUCT_DIR}" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/${SURGE_XT_DIST_OUTPUT_DIR}" "${SXTVER}"
)
endif()

if( WIN32 )
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ You will also need to install a set of dependencies:
- libxcb-cursor-dev
- libxcb-keysyms1-dev
- libxcb-util-dev
- libxrander-dev

# Continuous Integration

Expand Down
16 changes: 11 additions & 5 deletions scripts/installer_linux/make_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ gzip -9 -n ${PACKAGE_NAME}/usr/share/${SURGE_NAME}/doc/changelog.Debian
cp ${SOURCEDIR}/LICENSE ${PACKAGE_NAME}/usr/share/${SURGE_NAME}/doc/copyright
cp -r ${SOURCEDIR}/resources/data/* ${PACKAGE_NAME}/usr/share/${SURGE_NAME}/

# Copy the VST3 bundld
# Copy the VST3 bundle
cp -r "${INDIR}/Surge XT.vst3" ${PACKAGE_NAME}/usr/lib/vst3/
cp -r "${INDIR}/Surge XT Effects.vst3" ${PACKAGE_NAME}/usr/lib/vst3/
cp -r "${INDIR}/Surge XT" ${PACKAGE_NAME}/usr/bin/
Expand All @@ -83,15 +83,21 @@ cp -r "${INDIR}/Surge XT Effects" ${PACKAGE_NAME}/usr/bin/
# cp -r ../build/surge_products/Surge.lv2 ${PACKAGE_NAME}/usr/lib/lv2/

# set permissions on shared libraries
find ${PACKAGE_NAME}/usr/lib/vst3/ -type f -iname "*.so" | xargs chmod 0644
gnac marked this conversation as resolved.
Show resolved Hide resolved
# find ${PACKAGE_NAME}/usr/lib/lv2/ -type f -iname "*.so" | xargs chmod 0644
find ${PACKAGE_NAME}/usr/lib/vst3/ -type f -iname "*.so" -exec chmod 0644 {} +
# find ${PACKAGE_NAME}/usr/lib/lv2/ -type f -iname "*.so" -exec chmod 0644 {} +

echo "----- LIBRARY CONTENTS (except resource) -----"
find ${PACKAGE_NAME}/usr/lib -print

# build package

# build deb package
dpkg-deb --verbose --build ${PACKAGE_NAME} ${TARGET_DIR}/${PACKAGE_NAME}-linux-x64-${VERSION}.deb

# create a tarball of the {PACKAGE_NAME}/usr contents.
pushd ${PACKAGE_NAME}/usr
tar -czf ${TARGET_DIR}/${PACKAGE_NAME}-linux-x64-${VERSION}.tar.gz *
popd


rm -rf ${PACKAGE_NAME}
popd

158 changes: 158 additions & 0 deletions scripts/installer_linux/make_rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/bin/bash
#
# create a Surge XT RPM package.
# see the RPM Packaging guide at https://rpm-packaging-guide.github.io/


# check to ensure rpm build tool exists
if ! [[ -x "$(command -v rpmbuild)" ]]
then
echo "rpmbuild not found! Please install rpm build tools"
exit -1
fi

# parameter check
if [[ "$#" -ne 4 ]]; then
echo "ERROR: make_rpm.sh requires 4 parameters."
echo
echo " make_rpm.sh INDIR SOURCEDIR TARGET_DIR VERSION"
echo
echo " INDIR Location of Intermediate build artifacts"
echo " SOURCEDIR Location of source code / license file"
echo " TARGET_DIR where to put the output"
echo " VERSION build/rpm version"
echo
exit -1
fi

# Intermediate build artifacts
INDIR=$1
# license file location
SOURCEDIR=$2
# where to put the output
TARGET_DIR=$3
# Build version
VERSION=$4

echo running make_rpm.sh $INDIR $SOURCEDIR $TARGET_DIR $VERSION


# generate/modify version
if [[ ${VERSION:0:1} =~ [0-9] ]]; then
echo "Build Version (${VERSION})"
elif [[ ${VERSION} = NIGHTLY* ]]; then
VERSION="9.${VERSION}"
echo "NIGHTLY; VERSION is ${VERSION}"
else
VERSION="0.${VERSION}"
echo "VERSION is ${VERSION}"
fi

# TODO Do we want to parameterize this?
RPM_RELEASE=1
ARCH=$(uname -i)

# create and enter temporary build package directory.
mkdir -p ./installer-tmp
pushd ./installer-tmp

# Name of Package
PACKAGE_NAME=surge-xt

# Date in RFC formate for the Changelog
DATE_RFC=`date --rfc-email`
# Date in Day-of-Week Month Day Year format for the rpm config header.
DATE_RPM=`date`
MSG=`git log -n 1 --pretty="%s (git hash %H)"`

# generate changelog to put in install package
touch changelog.txt
cat <<EOT > changelog.txt
${PACKAGE_NAME} (${VERSION}) stable; urgency=medium

* ${MSG}
* For more details see https://github.com/surge-synthesizer/surge

-- Surge Synthesizer Team <[email protected]> ${DATE_RFC}
EOT


# build rpm spec file
RPM_SPEC_FILE=${PACKAGE_NAME}.spec

touch ${RPM_SPEC_FILE}
cat << EOT > ${RPM_SPEC_FILE}
Name: ${PACKAGE_NAME}
Version: $VERSION
Release: ${RPM_RELEASE}
BuildArch: ${ARCH}
Summary: Subtractive hybrid synthesizer virtual instrument
License: GPLv3+
URL: https://surge-synthesizer.github.io/
Source: https://github.com/surge-synthesizer/surge
Provides: vst-plugin
Group: sound


%description
Subtractive hybrid synthesizer virtual instrument.
Surge XT includes VST3 instrument formats for use in compatible hosts and a standalone executable


%install
install -m 0755 -d %{buildroot}%{_bindir}/
install -m 0755 -d %{buildroot}%{_datadir}/
install -m 0755 -d %{buildroot}%{_defaultdocdir}/
install -m 0755 -d %{buildroot}%{_libdir}/vst3/
install -m 0755 -d %{buildroot}%{_datarootdir}
install -m 0755 -d %{buildroot}%{_datarootdir}/surge-xt/
install -m 0755 -d %{buildroot}%{_datarootdir}/surge-xt/doc
install -m 0644 ${SOURCEDIR}/LICENSE %{buildroot}%{_datarootdir}/surge-xt/doc/copyright
install -m 0644 $(pwd)/changelog.txt %{buildroot}%{_datarootdir}/surge-xt/doc/changelog.txt

cp -r ${SOURCEDIR}/resources/data/* %{buildroot}%{_datarootdir}/surge-xt/
cp -r "${INDIR}/Surge XT.vst3" %{buildroot}%{_libdir}/vst3/
cp -r "${INDIR}/Surge XT Effects.vst3" %{buildroot}%{_libdir}/vst3/

# install executable files as executable
install -m 0755 "${INDIR}/Surge XT" %{buildroot}/%{_bindir}
install -m 0755 "${INDIR}/Surge XT Effects" %{buildroot}/%{_bindir}

# set permissions on shared libraries
find %{buildroot}%{_libdir}/vst3/ -type f -iname "*.so" -exec chmod 0644 {} +


%files
%{_bindir}
%{_libdir}/vst3/
%{_datarootdir}/surge-xt/


%changelog
* ${DATE_RPM} Surge Synthesizer Team <[email protected]> - ${VERSION}
- Initial SurgeXT package
- ${MSG} ${DATE_RFC}
- For more details see https://github.com/surge-synthesizer/surge

EOT

# create the folders to build the rpm
RPM_BUILD_DIR=$(pwd)/rpmbuild
mkdir -p $RPM_BUILD_DIR/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

# build rpm package
rpmbuild -bb --define "_topdir $RPM_BUILD_DIR" ${RPM_SPEC_FILE}

# TODO add key signing, or sign as a post build step

# move rpm to target directory
mv $RPM_BUILD_DIR/RPMS/$ARCH/$PACKAGE_NAME-$VERSION-$RPM_RELEASE.$ARCH.rpm ${TARGET_DIR}/

if [[ $? -ne 0 ]]
then
echo ERROR moving rpm file, RPMBUILD Failed!
popd
exit -1
fi

popd