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')
31 # option for "multipackage" just to let the system know that's what you meant
32 # option to take filenames from stdin
33 # parse package, version, release from file if not given
34 while getopts :f:v:r:l:P:S:Ccu:g: opt; do
36 f) pkgfile="$OPTARG" ;;
37 v) pkgver="$OPTARG" ;;
38 r) pkgrel="$OPTARG" ;;
39 l) licenses="$OPTARG" ;;
40 P) prefix="$OPTARG" ;;
41 S) strip=$(cleanpath "$OPTARG"); ;;
42 t) tags="$tags $OPTARG" ;;
43 c) tags="$tags configuration" ;;
45 u) username="$OPTARG" ;;
46 g) groupname="$OPTARG" ;;
47 *) echo 'unknown option' $opt; exit 1 ;;
54 if [ -z "$package" ]; then
55 die "must specify package"
59 if [ -z "$pkgfile" ]; then
60 pkgfile="$package-$pkgver-$pkgrel.zpm"
63 # check for package file
64 if [ ! -f "$pkgfile" ]; then
65 if [ $create -eq 1 ]; then
66 echo creating $pkgfile
67 zpm newpackage -I -f $pkgfile -v $pkgver -r $pkgrel $package || exit 1
69 echo $pkgfile does not exist
76 #strip=$(cleanpath "$strip")
79 mtime=$(zpm stat -f '%y' $path)
80 uid=$(zpm stat -f '%u' $path)
81 gid=$(zpm stat -f '%g' $path)
82 : ${username:=$(zpm stat -f '%U' $path)}
83 : ${groupname:=$(zpm stat -f '%G' $path)}
84 mode=$(zpm stat -f '%a' $path)
87 rpath=$(cleanpath "$path")
89 # strip off leading slash
92 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
96 if [ ! -z "$strip" ]; then
97 echo "stripping $strip"
102 if [ -z "$rpath" ]; then
103 die "$path resolves to nothing"
106 prefix=$(cleanpath "$prefix")
107 if [ ! -z "$prefix" ]; then
108 rpath="$prefix/$rpath"
111 filetype=$(zpm stat -f '%t' "$path")
117 hash=$(zpm addfile $pkgfile "$path")
118 if [ $? -ne 0 ]; then
119 die "zpm addfile failed ($?): $pkgfile $path"
128 target=$(readlink $path)
133 # TODO check that we have such a package,version,release
134 zpm shell $pkgfile <<EOS
135 PRAGMA foreign_keys = ON;
137 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
138 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
142 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}