From dd4d7df093de0847a9cd7b4b90f885d7564f08cb Mon Sep 17 00:00:00 2001 From: emmett1 Date: Mon, 11 Jun 2018 16:09:10 +0800 Subject: [PATCH] updated --- buildpkg | 23 +++++++++++------------ installpkg | 20 +++++++++----------- removepkg | 8 ++++---- scratch | 20 ++++++++++---------- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/buildpkg b/buildpkg index f721567..4832afc 100755 --- a/buildpkg +++ b/buildpkg @@ -309,7 +309,7 @@ packaging() { [ -n "$depends" ] && for d in ${depends[@]}; do echo "depends = $d" >> .pkginfo; done [ -n "$noextract" ] && echo "noextract = $noextract" >> .pkginfo - msg2 "Packaging..." + msg2 "Compressing package..." for file in .pkginstall .pkgreadme; do if [ -f $file ]; then @@ -506,10 +506,10 @@ Options: -c, --ignore-conflict ignore conflict when installing package -v, --verbose verbose install process -f, --force-rebuild rebuild package - -m, --ignore-mdsum skip md5sum checking + -m, --skip-mdsum skip md5sum checking -g, --genmdsum generate md5sum - -o, --download-only download only source file - -e, --extract-only extract only source file + -o, --download download only source file + -e, --extract extract only source file -w, --keep-work keep working directory -h, --help show this help message --srcdir= override directory path for sources @@ -535,13 +535,11 @@ EOF extract_opt() { for opt in $@; do case $opt in - --*=*) OPTS+=($opt) ;; - --*) OPTS+=($opt) ;; - -*) for (( i=1; i<${#opt}; i++ )); do OPTS+=(-${opt:$i:1}); done ;; - *) OPTS+=($opt) ;; + --*) BOPTS+=($opt) ;; + -*) for (( i=1; i<${#opt}; i++ )); do BOPTS+=(-${opt:$i:1}); done ;; + *) BOPTS+=($opt) ;; esac done - echo "${OPTS[@]}" } parse_opts() { @@ -558,7 +556,7 @@ parse_opts() { -m | --skip-mdsum) IGNORE_MDSUM=yes ;; -g | --genmdsum) UPDATE_MDSUM=yes ;; -o | --download) DOWNLOAD_ONLY=yes ;; - -e | --extract) EXTRACT_ONLY=yes ;; + -x | --extract) EXTRACT_ONLY=yes ;; -w | --keep-work) KEEP_WORK=yes ;; -h | --help) SHOWHELP=yes ;; --no-preinstall) NO_PREINSTALL=yes; OPTS+=($1) ;; @@ -571,7 +569,7 @@ parse_opts() { --check-source) SOURCE_CHECK=yes ;; --srcdir=*) SOURCE_DIR="${1#*=}" ;; --pkgdir=*) PACKAGE_DIR="${1#*=}" ;; - *) msg "Invalid option! ($1)"; exit 1 ;; + *) msg "Invalid $(basename $0) option! ($1)"; exit 1 ;; esac shift done @@ -580,7 +578,8 @@ parse_opts() { main() { - parse_opts $(extract_opt $@) + extract_opt $@ + parse_opts ${BOPTS[@]} # disable colour if [ "$NOCOLOR" ]; then diff --git a/installpkg b/installpkg index 16826a3..1f71c4e 100755 --- a/installpkg +++ b/installpkg @@ -136,7 +136,7 @@ installpkg() { runhooks - msg "Successfully $oprmsg." + msg "Successfully $oprmsg ${GREEN}$name-$version-$release${CRESET}." # remove lock file spkglock @@ -179,7 +179,6 @@ registerpkg() { tar -x -f $PKGNAME -C $INDEX_DIR/$name .pkginfo cat /tmp/spkginstall.$name > $INDEX_DIR/$name/.files rm -f /tmp/spkginstall.$name - #tar -t -f $PKGNAME --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]} > $INDEX_DIR/$name/.files tar -x -f $PKGNAME -C $INDEX_DIR/$name .pkginstall .pkgreadme >/dev/null 2>&1 } @@ -337,13 +336,11 @@ EOF extract_opt() { for opt in $@; do case $opt in - --*=*) OPTS+=($opt) ;; --*) OPTS+=($opt) ;; -*) for (( i=1; i<${#opt}; i++ )); do OPTS+=(-${opt:$i:1}); done ;; *) OPTS+=($opt) ;; esac done - echo "${OPTS[@]}" } parse_opts() { @@ -359,14 +356,14 @@ parse_opts() { -c | --ignore-conflict) IGNORE_CONFLICT=yes ;; -v | --verbose) VERBOSE_INSTALL=yes ;; -h | --help) SHOWHELP=yes ;; - --no-preinstall) NO_PREINSTALL=yes ;; - --no-postinstall) NO_POSTINSTALL=yes ;; - --no-preupgrade) NO_PREUPGRADE=yes ;; + --no-preinstall) NO_PREINSTALL=yes ;; + --no-postinstall) NO_POSTINSTALL=yes ;; + --no-preupgrade) NO_PREUPGRADE=yes ;; --no-postupgrade) NO_POSTUPGRADE=yes ;; - --no-backup) NO_BACKUP=yes ;; - --no-color) NOCOLOR=yes ;; + --no-backup) NO_BACKUP=yes ;; + --no-color) NOCOLOR=yes ;; *.spkg.txz) PKGNAME="$1" ;; - *) msg "Invalid option! ($1)"; exit 1 ;; + *) msg "Invalid option! ($1)"; exit 1 ;; esac shift done @@ -376,7 +373,8 @@ parse_opts() { main() { - parse_opts $(extract_opt $@) + extract_opt $@ + parse_opts ${OPTS[@]} if [ -n "$PKGNAME" ]; then BASEPKGNAME=$(basename $PKGNAME) diff --git a/removepkg b/removepkg index fa8b973..14551ae 100755 --- a/removepkg +++ b/removepkg @@ -211,7 +211,6 @@ EOF extract_opt() { for opt in $@; do case $opt in - --*=*) OPTS+=($opt) ;; --*) OPTS+=($opt) ;; -*) for (( i=1; i<${#opt}; i++ )); do OPTS+=(-${opt:$i:1}); done ;; *) OPTS+=($opt) ;; @@ -230,9 +229,9 @@ parse_opts() { -d | --no-dep) IGNORE_DEP=yes ;; -v | --verbose) VERBOSE_REMOVE=yes ;; -h | --help) SHOWHELP=yes ;; - --no-preremove) NO_PREREMOVE=yes ;; + --no-preremove) NO_PREREMOVE=yes ;; --no-postremove) NO_POSTREMOVE=yes ;; - --no-color) NOCOLOR=yes ;; + --no-color) NOCOLOR=yes ;; -*) msg "Invalid option: ($1)"; exit 1 ;; *) RMNAME+=($1) ;; esac @@ -244,7 +243,8 @@ parse_opts() { main() { - parse_opts $(extract_opt $@) + extract_opt $@ + parse_opts ${OPTS[@]} # disable colour if [ "$NOCOLOR" ]; then diff --git a/scratch b/scratch index 8fcb173..55a8a50 100755 --- a/scratch +++ b/scratch @@ -731,6 +731,7 @@ options for: -e, --extract extract only -w, --keep-work keep woring directory -o, --download download source files only + -v, --verbose be verbose --redownload re-download source files --srcdir= override default SOURCE_DIR --pkgdir= override default PACKAGE_DIR @@ -740,7 +741,6 @@ options for: -d, --no-dep skip installing dependencies -c, --ignore-conflict skip file conflict check -r, --reinstall reinstall installed package - -v, --verbose print install process --no-preinstall skip pre-install script --no-postinstall skip post-install script @@ -769,21 +769,21 @@ EOF extract_opt() { for opt in $@; do case $opt in - --*=*) OPTS+=($opt) ;; - --*) OPTS+=($opt) ;; - -*) for (( i=1; i<${#opt}; i++ )); do OPTS+=(-${opt:$i:1}); done ;; - *) OPTS+=($opt) ;; + --*) MAINOPTS+=($opt) ;; + -*) for (( i=1; i<${#opt}; i++ )); do MAINOPTS+=(-${opt:$i:1}); done ;; + *) MAINOPTS+=($opt) ;; esac done - echo "${OPTS[@]}" } # set mode mode=$1 shift + +extract_opt "$@" # strip global options -for i in $(extract_opt $@); do +for i in ${MAINOPTS[@]}; do case $i in --no-color) nocolor ;; --debug) set -x ;; @@ -807,10 +807,10 @@ if [ "$mode" = "build" ]; then parseopt() { while [ "$1" ]; do case $1 in - -f|-m|-d|-e|-w|-o|-v|--verbose|--srcdir=*|--pkgdir=*) OPTS+=($1) ;; + -f|-m|-d|-x|-w|-o|-v|--verbose|--srcdir=*|--pkgdir=*) OPTS+=($1) ;; --skip-mdsum|--no-dep|--extract|--keep-work|--download) OPTS+=($1) ;; --force-rebuild|--redownload|--no-preinstall) OPTS+=($1) ;; - -*) msgerr "Invalid option! ($1)"; exit 1 ;; + -*) msgerr "Invalid build option! ($1)"; exit 1 ;; *) PKG=$1 ;; esac shift @@ -832,7 +832,7 @@ if [ "$mode" = "install" ]; then parseopt() { while [ "$1" ]; do case $1 in - -v|-c|--verbose|--ignore-conflict) OPTS+=($1) ;; + -c|--ignore-conflict) OPTS+=($1) ;; --no-preinstall|--no-postinstall) OPTS+=($1) ;; -r|--reinstall) OPTS+=($1); REINSTALL=1 ;; -d|--no-dep) NO_DEP=1 ;;