forked from josch/mmdebstrap
if /etc/machine-id exists, replace by an empty file
This commit is contained in:
parent
9eaacca795
commit
bef4c890d8
1 changed files with 16 additions and 0 deletions
16
mmdebstrap
16
mmdebstrap
|
@ -2290,6 +2290,22 @@ sub setup {
|
||||||
unlink $path or error "cannot unlink $path: $!";
|
unlink $path or error "cannot unlink $path: $!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (-e "$options->{root}/etc/machine-id") {
|
||||||
|
# from machine-id(5):
|
||||||
|
# For operating system images which are created once and used on
|
||||||
|
# multiple machines, for example for containers or in the cloud,
|
||||||
|
# /etc/machine-id should be an empty file in the generic file system
|
||||||
|
# image. An ID will be generated during boot and saved to this file if
|
||||||
|
# possible. Having an empty file in place is useful because it allows a
|
||||||
|
# temporary file to be bind-mounted over the real file, in case the
|
||||||
|
# image is used read-only.
|
||||||
|
unlink "$options->{root}/etc/machine-id"
|
||||||
|
or error "cannot unlink /etc/machine-id: $!";
|
||||||
|
open my $fh, '>', "$options->{root}/etc/machine-id"
|
||||||
|
or error "failed to open(): $!";
|
||||||
|
close $fh;
|
||||||
|
}
|
||||||
|
|
||||||
# remove any possible leftovers in /tmp but warn about it
|
# remove any possible leftovers in /tmp but warn about it
|
||||||
if (-d "$options->{root}/tmp") {
|
if (-d "$options->{root}/tmp") {
|
||||||
opendir(my $dh, "$options->{root}/tmp")
|
opendir(my $dh, "$options->{root}/tmp")
|
||||||
|
|
Loading…
Reference in a new issue