problem when creating my package

Asked by Poste on 2020-03-31

When launchpad tries to compile my source program, it fails with the following error:
dpkg-buildpackage
-----------------

dpkg-buildpackage: info: source package test
dpkg-buildpackage: info: source version 1.9-1
dpkg-buildpackage: info: source distribution eoan
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
 fakeroot debian/rules clean
dh clean
   dh_auto_clean
 make -j4 clean
make[1]: Entering directory '/<<PKGBUILDDIR>>'
rm -rf *.o
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
   dh_clean
 debian/rules build
dh build
   dh_update_autotools_config
   dh_autoreconf
   dh_auto_configure
   dh_auto_build
 make -j4 "INSTALL=install --strip-program=true"
make[1]: Entering directory '/<<PKGBUILDDIR>>'
gcc -o hello.o -c src/hello.c -W -Wall -ansi -pedantic
gcc -o main.o -c src/main.c -W -Wall -ansi -pedantic
gcc -o hello.exe src/hello.o src/main.o
install -m 644 hello.exe /usr/local/bin
install: cannot create regular file '/usr/local/bin/hello.exe': Permission denied
make[1]: *** [Makefile:24: install] Error 1
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_build: make -j4 "INSTALL=install --strip-program=true" returned exit code 2
make: *** [debian/rules:18: build] Error 255
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

Here is my makefile

CC=gcc
CFLAGS=-W -Wall -ansi -pedantic
LDFLAGS=
EXEC=hello.exe

all: install

hello.exe: hello.o main.o
 $(CC) -o hello.exe src/hello.o src/main.o $(LDFLAGS)

hello.o: src/hello.c
 $(CC) -o hello.o -c src/hello.c $(CFLAGS)

main.o: src/main.c src/hello.h
 $(CC) -o main.o -c src/main.c $(CFLAGS)

clean:
 rm -rf *.o

mrproper: clean
 rm -rf $(EXEC)

install: hello.exe
 install -m 644 hello.exe /usr/local/bin

How to fix that?

Thanks in advance.

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
2020-03-31
Last reply:
2020-03-31

Hi, Poste.

This doesn't seem to be a problem related to Launchpad itself.

The `all` target on your Makefile seems to be trying to install the program, rather than just building it. It shouldn't try to install, since it will run with an unprivileged user on Launchpad's builders (that means that it will not be able to create a file under /usr/local/bin/.

You might want to take a look at Launchpad's guide to create a new source package (https://help.launchpad.net/Packaging/SourceBuilds/GettingStarted) and the Ubuntu's packaging guide ( https://packaging.ubuntu.com/html/).

Other than that, I suggest you test building your package locally first before building it on Launchpad, since it will be faster for you to iterate and fix problems. On Ubuntu's packaging guide you should have a tutorial on how to setup your build locally for testing: https://packaging.ubuntu.com/html/setting-up-sbuild.html .

Can you help with this problem?

Provide an answer of your own, or ask Poste for more information if necessary.

To post a message you must log in.