]> pd.if.org Git - zpackage/commitdiff
add option to set a log message in rmpackage
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 15 Dec 2018 16:07:30 +0000 (16:07 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 15 Dec 2018 16:07:30 +0000 (16:07 +0000)
zpm-rmpackage

index 1cb39566f37a832c322822068046373e04114f2c..1292eda98dc7be6d592efc652a919e4160bb5843 100755 (executable)
@@ -5,14 +5,19 @@ pkgfile=${ZPM_PACKAGE_FILE:-${ZPMDB:-/var/lib/zpm/local.db}}
 verbose=0
 
 # newpackage -f pkgfile $pkgid
 verbose=0
 
 # newpackage -f pkgfile $pkgid
-while getopts :f:v opt; do
+while getopts :f:vm: opt; do
        case $opt in
                f) pkgfile="$OPTARG" ;;
                v) verbose=1 ;;
        case $opt in
                f) pkgfile="$OPTARG" ;;
                v) verbose=1 ;;
+               m) message=$(zpm quote "$OPTARG") ;;
        esac
 done
 shift $(( OPTIND - 1))
 
        esac
 done
 shift $(( OPTIND - 1))
 
+if [ -z "$message" ]; then
+       message=null
+fi
+
 die() {
        echo $* 1>&2
        exit 1
 die() {
        echo $* 1>&2
        exit 1
@@ -42,6 +47,7 @@ fi
                fi
                pkgid=$(zpm quote "$pkgid")
                printf "delete from packages_pkgid where pkgid = '$pkgid';\n"
                fi
                pkgid=$(zpm quote "$pkgid")
                printf "delete from packages_pkgid where pkgid = '$pkgid';\n"
+               printf "insert into zpmlog (action, target, info) values (%s,'%s',%s);\n" 'rmpackage', "$pkgid", "$message"
        done
        printf "commit;\n"
 } | zpm shell $pkgfile
        done
        printf "commit;\n"
 } | zpm shell $pkgfile