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:nSCvAObBLUzpl 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 zpm repo fetch $reponame $pkgid
241 if [ -f "$zpmfile" ]; then
242 nlist="$nlist $pkgid:$zpmfile"
244 baddl="$baddl $reponame:$pkgid"
249 nlist="$nlist $mergepkg"
255 if [ -n "$baddl" ]; then
256 printf 'unable to download: %s\n' $baddl
260 for package in $merge; do
262 installlist="$installlist $pkgid"
264 installlist=${installlist#' '}
266 if [ $justlist -eq 1 ]; then
267 for package in $merge; do
269 printf 'install %s\n' $pkgid
271 for pkgid in $to_remove; do
272 printf 'remove %s\n' $pkgid
277 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
282 test -n "$merge" && echo "install: $installlist"
283 test -n "$to_remove" && echo "remove: $to_remove"
285 # finally, merge everything
286 for mergepkg in $merge; do
288 pkgfile=${mergepkg#*:}
290 # we could have found the package already in the localdb
291 # in which case, we don't need to merge it
292 # TODO check for symlinks?
293 if [ $pkgfile != $ZPMDB ]; then
294 echo merging $pkgfile $pkgid
295 zpm merge -Fuv -f "$pkgfile" $pkgid
296 if [ $? -ne 0 ]; then
297 die "unable to merge $pkgfile"
300 to_install="$to_install $pkgid"
303 to_install=${to_install#' '}
305 if [ -n "$to_install" ]; then
306 echo "installing: $to_install"
309 # absorb anything we're updating or removing, if absorb flag set
311 if [ -n "$to_install" ]; then
312 for pkgid in $to_install; do
313 current=$(current_version $pkgid)
314 maybe_run pre-install $pkgid $runscripts $current || die
318 if [ -n "$to_remove" ]; then
319 for pkgid in $to_remove; do
320 maybe_run pre-remove $pkgid $runscripts || die
324 if [ -n "$to_install" ]; then
325 for pkgid in $to_install; do
326 zpm pkg $pkgid status=installing
328 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
331 if [ -n "$to_remove" ]; then
332 for pkgid in $to_remove; do
333 zpm pkg $pkgid status=removing
337 if [ $dryrun -gt 0 ]; then
338 runscripts=0 # we don't want to run post scripts on a dry-run
339 syncopts="$syncopts -n"
342 if [ $verbose -gt 0 ]; then
343 syncopts="${syncopts} -v"
345 # force -v during development
346 syncopts="${syncopts} -v"
349 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
351 #zpm absorb -s updating
352 #zpm absorb -s removing
355 zpm syncfs $syncopts || die 'zpm-syncfs failed';
357 if [ -n "$to_remove" ]; then
358 for pkgid in $to_remove; do
359 maybe_run post-remove $pkgid $runscripts
363 changeall removing removed
364 changeall updating updated
366 echo running ldconfig
367 run_ldconfig $rootdir
369 if [ -n "$to_install" ]; then
370 for pkgid in $to_install; do
371 package=$(zpm parse -n $pkgid)
372 current=$(zpm list -s installed "$package")
374 maybe_run post-install $pkgid $runscripts $current
376 if [ -n "$current" ]; then
377 zpm pkg $pkgid status=installed :$current status=updated
379 zpm pkg $pkgid status=installed
382 maybe_run configure $pkgid $runconfigure
385 echo install complete