#!/bin/sh
find_ubuntu(){
sourcedir=$1
directdir=$2
if [ -f /var/tmp/ubuntu ];then
rm /var/tmp/ubuntu
fi
touch /var/tmp/ubuntu
if [ -f /var/tmp/ubuntuall ];then
rm /var/tmp/ubuntuall
fi
touch /var/tmp/ubuntuall
find $directdir/lib/ $directdir/usr/lib/ $directdir/usr/local/lib/ $directdir/opt/ ! -type d -name "*.so*" | while read file
do
if [ -z "$file" ];then
continue
fi
ex=`basename $(ls -l $file | awk '{if(($1~/^-/) || ($1~/^l/)) print $8}') | awk -F"." '{print $1}'`
if [ "$ex" != "" ];then
echo $ex>>/var/tmp/ubuntu
echo $file>>/var/tmp/ubuntuall
echo "write $file"
fi
done
}
find_copy(){
sdir=$1
directdir=$2
find $sdir/lib/ $sdir/usr/ ! -type d -name "*.so*" | while read file
do
if [ ! -z `ls -l $file | awk '{if(($1~/^-/) || ($1~/^l/)) print $8}'` ];then
ex=`basename $(ls -l $file | awk '{if(($1~/^-/) || ($1~/^l/)) print $8}') | awk -F"." '{print $1}'`
if [ "$ex" != "" ];then
grep -q "\<$ex" /var/tmp/ubuntu
if [ "$?" -eq "1" ];then
dname=`dirname $file`
tmpdir=`echo "$dname $sdir" | awk '{print substr($1,1+length($2))}'`
echo "$tmpdir"
if [ ! -d $directdir/$tmpdir ];then
mkdir -p $directdir/$tmpdir
fi
echo "h3 lib $file"
cp -a $file $directdir/$tmpdir
else
dname=`dirname $file`
tmpdir=`echo "$dname $sdir" | awk '{print substr($1,1+length($2))}'`
if [ ! -z `echo $tmpdir | grep "^/"` ];then
tmpdir=`echo $tmpdir | awk '{print substr($1,2)}'`
fi
ex=$tmpdir/$ex
grep -q "\<$ex" /var/tmp/ubuntuall
if [ "$?" -eq "1" ];then
if [ ! -d $directdir/$tmpdir ];then
mkdir -p $directdir/$tmpdir
fi
cp -a $file $directdir/$tmpdir
fi
fi
fi
fi
done
}
if [ -z "$1" -o -z "$2" ];then
echo "error:lack of parameter"
echo "usage:sh h3only.sh sourcedir dirctdir"
echo "sourcedir"
echo " intel filesystem directory"
echo "directdir"
echo " your filesystem dirctory"
exit 1
fi
if [ ! -d $1 ];then
echo "$1 is not exits"
exit 1
fi
sourcedir=`realpath $1`
echo "source dir $sourcedir"
if [ ! -d $2 ];then
mkdir -p $2
fi
directdir=`realpath $2`
echo "direct dir $directdir"
find_ubuntu $sourcedir $directdir
compiledir=$sourcedir/build_i686/staging_dir/
compiledir=`realpath $compiledir`
find_copy $compiledir $directdir
rootdir=$sourcedir/project_build_i686/IntelCE/root/
rootdir=`realpath $rootdir`
find_copy $rootdir $directdir
find_ubuntu(){
sourcedir=$1
directdir=$2
if [ -f /var/tmp/ubuntu ];then
rm /var/tmp/ubuntu
fi
touch /var/tmp/ubuntu
if [ -f /var/tmp/ubuntuall ];then
rm /var/tmp/ubuntuall
fi
touch /var/tmp/ubuntuall
find $directdir/lib/ $directdir/usr/lib/ $directdir/usr/local/lib/ $directdir/opt/ ! -type d -name "*.so*" | while read file
do
if [ -z "$file" ];then
continue
fi
ex=`basename $(ls -l $file | awk '{if(($1~/^-/) || ($1~/^l/)) print $8}') | awk -F"." '{print $1}'`
if [ "$ex" != "" ];then
echo $ex>>/var/tmp/ubuntu
echo $file>>/var/tmp/ubuntuall
echo "write $file"
fi
done
}
find_copy(){
sdir=$1
directdir=$2
find $sdir/lib/ $sdir/usr/ ! -type d -name "*.so*" | while read file
do
if [ ! -z `ls -l $file | awk '{if(($1~/^-/) || ($1~/^l/)) print $8}'` ];then
ex=`basename $(ls -l $file | awk '{if(($1~/^-/) || ($1~/^l/)) print $8}') | awk -F"." '{print $1}'`
if [ "$ex" != "" ];then
grep -q "\<$ex" /var/tmp/ubuntu
if [ "$?" -eq "1" ];then
dname=`dirname $file`
tmpdir=`echo "$dname $sdir" | awk '{print substr($1,1+length($2))}'`
echo "$tmpdir"
if [ ! -d $directdir/$tmpdir ];then
mkdir -p $directdir/$tmpdir
fi
echo "h3 lib $file"
cp -a $file $directdir/$tmpdir
else
dname=`dirname $file`
tmpdir=`echo "$dname $sdir" | awk '{print substr($1,1+length($2))}'`
if [ ! -z `echo $tmpdir | grep "^/"` ];then
tmpdir=`echo $tmpdir | awk '{print substr($1,2)}'`
fi
ex=$tmpdir/$ex
grep -q "\<$ex" /var/tmp/ubuntuall
if [ "$?" -eq "1" ];then
if [ ! -d $directdir/$tmpdir ];then
mkdir -p $directdir/$tmpdir
fi
cp -a $file $directdir/$tmpdir
fi
fi
fi
fi
done
}
if [ -z "$1" -o -z "$2" ];then
echo "error:lack of parameter"
echo "usage:sh h3only.sh sourcedir dirctdir"
echo "sourcedir"
echo " intel filesystem directory"
echo "directdir"
echo " your filesystem dirctory"
exit 1
fi
if [ ! -d $1 ];then
echo "$1 is not exits"
exit 1
fi
sourcedir=`realpath $1`
echo "source dir $sourcedir"
if [ ! -d $2 ];then
mkdir -p $2
fi
directdir=`realpath $2`
echo "direct dir $directdir"
find_ubuntu $sourcedir $directdir
compiledir=$sourcedir/build_i686/staging_dir/
compiledir=`realpath $compiledir`
find_copy $compiledir $directdir
rootdir=$sourcedir/project_build_i686/IntelCE/root/
rootdir=`realpath $rootdir`
find_copy $rootdir $directdir