postgresql-96: update to 9.6.2
[unleashed-userland.git] / tools / ips2tgz
blob0301e1f3016837fc2d1f9f14b712de5a4e174c5f
1 #!/bin/sh
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL)". You may
5 # only use this file in accordance with the terms of the CDDL.
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright 2012, Andrzej Szeszo
16 #PREFIX=cde-runtime
17 #SRCREPO=http://pkg.openindiana.org/legacy
18 #PKGLIST=pkg:/cde/$PREFIX@0.5.11,5.11-0.134:20100302T005909Z
20 set -e
22 PREFIX=$1; shift
23 ARCHIVE=$1; shift
24 SRCREPO=$1; shift
25 PKGLIST="$@"
27 [ -f $ARCHIVE ] && exit 0
29 if [ ! -d $PREFIX.pkgrecv ]; then
30 mkdir $PREFIX.pkgrecv
31 pkgrecv -s $SRCREPO -d $PREFIX.pkgrecv --raw $PKGLIST
34 dir() {
35 parm=$1
36 while [ ! x$1 = x ]; do
37 variant=
38 case $parm in
39 path=*)
40 path=`echo $parm|sed s/^path=//`
42 variant.arch=*)
43 variant=`echo $parm|sed s/^variant.arch=//`
45 esac
46 shift
47 parm=$1
48 done
50 if [ -z $variant ]; then
51 mkdir -p $PREFIX/i386/$path
52 mkdir -p $PREFIX/sparc/$path
53 elif [ $variant = i386 ]; then
54 mkdir -p $PREFIX/i386/$path
55 elif [ $variant = sparc ]; then
56 mkdir -p $PREFIX/sparc/$path
61 file() {
62 hash=$1
63 parm=$1
64 while [ ! x$1 = x ]; do
65 variant=
66 case $parm in
67 path=*)
68 path=`echo $parm|sed s/^path=//`
70 mode=*)
71 mode=`echo $parm|sed s/^mode=//`
73 variant.arch=*)
74 variant=`echo $parm|sed s/^variant.arch=//`
76 esac
77 shift
78 parm=$1
79 done
81 if [ -z $variant ]; then
82 [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
83 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
84 cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/i386/$path
85 chmod $mode $PREFIX/i386/$path
86 [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
87 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
88 cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/sparc/$path
89 chmod $mode $PREFIX/sparc/$path
90 elif [ $variant = i386 ]; then
91 [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
92 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
93 cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/i386/$path
94 chmod $mode $PREFIX/i386/$path
95 elif [ $variant = sparc ]; then
96 [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
97 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
98 cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/sparc/$path
99 chmod $mode $PREFIX/sparc/$path
104 hardlink() {
105 parm=$1
106 while [ ! x$1 = x ]; do
107 variant=
108 case $parm in
109 path=*)
110 path=`echo $parm|sed s/^path=//`
112 target=*)
113 target=`echo $parm|sed s/^target=//`
115 variant.arch=*)
116 variant=`echo $parm|sed s/^variant.arch=//`
118 esac
119 shift
120 parm=$1
121 done
123 if [ -z $variant ]; then
124 [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
125 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
126 ln `dirname $PREFIX/i386/$path`/$target $PREFIX/i386/$path
127 [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
128 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
129 ln `dirname $PREFIX/sparc/$path`/$target $PREFIX/sparc/$path
130 elif [ $variant = i386 ]; then
131 [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
132 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
133 ln `dirname $PREFIX/i386/$path`/$target $PREFIX/i386/$path
134 elif [ $variant = sparc ]; then
135 [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
136 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
137 ln `dirname $PREFIX/sparc/$path`/$target $PREFIX/sparc/$path
142 link() {
143 parm=$1
144 while [ ! x$1 = x ]; do
145 variant=
146 case $parm in
147 path=*)
148 path=`echo $parm|sed s/^path=//`
150 target=*)
151 target=`echo $parm|sed s/^target=//`
153 variant.arch=*)
154 variant=`echo $parm|sed s/^variant.arch=//`
156 esac
157 shift
158 parm=$1
159 done
161 if [ -z $variant ]; then
162 [ -h $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
163 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
164 ln -s $target $PREFIX/i386/$path
165 [ -h $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
166 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
167 ln -s $target $PREFIX/sparc/$path
168 elif [ $variant = i386 ]; then
169 [ -h $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
170 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
171 ln -s $target $PREFIX/i386/$path
172 elif [ $variant = sparc ]; then
173 [ -h $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
174 [ ! -d `dirname $PREFIX/i386/$path` ] || mkdir -p `dirname $PREFIX/i386/$path`
175 ln -s $target $PREFIX/sparc/$path
180 license() {
181 hash=$1
182 parm=$1
183 while [ ! x"$1" = x ]; do
184 case $parm in
185 license=*)
186 license=`echo $parm|sed s/^license=//`
188 esac
189 shift
190 parm=$1
191 done
192 cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/i386/"$license"
193 cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/sparc/"$license"
198 for i in $PREFIX.pkgrecv/*/*/manifest.dir; do
199 [ -f $i ] && . $i
200 done
202 for i in $PREFIX.pkgrecv/*/*/manifest.file; do
203 [ -f $i ] && . $i
204 done
206 for i in $PREFIX.pkgrecv/*/*/manifest.hardlink; do
207 [ -f $i ] && . $i
208 done
210 for i in $PREFIX.pkgrecv/*/*/manifest.link; do
211 [ -f $i ] && . $i
212 done
214 for i in $PREFIX.pkgrecv/*/*/manifest.license; do
215 [ -f $i ] && . $i
216 done
218 tar cf - $PREFIX | gzip -9 >$ARCHIVE
220 rm -rf $PREFIX.pkgrecv $PREFIX