Skip to content

Package Manuskript for Linux with dpkg

Curtis Gedak edited this page Nov 21, 2017 · 4 revisions

SUMMARY

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

CONSIDERATIONS

This document is heavily based on the steps found in this stackoverflow.com answer. A huge thank you to Rafael Senties Martinelli for posting this simplified method of building a .deb package.

Originally I tried Ubuntu 14.04 Trusty Tahr as the base distro to build the .deb file. Unfortunately when this .deb file was installed on same distro it failed to run. Hence I am now using Debian 8 Jessie.

PREPARATION

Install tools needed to build package.

sudo update
sudo apt install dpkg wget

CREATE PACKAGE STRUCTURE

These are the basics for creating a Debian package for manuskript with dpkg -b <folder>.

Note that I have modified these steps to be specific to manuskript.

In all of the steps replace the following variables with values:

AppName      manuskript
AppVersion   0.5.0
PkgNumber    1
PkgVersion   0.5.0-1
PkgSizeInKb  # find with:  du -sk manuskript-0.5.0-1
  1. Create the files and folders in order to recreate the following structure:

    {PkgVersion}/
    {PkgVersion}/DEBIAN
    {PkgVersion}/DEBIAN/control
    {PkgVersion}/usr/
    {PkgVersion}/usr/bin/
    {PkgVersion}/usr/bin/{AppName}   # Invocation script
    {PkgVersion}/usr/share/
    {PkgVersion}/usr/share/applications
    {PkgVersion}/usr/share/applications/{AppName}.desktop
    {PkgVersion}/usr/share/{AppName}
    {PkgVersion}/usr/share/{AppName}/{AppName-files}   # Python code
    

Now the code to do this:

    mkdir dist
    cd dist
    mkdir -p manuskript-0.5.0-1/DEBIAN
    mkdir -p manuskript-0.5.0-1/usr/bin
    mkdir -p manuskript-0.5.0-1/usr/share/applications
  1. Add the python source code

    pushd manuskript-0.5.0-1/usr/share
    wget https://github.com/olivierkes/manuskript/archive/0.5.0.tar.gz
    tar -xvf 0.5.0.tar.gz
    rm 0.5.0.tar.gz
    mv manuskript-0.5.0 manuskript
    popd
    
  2. Add the invocation script

    Create manuskript-0.5.0-1/usr/bin/manuskript invocation file with contents:

    ----- begin manuskript -----

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    #
    # manuskript - invocation python script
    #
    # Copyright (C) 2017 Olivier Keshavjee
    #
    # This file is part of Manuskript.
    #
    # Manuskript is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # Manuskript is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with Manuskript.  If not, see <http://www.gnu.org/licenses/>.
    
    import os
    import sys
    
    sys.path.insert(1, '/usr/share/manuskript/')
    
    from manuskript import main
    
    main.run()
    

    ----- end manuskript -----

  3. Make the invocation script permissions executable.

    chmod 0755 manuskript-0.5.0-1/usr/bin/manuskript
    
  4. Make the desktop graphic icon launch file.

    Create manuskript-0.5.0-1/usr/share/applications/manuskript.desktop file with contents:

    ----- begin manuskript.desktop -----

    [Desktop Entry]
    Name=Manuskript
    Comment=An open source tool for writers
    Keywords=manuskript;office;write;edit;novel;text;msk
    Exec=/usr/bin/manuskript
    Terminal=false
    Type=Application
    Icon=/usr/share/manuskript/icons/Manuskript/icon-512px.png
    Categories=Office;WordProcessor;
    

    ----- end manuskript.desktop -----

    After 0.5.0 release start using /usr/share/manuskript/icons/Manuskript/manuskript.svg

  5. Make the DEBIAN control file.

    Fields taken from deb-control man page.

    Create manuskript-0.5.0-1/DEBIAN/control file with contents:

    ----- begin control -----

    Package: manuskript
    Version: 0.5.0-1
    Maintainer: Curtis Gedak <[email protected]>
    Description: Manuskript open source tool for writers.
     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.
    Section: office, text
    Priority: optional
    Installed-Size: {PkgSizeInKb}
    Architecture: all
    Origin: Debian 8 Jessie
    Bugs: https://github.com/olivierkes/manuskript/issues
    Homepage: https://github.com/olivierkes/manuskript/
    Source: https://github.com/olivierkes/manuskript/archive/0.5.0.tar.gz
    Depends: python3, python3-pyqt5, python3-pyqt5.qtwebkit, libqt5svg5, python3-lxml, zlib1g, python3-enchant, python3-markdown, pandoc
    Suggests: texlive-latex-recommended
    

    ----- end control -----

    Remember to fill in {PkgSizeInKb}!
    Use command: du -sk manuskript-0.5.0-1

    NOTE: Build on Ubuntu 14.04 Trusty Tahr would fail to run when the .deb package was installed. Now using Debian 8 Jessie.

  6. Change all the folders and files ownership to root.

    sudo chown root:root -R manuskript-0.5.0-1
    
  7. Create the .deb package.

    dpkg -b manuskript-0.5.0-1
    

    This should create a manuskript-0.5.0-1.deb file.

PACKAGE INSTALL TEST

Install .deb package with:

sudo apt update                       # Ensure repository is up-to-date
sudo dpkg -i manuskript-0.5.0-1.deb   # Install package without dependencies
sudo apt install -f                   # Install missing dependencies

And try running manuskript.

Other useful commands:

  • List installed manuskript package with dpkg -l | grep -i manuskript
  • Remove manuskript package with sudo apt purge manuskript or sudo dpkg --purge manuskript

REFERENCES

Clone this wiki locally