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

Open
scx opened this Issue Feb 16, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@scx
Copy link
Contributor

commented Feb 16, 2019

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

Repos

https://copr.fedorainfracloud.org/coprs/scx/nasc

Build instruction

RPM SPEC (nasc.spec):

https://paste.ubuntu.com/p/vDJY3cxyCx

code

%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
%endif

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

%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}
%endif

Name:           nasc
Version:        0.5.1
Release:        12%{?dist}
License:        GPL-3.0
Group:          Applications/Engineering
URL:            https://parnold-x.github.io/nasc
Summary:        Do maths like a normal person

Source0:        https://github.com/parnold-x/nasc/archive/%{version}/%{name}-%{version}.tar.gz

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

# CMake patches
# PATCH-FIX-UPSTREAM link.patch -- Build app with 'Wl,--no-undefined' and static library
# https://build.opensuse.org/package/view_file/openSUSE:Factory/nasc/nasc-0.5.0-link.patch?expand=1
# https://github.com/scx/nasc/commit/bebce8e7ea33e4479498796346e32afaf0318739
Patch10:        nasc-0.5.1-link.patch
# The --thread option is now deprecated
# Should be ignored, but actually it leads to a build failure
# https://github.com/GNOME/vala/blob/f7c386eae4a1ab15eb4a21dce540e6298d93436c/compiler/valacompiler.vala#L131
# Fixes builds on FC >= 28 and EL >= 8
# https://github.com/scx/nasc/commit/fdf40fa6828af6fffb5976f43c8f331eac8eafe7
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/config.vala.in 
# https://github.com/scx/nasc/commit/19412dcdf1a9e868566f8030324b1ab903ca0a34
Patch12:        nasc-0.5.1-cmake.patch

# Meson patches
# Based on: Port to Meson
# https://github.com/parnold-x/nasc/pull/98
# Add cln dependency to libqalculatenasc
# Fixes builds on FC < 28 and EL < 8
# https://github.com/scx/nasc/commit/989bff9a4cff609d98e564e33e1016762633ffde
Patch20:        nasc-0.5.1-meson-optional.patch

# Change Application ID
# https://github.com/parnold-x/nasc/issues/101
# https://github.com/parnold-x/nasc/issues/67
# https://github.com/elementary/houston/issues/566
# 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 'meson.build' \) | 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;
# https://github.com/scx/nasc/commit/f0142da2ce18e92ed976afcc30712508d946727e
Patch30:        nasc-0.5.1-change-id.patch

%if ! 0%{?buildsystem_meson}
BuildRequires:  cmake
%else
BuildRequires:  meson
%if 0%{?rhel} && 0%{?rhel} < 8
BuildRequires:  python34-devel
BuildRequires:  python36-devel
%else
BuildRequires:  python3-devel
%endif
%endif
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}
%endif
%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}
%endif
%endif

# https://fedoraproject.org/wiki/Packaging:Scriptlets
# https://fedoraproject.org/wiki/PackagingDrafts/ScriptletSnippets
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


%description
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.


%prep
%setup -q

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


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

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

%install
%if ! 0%{?buildsystem_meson}
%make_install INSTALL_ROOT="%{buildroot}"
%else
%meson_install
%endif

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

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

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


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

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


%post
/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 || :
#/sbin/ldconfig


%postun
if [[ "${1}" -eq "0" ]]; then
  /usr/bin/glib-compile-schemas "%{_datadir}/glib-2.0/schemas" &> /dev/null || :
fi
/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 || :
fi
#/sbin/ldconfig


%posttrans
/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 || :


%files
%doc AUTHORS README.md
%license COPYING
%{_bindir}/%{app_id}
%if "%{app_id}" != "%{app_id_old}"
%{_bindir}/%{app_id_old}
%endif
%{_bindir}/%{name}
%{_datadir}/applications/%{app_id}.desktop
%{_datadir}/glib-2.0/schemas/%{app_id}.gschema.xml
%{_datadir}/icons/hicolor/*/apps/%{app_id}.??g
%{_metainfodir}/%{app_id}.appdata.xml
%{_datadir}/qalculate/styles/*

Patches (nasc-*.patch):

https://github.com/scx/nasc-flatpak/tree/64b3ac2b031b7cfa9d6d7dffe298fad4b0bbfbab

Build

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

or:

rpmbuild --rebuild nasc-*.src.rpm

You can use mock as well.

@scx

This comment has been minimized.

Copy link
Contributor Author

commented Feb 16, 2019

See also: Flatpak package
#105

@scx scx referenced this issue Feb 16, 2019

Closed

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.