You are not logged in.

#1 2013-05-08 16:06:15

matthiaskrgr
Member
Registered: 2012-04-03
Posts: 28
Website

aurebuildcheck - checks if aur packages need rebuild

Hi everyone, I made a small script which checks locally installed packages for missing dependencies using ldd.
The script basically gets the list of files contained in local packages and runs ldd on the files to check if dependencies are missing (kinda like findbrokenpkgs or lddd found in "devtools").
However, since it only checks the files of local packages, it's much faster than lddd or findbrokenpkgs which check all packages.

The aur package is called aurebuildcheck-git and can be found at https://aur.archlinux.org/packages/aurebuildcheck-git/ .


Have fun. smile

Offline

#2 2013-05-08 18:15:42

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: aurebuildcheck - checks if aur packages need rebuild

matthiaskrgr wrote:

runs ldd on the files

ldd is the wrong tool to use. As a contrived example, suppose libcairo has a soname bump and you have a locally built version of gvim. Your tool is going to tell you that gvim needs a rebuild. This is wrong -- gvim links to libgtk, not libcairo. But, because ldd leverages the linker to do full recursive resolution, gvim is going to be pointed out as a suspect.

Use objdump or readelf to read the DT_NEEDED sections of ELF binaries and search for *those* dependencies being broken.

Offline

#3 2013-05-08 21:13:53

matthiaskrgr
Member
Registered: 2012-04-03
Posts: 28
Website

Re: aurebuildcheck - checks if aur packages need rebuild

Ok, thank you!

It's a bit more hacky now, and a bit slower.

localpackages=`pacman -Qqm`
localpackagesamount=`echo $localpackages | wc -w`
echo -e "${localpackagesamount} packages will be checked...\n"

brokenpkgs=""
localpackages=`pacman -Qqm`
for package in $localpackages ; do
	BROKEN="false"
	echo "checking ${package}..."
	packagefiles=`pacman -Qql $package | grep -v "\.a\|\.png\|\.la\|\.ttf\|\.gz\|\.html\|\.css\|\.h\|\.xml\|\.rgb\|\.gif\|\.wav\|\.ogg\|\.mp3\|\.po\|\.txt\|\.jpg\|\.jpeg"`
	IFS=$'\n'
	for file in $packagefiles; do
		if (( $(file $file | grep -c 'ELF') != 0 )); then
			#  Is an ELF binary.
			libs=`readelf -d "${file}" | grep "NEEDED.*\[.*\]" | awk '{print $5}' | sed -e "s/\[//" -e "s/\]//"`
			for lib in ${libs} ; do
			# needed libs
				if [ -z `whereis ${lib} | awk '{print $2}'` ] ; then
					#  Missing lib.
					echo -e "\t ${RED}${file}${NC} needs ${REDUL}$lib${NC}" # >> $TEMPDIR/raw.txt
					BROKEN="true" # to avoid packages being listed in the brokenpkg array several times
				fi
			done
		fi
	done

	if [[ ${BROKEN} == "true" ]] ; then
		brokenpkgs="${brokenpkgs} ${package}"
	fi

done

Offline

Board footer

Powered by FluxBB