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"
106 # treat un-adorned packages as uninstalls
109 # TODO option to attempt to resume an ongoing install
110 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
111 while getopts f:d:R:nSCvAObBLU opt; do
113 f) pkgfile="$OPTARG" ;;
114 d) localdb="$OPTARG" ;;
115 P) packagepath="$OPTARG" ;;
116 D) packagepath="$OPTARG:$packagepath" ;;
117 R) rootdir="$OPTARG" ;;
120 A) absorb=1; syncopts="${syncopts} -A" ;;
121 O) overwrite=1; syncopts="${syncopts} -O" ;;
126 L) ignorelibdeps=1 ;;
129 *) die "usage ..." ;;
132 shift $(( OPTIND - 1))
134 ZPMDB=${localdb:-${ZPMDB:-/var/lib/zpm/local.db}}
136 # create the localdb if needed
139 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
145 -*) pkgid=$(zpm findpkg -I "${op#-}")
146 if [ -n "$pkgid" ]; then
147 to_remove="$to_remove $pkgid"
149 die "$op not installed"
153 search="$search $pkg"
157 pkgid=$(zpm findpkg -f $file $pkg)
158 if [ -n $pkgid ]; then
159 merge="$merge $pkgid:$file"
161 die "can't find $pkg in $file"
165 if [ $uninstall -eq 0 ]; then
168 pkgid=$(zpm findpkg -I "${op}")
169 if [ -n "$pkgid" ]; then
170 to_remove="$to_remove $pkgid"
172 die "$op not installed"
179 search=$(echo $search)
183 if [ $ignorelibdeps -eq 1 ]; then
184 merge=$(zpm search -iIO $search)
186 merge=$(zpm search -iIO -l $search)
189 if [ $? -ne 0 ]; then
190 warn "unmet packages or dependencies, or errors"
195 for mergepkg in $merge; do
196 pkgid=${mergepkg%%:*}
197 installset="$installset $pkgid"
199 installset=$(printf "%s\n" $installset | sort -u)
201 # TODO check for downgrade
207 for mergepkg in $merge; do
209 repofile=${mergepkg#*:}
210 if [ ${repofile##*.} = 'repo' ]; then
211 status=$(zpm pkg -f $repofile $pkgid status)
212 reponame=$(basename $repofile .repo)
213 if [ "$status" != 'merged' ]; then
214 repodir=$(dirname $repofile)
215 zpmfile=$repodir/$reponame/$pkgid.zpm
216 if [ -f "$zpmfile" ]; then
217 nlist="$nlist $pkgid:$zpmfile"
220 echo downloading $zpmfile
221 zpm repo fetch $reponame $pkgid
222 if [ -f "$zpmfile" ]; then
223 nlist="$nlist $pkgid:$zpmfile"
225 baddl="$baddl $reponame:$pkgid"
230 nlist="$nlist $mergepkg"
236 if [ -n "$baddl" ]; then
237 printf 'unable to download: %s\n' $baddl
241 if [ $justlist -eq 1 ]; then
242 for package in $merge; do
244 printf 'install %s\n' $pkgid
246 for pkgid in $to_remove; do
247 printf 'remove %s\n' $pkgid
252 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
257 test -n "$merge" && echo "install: $merge"
258 test -n "$to_remove" && echo "remove: $to_remove"
260 # finally, merge everything
261 for mergepkg in $merge; do
263 pkgfile=${mergepkg#*:}
265 # we could have found the package already in the localdb
266 # in which case, we don't need to merge it
267 # TODO check for symlinks?
268 if [ $pkgfile != $ZPMDB ]; then
269 echo merging $pkgfile $pkgid
270 zpm merge -Fuv -f "$pkgfile" $pkgid
271 if [ $? -ne 0 ]; then
272 die "unable to merge $pkgfile"
275 to_install="$to_install $pkgid"
278 to_install=${to_install#' '}
280 echo "installing: $to_install"
282 # absorb anything we're updating or removing, if absorb flag set
284 if [ -n "$to_install" ]; then
285 for pkgid in $to_install; do
286 current=$(current_version $pkgid)
287 maybe_run pre-install $pkgid $runscripts $current || die
291 if [ -n "$to_remove" ]; then
292 for pkgid in $to_remove; do
293 maybe_run pre-remove $pkgid $runscripts || die
297 if [ -n "$to_install" ]; then
298 for pkgid in $to_install; do
299 zpm pkg $pkgid status=installing
301 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
304 if [ -n "$to_remove" ]; then
305 for pkgid in $to_remove; do
306 zpm pkg $pkgid status=removing
310 if [ -n "$rootdir" ]; then
311 ZPM_ROOT_DIR=$rootdir
313 : rootdir=${rootdir%%/}
316 if [ $dryrun -gt 0 ]; then
317 runscripts=0 # we don't want to run post scripts on a dry-run
318 syncopts="$syncopts -n"
321 if [ $verbose -gt 0 ]; then
322 syncopts="${syncopts} -v"
324 # force -v during development
325 syncopts="${syncopts} -v"
328 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
330 #zpm absorb -s updating
331 #zpm absorb -s removing
334 zpm syncfs $syncopts || die 'zpm-syncfs failed';
336 if [ -n "$to_remove" ]; then
337 for pkgid in $to_remove; do
338 maybe_run post-remove $pkgid $runscripts
342 changeall removing removed
343 changeall updating updated
345 echo running ldconfig
346 run_ldconfig $rootdir
348 if [ -n "$to_install" ]; then
349 for pkgid in $to_install; do
350 package=$(zpm parse -n $pkgid)
351 current=$(zpm list -s installed "$package")
353 maybe_run post-install $pkgid $runscripts $current
355 if [ -n "$current" ]; then
356 zpm pkg $pkgid status=installed :$current status=updated
358 zpm pkg $pkgid status=installed
361 maybe_run configure $pkgid $runconfigure
364 echo install complete