12

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:

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.

troutwine
  • 3,721
  • 3
  • 28
  • 62

3 Answers3

8

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).

jrwren
  • 17,465
  • 8
  • 35
  • 56
Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • 2
    That `cp -r` is wrong at least because it assumes that `$(DESTDIR)/share/statrec` exists. `dh_make --native` creates a native package which is wrong here. `ChangeLog` is named `changelog`. Other files under `debian` should be reviewed and edited, renamed or deleted. `dpkg-buildpackage` uses `fakeroot` automatically last 2 years. – wRAR Aug 24 '11 at 17:14
  • wRAR: Can you explain what would be preferable to the use of `cp -r`? Why is `dh_make --native` wrong? – troutwine Aug 24 '11 at 17:20
  • 2
    `dh_make --native` is wrong because, quoting `maint-guide`, "Normal Debian packages are non-native Debian packages made from upstream programs." Native package are only for Debian-only software and even then non-native package may be a better choice. That `Makefile` requires either `mkdir -p $(DESTDIR)/share/statrec/$(VERSION)` before `cp -a` (not `cp -r`) or some other means to create the directory if necessary. Also, the destination directory should be `/usr/share/statrec/$(VERSION)`, not `/share/statrec/$(VERSION)` (and if you use `$(VERSION)`, you need to define it first). – wRAR Aug 24 '11 at 17:37
  • 1
    Your quotation defines what a 'Normal Debian' package is, not the vital distinction between native and non-native. A 'native' package is, then, a Debian project specific bit of software, like `dpkg`? What is the functional difference between the distinctions? In what situations might a non-native package be a better choice, and why? Concerning `VERSION` MG 3.3 notes that only DESTDIR is defined; are there any other variables defined? How do the targets of the project Makefile map to their use by `debuild` or `dpkg-buildpackage`? Is it the case that only the `install` target is used? – troutwine Aug 24 '11 at 17:51
  • 1
    `dpkg` is packaged as native, yes. native package means you need to publish a new upstream version every time you change something in the packaging, because it has only upstream version and no Debian version number, and this may be inconvenient. – wRAR Aug 24 '11 at 17:53
  • `dh_auto_build(1)` tries to use `make` and `make install` if it finds a `Makefile`. – wRAR Aug 24 '11 at 17:54
  • 1
    instead of creating a Makefile at the root, which you otherwise may not want, you can use similar copy command in debian/rules under the override_dh_auto_install target. use dh_install source dest. – jrwren Apr 29 '15 at 19:59
1

You should read section 15.2.2 in the debian-handbook.

I found it helpfull to just create a .install file and skip that Makefile part, for my own project

kjetildm
  • 274
  • 3
  • 11
1

I found saurik's (of cydia/jailbreak fame) "Hosting a Cydia Repository" guide useful for creating your own .deb files. Have a look at it here: http://www.saurik.com/id/7

holygeek
  • 15,653
  • 1
  • 40
  • 50