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
251 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
258 # finally, merge everything
259 for mergepkg in $merge; do
261 pkgfile=${mergepkg#*:}
263 # we could have found the package already in the localdb
264 # in which case, we don't need to merge it
265 # TODO check for symlinks?
266 if [ $pkgfile != $ZPMDB ]; then
267 echo merging $pkgfile $pkgid
268 zpm merge -Fuv -f "$pkgfile" $pkgid
270 to_install="$to_install $pkgid"
273 to_install=${to_install#' '}
275 echo "installing: $to_install"
277 # absorb anything we're updating or removing, if absorb flag set
279 if [ -n "$to_install" ]; then
280 for pkgid in $to_install; do
281 current=$(current_version $pkgid)
282 maybe_run pre-install $pkgid $runscripts $current || die
286 if [ -n "$to_remove" ]; then
287 for pkgid in $to_remove; do
288 maybe_run pre-remove $pkgid $runscripts || die
292 if [ -n "$to_install" ]; then
293 for pkgid in $to_install; do
294 zpm pkg $pkgid status=installing
296 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
299 if [ -n "$to_remove" ]; then
300 for pkgid in $to_remove; do
301 zpm pkg $pkgid status=removing
305 if [ -n "$rootdir" ]; then
306 ZPM_ROOT_DIR=$rootdir
308 : rootdir=${rootdir%%/}
311 if [ $dryrun -gt 0 ]; then
312 runscripts=0 # we don't want to run post scripts on a dry-run
313 syncopts="$syncopts -n"
316 if [ $verbose -gt 0 ]; then
317 syncopts="${syncopts} -v"
319 # force -v during development
320 syncopts="${syncopts} -v"
323 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
325 #zpm absorb -s updating
326 #zpm absorb -s removing
329 zpm syncfs $syncopts || die 'zpm-syncfs failed';
331 if [ -n "$to_remove" ]; then
332 for pkgid in $to_remove; do
333 maybe_run post-remove $pkgid $runscripts
337 changeall removing removed
338 changeall updating updated
340 echo running ldconfig
341 run_ldconfig $rootdir
343 if [ -n "$to_install" ]; then
344 for pkgid in $to_install; do
345 package=$(zpm parse -n $pkgid)
346 current=$(zpm list -s installed "$package")
348 maybe_run post-install $pkgid $runscripts $current
350 if [ -n "$current" ]; then
351 zpm pkg $pkgid status=installed :$current status=updated
353 zpm pkg $pkgid status=installed
356 maybe_run configure $pkgid $runconfigure
359 echo install complete