cache linux environments #446
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cache linux environments | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "33 2 * * *" | |
jobs: | |
centos7: | |
name: ${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
container: "centos:7" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup CentOS and EPEL mirror | |
run: | | |
CENTOS_MIRROR='mirror.facebook.net/centos/' | |
sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo | |
sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#baseurl=http://mirror\.centos\.org/centos/|baseurl=https://'$CENTOS_MIRROR'|g' /etc/yum.repos.d/*.repo | |
yum install -yy epel-release | |
EPEL_MIRROR='mirror.facebook.net/fedora/epel/' | |
sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo | |
sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#baseurl=http://download.fedoraproject.org/pub/epel/|baseurl=https://'$EPEL_MIRROR'|g' /etc/yum.repos.d/*.repo | |
- name: Cache PHP 8.1 and cmake tar for CentOS | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
path: | | |
/opt/cmake | |
/opt/php | |
/usr/bin/tar | |
/usr/libexec/rmt | |
# note: match this | |
key: linux-centos-v3 | |
- name: Prepare PHP 8.1 and cmake tar for CentOS | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
yum groupinstall -yy 'Development Tools' | |
yum install -yy re2c xz tar curl | |
mkdir -p php-src | |
curl -sLO https://www.php.net/distributions/php-8.1.6.tar.xz | |
tar -xf php-8.1.6.tar.xz --strip-components=1 -C php-src | |
cd php-src | |
./configure \ | |
--prefix=/opt/php \ | |
--disable-all \ | |
--enable-cli | |
make -j $(nproc) | |
make install | |
cd .. | |
mkdir -p /opt/cmake | |
curl -sLO https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-linux-x86_64.tar.gz | |
tar -xf cmake-3.23.1-linux-x86_64.tar.gz --strip-components=1 -C /opt/cmake | |
curl -sLO https://ftp.gnu.org/gnu/tar/tar-latest.tar.xz | |
mkdir tar | |
tar -xf tar-latest.tar.xz --strip-components=1 -C tar | |
cd tar | |
FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr | |
make -j $(nproc) | |
make install | |
cd .. | |
fedora: | |
name: ${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
container: "fedora" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Fedora mirror | |
run: | | |
FEDORA_MIRROR='mirror.facebook.net/fedora/linux/' | |
find /etc/yum.repos.d -name "*cisco*.repo" -exec rm {} \; | |
sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo | |
sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#baseurl=http://download.example/pub/fedora/linux/|baseurl=https://'$FEDORA_MIRROR'|g' /etc/yum.repos.d/*.repo | |
- name: Cache Fedora arm64 things | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
path: | | |
/usr/aarch64-linux-gnu/sys-root | |
# note: match this | |
key: linux-fedora-arm64-v1 | |
- name: Prepare Fedora arm64 things | |
run: | | |
dnf install -yy php | |
exec php $0 || false | |
<?php | |
$mirror = 'https://mirror.facebook.net'; | |
passthru('yum install -yy cpio curl '); | |
@mkdir('/usr/aarch64-linux-gnu/sys-root', recursive: true); | |
exec("curl -sL \"$mirror\"/centos-altarch/7/os/aarch64/Packages/", $page, $ret); | |
$page = implode("\n", $page); | |
if ($ret != 0) { | |
exit("failed fetch page"); | |
} | |
function getlast($package, $page) { | |
preg_match_all('/href="(?<filename>'.$package.'-(?<version>[\d\-.]+)\.el7\.aarch64\.rpm)"/i', $page, $matches); | |
if (!$matches) { | |
exit("failed finding $package"); | |
} | |
$versions = []; | |
foreach($matches['version'] as $i => $version) { | |
$versions[str_replace('-', '.', $version)] = $matches['filename'][$i]; | |
} | |
uksort($versions, 'version_compare'); | |
return end($versions); | |
} | |
foreach ([ | |
'glibc', | |
'glibc-common', | |
'glibc-devel', | |
'glibc-static', | |
'glibc-headers', | |
'kernel-headers', | |
] as $package) { | |
$file = getlast($package, $page); | |
passthru( | |
'set -x ; ' . | |
"curl -sL -o /tmp/$file \"$mirror\"/centos-altarch/7/os/aarch64/Packages/$file && ". | |
"cd /usr/aarch64-linux-gnu/sys-root && ". | |
"rpm2cpio /tmp/$file | cpio -idmv", | |
$ret); | |
if ($ret != 0) { | |
exit("failed fetch $file"); | |
} | |
}?> |