Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a native Debian package for static files?

I have a need to Debianize some static resources for a software project but am confused by the available information and could use some guidance in doing so. Here are the materials I've been reading:

  • Rolling your own Debian packages
  • Debian New Maintainer's Guide
  • Debian Library Packaging Guide
  • Debian Mentors FAQ

The Debian New Maintainer's Guide seems the most apropos, especially this chapter, but it's didactic presentation is not effective for me; it reads more as a re-learning reference than a guide for the unknowing. Much of the information I've found is likewise geared to getting packages included in a public repository which I do not need. To make it that some kindly folk might show me the way, I've created a small project statrec which exemplifies the type of package I need to create. It's source tree looks like so:

statrec/
├── LICENSE
├── README.md
├── share
│   ├── gilgamesh.txt
│   └── thoreau.txt
└── VERSION

I need to but am unable to deduce how to:

  • install statrec/share to /usr/share/statrec/VERSION/,
  • create or modify a symlink from /usr/share/statrec/current/ to /usr/share/statrec/VERSION/ and then
  • uninstall previous versions of statrec.

I understand how to accomplish some of this, maybe which tools to use but feel rather paralized by the surfeit of information.

like image 865
troutwine Avatar asked Aug 24 '11 13:08

troutwine


People also ask

What language are Debian packages written in?

Most Linux programs are written in the C programming language. These are the C libraries and header files gcc needs to link with to create object files. As I write this, Debian is in a transition between libc5 and libc6. Any new packages should be created using libc6.

How do I get Debian source package?

From debian.orgYou can do a manual download from http://www.debian.org/distrib/packages. When you are on the page of the package, choose a distribution, and you will have a link to the three files which make the source package.


1 Answers

I would say easiest thing would be to:

  1. Create a makefile, that will install the files as you want them honoring any DESTDIR setting and do nothing for default target. Something along the lines of:

    all: # nothing to build
    
    install:
        cp -r share/* $(DESTDIR)/usr/share/statrec/$(VERSION)
    

    The DESTDIR thing is important; it will not be installing to the system, but instead to a temporary directory that dpkg will than pack up. All symlinks must point to the final destinations (without $(DESTDIR) prefix).

  2. Let dh_make --native do it's business (it will create another makefile debian/rules that will call the first makefile).

  3. Look at the files under debian. Especially debian/changelog may need editing (it's where debuild /dpkg-buildpackage get the version number from, so it must be filled in).

    I believe debuild uses fakeroot automatically, for dpkg-buildpackage you have to specify it manually. Don't even think about running it as real root.

  4. Use debuild or dpkg-buildpackage -rfakeroot to build it

No need to care for uninstalling as dpkg is going to handle that.

Update: I suggest dh_make --native, because I understood the question is for simply installing a handful of data files on a handful of debian systems. If it should be distributed, I suggest simply going to ask on the irc.debian.org#debian IRC channel and probably leaving it up to Debian Developer (only Debian Developers may upload to Debian archive and they usually want to handle the packaging themselves).

Also if it's part of software rather than stand-alone bunch of data files, the installation should be part of the general installation of the software using one common makefile, there should be just one Debian source package and just the debian/control and debian/*.files should specify which files go to the application package (which is "Architecture: any") and which files go to the data package (which is "Architecure: all" and usually gets suffix -data).

like image 121
Jan Hudec Avatar answered Oct 15 '22 09:10

Jan Hudec