3 package=${1:-$ZPMPACKAGE}
5 pkgver=${ZPMPACKAGEVER:-1.0}
6 pkgrel=${ZPMPACKAGEREL:-1}
8 # option for "multipackage" just to let the system know that's what you meant
9 # option to take filenames from stdin
10 # parse package, version, release from file if not given
11 while getopts :f:v:r:d:a:u:l:p:b:P: opt; do
13 f) pkgfile="$OPTARG" ;;
14 v) pkgver="$OPTARG" ;;
15 r) pkgrel="$OPTARG" ;;
16 d) description="$OPTARG" ;;
19 l) licenses="$OPTARG" ;;
20 p) packager="$OPTARG" ;;
21 b) builddate="$OPTARG" ;;
22 P) prefix="$OPTARG" ;;
27 if [ -z "$pkgfile" ]; then
28 pkgfile="$package-$pkgver-$pkgrel.zpm"
31 if [ ! -f $pkgfile ]; then
32 ./zpm-newpackage $package || exit 1
34 appid=$(sqlite3 $pkgfile 'pragma application_id;' | ( echo obase = 16; cat - ) | bc)
35 if [ "$appid" != "5A504442" ]; then
36 echo $pkgfile does not appear to be a zpm package file
42 mtime=$(stat -c '%Y' $path)
43 uid=$(stat -c '%u' $path)
44 gid=$(stat -c '%g' $path)
45 username=$(stat -c '%U' $path)
46 groupname=$(stat -c '%G' $path)
47 mode=$(stat -c '%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 if [ -f "$path" ]; then
67 hash=$(./zpm-addfile $pkgfile $path)
69 #if [ -z "$hash" ]; then continue; fi
72 sqlite3 $pkgfile <<EOS
73 PRAGMA foreign_keys = ON;
74 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,hash)
75 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$hash')
78 elif [ -d "$path" ]; then
79 sqlite3 $pkgfile <<EOS
80 PRAGMA foreign_keys = ON;
81 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname)
82 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname')
85 elif [ -l "$path" ]; then
86 target=$(readlink $path)
87 sqlite3 $pkgfile <<EOS
88 PRAGMA foreign_keys = ON;
89 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,target)
90 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$target')
94 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}