Skip to content

Commit d8ad7b3

Browse files
committed
Update rpm/deb
1 parent 0299ee2 commit d8ad7b3

6 files changed

Lines changed: 102 additions & 86 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,27 @@ endif()
9494

9595
# QT
9696

97-
option(BUILD_WITH_QT5 "Build with Qt 5")
98-
option(BUILD_WITH_QT6 "Build with Qt 6")
99-
100-
if (NOT BUILD_WITH_QT5 AND NOT BUILD_WITH_QT6)
101-
set(BUILD_WITH_QT5 ON)
97+
if(NOT QT_DEFAULT_MAJOR_VERSION)
98+
set(QT_DEFAULT_MAJOR_VERSION 5)
10299
endif()
100+
set(QT_MAJOR_VERSION ${QT_DEFAULT_MAJOR_VERSION} CACHE STRING "Qt version to use (5 or 6), defaults to ${QT_DEFAULT_MAJOR_VERSION}")
101+
102+
option(BUILD_WITH_QT5 "Use Qt 5" OFF)
103+
option(BUILD_WITH_QT6 "Use Qt 6" OFF)
103104

104105
if(BUILD_WITH_QT5)
105106
set(QT_MAJOR_VERSION 5)
106107
elseif(BUILD_WITH_QT6)
107108
set(QT_MAJOR_VERSION 6)
108109
else()
109-
message(FATAL_ERROR "You need to set either BUILD_WITH_QT5 or BUILD_WITH_QT6.")
110+
if(QT_MAJOR_VERSION EQUAL 5)
111+
set(BUILD_WITH_QT5 ON)
112+
elseif(QT_MAJOR_VERSION EQUAL 6)
113+
set(BUILD_WITH_QT6 ON)
114+
else()
115+
set(BUILD_WITH_QT5 ON)
116+
set(QT_MAJOR_VERSION 5)
117+
endif()
110118
endif()
111119

112120
set(QT_COMPONENTS Core Concurrent Widgets Network Sql)

cmake/Deb.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ if (LSB_RELEASE_EXEC AND DPKG_BUILDPACKAGE)
99
OUTPUT_STRIP_TRAILING_WHITESPACE
1010
)
1111

12-
if (DEB_CODENAME)
13-
configure_file(${CMAKE_SOURCE_DIR}/debian/changelog.in ${CMAKE_SOURCE_DIR}/debian/changelog)
12+
if (DEB_CODENAME AND DEB_DATE)
1413
add_custom_target(deb
1514
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1615
COMMAND ${DPKG_BUILDPACKAGE} -b -d -uc -us

cmake/ParseArguments.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# From http://www.cmake.org/Wiki/CMakeMacroParseArguments
22

3-
cmake_minimum_required(VERSION 2.6)
4-
53
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
64
SET(DEFAULT_ARGS)
75
FOREACH(arg_name ${arg_names})

cmake/Rpm.cmake

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,47 @@ if (LSB_RELEASE_EXEC AND RPMBUILD_EXEC)
1717
OUTPUT_STRIP_TRAILING_WHITESPACE
1818
)
1919
if (DIST_NAME)
20+
2021
message(STATUS "Distro Name: ${DIST_NAME}")
2122
if (DIST_RELEASE)
2223
message(STATUS "Distro Release: ${DIST_RELEASE}")
2324
endif()
2425
if (DIST_VERSION)
2526
message(STATUS "Distro Version: ${DIST_VERSION}")
2627
endif()
28+
2729
set(RPMBUILD_DIR ~/rpmbuild CACHE STRING "Rpmbuild directory, for the rpm target")
28-
if (${DIST_NAME} STREQUAL "opensuse")
29-
if (DIST_RELEASE)
30-
if (${DIST_RELEASE} STREQUAL "leap")
31-
if (DIST_VERSION)
32-
set(RPM_DISTRO "lp${DIST_VERSION}" CACHE STRING "Suffix of the rpm file")
33-
else()
34-
set(RPM_DISTRO ${DIST_RELEASE} CACHE STRING "Suffix of the rpm file")
35-
endif()
36-
elseif (${DIST_RELEASE} STREQUAL "tumbleweed")
37-
set(RPM_DISTRO ${DIST_RELEASE} CACHE STRING "Suffix of the rpm file")
38-
else ()
39-
set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file")
30+
31+
if (${DIST_NAME} STREQUAL "opensuse" AND DIST_RELEASE)
32+
if (${DIST_RELEASE} STREQUAL "leap")
33+
if (DIST_VERSION)
34+
set(RPM_DISTRO "lp${DIST_VERSION}")
35+
else()
36+
set(RPM_DISTRO ${DIST_RELEASE})
4037
endif()
41-
else()
42-
set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file")
38+
elseif (${DIST_RELEASE} STREQUAL "tumbleweed")
39+
set(RPM_DISTRO ${DIST_RELEASE})
4340
endif()
44-
elseif (${DIST_NAME} STREQUAL "fedora")
45-
if (DIST_VERSION)
46-
set(RPM_DISTRO "fc${DIST_VERSION}" CACHE STRING "Suffix of the rpm file")
47-
else ()
48-
set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file")
49-
endif()
50-
elseif (${DIST_NAME} STREQUAL "mageia")
51-
if (DIST_RELEASE)
52-
set(RPM_DISTRO "mga${DIST_RELEASE}" CACHE STRING "Suffix of the rpm file")
53-
else ()
54-
set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file")
55-
endif()
56-
else()
57-
set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file")
41+
elseif (${DIST_NAME} STREQUAL "fedora" AND DIST_VERSION)
42+
set(RPM_DISTRO "fc${DIST_VERSION}")
43+
elseif (${DIST_NAME} STREQUAL "centos" AND DIST_VERSION)
44+
set(RPM_DISTRO "el${DIST_VERSION}")
45+
elseif (${DIST_NAME} STREQUAL "mageia" AND DIST_RELEASE)
46+
set(RPM_DISTRO "mga${DIST_RELEASE}")
5847
endif()
48+
49+
if(NOT RPM_DISTRO)
50+
set(RPM_DISTRO ${DIST_NAME})
51+
endif()
52+
5953
message(STATUS "RPM Suffix: ${RPM_DISTRO}")
60-
configure_file(${CMAKE_SOURCE_DIR}/dist/unix/sqlrestore.spec.in ${CMAKE_SOURCE_DIR}/dist/unix/sqlrestore.spec @ONLY)
54+
6155
add_custom_target(rpm
6256
COMMAND ${CMAKE_SOURCE_DIR}/dist/scripts/maketarball.sh
6357
COMMAND ${CMAKE_COMMAND} -E copy sqlrestore-${SQLRESTORE_VERSION_PACKAGE}.tar.xz ${RPMBUILD_DIR}/SOURCES/
64-
COMMAND ${RPMBUILD_EXEC} -bs ${CMAKE_SOURCE_DIR}/dist/unix/sqlrestore.spec
65-
COMMAND ${RPMBUILD_EXEC} -bb ${CMAKE_SOURCE_DIR}/dist/unix/sqlrestore.spec
58+
COMMAND ${RPMBUILD_EXEC} -ba ${CMAKE_SOURCE_DIR}/dist/unix/sqlrestore.spec
6659
)
60+
6761
endif()
62+
6863
endif()

dist/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
execute_process(COMMAND env LC_ALL="en_US.utf8" date "+%a %b %d %Y" OUTPUT_VARIABLE RPM_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
2-
execute_process(COMMAND env LC_ALL=C date "+%a, %-d %b %Y %H:%M:%S %z" OUTPUT_VARIABLE DEB_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
3-
41
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/maketarball.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/scripts/maketarball.sh @ONLY)
2+
if(RPM_DISTRO AND RPM_DATE)
3+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/unix/sqlrestore.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/unix/sqlrestore.spec @ONLY)
4+
endif(RPM_DISTRO AND RPM_DATE)
5+
if(DEB_CODENAME AND DEB_DATE)
6+
configure_file(${CMAKE_SOURCE_DIR}/debian/changelog.in ${CMAKE_SOURCE_DIR}/debian/changelog)
7+
endif(DEB_CODENAME AND DEB_DATE)
8+
9+
if(WIN32)
10+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/windows/sqlrestore.nsi.in ${CMAKE_CURRENT_SOURCE_DIR}/windows/sqlrestore.nsi @ONLY)
11+
endif(WIN32)
512

6-
if (UNIX AND NOT APPLE)
13+
if(UNIX AND NOT APPLE)
714
install(FILES unix/sqlrestore.desktop DESTINATION share/applications)
815
install(FILES ../data/icons/48x48/backup.png DESTINATION share/icons/hicolor/48x48/apps RENAME sqlrestore.png)
916
install(FILES ../data/icons/64x64/backup.png DESTINATION share/icons/hicolor/64x64/apps RENAME sqlrestore.png)
1017
install(FILES ../data/icons/128x128/backup.png DESTINATION share/icons/hicolor/128x128/apps RENAME sqlrestore.png)
11-
endif (UNIX AND NOT APPLE)
18+
endif(UNIX AND NOT APPLE)
1219

13-
if (WIN32)
20+
if(WIN32)
1421
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/windows/sqlrestore.nsi.in ${CMAKE_CURRENT_SOURCE_DIR}/windows/sqlrestore.nsi @ONLY)
1522
endif()

dist/unix/sqlrestore.spec.in

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Group: Productivity/Databases/Tools
66
License: GPL-3.0+
77
URL: https://github.com/jonaski/sqlrestore
88
Source0: %{name}-@SQLRESTORE_VERSION_PACKAGE@.tar.xz
9-
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
109

1110
%if 0%{?suse_version} && 0%{?is_opensuse}
1211
BuildRequires: libboost_headers-devel
@@ -32,41 +31,56 @@ BuildRequires: libappstream-glib
3231
BuildRequires: appstream-util
3332
%endif
3433
%endif
35-
%if 0%{?suse_version} || 0%{?fedora_version} || 0%{?mageia}
36-
BuildRequires: cmake(Qt5LinguistTools)
37-
%endif
3834
BuildRequires: pkgconfig
3935
BuildRequires: pkgconfig(glib-2.0)
4036
BuildRequires: pkgconfig(gio-2.0)
4137
BuildRequires: pkgconfig(gio-unix-2.0)
4238
BuildRequires: pkgconfig(gthread-2.0)
4339
BuildRequires: pkgconfig(zlib)
44-
BuildRequires: pkgconfig(Qt5Core)
45-
BuildRequires: pkgconfig(Qt5Gui)
46-
BuildRequires: pkgconfig(Qt5Widgets)
47-
BuildRequires: pkgconfig(Qt5Concurrent)
48-
BuildRequires: pkgconfig(Qt5Network)
49-
BuildRequires: pkgconfig(Qt5Sql)
50-
BuildRequires: pkgconfig(Qt5Test)
40+
41+
%if "@QT_MAJOR_VERSION@" == "5" && ( 0%{?fedora} || 0%{?rhel_version} || 0%{?centos} )
42+
BuildRequires: pkgconfig(Qt@QT_MAJOR_VERSION@Core)
43+
BuildRequires: pkgconfig(Qt@QT_MAJOR_VERSION@Gui)
44+
BuildRequires: pkgconfig(Qt@QT_MAJOR_VERSION@Widgets)
45+
BuildRequires: pkgconfig(Qt@QT_MAJOR_VERSION@Concurrent)
46+
BuildRequires: pkgconfig(Qt@QT_MAJOR_VERSION@Network)
47+
BuildRequires: pkgconfig(Qt@QT_MAJOR_VERSION@Sql)
48+
%else
49+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Core)
50+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Gui)
51+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Widgets)
52+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Concurrent)
53+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Network)
54+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Sql)
55+
BuildRequires: cmake(Qt@QT_MAJOR_VERSION@Core5Compat)
56+
%endif
5157

5258
BuildRequires: file-devel
5359

5460
%if 0%{?fedora} || (0%{?suse_version} && 0%{?sle_version} < 150200)
61+
%if "@QT_MAJOR_VERSION@" == "5"
5562
BuildRequires: quazip-qt5-devel
63+
%else
64+
BuildRequires: quazip-qt6-devel
65+
%endif
5666
%else
57-
%if 0%{?mageia}
58-
%ifarch x86_64
67+
%if 0%{?mageia}
68+
%ifarch x86_64
5969
BuildRequires: lib64quazip-devel
60-
%else
70+
%else
6171
BuildRequires: libquazip-devel
62-
%endif
63-
%else
72+
%endif
73+
%else
6474
BuildRequires: quazip-devel
65-
%endif
75+
%endif
6676
%endif
6777

6878
%if 0%{?suse_version}
79+
%if "@QT_MAJOR_VERSION@" == "5"
6980
Requires: libQt5Sql5-unixODBC
81+
%else
82+
Requires: qt6-sql-unixODBC
83+
%endif
7084
%endif
7185

7286
%description
@@ -84,38 +98,33 @@ Features:
8498
- Works on Linux, macOS and Windows.
8599
- Compatible with MSSQL 2008 R2 to SQL 2019 server on Linux and Windows.
86100

101+
%if 0%{?suse_version}
102+
%debug_package
103+
%endif
104+
87105
%prep
88106
%setup -qn %{name}-@SQLRESTORE_VERSION_PACKAGE@
89107

90108
%build
91-
%if 0%{?suse_version} || 0%{?mageia}
92-
%{cmake} ..
93-
%else
94-
mkdir -p %{_target_platform}
95-
pushd %{_target_platform}
96-
%{cmake} ..
97-
popd
109+
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos}
110+
export CXXFLAGS="-fPIC $RPM_OPT_FLAGS"
98111
%endif
99-
100-
%if 0%{?suse_version} || 0%{?mageia}
101-
%if 0%{?suse_version} && 0%{?suse_version} < 1500
102-
make %{?_smp_mflags}
103-
%else
104-
%make_build
105-
%endif
112+
%{cmake} -DCMAKE_BUILD_TYPE:STRING=Release -DQT_MAJOR_VERSION=@QT_MAJOR_VERSION@
113+
%if 0%{?centos} || (0%{?mageia} && 0%{?mageia} <= 7)
114+
%make_build
106115
%else
107-
%make_build -C %{_target_platform}
116+
%cmake_build
108117
%endif
109118

110119
%install
111-
%if 0%{?suse_version}
112-
%cmake_install
120+
%if 0%{?centos}
121+
%make_install
113122
%else
114-
%if 0%{?mageia}
115-
%make_install -C build
116-
%else
117-
%make_install -C %{_target_platform}
118-
%endif
123+
%if 0%{?mageia}
124+
%make_install -C build
125+
%else
126+
%cmake_install
127+
%endif
119128
%endif
120129

121130
%if 0%{?suse_version}

0 commit comments

Comments
 (0)