3 builddate=$(date '+%s')
5 # the repo implied by the arguments
9 # newpackage -f pkgfile $pkgid
10 while getopts :Cf:r:d:a:u:l:p:b:In: opt; do
12 f) pkgfile="$OPTARG" ;;
13 d) description="$OPTARG" ;;
16 l) licenses="$OPTARG" ;;
18 p) packager="$OPTARG" ;;
19 b) builddate="$OPTARG" ;;
23 shift $(( OPTIND - 1))
33 if [ -z "$pkgid" ]; then
34 die "must specify pkgid"
37 eval "$(zpm parse -E $pkgid)"
39 if [ -z "$pkgfile" ]; then
40 pkgfile=$ZPM_PACKAGE_FILE
43 # cases C = create ok, R = full package id, F = specified package file
46 # C-- 100 error, must specify something
47 # --- 000 error, must specify something
48 if [ -z "$release" ] && [ -z "$pkgfile" ]; then
49 die must specify package file or complete package id
52 # --F 001 error, wouldn't know which pkgid to create, could derive from file?
53 # C-F 101 error, since package wouldn't exist in file to find
54 if [ -z "$release" ]; then
55 die must specify complete package id
59 # CR- 110 set file from pkgid, create if needed
60 # -R- 010 set file from pkgid, create in file, error if no file
61 if [ -z "$pkgfile" ]; then
65 # will now be one of these
66 # CRF 111 create package in file given, create file if needed
67 # -RF 011 create package in file, error if file doesn't exist
68 if [ ! -f "$pkgfile" ]; then
69 if [ $create -eq 1 ]; then
72 die $pkgfile does not exist
78 if [ "$idempotent" = 1 ]; then
79 idempotent='or ignore'
82 package=$(zpm quote "$name")
83 pkgver=$(zpm quote "$version")
84 pkgrel=$(zpm quote "$release")
85 if [ -n "$description" ]; then
86 description=$(zpm quote -q "$description")
91 if [ -n "$licenses" ]; then
92 licenses=$(zpm quote -q "$licenses")
97 if [ -n "$packager" ]; then
98 packager=$(zpm quote -q "$packager")
102 if [ -n "$url" ]; then
103 url=$(zpm quote -q "$url")
108 zpm shell $pkgfile <<EOS
109 insert $idempotent into packages ("package", "version", "release",
110 "build_time", licenses, description, url, packager)
111 values ('$package', '$pkgver', $pkgrel, $builddate, $licenses, $description,