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 ZPMDB=${localdb:-${ZPMDB:-/var/lib/zpm/local.db}}
139 # create the localdb if needed
142 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
148 -*) pkgid=$(zpm findpkg -I "${op#-}")
149 if [ -n "$pkgid" ]; then
150 to_remove="$to_remove $pkgid"
152 die "$op not installed"
156 search="$search $pkg"
160 pkgid=$(zpm findpkg -f $file $pkg)
161 if [ -n $pkgid ]; then
162 merge="$merge $pkgid:$file"
164 die "can't find $pkg in $file"
168 if [ $uninstall -eq 0 ]; then
171 pkgid=$(zpm findpkg -I "${op}")
172 if [ -n "$pkgid" ]; then
173 to_remove="$to_remove $pkgid"
175 die "$op not installed"
182 search=$(echo $search)
186 if [ $pullrepos -eq 1 ]; then
191 if [ $ignorelibdeps -eq 1 ]; then
192 merge=$(zpm search -iIO $search)
194 merge=$(zpm search -iIO -l $search)
197 if [ $? -ne 0 ]; then
198 warn "unmet packages or dependencies, or errors"
203 for mergepkg in $merge; do
204 pkgid=${mergepkg%%:*}
205 installset="$installset $pkgid"
207 installset=$(printf "%s\n" $installset | sort -u)
209 # TODO check for downgrade
215 for mergepkg in $merge; do
217 repofile=${mergepkg#*:}
218 if [ ${repofile##*.} = 'repo' ]; then
219 status=$(zpm pkg -f $repofile $pkgid status)
220 reponame=$(basename $repofile .repo)
221 if [ "$status" != 'merged' ]; then
222 repodir=$(dirname $repofile)
223 zpmfile=$repodir/$reponame/$pkgid.zpm
224 if [ -f "$zpmfile" ]; then
225 nlist="$nlist $pkgid:$zpmfile"
228 echo downloading $zpmfile
229 zpm repo fetch $reponame $pkgid
230 if [ -f "$zpmfile" ]; then
231 nlist="$nlist $pkgid:$zpmfile"
233 baddl="$baddl $reponame:$pkgid"
238 nlist="$nlist $mergepkg"
244 if [ -n "$baddl" ]; then
245 printf 'unable to download: %s\n' $baddl
249 for package in $merge; do
251 installlist="$installlist $pkgid"
253 installlist=${installlist#' '}
255 if [ $justlist -eq 1 ]; then
256 for package in $merge; do
258 printf 'install %s\n' $pkgid
260 for pkgid in $to_remove; do
261 printf 'remove %s\n' $pkgid
266 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
271 test -n "$merge" && echo "install: $installlist"
272 test -n "$to_remove" && echo "remove: $to_remove"
274 # finally, merge everything
275 for mergepkg in $merge; do
277 pkgfile=${mergepkg#*:}
279 # we could have found the package already in the localdb
280 # in which case, we don't need to merge it
281 # TODO check for symlinks?
282 if [ $pkgfile != $ZPMDB ]; then
283 echo merging $pkgfile $pkgid
284 zpm merge -Fuv -f "$pkgfile" $pkgid
285 if [ $? -ne 0 ]; then
286 die "unable to merge $pkgfile"
289 to_install="$to_install $pkgid"
292 to_install=${to_install#' '}
294 if [ -n "$to_install" ]; then
295 echo "installing: $to_install"
298 # absorb anything we're updating or removing, if absorb flag set
300 if [ -n "$to_install" ]; then
301 for pkgid in $to_install; do
302 current=$(current_version $pkgid)
303 maybe_run pre-install $pkgid $runscripts $current || die
307 if [ -n "$to_remove" ]; then
308 for pkgid in $to_remove; do
309 maybe_run pre-remove $pkgid $runscripts || die
313 if [ -n "$to_install" ]; then
314 for pkgid in $to_install; do
315 zpm pkg $pkgid status=installing
317 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
320 if [ -n "$to_remove" ]; then
321 for pkgid in $to_remove; do
322 zpm pkg $pkgid status=removing
326 if [ -n "$rootdir" ]; then
327 ZPM_ROOT_DIR=$rootdir
329 : rootdir=${rootdir%%/}
332 if [ $dryrun -gt 0 ]; then
333 runscripts=0 # we don't want to run post scripts on a dry-run
334 syncopts="$syncopts -n"
337 if [ $verbose -gt 0 ]; then
338 syncopts="${syncopts} -v"
340 # force -v during development
341 syncopts="${syncopts} -v"
344 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
346 #zpm absorb -s updating
347 #zpm absorb -s removing
350 zpm syncfs $syncopts || die 'zpm-syncfs failed';
352 if [ -n "$to_remove" ]; then
353 for pkgid in $to_remove; do
354 maybe_run post-remove $pkgid $runscripts
358 changeall removing removed
359 changeall updating updated
361 echo running ldconfig
362 run_ldconfig $rootdir
364 if [ -n "$to_install" ]; then
365 for pkgid in $to_install; do
366 package=$(zpm parse -n $pkgid)
367 current=$(zpm list -s installed "$package")
369 maybe_run post-install $pkgid $runscripts $current
371 if [ -n "$current" ]; then
372 zpm pkg $pkgid status=installed :$current status=updated
374 zpm pkg $pkgid status=installed
377 maybe_run configure $pkgid $runconfigure
380 echo install complete