forked from ungleich-public/cdist
[type/__debconf_set_selections] Synchronise objects
Works around locking error: debconf: DbDriver "config": /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
This commit is contained in:
parent
9cf19388ab
commit
a42ebc7a78
2 changed files with 19 additions and 1 deletions
|
@ -41,10 +41,15 @@ test -s "${linesfile}" || {
|
|||
exit 0
|
||||
}
|
||||
|
||||
# assert __type_explorer is set (because it is used by the Perl script)
|
||||
: "${__type_explorer:?}"
|
||||
|
||||
/usr/bin/perl -- - "${linesfile}" <<'EOF'
|
||||
use strict;
|
||||
use warnings "all";
|
||||
|
||||
use Fcntl qw(:DEFAULT :flock);
|
||||
|
||||
use Debconf::Db;
|
||||
use Debconf::Question;
|
||||
|
||||
|
@ -78,7 +83,20 @@ sub state {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
# Load Debconf DB but manually lock on the state explorer script,
|
||||
# because Debconf aborts immediately if executed concurrently.
|
||||
# This is not really an ideal solution because the Debconf DB could be locked by
|
||||
# another process (e.g. apt-get), but no way to achieve this could be found.
|
||||
# If you know how to, please provide a patch.
|
||||
my $lockfile = "%ENV{'__type_explorer'}/state";
|
||||
if (open my $lock_fh, '+<', $lockfile) {
|
||||
flock $lock_fh, LOCK_EX or die "Cannot lock $lockfile";
|
||||
}
|
||||
{
|
||||
Debconf::Db->load(readonly => 'true');
|
||||
}
|
||||
|
||||
|
||||
while (<>) {
|
||||
# Read and process lines (taken from debconf-set-selections)
|
||||
|
|
0
cdist/conf/type/__debconf_set_selections/nonparallel
Normal file
0
cdist/conf/type/__debconf_set_selections/nonparallel
Normal file
Loading…
Reference in a new issue