Skip to content

Package Manuskript for Linux with rpm

Curtis Gedak edited this page Jul 28, 2018 · 4 revisions

SUMMARY

This guide describes the steps for packaging Manuskript for Linux using rpm. The resulting .rpm package runs on both 32-bit and 64-bit Fedora based GNU/Linux distributions.

CONSIDERATIONS

This document is heavily based on the steps found in this stackoverflow.com post.

I chose Debian 8 Jessie as the build platform because I also use this to Package Manuskript for Linux with dpkg.

In an effort to reduce duplication of effort, I chose to use the above built .deb package as a base starting point.

PREPARATION

Install tools needed to build package.

sudo update
sudo apt install rpm

CREATE RPM PACKAGE

  1. Create the rpm tree structure.

    mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SRPMS,SPECS,tmp}
    mkdir -p ~/rpmbuild/RPMS/noarch
    
  2. Define rpm macros.

    cat <<EOF >~/.rpmmacros
    %_topdir   %(echo $HOME)/rpmbuild
    %_tmppath  %{_topdir}/tmp
    EOF
    
  3. Change into rpmbuild directory.

    cd ~/rpmbuild
    
  4. Create tarball using deb package.
    Using deb package means we don't need to recreate /usr/bin/manuskript and /usr/share/application/manuskript.desktop files.

    mkdir manuskript-0.5.0
    dpkg -x /path-to/manuskript-0.5.0-1.deb manuskript-0.5.0
    # Clean up unneeded source files
    rm manuskript-0.5.0/usr/share/manuskript/{.codeclimate.yml,.gitignore,.travis.yml}
    tar -czf manuskript-0.5.0.tar.gz manuskript-0.5.0/
    mv manuskript-0.5.0.tar.gz SOURCES/
    rm -rf manuskript-0.5.0/
    
  5. Create SPECS/manuskript.spec file.
    Fill with contents:

    cat <<EOF > SPECS/manuskript.spec
    # Don't try fancy stuff like debuginfo, which is useless on binary-only
    # packages. Don't strip binary too
    # Be sure buildpolicy set to do nothing
    %define name    manuskript
    %define version 0.5.0
    %define release 1
    %define        __spec_install_post %{nil}
    %define          debug_package %{nil}
    %define        __os_install_post %{_dbpath}/brp-compress
    
    Summary: Manuskript open source tool for writers
    Name: %{name}
    Version: %{version}
    Release: %{release}
    License: GPL3+
    Group: Applications/Editors
    BuildArch: noarch
    BuildRoot: %{_builddir}/%{name}-%{version}-%{release}-root
    URL: http://www.theologeek.ch/manuskript/
    SOURCE0 : %{name}-%{version}.tar.gz
    Packager: Curtis Gedak <[email protected]>
    Provides: Manuskript
    Requires: python3, python3-qt5, python3-lxml, zlib, python3-markdown, pandoc
    %if 0%{?suse_version}
    # Assume openSUSE
    # Note - have to build rpm on openSUSE for this to work.
    Requires: libQt5Svg5, python3-pyenchant
    %else
    # Assume Fedora and others
    Requires: python3-qt5-webkit, qt5-qtsvg, python3-enchant
    %endif
    
    %description
    Manuskript is an open source tool for writers.  It
    provides a rich environment to help writers create
    their first draft and then further refine and edit
    their masterpiece.
    
    %prep
    %setup -q
    
    %build
    # Empty section.
    
    %install
    rm -rf %{buildroot}
    mkdir -p  %{buildroot}
    
    # in builddir
    cp -a * %{buildroot}
    
    %clean
    rm -rf %{buildroot}
    
    %files
    %defattr(-,root,root,-)
    /usr/bin/manuskript
    /usr/share/applications/manuskript.desktop
    /usr/share/manuskript/*
    
    %changelog
    # Empty section.
    
    EOF
    

    ----- end manuskript.spec -----

  6. Build the "binary" rpm package.

    rpmbuild --target=noarch -bb SPECS/manuskript.spec
    

    This should create the RPM file in:
    RPMS/noarch/manuskript-0.5.0-1.noarch.rpm

PACKAGE INSTALL TEST

Install .rpm package with:

su -c "dnf install manuskript-0.5.0-1.noarch.rpm"

And try running manuskript.

Other useful commands:

  • Remove package with: su -c "dnf remove manuskript-0.5.0-1.noarch.rpm"
  • List package information with: rpm -qip manuskript-0.5.0-1.noarch.rpm
  • List package dependencies with: rpm -qRp manuskript-0.5.0-1.noarch.rpm

REFERENCES

Clone this wiki locally