8 if [ $(id -u) -eq 0 ]; then
9 if [ ! -d $1/etc ]; then
10 warn "no etc directory in $1, skipping ldconfig"
11 elif [ -f $1/sbin/ldconfig ]; then
12 $1/sbin/ldconfig -r ${1:-/}
13 elif [ -f /sbin/ldconfig ]; then
14 /sbin/ldconfig -r ${1:-/}
22 for pkgid in $(zpm list -s $1); do
23 zpm pkg $pkgid status=$2
31 zpm log -i -a 'aborted install' -t "$pkgid" "$*"
33 changeall removing installed
34 changeall updating installed
39 zpm list -s installed $(zpm parse -n $1)
48 if [ $run -gt 0 ]; then
49 zpm script -p $phase $pkgid $current
51 if [ $rv -ne 0 ]; then
52 warn "$phase script for $pkgid failed"
56 if zpm script -Fql -p $phase $pkgid; then
57 zpm note -e -p $pkgid -m "$phase script not run"
64 # check if we're installing something already
65 var=$(zpm list -s installing | wc -l)
66 if [ $var -gt 0 ]; then
67 zpm list -v -f $localdb -s installing
68 warn "already ($localdb) installing $var package(s)"
71 var=$(zpm list -s removing | wc -l)
72 if [ $var -gt 0 ]; then
73 zpm list -v -f $localdb -s removing
74 warn "already ($localdb) removing $var package(s)"
77 var=$(zpm list -s updating | wc -l)
78 if [ $var -gt 0 ]; then
79 zpm list -v -f $localdb -s updating
80 warn "already ($localdb) updating $var package(s)"
83 if [ $rv -ne 0 ]; then
96 packagepath="/var/lib/zpm/packages"
107 # treat un-adorned packages as uninstalls
110 # TODO option to attempt to resume an ongoing install
111 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
112 while getopts f:d:R:nSCvAObBLUzp opt; do
114 f) pkgfile="$OPTARG" ;;
115 d) localdb="$OPTARG" ;;
116 P) packagepath="$OPTARG" ;;
117 D) packagepath="$OPTARG:$packagepath" ;;
118 R) rootdir="$OPTARG" ;;
121 A) absorb=1; syncopts="${syncopts} -A" ;;
122 O) overwrite=1; syncopts="${syncopts} -O" ;;
127 L) ignorelibdeps=1 ;;
131 p) syncopts="$syncopts -p" ;;
132 *) die "usage ..." ;;
135 shift $(( OPTIND - 1 ))
137 if [ -n "$rootdir" ]; then
138 : rootdir=${rootdir%%/}
139 ZPM_ROOT_DIR=$rootdir
143 if [ -n "$localdb" ]; then
145 elif [ -z "$ZPMDB" ]; then
146 ZPMDB="$ZPM_ROOT_DIR/var/lib/zpm/local.db"
151 # create the localdb if needed
154 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
160 -*) pkgid=$(zpm findpkg -I "${op#-}")
161 if [ -n "$pkgid" ]; then
162 to_remove="$to_remove $pkgid"
164 die "$op not installed"
168 search="$search $pkg"
172 pkgid=$(zpm findpkg -f $file $pkg)
173 if [ -n $pkgid ]; then
174 merge="$merge $pkgid:$file"
176 die "can't find $pkg in $file"
180 if [ $uninstall -eq 0 ]; then
183 pkgid=$(zpm findpkg -I "${op}")
184 if [ -n "$pkgid" ]; then
185 to_remove="$to_remove $pkgid"
187 die "$op not installed"
194 search=$(echo $search)
198 if [ $pullrepos -eq 1 ]; then
203 if [ $ignorelibdeps -eq 1 ]; then
204 merge=$(zpm search -iIO $search)
206 merge=$(zpm search -iIO -l $search)
209 if [ $? -ne 0 ]; then
210 warn "unmet packages or dependencies, or errors"
215 for mergepkg in $merge; do
216 pkgid=${mergepkg%%:*}
217 installset="$installset $pkgid"
219 installset=$(printf "%s\n" $installset | sort -u)
221 # TODO check for downgrade
227 for mergepkg in $merge; do
229 repofile=${mergepkg#*:}
230 if [ ${repofile##*.} = 'repo' ]; then
231 status=$(zpm pkg -f $repofile $pkgid status)
232 reponame=$(basename $repofile .repo)
233 if [ "$status" != 'merged' ]; then
234 repodir=$(dirname $repofile)
235 zpmfile=$repodir/$reponame/$pkgid.zpm
236 if [ -f "$zpmfile" ]; then
237 nlist="$nlist $pkgid:$zpmfile"
240 echo downloading $zpmfile
241 zpm repo fetch $reponame $pkgid
242 if [ -f "$zpmfile" ]; then
243 nlist="$nlist $pkgid:$zpmfile"
245 baddl="$baddl $reponame:$pkgid"
250 nlist="$nlist $mergepkg"
256 if [ -n "$baddl" ]; then
257 printf 'unable to download: %s\n' $baddl
261 for package in $merge; do
263 installlist="$installlist $pkgid"
265 installlist=${installlist#' '}
267 if [ $justlist -eq 1 ]; then
268 for package in $merge; do
270 printf 'install %s\n' $pkgid
272 for pkgid in $to_remove; do
273 printf 'remove %s\n' $pkgid
278 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
283 test -n "$merge" && echo "install: $installlist"
284 test -n "$to_remove" && echo "remove: $to_remove"
286 # finally, merge everything
287 for mergepkg in $merge; do
289 pkgfile=${mergepkg#*:}
291 # we could have found the package already in the localdb
292 # in which case, we don't need to merge it
293 # TODO check for symlinks?
294 if [ $pkgfile != $ZPMDB ]; then
295 echo merging $pkgfile $pkgid
296 zpm merge -Fuv -f "$pkgfile" $pkgid
297 if [ $? -ne 0 ]; then
298 die "unable to merge $pkgfile"
301 to_install="$to_install $pkgid"
304 to_install=${to_install#' '}
306 if [ -n "$to_install" ]; then
307 echo "installing: $to_install"
310 # absorb anything we're updating or removing, if absorb flag set
312 if [ -n "$to_install" ]; then
313 for pkgid in $to_install; do
314 current=$(current_version $pkgid)
315 maybe_run pre-install $pkgid $runscripts $current || die
319 if [ -n "$to_remove" ]; then
320 for pkgid in $to_remove; do
321 maybe_run pre-remove $pkgid $runscripts || die
325 if [ -n "$to_install" ]; then
326 for pkgid in $to_install; do
327 zpm pkg $pkgid status=installing
329 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
332 if [ -n "$to_remove" ]; then
333 for pkgid in $to_remove; do
334 zpm pkg $pkgid status=removing
338 if [ $dryrun -gt 0 ]; then
339 runscripts=0 # we don't want to run post scripts on a dry-run
340 syncopts="$syncopts -n"
343 if [ $verbose -gt 0 ]; then
344 syncopts="${syncopts} -v"
346 # force -v during development
347 syncopts="${syncopts} -v"
350 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
352 #zpm absorb -s updating
353 #zpm absorb -s removing
356 zpm syncfs $syncopts || die 'zpm-syncfs failed';
358 if [ -n "$to_remove" ]; then
359 for pkgid in $to_remove; do
360 maybe_run post-remove $pkgid $runscripts
364 changeall removing removed
365 changeall updating updated
367 echo running ldconfig
368 run_ldconfig $rootdir
370 if [ -n "$to_install" ]; then
371 for pkgid in $to_install; do
372 package=$(zpm parse -n $pkgid)
373 current=$(zpm list -s installed "$package")
375 maybe_run post-install $pkgid $runscripts $current
377 if [ -n "$current" ]; then
378 zpm pkg $pkgid status=installed :$current status=updated
380 zpm pkg $pkgid status=installed
383 maybe_run configure $pkgid $runconfigure
386 echo install complete