build-system: initial spec file for Fedora copr build

This should allow us to automate builds using the Fedora infrastructure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2022-05-11 17:44:27 -07:00
parent df5c715afa
commit 8ead205c8c
2 changed files with 206 additions and 0 deletions

View file

@ -0,0 +1,81 @@
#!/bin/bash -e
# start from the directory above the subsurface directory
#
# we need to build the google maps plugin which is not part of our sources, so let's make sure
# it is included in our source tar file
#
# a lot of this is redundant with the OBS code - but I'm trying to make both of these scripts reasonably
# complete so a user could simply run one of them and not the other - well, of course a user would have
# to make changes as they can't write to the OBS/COPR repos that I own... but this should be a great
# starting point.
if [[ $(pwd | grep "subsurface$") || ! -d subsurface || ! -d subsurface/libdivecomputer ]] ; then
echo "Please start this script from the folder ABOVE the subsurface source directory"
exit 1;
fi
if [[ ! -d googlemaps ]] ; then
echo "Please make sure you have the current master of https://github.com/Subsurface/googlemaps"
echo "checked out in parallel to the Subsurface directory"
exit 1;
fi
# ensure that the libdivecomputer module is there and current
cd subsurface
git submodule init
git submodule update
cd -
GITVERSION=$(cd subsurface ; git describe --abbrev=12 | sed -e 's/-g.*$// ; s/^v//')
GITREVISION=$(echo $GITVERSION | sed -e 's/.*-// ; s/.*\..*//')
VERSION=$(echo $GITVERSION | sed -e 's/-/./')
GITDATE=$(cd subsurface ; git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%d)
LIBDCREVISION=$(cd subsurface/libdivecomputer ; git rev-parse --verify HEAD)
FOLDER="subsurface-$VERSION"
echo "building Subsurface" $VERSION "with libdivecomputer" $LIBDCREVISION
# we put all of the files into the distrobuilds directory in order not to clutter the 'src' directory
mkdir -p distrobuilds
cd distrobuilds
if [[ ! -d $FOLDER ]]; then
mkdir $FOLDER
echo "copying sources"
(cd ../subsurface ; tar cf - . ) | (cd $FOLDER ; tar xf - )
cd $FOLDER
cp -a ../../googlemaps .
rm -rf .git libdivecomputer/.git googlemaps/.git build build-mobile libdivecomputer/build googlemaps/build
echo $GITVERSION > .gitversion
echo $GITDATE > .gitdate
echo $LIBDCREVISION > libdivecomputer/revision
cd ..
fi
if [[ ! -f rpmbuild/SOURCES/subsurface-$VERSION.orig.tar.xz ]] ; then
tar ch $FOLDER | xz > rpmbuild/SOURCES/subsurface-$VERSION.orig.tar.xz
fi
# if the user wanted to post this automatically, do so
#
# because in the normal flow we should never have the need to rev the Release number in the spec
# file, this is hard coded to 1 - it's entirely possible that there will be use cases where we
# need to push additional versions... but it seems impossible to predict what exactly would drive
# those and how to automate them
if [[ "$1" = "post" ]] ; then
# daily vs. release
if [[ "$GITREVISION" == "" ]] ; then
# this is a release
echo "RELEASE PROCESS IS NOT WELL TESTED"
REPO="Subsurface"
DESCRIPTION="This is the official Subsurface build, including our own custom libdivecomputer."
else
REPO="Subsurface-test"
DESCRIPTION="This is a test build of Subsurface, provided by the Subsurface team, based on the latest sources. Only use if you need the bleeding edge of development."
fi
cd rpmbuild
cat ../../subsurface/packaging/copr/subsurface.spec | sed "s/%define latestVersion.*/%define latestVersion $VERSION/;s/DESCRIPTION/$DESCRIPTION/" > SPECS/subsurface.spec
rpmbuild --verbose -bs $(pwd)/SPECS/subsurface.spec
copr build $REPO $(pwd)/SRPMS/subsurface-$VERSION-1.fc*.src.rpm
fi

View file

@ -0,0 +1,125 @@
#
# Fedora COPR spec file for package subsurface
#
# Copyright (c) 2014-2022 Dirk Hohndel
#
%define latestVersion 0.0.0.0
Name: subsurface
Version: %latestVersion
Release: 1%{?dist}
Summary: A test build of the latest development version of Subsurface
License: GPL v2
Url: http://subsurface-divelog.org
Source: subsurface-%latestVersion.orig.tar.xz
Group: Productivity/Other
BuildRequires: desktop-file-utils
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: make
BuildRequires: asciidoc
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: cmake
BuildRequires: libzip-devel
BuildRequires: libxml2-devel
BuildRequires: libxslt-devel
BuildRequires: libssh2-devel
BuildRequires: libcurl-devel
BuildRequires: libgit2-devel
BuildRequires: libmtp-devel
BuildRequires: netpbm-devel
BuildRequires: openssl-devel
BuildRequires: libsqlite3x-devel
BuildRequires: libusbx-devel
BuildRequires: bluez-libs-devel
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qttools-devel
BuildRequires: qt5-qtwebkit-devel
BuildRequires: qt5-qtsvg-devel
BuildRequires: qt5-qtscript-devel
BuildRequires: qt5-qtdeclarative-devel
BuildRequires: qt5-qtbase-mysql
BuildRequires: qt5-qtbase-postgresql
BuildRequires: qt5-qtbase-ibase
BuildRequires: qt5-qtbase-odbc
BuildRequires: qt5-qtbase-tds
BuildRequires: qt5-qtconnectivity-devel
BuildRequires: qt5-qtlocation-devel
BuildRequires: libappstream-glib
Recommends: qt5-qttranslations
%description
DESCRIPTION
%prep
%setup -q
%build
# we need to temporarily install the output of our two included dependency in order to use those
# when building Subsurface - yes, this is ugly. But since we have private versions of these two
# libraries, this is the most reasonable approach...
mkdir -p install-root
(cd libdivecomputer ; \
autoreconf --install ; \
CFLAGS="-fPIC -g -O2" ./configure --prefix=%{_builddir}/install-root --bindir=%{_builddir}/install-root/bin --libdir=%{_builddir}/install-root/lib --includedir=%{_builddir}/install-root/include --disable-examples ; \
make %{?_smp_mflags} ; \
make install)
( cd googlemaps ; mkdir -p build ; cd build ; \
qmake-qt5 ../googlemaps.pro ; \
# on Fedora 36 and newer we get the package_notes that break the build - let's rip them out
sed -i 's/-Wl[^ ]*package_note[^ ]* //g' Makefile
make -j4 ; \
make install_target INSTALL_ROOT=%{_builddir}/install-root )
%cmake -DCMAKE_BUILD_TYPE=Release \
-DMAKE_TESTS=OFF \
-DLRELEASE=lrelease-qt5 \
-DLIBDIVECOMPUTER_INCLUDE_DIR=%{_builddir}/install-root/include \
-DLIBGIT2_INCLUDE_DIR=%{_builddir}/install-root/include \
-DLIBDIVECOMPUTER_LIBRARIES=%{_builddir}/install-root/lib/libdivecomputer.a \
-DNO_PRINTING=OFF \
.
%cmake_build
%install
mkdir -p %{buildroot}/%{_libdir}
( cd googlemaps/build ; make install_target INSTALL_ROOT=%{buildroot} )
%cmake_install
install subsurface.debug %{buildroot}%{_bindir}
install appdata/subsurface.appdata.xml %{buildroot}%{_datadir}/metainfo
desktop-file-install --dir=%{buildroot}/%{_datadir}/applications subsurface.desktop
%fdupes %{buildroot}
%post
%desktop_database_post
/sbin/ldconfig
%postun
%desktop_database_post
/sbin/ldconfig
%files
%defattr(-,root,root)
%doc gpl-2.0.txt README.md ReleaseNotes/ReleaseNotes.txt
%{_bindir}/subsurface*
%{_libdir}/qt5/plugins/geoservices/libqtgeoservices_googlemaps.so
%{_datadir}/applications/subsurface.desktop
%dir %{_datadir}/metainfo
%{_datadir}/metainfo/subsurface.appdata.xml
%{_datadir}/icons/hicolor/*/apps/subsurface-icon.*
%{_datadir}/subsurface/
%changelog