From 9bc1d750a05cc4efec0f1b9f4384bfd12d73daa3 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Fri, 7 Nov 2003 12:50:05 +0000 Subject: better handle etc files: scan a/c/mtime after copying all /etc files to list the ones which are read and written, make it a file list and be assured to have those when initing move --- move/move.pm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'move/move.pm') diff --git a/move/move.pm b/move/move.pm index 8354ebbe9..f2ffd6ddb 100644 --- a/move/move.pm +++ b/move/move.pm @@ -17,9 +17,25 @@ sub symlinkf_short { if (my $l = readlink $dest) { $dest = $l if $l =~ m!^/!; } + -d $file and log::l("$file already exists and is a directory! writing in directory may be needed, not overwriting"), return; symlinkf($dest, $file); } +sub handle_etcfiles { + my (@allowed_modes) = @_; + #- non-trivial files listed from tools/scan-etc.pl + foreach (chomp_(cat_('/image/move/etcfiles'))) { + my $mode if 0; + m|^# (\S+)| and $mode = $1; + m|^/| && member($mode, @allowed_modes) and do { + $mode eq 'READ' && !-e $_ and symlinkf_short("/image$_", $_); + $mode eq 'OVERWRITE' and system("cp /image$_ $_"); #- need copy contents + $mode eq 'DIR' and mkdir_p $_; + } + } + +} + #- run very soon at stage2 start, setup things on tmpfs rw / that #- were not necessary to start stage2 itself (there were setup #- by stage1 of course) @@ -40,6 +56,9 @@ sub init { mkdir_p("/etc/$_"), system("cp -R /image/etc/$_/* /etc/$_") foreach qw(cups profile.d sysconfig/network-scripts devfs/conf.d); + + #- directories we badly need as non-links because files will be written in + handle_etcfiles('DIR'); #- for /etc/sysconfig/networking/ifcfg-lo mkdir "/etc/sysconfig/networking"; @@ -54,6 +73,9 @@ sub init { symlinkf_short("/image/etc/X11/$_", "/etc/X11/$_") foreach qw(encodings.dir app-defaults applnk fs lbxproxy proxymngr rstart wmsession.d xinit.d xinit xkb xserver xsm); + #- non-trivial files/directories that need be readable, files that will be overwritten + handle_etcfiles('READ', 'OVERWRITE'); + #- create remaining /etc and /var subdirectories if not already copied or symlinked, #- because programs most often won't try to create the missing subdir before trying #- to write a file, leading to obscure unexpected failures -- cgit v1.2.1