-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapkg
executable file
·329 lines (279 loc) · 8.07 KB
/
apkg
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#!/bin/sh
#############################################################################
# apkg - a front-end script to autopackage for AliEn
#############################################################################
#
#
# SYNOPSIS
#
# DESCRIPTION
#
# AUTHOR:
# Predrag Buncic, e-mail: Predrag.Buncic@cern.ch
#
# CREATION DATE:
#C<
#############################################################################
VERSION=0.01
###########################################################################
[ -f $HOME/.alien/apkg.rc ] && . $HOME/.alien/apkg.rc
###########################################################################
URL=${APKG_URL:=http://alien.cern.ch/cache/dist/releases/HEAD}
AUTOURL=${APKG_AUTOURL:=http://alien.cern.ch/cache/packages}
CACHEURL=${APKG_CACHEURL:=http://alien.cern.ch/cache}
PREFIX=${APKG_PREFIX:=/opt/alien}
PLATFORM=${APKG_PLATFORM:=}
CONFIG_PLATFORM=${APKG_CONFIG_PLATFORM:=}
ALIEN_VERSION=1
AUTOPACKAGE_VERSION=1.05
# release_file=`mktemp /tmp/release.XXXXXX`
# cache_file=`mktemp /tmp/cache.XXXXXX`
# dialog_file=`mktemp /tmp/dialog.XXXXXX`
#wget -O $cache_file http://alien.cern.ch/BitServers > /dev/null 2>&1
#list=`grep -v -e HEAD -e "^#" $release_file | awk -F: '{if (i==1) {on="on"} else {on="0"}; printf("%s %s %s ",$3,$4,on); i++}'`
#caches=`grep -v -e "^#" $cache_file | grep $platform | awk -v platform=$APKG_PLATFORM -v release=$ALIEN_RELEASE -F'|' '{printf("%s/%s/%s/download/",$2,platform,release)}' | sed 's/ *//'`
###########################################################################
RcUpdate()
###########################################################################
{
mkdir -p $HOME/.alien
(
echo "APKG_URL=$URL"
echo "APKG_AUTOURL=$AUTOURL"
echo "APKG_CACHEURL=$CACHEURL"
echo "APKG_PREFIX=$PREFIX"
echo "APKG_PLATFORM=$PLATFORM"
echo "APKG_CONFIG_PLATFORM=$CONFIG_PLATFORM"
) > $HOME/.alien/apkg.rc
}
###########################################################################
Usage()
###########################################################################
{
cat<<EOF
apkg [--prefix <path>]
[--force]
[-qt|--qtfe][-g|--gtkfe][-t|--ttyfe]
[--platform <string>]
[--url <url>][--cacheurl <cache url>][--autourl <autopackage url>]
[-h|--help]"
manager
install <all|client|site|wn|core>
<autopackage action> <args>
EOF
[ -x $PREFIX/bin/package ] && $PREFIX/bin/package --help
exit 0
}
###########################################################################
Error()
###########################################################################
{
echo "Error:" $*
exit 1
}
###########################################################################
Configure()
###########################################################################
{
mkdir -p $PREFIX/bin || Error "Cannot create directory: $PREFIX"
[ ! -f $PREFIX/bin/apkg ] && cp $0 $PREFIX/bin
TOOLS="tar wget pkg-config"
for cmd in $TOOLS
do
which $cmd > /dev/null || Error "Cannot find $cmd command."
done
AUTOPACKAGES=""
[ ! -f $PREFIX/bin/package -o ! -z "$FORCE" ] && \
AUTOPACKAGES=$AUTOPACKAGES" autopackage"
[ ! -f $PREFIX/bin/apg++ -o ! -z "$FORCE" ] && \
AUTOPACKAGES=$AUTOPACKAGES" autopackage-apbuild"
LIBS="glib-2.0 gtk+"
ld_path=$LD_LIBRARY_PATH
for lib in $LIBS
do
libs=`pkg-config --libs-only-L $lib | sed -e 's/ \?\-L/:/g'` || Error "Cannot find $lib on your system."
ld_path=$ld_path$libs
[ "$MODE" = "" ] && MODE="gtkfe"
done
[ ! -f $PREFIX/bin/autopackage-frontend-gtk -o ! -z "$FORCE" ] && \
AUTOPACKAGES=$AUTOPACKAGES" autopackage-gtkfe"
[ ! -f $PREFIX/bin/autopackage-manager-gtk -o ! -z "$FORCE" ] && \
AUTOPACKAGES=$AUTOPACKAGES" autopackage-manager"
DIRS="/usr/lib/qt3/lib /usr/qt/3/lib /usr/lib/qt-3.*"
for dir in $DIRS
do
if [ -d $dir ]
then
ld_path=$ld_path:$dir
AUTOPACKAGES=$AUTOPACKAGES" autopackage-qtfe"
[ "$MODE" = "" ] && MODE="qtfe"
fi
done
ld_path=`echo $ld_path | sed -e 's/ *//g' -e 's/::/:/g' -e 's/^://'`
EXTRAPACKAGES=""
[ ! -f $PREFIX/lib/libuau.a -o ! -z "$FORCE" ] && \
EXTRAPACKAGES=$EXTRAPACKAGES" luau-0.1.9"
[ ! -f $PREFIX/bin/curl -o ! -z "$FORCE" ] && \
EXTRAPACKAGES=$EXTRAPACKAGES" curl-7.13.2"
[ ! -f $PREFIX/lib/libhistory.a -o ! -z "$FORCE" ] && \
EXTRAPACKAGES=$EXTRAPACKAGES" readline-5.0"
for name in $EXTRAPACKAGES
do
(cd $PREFIX; wget -q -O - ${URL}/${name}_${CONFIG_PLATFORM}.tar.bz2 | tar jxf -)
done
for name in $AUTOPACKAGES
do
(cd $PREFIX; wget -q -O - ${URL}/${name}-${AUTOPACKAGE_VERSION}_${CONFIG_PLATFORM}.tar.bz2 | tar jxf -)
done
RcUpdate
}
###########################################################################
Install()
###########################################################################
{
Configure
export LD_LIBRARY_PATH=$PREFIX/lib:$ld_path:$LD_LIBRARY_PATH
export PATH=$PREFIX/bin:$PATH
tmpdir=`mktemp -d /tmp/dialog.XXXXXX`
mkdir -p $tmpdir || Error "Cannot create directory: $tmpdir"
if [ "$MODE" = "qtfe" ]
then
arg=""
else
arg="--$MODE"
fi
for pkg in $*
do
(cd $tmpdir && wget -q ${AUTOURL}/alien-meta-$pkg-${ALIEN_VERSION}.${PLATFORM}.package && sh alien-meta-$pkg-${ALIEN_VERSION}.${PLATFORM}.package $arg) || Error "Could not install $pkg"
done
rm -rf $tmpdir
}
###########################################################################
Manage()
###########################################################################
{
Configure
export LD_LIBRARY_PATH=$PREFIX/lib:$ld_path:$LD_LIBRARY_PATH
export PATH=$PREFIX/bin:$PATH
case $MODE in
qtfe)
[ -x $PREFIX/bin/autopackage-manager-qt ] && \
$PREFIX/bin/autopackage-manager-qt
;;
gtkfe)
[ -x $PREFIX/bin/autopackage-manager-gtk ] && \
$PREFIX/bin/autopackage-manager-gtk
;;
*)
break
esac
exit
}
###########################################################################
###########################################################################
if [ "$PLATFORM" = "" -o "$CONFIG_PLATFORM" = "" ]
then
for dir in /usr/share/libtool /usr/lib/rpm
do
if [ -f $dir/config.guess ]
then
p=`$dir/config.guess`
break
fi
done
case $p in
i*86-pc-linux-gnu)
platform=i686-pc-linux-gnu
autoplatform=x86
;;
ia64-*-linux-gnu)
platform=ia64-unknown-linux-gnu
autoplatform=x86_64
;;
powerpc-apple-darwin8.*.*)
platform=powerpc-apple-darwin8.1.0
autoplatform=ppc
;;
x86_64-*-linux-gnu)
platform=x86_64-unknown-linux-gnu
autoplatform=ia64
;;
esac
PLATFORM=$autoplatform
CONFIG_PLATFORM=$platform
fi
FORCE=""
args=$*
while [ $# -gt 0 ]
do
case $1 in
--platform)
shift 1
PLATFORM=$1
shift 1
;;
--prefix)
shift 1
PREFIX=$1
shift 1
;;
--url)
shift 1
URL=$1
shift 1
;;
--autourl)
shift 1
AUTOURL=$1
shift 1
;;
--cacheurl)
shift 1
CACHEURL=$1
shift 1
;;
--trace)
shift 1
set -vx
;;
--force)
shift 1
FORCE=true
;;
-qt|--qtfe)
shift 1
MODE=qtfe
;;
-g|--gtkfe)
shift 1
MODE=gtkfe
;;
-t|--ttyfe)
shift 1
MODE=ttyfe
;;
-h|--help)
shift 1
Usage
;;
manager)
shift 1
Manage
exit
;;
install)
shift 1
Install $*
exit
;;
*)
if [ -x $PREFIX/bin/package ]
then
$PREFIX/bin/package $*
exit
else
Error "Unknown command: $*"
fi
;;
esac
done