Repository navigation
Expand file tree
/
Copy pathchevahbs
More file actions
executable file
·191 lines (169 loc) · 6.72 KB
/
Copy pathchevahbs
File metadata and controls
executable file
·191 lines (169 loc) · 6.72 KB
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
#!/usr/bin/env bash
#
# Chevah Build Script for Python.
#
# Import shared code and the Bash checks.
. ./functions.sh
#
# Called inside the build folder to prepare the Python source.
#
chevahbs_patch() {
# First we apply the generic patches.
if [ "$OS" = "win" ]; then
echo "No sources to patch in Windows."
return
fi
# Our own patch to avoid compiling certain modules.
echo "Applying disabled_modules.patch:"
execute patch < disabled_modules.patch
# Patch to disable Python 2 / OpenSSL 1.0.2 warnings from cryptography.
echo "Applying crypto_silence_warnings.patch:"
execute patch -p0 < crypto_silence_warnings.patch
# Then we apply features-specific patches.
if [ "$BUILD_LIBEDIT" = "yes" ]; then
# Adapted from the v4 patch at https://bugs.python.org/issue13501.
echo "Applying readline_libedit.patch:"
execute patch -p0 < readline_libedit.patch
fi
# And finally we apply the OS-specific patches.
case $OS in
aix*)
echo "Applying openssl102_allow.patch:"
execute patch -p0 < openssl102_allow.patch
# BLDSHARED fixes from https://bugs.python.org/issue18235.
echo "Applying aix_bldshared.patch:"
execute patch -p0 < aix_bldshared.patch
;;
sol11)
# The "mmheap" package is required to build Python.
echo "Applying openssl102_allow.patch:"
execute patch -p0 < openssl102_allow.patch
;;
esac
}
chevahbs_configure() {
CONFIG_ARGS="--disable-shared"
CONFIGURE_ENVIRONMENT=""
if [ "$OS" != "win" ]; then
echo "Copying our header files among Python's ones..."
execute cp -r "$INSTALL_FOLDER"/include/* ./Include/
fi
case $OS in
aix*)
# Workaround for http://bugs.python.org/issue21917
echo "import os; os.__dict__.pop('O_NOFOLLOW', None)" \
>> Lib/site-packages/sitecustomize.py
# Computed goto's are a problem with Python 2.7.13,
# details at https://bugs.python.org/issue9799.
CONFIG_ARGS="${CONFIG_ARGS} \
--with-system-ffi \
--without-computed-gotos \
"
;;
macos*)
CONFIG_ARGS="${CONFIG_ARGS} --without-gcc"
;;
fbsd*|sol11*)
LDFLAGS="$LDFLAGS -lncurses"
;;
obsd*)
# In OpenBSD 6.1 and newer we need to mark the Python binary as
# "wxneeded" because it breaks the mandatory W^X protection.
LDFLAGS="$LDFLAGS -Wl,-z,wxneeded"
;;
esac
# This requires the v4 patch from https://bugs.python.org/issue13501.
if [ "$BUILD_LIBEDIT" = "yes" ]; then
CONFIG_ARGS="${CONFIG_ARGS} --with-readline=editline"
fi
case $OS in
win)
echo "Skip configure on Windows."
;;
*)
execute ./configure --prefix="" $CONFIG_ARGS
# These files are already created in the Python distribution,
# but for some strange reason, make tries to recreate them.
# We just touch them so that make will see them up to date.
touch Include/Python-ast.h Python/Python-ast.c
;;
esac
}
chevahbs_compile() {
case $OS in
win)
echo "Skip make on Windows."
;;
*)
echo "Patching the git rev id into Python's version string..."
cp Modules/getbuildinfo.c Modules/getbuildinfo.c.orig
VCS_ID="gitid"
if [ $PYTHON_BUILD_VERSION == "2.7.8" ] ; then
VCS_ID="hgid"
fi
execute sed -e \
s/$VCS_ID\ =\ \"default\"/$VCS_ID\ =\ \"$PYTHON_PACKAGE_VERSION\"/g \
Modules/getbuildinfo.c.orig > Modules/getbuildinfo.c
execute $MAKE
;;
esac
}
chevahbs_install() {
case $OS in
win)
local destination=$INSTALL_FOLDER/lib
local inst_ext="msi"
local arch_dir=$ARCH
if [ "$ARCH" = "x64" ]; then
# Upstream installer filename ends in ".msi" or ".amd64.msi".
inst_ext="amd64.msi"
# VC redist x64 DLLs actually use "amd64" in filenames.
arch_dir="amd64"
fi
# On Windows we don't build from source but rather create the
# distribution from pre-compiled binaries.
current_win_path=`pwd -W | sed 's|\/|\\\\|g'`
install_win_path=`cd $INSTALL_FOLDER && pwd -W | sed 's|\/|\\\\|g'`
echo "Extracting MSI to $install_win_path"
execute msiexec //a \
$current_win_path\\python-"$PYTHON_BUILD_VERSION"."$inst_ext" \
//qn TARGETDIR=$install_win_path\\lib
# Copy Windows redistributables
local redistributables=../../win-tools/redistributables/
echo "Copying redistributables for Windows"
execute cp $redistributables/$REDISTRIBUTABLE_VERSION/$arch_dir/* \
$destination
wipe_manifest $destination/python.exe
wipe_manifest $destination/pythonw.exe
wipe_manifest $destination/python27.dll
# Remove Python MSI installer.
echo "Removing: $destination/python-installer.msi"
execute rm -f --verbose $destination/python-installer.msi
# add cp65001 as an utf-8 alias.
execute mv \
$destination/lib/encodings/aliases.py \
$destination/lib/encodings/aliases.old
execute \
sed "s|# utf_8 codec|# utf_8 codec\n 'cp65001' : 'utf_8',|" < $destination/lib/encodings/aliases.old > $destination/lib/encodings/aliases.py
# Patch to disable Python 2 / OpenSSL 1.0.2 warnings from cryptography.
echo "Applying crypto_silence_warnings.patch:"
execute patch -d $destination -p0 < crypto_silence_warnings.patch
# Lifted from https://github.com/ActiveState/cpython/.
for hotfix in *.diff; do
echo "Applying ${hotfix}:"
execute patch -d $destination -p1 < $hotfix
done
;;
*)
if [ -f /etc/alpine-release ]; then
# EMUTRAMP required for full functionality under a grsec kernel.
# Don't use "paxmark", file attributes will be lost when tar'ed.
# Needed with non-grsec kernels as well, otherwise PAM-related
# compat tests crash with signal 11 (tested on Alpine 3.12).
execute paxctl -cE python
fi
execute $MAKE install DESTDIR=$INSTALL_FOLDER
;;
esac
}
select_chevahbs_command $@