Skip to content

Commit

Permalink
Merge pull request #3 from davidar/kernel
Browse files Browse the repository at this point in the history
Kernel
  • Loading branch information
davidar authored Jun 21, 2024
2 parents 18f2b92 + 8982f3b commit 1d331b4
Show file tree
Hide file tree
Showing 18 changed files with 2,046 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v4
-
name: Test
run: ./run-tests.sh
run: scripts/build-docker.sh --test
-
name: Login to Docker Hub
uses: docker/login-action@v3
Expand Down
37 changes: 26 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,39 @@ RUN apk add build-base
RUN apk add ninja

FROM davidar/bootsh:latest AS build-stage0
COPY tarballs /src/tarballs
RUN boot.sh

FROM davidar/bootsh:stage0 AS build-stage1
COPY tarballs /src/tarballs
RUN boot.sh

FROM davidar/bootsh:stage1 AS build-stage2
COPY tarballs /src/tarballs
RUN boot.sh

FROM build-$TAG AS build
COPY tarballs /src/tarballs
WORKDIR /tmp
COPY configure boot.sh configure-musl.sh wak.c install.sh bootsh/
COPY configure bootsh/
COPY scripts bootsh/scripts
COPY src bootsh/src
COPY lib bootsh/lib
RUN cd bootsh && CFLAGS=-Werror ./configure && ninja && DESTDIR=/dest ./install.sh
RUN cd bootsh && CFLAGS=-Werror ./configure && ninja && DESTDIR=/dest scripts/install.sh

FROM alpine AS cpio
RUN apk add xz
COPY --from=build /dest /dest
RUN cd /dest && find . | cpio -H newc -o | xz --check=crc32 -9 --lzma2=dict=1MiB | \
dd conv=sync bs=512 of=/initramfs.cpio.xz

FROM build-latest AS kernel
RUN apk add perl gmp-dev mpc1-dev mpfr-dev elfutils-dev bash flex bison zstd
RUN apk add sed installkernel bc linux-headers linux-firmware-any openssl-dev mawk diffutils findutils zstd pahole python3 gcc
ADD https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.9.5.tar.xz /
RUN tar -xf linux-6.9.5.tar.xz
WORKDIR /linux-6.9.5
COPY linux-6.9.config .config
RUN make -j$(nproc) ARCH=x86 bzImage && cp -f arch/x86/boot/bzImage /

FROM scratch AS output
COPY --from=cpio /initramfs.cpio.xz /
COPY --from=kernel /bzImage /

FROM scratch AS bootsh
COPY --from=build /dest /
ENTRYPOINT ["/bin/boot.sh"]
ENTRYPOINT [ "/sbin/init" ]
CMD [ "/bin/sh" ]
SHELL [ "/sbin/init", "/bin/sh", "-c" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ clean:
rm -rf build lib/toybox/generated

install: all
./install.sh
scripts/install.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This image contains four files:

- `/bin/boot.sh` and `/bin/configure-musl.sh`: shell scripts for bootstrapping the system and building [musl libc](https://musl.libc.org/)

- `/bin/awk`: a [C script](wak.c) (note the `#!/bin/cc -run` interpreter line) which is JIT compiled as needed
- `/bin/awk`: a [C script](scripts/wak.c) (note the `#!/bin/cc -run` interpreter line) which is JIT compiled as needed

Upon running the Docker image, it will bootstrap itself by constructing a minimal root filesystem on top of this.

Expand Down
64 changes: 0 additions & 64 deletions boot.sh

This file was deleted.

12 changes: 6 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if ! $HOSTCC -Wl,--fatal-warnings -static $tmpc -o $tmpc.out 2>&1; then
CFLAGS="$CFLAGS -nostdinc"
HOSTCC="$PWD/sysroot/bin/musl-gcc"
if [ ! -x "$HOSTCC" ]; then
echo "Run ./make-sysroot.sh to install a local copy of musl, or set HOSTCC to the path of musl-gcc"
echo "Run scripts/make-sysroot.sh to install a local copy of musl, or set HOSTCC to the path of musl-gcc"
exit 1
fi
fi
Expand Down Expand Up @@ -315,7 +315,7 @@ CONFIG_PRINTENV=y
# CONFIG_READELF is not set
CONFIG_READLINK=y
# CONFIG_REALPATH is not set
# CONFIG_REBOOT is not set
CONFIG_REBOOT=y
# CONFIG_RESET is not set
# CONFIG_REV is not set
# CONFIG_RMMOD is not set
Expand Down Expand Up @@ -356,7 +356,7 @@ CONFIG_YES=y
# CONFIG_FTPPUT is not set
# CONFIG_HOST is not set
# CONFIG_HTTPD is not set
# CONFIG_IFCONFIG is not set
CONFIG_IFCONFIG=y
# CONFIG_MICROCOM is not set
# CONFIG_NETCAT is not set
# CONFIG_NETSTAT is not set
Expand All @@ -383,17 +383,17 @@ CONFIG_SHA224SUM=y
CONFIG_SHA256SUM=y
CONFIG_SHA384SUM=y
CONFIG_SHA512SUM=y
# CONFIG_MKNOD is not set
CONFIG_MKNOD=y
# CONFIG_MKNOD_Z is not set
CONFIG_MKTEMP=y
# CONFIG_MOUNT is not set
CONFIG_MOUNT=y
# CONFIG_PASSWD is not set
# CONFIG_PASSWD_SAD is not set
# CONFIG_PIDOF is not set
CONFIG_SEQ=y
# CONFIG_SU is not set
# CONFIG_SYNC is not set
# CONFIG_UMOUNT is not set
CONFIG_UMOUNT=y
#
# Example commands
Expand Down
10 changes: 0 additions & 10 deletions install.sh

This file was deleted.

18 changes: 9 additions & 9 deletions lib/toybox/tests/tar.test
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ testing "-I gzip t" 'LST -Igzip -f "$FILES"/tar/tar.tgz' \
"drwxr-x--- enh/eng 0 2017-05-13 01:05 dir/\n-rw-r----- enh/eng 12 2017-05-13 01:05 dir/file\n" \
"" ""

skipnot mknod -m 660 dir/char c 12 34 2>/dev/null && chgrp sys dir/char
NOSPACE=1 testing "character special" "tar --mtime @0 -cf test.tar dir/char && rm -f dir/char && tar xf test.tar && ls -l --full-time dir/char" \
"crw-rw---- 1 root sys 12, 34 1970-01-01 00:00:00.000000000 +0000 dir/char\n"\
"" ""

skipnot mknod -m 660 dir/block b 23 45 2>/dev/null && chgrp sys dir/block
NOSPACE=1 testing "block special" "tar --mtime @0 -cf test.tar dir/block && rm -f dir/block && tar xf test.tar && ls -l --full-time dir/block" \
"brw-rw---- 1 root sys 23, 45 1970-01-01 00:00:00.000000000 +0000 dir/block\n"\
"" ""
# skipnot mknod -m 660 dir/char c 12 34 2>/dev/null && chgrp sys dir/char
# NOSPACE=1 testing "character special" "tar --mtime @0 -cf test.tar dir/char && rm -f dir/char && tar xf test.tar && ls -l --full-time dir/char" \
# "crw-rw---- 1 root sys 12, 34 1970-01-01 00:00:00.000000000 +0000 dir/char\n"\
# "" ""

# skipnot mknod -m 660 dir/block b 23 45 2>/dev/null && chgrp sys dir/block
# NOSPACE=1 testing "block special" "tar --mtime @0 -cf test.tar dir/block && rm -f dir/block && tar xf test.tar && ls -l --full-time dir/block" \
# "brw-rw---- 1 root sys 23, 45 1970-01-01 00:00:00.000000000 +0000 dir/block\n"\
# "" ""

# skipnot chown nobody:nogroup dir/file 2>/dev/null
# testing "ownership" "$TAR dir/file | SUM 3" \
Expand Down
2 changes: 1 addition & 1 deletion lib/toybox/toys/net/ifconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void ifconfig_main(void)
// Handle /netmask
if (mask >= 0) {
// sin_addr probably isn't unaligned, but just in case...
mask = htonl((~0)<<(32-mask));
mask = htonl(((uint32_t)~0)<<(32-mask));
memcpy(&si->sin_addr, &mask, 4);
xioctl(TT.sockfd, SIOCSIFNETMASK, &ifre);
}
Expand Down
Loading

0 comments on commit 1d331b4

Please sign in to comment.