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" ;;
31 if [ -z "$pkgfile" ]; then
32 pkgfile="$package-$pkgver-$pkgrel.zpm"
35 if [ ! -f $pkgfile ]; then
36 zpm newpackage $package || exit 1
42 mtime=$(zpm stat -f '%y' $path)
43 uid=$(zpm stat -f '%u' $path)
44 gid=$(zpm stat -f '%g' $path)
45 username=$(zpm stat -f '%U' $path)
46 groupname=$(zpm stat -f '%G' $path)
47 mode=$(zpm stat -f '%a' $path)
49 # strip off leading slashes
50 rpath=$(echo "$path" | sed -e 's|^/*||')
53 rpath=$(echo "$rpath" | sed -e 's|^/*||')
55 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
59 if [ ! -z "$prefix" ]; then
60 # trailing slashes on prefix
61 prefix=$(echo "$prefix" | sed -e 's|/*$||')
62 rpath="$prefix/$rpath"
65 filetype=$(zpm stat -f '%t' "$path")
71 hash=$(zpm addfile $pkgfile "$path")
80 target=$(readlink $path)
85 sqlite3 $pkgfile <<EOS
86 PRAGMA foreign_keys = ON;
88 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,filetype,hash,target)
89 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$filetype',$hash,$target);
93 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}