#!/bin/sh pkgver=${ZPMPKGVER:-1.0} pkgrel=${ZPMPKGREL:-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 while getopts :f:v:r:d:a:u:l:p:b:P: 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" ;; p) packager="$OPTARG" ;; b) builddate="$OPTARG" ;; P) prefix="$OPTARG" ;; t) tags="$OPTARG" ;; c) tags="$tags +configuration" ;; esac done shift $((OPTIND - 1)) package="$1" shift set -e if [ -z "$pkgfile" ]; then pkgfile="$package-$pkgver-$pkgrel.zpm" fi if [ ! -f $pkgfile ]; then zpm newpackage $package || exit 1 else zpm test -v $pkgfile fi for path in $*; do mtime=$(zpm stat -f '%y' $path) uid=$(zpm stat -f '%u' $path) gid=$(zpm stat -f '%g' $path) username=$(zpm stat -f '%U' $path) groupname=$(zpm stat -f '%G' $path) mode=$(zpm stat -f '%a' $path) # strip off leading slashes rpath=$(echo "$path" | sed -e 's|^/*||') # and a leading ./ rpath=${rpath#./} rpath=$(echo "$rpath" | sed -e 's|^/*||') if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then continue fi if [ ! -z "$prefix" ]; then # trailing slashes on prefix prefix=$(echo "$prefix" | sed -e 's|/*$||') rpath="$prefix/$rpath" fi filetype=$(zpm stat -f '%t' "$path") hash='NULL' target='NULL' case "$filetype" in regular) filetype=d hash=$(zpm addfile $pkgfile "$path") hash="'$hash'" filetype=r ;; directory) filetype=d ;; symlink) filetype=l target=$(readlink $path) target="'$target'" ;; esac sqlite3 $pkgfile < $target"} printf "%s\n" $path done