| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- <!doctype texinfo system "texinfo.dtd" [
- <!entity % manuals-version-def system "manuals-version">
- %manuals-version-def;
- ]>
- <texinfo>
- <setfilename>internals.info</>
- <titlepage>
- <title>dpkg Internals Manual</title>
- <author>Klee Dienes</author>
- <date>Version &manuals-version; (dpkg &dpkg-version;)</date>
- <abstract>
- This manual describes the internal structure of the <code/dpkg/ package
- management system.
- </abstract>
- </titlepage>
- <chapter>Copyright
- <p>
- Copyright ©1997 Klee Dienes <samp/<klee@@mit.edu>/.
- <p>
- This manual is free software; you may redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2, or (at your option) any
- later version.
- <p>
- This is distributed in the hope that it will be useful, but
- <em>without any warranty</em>; without even the implied warranty of
- merchantability or fitness for a particular purpose. See the GNU
- General Public License for more details.
- You should have received a copy of the GNU General Public License with
- your Debian GNU/Linux system, in <file>/usr/share/common-licenses/GPL</>, or
- with the <code/dpkg/ source package as the file <file>COPYING</>. If
- not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- Cambridge, MA 02139, USA.
- </chapter>
- <chapter>Build Notes
- <section>Automake
- <p>
- This chapter by Tom Lees <tom&at;lpsg.demon.co.uk> on Tue, 4 Mar 1997
- 21:34:57 +0000, with subsequent modifications by Klee Dienes <klee&at;debian.org>
- <p>
- This chapter contains general notes about the conversion to
- <code/automake/. If you plan on doing anything with <code/dpkg/, you
- should probably read all of this file first. You have been warned.
- <p>
- The current version of automake used is version <code/automake-1.1n/,
- which is currently a beta version. It has several significant
- advantages over the released version, including:
- <itemize>
- <item>it supports emacs lisp properly
- <item>It supports libtool properly
- <item>it includes the aclocal utility
- </itemize>
- <p>
- The <code/aclocal/ utility is a very useful program which will automatically
- build an <file/aclocal.m4/ file from the <file/configure.in/ file to include the
- appropriate macros.
- <p>
- <code/automake-1.1n/ can be retreived from
- <file>ftp://ftp.cygnus.com/pub/tromey</file>
- <p>
- This doesn't affect anything other than rebuilding the <file/Makefile.in/ files
- from the sources.
- <p>
- Probably the main difference which is noticable is that instead of
- using proprietary directory names, it now supports <code/configure
- --sharedstatedir/, and <code/configure --localstatedir/. To set these
- to the Debian defaults, you should use <code>./configure
- --localstatedir=/etc --sharedstatedir=/var/lib</>.
- <p>
- I have also customized the canonicalizing macros found in
- <code/autoconf-2.12/ to include the old way of finding the <code/dpkg/
- ``architecture'', i.e. to be a bit more smart. Instead of it trying to
- determine the architecture only, I changed it to use the `host',
- `build', and `target' system types. The target CPU type is checked
- against the archtable to find the architecture on which dpkg will run.
- <p>
- It uses <code/gcc --print-libgcc-file-name/ to find out the build
- architecture if possible (used later to determine ELF or <code/a.out/
- format), and also uses <code/dpkg --print-architecture/ if possible to
- modify the <samp/cpu/ field before it passes on the target alias to
- config.sub. If you want to specify the architecture, you should now
- use "--target=", rather than <code/--with-arch/, which was essentially
- a hack anyway. The old <code/--with-arch/ is still there, but it is
- somewhat less functional. I have also moved the <code/DPKG_CACHED_/
- macros into dpkg.m4 to make configure.in a bit more readable.
- <p>
- I also converted to libtool 0.7 (which can be found in the Debian
- distribution now). Essentially, this means that all the dpkg tools can
- be compiled against a shared <samp/libdpkg/ without much hassle (in
- fact, it is the default). You do not need to install libtool to use
- this feature (it works like autoconf), and generally, it should not be
- needed much at all.
- <p>
- The new <samp/dist/ targets will build a distribution including all
- files built by the <code/debiandoc2html/, <code/debiandoc2ps/, etc.,
- which are included in the distribution so that people may build <code/dpkg/
- without these (especially useful to porters).
- <p>
- A target <samp/make debian/ has been added, which will build the
- Debian files from a working directory (does a <samp/make dist/
- first). Now all we need is a modified dpkg-source so that the
- <file/dpkg-1.4.0.8.tar.gz/ GNU-distribution file can be used as part
- of the Debian dsitribution. I'm working on this, but it doesn't work
- too well at the moment (find it in examples).
- <p>
- I removed the <samp/make portable/ target - it doesn't do anything useful.
- <p>
- I have added <samp/make uninstall/ targets to aid non-Debian users who simply
- want to try out certain Debian packages, and the "dist" targets are also
- useful to build a "distribution" of the dpkg tool. Note that since automake
- automatically includes dependencies into the Makefiles in a distribution,
- if you want to modify the C files, it would be advisable to get and install
- automake, and then re-run it in the base dpkg distribution directory, so that
- automatic dependency generation will be switched back on, and any
- dependencies which change will be taken account of. The "make maintainer-clean"
- targets will remove all files which any of the following utilities create:
- <itemize>
- <item>automake
- <item>autoconf
- <item>aclocal
- <item>autoheader
- <item>gettextize
- <item>libtoolize
- </itemize>
- <p>
- If you want to modify any of the sources, I recommend that you do the following
- first (after having installed the appropriate utilities, of course):-
- <itemize>
- <item>
- make maintainer-clean
- <item>
- aclocal
- <item>
- autoheader
- <item>
- autoconf
- <item>
- gettextize
- <item>
- libtoolize (do not let automake run this, as it will cause it not to
- include the libtool files in the dist targets)
- <item>
- for i in COPYING INSTALL; do ln -s /usr/share/automake/$i .; done
- <item>
- automake
- </itemize>
- <p>
- I have also incorporated the patches originally made by Galen
- Hazelwood to internationalize dpkg using GNU gettext - see the file
- "NOTES.intl" for more information about this.
- <p>
- Other minor changes are:
- <itemize>
- <item>
- The version number is now determined from debian/changelog, not from
- the directory name.
- <item>
- Creation of version.h now handled from configure script, not Makefile.
- <item>
- include/dpkg.h is now generated from include/dpkg.h.in by a sed
- script, inserting the appropriate directory definitions - so now it
- supports changing the dpkg directories (can install in /usr/local)
- <item>
- Updated the COPYING (1 very minor change) and INSTALL files to those
- distributed with automake-1.1l
- <item>
- Since the shared libdpkg is now installed, I also made
- include/Makefile install dpkg.h and dpkg-db.h into /usr/include by
- default
- </itemize>
- Questions:
- <itemize>
- <item>
- Should I use <samp/localstatedir/ and <samp/sharedstatedir/ instead of
- <samp/sysconfdir/ and <samp/datadir/?
- </itemize>
- </section>
- <section>Internationalization
- <p>
- This section by Galen Hazelwood.
- <p>
- Dpkg is, to say the least, generous in its error reporting. The vast
- majority of the output strings are error messages of one kind or another.
- And if you feel that you've stumbled into the Department of Redundancy
- Department, you would be absolutely correct. Many of the error messages
- in dpkg.pot are duplicates, used at different points in the program.
- <p>
- To avoid swamping the translators completely, I made some executive decisions
- on what kinds of strings to translate. All the strings sent to debug() are
- left alone, on the grounds that these are for dpkg developers, and not for
- the general public. Most interal error messages were very cryptic, and
- would probably confuse the translators when seen just sitting there in
- the dpkg.pot file, and are also left alone. (I did mark some of the more
- verbose ones for translation.)
- <p>
- If others disagree with me about the necessity of translating these strings,
- it's easy enough to just go through and mark them later.
- <p>
- I added the startup gettext code to the main routine in dselect, which was
- necessary as many of the strings in lib are translated. Dselect is otherwise
- unchanged.
- <p>
- Changes:
- <itemize>
- <item>
- The files in intl and po were taken from gettext 0.10.26, by way of
- the gettextize program. I altered the makefiles to remove the VERSION
- symbol, which is only used in targets which dpkg does not support.
- <item>
- aclocal.m4 was stolen from the textutils package, configure.in was
- altered to use these new tests, symbols were added to acconfig.h, and
- the two new directories were added to Makefile.in.
- <item>
- The dpkg, dpkg-deb, md5sum, split, and dselect Makefiles now look for
- headers in ../intl, and try to link with whatever i18n libraries
- configure finds. They also now define LOCALEDIR in CFLAGS.
- <item>
- include/dpkg.h has the necessary NLS boilerplate, and the only file
- which dosen't include this (md5sum/md5sum.c) had it added directly.
- <item>
- The most intrusive change is due to a disagreement between xgettext
- and the dpkg coding style. Although xgettext understands string
- constant concatenation, it can't handle the case where preprocessor
- symbols are used as well. The dpkg code uses this a lot, especially
- in cases like this:
- <example>
- ohshite("error reading from " BACKEND " pipe");
- </example>
- where BACKEND is defined as "dpkg-deb". Because xgettext can't handle
- this, I have changed this usage in all cases to something like:
- <example>
- ohshite(_("error reading from dpkg-deb pipe");
- </example>
- This isn't very kind to Ian, I know. But what can I do?
- </itemize>
- </section>
- </chapter>
- <chapter>Code Internals
- <section>Structure Definitons
- <subsection>versionrevision
- <p>
- <example>
- struct versionrevision @{
- unsigned long epoch;
- char *version;
- char *revision;
- @};
- </example>
- <p>
- The <tt/versionrevision/ structure is used to store a Debian version specification
- </subsection>
- </section>
- <section>Functions
- <subsection>Parsing translation tables
- <p>
- Each of these tables is used to associate a set of strings with a
- corresponding set of integers.
- Current tables are:
- <p>
- <example>
- const struct namevalue booleaninfos[];
- </example>
- <p>
- Maps boolean strings (<code/"yes"/,<code/"no"/) to their binary values.
- <subsubsection><code/priorityinfos[]/
- <p>
- <example>
- const struct namevalue priorityinfos[];
- </example>
- <p>
- Maps priority strings to and from values of
- type <code/enum pkgpriority/.
- Current priority values are:
- <table>
- <item><code/required/</item>
- required
- <item><code/important/</item>
- important
- <item><code/standard/</item>
- standard
- <item><code/recommended/</item>
- recommended
- <item><code/optional/</item>
- optional
- <item><code/extra/</item>
- extra
- <item><code/contrib/</item>
- contrib
- <item><code/other/</item>
- other
- <item><code/unknown/</item>
- unknown
- <item><code/base/</item>
- This is obsolete, but is accepted as an alias for <code/required/.
- </table>
- </subsubsection>
- <subsubsection><code/statusinfos[]/
- <p>
- <example>
- const struct namevalue statusinfos[];
- </example>
- Maps package status strings to values of type <code/enum ???/.
- Package status strings are:
- "not-installed" "unpacked" "half-configured" "installed"
- "half-installed" "config-files" "postinst-failed" "removal-failed"
- </subsubsection>
- <subsubsection><code/eflaginfos[]/
- <p>
- <example>
- const struct namevalue eflaginfos[];
- </example>
- </subsubsection>
- <subsubsection><code/wantinfos[]/
- <p>
- <example>
- const struct namevalue wantinfos[];
- </example>
- </subsubsection>
- <subsubsection><code/nicknames[]/
- <p>
- <example>
- const struct nickname nicknames[];
- </example>
- Maps obsolete control fields to their current versions.
- </subsubsection>
- </subsection>
- <subsection>Parsing functions
- <subsubsection><code/parseerr/
- <findex/parseerr()/
- <p>
- <example>
- void parseerr
- (FILE *file, const char *filename, int lno,
- FILE *warnto, int *warncount, const struct pkginfo *pigp,
- int warnonly, const char *fmt, ...);
- </example>
- Report an error parsing a control data stream. Checks <var/file/ for
- error status on <var/file/, printing an error message to stderr and
- exiting with error status if an error is present on the stream.
- Formats the variable arguments according to the <code/printf/-style
- string in <var/fmt/, preceding the result with <var/filename/,
- <var/lno/, and <var/pigp/ (if not NULL). If <var/warnonly/ is 0,
- writes the result to stderr and exits with error status. Otherwise,
- increments <var/warncount/ and returns normally.
- </subsubsection>
- <subsubsection><code/illegal_packagename/
- <findex/illegal_packagename()/
- <p>
- <example>
- const char *illegal_packagename
- (const char *p, const char **ep)
- </example>
- Checks the package name at <var/p/ for proper syntax. Returns NULL in
- case of success, setting <var/*ep/ to point after the last character
- in the package name, including any trailing whitespace (as defined by
- isspace()). In case of error, returns the error message as a pointer
- to a static buffer.
- </subsubsection>
- <subsubsection><code/informativeversion/
- <findex/informativeversion()/
- <p>
- <example>
- int informativeversion(const struct versionrevision *version)
- </example>
- <p>
- Returns true if and only if the <code/versionrevision/ is non-empty;
- otherwise returns false.
- </subsubsection>
- <subsubsection><code/varbufversion/
- <findex/varbufversion()/
- <p>
- <example>
- void varbufversion
- (struct varbuf *vb,
- const struct versionrevision *version,
- enum versiondisplayepochwhen vdew);
- </example>
- Writes a human-readable representation of <var/version/ to <var/vb/.
- Possible values of <var/vdew/:
- <table>
- <item><tt/vdew_never/</item>
- never include epoch
- <item><tt/vdew_nonambig/</item>
- include epoch string if non-zero
- <item><tt/vdew_always/</item>
- always include epoch string
- </table>
- </subsubsection>
- <subsubsection><code/versiondescribe/
- <findex/versiondescribe()/
- <p>
- <example>
- const char *versiondescribe
- (const struct versionrevision *version,
- enum versiondisplayepochwhen vdew);
- </example>
- <p>
- Return a human-readable representation of <var/version/ as a pointer
- to a static buffer. If the version structure is empty, return
- <code/"<none>"/. Static buffers are allocated from a set of 10
- in round-robin fashion (they will be re-used after 10 successive calls
- to <code/versiondescribe/).
- </subsubsection>
- <subsubsection><code/parseversion/
- <findex/parseversion()/
- <p>
- <example>
- const char *parseversion
- (struct versionrevision *rversion, const char *string);
- </example>
- <p>
- Parse the contents of <var/string/ into <var/rversion/. If
- successful, returns NULL, otherwise returns a pointer to a static
- error string.
- </subsubsection>
- <subsubsection><code/parsemustfield/
- <findex/parsemustfield()/
- <p>
- <example>
- void parsemustfield
- (FILE *file, const char *filename, int lno,
- FILE *warnto, int *warncount,
- const struct pkginfo *pigp, int warnonly,
- char **value, const char *what);
- </example>
- </subsubsection>
- <subsubsection><code/skip_slash_dotslash/
- <findex/skip_slash_dotslash()/
- <p>
- <example>
- const char *skip_slash_dotslash (const char *p);
- </example>
- </subsubsection>
- <subsubsection><code/convert_string/
- <findex/convert_string()/
- <p>
- <example>
- static int convert_string
- (const char *filename, int lno, const char *what, int otherwise,
- FILE *warnto, int *warncount, const struct pkginfo *pigp,
- const char *startp, const struct namevalue *nvip,
- const char **endpp)
- </example>
- </subsubsection>
- </subsection>
- </section>
- <contents>
- <printindex name="fn">
- </texinfo>
|