Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I package my linux application using MonoDevelop?

I have a hobby project that is written in C# using MonoDevelop. I've been trying for some time now to get my head around linux packaging, but I keep coming away feeling frustrated and overwhelmed.

My program consists of:

  • A library project ("Generator") that does stuff with the data created by my program.
  • An ui ("Interface") project using Gtk#. This project has two subdirectories: "glade" (xml files that gtk uses to build widgets) and "book" (data used by my program).
  • A utility project ("Utils") used by both the library and interface projects.
  • A main project ("MyProgramName") that just starts the interface.

What (I think) I want to do is really very simple (I think):

  • Compile my application
  • Copy the .exe and .dll files (to /usr/local/bin?)
  • Copy the "book" directory (to /usr/local/bin?)
  • Copy the "glade" directory (to /usr/local/bin?)

Oh, and I want to do this as a .deb package. I think if I can get the tarball working, a .deb package shouldn't be too much trouble, but that's what I want to do eventually.

I'm still not really sure how to do this. I've used MonoDevelop to create a Tarball. When I install the tarball (using ./configure, make, sudo checkinstall), it seems to install the executable code (and even create a command to run the program), but forgets about the "book" and "glade" directories.

How would I go about doing this? Sorry if this is a basic/broad question. I've been googling around about this, and I can't seem to find anything that doesn't assume I know the basics of packaging (even if it claims it doesn't assume this).

like image 633
Matthew Avatar asked Nov 15 '09 21:11

Matthew


2 Answers

Debian packages are like tar files - they contain a copy of the file system. To create a Debian package...

  1. Install the tarball in a build directory.
  2. Add a DEBIAN directory with the control files. I found this article helpful.
  3. Create the package with dpkg --build.

I would start by learning GNU's autotools: autoconf and automake. They make it very easy to install the program in a build directory. You mentioned ./configure. So I assume ythis project already has some of the structure. From the description, it sounds like the project might need...

  • Entries in configure.in for files in "book" and "glade".
  • Makefile.am files in "book" and "glade".

Putting it all together, the following commands result in a package file named project.deb.

# ./configure --prefix build/usr
# make && make install
# dpkg --build build project.deb
like image 135
Robert Wohlfarth Avatar answered Sep 22 '22 10:09

Robert Wohlfarth


Perhaps this blog post may be of help to you.

It thoroughly describes the structure of a deb package, which is as follows:

<YOUR PACKAGE NAME>
└── deb
    ├── DEBIAN
    │   ├── conffiles
    │   ├── control
    │   └── preinst
    └── opt
        └── <YOUR APPLICATION>
            └── <Your Application Contents>  

Basically, you have a deb folder inside the package with the following 2 mandatory folders inside:

  • DEBIAN - containing files that describe the deb package itself
  • file-system structure mirroring the destination for the package installation. In the above example, the package will be deployed inside /opt/<YOUR APPLICATION> directory.

From the DEBIAN directory, you must have at least the control file, which is plain text. It needs to contain entries in specific format that is described in detail in the linked page. Here is a mere example (taken from there) with a sample control file:

Package:packagingmono
Version:1.0
Maintainer:Mikael Chudinov <[email protected]>
Architecture:amd64
Section:net
Description:Template for Debian packaged Mono application.
Depends:mono-complete (>=3)
  • Package must be your package name. Allowed is upper/lower latin letters, numbers and -.
  • Version - the package version. I'd recommend using the assembly version for that field.
  • Maintainer - the package developer(s) name and contact info.
  • Architecture - either i386 or amd64. If you want to distribute your application optimized for x86 and x64 as separate executables per platform (I mean built explicitly for x64 or x86, not using AnyCPU), then you should produce separate .deb packages for each, and set the Architecture field appropriately. The rest of the fields may still be the same.
  • Section - optional, could be any of the allowed package categories in the debian apt system.
  • Description. Consist of two tokens - short description (the first item before a new line symbol) and optionally longer one (the text after the first new line).
  • Depends - a list of dependencies to your package. The example states mono-complete which is the package name for the mono runtime, and further restricts it to be higher or equal to version 3

Important thing to know about a deb package is that you can actually put an entire application (the contents of the bin folder) into a single package. There is no need to put the referenced libraries in separate packages and mark them as dependencies, the latter makes sense if you plan to install other applications that would rely on the same libraries. Besides, packing the application together would not allow the dll-hell problem to one day become a package-hell problem. A drawback to this is that the size of the package might become larger.

The article also recommends some native GNU/Linux tools that will aid you in the package creation. For example xbuild can be used to run an MSBuild file that will do the packaging for you. This will help make things more familiar to Windows developers. The lintian tool may also assist you in fixing issues with the produced .deb file. The rest of the tools are intermediate utilities that are invoked during the MSBuild packaging process.

like image 36
Ivaylo Slavov Avatar answered Sep 19 '22 10:09

Ivaylo Slavov