3 package=${1:-$ZPMPACKAGE}
5 pkgver=${ZPMPKGVER:-1.0}
8 # option for "multipackage" just to let the system know that's what you meant
9 # option to take filenames from stdin
10 # parse package, version, release from file if not given
11 while getopts :f:v:r:d:a:u:l:p:b:P: opt; do
13 f) pkgfile="$OPTARG" ;;
14 v) pkgver="$OPTARG" ;;
15 r) pkgrel="$OPTARG" ;;
16 d) description="$OPTARG" ;;
19 l) licenses="$OPTARG" ;;
20 p) packager="$OPTARG" ;;
21 b) builddate="$OPTARG" ;;
22 P) prefix="$OPTARG" ;;
24 c) tags="$tags +configuration" ;;
29 if [ -z "$pkgfile" ]; then
30 pkgfile="$package-$pkgver-$pkgrel.zpm"
33 if [ ! -f $pkgfile ]; then
34 zpm newpackage $package || exit 1
36 appid=$(sqlite3 $pkgfile 'pragma application_id;' | ( echo obase = 16; cat - ) | bc)
37 if [ "$appid" != "5A504442" ]; then
38 echo $pkgfile does not appear to be a zpm package file
44 mtime=$(zpm stat -f '%y' $path)
45 uid=$(zpm stat -f '%u' $path)
46 gid=$(zpm stat -f '%g' $path)
47 username=$(zpm stat -f '%U' $path)
48 groupname=$(zpm stat -f '%G' $path)
49 mode=$(zpm stat -f '%a' $path)
51 # strip off leading slashes
52 rpath=$(echo "$path" | sed -e 's|^/*||')
55 rpath=$(echo "$rpath" | sed -e 's|^/*||')
57 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
61 if [ ! -z "$prefix" ]; then
62 # trailing slashes on prefix
63 prefix=$(echo "$prefix" | sed -e 's|/*$||')
64 rpath="$prefix/$rpath"
67 filetype=$(zpm stat -f '%t' "$path")
73 hash=$(zpm addfile $pkgfile "$path")
82 target=$(readlink $path)
87 sqlite3 $pkgfile <<EOS
88 PRAGMA foreign_keys = ON;
90 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
91 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
95 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}