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:Cc 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 *) echo 'unknown option' $opt; exit 1 ;;
52 if [ -z "$package" ]; then
53 die "must specify package"
57 if [ -z "$pkgfile" ]; then
58 pkgfile="$package-$pkgver-$pkgrel.zpm"
61 # check for package file
62 if [ ! -f "$pkgfile" ]; then
63 if [ $create -eq 1 ]; then
64 echo creating $pkgfile
65 zpm newpackage -I -f $pkgfile -v $pkgver -r $pkgrel $package || exit 1
67 echo $pkgfile does not exist
74 #strip=$(cleanpath "$strip")
77 mtime=$(zpm stat -f '%y' $path)
78 uid=$(zpm stat -f '%u' $path)
79 gid=$(zpm stat -f '%g' $path)
80 username=$(zpm stat -f '%U' $path)
81 groupname=$(zpm stat -f '%G' $path)
82 mode=$(zpm stat -f '%a' $path)
85 rpath=$(cleanpath "$path")
87 # strip off leading slash
90 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
94 if [ ! -z "$strip" ]; then
95 echo "stripping $strip"
100 if [ -z "$rpath" ]; then
101 die "$path resolves to nothing"
104 prefix=$(cleanpath "$prefix")
105 if [ ! -z "$prefix" ]; then
106 rpath="$prefix/$rpath"
109 filetype=$(zpm stat -f '%t' "$path")
115 hash=$(zpm addfile $pkgfile "$path")
116 if [ $? -ne 0 ]; then
117 die "zpm addfile failed ($?): $pkgfile $path"
126 target=$(readlink $path)
131 # TODO check that we have such a package,version,release
132 zpm shell $pkgfile <<EOS
133 PRAGMA foreign_keys = ON;
135 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
136 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
140 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}