3 # what we need to install a package:
5 # recording repo: where we record what we've done
6 # source: where we get the package and files from
7 # install root: really just a prefix, but thought about differently,
8 # and we might need to do a chroot
10 # zpm install [options] <package ...>
12 pkgver=${ZPMPACKAGEVER:-1.0}
13 pkgrel=${ZPMPACKAGEREL:-1}
17 # allocate an install id, perhaps hash package and timestamp
18 # installid=$(echo $(date) $pkglist | zpm hash)
20 # extract pre-scripts and run them
21 # get list of paths to install
22 # for each path, if directory, create and set mode
23 # for each path, create leading directories
24 # extract to something like /var/tmp/.hash, with low perms
25 # only atomic if same filesystem, so use .installid.hash in the
29 # after all the files, extract post scripts and run them
31 # also need to mark package as installing so if it fails part way
32 # through, it can be finished later
33 # probably also want an option to "backup" any packages being upgraded
34 # so it's trivial to downgrade or to revert if the install fails
36 # option for "multipackage" just to let the system know that's what you meant
37 # option to take filenames from stdin
38 # parse package, version, release from file if not given
39 # TODO what's the difference between prefix and pkgroot
40 # need an option to not chown the files
41 # option to install but not merge/track
44 # -R install root, if installing as root, will chroot?
45 # -C no chroot, even if root
48 # -f source repository file
49 # -d local (recording) repository database
50 # -D don't locally record
51 # -t only files matching tags
52 # -T exclude files matching tags
56 for cf in /etc/zpmrc ~/.zpmrc ./.zpmrc; do
60 while getopts :R:CNXf:d:Dt:T:u:g: opt; do
62 R) pkgroot="$OPTARG" ;;
64 f) pkgfile="$OPTARG" ;;
73 : ${ZPMDB:=/var/lib/zpm/db.zpm}
78 printf 'zpm-install:' 1>&2
84 if [ -z "$pkgfile" ]; then
85 # actually, if no pkgfile, get pkgfile from repo
86 # but need to loop over finding package files then
87 # so this program probably needs to be "install from pkgfile"
88 # and a separate one that will loop over a package
89 # spec list and find from repos
90 die "must specify package file"
91 pkgfile="$package-$pkgver-$pkgrel.zpm"
100 pkglist=$(zpm findpkg $pkgfile)
104 zpm shell $pkgfile<<EOS
105 select path from packagefiles
106 where package||'-'||version||'-'||release = '$pkg'
111 # find a repo file for a given package
122 for pkg in $pkglist; do
123 # TODO find scripts marked as pre-install
124 # TODO if this is an upgrade, run pre-upgrade
126 # TODO get total size of install so we can do a progress bar
128 # add package info to local package db
129 # check for conflicts
130 # mark package in localdb as installing
131 # zpm setmark installing $pkg
132 # install all the files for a package
133 # TODO install directories first in order of path length
134 echo installing $pkglist
135 filecount=$(pathlist | wc -l)
136 echo $filecount files
138 pathlist | xargs zpm ipkgfile ${user+-u $user} ${group+-g $group} -R "$pkgroot" -f $pkgfile -- $pkg
140 # TODO find scripts marked as post-install
141 # TODO if this is an upgrade, run post-upgrade
143 # mark as ready for install
144 #zpm setmark ready $pkg
147 #zpm setmark installed $pkglist