Write a deb-extra-override File for dpkg-scanpackages
A deb-extra-override file rewrites one exported field for one package when you generate a Debian index. Nothing about the .deb itself changes; only what dpkg-scanpackages writes into Packages. Allow about fifteen minutes: write the file, run the scan, then check the field actually landed. The examples match dpkg 1.22.6, installed here as dpkg-dev 1.22.6ubuntu6.6.
The route
Jump straight to the step you need, or tick off Done means at the end.
- You need:
dpkg-scanpackages, a directory of Debian packages, and write access to the generated index and a temporary override file. - Privilege: the normal workflow is unprivileged. Only reach for elevated privileges if your archive directory is not writable, and check the paths before you hand a command
sudo.
1. Confirm the installed tool
Read-only, and worth doing before you write anything into an archive script:
$ command -v dpkg-scanpackages
/usr/bin/dpkg-scanpackages
$ dpkg-scanpackages --version
Debian dpkg-scanpackages version 1.22.6.
$ dpkg-query -W -f='${Package} ${Version}\n' dpkg-dev
dpkg-dev 1.22.6ubuntu6.6
Checkpoint
The command is present and the version matches what you have recorded for this archive build. The extra override file is passed to it with -e or --extra-override.
2. Write one override record
- Three columns, whitespace-delimited. Binary or source package name, field name, replacement value. The parser stops splitting after the third column, so anything after that stays part of the value, spaces included.
- One record per line. Do not quote the value to try to protect spaces; quoting plays no part in this format.
- A
#starts a comment. Use it to shelve an example line rather than delete it.
$ mkdir -p /path/to/archive/overrides
$ editor /path/to/archive/overrides/extra.override
Put this in the file, replacing PACKAGE_NAME with the name as it appears in the package's own control data:
PACKAGE_NAME Section local/testing package
# PACKAGE_NAME FieldName another value with spaces
The first line rewrites the exported Section field to local/testing package. The second is only a shape example: swap in a field name your index consumer actually accepts, or delete it if you have nothing to add there.
This is not the ordinary positional override file that dpkg-scanpackages also accepts. The extra file is supplementary metadata, selected explicitly with -e, and the two should not be confused.
3. Generate the Packages index
Run the scanner from the archive root, or from wherever produces the filenames you want. The package tree is the first argument, the override file comes in with -e, and the output is redirected to a new file:
$ dpkg-scanpackages \
-e /path/to/archive/overrides/extra.override \
/path/to/archive/pool \
/dev/null \
> /path/to/archive/Packages
dpkg-scanpackages: info: Wrote 1 entries to output Packages file.
/dev/null is standing in for the optional positional override argument here, which keeps the extra override unambiguous. In a real archive, point the package tree at the directory holding your .deb files: the command scans binary packages by default.
Warning
Shell redirection truncates Packages the instant it runs, before the scanner has produced anything. Generate to a temporary path first whenever you are replacing a live index:
$ dpkg-scanpackages -e /path/to/extra.override /path/to/archive/pool /dev/null > /path/to/archive/Packages.new
$ test -s /path/to/archive/Packages.new
$ mv /path/to/archive/Packages.new /path/to/archive/Packages
Recovery
If the scan fails, leave the old index alone and read the diagnostic. If the replacement turns out wrong, restore your last backup or regenerate from the original package tree and override file. Do not delete the old index until the new one has actually been consumed successfully.
4. Verify the exported field
Trust the generated stanza, not the scanner's exit status alone. This read-only check finds the package and prints its section:
$ awk -v want='PACKAGE_NAME' '
$1 == "Package:" && $2 == want { found=1 }
found && $1 == "Section:" { print; exit }
' /path/to/archive/Packages
Section: local/testing package
The output should match the value you wrote after the package and field names. Nothing printed? Check the package spelling, the path you gave -e, and whether the package was scanned at all.
Example
For a fast smoke test, point the installed tool at one local package in a scratch directory. The thing to look for is that the normal control field is replaced in the generated stanza while the .deb stays byte-for-byte unchanged. An extra override changes index output only; it never rewrites metadata inside the archive.
Common traps
- Filename is not package name. Use the exact binary or source package name, not whatever the file happens to be called.
- Field names are not free text. Use the name exactly as it should appear in the generated index.
- Do not split a value across records. Keep the spaces in the third column on one line, or you get several separate, wrong overrides instead of one correct one.
- Only the newest version scans by default. Add
--multiversionif you need every version considered. - Compress before APT reads it. APT ignores an uncompressed index except for local
file://access, so shipPackages.gzorPackages.xzfor normal use.
Treat every warning from dpkg-scanpackages, whether about a wrong subdirectory, a duplicate, a pre-existing Filename field, or an override that never matched a package, as an archive-quality problem to chase down, not proof the override worked.
Done means
- Recorded the installed
dpkg-scanpackagesversion. - Wrote one package, field, and value per line in the extra override, with comments where useful.
- Generated the index with
-eand the correct package tree. - Verified the exported field in the actual
Packagesstanza, not just the exit code. - Left the original
.debfiles untouched, with a recoverable path if the replacement goes wrong.