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:nSCvAObBLUz 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 *) die "usage ..." ;;
134 shift $(( OPTIND - 1))
136 ZPMDB=${localdb:-${ZPMDB:-/var/lib/zpm/local.db}}
138 # create the localdb if needed
141 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
147 -*) pkgid=$(zpm findpkg -I "${op#-}")
148 if [ -n "$pkgid" ]; then
149 to_remove="$to_remove $pkgid"
151 die "$op not installed"
155 search="$search $pkg"
159 pkgid=$(zpm findpkg -f $file $pkg)
160 if [ -n $pkgid ]; then
161 merge="$merge $pkgid:$file"
163 die "can't find $pkg in $file"
167 if [ $uninstall -eq 0 ]; then
170 pkgid=$(zpm findpkg -I "${op}")
171 if [ -n "$pkgid" ]; then
172 to_remove="$to_remove $pkgid"
174 die "$op not installed"
181 search=$(echo $search)
185 if [ $pullrepos -eq 1 ]; then
190 if [ $ignorelibdeps -eq 1 ]; then
191 merge=$(zpm search -iIO $search)
193 merge=$(zpm search -iIO -l $search)
196 if [ $? -ne 0 ]; then
197 warn "unmet packages or dependencies, or errors"
202 for mergepkg in $merge; do
203 pkgid=${mergepkg%%:*}
204 installset="$installset $pkgid"
206 installset=$(printf "%s\n" $installset | sort -u)
208 # TODO check for downgrade
214 for mergepkg in $merge; do
216 repofile=${mergepkg#*:}
217 if [ ${repofile##*.} = 'repo' ]; then
218 status=$(zpm pkg -f $repofile $pkgid status)
219 reponame=$(basename $repofile .repo)
220 if [ "$status" != 'merged' ]; then
221 repodir=$(dirname $repofile)
222 zpmfile=$repodir/$reponame/$pkgid.zpm
223 if [ -f "$zpmfile" ]; then
224 nlist="$nlist $pkgid:$zpmfile"
227 echo downloading $zpmfile
228 zpm repo fetch $reponame $pkgid
229 if [ -f "$zpmfile" ]; then
230 nlist="$nlist $pkgid:$zpmfile"
232 baddl="$baddl $reponame:$pkgid"
237 nlist="$nlist $mergepkg"
243 if [ -n "$baddl" ]; then
244 printf 'unable to download: %s\n' $baddl
248 for package in $merge; do
250 installlist="$installlist $pkgid"
252 installlist=${installlist#' '}
254 if [ $justlist -eq 1 ]; then
255 for package in $merge; do
257 printf 'install %s\n' $pkgid
259 for pkgid in $to_remove; do
260 printf 'remove %s\n' $pkgid
265 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
270 test -n "$merge" && echo "install: $installlist"
271 test -n "$to_remove" && echo "remove: $to_remove"
273 # finally, merge everything
274 for mergepkg in $merge; do
276 pkgfile=${mergepkg#*:}
278 # we could have found the package already in the localdb
279 # in which case, we don't need to merge it
280 # TODO check for symlinks?
281 if [ $pkgfile != $ZPMDB ]; then
282 echo merging $pkgfile $pkgid
283 zpm merge -Fuv -f "$pkgfile" $pkgid
284 if [ $? -ne 0 ]; then
285 die "unable to merge $pkgfile"
288 to_install="$to_install $pkgid"
291 to_install=${to_install#' '}
293 echo "installing: $to_install"
295 # absorb anything we're updating or removing, if absorb flag set
297 if [ -n "$to_install" ]; then
298 for pkgid in $to_install; do
299 current=$(current_version $pkgid)
300 maybe_run pre-install $pkgid $runscripts $current || die
304 if [ -n "$to_remove" ]; then
305 for pkgid in $to_remove; do
306 maybe_run pre-remove $pkgid $runscripts || die
310 if [ -n "$to_install" ]; then
311 for pkgid in $to_install; do
312 zpm pkg $pkgid status=installing
314 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
317 if [ -n "$to_remove" ]; then
318 for pkgid in $to_remove; do
319 zpm pkg $pkgid status=removing
323 if [ -n "$rootdir" ]; then
324 ZPM_ROOT_DIR=$rootdir
326 : rootdir=${rootdir%%/}
329 if [ $dryrun -gt 0 ]; then
330 runscripts=0 # we don't want to run post scripts on a dry-run
331 syncopts="$syncopts -n"
334 if [ $verbose -gt 0 ]; then
335 syncopts="${syncopts} -v"
337 # force -v during development
338 syncopts="${syncopts} -v"
341 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
343 #zpm absorb -s updating
344 #zpm absorb -s removing
347 zpm syncfs $syncopts || die 'zpm-syncfs failed';
349 if [ -n "$to_remove" ]; then
350 for pkgid in $to_remove; do
351 maybe_run post-remove $pkgid $runscripts
355 changeall removing removed
356 changeall updating updated
358 echo running ldconfig
359 run_ldconfig $rootdir
361 if [ -n "$to_install" ]; then
362 for pkgid in $to_install; do
363 package=$(zpm parse -n $pkgid)
364 current=$(zpm list -s installed "$package")
366 maybe_run post-install $pkgid $runscripts $current
368 if [ -n "$current" ]; then
369 zpm pkg $pkgid status=installed :$current status=updated
371 zpm pkg $pkgid status=installed
374 maybe_run configure $pkgid $runconfigure
377 echo install complete