Marcel Telka
2024-04-05 e5e9b978d16f3a418fcae51695fb9398f0a160ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/sh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL)". You may
# only use this file in accordance with the terms of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
 
#
# Copyright 2012, Andrzej Szeszo
#
 
#PREFIX=cde-runtime
#SRCREPO=http://pkg.openindiana.org/legacy
#PKGLIST=pkg:/cde/$PREFIX@0.5.11,5.11-0.134:20100302T005909Z
 
set -e
 
PREFIX=$1; shift
ARCHIVE=$1; shift
SRCREPO=$1; shift
PKGLIST="$@"
 
[ -f $ARCHIVE ] && exit 0
 
if [ ! -d $PREFIX.pkgrecv ]; then
    mkdir $PREFIX.pkgrecv
    pkgrecv -s $SRCREPO -d $PREFIX.pkgrecv --raw $PKGLIST
fi
 
dir() {
    parm=$1
    while [ ! x$1 = x ]; do
        variant=
        case $parm in
            path=*)
                path=`echo $parm|sed s/^path=//`
                ;;
            variant.arch=*)
                variant=`echo $parm|sed s/^variant.arch=//`
                ;;
        esac
        shift
        parm=$1
    done
 
    if [ -z $variant ]; then
        mkdir -p $PREFIX/i386/$path
        mkdir -p $PREFIX/sparc/$path
    elif [ $variant = i386 ]; then
        mkdir -p $PREFIX/i386/$path
    elif [ $variant = sparc ]; then
        mkdir -p $PREFIX/sparc/$path
    fi
 
}
 
file() {
    hash=$1
    parm=$1
    while [ ! x$1 = x ]; do
        variant=
        case $parm in
            path=*)
                path=`echo $parm|sed s/^path=//`
                ;;
            mode=*)
                mode=`echo $parm|sed s/^mode=//`
                ;;
            variant.arch=*)
                variant=`echo $parm|sed s/^variant.arch=//`
                ;;
        esac
        shift
        parm=$1
    done
 
    if [ -z $variant ]; then
        [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
        mkdir -p `dirname $PREFIX/i386/$path`
        cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/i386/$path
        chmod $mode $PREFIX/i386/$path
        [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
        mkdir -p `dirname $PREFIX/sparc/$path`
        cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/sparc/$path
        chmod $mode $PREFIX/sparc/$path
    elif [ $variant = i386 ]; then
        [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
        mkdir -p `dirname $PREFIX/i386/$path`
        cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/i386/$path
        chmod $mode $PREFIX/i386/$path
    elif [ $variant = sparc ]; then
        [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
        mkdir -p `dirname $PREFIX/sparc/$path`
        cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/sparc/$path
        chmod $mode $PREFIX/sparc/$path
    fi
 
}
 
hardlink() {
    parm=$1
    while [ ! x$1 = x ]; do
        variant=
        case $parm in
            path=*)
                path=`echo $parm|sed s/^path=//`
                ;;
            target=*)
                target=`echo $parm|sed s/^target=//`
                ;;
            variant.arch=*)
                variant=`echo $parm|sed s/^variant.arch=//`
                ;;
        esac
        shift
        parm=$1
    done
 
    if [ -z $variant ]; then
        [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
        mkdir -p `dirname $PREFIX/i386/$path`
        ln `dirname $PREFIX/i386/$path`/$target $PREFIX/i386/$path
        [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
        mkdir -p `dirname $PREFIX/sparc/$path`
        ln `dirname $PREFIX/sparc/$path`/$target $PREFIX/sparc/$path
    elif [ $variant = i386 ]; then
        [ -f $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
        mkdir -p `dirname $PREFIX/i386/$path`
        ln `dirname $PREFIX/i386/$path`/$target $PREFIX/i386/$path
    elif [ $variant = sparc ]; then
        [ -f $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
        mkdir -p `dirname $PREFIX/sparc/$path`
        ln `dirname $PREFIX/sparc/$path`/$target $PREFIX/sparc/$path
    fi
 
}
 
link() {
    parm=$1
    while [ ! x$1 = x ]; do
        variant=
        case $parm in
            path=*)
                path=`echo $parm|sed s/^path=//`
                ;;
            target=*)
                target=`echo $parm|sed s/^target=//`
                ;;
            variant.arch=*)
                variant=`echo $parm|sed s/^variant.arch=//`
                ;;
        esac
        shift
        parm=$1
    done
 
    if [ -z $variant ]; then
        [ -h $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
        mkdir -p `dirname $PREFIX/i386/$path`
        ln -s $target $PREFIX/i386/$path
        [ -h $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
        mkdir -p `dirname $PREFIX/sparc/$path`
        ln -s $target $PREFIX/sparc/$path
    elif [ $variant = i386 ]; then
        [ -h $PREFIX/i386/$path ] && rm -f $PREFIX/i386/$path
        mkdir -p `dirname $PREFIX/i386/$path`
        ln -s $target $PREFIX/i386/$path
    elif [ $variant = sparc ]; then
        [ -h $PREFIX/sparc/$path ] && rm -f $PREFIX/sparc/$path
        mkdir -p `dirname $PREFIX/sparc/$path`
        ln -s $target $PREFIX/sparc/$path
    fi
 
}
 
license() {
    hash=$1
    parm=$1
    while [ ! x"$1" = x ]; do
        case $parm in
            license=*)
                license=`echo $parm|sed s/^license=//`
                ;;
        esac
        shift
        parm=$1
    done
    cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/i386/"$license"
    cp `ls $PREFIX.pkgrecv/*/*/$hash|head -1` $PREFIX/sparc/"$license"
 
}
 
 
for i in $PREFIX.pkgrecv/*/*/manifest.dir; do
    [ -f $i ] && sed -e 's/\([^ ]*\)/"\1"/g' < $i > $i-edited && . $i-edited
done
 
for i in $PREFIX.pkgrecv/*/*/manifest.file; do
    [ -f $i ] && sed -e 's/\([^ ]*\)/"\1"/g' < $i > $i-edited && . $i-edited
done
 
for i in $PREFIX.pkgrecv/*/*/manifest.hardlink; do
    [ -f $i ] && sed -e 's/\([^ ]*\)/"\1"/g' < $i > $i-edited && . $i-edited
done
 
for i in $PREFIX.pkgrecv/*/*/manifest.link; do
    [ -f $i ] && sed -e 's/\([^ ]*\)/"\1"/g' < $i > $i-edited && . $i-edited
done
 
for i in $PREFIX.pkgrecv/*/*/manifest.license; do
    [ -f $i ] && sed -e 's/\([^ ]*\)/"\1"/g' < $i > $i-edited && . $i-edited
done
 
tar cf - $PREFIX | gzip -9 >$ARCHIVE
 
rm -rf $PREFIX.pkgrecv $PREFIX