Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

A bash script checking aur (local) packages for needing rebuild

View aurebuildcheck
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#!/bin/bash
#
#This Script is original written by matthiaskrgr(https://github.com/matthiaskrgr/aurebuildcheck).
#Modified by proudzhu(https://github.com/proudzhu/dotfiles/bin/aurebuildcheck)
#
 
export LANG=C
 
#color used by cower
NC="\033[0m"
 
BOLDRED="\033[1;31m"
BOLDGREEN="\033[1;32m"
BOLDWHITE="\033[1;37m"
 
# functions and variables #
brokenpkgs=""
autoignored=""
 
# the core of the script #
TS=$(date +%s) # start timer
 
if [[ -z "$*" ]] ; then
localpackages=$(pacman -Qqm)
else
localpackages="$*"
fi
 
localpackagesamount=$(echo ${localpackages} | wc -w)
echo -e "Checking ${BOLDWHITE}${localpackagesamount}${NC} local package(s)...\n"
 
for package in $localpackages ; do
BROKEN="false"
echo -en "Checking ${BOLDWHITE}${package}${NC}..."
PkgArch=$(pacman -Qi $package 2>/dev/null | awk ' BEGIN {FS=" "}/^Architecture/{printf $3}') #use awk only instead of grep
if [[ ${PkgArch} == 'any' ]]; then #Skip package whose architecture is any
autoignored="${autoignored} ${package}"
echo -e " ${BOLDGREEN}[SKIPPED]${NC}"
continue
fi
packagefiles=$(pacman -Qql $package | egrep "/s?bin/\w|\.so\.?|\.o$") #only choose binary, .so and .o files
for file in $packagefiles; do # check the files
if (( $(file $file | grep -c 'ELF') != 0 )); then
# Is an ELF binary.
libs=$(readelf -d "${file}" | awk 'BEGIN {FS="["}/NEEDED/{printf $2}'|tr ']' '\n')
for lib in ${libs} ; do
# needed libs
if [ -z $(whereis ${lib} | awk '{print $2}') ] && [ -z $(find $(dirname ${file}) -type f -name ${lib}) ] ; then #check local libs and bundled libs
# Missing lib.
echo -e "\n\t ${BOLDRED}${file}${NC} needs ${BOLDRED}${lib}${NC}"
BROKEN="true" # to avoid packages being listed in the brokenpkg array several times
fi
done
fi
done
 
if [[ ${BROKEN} == "true" ]] ; then
brokenpkgs="${brokenpkgs} ${package}"
elif [[ ${BROKEN} == "false" ]] ; then
echo -e " ${BOLDGREEN}[OK]${NC}"
fi
done
echo "everything done."
 
brokenamount=$(echo ${brokenpkgs} | wc -w)
echo -e "\n${BOLDWHITE}${brokenamount}${NC} package(s) may need rebuild: \n${BOLDRED}${brokenpkgs}${NC}\n"
autoignoredamount=$(echo ${autoignored} | wc -w)
echo -e "${BOLDWHITE}${autoignoredamount}${NC} package(s) auto ignored: \n${BOLDGREEN}${autoignored}${NC}\n"
 
#timeend
TE=$(date +%s)
TD=$((TE-TS))
echo -e "Done after ${BOLDWHITE}${TD}${NC} seconds."
echo "This script may not be able to distinguish between required and optional dependencies!"
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.