mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-06 09:26:35 +00:00
78 lines
2.1 KiB
Bash
Executable File
78 lines
2.1 KiB
Bash
Executable File
#!/bin/bash -e
|
|
|
|
INDEX_DIR="/var/spkg/index"
|
|
COLOR="/usr/share/scratchpkg/color"
|
|
|
|
. $COLOR
|
|
|
|
onepkg() {
|
|
|
|
pushd / >/dev/null
|
|
while IFS=' ' read -r line; do
|
|
case "$(file -Lbi "${line}")" in
|
|
*application/x-sharedlib* | *application/x-executable*)
|
|
if [ "$(ldd $line 2>/dev/null | grep "not found")" ]; then
|
|
LIB_NAME=$(ldd $line 2>/dev/null | grep "not found" | sort | uniq | awk '{print $1}')
|
|
LIB=$(echo $LIB_NAME | tr '\n' ' ')
|
|
echo -e "$line ${color_green}>>>${color_reset} $LIB"
|
|
fi
|
|
esac
|
|
done < <(grep -E "^(bin|lib|libexec|sbin|usr/bin|usr/lib|usr/libexec|usr/sbin)" $INDEX_DIR/$1/.files | grep -Ev "(/firmware/|/java/|/debug/)")
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
allpkg() {
|
|
|
|
allpkgs=($(ls $INDEX_DIR))
|
|
totalpkgs=$(echo ${#allpkgs[@]})
|
|
|
|
pushd / >/dev/null
|
|
for pkgs in $(seq 0 $(($totalpkgs -1))); do
|
|
echo -ne "[ $((pkgs + 1))/$totalpkgs ] Checking ${allpkgs[pkgs]}...\033[0K\r"
|
|
while IFS=' ' read -r line; do
|
|
case "$(file -Lbi "${line}")" in
|
|
*application/x-sharedlib* | *application/x-executable*)
|
|
if [ "$(ldd $line 2>/dev/null | grep "not found")" ]; then
|
|
LIB_NAME=$(ldd $line 2>/dev/null | grep "not found" | sort | uniq | awk '{print $1}')
|
|
PKG_NAME=$(basename $(dirname $(grep -Rx $line $INDEX_DIR | cut -d ':' -f1)))
|
|
LIB=$(echo $LIB_NAME | tr '\n' ' ')
|
|
echo -e "(${color_green}$PKG_NAME${color_reset}) $line ${color_green}>>>${color_reset} $LIB"
|
|
if [[ "$(echo ${ALLPKG[@]} | tr ' ' '\n' | grep -w "$PKG_NAME")" ]]; then
|
|
continue
|
|
else
|
|
ALLPKG+=($PKG_NAME)
|
|
fi
|
|
fi
|
|
esac
|
|
done < <(grep -E "^(bin|lib|libexec|sbin|usr/bin|usr/lib|usr/libexec|usr/sbin)" $INDEX_DIR/${allpkgs[pkgs]}/.files | grep -Ev "(/firmware/|/java/|/debug/)")
|
|
done
|
|
popd >/dev/null
|
|
|
|
echo -ne "\033[0K"
|
|
|
|
echo
|
|
if [ "${#ALLPKG[@]}" -gt 0 ]; then
|
|
echo "This package(s) need rebuild:"
|
|
for rebuild in ${ALLPKG[@]}; do
|
|
echo -e "${color_green}>>>${color_reset} $rebuild"
|
|
done
|
|
else
|
|
echo "All packages is doing fine."
|
|
fi
|
|
|
|
}
|
|
|
|
if [ "$1" ]; then
|
|
if [ ! -d "$INDEX_DIR/$1" ]; then
|
|
echo "Package '$1' not installed"
|
|
exit 1
|
|
else
|
|
onepkg $1
|
|
fi
|
|
else
|
|
allpkg
|
|
fi
|
|
|
|
exit 0
|