#!/bin/sh package=${1:-$ZPMPACKAGE} shift pkgver=${ZPMPACKAGEVER:-1.0} pkgrel=${ZPMPACKAGEREL:-1} pkgroot=/ # option for "multipackage" just to let the system know that's what you meant # option to take filenames from stdin # parse package, version, release from file if not given while getopts :f:v:r:d:a:u:l:p:b:P: opt; do case $opt in R) pkgroot="$OPTARG" ;; f) pkgfile="$OPTARG" ;; v) pkgver="$OPTARG" ;; r) pkgrel="$OPTARG" ;; d) description="$OPTARG" ;; a) arch="$OPTARG" ;; u) url="$OPTARG" ;; l) licenses="$OPTARG" ;; p) packager="$OPTARG" ;; b) builddate="$OPTARG" ;; P) prefix="$OPTARG" ;; esac done set -e if [ -z "$pkgfile" ]; then pkgfile="$package-$pkgver-$pkgrel.zpm" fi appid=$(sqlite3 $pkgfile 'pragma application_id;' | ( echo obase = 16; cat - ) | bc) if [ "$appid" != "5A504442" ]; then echo $pkgfile does not appear to be a zpm package file exit 1 fi # check if package exists # run preinstall or preupgrade stage, in chroot # add package info and mark installing to local package database # each path: add to local db, extract, set mode/owner/mtime etc. # mark install done in local database for path in $*; do mtime=$(stat -c '%Y' $path) uid=$(stat -c '%u' $path) gid=$(stat -c '%g' $path) username=$(stat -c '%U' $path) groupname=$(stat -c '%G' $path) mode=$(stat -c '%a' $path) # strip off leading slashes rpath=$(echo "$path" | sed -e 's|^/*||') # and a leading ./ rpath=${rpath#./} rpath=$(echo "$rpath" | sed -e 's|^/*||') if [ -z "$rpath" ] || [ "$rpath" = '.' ]; then continue fi if [ ! -z "$prefix" ]; then # trailing slashes on prefix prefix=$(echo "$prefix" | sed -e 's|/*$||') rpath="$prefix/$rpath" fi if [ -f "$path" ]; then hash=$(./zpm-addfile $pkgfile $path) #if [ -z "$hash" ]; then continue; fi # TODO mtime, mode sqlite3 $pkgfile < $target"} printf "%s\n" $path done