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
38 zpm list -s installed $(zpm parse -n $1)
47 if [ $run -gt 0 ]; then
48 zpm script -p $phase $pkgid $current
50 if [ $rv -ne 0 ]; then
51 warn "$phase script for $pkgid failed"
55 if zpm script -Fql -p $phase $pkgid; then
56 zpm note -e -p $pkgid -m "$phase script not run"
63 # check if we're installing something already
64 var=$(zpm list -s installing | wc -l)
65 if [ $var -gt 0 ]; then
66 zpm list -v -f $localdb -s installing
67 warn "already ($localdb) installing $var package(s)"
70 var=$(zpm list -s removing | wc -l)
71 if [ $var -gt 0 ]; then
72 zpm list -v -f $localdb -s removing
73 warn "already ($localdb) removing $var package(s)"
76 var=$(zpm list -s updating | wc -l)
77 if [ $var -gt 0 ]; then
78 zpm list -v -f $localdb -s updating
79 warn "already ($localdb) updating $var package(s)"
82 if [ $rv -ne 0 ]; then
95 packagepath="/var/lib/zpm/packages"
105 # TODO option to attempt to resume an ongoing install
106 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
107 while getopts f:d:R:nSCvAObBL opt; do
109 f) pkgfile="$OPTARG" ;;
110 d) localdb="$OPTARG" ;;
111 P) packagepath="$OPTARG" ;;
112 D) packagepath="$OPTARG:$packagepath" ;;
113 R) rootdir="$OPTARG" ;;
116 A) absorb=1; syncopts="${syncopts} -A" ;;
117 O) overwrite=1; syncopts="${syncopts} -O" ;;
122 L) ignorelibdeps=1 ;;
124 *) die "usage ..." ;;
127 shift $(( OPTIND - 1))
129 ZPMDB=${localdb:-${ZPMDB:-/var/lib/zpm/local.db}}
131 # create the localdb if needed
134 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
140 -*) pkgid=$(zpm findpkg -I "${op#-}")
141 if [ -n "$pkgid" ]; then
142 to_remove="$to_remove $pkgid"
144 # else warn not installed
147 search="$search $pkg"
151 pkgid=$(zpm findpkg -f $file $pkg)
152 if [ -n $pkgid ]; then
153 merge="$merge $pkgid:$file"
155 die "can't find $pkg in $file"
158 *) search="$search $op"
163 search=$(echo $search)
167 if [ $ignorelibdeps -eq 1 ]; then
168 merge=$(zpm search -iIO $search)
170 merge=$(zpm search -iIO -l $search)
173 if [ $? -ne 0 ]; then
174 warn "unmet packages or dependencies, or errors"
179 for mergepkg in $merge; do
180 pkgid=${mergepkg%%:*}
181 installset="$installset $pkgid"
183 installset=$(printf "%s\n" $installset | sort -u)
185 # TODO check for downgrade
191 for mergepkg in $merge; do
193 repofile=${mergepkg#*:}
194 if [ ${repofile##*.} = 'repo' ]; then
195 status=$(zpm pkg -f $repofile $pkgid status)
196 reponame=$(basename $repofile .repo)
197 if [ "$status" != 'merged' ]; then
198 repodir=$(dirname $repofile)
199 zpmfile=$repodir/$reponame/$pkgid.zpm
200 if [ -f "$zpmfile" ]; then
201 nlist="$nlist $pkgid:$zpmfile"
204 echo downloading $zpmfile
205 zpm repo fetch $reponame $pkgid
206 if [ -f "$zpmfile" ]; then
207 nlist="$nlist $pkgid:$zpmfile"
209 baddl="$baddl $reponame:$pkgid"
214 nlist="$nlist $mergepkg"
220 if [ -n "$baddl" ]; then
221 printf 'unable to download: %s\n' $baddl
225 if [ $justlist -eq 1 ]; then
226 for package in $merge; do
228 printf 'install %s\n' $pkgid
230 for pkgid in $to_remove; do
231 printf 'remove %s\n' $pkgid
235 if [ -z "$merge" ] && [ -z "$to_remove" ]; then
242 # finally, merge everything
243 for mergepkg in $merge; do
245 pkgfile=${mergepkg#*:}
247 # we could have found the package already in the localdb
248 # in which case, we don't need to merge it
249 # TODO check for symlinks?
250 if [ $pkgfile != $ZPMDB ]; then
251 echo merging $pkgfile $pkgid
252 zpm merge -Fuv -f "$pkgfile" $pkgid
254 to_install="$to_install $pkgid"
257 to_install=${to_install#' '}
259 echo "installing: $to_install"
261 # absorb anything we're updating or removing, if absorb flag set
263 if [ -n "$to_install" ]; then
264 for pkgid in $to_install; do
265 current=$(current_version $pkgid)
266 maybe_run pre-install $pkgid $runscripts $current || die
270 if [ -n "$to_remove" ]; then
271 for pkgid in $to_remove; do
272 maybe_run pre-remove $pkgid $runscripts || die
276 if [ -n "$to_install" ]; then
277 for pkgid in $to_install; do
278 zpm pkg $pkgid status=installing
282 if [ -n "$to_remove" ]; then
283 for pkgid in $to_remove; do
284 zpm pkg $pkgid status=removing
288 if [ -n "$rootdir" ]; then
289 ZPM_ROOT_DIR=$rootdir
291 : rootdir=${rootdir%%/}
294 if [ $dryrun -gt 0 ]; then
295 runscripts=0 # we don't want to run post scripts on a dry-run
296 syncopts="$syncopts -n"
299 if [ $verbose -gt 0 ]; then
300 syncopts="${syncopts} -v"
302 # force -v during development
303 syncopts="${syncopts} -v"
306 if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then
308 #zpm absorb -s updating
309 #zpm absorb -s removing
312 zpm syncfs $syncopts || die 'zpm-syncfs failed';
314 if [ -n "$to_remove" ]; then
315 for pkgid in $to_remove; do
316 maybe_run post-remove $pkgid $runscripts
320 changeall removing removed
322 echo running ldconfig
323 run_ldconfig $rootdir
325 if [ -n "$to_install" ]; then
326 for pkgid in $to_install; do
327 package=$(zpm parse -n $pkgid)
328 current=$(zpm list -s installed "$package")
330 maybe_run post-install $pkgid $runscripts $current
332 if [ -n "$current" ]; then
333 zpm pkg $pkgid status=installed :$current status=updated
335 zpm pkg $pkgid status=installed
338 maybe_run configure $pkgid $runconfigure
341 echo install complete