3 pkgver=${ZPMPKGVER:-1.0}
11 # basic cleanup on a path
14 if [ -z "$clean" ]; then printf ''; fi
17 clean=$(printf "%s" "$clean" | sed -e 's|/+|/|g')
19 clean=$(printf "%s" "$clean" | sed -e 's|/\./|/|g')
29 # option for "multipackage" just to let the system know that's what you meant
30 # option to take filenames from stdin
31 # parse package, version, release from file if not given
32 while getopts :f:v:r:d:a:u:l:p:b:P:S: opt; do
34 f) pkgfile="$OPTARG" ;;
35 v) pkgver="$OPTARG" ;;
36 r) pkgrel="$OPTARG" ;;
37 d) description="$OPTARG" ;;
40 l) licenses="$OPTARG" ;;
41 p) packager="$OPTARG" ;;
42 b) builddate="$OPTARG" ;;
43 P) prefix="$OPTARG" ;;
44 S) strip=$(cleanpath "$OPTARG"); ;;
46 c) tags="$tags +configuration" ;;
53 if [ -z "$package" ]; then
54 die "must specify package"
58 if [ -z "$pkgfile" ]; then
59 pkgfile="$package-$pkgver-$pkgrel.zpm"
62 # make sure package exists
63 zpm newpackage -I -f $pkgfile -v $pkgver -r $pkgrel $package || exit 1
67 #strip=$(cleanpath "$strip")
69 mtime=$(zpm stat -f '%y' $path)
70 uid=$(zpm stat -f '%u' $path)
71 gid=$(zpm stat -f '%g' $path)
72 username=$(zpm stat -f '%U' $path)
73 groupname=$(zpm stat -f '%G' $path)
74 mode=$(zpm stat -f '%a' $path)
77 rpath=$(cleanpath "$path")
79 # strip off leading slash
82 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
86 if [ ! -z "$strip" ]; then
87 echo "stripping $strip"
92 if [ -z "$rpath" ]; then
93 die "$path resolves to nothing"
96 prefix=$(cleanpath "$prefix")
97 if [ ! -z "$prefix" ]; then
98 rpath="$prefix/$rpath"
101 filetype=$(zpm stat -f '%t' "$path")
107 hash=$(zpm addfile $pkgfile "$path")
108 if [ $? -ne 0 ]; then
109 die "zpm addfile failed ($?): $pkgfile $path"
118 target=$(readlink $path)
123 sqlite3 $pkgfile <<EOS
124 PRAGMA foreign_keys = ON;
126 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
127 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
131 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}