I am having some trouble creating a package for a shared library.

I ran dh_make and edited the files. However, when I go to build the package, I get the following:

******@******-laptop:~/Documents/temp/jsoncpp/jsoncpp-0.5.0$ debuild
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CPPFLAGS to default value: 
dpkg-buildpackage: set LDFLAGS to default value: -Wl,-Bsymbolic-functions
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: source package jsoncpp
dpkg-buildpackage: source version 0.5.0-1
dpkg-buildpackage: source changed by ****** 
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
dh  clean
 dpkg-source -b jsoncpp-0.5.0
dpkg-source: info: using source format `1.0'
dpkg-source: info: building jsoncpp using existing jsoncpp_0.5.0.orig.tar.gz
dpkg-source: info: building jsoncpp in jsoncpp_0.5.0-1.diff.gz
dpkg-source: info: building jsoncpp in jsoncpp_0.5.0-1.dsc
 debian/rules build
dh  build
make[1]: Entering directory `/home/******/Documents/temp/jsoncpp/jsoncpp-0.5.0'
test -d obj || mkdir obj
g++ -I ./include -c -o obj/json_reader.o src/lib_json/json_reader.cpp
g++ -I ./include -c -o obj/json_writer.o src/lib_json/json_writer.cpp
g++ -I ./include -c -o obj/json_value.o src/lib_json/json_value.cpp
ar -r libjsoncpp.a obj/json_reader.o obj/json_writer.o obj/json_value.o
ar: creating libjsoncpp.a
make[1]: Leaving directory `/home/******/Documents/temp/jsoncpp/jsoncpp-0.5.0'
 fakeroot debian/rules binary
dh  binary
make[1]: Entering directory `/home/******/Documents/temp/jsoncpp/jsoncpp-0.5.0'
sudo cp -r include/json --target-directory=/usr/include
ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded: ignored.
cp libjsoncpp.a /usr/lib/libjsoncpp.a
cp: cannot create regular file `/usr/lib/libjsoncpp.a': Permission denied
make[1]: *** [install] Error 1
make[1]: Leaving directory `/home/******/Documents/temp/jsoncpp/jsoncpp-0.5.0'
dh_auto_install: make -j1 install DESTDIR=/home/******/Documents/temp/jsoncpp/jsoncpp-0.5.0/debian/tmp returned exit code 2
make: *** [binary] Error 29
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2
debuild: fatal error at line 1340:
dpkg-buildpackage -rfakeroot -D -us -uc failed

The problem seems to be here:

ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded: ignored.
cp libjsoncpp.a /usr/lib/libjsoncpp.a
cp: cannot create regular file `/usr/lib/libjsoncpp.a': Permission denied

...but I haven't the faintest idea what the problem is.

The makefile is here if needed.

  • Are you sure you have all the build-prerequisites installed? – txwikinger Aug 3 '10 at 22:50
  • @txwikinger: No... how can I be sure? (Sorry, I'm new to package building - I've only ever built one and it wasn't a library.) – Nathan Osman Aug 3 '10 at 22:53
  • Did you get the source upstream or from apt-get source? – txwikinger Aug 3 '10 at 22:57
  • @txwikinger: Well, I got the source upstream but needed to modify it quite heavily to insert a Makefile and remove unnecessary files. Probably I shouldn't have done it that way, but I don't know any better way. By the way, the package is jsoncpp. – Nathan Osman Aug 3 '10 at 23:01
  • Maybe offtopic to this question, but in general we do not edit the sources, we create patches for any changes. However, this would probably not have a baring on this problem. – txwikinger Aug 3 '10 at 23:18

The Makefile you are using is not respecting the DESTDIR variable - packages should never install directly into /usr at build time, but instead put files into a temporary tree. You've mentioned that you added the Makefile yourself - the usual case is that you'd need to make it use the DESTDIR variable as a prefix for all install paths. Having looked at the package build instructions, the package uses scons as a build system, which is a replacement of sorts for make. dh_make most likely doesn't have a template for building packages with this, so you should look for packages that do use it for building, such as yafray, and look at their debian/rules

As package builds are never done as root, it is better to have this error shown & corrected rather than having a package overwrite important files as the package is being built on an unsuspecting developer's system.

| improve this answer | |
  • Aha! Thank you soooo much! This piece of information is a tremendous help. – Nathan Osman Aug 4 '10 at 2:39

As you figured the problems lies here:

cp libjsoncpp.a /usr/lib/libjsoncpp.a

You are calling debbuild as normal user, who has no rights to write to that directory. If you try sudo debbuild it should work.

| improve this answer | |
  • This does not fix the problem. As mentioned above, this is happening inside a chroot environment... so permissions should not be a problem. – Nathan Osman Aug 4 '10 at 0:11

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.