]> pd.if.org Git - zpackage/blob - zpm-install
general zpm-install work
[zpackage] / zpm-install
1 #!/bin/sh
2
3 #package=${1:-$ZPMPACKAGE}
4 pkgver=${ZPMPACKAGEVER:-1.0}
5 pkgrel=${ZPMPACKAGEREL:-1}
6
7 pkgroot=/
8
9 # allocate an install id, perhaps hash package and timestamp
10 # extract pre-scripts and run them
11 # get list of paths to install
12 # for each path, if directory, create and set mode
13 # for each path, create leading directories
14 # extract to something like /var/tmp/.hash, with low perms
15 # only atomic if same filesystem, so use .installid.hash in the
16 # install directory
17 # set perms and such
18 # move into place
19 # after all the files, extract post scripts and run them
20
21 # option for "multipackage" just to let the system know that's what you meant
22 # option to take filenames from stdin
23 # parse package, version, release from file if not given
24 while getopts :f:v:r:d:a:u:l:p:b:P:R: opt; do
25         case $opt in
26                 R) pkgroot="$OPTARG" ;;
27                 f) pkgfile="$OPTARG" ;;
28                 v) pkgver="$OPTARG" ;;
29                 r) pkgrel="$OPTARG" ;;
30                 d) description="$OPTARG" ;;
31                 a) arch="$OPTARG" ;;
32                 u) url="$OPTARG" ;;
33                 l) licenses="$OPTARG" ;;
34                 p) packager="$OPTARG" ;;
35                 b) builddate="$OPTARG" ;;
36                 P) prefix="$OPTARG" ;;
37         esac
38 done
39 shift $((OPTIND - 1))
40
41 set -e
42 if [ -z "$pkgfile" ]; then
43         # actually, if no pkgfile, get pkgfile from repo
44         pkgfile="$package-$pkgver-$pkgrel.zpm"
45 fi
46
47 die() {
48         echo $* 1&>2
49         exit 1
50 }
51
52 set -e
53 zpm test -v $pkgfile
54 set +e
55
56 if [ $# -gt 0 ]; then
57         pkglist="$@"
58 else
59         pkglist=$(zpm findpkg $pkgfile)
60 fi
61
62 pathlist() {
63         sqlite3 $pkgfile<<EOS
64 select path from packagefiles
65         where package||'-'||version||'-'||release = '$pkg'
66         ;
67 EOS
68 }
69
70 for pkg in $pkglist; do
71         # TODO find scripts marked as pre-install
72         # TODO if this is an upgrade, run pre-upgrade
73
74         # TODO get total size of install so we can do a progress bar
75
76         # add package info to local package db
77         # zpm merge -L -f $pkgfile $pkg
78         # mark package in localdb as installing
79         # zpm setmark installing $pkg
80         # install all the files for a package
81         # TODO install directories first in order of path length
82         pathlist | xargs zpm ipkgfile -R "$pkgroot" -f $pkgfile -- $pkg 
83
84         # TODO find scripts marked as post-install
85         # TODO if this is an upgrade, run post-upgrade
86
87         # mark as ready for install
88         #zpm setmark ready $pkg
89 done
90
91 #zpm setmark installed $pkglist