This commit is contained in:
emmett1
2018-06-11 16:09:10 +08:00
parent d8d0eb0e65
commit dd4d7df093
4 changed files with 34 additions and 37 deletions

View File

@@ -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=<path> 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

View File

@@ -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)

View File

@@ -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

20
scratch
View File

@@ -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=<path> override default SOURCE_DIR
--pkgdir=<path> 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 ;;