2024-10-07 05:00:45 +08:00
|
|
|
#!/bin/bash
|
2024-03-22 05:49:18 +08:00
|
|
|
# first parameter is the blfs tool's script folder
|
|
|
|
# second parameter is the blfs tool's installed packages xml file
|
|
|
|
|
2024-10-24 06:12:12 +08:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# Check if the script folder is specified as an argument
|
|
|
|
if [ -z "$1" ] ; then
|
|
|
|
echo "Please specify the blfs tool's script folder as the first argument!" >&2
|
|
|
|
exit 1
|
2024-03-22 05:49:18 +08:00
|
|
|
fi
|
|
|
|
|
2024-10-24 06:12:12 +08:00
|
|
|
# Check if the given script folder exists
|
|
|
|
if [ ! -d "$1" ] ; then
|
|
|
|
echo "The given script folder is not exist!" >&2
|
|
|
|
exit 2
|
2024-03-22 05:49:18 +08:00
|
|
|
fi
|
|
|
|
|
2024-10-24 06:12:12 +08:00
|
|
|
# Check if the installed packages xml is specified as an argument
|
|
|
|
if [ -z "$2" ] ; then
|
|
|
|
echo "Please specify the blfs tool's installed packages xml file as the second argument!" >&2
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if installed packages xml file exists
|
|
|
|
if [ ! -f "$2" ] ; then
|
|
|
|
echo "The given installed packages xml file is not exist!" >&2
|
|
|
|
exit 4
|
2024-03-22 05:49:18 +08:00
|
|
|
fi
|
|
|
|
|
2024-10-24 06:12:12 +08:00
|
|
|
# Add slash to script path if not there yet
|
|
|
|
if [[ "$1" != */ ]] ; then
|
|
|
|
SCRIPTPATH="$1/"
|
|
|
|
else
|
|
|
|
SCRIPTPATH="$1"
|
|
|
|
fi
|
2024-03-22 05:49:18 +08:00
|
|
|
|
2024-10-24 06:12:12 +08:00
|
|
|
# Find and remove all the scripts which would install a package that is already mentioned in the installed packages file
|
|
|
|
grep "$2" -f <(find "$SCRIPTPATH" -type f -printf '%f\n' | awk -F'-z-' '{print "<name>"$2"</name>"}') | \
|
|
|
|
while read -r line
|
|
|
|
do
|
|
|
|
rm -v "$(find "$SCRIPTPATH" -name "$(echo "$line" | sed 's/<name>/*-/g' | sed 's|</name>||g')" -type f)"
|
|
|
|
done
|