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)
205 # TODO search for libs anyway and put a note for non-installed
208 merge=$(zpm search -iIO -l $search)
211 if [ $? -ne 0 ]; then
212 warn "unmet packages or dependencies, or errors"
217 for mergepkg in $merge; do
218 pkgid=${mergepkg%%:*}
219 installset="$installset $pkgid"
221 installset=$(printf "%s\n" $installset | sort -u)
223 # TODO check for downgrade
229 for mergepkg in $merge; do
231 repofile=${mergepkg#*:}
232 if [ ${repofile##*.} = 'repo' ]; then
233 status=$(zpm pkg -f $repofile $pkgid status)
234 reponame=$(basename $repofile .repo)
235 if [ "$status" != 'merged' ]; then
236 repodir=$(dirname $repofile)
237 zpmfile=$repodir/$reponame/$pkgid.zpm
238 if [ -f "$zpmfile" ]; then
239 nlist="$nlist $pkgid:$zpmfile"
242 zpm repo fetch $reponame $pkgid
243 if [ -f "$zpmfile" ]; then
244 nlist="$nlist $pkgid:$zpmfile"
246 baddl="$baddl $reponame:$pkgid"
251 nlist="$nlist $mergepkg"
257 if [ -n "$baddl" ]; then
258 printf 'unable to download: %s\n' $baddl
262 for package in $merge; do
264 installlist="$installlist $pkgid"
266 installlist=${installlist#' '}
268 if [ $justlist -eq 1 ]; then
269 for package in $merge; do
271 printf 'install %s\n' $pkgid
273 for pkgid in $to_remove; do
274 printf 'remove %s\n' $pkgid
279 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
284 test -n "$merge" && echo "install: $installlist"
285 test -n "$to_remove" && echo "remove: $to_remove"
287 # finally, merge everything
288 for mergepkg in $merge; do
290 pkgfile=${mergepkg#*:}
292 # we could have found the package already in the localdb
293 # in which case, we don't need to merge it
294 # TODO check for symlinks?
295 if [ $pkgfile != $ZPMDB ]; then
296 echo merging $pkgfile $pkgid
297 zpm merge -Fu -f "$pkgfile" $pkgid
298 if [ $? -ne 0 ]; then
299 die "unable to merge $pkgfile"
302 to_install="$to_install $pkgid"
305 to_install=${to_install#' '}
307 if [ -n "$to_install" ]; then
308 echo "installing: $to_install"
311 # absorb anything we're updating or removing, if absorb flag set
313 if [ -n "$to_install" ]; then
314 for pkgid in $to_install; do
315 current=$(current_version $pkgid)
316 maybe_run pre-install $pkgid $runscripts $current || die
320 if [ -n "$to_remove" ]; then
321 for pkgid in $to_remove; do
322 maybe_run pre-remove $pkgid $runscripts || die
326 if [ -n "$to_install" ]; then
327 for pkgid in $to_install; do
328 zpm pkg $pkgid status=installing
330 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
333 if [ -n "$to_remove" ]; then
334 for pkgid in $to_remove; do
335 zpm pkg $pkgid status=removing
339 if [ $dryrun -gt 0 ]; then
340 runscripts=0 # we don't want to run post scripts on a dry-run
341 syncopts="$syncopts -n"
344 if [ $verbose -gt 0 ]; then
345 syncopts="${syncopts} -v"
348 # force -v during development
349 #syncopts="${syncopts} -v"
352 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
354 #zpm absorb -s updating
355 #zpm absorb -s removing
358 zpm syncfs $syncopts || die 'zpm-syncfs failed';
360 if [ -n "$to_remove" ]; then
361 for pkgid in $to_remove; do
362 maybe_run post-remove $pkgid $runscripts
366 changeall removing removed
367 changeall updating updated
369 echo running ldconfig
370 run_ldconfig $rootdir
372 if [ -n "$to_install" ]; then
373 for pkgid in $to_install; do
374 package=$(zpm parse -n $pkgid)
375 current=$(zpm list -s installed "$package")
377 maybe_run post-install $pkgid $runscripts $current
379 if [ -n "$current" ]; then
380 zpm pkg $pkgid status=installed :$current status=updated
382 zpm pkg $pkgid status=installed
385 maybe_run configure $pkgid $runconfigure
388 echo install complete