-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: pack parted & sfdisk | ||
# auto-task.start-build-time = ? | ||
|
||
on: | ||
# schedule: | ||
# - cron: '30 20 20 */2 *' | ||
push: | ||
# branches: ["build"] | ||
paths: | ||
- .github/workflows/pack-parted.yml | ||
- assets/parted/Dockerfile | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
builder: ["alpine:edge"] | ||
arch: [ "x64", "x86", "s390x", "ppc64le", "armv7a", "arm64"] | ||
include: | ||
- arch: x64 | ||
oci_arch: amd64 | ||
# builder: ["alpine:edge"] | ||
- arch: x86 | ||
oci_arch: 386 | ||
- arch: s390x | ||
oci_arch: s390x | ||
- arch: ppc64le | ||
oci_arch: ppc64le | ||
- arch: armv7a | ||
oci_arch: arm/v7 | ||
- arch: arm64 | ||
oci_arch: arm64 | ||
|
||
- arch: mipsle | ||
oci_arch: mipsle | ||
builder: ["ghcr.io/2cd/debian:bookworm-mipsle"] | ||
- arch: mipsbe | ||
oci_arch: mips | ||
builder: ["ghcr.io/2cd/debian:buster-mipsbe"] | ||
|
||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: zsh --pipefail -fex {0} | ||
env: | ||
DOCKER_DIR: assets/parted | ||
|
||
steps: | ||
- name: install zsh | ||
shell: sh -e {0} | ||
run: ${{ vars.INSTALL_ZSH }} | ||
|
||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
ref: build | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ${{env.DOCKER_DIR}} | ||
push: true | ||
tags: ghcr.io/2cd/pkgs:parted-${{matrix.arch}} | ||
build-args: | | ||
TMM_ARCH=${{matrix.arch}} | ||
BUILDER=${{matrix.builder}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG BUILDER | ||
ARG TMM_ARCH | ||
|
||
FROM --platform=${BUILDPLATFORM} ghcr.io/2moe/zsh-static as zsh | ||
FROM ghcr.io/2moe/zsh-static:${TMM_ARCH} as zsh_target | ||
# ---------- | ||
FROM --platform=${BUILDPLATFORM} alpine:edge as patcher | ||
RUN apk add patchelf | ||
# ---------- | ||
FROM --platform=${TARGETPLATFORM} ${BUILDER} as builder | ||
COPY --link --from=zsh /opt/bin/zsh /bin | ||
WORKDIR /app/bin | ||
|
||
RUN <<'INSTALL_PARTED' | ||
#!/bin/zsh -fex | ||
mkdir -p ../{lib,share} | ||
pkg_mgr=apk | ||
if (($+commands[apt-get])) { | ||
apt-get update | ||
pkg_mgr=dpkg | ||
} | ||
apt_i() { | ||
apt-get install -y $* | ||
} | ||
for i (parted partprobe sfdisk) { | ||
if [[ $i != partprobe ]] { | ||
case $pkg_mgr { | ||
(dpkg) apt_i $i || apt_i fdisk ;; | ||
(apk) apk add $i ;; | ||
} | ||
hash -r | ||
} | ||
bin=$commands[$i] | ||
cp -L $bin . | ||
|
||
local -A map=($( | ||
ldd $i | awk '{ | ||
printf("%s\n%s\n", $1, $(NF - 1)) | ||
}') | ||
) | ||
local -p i map | ||
|
||
for src dst (${(kv)map}) { | ||
case ${dst:t} { | ||
(linux-vdso.so.*) continue ;; | ||
} | ||
|
||
cp -fL $dst ../lib/ ||: | ||
|
||
lib_file=../lib/${src:t} | ||
|
||
if [[ ! -e $lib_file ]] { | ||
ln -svf ${dst:t} $lib_file | ||
} | ||
} | ||
files=(../lib/ld-*-*.so.*) | ||
print -R ${files[1]:t} > ../share/interpreter.txt | ||
} | ||
INSTALL_PARTED | ||
|
||
FROM patcher as patched | ||
COPY --link --from=zsh /opt/bin/zsh /bin | ||
COPY --from=builder /app /app | ||
WORKDIR /app/bin | ||
RUN <<'PATCH_ELF' | ||
#!/bin/zsh -fex | ||
interpreter=$(< ../share/interpreter.txt) | ||
vendor_dir=/var/lib/tmm/vendor | ||
for i (parted partprobe sfdisk) { | ||
patchelf --set-interpreter ${vendor_dir}/lib/$interpreter $i | ||
patchelf --set-rpath ${vendor_dir}/lib:.:../lib $i ||: | ||
tmpfile=$(mktemp) | ||
> $tmpfile <<'XBIN' | ||
#!/bin/sh | ||
env LD_PRELOAD="" LD_LIBRARY_PATH="_VENDOR_/lib" "_VENDOR_/bin/_BIN_" "$@" | ||
XBIN | ||
sed -e "s@_VENDOR_@$vendor_dir@g" -e "s@_BIN_@$i@" -i $tmpfile | ||
install -Dm755 $tmpfile ../xbin/$i | ||
unlink $tmpfile | ||
} | ||
PATCH_ELF | ||
|
||
# FROM patcher | ||
FROM zsh_target | ||
ARG VENDOR=/var/lib/tmm/vendor | ||
COPY --from=patched /app ${VENDOR} | ||
WORKDIR /bin | ||
RUN ln -svf /opt/bin/busybox /bin/sh | ||
WORKDIR ${VENDOR}/xbin |
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