-
Notifications
You must be signed in to change notification settings - Fork 0
/
repackage.sh
102 lines (89 loc) · 1.92 KB
/
repackage.sh
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
#!/bin/bash
#(C) 2011 SIANA GEARZ
usage() {
echo "Usage: repackage PLATTFORM FILEIN.tar.bz2 [FILEOUT.tar.bz2]
Repackage an archive from llautobuild format into legacy format
PLATTFORM can be one of windows, linux, mac.
"
exit 0
}
TMP="/tmp/pak$$"
LIBPATH=""
INCPATH=""
PWD=`pwd`
shopt -s nocasematch
case "$1" in
--windows|-w|windows|win)
MODE=win
LIBPATH="libraries/i686-win32/lib/release"
LIBDPATH="libraries/i686-win32/lib/debug"
INCPATH="libraries/i686-win32/include"
;;
--mac|--osx|--darwin|-x|mac|osx|darwin)
MODE=osx
LIBPATH="libraries/universal-darwin/lib_release"
LIBDPATH="libraries/universal-darwin/lib_release"
INCPATH="libraries/universal-darwin/include"
;;
--lin|--linux|-l|linux)
MODE=linux
LIBPATH="libraries/i686-linux/lib_release_client"
INCPATH="libraries/i686-linux/include"
;;
--linux64|-6|linux64)
MODE=linux64
LIBPATH="libraries/x86_64-linux/lib_release_client"
INCPATH="libraries/x86_64-linux/include"
;;
*)
usage
;;
esac
case "$2" in
--commoninclude|--common-include|--common)
INCPATH="libraries/include"
shift
;;
esac
test -n "$2" && FILEIN=`readlink -e $2`
test -n "$3" && FILEOUT=`readlink -f $3`
if [ -z $FILEIN ]; then
usage
fi
if [ -z $FILEOUT ]; then
FILEOUT=`readlink -m package.tar.bz2`
fi
mkdir "$TMP"
cd "$TMP"
case "$FILEIN" in
http\:\/\/|https\:\/\/)
echo " Downloading..."
wget "$FILEIN" -O package.tar.bz2
echo " Unpacking..."
tar -xjvf package.tar.bz2
rm package.tar.bz2
;;
*)
echo " Unpacking..."
tar -xjvf "$FILEIN"
;;
esac
if [ -n "$LIBDPATH" -a -d lib/debug ]; then
mkdir -p $LIBDPATH
mv -f lib/debug/* $LIBDPATH
fi
if [ -d lib/release ]; then
mkdir -p $LIBPATH
mv -f lib/release/* $LIBPATH
fi
if [ -d include ]; then
mkdir -p $INCPATH
mv -f include/* $LIBPATH
fi
echo " Packing..."
tar -cjvf "$FILEOUT" libraries LICENSES
echo " Checksum:"
cd `dirname "$FILEOUT"`
md5sum -b `basename "$FILEOUT"`
cd "$PWD"
rm -rf "$TMP"