Blob Blame History Raw
#!/bin/bash

perk=/usr/bin/perk
test -x $perk || {
    cat > /dev/null
    exit 0
}

[ $# -ge 1 ] || {
    cat > /dev/null
    exit 0
}

case $1 in
-P|--provides)
    while read filename ; do
    case "${filename}" in
    *.so*)
	if [ -L "${filename}" ]; then
		# Skip symlink files
		continue
	fi
	# Print the name of the library with correct multilibbing
	DIR="`dirname ${filename}`"
	FILE="`basename ${filename}`"
	if [[ $DIR =~ "/lib64" ]]; then
		printf "%s(64bit)\n" "${FILE}"
	fi
	if [[ $DIR =~ "/lib32" ]]; then
		printf "%s(32bit)\n" "${FILE}"
	fi
    esac
    done
    ;;
-R|--requires)
    while read filename ; do
	# Print the name of the library with correct multilibbing
	DIR="`dirname ${filename}`"
	FILE="`basename ${filename}`"
	PEDEPS="`perk -d ${filename}`"
	readarray -t DEPS <<<"$PEDEPS"
	if [[ $DIR =~ "/lib64" ]]; then
		for dep in "${DEPS[@]}"
		do
			printf "%s(64bit)\n" "${dep}"
		done
	fi
	if [[ $DIR =~ "/lib32" ]]; then
		for dep in "${DEPS[@]}"
		do
			printf "%s(32bit)\n" "${dep}"
		done
	fi
    done
    ;;
esac
exit 0