mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-03-22 00:45:01 +00:00
updated
This commit is contained in:
2
pkgadd
2
pkgadd
@@ -69,7 +69,7 @@ runhooks() {
|
||||
target=$(grep "^# target[[:blank:]]*:" $hook | sed 's/^# target[[:blank:]]*:[[:blank:]]*//')
|
||||
if [ -n "$description" ] && [ -n "$operation" ] && [ -n "$target" ]; then
|
||||
if [ "$(echo $operation | grep -w "$opr" )" ]; then
|
||||
if [ "$(grep -E $target $INDEX_DIR/$name/.files)" ]; then
|
||||
if [ "$(grep $target $INDEX_DIR/$name/.files)" ]; then
|
||||
[ "$SILENT_INSTALL" ] || msg2 "$description"
|
||||
. $hook
|
||||
if [ "`type -t exechook`" = "function" ]; then
|
||||
|
||||
1
pkgbuild
1
pkgbuild
@@ -563,6 +563,7 @@ parse_opts() {
|
||||
--no-postinstall) OPTS+=($1) ;;
|
||||
--no-preupgrade) OPTS+=($1) ;;
|
||||
--no-postupgrade) OPTS+=($1) ;;
|
||||
--no-hook) OPTS+=($1) ;;
|
||||
--no-color) NOCOLOR=yes; OPTS+=($1) ;;
|
||||
--no-backup) OPTS+=($1) ;;
|
||||
--redownload) REDOWNLOAD_SOURCE=yes ;;
|
||||
|
||||
32
pkgdel
32
pkgdel
@@ -63,7 +63,7 @@ runremovehooks() {
|
||||
operation=$(cat "$hook" | grep ^"# operation" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
target=$(cat "$hook" | grep ^"# target" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
if [ -n "$description" ] && [ -n "$operation" ] && [ -n "$target" ]; then
|
||||
msg2 "$description"
|
||||
[ "$SILENT_REMOVE" ] || msg2 "$description"
|
||||
. $hook
|
||||
if [ "`type -t exechook`" = "function" ]; then
|
||||
exechook
|
||||
@@ -99,9 +99,11 @@ Usage:
|
||||
Options:
|
||||
-v, --verbose print removed files
|
||||
-h, --help show this help message
|
||||
-s, --silent print remove message in simple format
|
||||
--no-preremove don't run pre-remove script
|
||||
--no-postremove don't run post-remove script
|
||||
--no-color disable colour for output
|
||||
--no-hook skip executing hook
|
||||
--root=<path> remove package from custom root directory
|
||||
|
||||
Example:
|
||||
@@ -130,9 +132,11 @@ parse_opts() {
|
||||
case $1 in
|
||||
-v | --verbose) VERBOSE_REMOVE=yes ;;
|
||||
-h | --help) SHOWHELP=yes ;;
|
||||
-s | --silent) SILENT_REMOVE=yes ;;
|
||||
--no-preremove) NO_PREREMOVE=yes ;;
|
||||
--no-postremove) NO_POSTREMOVE=yes ;;
|
||||
--no-color) NOCOLOR=yes ;;
|
||||
--no-hook) NOHOOK=yes ;;
|
||||
--root=*) ROOT="${1#*=}" ;;
|
||||
-*) msg "Invalid option: ($1)"; exit 1 ;;
|
||||
*) RMNAME=$1 ;;
|
||||
@@ -195,8 +199,12 @@ name=$(cat $INDEX_DIR/$RMNAME/.pkginfo | grep ^name | cut -d " " -f3-)
|
||||
version=$(cat $INDEX_DIR/$RMNAME/.pkginfo | grep ^version | cut -d " " -f3-)
|
||||
release=$(cat $INDEX_DIR/$RMNAME/.pkginfo | grep ^release | cut -d " " -f3-)
|
||||
|
||||
msg "Removing '$name-$version-$release'..."
|
||||
|
||||
if [ "$SILENT_REMOVE" ]; then
|
||||
echo -ne "Removing $name-$version-$release "
|
||||
else
|
||||
msg "Removing '$name-$version-$release'..."
|
||||
fi
|
||||
|
||||
# source .install script
|
||||
if [ "$ROOT" = "" ]; then
|
||||
if [ -f $INDEX_DIR/$name/.pkginstall ]; then
|
||||
@@ -206,23 +214,23 @@ fi
|
||||
|
||||
if [ ! "$NO_PREREMOVE" ]; then
|
||||
if [ "`type -t pre_remove`" = "function" ]; then
|
||||
msg2 "Running preremove script..."
|
||||
[ "$SILENT_REMOVE" ] || msg2 "Running preremove script..."
|
||||
pre_remove "$version" &>/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ROOT" = "" ]; then
|
||||
if [ "$ROOT" = "" ] && [ "$NOHOOK" != "yes" ]; then
|
||||
runpreremovehooks $name
|
||||
fi
|
||||
|
||||
if [ -f "$INDEX_DIR/$name/.bkpfiles" ]; then
|
||||
msg2 "Removing backup files..."
|
||||
[ "$SILENT_REMOVE" ] || msg2 "Removing backup files..."
|
||||
while IFS=' ' read -r line; do
|
||||
[ -e "$ROOT/$line" ] && rm "$ROOT/$line"
|
||||
done < <(tac $INDEX_DIR/$name/.bkpfiles)
|
||||
fi
|
||||
|
||||
msg2 "Removing files & dirs..."
|
||||
[ "$SILENT_REMOVE" ] || msg2 "Removing files & dirs..."
|
||||
while IFS=' ' read -r line; do
|
||||
rm "$ROOT/$line" &>/dev/null
|
||||
done < <(tac $INDEX_DIR/$name/.files | grep -v '/$')
|
||||
@@ -235,18 +243,22 @@ done < <(tac $INDEX_DIR/$name/.files | grep '/$')
|
||||
|
||||
if [ ! "$NO_POSTREMOVE" ]; then
|
||||
if [ "`type -t post_remove`" = "function" ]; then
|
||||
msg2 "Running postremove script..."
|
||||
[ "$SILENT_REMOVE" ] || msg2 "Running postremove script..."
|
||||
post_remove "$version" &>/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf $INDEX_DIR/$name
|
||||
|
||||
if [ "$ROOT" = "" ]; then
|
||||
if [ "$ROOT" = "" ] && [ "$NOHOOK" != "yes" ]; then
|
||||
runremovehooks
|
||||
fi
|
||||
|
||||
msg "Package '$name-$version-$release' removed."
|
||||
if [ "$SILENT_REMOVE" ]; then
|
||||
echo "[ done ]"
|
||||
else
|
||||
msg "Package '$name-$version-$release' removed."
|
||||
fi
|
||||
|
||||
# running ldconfig
|
||||
if [ "$ROOT" = "" ] && [ -x /sbin/ldconfig ]; then
|
||||
|
||||
128
scratch
128
scratch
@@ -512,11 +512,16 @@ installpkg() {
|
||||
echo "Package '$ii' not found."
|
||||
else
|
||||
pushd $(getportpath $ii)
|
||||
pkgbuild -r ${OPTS[@]} || exit 1
|
||||
pkgbuild -s --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
popd
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
srunhooks ${PKGNAME[@]}
|
||||
[ "$error" = 1 ] && return 1 || return 0
|
||||
fi
|
||||
if [ "$NO_DEP" = 1 ]; then
|
||||
for ii in ${PKGNAME[@]}; do
|
||||
@@ -527,11 +532,16 @@ installpkg() {
|
||||
exit 1
|
||||
else
|
||||
pushd $(getportpath $ii)
|
||||
pkgbuild -i ${OPTS[@]} || exit 1
|
||||
pkgbuild -i --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
popd
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
srunhooks ${PKGNAME[@]}
|
||||
[ "$error" = 1 ] && return 1 || return 0
|
||||
fi
|
||||
for i in ${PKGNAME[@]}; do
|
||||
if [ -f $INDEX_DIR/$i/.pkginfo ]; then
|
||||
@@ -571,16 +581,53 @@ installpkg() {
|
||||
pushd $portpathh
|
||||
. $BUILD_SCRIPT
|
||||
echo -en "\033]0;($count/$total) $name-$version-$release \a"
|
||||
pkgbuild -is ${OPTS[@]} || exit 1
|
||||
pkgbuild -is --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
popd
|
||||
else
|
||||
msgwarn "Skipping missing package: $int"
|
||||
fi
|
||||
unset portpathh
|
||||
done
|
||||
srunhooks ${INST[@]}
|
||||
[ "$error" = 1 ] && return 1 || return 0
|
||||
fi
|
||||
}
|
||||
|
||||
srunhooks() {
|
||||
if [ "$mode" = "upgrade" ] || [ "$mode" = "sysup" ]; then
|
||||
opr=upgrade
|
||||
else
|
||||
opr=install
|
||||
fi
|
||||
|
||||
for hook in $(ls $HOOK_DIR/*.hook 2>/dev/null); do
|
||||
description=$(grep "^# description[[:blank:]]*:" $hook | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
|
||||
operation=$(grep "^# operation[[:blank:]]*:" $hook | sed 's/^# operation[[:blank:]]*:[[:blank:]]*//')
|
||||
target=$(grep "^# target[[:blank:]]*:" $hook | sed 's/^# target[[:blank:]]*:[[:blank:]]*//')
|
||||
if [ -n "$description" ] && [ -n "$operation" ] && [ -n "$target" ]; then
|
||||
if [ "$(echo $operation | grep -w "$opr" )" ]; then
|
||||
for pn in $@; do
|
||||
if [ -f $INDEX_DIR/$pn/.files ] && [ "$(grep $target $INDEX_DIR/$pn/.files)" ]; then
|
||||
[ "$ee" != 1 ] && { echo; ee=1; }
|
||||
echo "$description"
|
||||
. $hook
|
||||
if [ "`type -t exechook`" = "function" ]; then
|
||||
exechook
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
unset description operation target
|
||||
unset -f exechook
|
||||
done
|
||||
}
|
||||
|
||||
outdatepkg() {
|
||||
local pkg
|
||||
|
||||
@@ -651,12 +698,56 @@ sysup() {
|
||||
. $BUILD_SCRIPT
|
||||
echo -en "\033]0;($count/$total) $name-$version-$release \a"
|
||||
if [ ! -e "$INDEX_DIR/$inst/.pkginfo" ]; then
|
||||
pkgbuild -is ${OPTS[@]} || exit 1
|
||||
pkgbuild -is --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
else
|
||||
pkgbuild -us ${OPTS[@]} || exit 1
|
||||
pkgbuild -us --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
srunhooks ${WILLINSTALL[@]}
|
||||
[ "$error" = 1 ] && return 1 || return 0
|
||||
}
|
||||
|
||||
srunremovehooks() {
|
||||
if [ "${#runthishook[@]}" -gt 0 ]; then
|
||||
echo
|
||||
for hook in ${runthishook[@]}; do
|
||||
description=$(cat "$hook" | grep ^"# description" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
operation=$(cat "$hook" | grep ^"# operation" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
target=$(cat "$hook" | grep ^"# target" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
if [ -n "$description" ] && [ -n "$operation" ] && [ -n "$target" ]; then
|
||||
echo "$description"
|
||||
. $hook
|
||||
if [ "`type -t exechook`" = "function" ]; then
|
||||
exechook
|
||||
fi
|
||||
fi
|
||||
unset description operation target
|
||||
unset -f exechook
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
srunpreremovehooks() {
|
||||
for hook in $(ls $HOOK_DIR/*.hook 2>/dev/null); do
|
||||
operation=$(cat "$hook" | grep ^"# operation" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
target=$(cat "$hook" | grep ^"# target" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
if [ "$(echo $operation | grep -w "remove" )" ]; then
|
||||
if [ "$(grep $target $INDEX_DIR/$1/.files)" ]; then
|
||||
if [ ! $(echo ${runthishook[@]} | tr ' ' '\n' | grep -x $hook) ]; then
|
||||
runthishook+=($hook)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
unset operation target
|
||||
done
|
||||
}
|
||||
|
||||
removepkg() {
|
||||
@@ -705,8 +796,10 @@ removepkg() {
|
||||
echo
|
||||
fi
|
||||
for pkg in ${IPKG[@]}; do
|
||||
pkgdel $pkg ${OPTS[@]}
|
||||
srunpreremovehooks $pkg
|
||||
pkgdel -s --no-hook $pkg ${OPTS[@]}
|
||||
done
|
||||
srunremovehooks
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -774,17 +867,29 @@ upgradepkg() {
|
||||
pushd $(getportpath $newpkg)
|
||||
. $BUILD_SCRIPT
|
||||
echo -en "\033]0;($count/$total) $name-$version-$release \a"
|
||||
pkgbuild -is ${OPTS[@]} || exit 1
|
||||
pkgbuild -is --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
popd
|
||||
done
|
||||
srunhooks ${NEWPKG[@]}
|
||||
[ "$error" = 1 ] && return 1 || return 0
|
||||
fi
|
||||
for pkg in ${PKGNAME[@]}; do # upgrade all target packages
|
||||
pushd $(getportpath $pkg)
|
||||
. $BUILD_SCRIPT
|
||||
echo -en "\033]0;($count/$total) $name-$version-$release \a"
|
||||
pkgbuild -us ${OPTS[@]} || exit 1
|
||||
pkgbuild -us --no-hook ${OPTS[@]} #|| exit 1
|
||||
if [ $? != 0 ]; then
|
||||
error=1
|
||||
break
|
||||
fi
|
||||
popd
|
||||
done
|
||||
srunhooks ${PKGNAME[@]}
|
||||
[ "$error" = 1 ] && return 1 || return 0
|
||||
}
|
||||
|
||||
outdate() {
|
||||
@@ -1236,6 +1341,7 @@ main() {
|
||||
BUILD_SCRIPT="spkgbuild"
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
REPO_FILE="/etc/scratchpkg.repo"
|
||||
HOOK_DIR="/etc/hooks"
|
||||
|
||||
SOURCE_DIR="/var/cache/scratchpkg/sources"
|
||||
PACKAGE_DIR="/var/cache/scratchpkg/packages"
|
||||
|
||||
Reference in New Issue
Block a user