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 if [ $justlist -eq 1 ]; then
249 for package in $merge; do
251 printf 'install %s\n' $pkgid
253 for pkgid in $to_remove; do
254 printf 'remove %s\n' $pkgid
259 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
264 test -n "$merge" && echo "install: $merge"
265 test -n "$to_remove" && echo "remove: $to_remove"
267 # finally, merge everything
268 for mergepkg in $merge; do
270 pkgfile=${mergepkg#*:}
272 # we could have found the package already in the localdb
273 # in which case, we don't need to merge it
274 # TODO check for symlinks?
275 if [ $pkgfile != $ZPMDB ]; then
276 echo merging $pkgfile $pkgid
277 zpm merge -Fuv -f "$pkgfile" $pkgid
278 if [ $? -ne 0 ]; then
279 die "unable to merge $pkgfile"
282 to_install="$to_install $pkgid"
285 to_install=${to_install#' '}
287 echo "installing: $to_install"
289 # absorb anything we're updating or removing, if absorb flag set
291 if [ -n "$to_install" ]; then
292 for pkgid in $to_install; do
293 current=$(current_version $pkgid)
294 maybe_run pre-install $pkgid $runscripts $current || die
298 if [ -n "$to_remove" ]; then
299 for pkgid in $to_remove; do
300 maybe_run pre-remove $pkgid $runscripts || die
304 if [ -n "$to_install" ]; then
305 for pkgid in $to_install; do
306 zpm pkg $pkgid status=installing
308 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
311 if [ -n "$to_remove" ]; then
312 for pkgid in $to_remove; do
313 zpm pkg $pkgid status=removing
317 if [ -n "$rootdir" ]; then
318 ZPM_ROOT_DIR=$rootdir
320 : rootdir=${rootdir%%/}
323 if [ $dryrun -gt 0 ]; then
324 runscripts=0 # we don't want to run post scripts on a dry-run
325 syncopts="$syncopts -n"
328 if [ $verbose -gt 0 ]; then
329 syncopts="${syncopts} -v"
331 # force -v during development
332 syncopts="${syncopts} -v"
335 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
337 #zpm absorb -s updating
338 #zpm absorb -s removing
341 zpm syncfs $syncopts || die 'zpm-syncfs failed';
343 if [ -n "$to_remove" ]; then
344 for pkgid in $to_remove; do
345 maybe_run post-remove $pkgid $runscripts
349 changeall removing removed
350 changeall updating updated
352 echo running ldconfig
353 run_ldconfig $rootdir
355 if [ -n "$to_install" ]; then
356 for pkgid in $to_install; do
357 package=$(zpm parse -n $pkgid)
358 current=$(zpm list -s installed "$package")
360 maybe_run post-install $pkgid $runscripts $current
362 if [ -n "$current" ]; then
363 zpm pkg $pkgid status=installed :$current status=updated
365 zpm pkg $pkgid status=installed
368 maybe_run configure $pkgid $runconfigure
371 echo install complete