Linux札记: 3.根切换chroot与shell scripts初体验

这就需要我们把原属于/bin中的可执行命令(如ls mkdir等)拷到自己新建的bin文件夹中去,而且其依赖文件通过ldd命令找去后,也要拷到相应的位置。问题是每一个可执行命令都对应着好几个依赖项,如果纯手工去敲ldd再一个个cp的话,得敲到猴年马月去。
于是下午我就现学现用了一把,用shell scripts实现了一个自动的部署。

# used to put the lib in the right place
# Date: 2010/2/28 4:00PM
# Made by Xie Chuang

cmddir=`which $cmd`
if [ ! -d .`dirname $cmddir` ];then
	mkdir .`dirname $cmddir`
cp $cmddir .$cmddir
libdirs1=`ldd $cmddir | grep "=>" | cut -d " " -f 3 | sort | uniq`
libdirs2=`ldd $cmddir | grep -v "=>" | cut -d " " -f 1 | sort | uniq`
libdirs="$libdirs1"" ""$libdirs2"
for i in $libdirs
	if [ ! -d ".`dirname $i`" ]; then
		mkdir -p .`dirname $i`
	if [ ! -e .$i ]; then
                echo $i has been moved to the right place
                cp $i .$i

5 Responses

  1. We examined each card’s sequential and random read/write efficiency in a Google Have fun with Edition Samsung Galaxy S4 making use
    of A1 SD Bench It is possible to read more about the benchmark
    and how it works at the A1:dev website We also ran CrystalDiskMark , a benchmarking program designed to analyze sequential and random study and write speeds on solid-state storage.

  2. as an alternative United states health ID, Lauren’s Hope is another organization that
    introduce trendy health identification (ID) products for men, females and kids.
    Their particular previously- increasing line of medical ID bracelets along with other jewelries are always on-trend, made to the greatest
    quality and guaranteed to satisfy clients’ requirements
    and expectations. They’re some sources of medical ID bracelets that will not
    change your performance to be even worse at all.
    Infinitive like In Rose Gold healthcare ID Bracelet- This bracelet features a rose tone
    plated infinity icon combined with rose tone plated metal rolo sequence on either end.

  3. The hassle of recharging and putting the batteries back in, scare offf most people from ever wanting to invest
    in a wireless camera liike this, so if you. If you are
    interested in some useful Digital Photography Classes, than you are in the right
    place. This is crucial to those hunting to not disturb sensitive creatures.

    my web sikte – sigma 200-500Mm

Leave a Reply

Your email address will not be published. Required fields are marked *