2

I'm try to build a Debian package, using this commands :

debian/rules clean
dpkg-source -b .
debian/rules build
debian/rules binary

I've got this file :

myprog_1.1.0.orig.tar.gz
myprog_1.1.0-1.dsc
myprog_1.1.0-1.debian.tar.xz
myprog_1.1.0-1_all.deb
myprog-doc_1.1.0-1_all.deb

All the steps have been completed with success. When I open the directory myprog-1.1.0/debian, I find something, which looks like to a Debian package. But my libraries are not in there, they are under myprog-1.1.0/debian/tmp/usr/lib/....

And the compiled libraires are not in my .deb.

  • Is this normal?
  • Is there something else to do to finish this package ?
  • If I'd want it to distribute it, should I recreate a tar.gz from myprog-1.1.0?
  • Did you look into the .deb file? If the files are not in there, is your .dsc correct and referring to the libraries that need to be included in your .deb? – Anthon Jul 10 '14 at 14:27
  • Into the .deb file, there are the same files that in "myprog-1.1.0/debian/myprog", which contains /DEBIAN and /usr/share/some_doc ... But not /usr/lib. My .dsc seems good. – cooow Jul 10 '14 at 14:37
  • Is this your own packaging, or someone elses? Regardless use debuild -uc -us. debuild is from the devscripts package. What you you using to look inside the debian binary package? – Faheem Mitha Jul 10 '14 at 14:38
  • It's my own packaging. I use Xarchiver to look inside – cooow Jul 10 '14 at 14:40
  • It has been a while since I created my own .deb files, but I think you are missing something in your .dsc if things get compiled but not included in the .deb. – Anthon Jul 10 '14 at 15:13
2

I think the important thing your build is missing is that on make install the Makefile honours the DESTDIR variable (which on packaging target should be something like ./debian/myprog).

After the build, before the packaging, the library should be in myprog-1.1.0/debian/myprog/usr/lib not tmp.

Just as reference: Following is a minimal working example and the commands I've used to get the package. Put all these files in the directory myprog-1.0.1.


Makefile:

CFLAGS += -O2 -Wall
LIBS += -L$(BUILDDIR)/usr/lib -lfunc

ifeq ($(BUILDDIR),)
BUILDDIR = build
endif

all: $(BUILDDIR)/usr/bin/myprog $(BUILDDIR)/usr/lib/libfunc.so

install: $(BUILDDIR)/usr/bin/myprog $(BUILDDIR)/usr/lib/libfunc.so
    mkdir -p $(DESTDIR)/usr/bin $(DESTDIR)/usr/lib
    cp $(BUILDDIR)/usr/bin/myprog $(DESTDIR)/usr/bin
    cp $(BUILDDIR)/usr/lib/libfunc.so $(DESTDIR)/usr/lib

dir-stamp:
    mkdir -p $(BUILDDIR)/usr/bin $(BUILDDIR)/usr/lib
    touch $@

$(BUILDDIR)/usr/bin/myprog: myprog.c $(BUILDDIR)/usr/lib/libfunc.so
    $(CC) $(CFLAGS) -o $@ $< $(LIBS)

$(BUILDDIR)/usr/lib/libfunc.so: func.c dir-stamp
    $(CC) $(CFLAGS) -shared -o $@ $<

clean:
    -rm -fr dir-stamp $(BUILDDIR)

myprog.c:

#include <stdio.h>
#include <stdlib.h>
#include "func.h"
int main(int argc, char **argv) {
    printf("%d\n", func(atoi(argv[1]), atoi(argv[2])));
    return 0;
}

func.h:

#ifndef FUNC_H
#define FUNC_H
int func(int a, int b);
#endif

func.c:

#include "func.h"
int func(int a, int b) {
    return a + b;
}

And here the commands:

dh_make --createorig
#choose type of package (single)
rm debian/*.ex debian/*.EX (if not needed)
# update: depcheck against the built command
dpkg-depcheck -d ./build/usr/bin/myprog 1 1
#edit debian/control (add Build-Depends)
dpkg-buildpackage -us -uc -rfakeroot
dpkg --contents ../myprog_1.0.1-1_i386.deb

./
./usr/
./usr/share/
./usr/share/doc/
./usr/share/doc/myprog/
./usr/share/doc/myprog/changelog.Debian.gz
./usr/share/doc/myprog/copyright
./usr/share/doc/myprog/README.Debian
./usr/lib/
./usr/lib/libfunc.so
./usr/bin/
./usr/bin/myprog

Using cmake:

I'm not confident with cmake, but a quick test worked.

The only odd thing is the prefix at command line to generate the Makefile, could be a problem depending on the complexity of your project.

By default cmake uses /usr/local as prefix the an error is given building the package on rmdir, but using /usr works.

Notice also I've added OWNER_WRITE, because there was an error removing myprog rpath, there's probably a better way to set the wanted permissions correctly.

CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(myprog C)
ADD_DEFINITIONS(-O2 -Wall)
ADD_EXECUTABLE(myprog myprog.c)
ADD_LIBRARY(func SHARED func.c)
TARGET_LINK_LIBRARIES(myprog func)
INSTALL(TARGETS myprog DESTINATION "bin"
        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
INSTALL(TARGETS func DESTINATION "lib"
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

Generate the Makefile using:

cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .
| improve this answer | |
  • Indeed I don't use DESTDIR, but how can I use the variable, knowing that my Makefile is generated by CMake ? Thank's for your answer! – cooow Jul 11 '14 at 14:48
  • I'm not really confident with CMake but seem to be supported, try make install DESTDIR=/somedir and see if it work as expected, then make sure debian/rules use an absolute path as cmake require – Alex Jul 11 '14 at 14:54
  • @cooow see the update using cmake – Alex Jul 11 '14 at 15:37
  • Thank's for you help, your instructions help me. Finally, I've used override_dh_auto_install: dh_auto_install --destdir=debian/myprog , into debian/rules, but your method seems good too. – cooow Jul 16 '14 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.