Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
Moe-hacker committed Oct 27, 2024
1 parent a3663bf commit f860d99
Show file tree
Hide file tree
Showing 9 changed files with 292 additions and 2 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: AARCH64

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
check_update:
name: Check update
runs-on: ubuntu-latest
steps:
- name: Check version
id: check_version
run: |
local_version=$(curl -L --header 'authorization: Bearer ${{ github.token }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
remote_version=$(curl -L https://api.github.com/repos/Moe-sushi/xz-static/releases/latest | jq -r .tag_name)
echo local_version=$local_version | tee -a $GITHUB_OUTPUT
echo remote_version=$remote_version | tee -a $GITHUB_OUTPUT
outputs:
local_version: ${{ steps.check_version.outputs.local_version }}
remote_version: ${{ steps.check_version.outputs.remote_version }}
build:
name: Build
needs: check_update
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set env
run: |
echo remote_version=${{ needs.check_update.outputs.remote_version }} | tee -a $GITHUB_ENV
echo build_time=$(TZ=Asia/Shanghai date '+%Y%m%d%H%M') | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
name: Install packages
id: runcmd
with:
arch: aarch64
distro: ubuntu_latest
run: |
bash chroot-alpine.sh
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.remote_version }}
body: |
Build time: ${{ env.build_time }}
prerelease: false
files: |
/home/runner/work/xz-static/xz-static/aarch64.tar
53 changes: 53 additions & 0 deletions .github/workflows/armv7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ARMV7

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
check_update:
name: Check update
runs-on: ubuntu-latest
steps:
- name: Check version
id: check_version
run: |
local_version=$(curl -L --header 'authorization: Bearer ${{ github.token }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
remote_version=$(curl -L https://api.github.com/repos/Moe-sushi/xz-static/releases/latest | jq -r .tag_name)
echo local_version=$local_version | tee -a $GITHUB_OUTPUT
echo remote_version=$remote_version | tee -a $GITHUB_OUTPUT
outputs:
local_version: ${{ steps.check_version.outputs.local_version }}
remote_version: ${{ steps.check_version.outputs.remote_version }}
build:
name: Build
needs: check_update
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set env
run: |
echo remote_version=${{ needs.check_update.outputs.remote_version }} | tee -a $GITHUB_ENV
echo build_time=$(TZ=Asia/Shanghai date '+%Y%m%d%H%M') | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
name: Install packages
id: runcmd
with:
arch: armv7
distro: ubuntu_latest
run: |
bash chroot-alpine.sh
mv *.tar armv7.tar
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.remote_version }}
body: |
Build time: ${{ env.build_time }}
prerelease: false
files: |
/home/runner/work/xz-static/xz-static/armv7.tar
52 changes: 52 additions & 0 deletions .github/workflows/riscv64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: RISCV64

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
check_update:
name: Check update
runs-on: ubuntu-latest
steps:
- name: Check version
id: check_version
run: |
local_version=$(curl -L --header 'authorization: Bearer ${{ github.token }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
remote_version=$(curl -L https://api.github.com/repos/Moe-sushi/xz-static/releases/latest | jq -r .tag_name)
echo local_version=$local_version | tee -a $GITHUB_OUTPUT
echo remote_version=$remote_version | tee -a $GITHUB_OUTPUT
outputs:
local_version: ${{ steps.check_version.outputs.local_version }}
remote_version: ${{ steps.check_version.outputs.remote_version }}
build:
name: Build
needs: check_update
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set env
run: |
echo remote_version=${{ needs.check_update.outputs.remote_version }} | tee -a $GITHUB_ENV
echo build_time=$(TZ=Asia/Shanghai date '+%Y%m%d%H%M') | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
name: Install packages
id: runcmd
with:
arch: riscv64
distro: ubuntu_latest
run: |
bash build-riscv64.sh
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.remote_version }}
body: |
Build time: ${{ env.build_time }}
prerelease: false
files: |
/home/runner/work/xz-static/xz-static/riscv64.tar
49 changes: 49 additions & 0 deletions .github/workflows/x86_64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: X86_64

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
check_update:
name: Check update
runs-on: ubuntu-latest
steps:
- name: Check version
id: check_version
run: |
local_version=$(curl -L --header 'authorization: Bearer ${{ github.token }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
remote_version=$(curl -L https://api.github.com/repos/Moe-sushi/xz-static/releases/latest | jq -r .tag_name)
echo local_version=$local_version | tee -a $GITHUB_OUTPUT
echo remote_version=$remote_version | tee -a $GITHUB_OUTPUT
outputs:
local_version: ${{ steps.check_version.outputs.local_version }}
remote_version: ${{ steps.check_version.outputs.remote_version }}
build:
name: Build
needs: check_update
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set env
run: |
echo remote_version=${{ needs.check_update.outputs.remote_version }} | tee -a $GITHUB_ENV
echo build_time=$(TZ=Asia/Shanghai date '+%Y%m%d%H%M') | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
- name: Install packages
run: |
sudo bash chroot-alpine.sh
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.remote_version }}
body: |
This is ruri binary release.
Build time: ${{ env.build_time }}
prerelease: false
files: |
/home/runner/work/xz-static/xz-static/x86_64.tar
/home/runner/work/xz-static/xz-static/i386.tar
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# xz-static
xz static binary for aarch64, armv7, x86_64, i386 and riscv64
xz static binary
26 changes: 26 additions & 0 deletions build-riscv64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apt update
apt install -y sudo
sudo apt install -y git wget
yes|sudo apt install --no-install-recommends -y curl xz-utils \
make \
clang \
libseccomp-dev \
libcap-dev \
libc6-dev \
binutils

BASE_URL="https://dl-cdn.alpinelinux.org/alpine/edge/releases/riscv64"
ROOTFS_URL=$(curl -s -L "$BASE_URL/latest-releases.yaml" | grep "alpine-minirootfs"|grep "riscv64.tar.gz" | head -n 1|awk '{print $2}')
FULL_URL="$BASE_URL/$ROOTFS_URL"
wget "$FULL_URL"
mkdir alpine
tar -xvf "$ROOTFS_URL" -C alpine
git clone https://github.com/moe-hacker/ruri
cd ruri
cc -Wl,--gc-sections -static src/*.c src/easteregg/*.c -o ruri -lcap -lseccomp -lpthread
cd ..
sudo cp file.c alpine/file.c
sudo cp build.sh alpine/build.sh
sudo chmod +x alpine/build.sh
sudo ./ruri/ruri ./alpine /bin/sh /build.sh
cp alpine/$(uname -m).tar .
11 changes: 11 additions & 0 deletions build-x86.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BASE_URL="https://dl-cdn.alpinelinux.org/alpine/edge/releases/x86"
ROOTFS_URL=$(curl -s -L "$BASE_URL/latest-releases.yaml" | grep "alpine-minirootfs"|grep "x86.tar.gz" | head -n 1|awk '{print $2}')
FULL_URL="$BASE_URL/$ROOTFS_URL"
wget "$FULL_URL"
mkdir x86
tar -xvf "$ROOTFS_URL" -C x86
sudo cp file.c x86/file.c
sudo cp build.sh x86/build.sh
sudo chmod +x x86/build.sh
sudo ./ruri/ruri ./x86 /bin/sh /build.sh
cp x86/*.tar ./i386.tar
22 changes: 22 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
rm /etc/resolv.conf
echo nameserver 1.1.1.1 > /etc/resolv.conf
echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
apk add wget make clang git xz-dev libintl libbsd-static libsemanage-dev libselinux-utils libselinux-static xz-libs zlib zlib-static libselinux-dev linux-headers libssl3 libbsd libbsd-dev gettext-libs gettext-static gettext-dev gettext python3 build-base openssl-misc openssl-libs-static openssl zlib-dev xz-dev openssl-dev automake libtool bison flex gettext autoconf gettext sqlite sqlite-dev pcre-dev wget texinfo docbook-xsl libxslt docbook2x musl-dev gettext gettext-asprintf gettext-dbg gettext-dev gettext-doc gettext-envsubst gettext-lang gettext-libs gettext-static
apk add upx
mkdir output

# OK
git clone https://github.com/xz-mirror/xz
cd xz
autoreconf -fi
./autogen.sh
./configure LDFLAGS="-static" --enable-static --disable-shared
make -j8 LDFLAGS="--static"
strip src/xz/xz
upx src/xz/xz
cp src/xz/xz ../output/
cp COPYING ../output/LICENSE-xz
cd ..
cd output
tar -cvf ../$(uname -m).tar .
exit 0
26 changes: 26 additions & 0 deletions chroot-alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apt update
apt install -y sudo
sudo apt install -y git wget
yes|sudo apt install --no-install-recommends -y curl xz-utils \
make \
clang \
libseccomp-dev \
libcap-dev \
libc6-dev \
binutils
git clone https://github.com/moe-hacker/rootfstool
rootfstool/rootfstool d -d alpine -v edge
mkdir alpine
sudo tar -xvf rootfs.tar.xz -C alpine
git clone https://github.com/moe-hacker/ruri
cd ruri
cc -Wl,--gc-sections -static src/*.c src/easteregg/*.c -o ruri -lcap -lseccomp -lpthread
cd ..
sudo cp file.c alpine/file.c
sudo cp build.sh alpine/build.sh
sudo chmod +x alpine/build.sh
sudo ./ruri/ruri ./alpine /bin/sh /build.sh
cp alpine/$(uname -m).tar .
if [[ $(uname -m) == "amd64" ]]||[[ $(uname -m) == "x86_64" ]]; then
bash build-x86.sh
fi

0 comments on commit f860d99

Please sign in to comment.