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 # TODO option to attempt to resume an ongoing install
107 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
108 while getopts f:d:R:nSCvAObBL opt; do
110 f) pkgfile="$OPTARG" ;;
111 d) localdb="$OPTARG" ;;
112 P) packagepath="$OPTARG" ;;
113 D) packagepath="$OPTARG:$packagepath" ;;
114 R) rootdir="$OPTARG" ;;
117 A) absorb=1; syncopts="${syncopts} -A" ;;
118 O) overwrite=1; syncopts="${syncopts} -O" ;;
123 L) ignorelibdeps=1 ;;
125 *) die "usage ..." ;;
128 shift $(( OPTIND - 1))
130 ZPMDB=${localdb:-${ZPMDB:-/var/lib/zpm/local.db}}
132 # create the localdb if needed
135 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
141 -*) pkgid=$(zpm findpkg -I "${op#-}")
142 if [ -n "$pkgid" ]; then
143 to_remove="$to_remove $pkgid"
145 # else warn not installed
148 search="$search $pkg"
152 pkgid=$(zpm findpkg -f $file $pkg)
153 if [ -n $pkgid ]; then
154 merge="$merge $pkgid:$file"
156 die "can't find $pkg in $file"
159 *) search="$search $op"
164 search=$(echo $search)
168 if [ $ignorelibdeps -eq 1 ]; then
169 merge=$(zpm search -iIO $search)
171 merge=$(zpm search -iIO -l $search)
174 if [ $? -ne 0 ]; then
175 warn "unmet packages or dependencies, or errors"
180 for mergepkg in $merge; do
181 pkgid=${mergepkg%%:*}
182 installset="$installset $pkgid"
184 installset=$(printf "%s\n" $installset | sort -u)
186 # TODO check for downgrade
192 for mergepkg in $merge; do
194 repofile=${mergepkg#*:}
195 if [ ${repofile##*.} = 'repo' ]; then
196 status=$(zpm pkg -f $repofile $pkgid status)
197 reponame=$(basename $repofile .repo)
198 if [ "$status" != 'merged' ]; then
199 repodir=$(dirname $repofile)
200 zpmfile=$repodir/$reponame/$pkgid.zpm
201 if [ -f "$zpmfile" ]; then
202 nlist="$nlist $pkgid:$zpmfile"
205 echo downloading $zpmfile
206 zpm repo fetch $reponame $pkgid
207 if [ -f "$zpmfile" ]; then
208 nlist="$nlist $pkgid:$zpmfile"
210 baddl="$baddl $reponame:$pkgid"
215 nlist="$nlist $mergepkg"
221 if [ -n "$baddl" ]; then
222 printf 'unable to download: %s\n' $baddl
226 if [ $justlist -eq 1 ]; then
227 for package in $merge; do
229 printf 'install %s\n' $pkgid
231 for pkgid in $to_remove; do
232 printf 'remove %s\n' $pkgid
236 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
243 # finally, merge everything
244 for mergepkg in $merge; do
246 pkgfile=${mergepkg#*:}
248 # we could have found the package already in the localdb
249 # in which case, we don't need to merge it
250 # TODO check for symlinks?
251 if [ $pkgfile != $ZPMDB ]; then
252 echo merging $pkgfile $pkgid
253 zpm merge -Fuv -f "$pkgfile" $pkgid
255 to_install="$to_install $pkgid"
258 to_install=${to_install#' '}
260 echo "installing: $to_install"
262 # absorb anything we're updating or removing, if absorb flag set
264 if [ -n "$to_install" ]; then
265 for pkgid in $to_install; do
266 current=$(current_version $pkgid)
267 maybe_run pre-install $pkgid $runscripts $current || die
271 if [ -n "$to_remove" ]; then
272 for pkgid in $to_remove; do
273 maybe_run pre-remove $pkgid $runscripts || die
277 if [ -n "$to_install" ]; then
278 for pkgid in $to_install; do
279 zpm pkg $pkgid status=installing
281 zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
284 if [ -n "$to_remove" ]; then
285 for pkgid in $to_remove; do
286 zpm pkg $pkgid status=removing
290 if [ -n "$rootdir" ]; then
291 ZPM_ROOT_DIR=$rootdir
293 : rootdir=${rootdir%%/}
296 if [ $dryrun -gt 0 ]; then
297 runscripts=0 # we don't want to run post scripts on a dry-run
298 syncopts="$syncopts -n"
301 if [ $verbose -gt 0 ]; then
302 syncopts="${syncopts} -v"
304 # force -v during development
305 syncopts="${syncopts} -v"
308 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
310 #zpm absorb -s updating
311 #zpm absorb -s removing
314 zpm syncfs $syncopts || die 'zpm-syncfs failed';
316 if [ -n "$to_remove" ]; then
317 for pkgid in $to_remove; do
318 maybe_run post-remove $pkgid $runscripts
322 changeall removing removed
323 changeall updating updated
325 echo running ldconfig
326 run_ldconfig $rootdir
328 if [ -n "$to_install" ]; then
329 for pkgid in $to_install; do
330 package=$(zpm parse -n $pkgid)
331 current=$(zpm list -s installed "$package")
333 maybe_run post-install $pkgid $runscripts $current
335 if [ -n "$current" ]; then
336 zpm pkg $pkgid status=installed :$current status=updated
338 zpm pkg $pkgid status=installed
341 maybe_run configure $pkgid $runconfigure
344 echo install complete