build: Add infrastructure for bash-completions
[dpkg.git] / doc / spec / frontend-api.txt
blob5f25741bac81d27ee7c36b33a3394b45b6e5f04c
1 Frontend Interfaces
2 ===================
4 Status: recommendation, stable
7 Overview
8 --------
10 This file will try to document some of the interfaces that dpkg makes
11 available to frontends or that expects them to use, which are currently
12 not covered by any other type of documentation.
15 Database Locking
16 ----------------
18 Any frontend needing to make sure no write operation is currently happening,
19 and no other frontend is running should first acquire the frontend lock at
20 «<admindir>/lock-frontend», and then acquire the dpkg database lock at
21 «<admindir>/lock». When the frontend invokes dpkg, it should set the
22 environment variable DPKG_FRONTEND_LOCKED (to prevent dpkg from acquiring
23 the frontend lock), and then release the dpkg database lock, which will be
24 acquired by dpkg itself. This way no other frontend following this protocol
25 can race to perform operations while another one has one in progress.
27 These locks must be file record locks (i.e. fcntl(2) advisory locking), and
28 the whole file should be locked, as that's the most portable way to perform
29 this operation; this can be achieved by using start=0, len=0 and
30 whence=SEEK_SET.