5 Commits
0.4 ... 0.6

Author SHA1 Message Date
emmett1
b72816f8df revert logging 2020-03-14 00:12:29 +08:00
emmett1
9b186bfd31 add logging, --log 2020-03-13 17:20:31 +08:00
emmett1
8e8c62d338 xchroot: add '-l' to umount 2020-03-05 17:32:54 +08:00
emmett1
c8b2eca5ba updated 2020-02-25 23:59:33 +08:00
emmett1
a23a22c659 fix scratch_upgrade 2020-02-25 18:07:35 +08:00
4 changed files with 55 additions and 49 deletions

View File

@@ -98,9 +98,14 @@ download_src() {
FILENAME=$(basename $FILE)
SRCURL=$FILE
fi
[ "$DOWNLOAD_PROG" = "auto" ] && {
command -v curl >/dev/null && DOWNLOAD_PROG=curl
command -v wget >/dev/null && DOWNLOAD_PROG=wget
}
case $DOWNLOAD_PROG in
curl) DLCMD="curl -C - -L --fail --ftp-pasv --retry 3 --retry-delay 3 -o $SOURCE_DIR/$FILENAME.partial $CURL_OPTS" ;;
wget) DLCMD="wget -c --passive-ftp --no-directories --tries=3 --waitretry=3 --output-document=$SOURCE_DIR/$FILENAME.partial $WGET_OPTS" ;;
*) msgerr "No download agent found"; abort 1;;
esac
if [ "$FILENAME" != "$FILE" ]; then
if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then
@@ -691,7 +696,7 @@ PKGBUILD_BSCRIPT="spkgbuild"
SOURCE_DIR="/var/cache/scratchpkg/sources"
PACKAGE_DIR="/var/cache/scratchpkg/packages"
WORK_DIR="/var/cache/scratchpkg/work"
DOWNLOAD_PROG="wget"
DOWNLOAD_PROG="auto"
COMPRESSION_MODE="xz"
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"

83
scratch
View File

@@ -797,78 +797,79 @@ scratch_upgrade() {
}
for pkg in $PKGNAME; do
if ! isinstalled $pkg; then
msgerr "Package '$pkg' not installed."
echo "Package '$pkg' not installed."
continue
elif [ ! $(getportpath $pkg) ]; then
msgerr "Package '$pkg' not exist."
echo "Package '$pkg' not exist."
continue
else
. $(getportpath $pkg)/$BUILD_SCRIPT
if [ "$(installed_pkg_info version $pkg)-$(installed_pkg_info release $pkg)" = "$version-$release" ]; then
msg "Package '$pkg' is up to date."
echo "Package '$pkg' is up to date."
continue
fi
fi
upkg="$upkg $pkg"
done
[ "$upkg" ] || return 0
[ "$NO_DEP" ] || {
UPGPKG=0
NEWPKG=0
if [ "$NODEP" != 1 ]; then
echo "Resolving dependencies..."
DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}')
for dep in $DEP; do
if ! isinstalled $dep; then
[ "$(getportpath $dep)" ] && newpkg="$newpkg $dep"
echo
for d in $DEP; do
if [ "$(echo $upkg | tr ' ' '\n' | grep -x $d)" = "$d" ]; then
printf "[${GREEN}u${CRESET}] $d "
WILLINSTALL="$WILLINSTALL $d"
UPGPKG=$(( UPGPKG + 1 ))
elif ! isinstalled $d && [ "$(getportpath "$d")" ]; then
printf "[${CYAN}n${CRESET}] $d "
WILLINSTALL="$WILLINSTALL $d"
NEWPKG=$(( NEWPKG + 1 ))
fi
done
}
echo
tnew=0
tup=0
for i in $newpkg; do
tnew=$(( tnew + 1 ))
printf "[${CYAN}n${CRESET}] $i "
done
for i in $upkg; do
tup=$(( tup + 1 ))
printf "[${GREEN}u${CRESET}] $i "
done
else
echo
for dd in $upkg; do
printf "[${GREEN}u${CRESET}] $dd "
WILLINSTALL="$WILLINSTALL $dd"
UPGPKG=$(( UPGPKG + 1 ))
done
fi
echo; echo
echo "( $tup upgrade, $tnew new install )"
echo "( $UPGPKG upgrade, $NEWPKG new install )"
echo
[ "$NOCONFIRM" ] || {
confirm "Continue upgrade/install these package(s)?" "Package upgrade cancelled." || exit $?
echo
}
total=$(( tup + tnew ))
count=0
error=0
if [ "$newpkg" ]; then
for pkg in $newpkg; do
count=$(( count + 1 ))
cd $(getportpath $pkg)
settermtitle "[ $count/$total ] Installing $pkg..."
pkgbuild -i $OPTS || {
error=1
count=$(( count - 1 ))
break
}
done_pkg="$done_pkg $pkg"
cd - >/dev/null
done
fi
for pkg in $upkg; do # upgrade all target packages
count=0
total=$(echo $WILLINSTALL | wc -w)
for inst in $WILLINSTALL; do # install all required dependencies and target packages itself
count=$(( count + 1 ))
cd $(getportpath $pkg)
settermtitle "[ $count/$total ] Upgrading $pkg..."
cd $(getportpath $inst)
if ! isinstalled $inst; then
settermtitle "[ $count/$total ] Installing $inst..."
pkgbuild -i $OPTS || {
error=1
count=$(( count - 1 ))
break
}
else
settermtitle "[ $count/$total ] Upgrading $inst..."
pkgbuild -u $OPTS || {
error=1
count=$(( count - 1 ))
break
}
done_pkg="$done_pkg $pkg"
fi
cd - >/dev/null
done_pkg="$done_pkg $inst"
done
settermtitle "triggering upgrade hook..."
settermtitle "Triggering install hook."
[ "$done_pkg" ] && scratch_trigger $done_pkg
settermtitle "$count/$total package(s) upgraded."
return "$error"

View File

@@ -9,7 +9,7 @@ MAKEFLAGS="-j$(nproc)"
# SOURCE_DIR="/var/cache/scratchpkg/sources"
# PACKAGE_DIR="/var/cache/scratchpkg/packages"
# WORK_DIR="/var/cache/scratchpkg/work"
# DOWNLOAD_PROG="wget"
# DOWNLOAD_PROG="auto"
# WGET_OPTS=""
# CURL_OPTS=""
# COMPRESSION_MODE="xz"

12
xchroot
View File

@@ -78,13 +78,13 @@ retval=$?
mv $TARGET/etc/resolv.conf.tmp $TARGET/etc/resolv.conf
}
umount $TARGET/dev/pts
umount $TARGET/dev
umount $TARGET/run
umount $TARGET/proc
umount -l $TARGET/dev/pts
umount -l $TARGET/dev
umount -l $TARGET/run
umount -l $TARGET/proc
if [ -n "$EFI_SYSTEM" ]; then
umount $TARGET/sys/firmware/efi/efivars
umount -l $TARGET/sys/firmware/efi/efivars
fi
umount $TARGET/sys
umount -l $TARGET/sys
exit $retval