daily pastebin goal
41%
SHARE
TWEET

v7clean utility script

mpthompson May 2nd, 2012 1,936 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. v7clean -- script to verify that a .deb and .udeb files are clean from armv7 code using the 'readelf' Linux utility. To use:
  2.  
  3. 1. Copy the following shell script code into a file named 'v7clean'.
  4. 2. Use 'chmod 755 vclean' to make the file executable.
  5. 3. Run the utility passing one or more .deb or .udeb files on the command line.
  6.  
  7. --------------------------------------------------------
  8. #!/bin/sh
  9.  
  10. working=/tmp/dpkg-v7clean_$$
  11. v6tmp=$working/v6count
  12. v7tmp=$working/v7count
  13. othertmp=$working/othercount
  14.  
  15. mkdir $working
  16.  
  17. # Loop over each argument.
  18. for package in "$@"
  19. do
  20.         cat /dev/null > $v6tmp
  21.         cat /dev/null > $v7tmp
  22.         cat /dev/null > $othertmp
  23.  
  24.         package_file=`basename $package`
  25.         cwd=`pwd`
  26.         cd `dirname $package`
  27.         package_path=`pwd`/$package_file
  28.         cd $cwd
  29.  
  30.         cd $working
  31.         ar x $package_path
  32.         cd $cwd
  33.  
  34.         test -d $working/data && rm -rf $working/data
  35.         mkdir $working/data
  36.  
  37.         if [ -f $working/data.tar.gz ]; then
  38.                 tar xzf $working/data.tar.gz -C $working/data
  39.         elif [ -f $working/data.tar.bz2 ]; then
  40.                 tar xjf $working/data.tar.bz2 -C $working/data
  41.         elif [ -f $working/data.tar.xz ]; then
  42.                 tar xJf $working/data.tar.xz -C $working/data
  43.         else
  44.                 echo "Uknown data format."
  45.                 exit 1
  46.         fi
  47.  
  48.         find $working/data -type f -print0 | xargs -0 file /dev/null |
  49.                 grep '\(ELF\|ar archive\)' |
  50.                 sed 's/:.*//' |
  51.                 while read filename
  52.         do
  53.                 readelf -A $filename |
  54.                         grep 'Tag_CPU_arch:' |
  55.                         sed 's|.*:\W\+\(\w\+\).*|\1|' |
  56.                         while read arch
  57.                 do
  58.                         case $arch in
  59.                                 v6 )    echo "ARMv6" >> $v6tmp
  60.                                         ;;
  61.                                 v7 )    echo "ARMv7" >> $v7tmp
  62.                                         # echo $filename
  63.                                         ;;
  64.                                 * )     echo "other" >> $othertmp
  65.                                         ;;
  66.                         esac
  67.                 done
  68.         done
  69.         v6count=`cat $v6tmp | wc -l`
  70.         v7count=`cat $v7tmp | wc -l`
  71.         othercount=`cat $othertmp | wc -l`
  72.  
  73.         if [ $v7count -gt '0' ]; then
  74.                 echo v7_dirty $package_file
  75.         else
  76.                 echo v7_clean $package_file
  77.         fi
  78.         # echo $package_file "ARMv6=${v6count} ARMv7=${v7count} other=${othercount}"
  79.  
  80.         rm -f $working/data.tar.*
  81.         rm -f $working/control.tar.*
  82. done
  83.  
  84. rm -rf $working
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top