Skip to content

Commit

Permalink
Replace symlink forest targets with relative path
Browse files Browse the repository at this point in the history
It makes easier to handle unpacked image files. The symlinks point to
the image's location, rather than to system directories.
  • Loading branch information
thomasfsteeples authored and anatol committed Nov 2, 2022
1 parent 2b49c7c commit e13aa77
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions generator/generator.go
Expand Up @@ -243,22 +243,23 @@ func generateInitRamfs(conf *generatorConfig) error {
// appendCompatibilitySymlinks appends symlinks for compatibility with older firmware that loads extra files from non-standard locations
func appendCompatibilitySymlinks(img *Image) error {
symlinks := []struct{ src, target string }{
{"/lib", "/usr/lib"},
{"/usr/local/lib", "/usr/lib"},
{"/usr/sbin", "/usr/bin"},
{"/bin", "/usr/bin"},
{"/sbin", "/usr/bin"},
{"/usr/local/bin", "/usr/bin"},
{"/usr/local/sbin", "/usr/bin"},
{"/var/run", "/run"},
{"/usr/lib64", "/usr/lib"},
{"/lib64", "/usr/lib"},
{"/lib", "usr/lib"},
{"/usr/local/lib", "../lib"},
{"/usr/sbin", "bin"},
{"/bin", "usr/bin"},
{"/sbin", "usr/bin"},
{"/usr/local/bin", "../bin"},
{"/usr/local/sbin", "../bin"},
{"/var/run", "../run"},
{"/usr/lib64", "lib"},
{"/lib64", "usr/lib"},
}

for _, l := range symlinks {
// Ensure that target always exist which may not be the
// case if we only install files from /lib or /bin.
if err := img.AppendDirEntry(l.target); err != nil {
targetDir := filepath.Dir(filepath.Join(filepath.Dir(l.src), l.target))
if err := img.AppendDirEntry(targetDir); err != nil {
return err
}

Expand Down

0 comments on commit e13aa77

Please sign in to comment.