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
40 mtime=$(zpm stat -f '%y' $path)
41 uid=$(zpm stat -f '%u' $path)
42 gid=$(zpm stat -f '%g' $path)
43 username=$(zpm stat -f '%U' $path)
44 groupname=$(zpm stat -f '%G' $path)
45 mode=$(zpm stat -f '%a' $path)
47 # strip off leading slashes
48 rpath=$(echo "$path" | sed -e 's|^/*||')
51 rpath=$(echo "$rpath" | sed -e 's|^/*||')
53 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
57 if [ ! -z "$prefix" ]; then
58 # trailing slashes on prefix
59 prefix=$(echo "$prefix" | sed -e 's|/*$||')
60 rpath="$prefix/$rpath"
63 filetype=$(zpm stat -f '%t' "$path")
69 hash=$(zpm addfile $pkgfile "$path")
78 target=$(readlink $path)
83 sqlite3 $pkgfile <<EOS
84 PRAGMA foreign_keys = ON;
86 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
87 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
91 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}