- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-python-debian.sh
More file actions
Latest commit
executable file
·44 lines (37 loc) · 1.81 KB
/
Copy pathadd-python-debian.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.81 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
#!/bin/bash
."$(readlink -f "${BASH_SOURCE[0]}"| xargs dirname)/utils.sh"
# DEBIAN_VERSION="buster"
# DEBIAN_VARIANT="slim"
# PYTHON_VERSION="3.7"
functioninstall_python() {
output_file=$1
python_version=$2
# Creating temp folder and entering it
temp_folder
source_url="https://raw.githubusercontent.com/docker-library/python/master/${python_version}/buster/slim/Dockerfile"
wget --quiet ${source_url}
# Skip 6 first lines (comment)
tail -n +6 Dockerfile >Dockerfile_trunc
# Remove CMD
sed -ie 's/^CMD .*$//g' Dockerfile_trunc
# Remove FROM
sed -ie 's/^FROM .*$//g' Dockerfile_trunc
# Cd to a folder to avoid weird error in CI
sed -ie 's/make install/make install \&\& cd \/usr\/local/' Dockerfile_trunc
# Comment under are to keep this version
PYTHON_PRECISE_VERSION=$(cat Dockerfile_trunc | grep 'ENV PYTHON_VERSION'| sed -e 's/ENV PYTHON_VERSION \(.*\)$/\1/g')
PIP_PRECISE_VERSION=$(cat Dockerfile_trunc | grep 'ENV PYTHON_PIP_VERSION'| sed -e 's/ENV PYTHON_PIP_VERSION \(.*\)$/\1/g')
echo''>>"${output_file}"
echo'# Dockerfile generated fragment to install Python and Pip'>>"${output_file}"
echo"# Source: ${source_url}">>"${output_file}"
echo"# Python: ${PYTHON_PRECISE_VERSION}">>"${output_file}"
echo"# Pip: ${PIP_PRECISE_VERSION}">>"${output_file}"
echo"">>"${output_file}"
cat Dockerfile_trunc >>"${output_file}"
# Now, to avoid GPG problems
# https://github.com/f-secure-foundry/usbarmory-debian-base_image/issues/9
sed -i 's/^\(.*&&.*export GNUPGHOME="$(mktemp -d)" \)/\1\\\n# Fix to avoid GPG server problem\n\t\&\& echo "disable-ipv6" >> ${GNUPGHOME}\/dirmngr.conf /'"${output_file}"
sed -i "s/ -o -name '\*\.a' / /""${output_file}"
# Exiting temp folder and removing it
cleanup_folder
}