Neil Williams: Ideas for TDeb packages
This is a follow-up on TDebs with some detail of how existing packages can be adapted to support TDebs.$ cat debian/package-tdeb.tdeb
[gettextdir] po
[gettextname] package
[po4apodir] doc/po
[po4amandir] doc/package/man/
[po4acommand] po4a-build
What's happening then? Well, the first thing to take into account is that a lot of the values for these settings will be dictated by upstream, which is why it is necessary for maintainers to add this information as a support file in debian/. I tried determining all this information automatically but the script got far too long and still was far from complete.
- gettextdir - usually po but some upstream packages can support multiple po generation, so this allows for those.
- gettextname - the hardest thing to identify reliably, this is the name of the files to be installed in /usr/share/locale/lang/LC_MESSAGES/ and the name of the of the POT file.
- po4apodir - po4a is for documentation translation support, which is more variable, so a po4acommand field is available too.
Other changes
The (currently unsupported in Debian) XC-Package-Type: tdeb option is used in debian/control to mark a new or existing package as a TDeb. To use an existing package, it must comply with the rules for a TDeb including that it must be Architecture: all. The other rules centre around build issues. If any of the files in the existing package would require execution of any part of the normal build process of the package, these would have to be moved out of the package before that package could be a TDeb. The reason is that TDeb generation by translators needs to not require a full build environment for every individual package and must not risk modifying package contents in ways which are related to the build environment. So, unchanged images and other architecture-independent files are OK, any files which need build-dependencies are a problem. I don't know how many packages there are out there with such files. If you have a -data or -common package which contains translated data and that package also includes architecture-independent files, I'd be interested in knowing the name of the packages involved. If those packages also include files which are generated or modified within the package build, I'll be particularly interested in knowing about those source packages.
debconf
The most common use of TDebs during a release cycle is probably going to be debconf template updates by Christian and these are handled without needing a listing in the .tdeb file.
Other formats
I'm looking at QtLinguist support and it should be fairly straightforward using the .tdeb file arrangement.
Once that's done (in a branch, please - these can't be uploaded yet), the package can be tested with the soon-to-be-uploaded emdebian-tdeb package. The old content has been moved into the emdebian-grip-server package and the dependencies of the old version stripped back. The package contains two scripts dpkg-gentdeb and dh_gentdeb which I hope to get included into the respective packages in time for Wheezy. The idea will be that build systems (dh7, CDBS, debhelper-plain etc.) includes a call to the relevant script. (dh_ is just a wrapper around dpkg- in this case). This would allow maintainers to create the first TDeb, get that through NEW and then the fun starts. Once the translation mechanism is set up, I would like a nominated person (likely to be Christian if he agrees) to co-ordinate translation updates for particular packages to allow for a single upload including updates for many translations. This would be package_version+t1_all.tdeb and an appropriate .diff.gz or debian.tar.gz. No binary upload, no impact on testing migrations.
This is mostly theory right now but the scripts do exist in Emdebian SVN.
Still more testing to do but I hope to upload these scripts to unstable in the next few days.

Since my laptop features
We downloaded a total of 8
DECLARATIVE DIVERSIONS
======================
Introduction
A diversion is when it is possible to have dpkg not overwrite a file when it
reinstalls the package it belongs to, and to have it put the file from the
package somewhere else instead.
Declarative diversions involves a new control file with a declarative
syntax which dpkg will parse and process directly as part of the package unpack
and removal phases, eliminating the problems resulting from non-atomic
handling of diversions.
Topics
There are a number of topics involved in implementing this kind of project
* What syntax do we use for the new control file?
* What dpkg does with the control file
* How do we handle diversions to a non-existant directory?
* How do we order unpacking a new package which adds a diversion?
* How do we order unpacking a new package that removes a diversion?
* How do we order removing a package which had a diversion?
* How do we handle errors?
* What happens to dpkg-divert?
Details - Control File Syntax
-
It will conform to RFC2822 style with the following format:
* Divert-From:
* Divert-To:
* Blank lines and lines beginning with # will be comments
Divert-To will be optional and if it is ommitted then files being diverted
will have their filename changed to file.distrib
The above style has it s advantages, one of the main ones being that there is
no need to escape whitespace within filenames. It also allows for more commands
to be added at a later date.
Details - Control File Handling
-
Within control.tar.gz the file should be named diversions
This file is then copied to /var/lib/info/$package.diversions
We need to store the control file for the currently-installed package so that
we can detect declarative diversions that have been removed from the control
file between versions (On-disk version and the to-be-unpacked version).
If there is no previous version of a control file then all current diversions
within the package are left in place and any new ones declared within the
control file are added.
If there is a previous version of the control file then the diversions
listed within the file are compared with the diversions currently in place.
If a diversion exists that is no longer listed in the control file then it is
removed. If there is a diversion listed in the control file that doesn t
currently exist then it is added.
Details - Handling Diversions to non-existant directories
-
Diverting files to directories that don t exist can cause a number of problems.
If the package does not own the directory it may be left orphaned on
removal of the package
The package is responsible for ensuring the availability of the target
directory in the unpack phase.
If a declarative diversion attempts to divert a file to a folder that neither
exists already on the filesystem at unpack time, nor is shipped within
the package, dpkg will return an error at unpack time.
Details - Ordering Requirements
-
=>Unpacking a new package that adds a diversion
*1. Check if package has a previous diversion control file
*2. Copy control file to tmp directory
*3. Calculate diversions to be added
*4. Unpack folders
*5. Add diversions
*6. Unpack files
*7. Copy control file to /var/lib/dpkg/info/$package.diversion
*Performing diversions this way avoids trouble with creating folders and
accidentally overwriting the wrong version of files.
*Another major problem would be extracting a new version of the file and
overwriting the old one.
*This might cause the wrong version of the file to be diverted and the
package to break.
=>Unpacking a new package that removes a diversion
*1. Check if package has a previous diversion control file
*2. Copy control file to tmp directory
*3. Calculate diversions to be removed
*4. Check if dropped diversion results in a file conflict and abort the
unpack if it does.
*5. Unpack folders
*6. Unpack files
*7. Remove old files no longer needed in the package
*8. Remove diversions
*9. Copy control file to /var/lib/dpkg/info/$package.diversion
*If a package has no previous diversion control file then no diversions
will be removed and existing diversions can only be removed using
dpkg-divert.
*If removing a diversion results in a file conflict then dpkg will return
an error at unpack time before anything is unpacked and the unpack
is aborted.
=>Removing a package which had a diversion
*1. Remove files
*2. Remove diversions
*3. Remove folders
*4. Remove control file at /var/lib/dpkg/info/$package.diversion
*This ensures that all files, diversions and folders are removed correctly
Details - Error handling
Errors in diversions will have to handled with a great deal of care due to
the fact that if they are not the package could be broken.
This means that a great deal of checks must be done to ensure that all the files
can be diverted properly before any actual diverting takes place. If they can t
the package installation/update must be stopped and rolled back to avoid the
package being installed incorrectly or broken.
Details - dpkg-divert
-
When we impliment the new diversion method we should keep the current
dpkg-divert. This allows maintainers to catch up with the new method without
breaking their packages. It also allows maintainers to perform some operations
that aren t support by the new method.
All current functionality of dpkg-divert will be left intact for use by
sysadmins and for maintainers to catch up with the new system. The two
systems will work together without directly conflicting with each other.
Example Usage #1
The file to be diverted is /usr/share/foo
It needs to be moved to /usr/share/bar
The syntax of the control file would be:
#Start File
Divert-From: /usr/share/foo
Divert-To: /usr/share/bar
#End File
Example Usage #2
In this example the maintainer doesn t want to move the file to any specific
folder
The syntax of the control file would be:
#Start File
Divert-From: /usr/share/foo
#End File
This would divert the file to /usr/share/foo.distrib
Footnotes
-
RFC2822 Guide:
*

Hello, this is the official project report for the Debian GSoC admins and everyone. It s been few days since the official coding phase started. Most of the time I ve been figuring out the details regarding integration of non-x86 images to the Eucalyptus IaaS and working on the ARM image, as you ll learn later. I m also in the process of starting to design the set of tools we ll be delivering as part of the project.
The project s goal is to be a useful resource for Debian developers and porters. I ve joined some porters list in order to learn what are the things they are struggling with and how the project can help to address them. I ll be starting a wiki page with such topics.
Bonding period:
I have been
Doing some work towards Debian Rolling
At the start of the month, the discussions about Debian rolling were still very active on debian-devel. Declaring that testing would be rolling did not make it (as
From a packager s perspective
The implementation of triggers has several consequences on the status that packages can have.
Let s assume that the package A installs a file in a directory that is watched by package B (and that B is currently in the installed state). When A is unpacked, dpkg adds B to its Triggers-Awaited field and lists the activated trigger in B s Triggers-Pending field. Package A is in unpacked state, but B has been changed to triggers-pending .
When A is configured, instead of going to the installed state, it will go to the triggers-awaited state. In that state the package is assumed to NOT fulfill dependencies. However, B which is still in triggers-pending state does fulfill dependencies.
A and B will switch to installed at the same time when the trigger has been processed.
The fact that the triggers-awaited status does not fulfill dependencies means that some common triggers like man-db have to be processed regularly just to be able to ensure dependencies are satisfied before running the postinst of other installed packages.
But a package which ships a manual page can certainly be considered as configured when its postinst has been run even if man-db has not yet updated its cache to know about the new/updated manual page.
When you activate a trigger with the dpkg-trigger command you have an option
The problem
Some programs require root privileges for part of their work: most
notably Debian building tools such as dpkg-buildpackage or pdebuild. So, several command can be used to obtain real or fake root
privileges: su, sudo, fakeroot, etc. Among them, su is quite distinct,
because it only takes a quoted command to pass it to a shell. That is
why its interface is completely incompatible with the others':
I've installed Debian sid in a FreeBSD 8.2 jail and I'm seeing this weird effect: