Subject: Rebuilding Debian package from source

From: Joshua Schaeffer <[email-masked]>
Date: Sun, 18 Sep 2016 19:35:23 -0600

I'm trying to rebuild the nginx-extras package from Jessie and I'm running into an error when I run debuild. I want to add a module to Nginx. I've just been following this to rebuild the package: https://raphaelhertzog.com/2010/12/15/howto-to-rebuild-debian-packages/

Here is what I've done:

 1. Downloaded the source using apt.
      * apt-get source nginx-extras
 2. Built the dependencies for the package
      * apt-get build-dep nginx-extras
 3. Updated the debian/rules file to include my module
 4. Added my module to the debian/modules directory
 5. Ran debuild to compile the package.
      * debuild -us -uc

When I run the debuild command I get an error about no Test/nginx-1.6.2-5_deb8u2/auto directory existing. As the error suggests it doesn't exist, but I'm not sure how to fix it. Creating the directory just leads to another error. Would anybody be able to tell me why I'm getting this error and how to fix it. I do have devscripts installed on the machine.

jschaeffer@mutalisk:~/Build Test/nginx-1.6.2-5+deb8u2$ debuild -us -uc
...
make[1]: Entering directory '/home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2'
dh_testdir
mkdir -p /home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2/debian/build-full
cp -Pa /home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2/auto /home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2/debian/build-full/
*cp: cannot stat ‘Test/nginx-1.6.2-5+deb8u2/auto’: No such file or directory*
cp: will not create hard link ‘Test/nginx-1.6.2-5+deb8u2/debian/build-full/Build’ to directory ‘Test/nginx-1.6.2-5+deb8u2/debian/build-full/Build’
debian/rules:141: recipe for target 'config.arch.full' failed
make[1]: *** [config.arch.full] Error 1
make[1]: Leaving directory '/home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2'
debian/rules:117: recipe for target 'build' failed
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
debuild: fatal error at line 1376:
dpkg-buildpackage -rfakeroot -D -us -uc failed

---

From: Zoltán Hermann <[email-masked]>
Date: Mon, 19 Sep 2016 12:59:42 +0200

Hello,

"cp: cannot stat ‘Test/nginx-1.6.2-5+deb8u2/auto’: No such file or
directory"

Test or Build Test ?

Greetings
Zoltán

Joshua Schaeffer <[email-masked]> ezt írta (2016. szeptember 19.,
hétfő):
> I'm trying to rebuild the nginx-extras package from Jessie and I'm
running into an error when I run debuild. I want to add a module to Nginx.
I've just been following this to rebuild the package:
https://raphaelhertzog.com/2010/12/15/howto-to-rebuild-debian-packages/
>
> Here is what I've done:
>
> Downloaded the source using apt.
>
> apt-get source nginx-extras
>
> Built the dependencies for the package
>
> apt-get build-dep nginx-extras
>
> Updated the debian/rules file to include my module
> Added my module to the debian/modules directory
> Ran debuild to compile the package.
>
> debuild -us -uc
>
> When I run the debuild command I get an error about no
Test/nginx-1.6.2-5_deb8u2/auto directory existing. As the error suggests it
doesn't exist, but I'm not sure how to fix it. Creating the directory just
leads to another error. Would anybody be able to tell me why I'm getting
this error and how to fix it. I do have devscripts installed on the machine.
> mkdir -p /home/jschaeffer/Build
Test/nginx-1.6.2-5+deb8u2/debian/build-full
> cp -Pa /home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2/auto
/home/jschaeffer/Build Test/nginx-1.6.2-5+deb8u2/debian/build-full/
> cp: cannot stat ‘Test/nginx-1.6.2-5+deb8u2/auto’: No such file or
directory
> cp: will not create hard link
‘Test/nginx-1.6.2-5+deb8u2/debian/build-full/Build’ to directory
‘Test/nginx-1.6.2-5+deb8u2/debian/build-full/Build’

---

From: Joshua Schaeffer <[email-masked]>
Date: Mon, 19 Sep 2016 09:22:30 -0600

Test...

"Build Test" is the directory I downloaded everything into (a.k.a. it was
the directory I was in when I ran apt-get source nginx-extras)

jschaeffer@mutalisk:~/Build Test$ pwd
/home/jschaeffer/Build Test

jschaeffer@mutalisk:~/Build Test$ ls -l
total 2004
drwxr-xr-x 1 jschaeffer jschaeffer    154 Sep 18 19:02 nginx-1.6.2-5+deb8u2
-rw-r--r-- 1 jschaeffer jschaeffer 609344 Jun  1 12:36
nginx_1.6.2-5+deb8u2.debian.tar.xz
-rw-r--r-- 1 jschaeffer jschaeffer   2873 Jun  1 12:36
nginx_1.6.2-5+deb8u2.dsc
-rw-r--r-- 1 jschaeffer jschaeffer   3692 Sep 18 19:14
nginx_1.6.2-5+deb8u2-harm_amd64.build
-rw-r--r-- 1 jschaeffer jschaeffer 621532 Sep 18 19:14
nginx_1.6.2-5+deb8u2-harm.debian.tar.xz
-rw-r--r-- 1 jschaeffer jschaeffer   2051 Sep 18 19:14
nginx_1.6.2-5+deb8u2-harm.dsc
-rw-r--r-- 1 jschaeffer jschaeffer 804164 Sep 17  2014
nginx_1.6.2-5+deb8u2.orig.tar.gz

jschaeffer@mutalisk:~/Build Test$ ls -l nginx-1.6.2-5+deb8u2/
total 596
drwxr-xr-x 1 jschaeffer jschaeffer    246 Sep 18 19:11 auto
-rw-r--r-- 1 jschaeffer jschaeffer 236013 Sep 16  2014 CHANGES
-rw-r--r-- 1 jschaeffer jschaeffer 359556 Sep 16  2014 CHANGES.ru
drwxr-xr-x 1 jschaeffer jschaeffer    180 Sep 18 18:50 conf
-rwxr-xr-x 1 jschaeffer jschaeffer   2369 Sep 16  2014 configure
drwxr-xr-x 1 jschaeffer jschaeffer     68 Sep 18 18:50 contrib
drwxr-xr-x 1 jschaeffer jschaeffer   1476 Sep 18 18:59 debian
drwxr-xr-x 1 jschaeffer jschaeffer     36 Sep 18 18:50 html
-rw-r--r-- 1 jschaeffer jschaeffer   1397 Sep 16  2014 LICENSE
drwxr-xr-x 1 jschaeffer jschaeffer     14 Sep 18 18:50 man
-rw-r--r-- 1 jschaeffer jschaeffer     49 Sep 16  2014 README
drwxr-xr-x 1 jschaeffer jschaeffer     46 Sep 18 18:50 src
drwxr-xr-x 1 jschaeffer jschaeffer     40 Sep 18 19:02 Test

jschaeffer@mutalisk:~/Build Test$ ls -l nginx-1.6.2-5+deb8u2/Test/
total 0
drwxr-xr-x 1 jschaeffer jschaeffer 12 Sep 18 19:13 nginx-1.6.2-5+deb8u2

jschaeffer@mutalisk:~/Build Test$ ls -l
nginx-1.6.2-5+deb8u2/Test/nginx-1.6.2-5+deb8u2/
total 0
drwxr-xr-x 1 jschaeffer jschaeffer 20 Sep 18 19:14 debian

On Mon, Sep 19, 2016 at 4:59 AM, Zoltán Hermann <[email-masked]> wrote:

> Joshua Schaeffer <[email-masked]> ezt írta (2016. szeptember
> 19., hétfő):
> > cp: will not create hard link ‘Test/nginx-1.6.2-5+deb8u2/debian/build-full/Build’
> to directory ‘Test/nginx-1.6.2-5+deb8u2/debian/build-full/Build’

---

From: The Wanderer <[email-masked]>
Date: Mon, 19 Sep 2016 11:57:13 -0400

On 2016-09-19 at 11:22, Joshua Schaeffer wrote:

> Test...
> 
> "Build Test" is the directory I downloaded everything into (a.k.a. it
> was the directory I was in when I ran apt-get source nginx-extras)

Based on the error, it looks as if the build process is attempting to
run a command that uses the full path of the build directory, but does
not quote that path; as a result, the space gets treated as a token
separator.

The net result is that it attempts to cp the absolute path
'/home/jschaeffer/Build' into the relative path
'Test/nginx-1.6.2-5+deb8u2/auto', which does not exist. (The former path
may well not exist either, but I'd double-check that if I were you.)

To fix this, either modify the build process to quote things
appropriately, or build from under a path which does not contain a
space. (The latter can be accomplished using symlinks, if preferred.)

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

---

From: Greg Wooledge <[email-masked]>
Date: Mon, 19 Sep 2016 12:02:58 -0400

> not quote that path; as a result, the space gets treated as a token

Makefiles in general have no real way to handle filenames and directory
names with spaces in them.  The notion of a Makefile variable holding
a space-delimited list of filenames is embedded in the design at the
most fundamental levels.  Passing these "lists" from Makefile to /bin/sh
script fragments doesn't make things any simpler, either.

> space. (The latter can be accomplished using symlinks, if preferred.)

I doubt it's possible to make build paths containing spaces work correctly
in the general case, even if the original poster does manage to hack
it up this one time.  My advice would be to stop attempting to use a
directory with a space in its name as part of a build setup.  It's doomed.

---

From: Joshua Schaeffer <[email-masked]>
Date: Mon, 19 Sep 2016 11:53:19 -0600

> directory with a space in its name as part of a build setup.  It's doomed.
Go to know. I will not use spaces in the future. I was able to get the
package rebuilt by following this guide:
https://wiki.debian.org/BuildingAPackage

Which, incidentally, does not use spaces in its base directory.

Thanks,
Joshua Schaeffer