Skip to content

Commit 2cb032b

Browse files
committed
Merge branch 'master' of https://github.com/xplshn/baseutils
2 parents 20ed28e + bd3a2db commit 2cb032b

File tree

2 files changed

+215
-7
lines changed

2 files changed

+215
-7
lines changed

.github/workflows/build.yml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Build baseutils (Alpine + LLVM)
2+
3+
concurrency:
4+
group: build-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches: ['**']
10+
tags: ['**']
11+
workflow_dispatch:
12+
13+
env:
14+
CC: clang
15+
AR: llvm-ar
16+
STRIP: llvm-strip
17+
LD: ld.mold
18+
CFLAGS: "-O2 -static"
19+
LDFLAGS: "-static"
20+
21+
jobs:
22+
fetch-submodules:
23+
name: Fetch submodules
24+
runs-on: ubuntu-latest
25+
26+
container:
27+
image: alpine:latest
28+
volumes:
29+
- /:/host
30+
- /tmp/node20:/__e/node20
31+
32+
steps:
33+
- name: Patch Alpine for GitHub Actions
34+
run: |
35+
apk add --no-cache nodejs npm gcompat git tar
36+
sed -i 's/^ID=.*/ID=gha/' /etc/os-release
37+
mkdir -p /__e/node20/bin
38+
ln -sf /usr/bin/node /__e/node20/bin/node
39+
ln -sf /usr/bin/npm /__e/node20/bin/npm
40+
41+
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Restore submodules cache
46+
id: cache-submodules
47+
uses: actions/cache/restore@v4
48+
with:
49+
path: .git/modules
50+
key: submodules-${{ hashFiles('.gitmodules') }}
51+
52+
- name: Fetch submodules
53+
run: |
54+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
55+
git submodule update --init --recursive
56+
57+
- name: Save submodules cache
58+
if: steps.cache-submodules.outputs.cache-hit != 'true'
59+
uses: actions/cache/save@v4
60+
with:
61+
path: .git/modules
62+
key: submodules-${{ hashFiles('.gitmodules') }}
63+
64+
- name: Create submodules tarball
65+
run: |
66+
tar -czf submodules.tar.gz .git/modules
67+
apk del tar
68+
69+
- uses: actions/upload-artifact@v4
70+
with:
71+
name: submodules
72+
path: submodules.tar.gz
73+
retention-days: 1
74+
75+
build:
76+
name: ${{ matrix.arch }}
77+
needs: fetch-submodules
78+
runs-on: ubuntu-latest
79+
80+
container:
81+
image: alpine:latest
82+
volumes:
83+
- /:/host
84+
- /tmp/node20:/__e/node20
85+
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
arch: [x86_64, aarch64, i386, riscv64]
90+
91+
steps:
92+
- name: Patch Alpine for GitHub Actions
93+
run: |
94+
apk add --no-cache nodejs npm gcompat git
95+
sed -i 's/^ID=.*/ID=gha/' /etc/os-release
96+
mkdir -p /__e/node20/bin
97+
ln -sf /usr/bin/node /__e/node20/bin/node
98+
ln -sf /usr/bin/npm /__e/node20/bin/npm
99+
100+
- uses: actions/checkout@v4
101+
with:
102+
fetch-depth: 0
103+
104+
- uses: actions/download-artifact@v4
105+
with:
106+
name: submodules
107+
108+
- name: Restore submodules
109+
run: |
110+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
111+
tar -xzf submodules.tar.gz
112+
git submodule update --init --recursive
113+
114+
- name: Install LLVM toolchain
115+
run: |
116+
apk add --no-cache \
117+
clang llvm mold \
118+
musl-dev make curl \
119+
linux-headers \
120+
binutils \
121+
bash
122+
123+
# busybox is disgusting
124+
# toybox is disgusting
125+
# I've not written an alternative to them yet
126+
# So we ought to make do
127+
128+
#for t in ar ranlib nm objcopy objdump strip strings size readelf addr2line; do
129+
# ln -sf "/usr/bin/llvm-$t" "/usr/bin/$t"
130+
#done
131+
132+
ln -sfT /usr/bin/clang /usr/bin/cc
133+
134+
- name: Build
135+
env:
136+
ARCH: ${{ matrix.arch }}
137+
TARGET: ${{ matrix.arch }}-alpine-linux-musl
138+
run: |
139+
set -e
140+
./cbuild.sh clean
141+
./cbuild.sh -vvv
142+
143+
mkdir -p dist
144+
find . -maxdepth 1 -type f -perm -111 ! -name '*.sh' -exec mv {} dist/ \;
145+
146+
- name: Normalize outputs
147+
run: |
148+
for f in dist/*; do
149+
mv "$f" "dist/$(basename "$f")_${{ matrix.arch }}"
150+
done
151+
152+
- uses: actions/upload-artifact@v4
153+
with:
154+
name: baseutils-${{ matrix.arch }}
155+
path: dist/*
156+
157+
release:
158+
needs: build
159+
runs-on: ubuntu-latest
160+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
161+
162+
steps:
163+
- uses: actions/download-artifact@v4
164+
with:
165+
path: artifacts
166+
pattern: baseutils-*
167+
merge-multiple: true
168+
169+
- name: Update continuous release
170+
if: github.ref == 'refs/heads/main'
171+
uses: softprops/action-gh-release@v2
172+
with:
173+
tag_name: continuous
174+
prerelease: true
175+
files: artifacts/*
176+
177+
- name: Update tag release
178+
if: startsWith(github.ref, 'refs/tags/')
179+
uses: softprops/action-gh-release@v2
180+
with:
181+
tag_name: ${{ github.ref_name }}
182+
files: artifacts/*

README.txt

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1. `./cbuild.sh fetch` -> To fetch the submodules
2+
2. `./cbuild.sh -vvv` -> to build with full verbosity
3+
3. Profit
4+
15
# ===== Core POSIX =====
26
/bin/cat:sbase
37
/bin/cp:sbase
@@ -33,7 +37,6 @@
3337
/bin/fold:sbase
3438
/bin/expand:sbase
3539
/bin/unexpand:sbase
36-
3740
# ===== System / Privileged =====
3841
/bin/mount:ubase
3942
/bin/umount:ubase
@@ -44,7 +47,6 @@
4447
/bin/switch_root:ubase
4548
/bin/halt:ubase
4649
/bin/getty:busybox
47-
4850
# ===== Cron / users =====
4951
/bin/crond:toybox
5052
/bin/crontab:toybox
@@ -53,7 +55,6 @@
5355
/bin/userdel:toybox
5456
/bin/groupadd:toybox
5557
/bin/groupdel:toybox
56-
5758
# ===== Shell / Core OS =====
5859
/bin/ash:/bin/sh:busybox
5960
/bin/vi:busybox
@@ -79,7 +80,6 @@
7980
/bin/insmod:toybox
8081
/bin/rmmod:toybox
8182
/bin/lsmod:toybox
82-
8383
# ===== Networking =====
8484
/bin/ip:busybox
8585
/bin/ifconfig:busybox
@@ -90,13 +90,15 @@
9090
/bin/ftpget:busybox
9191
/bin/ftpput:busybox
9292
/bin/hostname:toybox
93-
/bin/wget:toybox
94-
93+
/bin/wget:busybox
94+
/bin/udhcpd:busybox
95+
/bin/udhcpc:busybox
96+
/bin/udhcpc6:busybox
97+
/bin/dhcprelay:busybox
9598
# ===== Build / Text / Archive / FS =====
9699
/bin/grep:toybox
97100
/bin/awk:toybox
98101
/bin/sed:toybox
99-
/bin/tar:toybox
100102
/bin/find:toybox
101103
/bin/cut:toybox
102104
/bin/sort:toybox
@@ -120,3 +122,27 @@
120122
/bin/sha512-224sum:sbase
121123
/bin/sha512-256sum:sbase
122124
/bin/sha512sum:sbase
125+
# ===== Archive / Compression =====
126+
# - archivers -
127+
/bin/cpio:toybox
128+
/bin/tar:busybox
129+
#/bin/ar:busybox
130+
# - gz -
131+
/bin/gzip:busybox
132+
/bin/gunzip:busybox
133+
/bin/zcat:busybox
134+
# - bz -
135+
/bin/bzip2:busybox
136+
/bin/bunzip2:busybox
137+
/bin/bzcat:busybox
138+
# - xz -
139+
/bin/xz:busybox
140+
/bin/unxz:busybox
141+
/bin/xzcat:busybox
142+
# - lz -
143+
/bin/lzma:busybox
144+
/bin/unlzma:busybox
145+
/bin/lzcat:busybox
146+
/bin/lzop:busybox
147+
# - zip -
148+
/bin/unzip:busybox

0 commit comments

Comments
 (0)