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 while getopts :R:CNXf:d:Dt:T: opt; do
58 R) pkgroot="$OPTARG" ;;
60 f) pkgfile="$OPTARG" ;;
71 if [ -z "$pkgfile" ]; then
72 # actually, if no pkgfile, get pkgfile from repo
73 # but need to loop over finding package files then
74 # so this program probably needs to be "install from pkgfile"
75 # and a separate one that will loop over a package
76 # spec list and find from repos
77 die "must specify package file"
78 pkgfile="$package-$pkgver-$pkgrel.zpm"
87 pkglist=$(zpm findpkg $pkgfile)
91 zpm shell $pkgfile<<EOS
92 select path from packagefiles
93 where package||'-'||version||'-'||release = '$pkg'
98 # find a repo file for a given package
107 for pkg in $pkglist; do
108 # TODO find scripts marked as pre-install
109 # TODO if this is an upgrade, run pre-upgrade
111 # TODO get total size of install so we can do a progress bar
113 # add package info to local package db
114 # zpm merge -L -f $pkgfile $pkg
115 # check for conflicts
116 # mark package in localdb as installing
117 # zpm setmark installing $pkg
118 # install all the files for a package
119 # TODO install directories first in order of path length
120 echo installing $pkglist
121 filecount=$(pathlist | wc -l)
122 echo $filecount files
124 pathlist | xargs zpm ipkgfile -R "$pkgroot" -f $pkgfile -- $pkg
126 # TODO find scripts marked as post-install
127 # TODO if this is an upgrade, run post-upgrade
129 # mark as ready for install
130 #zpm setmark ready $pkg
133 #zpm setmark installed $pkglist