Merge pull request #358 from vcaputo/handle_relative_etc_localtime

stage1/init: handle relative /etc/localtime symlinks
This commit is contained in:
Jonathan Boulle
2015-01-12 23:51:50 -08:00
+9 -1
View File
@@ -33,15 +33,23 @@ const (
nspawnBin = "/usr/bin/systemd-nspawn"
// Path to the interpreter within the stage1 rootfs
interpBin = "/usr/lib/ld-linux-x86-64.so.2"
// Path to the localtime file/symlink in host
localtimePath = "/etc/localtime"
)
// mirrorLocalZoneInfo tries to reproduce the /etc/localtime target in stage1/ to satisfy systemd-nspawn
func mirrorLocalZoneInfo(root string) {
zif, err := os.Readlink("/etc/localtime")
zif, err := os.Readlink(localtimePath)
if err != nil {
return
}
// On some systems /etc/localtime is a relative symlink, make it absolute
if !filepath.IsAbs(zif) {
zif = filepath.Join(filepath.Dir(localtimePath), zif)
zif = filepath.Clean(zif)
}
src, err := os.Open(zif)
if err != nil {
return