-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·172 lines (152 loc) · 5.51 KB
/
install.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
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
#! /bin/sh
# global install
DEST_HOME=/usr/local
# for testing
# DEST_HOME=${HOME}/INSTALL/usr/local
DEST_BIN=${DEST_HOME}/bin
DEST_SHARE=${DEST_HOME}/lib/p7zip
DEST_MAN=${DEST_HOME}/man
DEST_SHARE_DOC=${DEST_HOME}/share/doc/p7zip
DEST_DIR=
[ "$1" ] && DEST_BIN="$1"
[ "$2" ] && DEST_SHARE="$2"
[ "$3" ] && DEST_MAN="$3"
[ "$4" ] && DEST_SHARE_DOC="$4"
[ "$5" ] && DEST_DIR="$5"
use_share="n"
if [ -x bin/7zCon.sfx ]
then
use_share="o"
fi
if [ -x bin/7z ]
then
use_share="o"
fi
# cleaning previous install
rm -f "${DEST_DIR}${DEST_BIN}/7z"
rm -f "${DEST_DIR}${DEST_BIN}/7za"
rm -f "${DEST_DIR}${DEST_BIN}/7zr"
rm -f "${DEST_DIR}${DEST_SHARE}/7z"
rm -f "${DEST_DIR}${DEST_SHARE}/7za"
rm -f "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
rm -f "${DEST_DIR}${DEST_SHARE}/7zr"
rm -f "${DEST_DIR}${DEST_SHARE}/7z.so"
chmod -R 777 "${DEST_DIR}${DEST_SHARE}/Codecs" 2> /dev/null
chmod -R 777 "${DEST_DIR}${DEST_SHARE}/Formats" 2> /dev/null
rm -fr "${DEST_DIR}${DEST_SHARE}/Codecs"
rm -fr "${DEST_DIR}${DEST_SHARE}/Formats"
rm -f "${DEST_DIR}${DEST_MAN}/man1/7z.1"
rm -f "${DEST_DIR}${DEST_MAN}/man1/7za.1"
rm -f "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
chmod -R 777 "${DEST_DIR}${DEST_SHARE_DOC}" 2> /dev/null
rm -fr "${DEST_DIR}${DEST_SHARE_DOC}"
if [ "${use_share}" = "o" ]
then
mkdir -p "${DEST_DIR}${DEST_BIN}"
mkdir -p "${DEST_DIR}${DEST_SHARE}"
if [ -x bin/7za ]
then
echo "- installing ${DEST_DIR}${DEST_BIN}/7za"
cp bin/7za "${DEST_DIR}${DEST_SHARE}/7za"
chmod 777 "${DEST_DIR}${DEST_SHARE}/7za"
strip "${DEST_DIR}${DEST_SHARE}/7za"
chmod 555 "${DEST_DIR}${DEST_SHARE}/7za"
echo "#! /bin/sh" > "${DEST_DIR}${DEST_BIN}/7za"
echo "\"${DEST_SHARE}/7za\" \"\$@\"" >> "${DEST_DIR}${DEST_BIN}/7za"
chmod 555 "${DEST_DIR}${DEST_BIN}/7za"
fi
if [ -x bin/7zr ]
then
echo "- installing ${DEST_DIR}${DEST_BIN}/7zr"
cp bin/7zr "${DEST_DIR}${DEST_SHARE}/7zr"
chmod 777 "${DEST_DIR}${DEST_SHARE}/7zr"
strip "${DEST_DIR}${DEST_SHARE}/7zr"
chmod 555 "${DEST_DIR}${DEST_SHARE}/7zr"
echo "#! /bin/sh" > "${DEST_DIR}${DEST_BIN}/7zr"
echo "\"${DEST_SHARE}/7zr\" \"\$@\"" >> "${DEST_DIR}${DEST_BIN}/7zr"
chmod 555 "${DEST_DIR}${DEST_BIN}/7zr"
fi
if [ -x bin/7zCon.sfx ]
then
echo "- installing ${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
cp bin/7zCon.sfx "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
chmod 777 "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
strip "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
chmod 555 "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
fi
if [ -x bin/7z ]
then
echo "- installing ${DEST_DIR}${DEST_BIN}/7z"
cp bin/7z "${DEST_DIR}${DEST_SHARE}/7z"
chmod 777 "${DEST_DIR}${DEST_SHARE}/7z"
strip "${DEST_DIR}${DEST_SHARE}/7z"
chmod 555 "${DEST_DIR}${DEST_SHARE}/7z"
cp -r bin/Codecs "${DEST_DIR}${DEST_SHARE}/"
chmod 555 "${DEST_DIR}${DEST_SHARE}"/*/*
cp bin/7z.so "${DEST_DIR}${DEST_SHARE}/7z.so"
chmod 555 "${DEST_DIR}${DEST_SHARE}/7z.so"
echo "#! /bin/sh" > "${DEST_DIR}${DEST_BIN}/7z"
echo "\"${DEST_SHARE}/7z\" \"\$@\"" >> "${DEST_DIR}${DEST_BIN}/7z"
chmod 555 "${DEST_DIR}${DEST_BIN}/7z"
fi
else
if [ -x bin/7za ]
then
echo "- installing ${DEST_DIR}${DEST_BIN}/7za"
mkdir -p "${DEST_DIR}${DEST_BIN}"
cp bin/7za "${DEST_DIR}${DEST_BIN}/7za"
chmod 555 "${DEST_DIR}${DEST_BIN}/7za"
fi
if [ -x bin/7zr ]
then
echo "- installing ${DEST_DIR}${DEST_BIN}/7zr"
mkdir -p "${DEST_DIR}${DEST_BIN}"
cp bin/7zr "${DEST_DIR}${DEST_BIN}/7zr"
chmod 555 "${DEST_DIR}${DEST_BIN}/7zr"
fi
fi
mkdir -p "${DEST_DIR}${DEST_MAN}/man1"
if [ -d DOCS ]
then
echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7z.1"
sed -e s?"{DEST_SHARE_DOC}"?"${DEST_SHARE_DOC}/DOCS"?g man1/7z.1 > "${DEST_DIR}${DEST_MAN}/man1/7z.1"
chmod 444 "${DEST_DIR}${DEST_MAN}/man1/7z.1"
echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7za.1"
sed -e s?"{DEST_SHARE_DOC}"?"${DEST_SHARE_DOC}/DOCS"?g man1/7za.1 > "${DEST_DIR}${DEST_MAN}/man1/7za.1"
chmod 444 "${DEST_DIR}${DEST_MAN}/man1/7za.1"
echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7zr.1"
sed -e s?"{DEST_SHARE_DOC}"?"${DEST_SHARE_DOC}/DOCS"?g man1/7zr.1 > "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
chmod 444 "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
else
echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7z.1"
grep -v "{DEST_SHARE_DOC}" man1/7z.1 > "${DEST_DIR}${DEST_MAN}/man1/7z.1"
chmod 444 "${DEST_DIR}${DEST_MAN}/man1/7z.1"
echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7za.1"
grep -v "{DEST_SHARE_DOC}" man1/7za.1 > "${DEST_DIR}${DEST_MAN}/man1/7za.1"
chmod 444 "${DEST_DIR}${DEST_MAN}/man1/7za.1"
echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7zr.1"
grep -v "{DEST_SHARE_DOC}" man1/7zr.1 > "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
chmod 444 "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
fi
if [ -f README ]
then
echo "- installing ${DEST_DIR}${DEST_SHARE_DOC}/README"
mkdir -p "${DEST_DIR}${DEST_SHARE_DOC}"
cp README "${DEST_DIR}${DEST_SHARE_DOC}/README"
chmod 444 "${DEST_DIR}${DEST_SHARE_DOC}/README"
fi
if [ -f ChangeLog ]
then
echo "- installing ${DEST_DIR}${DEST_SHARE_DOC}/ChangeLog"
mkdir -p "${DEST_DIR}${DEST_SHARE_DOC}"
cp ChangeLog "${DEST_DIR}${DEST_SHARE_DOC}/ChangeLog"
chmod 444 "${DEST_DIR}${DEST_SHARE_DOC}/ChangeLog"
fi
if [ -d DOCS ]
then
echo "- installing HTML help in ${DEST_DIR}${DEST_SHARE_DOC}/DOCS"
mkdir -p "${DEST_DIR}${DEST_SHARE_DOC}"
cp -r DOCS "${DEST_DIR}${DEST_SHARE_DOC}/DOCS"
find "${DEST_DIR}${DEST_SHARE_DOC}/DOCS" -type d -exec chmod 555 {} \;
find "${DEST_DIR}${DEST_SHARE_DOC}/DOCS" -type f -exec chmod 444 {} \;
fi