From 5e3c7f4b2f4aed370d21e9ce6417be4972ec1cd6 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Sat, 12 Aug 2017 21:21:43 +0800 Subject: [PATCH] updated --- buildpkg | 131 ++++++++++++++++++++++++++++++++++++----------------- installpkg | 23 +++++++--- 2 files changed, 107 insertions(+), 47 deletions(-) diff --git a/buildpkg b/buildpkg index e40723f..b31bbba 100755 --- a/buildpkg +++ b/buildpkg @@ -420,64 +420,106 @@ interrupted() { exitscript1 } +help() { + + echo -e "Usage:" + echo -e "\t`basename $0` < options >" + echo -e "" + echo -e "Example:" + echo -e "\t`basename $0` -fr -kw -i this will force rebuild, install package and keep working directory" + echo -e "" + echo -e "Option:" + echo -e "\t-i,\t--install install package into system" + echo -e "\t-u,\t--upgrade upgrade package" + echo -e "\t-r,\t--reinstall reinstall package" + echo -e "\t-id,\t--ignore-dependency ignore dependency" + echo -e "\t-ic,\t--ignore-conflict ignore conflict when installing package" + echo -e "\t-v,\t--verbose verbose install process" + echo -e "\t\t--no-preinstall skip preinstall script when build/install package" + echo -e "\t\t--no-postinstall skip postinstall script after install package" + echo -e "\t\t--no-color disable color" + echo -e "\t-fr,\t--force-rebuild rebuild package" + echo -e "\t-im,\t--ignore-mdsum skip md5sum checking" + echo -e "\t-um,\t--update-mdsum update md5sum" + echo -e "\t-cm,\t--check-mdsum check md5sum for source file" + echo -e "\t-do,\t--download-only download only source file" + echo -e "\t-eo,\t--extract-only extract only source file" + echo -e "\t-kw,\t--keep-work keep working directory" + echo -e "\t-ns,\t--no-strip skip strip package library and binary" + echo -e "\t-rd,\t--redownload re-download source file" + echo -e "\t-sd,\t--source-dir override source dir" + echo -e "\t-o,\t--output override output path for packages" + echo -e "\t-h,\t--help show this help page" + echo -e "" + echo -e "Note:" + echo -e "\t* use `basename $0` without any options will only download source and build package by using other default options" + echo -e "\t* buildpkg need run inside port directory" + +} + parse_options() { while [ "$1" ]; do case $1 in + # this option will pass to installpkg + -i|--install) + INSTALL_PKG=yes + ;; + -u|--upgrade) + UPGRADE_PKG=yes + ;; + -r|--reinstall) + REINSTALL_PKG=yes + ;; -id|--ignore-dependency) IGNORE_DEP=yes ;; -ic|--ignore-conflict) IGNORE_CONFLICT=yes ;; - -im|--ignore-mdsum) - IGNORE_MDSUM=yes - ;; - -r|--reinstall) - REINSTALL_PKG=yes - ;; - -u|--upgrade) - UPGRADE_PKG=yes - ;; - -v|--verbose) - VERBOSE_INSTALL=yes - ;; - -fr|--force-rebuild) - FORCE_REBUILD=yes - ;; - -do|--download-only) - DOWNLOAD_ONLY=yes - ;; - -eo|--extract-only) - EXTRACT_ONLY=yes - ;; - -i|--install) - INSTALL_PKG=yes - ;; - -kw|--keep-work) - KEEP_WORK=yes - ;; - -ns|--no-strip) - NO_STRIP=yes - ;; --no-preinstall) NO_PREINSTALL=yes ;; --no-preinstall) NO_POSTINSTALL=yes ;; - -rd|--redownload) - REDOWNLOAD_SOURCE=yes - ;; - -um|--update-mdsum) - UPDATE_CHECKSUM=yes - ;; - -cm|--check-mdsum) - CHECK_CHECKSUM=yes + -v|--verbose) + VERBOSE_INSTALL=yes ;; --no-color) NO_COLOR=yes ;; + # this option not pass to installpkg + -fr|--force-rebuild) + FORCE_REBUILD=yes + ;; + -im|--ignore-mdsum) + IGNORE_MDSUM=yes + ;; + -um|--update-mdsum) + UPDATE_MDSUM=yes + ;; + -cm|--check-mdsum) + CHECK_MDSUM=yes + ;; + -do|--download-only) + DOWNLOAD_ONLY=yes + ;; + -eo|--extract-only) + EXTRACT_ONLY=yes + ;; + -kw|--keep-work) + KEEP_WORK=yes + ;; + -ns|--no-strip) + NO_STRIP=yes + ;; + -rd|--redownload) + REDOWNLOAD_SOURCE=yes + ;; + -h|--help) + SHOW_HELP=yes + ;; -sd|--source-dir) if [ ! "$2" ]; then msg "Option '$1' require an argument (source path for package)." @@ -517,6 +559,12 @@ main() { nocolor fi + ### SHOW HELP ### + if [ "$SHOW_HELP" ]; then + help + exit 0 + fi + ### SET OUTPUT PATH FOR PACKAGE ### if [ $OUTPUT_PKG ]; then PACKAGE_DIR="$OUTPUT_PKG" @@ -533,21 +581,21 @@ main() { ### CHECK SPKGBUILD ### if [ -z "$name" ] || [ -z "$version" ] || [ -z "$release" ] || [ "$(basename `pwd`)" != "$name" ] || [ "`type -t build`" != "function" ]; then - msg "Error, please check spkgbuild" + msg "Error, please check spkgbuild." exit 1 fi PKGNAME="$name-$version-$release.spkg.txz" ### UPDATE CHECKSUM ### - if [ "$UPDATE_CHECKSUM" ]; then + if [ "$UPDATE_MDSUM" ]; then getsource updatemdsum exit 0 fi ### CHECK CHECKSUM ### - if [ "$CHECK_CHECKSUM" ]; then + if [ "$CHECK_MDSUM" ]; then checkmdsum exit 0 fi @@ -598,6 +646,7 @@ main() { VERBOSE_INSTALL="$VERBOSE_INSTALL" \ NO_PREINSTALL="$NO_PREINSTALL" \ NO_POSTINSTALL="$NO_POSTINSTALL" \ + NO_COLOR="$NO_COLOR" \ installpkg $PACKAGE_DIR/$PKGNAME exitscript0 fi diff --git a/installpkg b/installpkg index 4733b83..53f6fa5 100755 --- a/installpkg +++ b/installpkg @@ -300,22 +300,30 @@ run_postupgrade() { } +help() { + + echo -e "Usage:" + echo -e "\t`basename $0` packagefile < options >" + echo -e "" + echo -e "Example:" + echo -e "\t`basename $0` foobar-1.0-1.spkg.txz -u --no-backup" + parse_options() { while [ "$1" ]; do case $1 in - -id|--ignore-dependency) - IGNORE_DEP=yes - ;; - -ic|--ignore-conflict) - IGNORE_CONFLICT=yes - ;; -u|--upgrade) UPGRADE_PKG=yes ;; -r|--reinstall) REINSTALL_PKG=yes ;; + -id|--ignore-dependency) + IGNORE_DEP=yes + ;; + -ic|--ignore-conflict) + IGNORE_CONFLICT=yes + ;; -v|--verbose) VERBOSE_INSTALL=yes ;; @@ -340,6 +348,9 @@ parse_options() { *.spkg.txz) [ -f $1 ] && PKGNAME=$1 || msg "${color_red}$1${color_reset} not exist." ;; + -h|--help) + SHOW_HELP=yes + ;; *) msg "Invalid option!" exit 1