3 package=${1:-$ZPMPACKAGE}
5 pkgver=${ZPMPACKAGEVER:-1.0}
6 pkgrel=${ZPMPACKAGEREL:-1}
10 # option for "multipackage" just to let the system know that's what you meant
11 # option to take filenames from stdin
12 # parse package, version, release from file if not given
13 while getopts :f:v:r:d:a:u:l:p:b:P: opt; do
15 R) pkgroot="$OPTARG" ;;
16 f) pkgfile="$OPTARG" ;;
17 v) pkgver="$OPTARG" ;;
18 r) pkgrel="$OPTARG" ;;
19 d) description="$OPTARG" ;;
22 l) licenses="$OPTARG" ;;
23 p) packager="$OPTARG" ;;
24 b) builddate="$OPTARG" ;;
25 P) prefix="$OPTARG" ;;
30 if [ -z "$pkgfile" ]; then
31 pkgfile="$package-$pkgver-$pkgrel.zpm"
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
40 # check if package exists
41 # run preinstall or preupgrade stage, in chroot
43 # add package info and mark installing to local package database
44 # each path: add to local db, extract, set mode/owner/mtime etc.
45 # mark install done in local database
48 mtime=$(stat -c '%Y' $path)
49 uid=$(stat -c '%u' $path)
50 gid=$(stat -c '%g' $path)
51 username=$(stat -c '%U' $path)
52 groupname=$(stat -c '%G' $path)
53 mode=$(stat -c '%a' $path)
55 # strip off leading slashes
56 rpath=$(echo "$path" | sed -e 's|^/*||')
59 rpath=$(echo "$rpath" | sed -e 's|^/*||')
61 if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then
65 if [ ! -z "$prefix" ]; then
66 # trailing slashes on prefix
67 prefix=$(echo "$prefix" | sed -e 's|/*$||')
68 rpath="$prefix/$rpath"
71 if [ -f "$path" ]; then
73 hash=$(./zpm-addfile $pkgfile $path)
75 #if [ -z "$hash" ]; then continue; fi
78 sqlite3 $pkgfile <<EOS
79 PRAGMA foreign_keys = ON;
80 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,hash)
81 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$hash')
84 elif [ -d "$path" ]; then
85 sqlite3 $pkgfile <<EOS
86 PRAGMA foreign_keys = ON;
87 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname)
88 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname')
91 elif [ -l "$path" ]; then
92 target=$(readlink $path)
93 sqlite3 $pkgfile <<EOS
94 PRAGMA foreign_keys = ON;
95 insert or replace into packagefiles (package,version,release,path,mode,mtime,username,groupname,target)
96 values ('$package', '$pkgver', $pkgrel, '$rpath', '$mode',$mtime, '$username','$groupname','$target')
100 #printf "%s %s%s\n" $path $rpath ${target:+" -> $target"}