Add Free Pascal ABI Dependencies with fpc-depends
Ship a Free Pascal package without the right ABI dependency and it installs fine, then breaks the day the compiler moves on. Running fpc-depends adds the Free Pascal ABI substitution to a Debian package, and you check the generated substvars data before the control metadata is built. Allow about 15 minutes if the package already has a debhelper workflow. This guide targets the Debian Free Pascal 3.2.2 implementation installed from fp-compiler-3.2.2.
The route
Jump straight to the step you need, or tick off Done means at the end.
1. Check the package layout
Work from the root of a Debian source package. You need:
- A
debian/directory. - A package name in
debian/control. - A normal debhelper build.
- The documented build dependency:
Build-Depends: fp-utils (>= 2.4.2-1)
The command is not part of debhelper itself. It is a debhelper-like helper shipped with the Free Pascal packaging. Its manual page describes it as the program that generates the ${fpc-abi:Depends} substitution and adds it to substvars files.
Confirm the installed version and the selected executable before editing any packaging files.
$ command -v fpc-depends
/usr/bin/fpc-depends
$ readlink -f /usr/bin/fpc-depends
/usr/bin/fpc-depends-3.2.2
$ dpkg-query -W -f='${Package} ${Version}\n' fp-compiler-3.2.2
fp-compiler-3.2.2 3.2.2+dfsg-32
Checkpoint
Exact package revisions vary. What matters is that the unversioned command resolves to the 3.2.2 implementation when that is the version you want to package against.
2. Add the helper to the build
Run fpc-depends before dh_gencontrol, so the substitution exists when Debian control files are expanded. If your package already has an override_dh_gencontrol target, add the helper there:
#!/usr/bin/make -f
%:
dh $@
override_dh_gencontrol:
fpc-depends
dh_gencontrol
Tip
The recipe lines in the target must start with real tabs. Pasted spaces will break the makefile. If another override already does work in override_dh_gencontrol, keep that work and place fpc-depends before the command that runs dh_gencontrol.
Warning
Do not run this helper with sudo. Package builds should run as an unprivileged user in a writable source tree. Elevated privileges can leave root-owned files behind and make the next build fail.
3. Run the helper and inspect its output
Build the package as usual, or run the helper from the package root while you diagnose the packaging step:
$ fpc-depends
$ find debian -maxdepth 2 -type f -name '*.substvars' -print
debian/hello.substvars
The file name depends on your binary package. Inspect it without editing it:
$ sed -n '1,80p' debian/hello.substvars
fpc-abi:Depends=fpc-abi-3.2.2
The installed 3.2.2 implementation removes any previous fpc-abi:Depends value and adds fpc-abi-3.2.2 for every package in debhelper's package list. That makes it safe to rerun during a build: the value is regenerated, not appended again and again. Other substvars in the same file belong to other helpers and stay intact.
Checkpoint
Your output can contain more substitutions and use a different package path. Verify the one thing that matters: the fpc-abi:Depends entry carries the 3.2.2 ABI package value, not a guessed compiler package name.
4. Let dh_gencontrol expand it
Now let the normal debhelper target consume the substitution:
$ dh_gencontrol
$ grep -R '^Depends:' debian/*/DEBIAN/control debian/*/DEBIAN/control 2>/dev/null
debian/hello/DEBIAN/control:Depends: fpc-abi-3.2.2, ...
The exact dependency line depends on the package. The ellipsis stands for other dependencies and is not literal output. Inspect the generated control file for the ABI dependency, then build or run your package's normal Debian checks.
Warning
Do not hand-edit files under debian/hello/DEBIAN. They are build output and will be regenerated.
5. Diagnose a helper that stops at once
On this machine the installed executable exists but cannot start, because the Perl module Debian::Debhelper::Dh_Lib is missing. The observed failure:
$ fpc-depends
Can't locate Debian/Debhelper/Dh_Lib.pm in @INC ...
BEGIN failed--compilation aborted ...
This is an installation problem, not evidence that your Pascal package has no ABI dependency. Restore the normal debhelper Perl support through your distribution's package manager, then rerun the command as the build user. Do not silence the error or write a local replacement module.
- Runs but nothing changes? Confirm you are in the package root and that debhelper selected the package you expect. Check the package list and generated file paths before touching the rules file.
- Wrong ABI value? Check which versioned
fpc-dependsexecutable the alternatives link selects.
6. Clean up generated files only
After a failed diagnostic run, remove only the generated substvars file, and only if it is untracked and your build policy allows it. A standard clean target is better:
$ debian/rules clean
Recovery
Do not delete the source tree or hand-remove unrelated files. If you changed debian/rules, revert that edit through version control only after checking that no other packaging work is mixed into the file.
Done means
- Right implementation.
fpc-dependsresolves to the intended Free Pascal implementation. - Build dependency present.
fp-utils (>= 2.4.2-1)is in the package build dependencies. - Right order. The helper runs before
dh_gencontroland writes substvars data for the selected packages. - Correct value.
fpc-abi:Dependsexpands tofpc-abi-3.2.2on the installed 3.2.2 implementation. - No root. The generated control file contains the ABI dependency, and no build step needed root privileges.