Skip to content

Commit

Permalink
add logging, --log
Browse files Browse the repository at this point in the history
  • Loading branch information
emmett1 committed Mar 13, 2020
1 parent 8e8c62d commit 9b186bf
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
1 change: 1 addition & 0 deletions INSTALL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ install -d ${DESTDIR}${REVDEPD}
install -dm777 ${DESTDIR}${CACHE_DIR}/packages
install -dm777 ${DESTDIR}${CACHE_DIR}/sources
install -dm777 ${DESTDIR}${CACHE_DIR}/work
install -dm777 ${DESTDIR}${CACHE_DIR}/log

install -m755 xchroot revdep pkgadd pkgdel pkgbuild pkgquery scratch updateconf ${DESTDIR}${BINDIR}
install -m644 scratchpkg.conf scratchpkg.repo scratchpkg.alias ${DESTDIR}${CONFDIR}
Expand Down
65 changes: 57 additions & 8 deletions scratch
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ scratch_build() {
while [ "$1" ]; do
case $1 in
-i|-u|-r|-g|-p) ;;
--log) LOGBUILD=1;;
-*) OPTS="$OPTS $1";;
*) PKGNAME="$PKGNAME $1";;
esac
Expand All @@ -497,7 +498,12 @@ scratch_build() {
}
cd $ppath
settermtitle "Building $pkg..."
pkgbuild $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS | tee $LOG_DIR/$pkg.log
else
pkgbuild $OPTS
fi
[ "$?" = 0 ] || {
settermtitle "Building $pkg failed."
return 1
}
Expand All @@ -514,6 +520,7 @@ scratch_install() {
-r|--reinstall) REINSTALL=1;;
-y|--yes) NOCONFIRM=1;;
-n|--no-dep) NO_DEP=1;;
--log) LOGBUILD=1;;
--exclude=*) EXOPT=$1;;
-*) OPTS="$OPTS $1";;
*) PKGNAME="$PKGNAME $1";;
Expand All @@ -535,7 +542,12 @@ scratch_install() {
else
cd $(getportpath $ii)
settermtitle "Reinstalling $ii..."
pkgbuild $OPTS -r || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -r | tee $LOG_DIR/$ii.log
else
pkgbuild $OPTS -r
fi
[ "$?" = 0 ] || {
error=1
break
}
Expand All @@ -559,7 +571,12 @@ scratch_install() {
else
cd $(getportpath $ii)
settermtitle "Installing $ii..."
pkgbuild -i $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -i | tee $LOG_DIR/$ii.log
else
pkgbuild $OPTS -i
fi
[ "$?" = 0 ] || {
error=1
break
}
Expand Down Expand Up @@ -606,7 +623,12 @@ scratch_install() {
if portpathh=$(getportpath $int); then
cd $portpathh
settermtitle "[ $count/$total ] installing $int..."
pkgbuild -i $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -i | tee $LOG_DIR/$int.log
else
pkgbuild $OPTS -i
fi
[ "$?" = 0 ] || {
error=1
count=$(( count - 1 ))
break
Expand Down Expand Up @@ -700,6 +722,7 @@ scratch_sysup() {
-i|-u|-r) ;;
-y|--yes) NOCONFIRM=1;;
-n|--no-dep) NODEP=1;;
--log) LOGBUILD=1;;
--exclude=*) EXOPT=$1;;
-*) OPTS="$OPTS $1";;
esac
Expand Down Expand Up @@ -756,14 +779,24 @@ scratch_sysup() {
cd $(getportpath $inst)
if ! isinstalled $inst; then
settermtitle "[ $count/$total ] Installing $inst..."
pkgbuild -i $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -i | tee $LOG_DIR/$inst.log
else
pkgbuild $OPTS -i
fi
[ "$?" = 0 ] || {
error=1
count=$(( count - 1 ))
break
}
else
settermtitle "[ $count/$total ] Upgrading $inst..."
pkgbuild -u $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -u | tee $LOG_DIR/$inst.log
else
pkgbuild $OPTS-u
fi
[ "$?" = 0 ] || {
error=1
count=$(( count - 1 ))
break
Expand All @@ -785,6 +818,7 @@ scratch_upgrade() {
-i|-r) ;;
-y|--yes) NOCONFIRM=1;;
-d|--no-dep) NO_DEP=1;;
--log) LOGBUILD=1;;
--exclude=*) EXOPT=$1;;
-*) OPTS="$OPTS $1";;
*) PKGNAME="$PKGNAME $1";;
Expand Down Expand Up @@ -853,14 +887,24 @@ scratch_upgrade() {
cd $(getportpath $inst)
if ! isinstalled $inst; then
settermtitle "[ $count/$total ] Installing $inst..."
pkgbuild -i $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -i | tee $LOG_DIR/$inst.log
else
pkgbuild $OPTS -i
fi
[ "$?" = 0 ] || {
error=1
count=$(( count - 1 ))
break
}
else
settermtitle "[ $count/$total ] Upgrading $inst..."
pkgbuild -u $OPTS || {
if [ "$LOGBUILD" = 1 ]; then
pkgbuild $OPTS -u | tee $LOG_DIR/$inst.log
else
pkgbuild $OPTS -u
fi
[ "$?" = 0 ] || {
error=1
count=$(( count - 1 ))
break
Expand Down Expand Up @@ -1141,11 +1185,13 @@ Options:
-r|--reinstall reinstall
-n|--no-dep skip dependencies
-y|--yes skip ask user permission
--log log build process
--exclude=* exclude dependencies, comma separated
upgrade <ports> <arg> upgrade ports (use pkgbuild arg, except '-i' & '-r')
-n|--no-dep skip dependencies
-y|--yes skip ask user permission
--log log build process
--exclude=* exclude dependencies, comma separated
remove <ports> <arg> remove installed ports (use pkgdel arg)
Expand All @@ -1154,13 +1200,15 @@ Options:
sysup <arg> full system upgrade (use pkgbuild arg, except '-i', '-r' & '-u')
-n|--no-dep skip dependencies
-y|--yes skip ask user permission
--log log build process
--exclude=* exclude dependencies, comma separated
deplist <ports> print all dependencies for ports
-q|--quick skip installed ports
--exclude=* exclude dependencies, comma separated
build <ports> <arg> build ports (use pkgbuild arg, except '-i', '-u', '-r', '-g', & '-p')
--log log build process
lock <ports> locking ports prevent upgrade
unlock <ports> unlock locked ports
Expand Down Expand Up @@ -1192,6 +1240,7 @@ ALIAS_FILE="/etc/scratchpkg.alias"
# default value from pkgbuild
SOURCE_DIR="/var/cache/scratchpkg/sources"
PACKAGE_DIR="/var/cache/scratchpkg/packages"
LOG_DIR="/var/cache/scratchpkg/log"
COMPRESSION_MODE="xz"

mode=$1
Expand Down

0 comments on commit 9b186bf

Please sign in to comment.