]> pd.if.org Git - zpackage/commitdiff
add option to zpm-add to not absorb file content
authorNathan Wagner <nw@hydaspes.if.org>
Sun, 30 Sep 2018 12:15:05 +0000 (12:15 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 30 Sep 2018 12:15:05 +0000 (12:15 +0000)
With -N file contents of regular files will not be added to the
database, only the metadata will be added to packagefiles.  This allows
a file to be marked as "owned" by a package, without actually importing
the contents.

zpm-add

diff --git a/zpm-add b/zpm-add
index 1d68800a9c2faf5d68befb55620a393f47340142..91c7b189610834679c3af386b7449d9a3a696e4d 100755 (executable)
--- a/zpm-add
+++ b/zpm-add
@@ -32,12 +32,14 @@ cleanpath() {
 verbose=0
 tags=
 isconfig=0
+addcontent=1
 # option for "multipackage" just to let the system know that's what you meant
 # option to take filenames from stdin
 # parse package, version, release from file if not given
 # TODO -l follow symlinks, -L follow symlinks, adding all, links and targets
-while getopts :f:vr:l:P:S:cu:g: opt; do
+while getopts :f:vr:l:P:S:cu:g:N opt; do
        case $opt in
+               N) addcontent=0 ;;
                f) pkgfile="$OPTARG" ;;
                P) prefix="$OPTARG" ;;
                S) strip=$(cleanpath "$OPTARG"); ;;
@@ -149,9 +151,13 @@ for path in $*; do
        case "$filetype" in
                regular)
                        filetype=r
-                       hash=$(zpm addfile $pkgfile "$path")
-                       if [ $? -ne 0 ]; then
-                               die "zpm addfile failed ($?): $pkgfile $path" 
+                       if [ $addcontent -eq 1 ]; then
+                               hash=$(zpm addfile $pkgfile "$path")
+                               if [ $? -ne 0 ]; then
+                                       die "zpm addfile failed ($?): $pkgfile $path" 
+                               fi
+                       else
+                               hash=$(zpm hash "$path")
                        fi
                        hash="'$hash'"
                        ;;