github.com/mvdan/u-root-coreutils@v0.0.0-20230122170626-c2eef2898555/cmds/core/lddfiles/lddfiles_linux.go (about)

     1  // Copyright 2009-2018 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  // lddfiles prints the arguments and all .so dependencies of those arguments
     6  //
     7  // Description:
     8  //
     9  //	lddfiles prints the arguments on the command line and all .so's
    10  //	on which they depend. In some cases, those .so's are actually symlinks;
    11  //	in that case, the symlink and its value are printed.
    12  //	lddfiles can be used to package up a command for tranporation to
    13  //	another machine, e.g.
    14  //	scp `lddfiles /usr/bin/*` remotehost:/
    15  //	will let you copy all of /usr/bin, and all needed libraries. to a remote
    16  //	host.
    17  //	lddfiles /usr/bin/* | cpio -H newc -o > /tmp/x.cpio
    18  //	lets you easily prepare cpio archives, which can be included in a kernel
    19  //	or similarly scp'ed to another machine.
    20  package main
    21  
    22  import (
    23  	"fmt"
    24  	"log"
    25  	"os"
    26  
    27  	"github.com/mvdan/u-root-coreutils/pkg/ldd"
    28  )
    29  
    30  func main() {
    31  	l, err := ldd.Ldd(os.Args[1:])
    32  	if err != nil {
    33  		log.Fatalf("ldd: %v", err)
    34  	}
    35  
    36  	for _, dep := range l {
    37  		fmt.Printf("%s\n", dep.FullName)
    38  	}
    39  }