fix minor bugs

This commit is contained in:
emmett1
2019-05-23 12:58:20 +08:00
parent e58bdbdc01
commit d2e803bad7
3 changed files with 23 additions and 19 deletions

24
pkgadd
View File

@@ -117,12 +117,12 @@ isinstalled() {
parse_opts $(extract_opt $@)
ROOT_DIR=${ROOT:-/}
ROOT_DIR=${ROOT:-}
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
LOCK_FILE="$ROOT_DIR/var/lib/scratchpkg/spkg.lock"
# disable pre/post install script when install to custom root location
if [ "$ROOT_DIR" != "/" ]; then
if [ "$ROOT_DIR" != "" ]; then
NO_PREINSTALL=yes
NO_POSTINSTALL=yes
NO_PREUPGRADE=yes
@@ -250,10 +250,10 @@ fi
if [ $(grep -x .pkginstall $TMP_PKGADD) ]; then
if [ ! "$NO_PREINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
(cd "$ROOT_DIR" && sh <(tar -xf "$PKGNAME" .pkginstall -O) pre-install "$version")
(cd "$ROOT_DIR"/ && sh <(tar -xf "$PKGNAME" .pkginstall -O) pre-install "$version")
fi
if [ "$UPGRADE_PKG" ] && [ ! "$NO_PREUPGRADE" ]; then
(cd "$ROOT_DIR" && sh <(tar -xf "$PKGNAME" .pkginstall -O) pre-upgrade "$version" "$iversion")
(cd "$ROOT_DIR"/ && sh <(tar -xf "$PKGNAME" .pkginstall -O) pre-upgrade "$version" "$iversion")
fi
fi
@@ -262,7 +262,7 @@ for i in $(grep ^.pkg* $TMP_PKGADD); do
done
rm -f $TMP_PKGINSTALL $TMP_PKGINSTALL_BKP
tar --keep-directory-symlink -p -x -v -f $PKGNAME -C $ROOT_DIR $excludefile | while read line; do
tar --keep-directory-symlink -p -x -v -f $PKGNAME -C "$ROOT_DIR"/ $excludefile | while read line; do
if [ "$line" = "${line%.*}.spkgnew" ]; then
echo "$line" >> $TMP_PKGINSTALL_BKP
line=${line%.*}
@@ -285,7 +285,7 @@ if [ "$UPGRADE_PKG" ] || [ "$REINSTALL_PKG" ]; then
rm "$ROOT_DIR/$line" &>/dev/null
done
grep '/$' $TMP_PKGADD_RMLIST | tac | while read line; do
if [ ! "$(grep -R --exclude-dir="$name" -w "$line" "$INDEX_DIR")" ]; then
if [ ! "$(grep -R --exclude-dir="$name" -w "$line" "$INDEX_DIR"/*/.files)" ]; then
rmdir "$ROOT_DIR/$line" &>/dev/null
fi
done
@@ -304,20 +304,22 @@ for ii in $(grep ^.pkg* $TMP_PKGADD); do
pkgfiles="$pkgfiles $ii"
done
tar -x -f $PKGNAME -C $INDEX_DIR/$name $pkgfiles >/dev/null 2>&1
if [ "$pkgfiles" ]; then
tar -x -f $PKGNAME -C $INDEX_DIR/$name $pkgfiles >/dev/null 2>&1
fi
if [ -f $INDEX_DIR/$name/.pkginstall ]; then
if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then
(cd "$ROOT_DIR" && sh $INDEX_DIR/$name/.pkginstall post-install "$version")
(cd "$ROOT_DIR"/ && sh $INDEX_DIR/$name/.pkginstall post-install "$version")
fi
if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then
(cd "$ROOT_DIR" && sh $INDEX_DIR/$name/.pkginstall post-upgrade "$version" "$iversion")
(cd "$ROOT_DIR"/ && sh $INDEX_DIR/$name/.pkginstall post-upgrade "$version" "$iversion")
fi
fi
# running ldconfig
if [ -x $ROOT_DIR/sbin/ldconfig ]; then
$ROOT_DIR/sbin/ldconfig -r $ROOT_DIR
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
$ROOT_DIR/sbin/ldconfig -r "$ROOT_DIR"/
fi
ret 0

14
pkgdel
View File

@@ -103,12 +103,12 @@ isinstalled() {
parse_opts $(extract_opt $@)
ROOT_DIR=${ROOT:-/}
ROOT_DIR=${ROOT:-}
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
LOCK_FILE="$ROOT_DIR/var/lib/scratchpkg/spkg.lock"
# disable pre/post remove script when remove from custom root location
if [ "$ROOT_DIR" != "/" ]; then
if [ "$ROOT_DIR" != "" ]; then
NO_PREREMOVE=yes
NO_POSTREMOVE=yes
fi
@@ -155,7 +155,7 @@ fi
echo "remove: $name-$version-$release..."
if [ ! "$NO_PREREMOVE" ] && [ -f $INDEX_DIR/$name/.pkginstall ]; then
(cd $ROOT_DIR && sh $INDEX_DIR/$name/.pkginstall pre-remove "$version")
(cd "$ROOT_DIR"/ && sh $INDEX_DIR/$name/.pkginstall pre-remove "$version")
fi
if [ -f "$INDEX_DIR/$name/.bkpfiles" ]; then
@@ -175,7 +175,7 @@ while read -r line; do
done < <(tac $INDEX_DIR/$name/.files | grep -v '/$')
while read -r line; do
if [ ! "$(grep -R --exclude-dir="$name" -w "$line" "$INDEX_DIR")" ]; then
if [ ! "$(grep -R --exclude-dir="$name" -w "$line" "$INDEX_DIR"/*/.files)" ]; then
if [ -d "$ROOT_DIR/$line" ]; then
[ "$VERBOSE_REMOVE" = yes ] && echo "<<< $line"
rmdir "$ROOT_DIR/$line"
@@ -184,14 +184,14 @@ while read -r line; do
done < <(tac $INDEX_DIR/$name/.files | grep '/$')
if [ ! "$NO_POSTREMOVE" ] && [ -f $INDEX_DIR/$name/.pkginstall ]; then
(cd $ROOT_DIR && sh $INDEX_DIR/$name/.pkginstall post-remove "$version")
(cd "$ROOT_DIR"/ && sh $INDEX_DIR/$name/.pkginstall post-remove "$version")
fi
rm -rf $INDEX_DIR/$name
# running ldconfig
if [ -x /sbin/ldconfig ]; then
/sbin/ldconfig -r $ROOT_DIR
if [ -x "$ROOT_DIR"/sbin/ldconfig ]; then
$ROOT_DIR/sbin/ldconfig -r "$ROOT_DIR"/
fi
ret 0

View File

@@ -806,7 +806,9 @@ scratch_install() {
fi
done
settermtitle "Triggering install hook"
scratch_trigger ${done_pkg[@]}
if [ ${#done_pkg[@]} -gt 0 ]; then
scratch_trigger ${done_pkg[@]}
fi
settermtitle "Reinstalling done"
[ "$error" = 1 ] && return 1 || return 0
fi