3 pkgver=${ZPMPKGVER:-1.0}
6 # option for "multipackage" just to let the system know that's what you meant
7 # option to take filenames from stdin
8 # parse package, version, release from file if not given
9 while getopts :f:v:r:d:a:u:l:p:b:P: opt; do
11 f) pkgfile="$OPTARG" ;;
12 v) pkgver="$OPTARG" ;;
13 r) pkgrel="$OPTARG" ;;
14 d) description="$OPTARG" ;;
17 l) licenses="$OPTARG" ;;
18 p) packager="$OPTARG" ;;
19 b) builddate="$OPTARG" ;;
20 P) prefix="$OPTARG" ;;
22 c) tags="$tags +configuration" ;;
34 if [ -z "$package" ]; then
35 die "must specify package"
39 if [ -z "$pkgfile" ]; then
40 pkgfile="$package-$pkgver-$pkgrel.zpm"
43 # make sure package exists
44 zpm newpackage -I -f $pkgfile -v $pkgver -r $pkgrel $package || exit 1
49 mtime=$(zpm stat -f '%y' $path)
50 uid=$(zpm stat -f '%u' $path)
51 gid=$(zpm stat -f '%g' $path)
52 username=$(zpm stat -f '%U' $path)
53 groupname=$(zpm stat -f '%G' $path)
54 mode=$(zpm stat -f '%a' $path)
56 # strip off leading slashes
57 rpath=$(echo "$path" | sed -e 's|^/*||')
60 rpath=$(echo "$rpath" | sed -e 's|^/*||')
62 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
66 if [ ! -z "$prefix" ]; then
67 # trailing slashes on prefix
68 prefix=$(echo "$prefix" | sed -e 's|/*$||')
69 rpath="$prefix/$rpath"
72 filetype=$(zpm stat -f '%t' "$path")
78 hash=$(zpm addfile $pkgfile "$path")
80 die "zpm addfile failed ($?): $pkgfile $path"
89 target=$(readlink $path)
94 sqlite3 $pkgfile <<EOS
95 PRAGMA foreign_keys = ON;
97 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
98 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
102 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}