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

RPM package #111

scx opened this Issue Feb 16, 2019 · 1 comment


None yet
1 participant
Copy link

commented Feb 16, 2019

I created RPM packages for EL (7) and Fedora (28, 29, 30).
I hope it will be useful for someone.


Build instruction

RPM SPEC (nasc.spec):


%define app_id com.github.parnold_x.nasc
%define app_id_old com.github.parnold-x.nasc

%define dir_appdata metainfo

%if 0%{?rhel} && 0%{?rhel} <= 7
  %define dir_appdata appdata

%if 0%{!?_metainfodir:1}
  %define _metainfodir %{_datadir}/%{dir_appdata}

%define dir_metainfo %( echo "%{_metainfodir}" | xargs -I{} basename '{}' )

%{!?_licensedir:%global license %doc}

%define buildsystem_meson 1

%if 0%{?buildsystem_meson}
%{!?_vpath_srcdir:%global _vpath_srcdir .}
%{!?_vpath_builddir:%global _vpath_builddir %{_target_platform}}
%{!?__global_cflags:%global __global_cflags  %{optflags}}
%{!?__global_cxxflags:%global __global_cxxflags  %{optflags}}
%{!?__global_fflags:%global __global_fflags  %{optflags} -I%_fmoddir}
%{!?__global_fcflags:%global __global_fcflags %{optflags} -I%_fmoddir}
%{!?__global_ldflags:%global __global_ldflags -Wl,-z,relro %{_hardened_ldflags}}
%{!?__meson_wrap_mod:%global __meson_wrap_mode default}

Name:           nasc
Version:        0.5.1
Release:        12%{?dist}
License:        GPL-3.0
Group:          Applications/Engineering
Summary:        Do maths like a normal person


# Application patches
# Use get_user_data_dir() instead of hardcoded path
Patch0:         nasc-0.5.1-sheet_path.patch
# Enhance desktop file: update Categories, change GenericName, add StartupWMClass and StartupNotify
Patch1:         nasc-0.5.1-desktop.patch
# Enhance AppData file: fix release notes, add screenshot captions and kudos
Patch2:         nasc-0.5.1-appdata.patch

# CMake patches
# PATCH-FIX-UPSTREAM link.patch -- Build app with 'Wl,--no-undefined' and static library
Patch10:        nasc-0.5.1-link.patch
# The --thread option is now deprecated
# Should be ignored, but actually it leads to a build failure
# Fixes builds on FC >= 28 and EL >= 8
Patch11:        nasc-0.5.1-vala-thread.patch
# Reorganize CMake spec
# Move com.github.parnold-x.nasc.gschema.xml to data subdirectory
# Rename src/config.vala.cmake to src/ 
Patch12:        nasc-0.5.1-cmake.patch

# Meson patches
# Based on: Port to Meson
# Add cln dependency to libqalculatenasc
# Fixes builds on FC < 28 and EL < 8
Patch20:        nasc-0.5.1-meson-optional.patch

# Change Application ID
# sed_exp='s!com\.github\.parnold-x\.nasc!com.github.parnold_x.nasc!g'; find * -xtype f \( -name '*.vala' -o -name 'com.github.parnold-x.nasc.*' -o -name 'CMakeLists.txt' -o -name '' \) | xargs -I{} sed -i -re "${sed_exp}" '{}'; find * -xtype f -name 'com.github.parnold-x.nasc.*' | while read -r file; do d="$( dirname "${file}" )"; f="$( basename "${file}" )"; g="$( sed -re "${sed_exp}" <<< "${f}" )"; git mv "${d}/${f}" "${d}/${g}"; done; desktop-file-edit --set-key='X-Flatpak-RenamedFrom' --set-value='nasc.desktop;com.github.parnold-x.nasc.desktop;' data/*.desktop;
Patch30:        nasc-0.5.1-change-id.patch

%if ! 0%{?buildsystem_meson}
BuildRequires:  cmake
BuildRequires:  meson
%if 0%{?rhel} && 0%{?rhel} < 8
BuildRequires:  python34-devel
BuildRequires:  python36-devel
BuildRequires:  python3-devel
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  vala >= 0.28.0
BuildRequires:  pkgconfig(cln)
BuildRequires:  pkgconfig(gee-0.8)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(granite)
BuildRequires:  pkgconfig(gthread-2.0)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(gtksourceview-3.0)
BuildRequires:  pkgconfig(libqalculate)
BuildRequires:  pkgconfig(libsoup-2.4)
Requires:       qalculate

Provides:       %{app_id} = %{?epoch:%{epoch}:}%{version}-%{release}
%if "%{?_isa}" != ""
Provides:       %{app_id}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%if "%{app_id}" != "%{app_id_old}"
Provides:       %{app_id_old} = %{?epoch:%{epoch}:}%{version}-%{release}
%if "%{?_isa}" != ""
Provides:       %{app_id_old}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}

Requires(post):         coreutils
Requires(postun):       coreutils
Requires(posttrans):    coreutils
# gtk-update-icon-cache
#Requires(post):         gtk-update-icon-cache
Requires(postun):       gtk-update-icon-cache
Requires(posttrans):    gtk-update-icon-cache
# update-mime-database
#Requires(post):         shared-mime-info
#Requires(postun):       shared-mime-info
#Requires(posttrans):    shared-mime-info
# update-desktop-database
Requires(post):         desktop-file-utils
Requires(postun):       desktop-file-utils
#Requires(posttrans):    desktop-file-utils
# glib-compile-schemas
#Requires(post):         glib2
Requires(postun):       glib2
Requires(posttrans):    glib2
# ldconfig
#Requires(post):         glibc /sbin/ldconfig
#Requires(postun):       glibc /sbin/ldconfig
#Requires(posttrans):    glibc /sbin/ldconfig

This is an application where you do calculations "like a normal
person". It lets you type whatever you want, smartly figures out what
computations are needed, and outputs an answer on the right pane.
Then you can plug those answers in to future equations and if that
answer changes, so does the equations it is used in.

%setup -q

%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch20 -p1
%if "%{app_id}" != "%{app_id_old}"
%patch30 -p1

%if 0%{?rhel} && 0%{?rhel} < 8
export CFLAGS="%{optflags} -std=c++11"
export CXXFLAGS="%{optflags} -std=c++11"

%if ! 0%{?buildsystem_meson}
%cmake \
  #-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined"

%if ! 0%{?buildsystem_meson}
%make_install INSTALL_ROOT="%{buildroot}"

%if "%{dir_metainfo}" != "metainfo"
[[ -d "%{buildroot}%{_metainfodir}" || ! -d "%{buildroot}%{_datadir}/metainfo" ]] || %{__mv} "%{buildroot}%{_datadir}/metainfo" "%{buildroot}%{_metainfodir}"

%if "%{app_id}" != "%{app_id_old}"
%{__ln_s} "%{app_id}" "%{buildroot}%{_bindir}/%{app_id_old}" || :

%{__ln_s} "%{app_id}" "%{buildroot}%{_bindir}/%{name}" || :

/usr/bin/desktop-file-validate "%{buildroot}/%{_datadir}/applications/%{app_id}.desktop"

/usr/bin/appstream-util validate-relax --nonet "%{buildroot}%{_metainfodir}/%{app_id}.appdata.xml" || :

/bin/touch --no-create "%{_datadir}/icons/hicolor" &> /dev/null || :
#/usr/bin/update-mime-database -n "%{_datadir}/mime" &>/dev/null || :
/usr/bin/update-desktop-database &> /dev/null || :

if [[ "${1}" -eq "0" ]]; then
  /usr/bin/glib-compile-schemas "%{_datadir}/glib-2.0/schemas" &> /dev/null || :
/usr/bin/update-desktop-database &> /dev/null || :
if [[ "${1}" -eq "0" ]]; then
  /bin/touch --no-create "%{_datadir}/icons/hicolor" &> /dev/null || :
  /usr/bin/gtk-update-icon-cache "%{_datadir}/icons/hicolor" &> /dev/null || :
  #/usr/bin/update-mime-database -n "%{_datadir}/mime" &>/dev/null || :

/usr/bin/glib-compile-schemas "%{_datadir}/glib-2.0/schemas" &> /dev/null || :
/usr/bin/gtk-update-icon-cache "%{_datadir}/icons/hicolor" &> /dev/null || :
#update-mime-database -n "%{_datadir}/mime" &>/dev/null || :

%license COPYING
%if "%{app_id}" != "%{app_id_old}"

Patches (nasc-*.patch):


cp nasc-*.patch ~/rpmbuild/SOURCES/
rpmbuild -ba nasc.spec


rpmbuild --rebuild nasc-*.src.rpm

You can use mock as well.


This comment has been minimized.

Copy link
Contributor Author

commented Feb 16, 2019

See also: Flatpak package

@scx scx referenced this issue Feb 16, 2019


port to meson #98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.