This commit is contained in:
emmett1
2018-11-03 22:51:28 +08:00
parent bd5af7c91b
commit f0551877c7
3 changed files with 104 additions and 8 deletions

View File

@@ -233,7 +233,7 @@ run_build() {
[ "$MAKE_FLAGS" = 1 ] && export MAKEFLAGS || unset MAKEFLAGS
[ "$BUILD_FLAGS" = 1 ] && export CFLAGS CXXFLAGS || unset CFLAGS CXXFLAGS
[ -f $name.install ] && . $name.install
[ -f install ] && . install
pushd $SRC >/dev/null
@@ -357,7 +357,7 @@ backupconf() {
packaging() {
local FILE
[ -f $name.install ] && cp $name.install $PKG/.pkginstall
[ -f install ] && cp install $PKG/.pkginstall
[ -f readme ] && cp readme $PKG/.pkgreadme
pushd $PKG >/dev/null

100
revdep
View File

@@ -18,6 +18,100 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
interrupted() {
cleanup
echo
exit 1
}
cleanup() {
rm -f $FILE_LIST
}
usage() {
cat << EOF
Usage:
$(basename $0) [option] [arg]
Options:
-r, --rebuild rebuild & reinstall broken package
-e, --exclude <pkg1 pkg2 pkgN> exclude package when rebuild (use with -r|--rebuild)
-h, --help print this help message
EOF
}
parse_opt() {
while [ $1 ]; do
case $1 in
-r|--rebuild) REBUILD=1 ;;
-e|--exclude) while [ "$2" ]; do
case $2 in
-*) break ;;
*) [ -z "$expkg" ] && expkg="$2" || expkg="$expkg $2"
esac
shift
done ;;
-h|--help) usage; exit 0 ;;
*) echo "Invalid option ($1)"; exit 1 ;;
esac
shift
done
}
rebuild() {
if [[ "$expkg" ]]; then
for broken in $ALLPKG; do
for exclude in $expkg; do
if [ $broken = $exclude ]; then
remove=1
fi
done
if [ "$remove" != 1 ]; then
if [ -z "$needrebuild" ]; then
needrebuild="$broken"
else
needrebuild="$needrebuild $broken"
fi
fi
unset remove
done
else
needrebuild=$ALLPKG
fi
for allpkg in $(pkgdeplist $needrebuild | cut -d ' ' -f2); do
for pkg in $needrebuild; do
if [ $pkg = $allpkg ]; then
if [ -z "$order" ]; then
order="$allpkg"
else
order="$order $allpkg"
fi
break
fi
done
done
echo
echo "Package will be rebuild & reinstall by this order:"
echo $order
echo
echo "Press ENTER to continue"
read
for p in $order; do
scratch build -f $p && scratch install -r $p || exit 1
done
}
trap "interrupted" SIGHUP SIGINT SIGQUIT SIGTERM
parse_opt $@
if [ "$UID" != 0 ] && [ "$REBUILD" = 1 ]; then
echo "$(basename $0) need to run as root to rebuild & reinstall package"
exit 1
fi
while read line; do
if [[ $(echo ${line::1}) = "/" ]]; then
EXTRA_SEARCH_DIRS+="$line "
@@ -55,6 +149,7 @@ SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /lib64 /usr/libexec $EX
INDEX_DIR="/var/lib/scratchpkg/index"
FILE_LIST=/tmp/$(basename $0)-$$
touch $FILE_LIST || { echo "Can't create temporary file .Aborting..."; exit 1; }
echo "SEARCH DIRS:"
for d in $SEARCH_DIRS; do
@@ -122,10 +217,11 @@ if [ "$ALLPKG" ]; then
for rebuild in $ALLPKG; do
echo -e "$rebuild"
done
if [ "$REBUILD" = 1 ]; then
rebuild
fi
else
echo "All packages is doing fine."
fi
rm -f $FILE_LIST
exit 0

View File

@@ -320,7 +320,7 @@ showdependent() {
for port in ${PORT_REPO[@]}; do
if [ -d $port ]; then
for all in $(ls $port/*/$BUILD_SCRIPT | rev | cut -d '/' -f2 | rev 2>/dev/null); do
for all in $(ls $port/*/$BUILD_SCRIPT 2>/dev/null | rev | cut -d '/' -f2 | rev); do
if [ -f $port/$all/$BUILD_SCRIPT ]; then
depend=$(cat $port/$all/$BUILD_SCRIPT | grep ^'# depends' | tr -d ':' | cut -d " " -f3-)
for dep in ${depend[@]}; do
@@ -455,7 +455,7 @@ buildpkg() {
while [ "$1" ]; do
if [[ "$1" =~ ^-(f|v|w|m|o|x)$ ]]; then
OPTS+=($1)
elif [[ "$1" =~ ^--(no-prebuild|--force-rebuild|skip-mdsum|download|extract|keep-work)$ ]]; then
elif [[ "$1" =~ ^--(no-prebuild|force-rebuild|skip-mdsum|download|extract|keep-work)$ ]]; then
OPTS+=($1)
elif [[ "$1" =~ ^--(pkgdir|srcdir)= ]]; then
OPTS+=($1)
@@ -469,7 +469,7 @@ buildpkg() {
done
pushd $(getportpath $PKGNAME)
if [ $? = 0 ]; then
pkgbuild ${OPTS[@]}
pkgbuild ${OPTS[@]} || exit 1
else
echo "Package '$PKGNAME' not found."
exit 1
@@ -512,7 +512,7 @@ installpkg() {
echo "Package '$ii' not found."
else
pushd $(getportpath $ii)
pkgbuild -r ${OPTS[@]}
pkgbuild -r ${OPTS[@]} || exit 1
popd
fi
done