@@ -26,45 +26,63 @@ jobs:
2626 libelf-dev rsync kmod git cpio wget zip \
2727 unzip python3 python-is-python3 make xz-utils python3-pip ccache rsync
2828
29+ - name : Check for existing Python 2.7
30+ id : check-python
31+ run : |
32+ if command -v python2.7 &> /dev/null; then
33+ echo "python_exists=true" >> $GITHUB_OUTPUT
34+ echo "✅ Python 2.7 already installed in system"
35+ else
36+ echo "python_exists=false" >> $GITHUB_OUTPUT
37+ echo "❌ Python 2.7 not found, will install"
38+ fi
39+
2940 - name : Cache Python 2.7
41+ if : steps.check-python.outputs.python_exists == 'false'
3042 uses : actions/cache@v4
3143 id : cache-python27
3244 with :
33- path : /usr/local /python-2.7.18
34- key : python-2.7.18-${{ runner.os }}-${{ hashFiles('.github/workflows/**') }}
45+ path : /tmp /python-2.7.18
46+ key : python-2.7.18-${{ runner.os }}-v3
3547 restore-keys : |
3648 python-2.7.18-${{ runner.os }}-
3749
38- - name : Build and Install Python 2.7 (if cache miss)
39- if : steps.cache-python27.outputs.cache-hit != 'true'
50+ - name : Build and Install Python 2.7 (if not exists and cache miss)
51+ if : steps.check-python.outputs.python_exists == 'false' && steps. cache-python27.outputs.cache-hit != 'true'
4052 run : |
41- cd ~
53+ echo "Installing Python 2.7.18 from source..."
54+ cd /tmp
4255 wget -q https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
4356 tar -xzf Python-2.7.18.tgz
4457 cd Python-2.7.18
45- ./configure --enable-optimizations --prefix=/usr/local /python-2.7.18
58+ ./configure --enable-optimizations --prefix=/tmp /python-2.7.18
4659 make -j$(nproc)
47- sudo make install
60+ make install
4861 cd ..
4962 rm -rf Python-2.7.18*
50- # 创建符号链接
51- sudo ln -sf /usr/local/python-2.7.18/bin/python2.7 /usr/local/bin/python2.7
52- sudo ln -sf /usr/local/python-2.7.18/bin/python2.7 /usr/local/bin/python2
5363
54- - name : Setup Python 2.7 (if cache hit)
55- if : steps.cache-python27.outputs.cache-hit == 'true'
64+ - name : Setup Python from cache
65+ if : steps.check-python.outputs.python_exists == 'false' && steps. cache-python27.outputs.cache-hit == 'true'
5666 run : |
5767 echo "Using cached Python 2.7.18"
58- # 创建符号链接
59- sudo ln -sf /usr/local/python-2.7.18/bin/python2.7 /usr/local/bin/python2.7 || true
60- sudo ln -sf /usr/local/python-2.7.18/bin/python2.7 /usr/local/bin/python2 || true
61- python2.7 --version
6268
63- - name : Verify Python installation
69+ - name : Install Python to system (if built from source)
70+ if : steps.check-python.outputs.python_exists == 'false' && steps.cache-python27.outputs.cache-hit != 'true'
6471 run : |
65- echo "Python versions:"
66- which python2.7 && python2.7 --version || echo "python2.7 not found"
67- which python2 && python2 --version || echo "python2 not found"
72+ echo "Installing Python 2.7.18 to system..."
73+ sudo cp -r /tmp/python-2.7.18/* /usr/local/
74+ sudo ln -sf /usr/local/bin/python2.7 /usr/local/bin/python2
75+
76+ - name : Final Python verification
77+ run : |
78+ echo "Final Python verification:"
79+ which python2.7 && python2.7 --version || echo "python2.7 not in PATH"
80+ which python2 && python2 --version || echo "python2 not in PATH"
81+ # 如果系统没有,使用我们安装的
82+ if ! command -v python2.7 &> /dev/null; then
83+ echo "Adding /usr/local/bin to PATH"
84+ echo "/usr/local/bin" >> $GITHUB_PATH
85+ fi
6886
6987 - name : Clone kernel source and setup KernelSU
7088 run : |
0 commit comments