File mdtopdf.spec of Package mdtopdf
%define realname mdtopdf
%define realver 1.2.0
%define srcext tar.gz
# Common info
Name: %{realname}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: MIT
Group: Productivity/Publishing/PDF
URL: https://github.com/mandolyte/mdtopdf
Summary: Markdown to PDF converter
# Build-time parameters
BuildRequires: go >= 1.18
BuildRoot: %{_tmppath}/%{name}-root
Source0: https://codeload.github.com/mandolyte/mdtopdf/%{srcext}/refs/tags/v%{realver}#/%{realname}-%{version}%{?extraver}.%{srcext}
# go mod vendor -v && tar -Jcvf ../vendor.tar.xz vendor
Source11: vendor.tar.xz
# Papper size and orientation support
Patch1: page-orientation-size.patch
%description
Markdown to PDF converter
Supported Markdown
The supported elements of markdown are:
* Emphasized and strong text
* Headings 1-6
* Ordered and unordered lists
* Nested lists
* Images
* Tables (but see limitations below)
* Links
* Code blocks and backticked text
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a11
%patch1 -p1
# Build step (compile/build binaries, documentation, etc)
%build
export GOCACHE=$(pwd -P)/.gocache
export GOTRACEBACK=crash
export CGO_ENABLED=1
# Build static assets
go build \
-v \
-mod=vendor \
-buildmode=pie \
-gcflags=all='-dwarf=false' \
-ldflags=all='-s -w' \
-o bin/mdtopdf \
./cmd/convert.go
# Install built stuff
%install
%{__install} -D -m0755 bin/mdtopdf %{buildroot}%{_bindir}/mdtopdf
# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
# Files list
%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_bindir}/mdtopdf
%changelog