X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-newpackage;h=8b9fb0badcb1aeab6722518c495df0336766de7c;hb=62f6ff407bc4f2cf03d1fa7cf3dc9a3f4026624a;hp=7ab8aa8e5079f1028e8ef9df364a761f786b7e7c;hpb=40a2775ee3b08f365330b478ddceabc8b793f035;p=zpackage diff --git a/zpm-newpackage b/zpm-newpackage index 7ab8aa8..8b9fb0b 100755 --- a/zpm-newpackage +++ b/zpm-newpackage @@ -1,43 +1,89 @@ #!/bin/sh -pkgver=${ZPMPKGVER:-1.0} -pkgrel=${ZPMPKGREL:-1} - builddate=$(date '+%s') -while getopts :f:v:r:d:a:u:l:p:b:I opt; do +# the repo implied by the arguments + +create=0 + +# newpackage -f pkgfile $pkgid +while getopts :Cf:r:d:a:u:l:p:b:In: opt; do case $opt in f) pkgfile="$OPTARG" ;; - v) pkgver="$OPTARG" ;; - r) pkgrel="$OPTARG" ;; d) description="$OPTARG" ;; a) arch="$OPTARG" ;; u) url="$OPTARG" ;; l) licenses="$OPTARG" ;; + C) create=1 ;; p) packager="$OPTARG" ;; b) builddate="$OPTARG" ;; I) idempotent=1 esac done -shift $(( $OPTIND - 1)) +shift $(( OPTIND - 1)) -package=$1 +die() { + echo $* 1>&2 + exit 1 +} + +pkgid=$1 +shift + +if [ -z "$pkgid" ]; then + die "must specify pkgid" +fi + +eval "$(zpm parse -E $pkgid)" if [ -z "$pkgfile" ]; then - pkgfile="$package-$pkgver-$pkgrel.zpm" + pkgfile=$ZPM_PACKAGE_FILE fi -set -e +# cases C = create ok, R = full package id, F = specified package file + +# immediate error +# C-- 100 error, must specify something +# --- 000 error, must specify something +if [ -z "$release" ] && [ -z "$pkgfile" ]; then + die must specify package file or complete package id +fi -if [ ! -e $pkgfile ]; then - zpm init $pkgfile +# --F 001 error, wouldn't know which pkgid to create, could derive from file? +# C-F 101 error, since package wouldn't exist in file to find +if [ -z "$release" ]; then + die must specify complete package id fi +# set file from pkgid +# CR- 110 set file from pkgid, create if needed +# -R- 010 set file from pkgid, create in file, error if no file +if [ -z "$pkgfile" ]; then + pkgfile="$pkgid.zpm" +fi + +# will now be one of these +# CRF 111 create package in file given, create file if needed +# -RF 011 create package in file, error if file doesn't exist +if [ ! -f "$pkgfile" ]; then + if [ $create -eq 1 ]; then + zpm init $pkgfile + else + die $pkgfile does not exist + fi +fi + +set -e + if [ "$idempotent" = 1 ]; then idempotent='or ignore' fi -sqlite3 $pkgfile <