github.com/shaardie/u-root@v4.0.1-0.20190127173353-f24a1c26aa2e+incompatible/pkg/uroot/util/urootpath.go (about)

     1  // Copyright 2015-2017 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package util
     6  
     7  import (
     8  	"os"
     9  	"path/filepath"
    10  )
    11  
    12  var root = os.Getenv("UROOT_ROOT")
    13  
    14  // UrootPath returns the full path for a uroot file with
    15  // the UROOT_ROOT environment variable taken into account.
    16  // It returns a proper value if UROOT_ROOT is not set.
    17  // u-root was built to assume everything is rooted at /,
    18  // and in most cases that is still true.
    19  // But in hosted mode, e.g. on developer mode chromebooks,
    20  // it's far better if u-root can be rooted in /usr/local,
    21  // so successive kernel/root file system upgrades
    22  // do not wipe it out.
    23  func UrootPath(n ...string) string {
    24  	return filepath.Join("/", root, filepath.Join(n...))
    25  }