10 Commits
0.3 ... 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
emmett1
9a06fbd474 fix pkgadd 2020-02-19 17:03:24 +08:00
emmett1
7a91fbdcd4 replace type with command 2020-02-19 15:23:42 +08:00
emmett1
00e55a2473 replace type with command 2020-02-19 00:39:34 +08:00
emmett1
0ee256b921 fix 2020-02-17 23:58:18 +08:00
emmett1
424c56f075 fix typo 2020-02-12 23:48:17 +08:00
7 changed files with 77 additions and 70 deletions

3
pkgadd
View File

@@ -140,7 +140,7 @@ LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
} }
[ -d "$ROOT_DIR/$INDEX_DIR" ] || { [ -d "$ROOT_DIR/$INDEX_DIR" ] || {
msgerr "Package's database directory not exist! ($ROOT_DIR$/INDEX_DIR)" msgerr "Package's database directory not exist! ($ROOT_DIR/$INDEX_DIR)"
ret 1 ret 1
} }
@@ -154,6 +154,7 @@ LOCK_FILE="$SCRATCHPKG_DIR/spkg.lock"
[ -f "$ROOT_DIR/$LOCK_FILE" ] && { [ -f "$ROOT_DIR/$LOCK_FILE" ] && {
msgerr "Cant install/remove package simultaneously." msgerr "Cant install/remove package simultaneously."
msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running." msgerr "remove '$ROOT_DIR/$LOCK_FILE' if no install/remove package process running."
exit 1
} }
touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || { touch "$ROOT_DIR/$LOCK_FILE" 2>/dev/null || {

View File

@@ -98,9 +98,14 @@ download_src() {
FILENAME=$(basename $FILE) FILENAME=$(basename $FILE)
SRCURL=$FILE SRCURL=$FILE
fi fi
[ "$DOWNLOAD_PROG" = "auto" ] && {
command -v curl >/dev/null && DOWNLOAD_PROG=curl
command -v wget >/dev/null && DOWNLOAD_PROG=wget
}
case $DOWNLOAD_PROG in case $DOWNLOAD_PROG in
curl) DLCMD="curl -C - -L --fail --ftp-pasv --retry 3 --retry-delay 3 -o $SOURCE_DIR/$FILENAME.partial $CURL_OPTS" ;; 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" ;; 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 esac
if [ "$FILENAME" != "$FILE" ]; then if [ "$FILENAME" != "$FILE" ]; then
if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then if [ ! -f "$SOURCE_DIR/$FILENAME" ] || [ "$REDOWNLOAD_SOURCE" ]; then
@@ -158,7 +163,7 @@ prepare_src() {
if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then if [ "$FILENAME" != "$FILE" ] && [ "$nxt" != 1 ]; then
case $FILENAME in case $FILENAME in
*.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm) *.tar|*.tar.gz|*.tar.Z|*.tgz|*.tar.bz2|*.tbz2|*.tar.xz|*.txz|*.tar.lzma|*.zip|*.rpm)
if [ $(type -p bsdtar) ]; then if [ $(command -v bsdtar) ]; then
COMMAND="bsdtar -p -o -C $SRC -xf $FILENAME" COMMAND="bsdtar -p -o -C $SRC -xf $FILENAME"
else else
COMMAND="tar -p -o -C $SRC -xf $FILENAME" COMMAND="tar -p -o -C $SRC -xf $FILENAME"
@@ -415,7 +420,7 @@ check_buildscript() {
elif [ -z "$release" ]; then elif [ -z "$release" ]; then
msgerr "'release' is empty!" msgerr "'release' is empty!"
exit 1 exit 1
elif [ "$(type -t build)" != "function" ]; then elif [ ! "$(command -v build)" ]; then
msgerr "'build' function not exist!" msgerr "'build' function not exist!"
exit 1 exit 1
elif echo "$version" | grep -q '-'; then elif echo "$version" | grep -q '-'; then
@@ -691,7 +696,7 @@ PKGBUILD_BSCRIPT="spkgbuild"
SOURCE_DIR="/var/cache/scratchpkg/sources" SOURCE_DIR="/var/cache/scratchpkg/sources"
PACKAGE_DIR="/var/cache/scratchpkg/packages" PACKAGE_DIR="/var/cache/scratchpkg/packages"
WORK_DIR="/var/cache/scratchpkg/work" WORK_DIR="/var/cache/scratchpkg/work"
DOWNLOAD_PROG="wget" DOWNLOAD_PROG="auto"
COMPRESSION_MODE="xz" COMPRESSION_MODE="xz"
OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales" OPTIONS="!libtool emptydirs strip zipman buildflags makeflags checksum !docs !locales"

View File

@@ -350,7 +350,7 @@ fi
shift shift
if [ $(type -t pkg_$opts) ]; then if [ $(command -v pkg_$opts) ]; then
pkg_$opts "$@" pkg_$opts "$@"
else else
print_runhelp_msg print_runhelp_msg

115
scratch
View File

@@ -133,7 +133,7 @@ confirm() {
} }
checktool() { checktool() {
if ! type -p $1 >/dev/null; then if ! command -v $1 >/dev/null; then
msgerr "'$1' not exist in your system!" msgerr "'$1' not exist in your system!"
exit 1 exit 1
fi fi
@@ -286,37 +286,37 @@ post_triggers() {
done done
fi fi
if [ "$trig_11" = 1 ] && [ $(type -p fc-cache) ]; then if [ "$trig_11" = 1 ] && [ $(command -v fc-cache) ]; then
echo "trigger: Updating fontconfig cache..." echo "trigger: Updating fontconfig cache..."
fc-cache -s fc-cache -s
fi fi
if [ "$trig_10" = 1 ] && [ $(type -p gdk-pixbuf-query-loaders) ]; then if [ "$trig_10" = 1 ] && [ $(command -v gdk-pixbuf-query-loaders) ]; then
echo "trigger: Probing GDK-Pixbuf loader modules..." echo "trigger: Probing GDK-Pixbuf loader modules..."
gdk-pixbuf-query-loaders --update-cache gdk-pixbuf-query-loaders --update-cache
fi fi
if [ "$trig_9" = 1 ] && [ $(type -p gio-querymodules) ]; then if [ "$trig_9" = 1 ] && [ $(command -v gio-querymodules) ]; then
echo "trigger: Updating GIO module cache..." echo "trigger: Updating GIO module cache..."
gio-querymodules /usr/lib/gio/modules gio-querymodules /usr/lib/gio/modules
fi fi
if [ "$trig_8" = 1 ] && [ $(type -p glib-compile-schemas) ]; then if [ "$trig_8" = 1 ] && [ $(command -v glib-compile-schemas) ]; then
echo "trigger: Compiling GSettings XML schema files..." echo "trigger: Compiling GSettings XML schema files..."
glib-compile-schemas /usr/share/glib-2.0/schemas glib-compile-schemas /usr/share/glib-2.0/schemas
fi fi
if [ "$trig_7" = 1 ] && [ $(type -p gtk-query-immodules-2.0) ]; then if [ "$trig_7" = 1 ] && [ $(command -v gtk-query-immodules-2.0) ]; then
echo "trigger: Probing GTK2 input method modules..." echo "trigger: Probing GTK2 input method modules..."
gtk-query-immodules-2.0 --update-cache gtk-query-immodules-2.0 --update-cache
fi fi
if [ "$trig_6" = 1 ] && [ $(type -p gtk-query-immodules-3.0) ]; then if [ "$trig_6" = 1 ] && [ $(command -v gtk-query-immodules-3.0) ]; then
echo "trigger: Probing GTK3 input method modules..." echo "trigger: Probing GTK3 input method modules..."
gtk-query-immodules-3.0 --update-cache gtk-query-immodules-3.0 --update-cache
fi fi
if [ "$trig_5" = 1 ] && [ $(type -p gtk-update-icon-cache) ]; then if [ "$trig_5" = 1 ] && [ $(command -v gtk-update-icon-cache) ]; then
echo "trigger: Updating icon theme caches..." echo "trigger: Updating icon theme caches..."
for dir in /usr/share/icons/* ; do for dir in /usr/share/icons/* ; do
if [ -e $dir/index.theme ]; then if [ -e $dir/index.theme ]; then
@@ -328,12 +328,12 @@ post_triggers() {
done done
fi fi
if [ "$trig_4" = 1 ] && [ $(type -p udevadm) ]; then if [ "$trig_4" = 1 ] && [ $(command -v udevadm) ]; then
echo "trigger: Updating hardware database..." echo "trigger: Updating hardware database..."
udevadm hwdb --update udevadm hwdb --update
fi fi
if [ "$trig_3" = 1 ] && [ $(type -p mkfontdir) ] && [ $(type -p mkfontscale) ]; then if [ "$trig_3" = 1 ] && [ $(command -v mkfontdir) ] && [ $(command -v mkfontscale) ]; then
echo "trigger: Updating X fontdir indices..." echo "trigger: Updating X fontdir indices..."
for dir in $(find /usr/share/fonts -maxdepth 1 -type d \( ! -path /usr/share/fonts -a ! -name X11 \)) /usr/share/fonts/X11/*; do for dir in $(find /usr/share/fonts -maxdepth 1 -type d \( ! -path /usr/share/fonts -a ! -name X11 \)) /usr/share/fonts/X11/*; do
rm -f $dir/fonts.scale $dir/fonts.dir $dir/.uuid rm -f $dir/fonts.scale $dir/fonts.dir $dir/.uuid
@@ -344,12 +344,12 @@ post_triggers() {
done done
fi fi
if [ "$trig_2" = 1 ] && [ $(type -p update-desktop-database) ]; then if [ "$trig_2" = 1 ] && [ $(command -v update-desktop-database) ]; then
echo "trigger: Updating desktop file MIME type cache..." echo "trigger: Updating desktop file MIME type cache..."
update-desktop-database --quiet update-desktop-database --quiet
fi fi
if [ "$trig_1" = 1 ] && [ $(type -p update-mime-database) ]; then if [ "$trig_1" = 1 ] && [ $(command -v update-mime-database) ]; then
echo "trigger: Updating the MIME type database..." echo "trigger: Updating the MIME type database..."
update-mime-database /usr/share/mime update-mime-database /usr/share/mime
fi fi
@@ -797,78 +797,79 @@ scratch_upgrade() {
} }
for pkg in $PKGNAME; do for pkg in $PKGNAME; do
if ! isinstalled $pkg; then if ! isinstalled $pkg; then
msgerr "Package '$pkg' not installed." echo "Package '$pkg' not installed."
continue continue
elif [ ! $(getportpath $pkg) ]; then elif [ ! $(getportpath $pkg) ]; then
msgerr "Package '$pkg' not exist." echo "Package '$pkg' not exist."
continue continue
else else
. $(getportpath $pkg)/$BUILD_SCRIPT . $(getportpath $pkg)/$BUILD_SCRIPT
if [ "$(installed_pkg_info version $pkg)-$(installed_pkg_info release $pkg)" = "$version-$release" ]; then 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 continue
fi fi
fi fi
upkg="$upkg $pkg" upkg="$upkg $pkg"
done done
[ "$upkg" ] || return 0 [ "$upkg" ] || return 0
[ "$NO_DEP" ] || {
UPGPKG=0
NEWPKG=0
if [ "$NODEP" != 1 ]; then
echo "Resolving dependencies..." echo "Resolving dependencies..."
DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}') DEP=$(scratch_deplist $upkg $EXOPT | awk '{print $2}')
for dep in $DEP; do echo
if ! isinstalled $dep; then for d in $DEP; do
[ "$(getportpath $dep)" ] && newpkg="$newpkg $dep" 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 fi
done done
} else
echo echo
tnew=0 for dd in $upkg; do
tup=0 printf "[${GREEN}u${CRESET}] $dd "
for i in $newpkg; do WILLINSTALL="$WILLINSTALL $dd"
tnew=$(( tnew + 1 )) UPGPKG=$(( UPGPKG + 1 ))
printf "[${CYAN}n${CRESET}] $i " done
done fi
for i in $upkg; do
tup=$(( tup + 1 ))
printf "[${GREEN}u${CRESET}] $i "
done
echo; echo echo; echo
echo "( $tup upgrade, $tnew new install )" echo "( $UPGPKG upgrade, $NEWPKG new install )"
echo echo
[ "$NOCONFIRM" ] || { [ "$NOCONFIRM" ] || {
confirm "Continue upgrade/install these package(s)?" "Package upgrade cancelled." || exit $? confirm "Continue upgrade/install these package(s)?" "Package upgrade cancelled." || exit $?
echo echo
} }
total=$(( tup + tnew ))
count=0
error=0 error=0
if [ "$newpkg" ]; then count=0
for pkg in $newpkg; do total=$(echo $WILLINSTALL | wc -w)
count=$(( count + 1 )) for inst in $WILLINSTALL; do # install all required dependencies and target packages itself
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=$(( count + 1 )) count=$(( count + 1 ))
cd $(getportpath $pkg) cd $(getportpath $inst)
settermtitle "[ $count/$total ] Upgrading $pkg..." 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 || { pkgbuild -u $OPTS || {
error=1 error=1
count=$(( count - 1 )) count=$(( count - 1 ))
break break
} }
done_pkg="$done_pkg $pkg" fi
cd - >/dev/null cd - >/dev/null
done_pkg="$done_pkg $inst"
done done
settermtitle "triggering upgrade hook..." settermtitle "Triggering install hook."
[ "$done_pkg" ] && scratch_trigger $done_pkg [ "$done_pkg" ] && scratch_trigger $done_pkg
settermtitle "$count/$total package(s) upgraded." settermtitle "$count/$total package(s) upgraded."
return "$error" return "$error"
@@ -1195,9 +1196,9 @@ COMPRESSION_MODE="xz"
mode=$1 mode=$1
if [ -z "$mode" ]; then [ "$mode" ] || {
print_runhelp_msg print_runhelp_msg
fi }
shift shift
@@ -1209,7 +1210,7 @@ for opt in $@; do
-*) char=${#opt}; count=1 -*) char=${#opt}; count=1
while [ "$count" != "$char" ]; do while [ "$count" != "$char" ]; do
count=$((count+1)) count=$((count+1))
MAINOPTS="$MAINOPTS -$(echo $opt | cut -c $count)" MAINOPTS="$MAINOPTS -$(printf '%s' $opt | cut -c $count)"
done;; done;;
*) MAINOPTS="$MAINOPTS $opt";; *) MAINOPTS="$MAINOPTS $opt";;
esac esac
@@ -1222,7 +1223,7 @@ if [ -f "$REPO_FILE" ]; then
done done
fi fi
if [ "$(type -t scratch_$mode)" = "function" ]; then if [ "$(command -v scratch_$mode)" ]; then
scratch_$mode $MAINOPTS scratch_$mode $MAINOPTS
else else
print_runhelp_msg print_runhelp_msg

View File

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

View File

@@ -20,7 +20,7 @@
EDITOR=${EDITOR:-vi} EDITOR=${EDITOR:-vi}
type -p $EDITOR >/dev/null || { command -v $EDITOR >/dev/null || {
echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}." echo "Editor '$EDITOR' not exist. Append 'EDITOR=<your editor>' to ${0##*/}."
exit 2 exit 2
} }

12
xchroot
View File

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