9 zpm log -i -a 'aborting install' -t "$pkgid" "$*"
14 for pkgid in $(zpm list -s $1); do
15 zpm pkg $pkgid status=$2
29 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
30 while getopts f:d:R:nSCvAOaF opt; do
32 f) pkgfile="$OPTARG" ;;
34 d) localdb="$OPTARG" ;;
35 R) rootdir="$OPTARG" ;;
38 A) absorb=1; syncopts="${syncopts} -A" ;;
40 O) overwrite=1; syncopts="${syncopts} -O" ;;
46 shift $(( OPTIND - 1))
52 if [ -z "$pkgfile" ]; then
53 pkgfile=$ZPM_PACKAGE_FILE
56 if [ $installall -eq 1 ]; then
57 pkglist="$(zpm list -f $pkgfile)"
59 pkglist=$(zpm findpkg -f $pkgfile "$1")
62 if [ $verbose -gt 0 ]; then
66 if [ -z "$pkglist" ]; then
67 die "$0 no packages specified for install"
70 if [ "$idempotent" = 1 ]; then
71 idempotent='or ignore'
74 if [ -n "$rootdir" ]; then
75 : rootdir=${rootdir%%/}
78 if [ -z "$localdb" ]; then
79 localdb=${rootdir}/var/lib/zpm/local.db
82 if [ ! -f "$localdb" ]; then
83 if [ -n "$rootdir" ] && [ ! -d $rootdir ]; then
84 mkdir $rootdir || die "can't create $rootdir: $!"
86 for d in /var /var/lib /var/lib/zpm; do
87 test -d $rootdir/$d || mkdir $rootdir/$d || die "can't create $rootdir/$d/: $!"
91 die "aborting install"
98 if [ -z "$ZPMDB" ]; then
101 #echo "localdb = $ZPMDB"
105 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
107 # check if we're installing something already
108 var=$(zpm list -f $localdb -s installing | wc -l)
109 if [ $var -gt 0 ]; then
110 zpm list -v -f $localdb -s installing
111 die "already ($localdb) installing $var package(s)"
113 # check if we're removing something already
114 var=$(zpm list -f $localdb -s removing | wc -l)
115 if [ $var -gt 0 ]; then
116 zpm list -v -f $localdb -s removing
117 die "already ($localdb) removing $var package(s)"
119 var=$(zpm list -f $localdb -s updating | wc -l)
120 if [ $var -gt 0 ]; then
121 zpm list -v -f $localdb -s updating
122 die "already ($localdb) updating $var package(s)"
125 if [ -n "$rootdir" ]; then
126 ZPM_ROOT_DIR="$rootdir"
130 for pkgid in $pkglist; do
131 curstatus=$(zpm pkg $pkgid status)
132 if [ "$curstatus" = 'installed' ]; then
133 die "$pkgid already installed"
136 package=$(zpm parse -n $pkgid)
137 current=$(zpm list -s installed "$package")
139 if [ $runscripts -gt 0 ]; then
140 # TODO run pre-upgrade script if needed
141 # zpm runscript -p pre-upgrade $current $pkgid
142 zpm script -f $pkgfile -p pre-install $pkgid $current
143 if [ $? -ne 0 ]; then
144 die "pre-install script for $pkgid failed"
147 if zpm script -f $pkgfile -Fql -p pre-install $pkgid; then
148 zpm note -e -p $pkgid -m 'pre-install script not run'
152 # remove the package if it exists. can't be in an installed
153 # state, would have bailed above. So, if it exists, can only
154 # be 'upgraded'. This should be fast, because we won't run
155 # a garbage collect, so any possible duplicate files between
156 # an upgraded or removed files, if they're there, won't need
159 # only merge if localdb and pkgfile are different
160 if [ "$pkgfile" != "$ZPMDB" ]; then
162 if [ $verbose -gt 0 ]; then
165 if [ $mergefiles -eq 1 ]; then
166 zpm merge -u -F -f $pkgfile -s installing $pkgid
168 zpm merge -u -f $pkgfile -s installing $pkgid
170 if [ $? -ne 0 ]; then
171 die "merging $pkgid failed"
174 zpm pkg $pkgid status=installing
177 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
182 #zpm shell $ZPMDB 'select * from install_status' 1>&2
183 if [ $dryrun -gt 0 ]; then
184 syncopts="$syncopts -n"
187 if [ $verbose -gt 0 ]; then
188 syncopts="$syncopts -v"
191 if [ "$pkgfile" != "$ZPMDB" ]; then
192 syncopts="$syncopts -f $pkgfile"
195 #zpm shell $ZPMDB 'select * from syncinfo'
201 if [ $dryrun -gt 0 ]; then
202 for pkgid in $pkglist; do
203 zpm pkg $pkgid status=dryrun
207 if [ $syncrv -ne 0 ]; then
208 zpm pkg $pkgid status=failed
209 die 'zpm-syncfs failed';
212 if [ $(id -u) -eq 0 ]; then
213 if [ ! -d $rootdir/etc ]; then
214 warn "no etc directory in $rootdir, skipping ldconfig"
215 elif [ -f $rootdir/sbin/ldconfig ]; then
216 $rootdir/sbin/ldconfig -r ${rootdir:-/}
217 elif [ -f /sbin/ldconfig ]; then
218 /sbin/ldconfig -r ${rootdir:-/}
224 for pkgid in $pkglist; do
225 package=$(zpm parse -n $pkgid)
226 current=$(zpm list -s updating "$package")
228 if [ $runscripts -gt 0 ]; then
229 zpm script -p post-install $pkgid $current
231 if zpm script -Fql -p post-install $pkgid; then
232 zpm note -e -p $pkgid -m 'post-install script not run'
236 if [ -n "$current" ]; then
237 zpm pkg $pkgid status=installed :$current status=updated
239 zpm pkg $pkgid status=installed
242 # TODO skip configure if not on a terminal, regardless of settings
243 # TODO will need force option
244 if [ $runconfigure -gt 0 ]; then
245 zpm script -p configure $pkgid
247 if zpm script -Fql -p configure $pkgid; then
248 zpm note -e -p $pkgid -m 'configure script not run'
254 changeall updating updated