]> pd.if.org Git - zpackage/commitdiff
add zpm-contents script
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 11 Aug 2018 02:40:31 +0000 (02:40 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 11 Aug 2018 02:40:31 +0000 (02:40 +0000)
Makefile
zpm-contents [new file with mode: 0755]

index b41942843989a75ec2ff0cadd9692979ddd8d890..96aca9d1674e12e4d4857d5d9d3a906e577e6b87 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CFLAGS=-Wall -W -Wextra -Werror -Wno-implicit-fallthrough -std=c99 -Ilib -Isqlit
 
 ZPMVER:=$(shell git tag --list 'v[0-9]*' | sed -e 's/^v//' | sort -nr | head -1)
 ifeq ($(strip $(ZPMVER)),)
-       ZPMVER:=0.1.1
+       ZPMVER:=0.1.2
 endif
 
 LZMAFLAGS=-Ilzma/api -Ilzma/tuklib -Ilzma/lzma -Ilzma/common -Ilzma/check -Ilzma/lz -Ilzma/rangecoder -Ilzma/simple -Ilzma/delta -DHAVE_CHECK_CRC64 -DHAVE_CHECK_CRC32 -DHAVE_ENCODER_LZMA2 -DHAVE_DECODER_LZMA2 -DHAVE_MF_BT4
@@ -18,7 +18,8 @@ curdir=$(shell pwd)
 ZPKGBIN=zpm-addfile zpm-extract zpm-init zpm-vercmp zpm-stat zpm-hash \
        zpm-findpkg zpm-shell zpm-soneed
 
-SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-preserve zpm-test zpm-log
+SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-preserve zpm-test zpm-log \
+       zpm-contents
 COMPILED=$(ZPKGBIN)
 PROGRAMS=$(SCRIPTS) $(COMPILED)
 
@@ -130,7 +131,10 @@ clean:
                *.xz *.zpm \
                local.db t/ctap/prove.o
 
-tmpinstall: package
+tmpinstall:
        rm -rf tmp
        mkdir tmp
+       ZPMDB=tmp/db.zpm ./zpm -P. install -R tmp -f zpm-0.1.1-1.zpm -u nw -g nw
+
+tmpupgrade:
        ZPMDB=tmp/db.zpm ./zpm -P. install -R tmp -f zpm-$(ZPMVER)-1.zpm -u nw -g nw
diff --git a/zpm-contents b/zpm-contents
new file mode 100755 (executable)
index 0000000..0d1a027
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm}
+
+while getopts f: opt; do
+       case $opt in
+               f) pkgfile="$OPTARG" ;;
+       esac
+done
+shift $((OPTIND - 1))
+
+set -e
+
+if [ ! -f $pkgfile ]; then
+       echo cannot find $pkgfile
+       exit 1
+fi
+
+
+for pkg in "$@"; do
+       pkgid=$(zpm findpkg $pkgfile $pkg)
+
+       zpm shell $pkgfile <<EOS
+.separator "\t"
+select package, version, release,
+path || case when hash is null then '/' else '' end
+from packagefiles
+where printf('%s-%s-%s', package,version,release) = '$pkgid'
+;
+EOS
+
+done