Having trouble creating a debian debug package

152 Views Asked by At

We have a fairly large project that consists of files in multiple git repositories that is built for multiple platforms. For each platform and repo, a build is run, and the output goes into a common directory. The directory layout (greatly simplified) is something like this:

multi:
build/  part1/  part2/  Makefile  VERSION

build:

multi/part1:
Makefile  part1.c

multi/part2:
Makefile  part2.c

Until fairly recently, we built the project for rpm-based systems. A customer needed for a Debian system. So we did some research. We created a build-deb.sh script in the multi directory, and created a debian directory under multi which contains the control, conffile, preinst, postinst, prerm, postrm.

make-deb.sh:

#!/bin/bash

. build/buildrc

version="${MULTI_MAJOR}.${MULTI_MINOR}.${MULTI_REVISION}.${MULTI_BUILD}"
branch="$MULTI_BRANCH"

# Set up the name and directories
package="Multi-$branch-$version.debian11.x86_64"
multi="build/${package}"
debdir="$multi/DEBIAN"

# Create the directories
rm -rf $multi
mkdir -p $debdir
mkdir -p $multi/usr/local/multi/bin

cp build/part1/* build/part2/* $multi/usr/local/multi/bin

# Copy dpkg files
cp debian/* $debdir

# Update the control file
size=`du -sk --exclude=DEBIAN $multi | cut -f1`
sed -i -r  -e "s/@size/$size/" -e "s/@version/$version/" $debdir/control

# Build the package
cd build
dpkg-deb --build ${package}

debian/control:

Package: Multi
Version: @version
Priority: optional
Architecture: amd64
Installed-Size: @size
Maintainer: <[email protected]>
Description: Multi-part System
 This is a simple Multi-part system that includes two executables,
 copied in from different directories.

The script creates a multi/build/multi-main-3.5.3.9999-debian11-x86_64 directory, and copies in appropriate files from the build directory and the debian directory.

We get the following output when we run the build:

$ make PLATFORM=debian
make[1]: Entering directory '/srv/devel/multi/part1'
mkdir -p ../build/part1
gcc -g -O2 -o ../build/part1/part1 part1.c
make[1]: Leaving directory '/srv/devel/multi/part1'
make[1]: Entering directory '/srv/devel/multi/part2'
mkdir -p ../build/part2
gcc -g -O2 -o ../build/part2/part2 part2.c
make[1]: Leaving directory '/srv/devel/multi/part2'
dpkg-deb: building package 'multi' in 'Multi-main-3.5.3.43.debian11.x86_64.deb'.

After doing a build, the build directory looks like this:

build/:
Multi-main-3.5.3.43.debian11.x86_64/
part1/
part2/
Multi-main-3.5.3.43.debian11.x86_64.deb
buildrc

build/Multi-main-3.5.3.43.debian11.x86_64:
debian/
usr/

build/Multi-main-3.5.3.43.debian11.x86_64/DEBIAN:
control

build/Multi-main-3.5.3.43.debian11.x86_64/usr:
local/

build/Multi-main-3.5.3.43.debian11.x86_64/usr/local:
multi/

build/Multi-main-3.5.3.43.debian11.x86_64/usr/local/multi:
bin/

build/Multi-main-3.5.3.43.debian11.x86_64/usr/local/multi/bin:
part1*
part2*

build/part1:
part1*

build/part2:
part2*

Ok, might be a bit cludgy, but it produces a .deb file that can be installed.

So, now we need to build a debug package. After doing some more research, it looked like all we had to do was add a Package: Multi-dbg section to the debian/control file and run dh_strip --dbg-package=Multi-dbg. Well that just gave us an error several package info entries found, only one allowed. Ok, take that section out, and run dh_strip --dbg-package=Multi. That gave us the error dh_strip: error: "debian/control" not found. Are you sure you are in the correct directory?.

Hmm, cd into the build/Multi-main-3.5.3.43.debian11.x86_64 directory and try dh_strip again. Error: "debian/control" not found. Are you sure you are in the correct directory?. Ok, rename the build/Multi-main-3.5.3.43.debian11.x86_64/DEBIAN directory as build/Multi-main-3.5.3.43.debian11.x86_64/debian and try again. Made a little progress:

$ make PLATFORM=debian
dpkg-deb: building package 'multi' in 'Multi-main-3.5.3.43.debian11.x86_64.deb'.
dh_strip: error: could not find Source: line in control file.
make: *** [Makefile:31: dist] Error 255

So we just need to add a Source: line in the control file. According to research, it's supposed to be the name of a source package. We don't have a source package, so maybe just make one up? Tried Source: Multi and Source: Multi.deb and Source: Multi-src.deb and other combinations and always end up with

$ make PLATFORM=debian
dpkg-deb: building package 'multi' in 'Multi-main-3.5.3.43.debian11.x86_64.deb'.
dh_strip: error: Source-field must be a valid package name, got: "Multi-src.deb", should match "(?^:^(?^:[a-z0-9][-+\.a-z0-9]+)$)"
make: *** [Makefile:31: dist] Error 255

Also tried all lower-case variants and got dh_strip: warning: No packages to build. Possible architecture mismatch: amd64, want:

It must be fairly simple, lots of people do it. I just can't figure out how to get the debug package. A little help here??

0

There are 0 best solutions below