Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- v7clean -- script to verify that a .deb and .udeb files are clean from armv7 code using the 'readelf' Linux utility. To use:
- 1. Copy the following shell script code into a file named 'v7clean'.
- 2. Use 'chmod 755 vclean' to make the file executable.
- 3. Run the utility passing one or more .deb or .udeb files on the command line.
- --------------------------------------------------------
- #!/bin/sh
- working=/tmp/dpkg-v7clean_$$
- v6tmp=$working/v6count
- v7tmp=$working/v7count
- othertmp=$working/othercount
- mkdir $working
- # Loop over each argument.
- for package in "$@"
- do
- cat /dev/null > $v6tmp
- cat /dev/null > $v7tmp
- cat /dev/null > $othertmp
- package_file=`basename $package`
- cwd=`pwd`
- cd `dirname $package`
- package_path=`pwd`/$package_file
- cd $cwd
- cd $working
- ar x $package_path
- cd $cwd
- test -d $working/data && rm -rf $working/data
- mkdir $working/data
- if [ -f $working/data.tar.gz ]; then
- tar xzf $working/data.tar.gz -C $working/data
- elif [ -f $working/data.tar.bz2 ]; then
- tar xjf $working/data.tar.bz2 -C $working/data
- elif [ -f $working/data.tar.xz ]; then
- tar xJf $working/data.tar.xz -C $working/data
- else
- echo "Uknown data format."
- exit 1
- fi
- find $working/data -type f -print0 | xargs -0 file /dev/null |
- grep '\(ELF\|ar archive\)' |
- sed 's/:.*//' |
- while read filename
- do
- readelf -A $filename |
- grep 'Tag_CPU_arch:' |
- sed 's|.*:\W\+\(\w\+\).*|\1|' |
- while read arch
- do
- case $arch in
- v6 ) echo "ARMv6" >> $v6tmp
- ;;
- v7 ) echo "ARMv7" >> $v7tmp
- # echo $filename
- ;;
- * ) echo "other" >> $othertmp
- ;;
- esac
- done
- done
- v6count=`cat $v6tmp | wc -l`
- v7count=`cat $v7tmp | wc -l`
- othercount=`cat $othertmp | wc -l`
- if [ $v7count -gt '0' ]; then
- echo v7_dirty $package_file
- else
- echo v7_clean $package_file
- fi
- # echo $package_file "ARMv6=${v6count} ARMv7=${v7count} other=${othercount}"
- rm -f $working/data.tar.*
- rm -f $working/control.tar.*
- done
- rm -rf $working
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement