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