├── .build.yml ├── .github └── workflows │ ├── all.yml │ ├── debian-installer.yml │ ├── debian.yml │ ├── modules.yml │ ├── qemu.yml │ ├── random.yml │ ├── release.yml │ ├── video-barebox.yml │ ├── video-debian.yml │ ├── video-uboot.yml │ └── video.yml ├── .gitignore ├── .gitmodules ├── COPYING ├── Makefile ├── README.org ├── blobs ├── README.org └── blobs.mk ├── bootloaders ├── README.org ├── barebox │ ├── barebox.config │ ├── barebox.mk │ ├── pearl │ │ └── bin │ │ │ └── barebox │ ├── t8103-j274.dts │ └── t8103.dtsi ├── bootloaders.mk ├── grub │ └── grub.mk ├── m1n1 │ ├── m1n1.mk │ └── pearl │ │ └── bin │ │ └── m1n1 └── u-boot │ ├── pearl │ └── bin │ │ └── u-boot │ ├── u-boot.config │ └── u-boot.mk ├── bootstrap ├── debian ├── README.org ├── deb │ ├── deb.mk │ └── deb.pl ├── debian.mk ├── debootstrap │ └── debootstrap.mk ├── injected │ └── bin │ │ └── installer └── pearl │ └── bin │ ├── auto-boot-debian │ ├── debian │ └── installer ├── g ├── Makefile ├── README.md ├── bin │ ├── add-remotes │ ├── add-self-remotes │ ├── branches │ ├── canonical │ ├── fetch │ ├── fetch-canon │ ├── fetch-upstream │ ├── find-canonical │ ├── fix-remotes │ ├── gather-remotes │ ├── incoming │ ├── init-repo │ ├── install-hooks │ ├── install-remote │ ├── install-remotes │ ├── locked │ ├── merge-incoming │ ├── p │ ├── pipcet │ ├── pre-push-hook │ ├── prepare-merge │ ├── prepare-specific-merge │ ├── pull │ ├── pull-push │ ├── push-canon │ ├── push-remotes │ ├── push-upstream │ ├── remotes │ ├── remotes-mk │ ├── remove-remotes │ ├── reverse-remotes │ ├── storage │ ├── storage2 │ ├── try-install-remote │ ├── u │ └── up ├── branches.txt ├── canonical.txt ├── fixed-remotes.txt ├── git │ └── hooks │ │ ├── post-commit │ │ ├── pre-push │ │ └── prepare-commit-msg ├── github │ ├── artifact-init │ ├── dl-artifact │ ├── dl-artifact.js │ ├── dl-daily │ ├── env │ │ ├── action.yml │ │ └── index.js │ ├── github.mk │ ├── release.js │ ├── ul-artifact │ └── ul-artifact.js ├── merge-branches.txt ├── new-remotes.txt ├── push-branches.txt ├── remotes.txt ├── stampserver │ ├── stampserver.mk │ └── stampserver.pl └── upstream-branches.txt ├── host ├── bashify │ └── bashify.bash ├── host.mk ├── macho-tools │ ├── bring-up-phys.c │ ├── disable-timers.S │ ├── enable-all-clocks.c │ ├── image-header.S │ ├── image-to-macho.c │ ├── macho-boot.c │ ├── macho-image-fill │ ├── macho-to-image.c │ ├── macho-to-initramfs │ ├── macho-tools.mk │ ├── nop.S │ ├── perform-alignment.c │ ├── restore-boot-args.S │ ├── save-boot-args.S │ └── x8r8g8b8.c ├── pack │ ├── pack │ ├── pack.bash │ ├── pack.mk │ └── pack.pl └── snippet │ ├── snippet.h │ └── snippet.mk ├── linux ├── README.org ├── linux.config ├── linux.mk ├── pearl.config ├── pearl.dts └── stage2.config ├── local ├── README.org ├── boot-el │ ├── boot-el.mk │ └── pearl │ │ └── share │ │ └── boot.el ├── dt │ ├── adtdump.c │ ├── adtp.cc │ ├── dt │ ├── dt.mk │ └── macho-version.c ├── dtc-relocs │ ├── dtc-relocs │ └── dtc-relocs.mk ├── initramfs │ ├── build-cpiospec.pl │ ├── initramfs.mk │ └── pearl.cpiospec ├── interactor │ ├── interactor.mk │ └── pearl │ │ └── bin │ │ ├── interactor │ │ ├── interactor-menu │ │ ├── interactor-perl │ │ └── once-sh ├── local.mk ├── memdump │ ├── boot.c │ ├── image.S │ ├── macho-to-memdump │ ├── memdump-to-image.c │ └── memdump.mk └── sendfile │ ├── receive-sendfile.c │ ├── send-sendfile │ └── sendfile.mk ├── pearl.ditaa ├── pearl ├── bin │ ├── debian-init │ ├── delay │ ├── enable-framebuffer │ ├── enable-wdt │ ├── final │ ├── gadget │ ├── gadget-mode │ ├── in-stage2 │ ├── init │ ├── init-final │ ├── init-final-debian │ ├── init-final-installer │ ├── init-final-root │ ├── init-final-shell │ ├── init-linux │ ├── init-rootshell │ ├── init-shell │ ├── init-stage1 │ ├── init-stage2 │ ├── init-stage3 │ ├── linux │ ├── linux-init │ ├── morse │ ├── no-payload │ ├── no4k │ ├── prepare-linux │ ├── prepare-stage2 │ ├── reboot-recovery │ ├── reboot-wdt │ ├── root │ ├── rootshell │ ├── sendfile │ ├── set-no4k │ ├── stage1 │ ├── stage2 │ ├── stage3 │ ├── start-cpus │ ├── undim-framebuffer │ ├── usbnet │ ├── wifi │ ├── x2r10g10b10 │ └── x8r8g8b8 └── init ├── qemu └── qemu.mk ├── recovery └── bin │ ├── kmutil-script │ ├── kmutil-script-raw │ └── readline.pm ├── sendfile └── sendfile.mk ├── toolchain ├── README.org ├── binutils-gdb │ └── binutils-gdb.mk ├── gcc │ └── gcc.mk └── toolchain.mk ├── userspace ├── IPC-Run │ └── IPC-Run.mk ├── README.org ├── busybox │ ├── busybox.config │ └── busybox.mk ├── cryptsetup │ └── cryptsetup.mk ├── dialog │ └── dialog.mk ├── dropbear │ └── dropbear.mk ├── dtc │ └── dtc.mk ├── emacs │ └── emacs.mk ├── glibc │ └── glibc.mk ├── json-c │ └── json-c.mk ├── kexec-tools │ └── kexec-tools.mk ├── libaio │ └── libaio.mk ├── libnl │ └── libnl.mk ├── lvm2 │ └── lvm2.mk ├── memtool │ └── memtool.mk ├── ncurses │ └── ncurses.mk ├── nvme-cli │ └── nvme-cli.mk ├── openssl │ └── openssl.mk ├── perl │ └── perl.mk ├── popt │ └── popt.mk ├── procps │ └── procps.mk ├── screen │ └── screen.mk ├── slurp │ └── slurp.mk ├── sys-mmap │ └── sys-mmap.mk ├── userspace.mk ├── util-linux │ └── util-linux.mk ├── wpa │ ├── wpa.mk │ └── wpa_supplicant.config ├── zlib │ └── zlib.mk ├── zsh │ └── zsh.mk └── zstd │ └── zstd.mk ├── video ├── barebox.mk ├── pearl-debian.mk ├── pearl.mk ├── u-boot.mk └── video.mk └── zstd ├── chickens.S ├── zstd.lds ├── zstd.mk ├── zstdlib.c └── zstdmain.c /.build.yml: -------------------------------------------------------------------------------- 1 | image: alpine/edge 2 | tasks: 3 | - build: | 4 | echo "this should run a task!" 5 | -------------------------------------------------------------------------------- /.github/workflows/all.yml: -------------------------------------------------------------------------------- 1 | name: all 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ update ] 6 | pull_request: 7 | branches: [ update ] 8 | jobs: 9 | all: 10 | name: all 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | submodules: recursive 16 | - name: Set env variables 17 | uses: ./g/github/env/ 18 | - run: sudo apt-get update 19 | - run: sudo apt-get install autopoint 20 | - run: sudo apt-get install lzop 21 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 22 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 23 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 24 | - run: sudo apt-get install gettext 25 | - run: sudo apt-get install xz-utils 26 | - run: sudo apt-get install device-tree-compiler 27 | - run: sudo apt-get install libtool-bin 28 | - run: make -j13 all 29 | -------------------------------------------------------------------------------- /.github/workflows/debian-installer.yml: -------------------------------------------------------------------------------- 1 | name: debian-installer 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | jobs: 9 | all: 10 | name: all 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | submodules: recursive 16 | - name: Set env variables 17 | uses: ./g/github/env/ 18 | - run: sudo apt-get update 19 | - run: sudo apt-get install autopoint 20 | - run: sudo apt-get install lzop 21 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 22 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 23 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 24 | - run: sudo apt-get install qemu-system-aarch64 sharutils 25 | - run: sudo apt-get install gettext 26 | - run: sudo apt-get install xz-utils 27 | - run: sudo apt-get install device-tree-compiler 28 | - run: sudo apt-get install libtool-bin myrepos 29 | - run: echo 1 | sudo tee /proc/sys/vm/overcommit_memory 30 | - run: make -j13 build/netboot-initrd.cpio.gz 31 | - run: make -j13 build/netboot-initrd.cpio.gz{artifact} 32 | -------------------------------------------------------------------------------- /.github/workflows/debian.yml: -------------------------------------------------------------------------------- 1 | name: debian 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | jobs: 9 | debian: 10 | name: debian 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | submodules: false 16 | - name: Set env variables 17 | uses: ./g/github/env/ 18 | - run: sudo apt-get update 19 | - run: sudo apt-get install autopoint 20 | - run: sudo apt-get install lzop 21 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 22 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 23 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 24 | - run: sudo apt-get install qemu-system 25 | - run: sudo apt-get install sharutils 26 | - run: sudo apt-get install gettext 27 | - run: sudo apt-get install xz-utils 28 | - run: sudo apt-get install device-tree-compiler 29 | - run: sudo apt-get install libtool-bin 30 | - run: git submodule update --init debian/debootstrap 31 | - run: make -j13 build/debian.cpio.zstd 32 | - run: make -j13 build/debian.cpio.zstd{artifact} 33 | -------------------------------------------------------------------------------- /.github/workflows/qemu.yml: -------------------------------------------------------------------------------- 1 | name: qemu 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ main, update ] 6 | pull_request: 7 | branches: [ main, update ] 8 | jobs: 9 | qemu: 10 | name: qemu 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | with: 15 | submodules: false 16 | - name: Set env variables 17 | uses: ./g/github/env/ 18 | - run: sudo apt-get update 19 | - run: sudo apt-get install autopoint 20 | - run: sudo apt-get install lzop 21 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 22 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 23 | - run: sudo apt-get install gettext 24 | - run: sudo apt-get install xz-utils 25 | - run: sudo apt-get install device-tree-compiler 26 | - run: sudo apt-get install libtool-bin 27 | - run: sudo apt-get install ninja-build meson libglib2.0-dev 28 | - run: make -j13 done/qemu/build 29 | - run: make -j13 build/qemu/build/qemu-system-aarch64{artifact} 30 | -------------------------------------------------------------------------------- /.github/workflows/random.yml: -------------------------------------------------------------------------------- 1 | name: random 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ main, restructure ] 6 | pull_request: 7 | branches: [ main, restructure ] 8 | jobs: 9 | random: 10 | name: random 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | submodules: false 16 | - name: Set env variables 17 | uses: ./g/github/env/ 18 | - run: sudo apt-get update 19 | - run: sudo apt-get install autopoint 20 | - run: sudo apt-get install lzop 21 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 22 | - run: sudo apt-get install libipc-run-perl 23 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 24 | - run: sudo apt-get install gettext 25 | - run: sudo apt-get install xz-utils 26 | - run: sudo apt-get install device-tree-compiler 27 | - run: sudo apt-get install libtool-bin 28 | - run: make -j13 random-target 29 | - run: make -j13 random-target 30 | - run: make -j13 random-target 31 | - run: make -j13 random-target 32 | - run: make -j13 random-target 33 | - run: make -j13 random-target 34 | - run: make -j13 random-target 35 | - run: make -j13 random-target 36 | - run: make -j13 random-target 37 | - run: make -j13 random-target 38 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: [ release ] 4 | jobs: 5 | release: 6 | name: release 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | with: 11 | submodules: false 12 | - name: Set env variables 13 | uses: ./g/github/env/ 14 | - run: sudo apt-get update 15 | - run: sudo apt-get install autopoint 16 | - run: sudo apt-get install lzop 17 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 18 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 19 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 20 | - run: sudo apt-get install qemu-system 21 | - run: sudo apt-get install gettext 22 | - run: sudo apt-get install xz-utils 23 | - run: sudo apt-get install device-tree-compiler 24 | - run: sudo apt-get install libtool-bin 25 | - run: make -j13 done/toolchain/binutils-gdb/install 26 | - run: make -j13 done/linux/headers/install 27 | - run: make -j13 done/userspace/glibc/headers/install 28 | - run: make -j13 done/toolchain/gcc/gcc/install 29 | - run: rm -rf build/toolchain/gcc/gcc 30 | - run: make -j13 done/userspace/glibc/glibc/install 31 | - run: make -j13 done/toolchain/gcc/libgcc/install 32 | - run: rm -rf build/toolchain/gcc/libgcc 33 | - run: rm -rf toolchain/gcc/gcc 34 | - run: rm -rf toolchain/binutils-gdb/binutils-gdb 35 | - run: make -j13 done/userspace/ncurses/install 36 | - run: make -j13 done/userspace/dialog/install 37 | - run: make -j13 done/userspace/screen/install 38 | - run: make -j13 done/userspace/procps/install 39 | - run: make -j13 done/userspace/busybox/install 40 | - run: make -j13 done/userspace/kexec-tools/install 41 | - run: make -j13 done/userspace/emacs/cross/install 42 | - run: make -j13 done/userspace/perl/install 43 | - run: make -j13 done/userspace/IPC-Run/install 44 | - run: make -j13 done/userspace/slurp/install 45 | - run: make -j13 done/userspace/libnl/install 46 | - run: make -j13 done/userspace/memtool/install 47 | - run: make -j13 done/userspace/libuuid/install 48 | - run: make -j13 done/userspace/json-c/install 49 | - run: make -j13 done/userspace/popt/install 50 | - run: make -j13 done/userspace/libblkid/install 51 | - run: make -j13 done/userspace/libaio/install 52 | - run: make -j13 done/userspace/lvm2/install 53 | - run: make -j13 done/userspace/openssl/install 54 | - run: make -j13 done/userspace/cryptsetup/install 55 | - run: make -j13 done/userspace/dtc/install 56 | - run: make -j13 done/userspace/wpa_supplicant/install 57 | - run: make -j13 done/bootloaders/m1n1/install 58 | - run: make -j13 done/bootloaders/barebox/install 59 | - run: make -j13 done/bootloaders/u-boot/install 60 | - run: make -j13 done/bootloaders/grub/install 61 | - run: make -j13 done/userspace/install 62 | - run: rm -rf build/userspace 63 | - run: rm -rf userspace/emacs/emacs 64 | - run: rm -rf userspace/glibc/glibc 65 | - run: rm -rf userspace/openssl/openssl 66 | - run: make -j13 build/linux/pearl.image.macho 67 | - run: rm -rf build/linux/linux 68 | - run: rm -rf build/linux/pearl 69 | - run: rm -rf build/linux/stage2 70 | - run: make -j3 debian/debootstrap/debootstrap{checkout} 71 | - run: make -j3 zstd/zstd{checkout} 72 | - run: make -j3 build/pearl.pl 73 | - run: make -j3 build/pearl.pl{release} 74 | - run: make -j3 {release} 75 | env: 76 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 77 | -------------------------------------------------------------------------------- /.github/workflows/video-barebox.yml: -------------------------------------------------------------------------------- 1 | name: video-barebox 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ dcp, update, video ] 6 | pull_request: 7 | branches: [ dcp, update, video ] 8 | jobs: 9 | video-barebox: 10 | name: video-barebox 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | with: 15 | submodules: false 16 | - run: make -j13 build/released/pipcet/pearl-bootloaders/bootloaders.tar.zstd 17 | - run: zstd -d < build/released/pipcet/pearl-bootloaders/bootloaders.tar.zstd | tar -xv 18 | - run: make qemu/qemu{checkout} 19 | - run: make toolchain/binutils-gdb/binutils-gdb{checkout} 20 | - name: Set env variables 21 | uses: ./g/github/env/ 22 | - run: sudo apt-get update 23 | - run: sudo apt-get install autopoint 24 | - run: sudo apt-get install lzop 25 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 26 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 27 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 28 | - run: sudo apt-get install qemu-system-arm 29 | - run: sudo apt-get install sharutils 30 | - run: sudo apt-get install gettext 31 | - run: sudo apt-get install xz-utils 32 | - run: sudo apt-get install device-tree-compiler 33 | - run: sudo apt-get install libtool-bin 34 | - run: sudo apt-get install ffmpeg 35 | - run: sudo apt-get install vncsnapshot 36 | - run: sudo apt-get install socat 37 | - run: sudo apt-get install netpbm 38 | - run: sudo apt-get install ninja-build 39 | - run: sudo apt-get install meson 40 | - run: echo 1 | sudo tee /proc/sys/vm/overcommit_memory 41 | - run: make -j13 done/toolchain/binutils-gdb/install 42 | - run: make -j13 done/qemu/build 43 | - run: mkdir -p done/bootloaders/barebox 44 | - run: touch done/bootloaders/barebox/checkout 45 | - run: touch done/bootloaders/barebox/copy 46 | - run: touch done/bootloaders/barebox/build 47 | - run: touch done/bootloaders/barebox/install 48 | - run: touch build/initramfs/pearl/boot/barebox.image 49 | - run: mkdir -p build/bootloaders 50 | - run: cp build/initramfs/pearl/boot/barebox.image build/bootloaders/barebox.image 51 | - run: cp build/initramfs/pearl/boot/barebox.dtb build/bootloaders/barebox.dtb 52 | - run: make -j13 build/video/barebox.mp4{artifact} 53 | -------------------------------------------------------------------------------- /.github/workflows/video-uboot.yml: -------------------------------------------------------------------------------- 1 | name: u-boot video 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: [ dcp, update, video ] 6 | pull_request: 7 | branches: [ dcp, update, video ] 8 | jobs: 9 | video-u-boot: 10 | name: u-boot video 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | with: 15 | submodules: false 16 | - run: make -j13 build/released/pipcet/pearl-bootloaders/bootloaders.tar.zstd 17 | - run: zstd -d < build/released/pipcet/pearl-bootloaders/bootloaders.tar.zstd | tar -xv 18 | - run: make qemu/qemu{checkout} 19 | - run: make toolchain/binutils-gdb/binutils-gdb{checkout} 20 | - name: Set env variables 21 | uses: ./g/github/env/ 22 | - run: sudo apt-get update 23 | - run: sudo apt-get install autopoint 24 | - run: sudo apt-get install lzop 25 | - run: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev 26 | - run: sudo apt-get install libipc-run-perl libfile-slurp-perl 27 | - run: sudo apt-get install qemu-user qemu-user-static binfmt-support 28 | - run: sudo apt-get install qemu-system-arm 29 | - run: sudo apt-get install sharutils 30 | - run: sudo apt-get install gettext 31 | - run: sudo apt-get install xz-utils 32 | - run: sudo apt-get install device-tree-compiler 33 | - run: sudo apt-get install libtool-bin 34 | - run: sudo apt-get install ffmpeg 35 | - run: sudo apt-get install vncsnapshot 36 | - run: sudo apt-get install socat 37 | - run: sudo apt-get install netpbm 38 | - run: sudo apt-get install ninja-build 39 | - run: sudo apt-get install meson 40 | - run: echo 1 | sudo tee /proc/sys/vm/overcommit_memory 41 | - run: make -j13 done/toolchain/binutils-gdb/install 42 | - run: make -j13 done/qemu/build 43 | - run: mkdir -p done/bootloaders/u-boot 44 | - run: touch done/bootloaders/u-boot/checkout 45 | - run: touch done/bootloaders/u-boot/copy 46 | - run: touch done/bootloaders/u-boot/build 47 | - run: touch done/bootloaders/u-boot/install 48 | - run: touch build/initramfs/pearl/boot/u-boot.image 49 | - run: mkdir -p done/bootloaders/barebox 50 | - run: touch done/bootloaders/barebox/checkout 51 | - run: touch done/bootloaders/barebox/copy 52 | - run: touch done/bootloaders/barebox/build 53 | - run: touch done/bootloaders/barebox/install 54 | - run: touch build/initramfs/pearl/boot/barebox.image 55 | - run: mkdir -p build/bootloaders 56 | - run: cp build/initramfs/pearl/boot/u-boot.image build/bootloaders/u-boot.image 57 | - run: cp build/initramfs/pearl/boot/barebox.dtb build/bootloaders/barebox.dtb 58 | - run: make -j13 build/video/u-boot.mp4{artifact} 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .vscode/ 3 | /build/ 4 | /done/ 5 | /stamp/ 6 | /blobs/macos.tar 7 | /blobs/brcm.tar 8 | /blobs/wifi.tar 9 | /blobs/etc.tar 10 | /blobs/usr-local.tar 11 | -------------------------------------------------------------------------------- /blobs/README.org: -------------------------------------------------------------------------------- 1 | * Blobs 2 | 3 | Unfortunately, the M1 hardware requires firmware which is not freely 4 | redistributable; in particular, this affects the WiFi module. 5 | 6 | To make things slightly easier, tar files placed in the blobs/ 7 | directory will show up in the initrd. 8 | -------------------------------------------------------------------------------- /blobs/blobs.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/blobs.tar: $(wildcard blobs/*.tar) 2 | $(MKDIR) $(dir $@) 3 | (cd blobs; tar c $(^:blobs/%=%)) > $@ || touch $@ 4 | 5 | $(call pearl-static,$(BUILD)/blobs.tar,$(BUILD)) 6 | -------------------------------------------------------------------------------- /bootloaders/README.org: -------------------------------------------------------------------------------- 1 | ** bootloaders: traditional stay-and-play bootloaders bootable from pearl 2 | -------------------------------------------------------------------------------- /bootloaders/barebox/barebox.mk: -------------------------------------------------------------------------------- 1 | bootloaders/barebox/barebox{menuconfig}: bootloaders/barebox/barebox.config | $(BUILD)/bootloaders/barebox/ 2 | $(CP) $< bootloaders/barebox/barebox/.config 3 | $(MAKE) -C bootloaders/barebox/barebox ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILE) menuconfig 4 | $(CP) bootloaders/barebox/barebox/.config $< 5 | 6 | bootloaders/barebox/barebox{oldconfig}: bootloaders/barebox/barebox.config stamp/barebox | $(BUILD)barebox/ 7 | $(CP) $< $(BUILD)/bootloaders/barebox/.config 8 | $(MAKE) -C submodule/barebox oldconfig ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILE) 9 | $(CP) $(BUILD)/bootloaders/barebox/.config $< 10 | 11 | $(BUILD)/bootloaders/barebox.modules: 12 | touch $@ 13 | 14 | $(BUILD)/bootloaders/barebox.image: $(call done,bootloaders/barebox,build) 15 | $(CP) $(BUILD)/bootloaders/barebox/build/images/barebox-dt-2nd.img $@ 16 | 17 | $(BUILD)/bootloaders/barebox.dtb: $(call done,bootloaders/barebox,build) 18 | $(CP) $(BUILD)/bootloaders/barebox/build/arch/arm/dts/apple-m1-j274.dtb $@ 19 | 20 | $(BUILD)/bootloaders/barebox.image.sendfile: $(BUILD)/bootloaders/barebox.dtb 21 | 22 | $(BUILD)/bootloaders/barebox.image.d/sendfile: $(call done,bootloaders/barebox,build) | $(BUILD)/bootloaders/barebox.image.d/ 23 | echo "#!/bin/sh" > $@ 24 | echo "enable-framebuffer &" >> $@ 25 | echo "echo > /sys/kernel/debug/dcp/trigger &" >> $@ 26 | echo "sleep 12" >> $@ 27 | echo "dt dtb-to-dtp barebox.dtb barebox.dtp" >> $@ 28 | echo "cat persist/bootargs.dtp >> barebox.dtp" >> $@ 29 | echo "dt dtp-to-dtb barebox.dtp barebox.dtb" >> $@ 30 | echo "cat barebox.dtp" >> $@ 31 | echo "(cd /sys/bus/platform/drivers/dwc3; for a in *0*; do echo \$$a > unbind; done)" >> $@ 32 | echo "sleep 2" >> $@ 33 | echo "kexec -fix barebox.image --dtb=barebox.dtb" >> $@ 34 | chmod u+x $@ 35 | 36 | $(call done,bootloaders/barebox,install): $(call done,bootloaders/barebox,build) 37 | $(TIMESTAMP) 38 | 39 | $(call done,bootloaders/barebox,build): $(call done,bootloaders/barebox,configure) 40 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/bootloaders/barebox/build ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILE) 41 | $(TIMESTAMP) 42 | 43 | $(call done,bootloaders/barebox,configure): bootloaders/barebox/barebox.config $(call done,bootloaders/barebox,copy) $(call done,toolchain/gcc,gcc/install) 44 | $(CP) $< $(BUILD)/bootloaders/barebox/build/.config 45 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/bootloaders/barebox/build ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILE) olddefconfig 46 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/bootloaders/barebox/build ARCH=arm64 CROSS_COMPILE=$(CROSS_COMPILE) oldconfig 47 | $(TIMESTAMP) 48 | 49 | $(call done,bootloaders/barebox,copy): $(call done,bootloaders/barebox,checkout) | $(call done,bootloaders/barebox,) $(BUILD)/bootloaders/barebox/build/ 50 | $(COPY_SAUNA) $(PWD)/bootloaders/barebox/barebox/* $(BUILD)/bootloaders/barebox/build/ 51 | $(TIMESTAMP) 52 | 53 | $(call done,bootloaders/barebox,checkout): | $(call done,bootloaders/barebox,) 54 | $(MAKE) bootloaders/barebox/barebox{checkout} 55 | $(TIMESTAMP) 56 | 57 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/barebox.image 58 | $(BUILD)/initramfs/pearl/boot/barebox.image: $(BUILD)/bootloaders/barebox.image ; $(COPY) 59 | $(BUILD)/initramfs/pearl/boot/barebox.dtb: $(BUILD)/bootloaders/barebox.dtb ; $(COPY) 60 | 61 | $(call pearl-static,$(wildcard bootloaders/barebox/pearl/bin/*),bootloaders/barebox/pearl) 62 | 63 | BOOTLOADER_FILES += $(BUILD)/initramfs/pearl/boot/barebox.image 64 | BOOTLOADER_FILES += $(BUILD)/initramfs/pearl/boot/barebox.dtb 65 | 66 | SECTARGETS += $(call done,bootloaders/barebox,build) 67 | SECTARGETS += $(BUILD)/bootloaders/barebox.image 68 | SECTARGETS += $(BUILD)/bootloaders/barebox.image.sendfile 69 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/barebox.image 70 | -------------------------------------------------------------------------------- /bootloaders/barebox/pearl/bin/barebox: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # enable-wdt 3 | kexec -fix /boot/barebox.image --dtb=/boot/barebox.dtb 4 | -------------------------------------------------------------------------------- /bootloaders/barebox/t8103-j274.dts: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0+ OR MIT 2 | /* 3 | * Apple Mac mini (M1, 2020) 4 | * 5 | * target-type: J274 6 | * 7 | * Copyright The Asahi Linux Contributors 8 | */ 9 | 10 | /dts-v1/; 11 | 12 | #include "t8103.dtsi" 13 | 14 | / { 15 | compatible = "apple,j274", "apple,t8103", "apple,arm-platform"; 16 | model = "Apple Mac mini (M1, 2020)"; 17 | 18 | aliases { 19 | serial0 = &serial0; 20 | }; 21 | 22 | chosen { 23 | #address-cells = <2>; 24 | #size-cells = <2>; 25 | ranges; 26 | 27 | stdout-path = "serial0"; 28 | 29 | 30 | }; 31 | 32 | memory@800000000 { 33 | device_type = "memory"; 34 | reg = <0x8 0 0x2 0>; /* To be filled by loader */ 35 | }; 36 | }; 37 | 38 | &serial0 { 39 | status = "okay"; 40 | }; 41 | -------------------------------------------------------------------------------- /bootloaders/bootloaders.mk: -------------------------------------------------------------------------------- 1 | include bootloaders/m1n1/m1n1.mk 2 | include bootloaders/barebox/barebox.mk 3 | include bootloaders/u-boot/u-boot.mk 4 | include bootloaders/grub/grub.mk 5 | 6 | $(BUILD)/bootloaders.tar: $(call done,bootloaders/m1n1,install) $(call done,bootloaders/barebox,install) $(call done,bootloaders/u-boot,install) $(call done,bootloaders/grub,install) $(BOOTLOADER_FILES) 7 | tar -C . -cf $@ $(patsubst $(PWD)/%,%,$(BUILD)/pearl/toolchain $(BOOTLOADER_FILES)) 8 | 9 | SECTARGETS += $(BUILD)/bootloaders.tar 10 | -------------------------------------------------------------------------------- /bootloaders/grub/grub.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/bootloaders/grub.efi: $(call done,bootloaders/grub,install) 2 | $(BUILD)/toolchain/bin/grub-mkimage -Oarm64-efi -p / acpi adler32 affs afs afsplitter all_video archelp bfs bitmap bitmap_scale blocklist boot bswap_test btrfs bufio cat cbfs chain cmdline_cat_test cmp cmp_test configfile cpio_be cpio crc64 cryptodisk crypto ctz_test datehook date datetime diskfilter disk div div_test dm_nv echo efifwsetup efi_gop efinet elf eval exfat exfctest ext2 extcmd f2fs fat fdt file font fshelp functional_test gcry_arcfour gcry_blowfish gcry_camellia gcry_cast5 gcry_crc gcry_des gcry_dsa gcry_idea gcry_md4 gcry_md5 gcry_rfc2268 gcry_rijndael gcry_rmd160 gcry_rsa gcry_seed gcry_serpent gcry_sha1 gcry_sha256 gcry_sha512 gcry_tiger gcry_twofish gcry_whirlpool geli gettext gfxmenu gfxterm_background gfxterm_menu gfxterm gptsync gzio halt hashsum hello help hexdump hfs hfspluscomp hfsplus http iso9660 jfs jpeg json keystatus ldm linux loadenv loopback lsacpi lsefimmap lsefi lsefisystab lsmmap ls lssal luks2 luks lvm lzopio macbless macho mdraid09_be mdraid09 mdraid1x memdisk memrw minicmd minix2_be minix2 minix3_be minix3 minix_be minix mmap mpi msdospart mul_test net newc nilfs2 normal ntfscomp ntfs odc offsetio part_acorn part_amiga part_apple part_bsd part_dfly part_dvh part_gpt part_msdos part_plan part_sun part_sunpc parttool password password_pbkdf2 pbkdf2 pbkdf2_test pgp png priority_queue probe procfs progress raid5rec raid6rec read reboot regexp reiserfs romfs scsi search_fs_file search_fs_uuid search_label search serial setjmp setjmp_test sfs shift_test signature_test sleep sleep_test smbios squash4 strtoull_test syslinuxcfg tar terminal terminfo test_blockarg testload test testspeed tftp tga time tpm trig tr true udf ufs1_be ufs1 ufs2 video_colors video_fb videoinfo video videotest_checksum videotest xfs xnu_uuid xnu_uuid_test xzio zfscrypt zfsinfo zfs zstd > $@ 3 | 4 | $(call done,bootloaders/grub,install): $(call done,bootloaders/grub,build) 5 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/bootloaders/grub/build install 6 | $(TIMESTAMP) 7 | 8 | $(call done,bootloaders/grub,build): $(call done,bootloaders/grub,configure) 9 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/bootloaders/grub/build 10 | $(TIMESTAMP) 11 | 12 | $(call done,bootloaders/grub,configure): $(call done,bootloaders/grub,copy) $(call done,toolchain/gcc,gcc/install) | $(BUILD)/bootloaders/grub/build/ 13 | (cd $(BUILD)/bootloaders/grub/build; sh bootstrap) 14 | (cd $(BUILD)/bootloaders/grub/build; $(WITH_CROSS_PATH) ./configure --host=$(NATIVE_TRIPLE) --build=$(NATIVE_TRIPLE) --target=aarch64-linux-gnu --with-platform=efi --prefix=$(BUILD)/toolchain --disable-werror) 15 | $(TIMESTAMP) 16 | 17 | $(call done,bootloaders/grub,copy): $(call done,bootloaders/grub,checkout) | $(BUILD)/bootloaders/grub/build/ 18 | $(CP) -aus $(PWD)/bootloaders/grub/grub/* $(BUILD)/bootloaders/grub/build/ 19 | $(TIMESTAMP) 20 | 21 | $(call done,bootloaders/grub,checkout): | $(call done,bootloaders/grub,) 22 | $(MAKE) bootloaders/grub/grub{checkout} 23 | $(TIMESTAMP) 24 | 25 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/grub.efi 26 | $(BUILD)/initramfs/pearl/boot/grub.efi: $(BUILD)/bootloaders/grub.efi ; $(COPY) 27 | 28 | BOOTLOADER_FILES += $(BUILD)/initramfs/pearl/boot/grub.efi 29 | -------------------------------------------------------------------------------- /bootloaders/m1n1/m1n1.mk: -------------------------------------------------------------------------------- 1 | M1N1DEVICE ?= $(shell ls /dev/ttyACM* | tail -2 | head -1) 2 | 3 | $(BUILD)/bootloaders/m1n1.macho: $(call done,bootloaders/m1n1,build) 4 | $(CP) $(BUILD)/bootloaders/m1n1/build/build/m1n1.macho $@ 5 | 6 | $(call done,bootloaders/m1n1,install): $(call done,bootloaders/m1n1,build) 7 | $(TIMESTAMP) 8 | 9 | $(call done,bootloaders/m1n1,build): $(call done,bootloaders/m1n1,copy) $(call done,toolchain/gcc,gcc/install) 10 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/bootloaders/m1n1/build build/m1n1.macho 11 | $(TIMESTAMP) 12 | 13 | $(call done,bootloaders/m1n1,copy): $(call done,bootloaders/m1n1,checkout) | $(BUILD)/bootloaders/m1n1/build/ 14 | $(CP) -aus $(PWD)/bootloaders/m1n1/m1n1/* $(BUILD)/bootloaders/m1n1/build/ 15 | $(TIMESTAMP) 16 | 17 | $(call done,bootloaders/m1n1,checkout): | $(call done,bootloaders/m1n1,) 18 | $(MAKE) bootloaders/m1n1/m1n1{checkout} 19 | $(TIMESTAMP) 20 | 21 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/m1n1.macho 22 | $(BUILD)/initramfs/pearl/boot/m1n1.macho: $(BUILD)/bootloaders/m1n1.macho ; $(COPY) 23 | 24 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/m1n1.macho 25 | SECTARGETS += $(BUILD)/bootloaders/m1n1.macho 26 | SECTARGETS += $(call done,bootloaders/m1n1,build) 27 | 28 | $(call pearl-static,bootloaders/m1n1/pearl/bin/m1n1,bootloaders/m1n1/pearl) 29 | 30 | %.macho{m1n1}: %.macho 31 | M1N1DEVICE=$(M1N1DEVICE) python3 ./bootloaders/m1n1/m1n1/proxyclient/tools/chainload.py $< 32 | 33 | {m1n1}: 34 | (cd bootloaders/m1n1/m1n1/proxyclient; M1N1DEVICE=$(M1N1DEVICE) python3 -m m1n1.shell) 35 | 36 | $(BUILD)/m1n1-chickens.S: $(call done,bootloaders/m1n1,install) 37 | cat bootloaders/m1n1/m1n1/src/chickens_blizzard.c bootloaders/m1n1/m1n1/src/chickens_avalanche.c bootloaders/m1n1/m1n1/src/chickens_firestorm.c bootloaders/m1n1/m1n1/src/chickens_icestorm.c bootloaders/m1n1/m1n1/src/chickens.c | $(CROSS_COMPILE)gcc -I$(BUILD)/bootloaders/m1n1/build/src -x c -finline -finline-functions -finline-limit=1000000000 -O3 -S -o $@ - 38 | 39 | BOOTLOADER_FILES += $(BUILD)/initramfs/pearl/boot/m1n1.macho 40 | -------------------------------------------------------------------------------- /bootloaders/m1n1/pearl/bin/m1n1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | macho-to-memdump /boot/m1n1.macho 3 | kexec -fix --dtb=/sys/firmware/fdt image 4 | -------------------------------------------------------------------------------- /bootloaders/u-boot/pearl/bin/u-boot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | gunzip < /boot/u-boot.image.gz > /boot/u-boot.image 3 | x2r10g10b10 4 | kexec -fix /boot/u-boot.image --dtb=/boot/u-boot.dtb 5 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit 3 | git submodule update --init --recursive 4 | while ! ./g/bin/install-remotes < g/remotes.txt; do sleep 1; done 5 | git submodule foreach --recursive git fetch --all 6 | make -j13 build/binutils-gdb/done/install 7 | make -j13 build/linux/done/headers/install 8 | make -j13 build/glibc/done/headers/install 9 | make -j13 build/gcc/done/gcc/install 10 | make -j13 build/glibc/done/glibc/install 11 | make -j13 build/busybox/done/install 12 | make -j13 build/kexec-tools/done/install 13 | make -j13 build/ncurses/done/install 14 | make -j13 build/emacs/done/cross/install 15 | make -j13 build/perl/done/install 16 | make -j13 build/IPC-Run/done/install 17 | make -j13 build/slurp/done/install 18 | make -j13 build/libnl/done/install 19 | make -j13 build/memtool/done/install 20 | make -j13 build/libuuid/done/install 21 | make -j13 build/json-c/done/install 22 | make -j13 build/popt/done/install 23 | make -j13 build/libblkid/done/install 24 | make -j13 build/libaio/done/install 25 | make -j13 build/lvm2/done/install 26 | make -j13 build/openssl/done/install 27 | make -j13 build/cryptsetup/done/install 28 | make -j13 build/nvme-cli/done/install 29 | make -j13 build/dtc/done/install 30 | make -j13 build/linux/linux.image 31 | make -j13 build/linux/stage2.image 32 | make -j13 build/linux/pearl.image 33 | -------------------------------------------------------------------------------- /debian/README.org: -------------------------------------------------------------------------------- 1 | ** debian: Debian-specific code 2 | -------------------------------------------------------------------------------- /debian/deb/deb.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/debian/deb/Packages: | $(BUILD)/debian/deb/ 2 | curl http://http.us.debian.org/debian/dists/sid/main/binary-arm64/Packages.xz | xzcat > $@ 3 | curl http://http.us.debian.org/debian/dists/sid/main/binary-all/Packages.xz | xzcat >> $@ 4 | 5 | $(BUILD)/debian/deb/%.deb: $(BUILD)/debian/deb/Packages debian/deb/deb.pl | $(BUILD)/debian/deb/ 6 | curl http://http.us.debian.org/debian/$(shell perl debian/deb/deb.pl "$*" < $<) > $@ 7 | 8 | nvme-debs = \ 9 | nvme-cli \ 10 | libuuid1 11 | 12 | dialog-debs = \ 13 | dialog \ 14 | libncurses6 \ 15 | libncursesw6 16 | 17 | procps-debs = \ 18 | procps \ 19 | libprocps8 \ 20 | libtinfo6 \ 21 | libsystemd0 22 | 23 | screen-debs = \ 24 | screen \ 25 | libtinfo6 \ 26 | libutempter0 \ 27 | libpam0g \ 28 | libaudit1 \ 29 | libcap-ng0 \ 30 | libaudit-common \ 31 | terminfo \ 32 | ncurses-base 33 | 34 | dropbear-debs = \ 35 | dropbear-bin \ 36 | libgmp10 \ 37 | libtomcrypt1 \ 38 | libtommath1 \ 39 | zlib1g 40 | 41 | mojo-debs = \ 42 | libmojolicious-perl \ 43 | libmojo-ioloop-readwriteprocess-perl 44 | 45 | wifi-debs = \ 46 | wpasupplicant \ 47 | libdbus-1-3 \ 48 | libnl-3-200 \ 49 | libnl-genl-3-200 \ 50 | libnl-route-3-200 \ 51 | libpcsclite1 \ 52 | libssl1.1 \ 53 | libsystemd0 \ 54 | dhcpcd5 55 | 56 | libc-debs = \ 57 | libc6 \ 58 | libcrypt1 59 | 60 | perl-debs = \ 61 | perl \ 62 | perl-base \ 63 | perl-modules-5.32 \ 64 | libfile-slurp-perl \ 65 | libipc-run-perl \ 66 | libsys-mmap-perl 67 | 68 | dtc-debs = \ 69 | device-tree-compiler \ 70 | libfdt1 \ 71 | libyaml-0-2 72 | 73 | lvm-debs = \ 74 | lvm2 \ 75 | cryptsetup \ 76 | cryptsetup-bin \ 77 | dmeventd \ 78 | dmsetup \ 79 | libaio1 \ 80 | libargon2-1 \ 81 | libblkid1 \ 82 | libbsd0 \ 83 | libcryptsetup12 \ 84 | libdevmapper-event1.02.1 \ 85 | libdevmapper1.02.1 \ 86 | libedit2 \ 87 | libgcc-s1 \ 88 | libgcrypt20 \ 89 | libgpg-error0 \ 90 | libjson-c5 \ 91 | liblz4-1 \ 92 | liblzma5 \ 93 | libmd0 \ 94 | libpcre2-8-0 \ 95 | libpcre2-16-0 \ 96 | libpcre2-32-0 \ 97 | libpopt0 \ 98 | libselinux1 \ 99 | libssl1.1 \ 100 | libsystemd0 \ 101 | libtinfo6 \ 102 | libudev1 \ 103 | libuuid1 \ 104 | libzstd1 105 | 106 | debs = libc perl dtc lvm mojo wifi dropbear screen 107 | 108 | $(BUILD)/debian/deb.tar: \ 109 | $(libc-debs:%=$(BUILD)/debian/deb/%.deb) \ 110 | $(perl-debs:%=$(BUILD)/debian/deb/%.deb) \ 111 | $(dtc-debs:%=$(BUILD)/debian/deb/%.deb) \ 112 | $(lvm-debs:%=$(BUILD)/debian/deb/%.deb) \ 113 | $(mojo-debs:%=$(BUILD)/debian/deb/%.deb) \ 114 | $(wifi-debs:%=$(BUILD)/debian/deb/%.deb) \ 115 | $(dropbear-debs:%=$(BUILD)/debian/deb/%.deb) \ 116 | $(screen-debs:%=$(BUILD)/debian/deb/%.deb) \ 117 | $(dialog-debs:%=$(BUILD)/debian/deb/%.deb) \ 118 | $(nvme-debs:%=$(BUILD)/debian/deb/%.deb) \ 119 | $(procps-debs:%=$(BUILD)/debian/deb/%.deb) 120 | rm -rf $(BUILD)/deb-tmp $(BUILD)/deb-tmp-ar 121 | $(MKDIR) $(BUILD)/deb-tmp $(BUILD)/deb-tmp-ar 122 | for file in $^; do if which dpkg > /dev/null 2>&1; then dpkg -x $$file $(BUILD)/deb-tmp; else ar -x $$file --output $(BUILD)/deb-tmp-ar && tar -C $(BUILD)/deb-tmp -axf $(BUILD)/deb-tmp-ar/data.tar.*; rm -rf $(BUILD)/deb-tmp-ar; fi; done 123 | (tar -C $(BUILD)/deb-tmp -cf $@ .) 124 | 125 | $(BUILD)/qemu-kernel: $(BUILD)/debian/deb/linux-image-5.18.0-3-cloud-arm64-unsigned.deb 126 | $(MKDIR) $(BUILD)/kernel 127 | dpkg --extract $< $(BUILD)/kernel 128 | cp $(BUILD)/kernel/boot/vmlinuz* $@ 129 | 130 | # $(call pearl-static,$(BUILD)/debian/deb.tar,$(BUILD)) 131 | -------------------------------------------------------------------------------- /debian/deb/deb.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my $print = 0; 3 | while () { 4 | chomp; 5 | if ($print && $_ =~ /^Filename: (.*)$/) { 6 | print "$1\n"; 7 | $print = 0; 8 | exit(1); 9 | } 10 | if ($_ eq "Package: $ARGV[0]") { 11 | $print = 1; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /debian/debian.mk: -------------------------------------------------------------------------------- 1 | include debian/deb/deb.mk 2 | include debian/debootstrap/debootstrap.mk 3 | 4 | $(call pearl-static,$(wildcard $(PWD)/debian/pearl/bin/*),$(PWD)/debian/pearl) 5 | -------------------------------------------------------------------------------- /debian/injected/bin/installer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir /installer 3 | mount -t ramfs installer /installer 4 | mkdir /installer/persist 5 | mount --bind /persist /installer/persist 6 | cp /persist/preseed.cfg /installer/preseed.cfg 7 | cat <>/installer/preseed.cfg 8 | #_preseed_V1 9 | d-i anna/no_kernel_modules boolean true 10 | d-i anna/standard_modules boolean false 11 | d-i partman-auto/init_automatically_partition select custom 12 | EOF 13 | cat /installer.cpio | (cd /installer; cpio -id) 14 | (cat < /installer/new-init 15 | #!/bin/sh -x 16 | EOF 17 | mv /installer/new-init /installer/init 18 | chmod u+x /installer/init 19 | mkdir -p /installer/var/log 20 | touch /installer/var/log/syslog 21 | systemctl switch-root /installer /init 22 | -------------------------------------------------------------------------------- /debian/pearl/bin/auto-boot-debian: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | counter=60 3 | [ -e /persist/timeout ] && counter="$(cat /persist/timeout)" 4 | while [ $counter -gt 0 ]; do 5 | sleep 1 || break 6 | test -e /interactive && break 7 | counter=$(($counter - 1)) 8 | echo "will boot installed system or Debian in $counter seconds" > /var/help/010-auto-action 9 | done 10 | if [ $counter -gt 0 ]; then 11 | rm -f /var/help/010-auto-action 12 | exit 1 13 | fi 14 | echo "booting" > /var/help/010-auto-action 15 | final 16 | -------------------------------------------------------------------------------- /debian/pearl/bin/debian: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "booting Debian" > /var/help/011-boot-action 3 | final debian 4 | -------------------------------------------------------------------------------- /debian/pearl/bin/installer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "booting Debian installer" > /var/help/011-boot-action 3 | final installer 4 | -------------------------------------------------------------------------------- /g/Makefile: -------------------------------------------------------------------------------- 1 | # This is in the g/ subdir of the m1 repository, but it's meant to be 2 | # run in the repository itself, as make -f g/Makefile daily! 3 | 4 | all!: daily! 5 | 6 | daily!: fetch-canon! fetch-all! fetch-canon! 7 | 8 | fetch-canon!: 9 | g/bin/fetch-canon 10 | 11 | fetch-upstream!: 12 | g/bin/fetch-upstream 13 | 14 | install-hooks!: 15 | g/bin/install-hooks 16 | 17 | pipcet!: 18 | g/bin/pipcet 19 | 20 | pull!: 21 | g/bin/pull 22 | 23 | remotes!: 24 | g/bin/remotes 25 | 26 | find-canonical!: 27 | g/bin/find-canonical 28 | 29 | list-remotes!: 30 | git remote -v show 31 | git submodule foreach --recursive git remote -v show 32 | 33 | g/remotes.mk: g/remotes.txt g/bin/remotes-mk 34 | g/bin/remotes-mk > $@ 35 | 36 | include g/remotes.mk 37 | -------------------------------------------------------------------------------- /g/README.md: -------------------------------------------------------------------------------- 1 | $ git clone https://github.com/pipcet/g 2 | $ cd g 3 | $ git submodule update --init --recursive 4 | $ ./g/bin/pipcet 5 | $ ./g/bin/install-hooks 6 | $ ./g/bin/remotes 7 | $ while ! ./g/bin/gather-remotes | ./g/bin/fix-remotes | ./g/bin/install-remotes; do sleep 1; done 8 | $ ./g/bin/canonical 9 | $ ./g/bin/add-self-remotes 10 | -------------------------------------------------------------------------------- /g/bin/add-remotes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my %lines; 3 | while (<>) { 4 | chomp; 5 | $lines{$_} = $_; 6 | } 7 | line: 8 | for my $line (keys %lines) { 9 | my ($name, $dir, $url, $fetch_or_push) = split / /, $line; 10 | print "$line\n"; 11 | print "self $dir . (fetch)\n"; 12 | print "self $dir . (push)\n"; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /g/bin/add-self-remotes: -------------------------------------------------------------------------------- 1 | git submodule foreach --recursive 'git remote add self . || true' -------------------------------------------------------------------------------- /g/bin/branches: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my @remotes = `git submodule foreach --recursive 'echo \$toplevel/\$sm_path'`; 3 | map { chomp } @remotes; 4 | my %branches = (); 5 | for my $line (`cat g/branches.txt`) { 6 | chomp $line; 7 | my ($dir, $name, $remote) = split / /, $line; 8 | $branches{$dir} = { name => $name, remote => $remote }; 9 | } 10 | for my $remote (@remotes) { 11 | for my $i (0 .. length ($remote) - 1) { 12 | my $prefix = substr($remote, $i); 13 | if (exists $branches{$prefix}) { 14 | system("(cd $prefix; git checkout $branches{$prefix}{remote}; git checkout -b $branches{$prefix}{name})"); 15 | last; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /g/bin/canonical: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | cat g/canonical.txt | while read clone canon branch; do 3 | pwd=$(pwd) 4 | echo $clone 5 | (cd $clone && git remote add canon $pwd/$canon) 6 | (cd $clone && git remote remove origin) 7 | (cd $clone && git remote remove pipcet) 8 | (cd $clone && git remote remove upstream) 9 | (cd $clone && git fetch --all) 10 | (cd $clone && git checkout -b $branch) 11 | (cd $clone && git push --set-upstream canon $branch) 12 | done 13 | -------------------------------------------------------------------------------- /g/bin/fetch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git fetch --all 3 | ./g/bin/fetch-upstream 4 | git submodule foreach --recursive git fetch --all 5 | -------------------------------------------------------------------------------- /g/bin/fetch-canon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat g/canonical.txt | while read dir canon branch; do 3 | (cd $dir && git fetch --all) 4 | done 5 | git submodule foreach --recursive 'git push self remotes/upstream/master:upstream || true' 6 | -------------------------------------------------------------------------------- /g/bin/fetch-upstream: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | cat g/remotes.txt | while read remote canon url; do 3 | (cd $canon && git fetch $remote master:$remote) 4 | done 5 | -------------------------------------------------------------------------------- /g/bin/find-canonical: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | open $fh, "git submodule foreach --quiet --recursive pwd|"; 3 | while (<$fh>) { 4 | chomp; 5 | my $path = $_; 6 | my @remotes = `cd ${path}; git remote -v show`; 7 | for my $remote (@remotes) { 8 | chomp $remote; 9 | my ($name, $url) = ($remote =~ /^(.+?)[ \t]+(.+?)[ \t]+(.+)$/); 10 | $urls{$url}{$path} = 1; 11 | $urls{$path}{$path} = 1; 12 | } 13 | } 14 | 15 | my $ids = 1; 16 | 17 | for my $url (keys %urls) { 18 | for my $path1 (keys %{$urls{$url}}) { 19 | $ids{$path1} = $ids++; 20 | } 21 | } 22 | 23 | for my $url (keys %urls) { 24 | for my $path1 (keys %{$urls{$url}}) { 25 | for my $path2 (keys %{$urls{$url}}) { 26 | my $a = ($ids{$path1} < $ids{$path2}) ? $ids{$path1} : $ids{$path2}; 27 | my $b = ($ids{$path1} < $ids{$path2}) ? $ids{$path2} : $ids{$path1}; 28 | if ($a != $b) { 29 | $tab{$b} = $a; 30 | } 31 | } 32 | } 33 | } 34 | 35 | for my $path (keys %ids) { 36 | while (exists $tab{$ids{$path}}) { 37 | $ids{$path} = $tab{$ids{$path}}; 38 | } 39 | } 40 | 41 | my %revids; 42 | for my $path (keys %ids) { 43 | $revids{$ids{$path}}{$path} = 1; 44 | } 45 | 46 | for my $id (keys %revids) { 47 | if (scalar keys %{$revids{$id}} > 1) { 48 | my @paths = (sort keys %{$revids{$id}}); 49 | @paths = sort { length $a <=> length $b } @paths; 50 | @paths = map { $_ = substr($_, length(`pwd`)) } @paths; 51 | for my $i (1 .. $#paths) { 52 | my $branch = `cd $paths[$i]; git branch --show-current`; 53 | chomp $branch; 54 | if ($branch eq "") { 55 | $branch = "HEAD"; 56 | } 57 | print "$paths[$i] $paths[0] $branch\n"; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /g/bin/fix-remotes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | while (<>) { 3 | chomp; 4 | my ($name, $dir, $url, $fetch_or_push) = split / /; 5 | if ($fetch_or_push eq "(fetch)") { 6 | $url =~ s/git\@github.com:/https:\/\/github.com\//g; 7 | } 8 | if ($fetch_or_push eq "(push)") { 9 | $url =~ s/https:\/\/github.com\/pipcet/git\@github.com:pipcet/g; 10 | } 11 | next if $name eq "origin"; 12 | print join(" ", ($name, $dir, $url, $fetch_or_push)) . "\n"; 13 | } 14 | -------------------------------------------------------------------------------- /g/bin/gather-remotes: -------------------------------------------------------------------------------- 1 | git submodule --quiet foreach --recursive 'git remote -v show | while read NAME REPLY; do echo "$NAME" $displaypath "$REPLY"; done' | sed -e 's/\t/ /g' | sort -------------------------------------------------------------------------------- /g/bin/incoming: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git submodule foreach --recursive git fetch --all 3 | cat g/upstream-branches.txt | while read SUBDIR BRANCH; do 4 | echo $SUBDIR 5 | (cd $SUBDIR; git diff $(git merge-base $BRANCH HEAD)..$BRANCH | head -1000); 6 | done 7 | -------------------------------------------------------------------------------- /g/bin/init-repo: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | # git clone git@github.com:pipcet/g -o pipcet --reference-if-able ... --no-tags 3 | #git submodule update --init --progress --remote --jobs 4 4 | #(cd asmjs; for repo in binaryen binutils-gdb gcc glibc musl ncurses wabt; do git submodule update --init --progress --remote --jobs 4 --reference ../$repo subrepos/$repo; done) 5 | #(cd asmjs; git submodule update --init --progress --remote --jobs 4 --recursive) 6 | #(cd wasm; for repo in bash binaryen binutils-gdb coreutils emacs gcc glibc gnulib libtool ncurses perl python wabt zsh; do git submodule update --init --progress --remote --jobs 4 --reference ../$repo subrepos/$repo; done) 7 | #(cd wasm; git submodule update --init --progress --remote --jobs 4 --recursive) 8 | git submodule update --init --progress --jobs 4 --recursive --reference $(pwd) 9 | ./g/bin/install-hooks 10 | ./g/bin/pipcet 11 | while ! ./g/bin/install-remotes < g/remotes.txt; do true; done 12 | # ./g/bin/canonical 13 | # ./g/bin/storage2 14 | # ./g/bin/storage 15 | # git submodule foreach --recursive 'git remote remove origin || :' 16 | -------------------------------------------------------------------------------- /g/bin/install-hooks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find .git -name hooks | while read; do 3 | ln -rsf g/git/hooks/* "$REPLY"; 4 | done 5 | -------------------------------------------------------------------------------- /g/bin/install-remote: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my ($smpath, $name, $url, $fetch_or_push) = split / /, shift; 3 | 4 | my @current = `git remote -v show`; 5 | for my $current (@current) { 6 | chomp $current; 7 | $current =~ s/\t/ /g; 8 | if ($current eq "$name $url $fetch_or_push") { 9 | exit 0; 10 | } 11 | } 12 | 13 | system("git remote remove $name"); 14 | -------------------------------------------------------------------------------- /g/bin/install-remotes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my %lines; 3 | while (<>) { 4 | chomp; 5 | $lines{$_} = $_; 6 | } 7 | line: 8 | for my $line (keys %lines) { 9 | my ($name, $dir, $url, $fetch_or_push) = split / /, $line; 10 | my @olines = `cd $dir; git remote -v show`; 11 | for my $oline (@olines) { 12 | chomp $oline; 13 | $oline =~ s/\t/ /g; 14 | { 15 | my ($name, $url, $fetch_or_push) = split / /, $oline; 16 | $oline = "$name $dir $url $fetch_or_push"; 17 | } 18 | if ($line eq $oline) { 19 | next line; 20 | } 21 | } 22 | warn("cd $dir; git remote set-url " . ($fetch_or_push eq "(fetch)" ? "" : "--push") . " $name $url"); 23 | system("cd $dir; git remote add $name $url"); 24 | system("cd $dir; git remote set-url " . ($fetch_or_push eq "(fetch)" ? "" : "--push") . " $name $url") and die; 25 | die; 26 | } 27 | for my $line (keys %lines) { 28 | my ($name, $dir, $url, $fetch_or_push) = split / /, $line; 29 | my @olines = `cd $dir; git remote -v show`; 30 | oline: 31 | for my $oline (@olines) { 32 | chomp $oline; 33 | $oline =~ s/\t/ /g; 34 | my ($name, $url, $fetch_or_push) = split / /, $oline; 35 | { 36 | $oline = "$name $dir $url $fetch_or_push"; 37 | } 38 | if (exists $lines{$oline}) { 39 | next oline; 40 | } else { 41 | warn "no $oline"; 42 | warn("cd $dir; git remote remove $name"); 43 | system("cd $dir; git remote remove $name") and die; 44 | die; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /g/bin/locked: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$1" != "--lockfile" ]; then 3 | exit 1 4 | fi 5 | shift 6 | FIFO=$1 7 | shift 8 | while true; do 9 | if [ -e $FIFO ]; then 10 | timeout 3 cat $FIFO 11 | continue 12 | fi 13 | if mkfifo $FIFO; then 14 | break 15 | fi 16 | done 17 | 18 | $@ 19 | RETVAL=$? 20 | 21 | rm $FIFO 22 | 23 | exit $RETVAL 24 | -------------------------------------------------------------------------------- /g/bin/merge-incoming: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git submodule foreach --recursive git fetch --all 3 | cat g/upstream-branches.txt | while read SUBDIR BRANCH; do 4 | echo $SUBDIR 5 | (cd $SUBDIR; git diff $(git merge-base $BRANCH HEAD)..$BRANCH | head -1000); 6 | (cd $SUBDIR; git rebase $BRANCH) 7 | (cd $SUBDIR; git push -f pipcet pearl) 8 | (cd $SUBDIR; git push -f sr.ht pearl) 9 | done 10 | -------------------------------------------------------------------------------- /g/bin/p: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while [ x"$(basename $(pwd))" != xg ] || ! [ -d g ]; do 3 | cd .. 4 | done 5 | DELAY=1 6 | while ! git push; do 7 | sleep $DELAY 8 | DELAY=$(($DELAY * 2)) 9 | done 10 | -------------------------------------------------------------------------------- /g/bin/pipcet: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git config user.name 'Pip Cet' 3 | git config user.email 'pipcet@gmail.com' 4 | git config pull.rebase false 5 | git config receive.denyCurrentBranch ignore 6 | git submodule foreach --recursive git config user.name 'Pip Cet' 7 | git submodule foreach --recursive git config user.email 'pipcet@gmail.com' 8 | git submodule foreach --recursive git config pull.rebase false 9 | git submodule foreach --recursive git config receive.denyCurrentBranch ignore 10 | -------------------------------------------------------------------------------- /g/bin/pre-push-hook: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | system("git remote | egrep '^pipcet\$'") && exit 0; 3 | my $sm_path = $ENV{sm_path}; 4 | my $toplevel = $ENV{toplevel}; 5 | my $fh; 6 | my $branch; 7 | my $remote; 8 | while (<>) { 9 | chomp; 10 | my ($subrepo, $r, $b) = split / /; 11 | if ($subrepo eq $sm_path) { 12 | $branch = $b; 13 | $remote = $r; 14 | last; 15 | } 16 | } 17 | 18 | if ($branch) { 19 | if (`git rev-parse ${remote}/${branch}` eq `git rev-parse ${branch}`) { 20 | exit 0; 21 | } 22 | system("IN_RECURSIVE_PUSH=1 git push ${remote} ${branch}:${branch}"); 23 | if (`git rev-parse ${remote}/${branch}` eq `git rev-parse ${branch}`) { 24 | exit 0; 25 | } 26 | 27 | die "unpushed changes in ${sm_path}, remote ${remote}, branch ${branch}"; 28 | } 29 | 30 | die "no branch configured for ${sm_path}"; 31 | 32 | -------------------------------------------------------------------------------- /g/bin/prepare-merge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while [ x"$(basename $(pwd))" != xg ] || ! [ -d g ]; do 3 | cd .. 4 | done 5 | rm -rf tmp 6 | WD=$(pwd) 7 | cat g/merge-branches.txt | while read REPO BRANCH; do 8 | (cd $REPO && REPO=$REPO TMPDIR=$WD/tmp BRANCH=$BRANCH $WD/g/bin/prepare-specific-merge) 9 | done 10 | -------------------------------------------------------------------------------- /g/bin/prepare-specific-merge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if git worktree add --detach $TMPDIR $BRANCH && 3 | (cd $TMPDIR; git branch -D merge || true) && 4 | (cd $TMPDIR; git checkout -b merge) && 5 | (cd $TMPDIR; git merge --no-commit upstream); then 6 | if [ -n "$(cd $TMPDIR; git status -s)" ]; then 7 | if (cd $TMPDIR; git commit -m merge); then 8 | echo "$(date):" successful merge prepared in $REPO >> ../g/merges.txt 9 | else 10 | echo "$(date):" merge failed in $REPO >> ../g/merges.txt 11 | fi 12 | else 13 | echo "$(date):" nothing to merge in $REPO >> ../g/merges.txt 14 | fi 15 | else 16 | echo "$(date):" merge failed in $REPO >> ../g/merges.txt 17 | fi 18 | 19 | git worktree remove --force $TMPDIR && 20 | rm -rf $TMPDIR 21 | 22 | -------------------------------------------------------------------------------- /g/bin/pull: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git submodule foreach --recursive 'git pull '"$@"' || :' 3 | git submodule foreach 'git pull upstream master '"$@"' || :' 4 | -------------------------------------------------------------------------------- /g/bin/pull-push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git submodule foreach --recursive 'git pull --no-edit '"$@"'; git pull --no-edit upstream master '"$@"'; git push pipcet || :' 3 | -------------------------------------------------------------------------------- /g/bin/push-canon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pwd=$(pwd) 3 | EXIT=0 4 | cat g/canonical.txt | while read dir canon branch; do 5 | canonhead=$(cd $canon; GIT_DIR=.git git rev-parse $branch) 6 | if [ $(cd $dir; GIT_DIR=.git git rev-parse HEAD) = $canonhead ]; then 7 | continue 8 | fi 9 | (cd $dir && [ x"$(GIT_DIR=.git git branch --show-current)" = x"$branch" ] && GIT_DIR=.git git push canon $branch) || continue 10 | if [ $(cd $canon; GIT_DIR=.git git rev-parse $branch) != $canonhead ]; then 11 | for secondarydir in $canon $(cat g/canonical.txt | while read dir2 canon2 branch2; do if [ $canon = $canon2 ] && [ $branch = $branch2 ] && [ $dir != $dir2 ]; then echo $dir2; fi; done); do 12 | (cd $secondarydir; GIT_DIR=.git git pull canon $branch); # XXX temporary branches 13 | done 14 | (cd $canon; $pwd/g/git/hooks/post-commit; [ $(GIT_DIR=.git git branch --show-current) = $branch ] && GIT_DIR=.git git reset --hard) 15 | EXIT=1 16 | fi 17 | done 18 | 19 | exit $EXIT 20 | -------------------------------------------------------------------------------- /g/bin/push-remotes: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | cat g/push-branches.txt | while read canon remote branch; do 3 | (cd $canon && GIT_DIR=.git git diff --quiet $remote/$branch $branch || GIT_DIR=.git git push $remote $branch:$branch) 4 | done 5 | exit 0 6 | -------------------------------------------------------------------------------- /g/bin/push-upstream: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | tac g/upstream-branches.txt | while read canon branch; do 3 | (cd $canon && git push self upstream/$branch:upstream) 4 | done 5 | exit 0 6 | -------------------------------------------------------------------------------- /g/bin/remotes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my @remotes = `git submodule foreach --recursive 'echo \$toplevel/\$sm_path'`; 3 | map { chomp } @remotes; 4 | my %remotes = (); 5 | for my $line (`cat g/remotes.txt`) { 6 | chomp $line; 7 | my ($name, $path, $url) = split " ", $line; 8 | $remotes{$path} = { name => $name, url => $url }; 9 | } 10 | for my $remote (keys %remotes) { 11 | for my $i (0 .. length ($remote)) { 12 | my $prefix = substr($remote, $i); 13 | if (exists $remotes{$prefix}) { 14 | system("(cd $prefix; git remote add " . $remotes{$prefix}{name} . " " . $remotes{$prefix}{url} . ")"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /g/bin/remotes-mk: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat g/remotes.txt | (while read name repo url; do 3 | echo "fetch-$repo-$name!:" 4 | echo -e "\t(cd $repo; git fetch $name)" 5 | echo 6 | REMS="$REMS fetch-$repo-$name!" 7 | done; 8 | echo -n "fetch-all!: $REMS" 9 | echo) 10 | -------------------------------------------------------------------------------- /g/bin/remove-remotes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my %lines; 3 | while (<>) { 4 | chomp; 5 | $lines{$_} = $_; 6 | } 7 | line: 8 | for my $line (keys %lines) { 9 | my ($name, $dir, $url, $fetch_or_push) = split / /, $line; 10 | next if ($name eq "origin"); 11 | print "$line\n"; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /g/bin/reverse-remotes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git submodule foreach --quiet --recursive 'echo git remote add local/$displaypath $displaypath/' | while read; do $REPLY; done 3 | git submodule foreach --quiet --recursive 'echo git remote add pipcet/$displaypath $(git remote show pipcet | grep "^ Fetch URL:" | sed -e "s/ Fetch URL: //")' | while read; do $REPLY; done 4 | git submodule foreach --quiet --recursive 'echo git remote add upstream/$displaypath $(git remote show upstream | grep "^ Fetch URL:" | sed -e "s/ Fetch URL: //")' | while read; do $REPLY; done 5 | -------------------------------------------------------------------------------- /g/bin/storage: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pwd=$(pwd) 3 | find .git/modules -name objects -type d | while read modpath; do 4 | echo "$pwd/.git/objects" > $modpath/info/alternates 5 | done 6 | git submodule foreach --recursive 'echo $displaypath' | egrep -v '^Entering' | while read sm_path; do 7 | dotdot=$(echo "$sm_path" | sed -e 's/[^\/]*/\.\./g'); 8 | (cd $sm_path; 9 | # git remote add storage $dotdot; 10 | # git push storage refs/heads/'*':"refs/heads/storage/$sm_path/g/heads/"'*'; 11 | # git push storage refs/remotes/origin/'*':"refs/heads/storage/$sm_path/g/remotes/origin/"'*'; 12 | git repack -a -d -l); 13 | done 14 | git repack -k -a -d -l 15 | -------------------------------------------------------------------------------- /g/bin/storage2: -------------------------------------------------------------------------------- 1 | git submodule foreach --recursive 'echo git remote add local/$displaypath $displaypath/' | while read; do $REPLY; done 2 | git submodule foreach --recursive 'echo git remote add origin/$displaypath $(git remote show origin | grep "^ Fetch URL:" | sed -e "s/ Fetch URL: //")' | while read; do $REPLY; done 3 | git submodule foreach --recursive 'echo git remote add pipcet/$displaypath $(git remote show pipcet | grep "^ Fetch URL:" | sed -e "s/ Fetch URL: //")' | while read; do $REPLY; done 4 | git submodule foreach --recursive 'echo git remote add upstream/$displaypath $(git remote show upstream | grep "^ Fetch URL:" | sed -e "s/ Fetch URL: //")' | while read; do $REPLY; done -------------------------------------------------------------------------------- /g/bin/try-install-remote: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my ($smpath, $name, $url, $fetch_or_push) = split / /, shift; 3 | system("git remote add $name $url"); 4 | system("git remote set-url " . ($fetch_or_push eq "(fetch)") ? "" : "--push" . " $name $url"); 5 | -------------------------------------------------------------------------------- /g/bin/u: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while [ x"$(basename $(pwd))" != xg ] || ! [ -d g ]; do 3 | cd .. 4 | done 5 | git fetch --no-tags --all -j 64 6 | git submodule foreach --recursive 'git fetch --all --no-tags' 7 | tac g/upstream-branches.txt | while read canon branch; do 8 | (cd $canon && git push self upstream/$branch:refs/heads/upstream) 9 | done 10 | ./g/bin/prepare-merge 11 | git submodule foreach --recursive 'git fetch self --no-tags || :' 12 | git submodule foreach --recursive 'git fetch canon --no-tags || :' 13 | -------------------------------------------------------------------------------- /g/bin/up: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while [ x"$(basename $(pwd))" != xg ] || ! [ -d g ]; do 3 | cd .. 4 | done 5 | ./g/bin/install-hooks 6 | while ! ./g/bin/install-remotes < g/remotes.txt; do 7 | sleep 1; 8 | done 9 | git fetch --no-tags --all -j 64 10 | git submodule foreach --recursive 'git fetch --all --no-tags' 11 | tac g/upstream-branches.txt | while read canon branch; do 12 | (cd $canon && git push self upstream/$branch:refs/heads/upstream) 13 | done 14 | ./g/bin/prepare-merge 15 | git submodule foreach --recursive 'git fetch self --no-tags || :' 16 | git submodule foreach --recursive 'git fetch canon --no-tags || :' 17 | DELAY=1 18 | while ! git push; do 19 | sleep $DELAY 20 | DELAY=$(($DELAY * 2)) 21 | done 22 | -------------------------------------------------------------------------------- /g/branches.txt: -------------------------------------------------------------------------------- 1 | submodule/barebox pearl pipcet/pearl 2 | submodule/busybox pearl pipcet/pearl 3 | submodule/kexec-tools pearl pipcet/pearl 4 | submodule/linux pearl pipcet/pearl 5 | submodule/m1n1 pearl pipcet/pearl 6 | submodule/memtool pearl pipcet/pearl 7 | submodule/u-boot pearl pipcet/pearl 8 | -------------------------------------------------------------------------------- /g/canonical.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pipcet/pearl/844d006c1233b1655fac3ceba47d203f85fb28f7/g/canonical.txt -------------------------------------------------------------------------------- /g/fixed-remotes.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pipcet/pearl/844d006c1233b1655fac3ceba47d203f85fb28f7/g/fixed-remotes.txt -------------------------------------------------------------------------------- /g/git/hooks/post-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | if [ x"$GIT_MSG" = x ]; then 3 | GIT_MSG="$(git log -1 --pretty='%s (%H)'; echo; git log -1 --pretty='%b')" 4 | fi 5 | toplevel="$(git rev-parse --show-toplevel)" 6 | super_toplevel="$(git rev-parse --show-superproject-working-tree)" 7 | toptoplevel=$toplevel; 8 | while true; do 9 | parent=$(cd $toptoplevel; git rev-parse --show-superproject-working-tree) 10 | if [ x$parent = x ]; then 11 | break 12 | fi 13 | toptoplevel=$parent 14 | done 15 | if [ "$toplevel" = "$super_toplevel" ] || [ x"$super_toplevel" = x ]; then 16 | exit 0; 17 | fi 18 | subrepo="$(echo $toplevel | cut -c $((2 + $(echo -n "$super_toplevel" | wc -c)))-)" 19 | echo "subrepo $subrepo" > /dev/stderr 20 | cd "$super_toplevel" 21 | GIT_MSG="$subrepo: $GIT_MSG" 22 | (unset GIT_DIR; unset GIT_INDEX_FILE; GIT_MSG="$GIT_MSG" git commit -m "$GIT_MSG" -- $subrepo) 23 | if [ x$IN_RECURSIVE_COMMIT != x ]; then 24 | : # exit 0 25 | fi 26 | subsubrepo="$(echo $toplevel | cut -c $((2 + $(echo -n "$toptoplevel" | wc -c)))-)" 27 | echo "subsubrepo $subsubrepo" > /dev/stderr 28 | if ! test -e $toptoplevel/g/canonical.txt; then 29 | exit 0 30 | fi 31 | cat $toptoplevel/g/canonical.txt | while read path canon branch; do 32 | if [ $canon = $subsubrepo ]; then 33 | cat $toptoplevel/g/canonical.txt | while read path2 canon2 branch2; do 34 | if [ $canon2 = $canon ]; then 35 | (cd $toptoplevel/$path2; unset GIT_DIR; unset GIT_INDEX_FILE; IN_RECURSIVE_COMMIT=1 GIT_MSG="$GIT_MSG" git pull --no-edit canon $branch2) 36 | fi 37 | done 38 | fi 39 | if [ $path = $subsubrepo ]; then 40 | GIT_MSG="$subrepo: $GIT_MSG" git push canon $branch:$branch 41 | (cd $toptoplevel/$canon; unset GIT_DIR; unset GIT_INDEX_FILE; git checkout $branch; GIT_MSG="$subrepo: $GIT_MSG" $toptoplevel/g/git/hooks/post-commit) 42 | fi 43 | done 44 | -------------------------------------------------------------------------------- /g/git/hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash -x 2 | toplevel=$(git rev-parse --show-superproject-working-tree) 3 | if [ x"$IN_RECURSIVE_PUSH" = x ] && [ x"$toplevel" != x ]; then 4 | # do not add IN_RECURSIVE_PUSH=1 here, we want to make it to the 5 | # toplevel (confusingly, $toplevel is only the immediate parent's 6 | # toplevel) 7 | # echo "Recursing into $toplevel" 8 | # (cd "$toplevel"; git push || exit 1) 9 | : 10 | fi 11 | if [ x"$IN_RECURSIVE_PUSH" = x ] && [ -e g/canonical.txt ]; then 12 | OLDHEAD=$(git rev-parse HEAD) 13 | if [ -e g/canonical.txt ]; then 14 | if ! IN_RECURSIVE_PUSH=1 g/bin/push-canon; then 15 | exit 1 16 | fi 17 | fi 18 | [ -e g/remotes.txt ] && IN_RECURSIVE_PUSH=1 g/bin/push-remotes 19 | if [ $(git rev-parse HEAD) != $OLDHEAD ]; then 20 | exit 1 21 | fi 22 | fi 23 | exit 0 24 | # [ -e g/canonical.txt ] && IN_RECURSIVE_PUSH=1 g/bin/fetch-canon 25 | # [ -e g/remotes.txt ] && IN_RECURSIVE_PUSH=1 g/bin/fetch-upstream 26 | -------------------------------------------------------------------------------- /g/git/hooks/prepare-commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | exit if $ENV{GIT_MSG}; 3 | my $commit_msg_file = shift; 4 | my $commit_source = shift; 5 | my $sha1 = shift; 6 | 7 | use File::Slurp qw(write_file read_file); 8 | 9 | my $non_subrepos = 0; 10 | my $subrepos = 0; 11 | my %subrepos; 12 | my %paths; 13 | my $msg = ""; 14 | for my $line (`git status -s`) { 15 | chomp $line; 16 | if ($line =~ /^M. subrepos\/([^\/]*)$/) { 17 | $subrepos{$1} = 1; 18 | $subrepos = 1; 19 | } elsif ($line =~ /^[ADM]. (.*)$/) { 20 | $paths{$1} = 1; 21 | $non_subrepos = 1; 22 | } 23 | } 24 | if ($subrepos && !$non_subrepos) { 25 | my @subrepos = sort keys %subrepos; 26 | my $subrepos = join(", ", @subrepos); 27 | for my $subrepo (@subrepos) { 28 | my $line = `(cd subrepos/$subrepo; git log -1 --pretty='%s (%H)')`; 29 | chomp $line; 30 | my $body = `(cd subrepos/$subrepo; git log -1 --pretty='%b')`; 31 | chomp $body; 32 | $msg .= <<"EOF"; 33 | $subrepo: $line$body 34 | 35 | EOF 36 | } 37 | if (@subrepos > 1) { 38 | $msg = <<"EOF" . $msg; 39 | Update subrepos ($subrepos) 40 | 41 | EOF 42 | } else { 43 | $msg = "Update " . $msg; 44 | } 45 | } elsif (scalar keys %paths == 1) { 46 | $msg = join(", ", sort keys %paths) . ": " . $msg; 47 | } 48 | 49 | my $oldmsg = read_file($commit_msg_file); 50 | if (substr($oldmsg, 0, length $msg) eq $msg) { 51 | $msg = ""; 52 | } 53 | # while ($msg ne "" && $oldmsg ne "" && substr ($oldmsg, 0, 1) ne "#") { 54 | # $oldmsg = substr ($oldmsg, 1); 55 | # } 56 | 57 | if ($oldmsg =~ /^#/) { 58 | $oldmsg = "\n\n$oldmsg"; 59 | } 60 | 61 | write_file($commit_msg_file, "$msg" . "$oldmsg"); 62 | -------------------------------------------------------------------------------- /g/github/artifact-init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | (cd g/github; npm up; npm i '@actions/artifact') 3 | -------------------------------------------------------------------------------- /g/github/dl-artifact: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | node g/github/dl-artifact.js "$@" 3 | -------------------------------------------------------------------------------- /g/github/dl-artifact.js: -------------------------------------------------------------------------------- 1 | const artifact = require('@actions/artifact'); 2 | const client = artifact.create(); 3 | const name = process.argv[2]; 4 | async function main() 5 | { 6 | console.log(await client.downloadArtifact(name, `build/artifacts/down/${name}.new`, { 7 | continueOnError: false, 8 | createArtifactFolder: false, 9 | })); 10 | } 11 | 12 | main(); 13 | -------------------------------------------------------------------------------- /g/github/dl-daily: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | wget --quiet -O build/daily/down/"$1" https://github.com/pipcet/pearl/releases/download/latest/"$1" 3 | -------------------------------------------------------------------------------- /g/github/env/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Set env variables' 2 | description: 'Sets certain env variables so that e2e artifact upload and download can be tested in a shell' 3 | runs: 4 | using: 'node12' 5 | main: 'index.js' 6 | env: 7 | ACTIONS_ALLOW_UNSECURE_COMMANDS: true 8 | -------------------------------------------------------------------------------- /g/github/env/index.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | fs.appendFileSync(process.env.GITHUB_ENV, `ACTIONS_RUNTIME_URL=${process.env.ACTIONS_RUNTIME_URL}\n`); 3 | fs.appendFileSync(process.env.GITHUB_ENV, `ACTIONS_RUNTIME_TOKEN=${process.env.ACTIONS_RUNTIME_TOKEN}\n`); 4 | fs.appendFileSync(process.env.GITHUB_ENV, `GITHUB_RUN_ID=${process.env.GITHUB_RUN_ID}\n`); 5 | -------------------------------------------------------------------------------- /g/github/release.js: -------------------------------------------------------------------------------- 1 | let this_release_date = process.argv[2]; 2 | //this_release_date = this_release_date.substr(1, this_release_date.length - 2) 3 | let last_release_date = process.argv[3]; 4 | //last_release_date = last_release_date.substr(1, this_release_date.length - 2) 5 | let child_process = require("child_process"); 6 | let log = ""; 7 | let json = {}; 8 | json.tag_name = this_release_date; 9 | json.name = `${this_release_date} (automatic release)`; 10 | let body = `\n\n`; 11 | body += log; 12 | json.body = body; 13 | console.error(JSON.stringify(json)); 14 | console.log(JSON.stringify(json)); 15 | -------------------------------------------------------------------------------- /g/github/ul-artifact: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | node g/github/ul-artifact.js "$@" 3 | -------------------------------------------------------------------------------- /g/github/ul-artifact.js: -------------------------------------------------------------------------------- 1 | const artifact = require('@actions/artifact'); 2 | const client = artifact.create(); 3 | const name = process.argv[2]; 4 | const files = process.argv.slice(3); 5 | async function main() 6 | { 7 | console.log(await client.uploadArtifact(name, files, "build/artifacts/up", { 8 | continueOnError: false, 9 | })); 10 | } 11 | 12 | main(); 13 | -------------------------------------------------------------------------------- /g/merge-branches.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pipcet/pearl/844d006c1233b1655fac3ceba47d203f85fb28f7/g/merge-branches.txt -------------------------------------------------------------------------------- /g/new-remotes.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pipcet/pearl/844d006c1233b1655fac3ceba47d203f85fb28f7/g/new-remotes.txt -------------------------------------------------------------------------------- /g/push-branches.txt: -------------------------------------------------------------------------------- 1 | bootloaders/barebox/barebox pipcet pearl 2 | bootloaders/grub/grub pipcet pearl 3 | bootloaders/m1n1/m1n1 pipcet pearl 4 | bootloaders/u-boot/u-boot pipcet pearl 5 | debootstrap/debootstrap pipcet pearl 6 | linux/linux pipcet pearl 7 | toolchain/binutils-gdb/binutils-gdb pipcet pearl 8 | toolchain/gcc/gcc pipcet pearl 9 | userspace/IPC-Run/IPC-Run pipcet pearl 10 | userspace/busybox/busybox pipcet pearl 11 | userspace/cryptsetup/cryptsetup pipcet pearl 12 | userspace/dialog/dialog pipcet pearl 13 | userspace/dtc/dtc pipcet pearl 14 | userspace/emacs/emacs pipcet pearl 15 | userspace/glibc/glibc pipcet pearl 16 | userspace/json-c/json-c pipcet pearl 17 | userspace/kexec-tools/kexec-tools pipcet pearl 18 | userspace/libaio/libaio pipcet pearl 19 | userspace/libnl/libnl pipcet pearl 20 | userspace/lvm2/lvm2 pipcet pearl 21 | userspace/memtool/memtool pipcet pearl 22 | userspace/ncurses/ncurses pipcet pearl 23 | userspace/nvme-cli/nvme-cli pipcet pearl 24 | userspace/openssl/openssl pipcet pearl 25 | userspace/perl/perl pipcet pearl 26 | userspace/popt/popt pipcet pearl 27 | userspace/procps/procps pipcet pearl 28 | userspace/screen/screen pipcet pearl 29 | userspace/slurp/slurp pipcet pearl 30 | userspace/util-linux/util-linux pipcet pearl 31 | userspace/wpa/wpa pipcet pearl 32 | -------------------------------------------------------------------------------- /g/stampserver/stampserver.mk: -------------------------------------------------------------------------------- 1 | stamp/%: | stamp/ 2 | touch $@ 3 | 4 | # echo $((1024*1024)) | sudo tee /proc/sys/fs/inotify/max_user_watches 5 | stampserver: g/stampserver/stampserver.pl | stamp/ 6 | inotifywait -m -r . | perl g/stampserver/stampserver.pl 7 | -------------------------------------------------------------------------------- /g/stampserver/stampserver.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | while (<>) { 3 | chomp; 4 | my ($dir,$flags,$file) = split " "; 5 | my %flags; 6 | for my $flag (split ",", $flags) { 7 | $flags{$flag} = 1; 8 | } 9 | next unless $flags{CLOSE_WRITE}; 10 | if ($dir =~ /^\.\/submodule\/(.*?)\/.*$/) { 11 | my $module = $1; 12 | warn "$module changed ($dir)"; 13 | system("touch stamp/$module"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /g/upstream-branches.txt: -------------------------------------------------------------------------------- 1 | bootloaders/m1n1 upstream/main 2 | linux/linux linux-next/master 3 | toolchain/binutils-gdb/binutils-gdb upstream/master 4 | toolchain/gcc/gcc upstream/trunk 5 | userspace/IPC-Run/IPC-Run upstream/master 6 | userspace/busybox/busybox upstream/master 7 | userspace/cryptsetup/cryptsetup upstream/master 8 | userspace/dtc/dtc upstream/master 9 | userspace/emacs/emacs upstream/master 10 | userspace/glibc/glibc upstream/master 11 | userspace/json-c/json-c upstream/master 12 | userspace/kexec-tools/kexec-tools upstream/master 13 | userspace/libaio/libaio upstream/master 14 | userspace/libnl/libnl upstream/master 15 | userspace/lvm2/lvm2 upstream/master 16 | userspace/memtool/memtool upstream/master 17 | userspace/ncurses/ncurses upstream/master 18 | userspace/nvme-cli/nvme-cli upstream/master 19 | userspace/openssl/openssl upstream/master 20 | userspace/perl/perl upstream/blead 21 | userspace/popt/popt upstream/master 22 | userspace/slurp/slurp upstream/master 23 | userspace/util-linux/util-linux upstream/master 24 | userspace/wpa/wpa upstream/debian/buster 25 | -------------------------------------------------------------------------------- /host/bashify/bashify.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BASENAME="$(echo "$1" | sed -e 's/.*\///')" 3 | echo "#!/bin/bash" 4 | bash ./host/pack/pack.bash '~/tmp' "$1" "./host/pack/pack.bash" 5 | echo "tar cf ~/tmp/wifi.tar /usr/share/firmware/wifi" 6 | echo 'SHA=$(sha512sum ~/tmp/'"$BASENAME"')' 7 | echo "bash ~/tmp/pack.bash --zsh /persist/ ~/tmp/wifi.tar >> ~/tmp/$BASENAME" 8 | # echo "echo SHA-512 of $BASENAME is \$SHA. Please verify. It should be $(sha512sum "$1"), but should also match the SHA-512 printed on the download page." 9 | echo "kmutil configure-boot -c ~/tmp/$BASENAME -v /Volumes/Macintosh\ HD/ 4 | #include 5 | typedef unsigned long u64; 6 | typedef unsigned u32; 7 | 8 | #define MACHO_COMMAND_UNIX_THREAD 0x05 9 | #define MACHO_COMMAND_SEGMENT_64 0x19 10 | struct macho_header { 11 | u32 irrelevant[5]; 12 | u32 cmdsize; 13 | u32 irrelevant2[2]; 14 | } __attribute__((packed)); 15 | 16 | struct macho_command { 17 | u32 type; 18 | u32 size; 19 | union { 20 | struct { 21 | u32 thread_type; 22 | u32 length; 23 | u64 regs[32]; 24 | u64 pc; 25 | u64 regs2[1]; 26 | } unix_thread; 27 | struct { 28 | char segname[16]; 29 | u64 vmaddr; 30 | u64 vmsize; 31 | u64 fileoff; 32 | u64 filesize; 33 | u64 unused2[2]; 34 | } segment_64; 35 | } u; 36 | } __attribute__((packed)); 37 | 38 | #define FOR_EACH_COMMAND(command) \ 39 | for(command = (void *)(header + 1), \ 40 | last_command = ((void *)command) + header->cmdsize; \ 41 | command < last_command; \ 42 | command = ((void*)command) + command->size) 43 | 44 | static inline void memmove(void *p, void *q, size_t len) 45 | { 46 | unsigned __int128 *p128 = p; 47 | unsigned __int128 *q128 = q; 48 | 49 | len += 15; 50 | len /= 16; 51 | while (len--) 52 | *p128++ = *q128++; 53 | } 54 | 55 | static inline void memset(void *p, int c_ignored, size_t len) 56 | { 57 | unsigned __int128 *p128 = p; 58 | 59 | len += 15; 60 | len /= 16; 61 | while (len--) 62 | *p128++ = 0; 63 | } 64 | 65 | void boot_macho(unsigned long, void *, void *) 66 | __attribute__((noreturn)); 67 | 68 | extern void macho_entry(unsigned long, unsigned long) __attribute__((noreturn)); 69 | 70 | void boot_macho(unsigned long bootargs, void *macho, void *base) 71 | { 72 | u64 vmin = (u64)-1, vmax = 0; 73 | u64 fmin = (u64)-1, fmax = 0; 74 | u64 pc = 0; 75 | struct macho_header *header = (struct macho_header *)macho; 76 | struct macho_command *command, *last_command; 77 | FOR_EACH_COMMAND(command) { 78 | switch(command->type) { 79 | case MACHO_COMMAND_UNIX_THREAD: 80 | pc = command->u.unix_thread.pc; 81 | break; 82 | case MACHO_COMMAND_SEGMENT_64: { 83 | u64 vmaddr = command->u.segment_64.vmaddr; 84 | u64 vmsize = command->u.segment_64.vmsize; 85 | 86 | if (vmin >= vmaddr) 87 | vmin = vmaddr; 88 | if (vmax <= vmaddr + vmsize) 89 | vmax = vmaddr + vmsize; 90 | 91 | u64 faddr = command->u.segment_64.fileoff; 92 | u64 fsize = command->u.segment_64.filesize; 93 | 94 | if (fmin >= faddr) 95 | fmin = faddr; 96 | if (fmax <= faddr + fsize) 97 | fmax = faddr + fsize; 98 | } 99 | } 100 | } 101 | vmin -= fmin; 102 | fmin = 0; 103 | u64 vlen = vmax - vmin; 104 | u64 flen = fmax - fmin; 105 | void *safebase = base + vlen; 106 | if (safebase != macho) { 107 | boot_macho(bootargs, safebase, base); 108 | memmove(safebase, macho, flen); 109 | } 110 | typeof(&macho_entry) actual_pc = (void *)pc - (void *)vmin + base; 111 | FOR_EACH_COMMAND(command) { 112 | switch (command->type) { 113 | case MACHO_COMMAND_SEGMENT_64: { 114 | u64 vmaddr = command->u.segment_64.vmaddr; 115 | u64 vmsize = command->u.segment_64.vmsize; 116 | u64 faddr = command->u.segment_64.fileoff; 117 | u64 fsize = command->u.segment_64.filesize; 118 | 119 | memset((void *)base + vmaddr - vmin, 0, vmsize); 120 | memmove((void *)base + vmaddr - vmin, macho + faddr, fsize); 121 | } 122 | } 123 | } 124 | 125 | asm volatile("isb"); 126 | 127 | actual_pc(bootargs, bootargs); 128 | } 129 | -------------------------------------------------------------------------------- /host/macho-tools/macho-image-fill: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use bytes; 3 | use strict; 4 | use File::Slurp qw(read_file write_file); 5 | my $macho_file = $ARGV[0]; 6 | my $bootargs_address = $ARGV[1] // unpack("Q>", read_file("/sys/firmware/devicetree/base/reserved-memory/bootargs\@800000000/reg")); 7 | my $original_base_address = $ARGV[2] // unpack("Q>", read_file("/sys/firmware/devicetree/base/reserved-memory/base\@800000000/reg")); 8 | 9 | my $macho = read_file($macho_file) or die; 10 | 11 | substr $macho, 72, 8, pack("Q<", $bootargs_address); 12 | substr $macho, 80, 8, pack("Q<", $original_base_address); 13 | 14 | write_file($macho_file, $macho) or die; 15 | -------------------------------------------------------------------------------- /host/macho-tools/macho-to-image.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define PRELUDE_SIZE 256 * 1024 8 | 9 | #define MACHO_COMMAND_UNIX_THREAD 0x05 10 | #define MACHO_COMMAND_SEGMENT_64 0x19 11 | 12 | typedef unsigned long long u64; 13 | typedef unsigned int u32; 14 | 15 | #ifndef KERNEL_SIZE 16 | #define KERNEL_SIZE 32 * 1024 * 1024 17 | #endif 18 | 19 | #define NULL ((void *)0) 20 | 21 | /* these strange includes are precompiled assembly snippets included 22 | as binary code in the (native) binaries. */ 23 | 24 | static 25 | #include "macho-boot..h" 26 | ; 27 | 28 | static 29 | #include "image-header..h" 30 | ; 31 | 32 | static 33 | #include "disable-timers..h" 34 | ; 35 | 36 | struct macho_header { 37 | u32 irrelevant[5]; 38 | u32 cmdsize; 39 | u32 irrelevant2[2]; 40 | }; 41 | 42 | struct macho_command { 43 | u32 type; 44 | u32 size; 45 | union { 46 | struct { 47 | u32 thread_type; 48 | u32 length; 49 | u64 regs[32]; 50 | u64 pc; 51 | u64 regs2[1]; 52 | } unix_thread; 53 | struct { 54 | char segname[16]; 55 | u64 vmaddr; 56 | u64 vmsize; 57 | u64 fileoff; 58 | u64 filesize; 59 | u64 unused2[2]; 60 | } segment_64; 61 | } u; 62 | }; 63 | 64 | asm(".text\n\t"); 65 | 66 | int main(int argc, char **argv) 67 | { 68 | const size_t prelude_size = PRELUDE_SIZE; 69 | if (argc != 3) { 70 | error: 71 | fprintf(stderr, "usage: %s \n", 72 | argv[0]); 73 | exit(1); 74 | } 75 | 76 | FILE *f = fopen(argv[1], "r"); 77 | if (!f) 78 | goto error; 79 | 80 | fseek(f, 0, SEEK_END); 81 | size_t macho_size = ftell(f); 82 | fseek(f, 0, SEEK_SET); 83 | void *buf = malloc(prelude_size + macho_size); 84 | if (!buf) 85 | goto error; 86 | 87 | memset(buf, 0, prelude_size + macho_size); 88 | 89 | void *p = buf; 90 | memcpy(p, image_header, sizeof(image_header)); 91 | *((unsigned long *)p + 2) = prelude_size + macho_size; 92 | p += sizeof(image_header); 93 | //memcpy(p, disable_timers, sizeof(disable_timers)); 94 | //p += sizeof(disable_timers); 95 | memcpy(p, macho_boot, sizeof(macho_boot)); 96 | p += sizeof(macho_boot); 97 | 98 | void *macho = buf + prelude_size; 99 | assert(p <= macho); 100 | 101 | fread(macho, macho_size, 1, f); 102 | fclose(f); 103 | f = fopen(argv[2], "w"); 104 | if (!f) 105 | goto error; 106 | fwrite(buf, 1, prelude_size + macho_size, f); 107 | fclose(f); 108 | return 0; 109 | } 110 | -------------------------------------------------------------------------------- /host/macho-tools/macho-to-initramfs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # find the first ZSTD signature in the input and print the rest of the 4 | # file. Depending on your file, that might or might not be the ZSTD 5 | # you're looking for. Run twice to search for the second signature, 6 | # and so on. 7 | 8 | # Piping the result into zstd -d works, since that ignores trailing 9 | # non-ZSTD data. 10 | 11 | use strict; 12 | use bytes; 13 | 14 | my $data = join("", <>); 15 | 16 | my @offs; 17 | 18 | for my $i (1 .. length($data)) { 19 | if (substr($data, $i, 4) eq "\x28\xb5\x2f\xfd") { 20 | push @offs, $i; 21 | } 22 | } 23 | 24 | die "no ZSTD signature found" unless @offs; 25 | 26 | print substr($data, $offs[0]); 27 | -------------------------------------------------------------------------------- /host/macho-tools/macho-tools.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/host/image-to-macho: host/macho-tools/image-to-macho.c | $(BUILD)/host/ 2 | gcc -Os -I$(BUILD)/host/macho-tools -o $@ $< 3 | 4 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/perform-alignment..h 5 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/x8r8g8b8..h 6 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/enable-all-clocks..h 7 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/save-boot-args..h 8 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/restore-boot-args..h 9 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/nop..h 10 | $(BUILD)/host/image-to-macho: $(BUILD)/host/macho-tools/bring-up-phys..h 11 | 12 | $(BUILD)/host/macho-to-image: host/macho-tools/macho-to-image.c | $(BUILD)/host/ 13 | gcc -Os -I$(BUILD)/host/macho-tools -o $@ $< 14 | 15 | $(BUILD)/host/macho-to-image: $(BUILD)/host/macho-tools/macho-boot..h 16 | $(BUILD)/host/macho-to-image: $(BUILD)/host/macho-tools/image-header..h 17 | $(BUILD)/host/macho-to-image: $(BUILD)/host/macho-tools/disable-timers..h 18 | 19 | $(BUILD)/macho-image-fill: host/macho-tools/macho-image-fill 20 | $(MKDIR) $(dir $@) 21 | $(CP) $< $@ 22 | 23 | $(BUILD)/%.image.macho: $(BUILD)/%.image $(BUILD)/host/image-to-macho 24 | $(BUILD)/host/image-to-macho $< $@ --version "$* of `date --iso=s`" 25 | 26 | $(BUILD)/%.macho.image: $(BUILD)/%.macho $(BUILD)/host/macho-to-image 27 | $(BUILD)/host/macho-to-image $< $@ 28 | -------------------------------------------------------------------------------- /host/macho-tools/nop.S: -------------------------------------------------------------------------------- 1 | nop 2 | -------------------------------------------------------------------------------- /host/macho-tools/perform-alignment.c: -------------------------------------------------------------------------------- 1 | #include "snippet.h" 2 | 3 | #define UNALIGNED(image) (((image) & ((1 << 21)-1)) != 0) 4 | 5 | START_SNIPPET { 6 | unsigned long pc; 7 | asm volatile("adr %0, ." : "=r" (pc)); 8 | unsigned long page = (pc & ~16383); 9 | unsigned long image = page + 16384; 10 | unsigned long size = ((unsigned long *)image)[2]; 11 | if (UNALIGNED(image)) { 12 | unsigned long newimage = 13 | (image + size + 512 * 1024 * 1024 + ((1 << 21) - 1)) & ~((1L<<21)-1); 14 | __int128 *p = (void *)image + size; 15 | while (p != (__int128 *)page) { 16 | p[(newimage - image)/16] = *p; 17 | --p; 18 | } 19 | asm volatile("isb"); 20 | asm volatile("br %0" : : "r" (newimage - image + pc)); 21 | __builtin_unreachable(); 22 | } 23 | } END_SNIPPET 24 | -------------------------------------------------------------------------------- /host/macho-tools/restore-boot-args.S: -------------------------------------------------------------------------------- 1 | mov x0, x30 2 | mov x1, x0 3 | mov x0, #0 4 | mov x2, x29 5 | -------------------------------------------------------------------------------- /host/macho-tools/save-boot-args.S: -------------------------------------------------------------------------------- 1 | #define HDR_SIZE 0x2000 2 | adr x29, . - HDR_SIZE 3 | mov x30, x0 4 | -------------------------------------------------------------------------------- /host/macho-tools/x8r8g8b8.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "snippet.h" 3 | 4 | START_SNIPPET { 5 | *(volatile uint32_t *)0x230850030 = 0x5000; 6 | } END_SNIPPET 7 | -------------------------------------------------------------------------------- /host/pack/pack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use File::Slurp qw(read_file); 4 | print "#!/bin/zsh\n"; 5 | for my $arg (@ARGV) { 6 | my $basename = `basename $arg`; 7 | chomp $basename; 8 | my $data = read_file($arg); 9 | my $nonce = ""; 10 | my $nonce2 = ""; 11 | for my $i (0 .. 8) { 12 | $nonce .= sprintf("%04x", int(rand(0x10000))); 13 | $nonce2 .= sprintf("%04x", int(rand(0x10000))); 14 | } 15 | while (index($data, $nonce) != -1 or 16 | index($data, $nonce2) != -1) { 17 | $nonce .= sprintf("%04x", int(rand(0x10000))); 18 | $nonce2 .= sprintf("%04x", int(rand(0x10000))); 19 | } 20 | my $len = length($data); 21 | my $chunklen = 32768; 22 | my $chunkcount = int($len / $chunklen); 23 | my $restlen = $len % $chunklen; 24 | if (0) { 25 | print "dd if=/persist/payload bs=1 | (while read; do if [ \"x\$REPLY\" = \"x$nonce\" ]; then break; fi; done; (dd iflag=fullblock bs=$chunklen count=$chunkcount; dd bs=$restlen count=1) > /persist/$basename)\ncat > /dev/null <<\"$nonce2\"\n$nonce\n$data\n$nonce2\n"; 26 | } elsif (0) { 27 | my $nonce = ""; 28 | while (index($data, $nonce) != -1) { 29 | $nonce .= chr(int(rand(26)) + ord("a")); 30 | } 31 | # sigh. busybox head eats NUL bytes when in "-n -1" mode. 32 | print "head -n -1 > /persist/$basename <<\"$nonce\"\n$data\n$nonce\n"; 33 | } elsif (0) { 34 | print "head -c " . length($data) . " > /persist/$basename\n$data\n"; 35 | } elsif (1) { 36 | print "head -c " . length($data) . " > /persist/$basename <<'$nonce'\n$data\n$nonce\n"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /host/pack/pack.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | QUOTE='"' 3 | if [ "x$1" = "x--zsh" ]; then 4 | shift; 5 | echo "#!/bin/zsh" 6 | else 7 | echo "#!/bin/bash" 8 | fi 9 | NONCE= 10 | for i in 1 2 3 4 5 6 7 8; do 11 | NONCE=$NONCE$(printf "%04x" $RANDOM) 12 | done 13 | DIR="$1" 14 | shift; 15 | for FILE; do 16 | BASENAME="$(echo "$FILE" | sed -e 's/.*\///')" 17 | echo mkdir -p "$DIR" 18 | echo head -c $(wc -c < $FILE) '>' "$DIR/$BASENAME" '<<'"$QUOTE$NONCE$QUOTE" 19 | cat $FILE 20 | echo 21 | echo $NONCE 22 | done 23 | -------------------------------------------------------------------------------- /host/pack/pack.mk: -------------------------------------------------------------------------------- 1 | %.pack: % 2 | perl ./host/pack/pack $< > $@ 3 | -------------------------------------------------------------------------------- /host/pack/pack.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my @files = @ARGV; 3 | my $sizes = join(",", map { s/\n//rmsg } map { join("", `wc -c < $_`) } @files); 4 | my $files = join(",", map { '"' . $_ . '"'} map { s/.*\///mrsg } @files); 5 | print <<"EOF"; 6 | #!/usr/bin/perl 7 | my \@sizes = ($sizes); 8 | my \$data = join("", ); 9 | for my \$file ($files) { 10 | my \$size = shift \@sizes; 11 | open \$fh, ">\${file}"; 12 | print \$fh substr(\$data, 0, \$size); 13 | \$data = substr(\$data, \$size); 14 | close \$fh; 15 | } 16 | system("bash " . [$files]->[0]); 17 | __DATA__ 18 | EOF 19 | for my $file (@files) { 20 | my $fh; 21 | open $fh, $file or die; 22 | print join("", <$fh>); 23 | } 24 | -------------------------------------------------------------------------------- /host/snippet/snippet.h: -------------------------------------------------------------------------------- 1 | #define START_SNIPPET \ 2 | void function(void) __attribute__((section(".noinclude.text"))); \ 3 | \ 4 | void function(void) \ 5 | { \ 6 | asm volatile(".pushsection .text"); \ 7 | asm volatile(".cfi_startproc"); 8 | 9 | #define END_SNIPPET \ 10 | asm volatile(".cfi_endproc"); \ 11 | asm volatile(".popsection"); \ 12 | asm volatile("" : : "r" (&&label)); \ 13 | label: \ 14 | return; \ 15 | } 16 | -------------------------------------------------------------------------------- /host/snippet/snippet.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/%.c: %.c ; $(COPY) 2 | $(BUILD)/%.S: %.S ; $(COPY) 3 | 4 | %..h: %.c.S.elf.bin.s.h ; $(COPY) 5 | %..h: %.S.elf.bin.s.h ; $(COPY) 6 | %..bin: %.c.S.elf.bin ; $(COPY) 7 | %..bin: %.S.elf.bin ; $(COPY) 8 | $(BUILD)/include/snippet.h: host/snippet/snippet.h | $(BUILD)/include/ ; $(COPY) 9 | 10 | %.c.S: %.c $(BUILD)/include/snippet.h $(call done,toolchain/gcc,gcc/install) 11 | $(WITH_CROSS_PATH) $(WITH_CROSS_CC) $(CROSS_CC) -I$(dir $<) -I$(BUILD)/host/macho-tools -I$(BUILD)/include -fno-builtin -ffunction-sections -march=armv8.5-a -Os -S -o $@ $< 12 | 13 | %.S.elf: %.S $(call done,toolchain/gcc,gcc/install) 14 | $(WITH_CROSS_PATH) $(WITH_CROSS_CC) $(CROSS_CC) -Os -static -march=armv8.5-a -nostdlib -o $@ $< 15 | 16 | %.elf.bin: %.elf $(call done,toolchain/gcc,gcc/install) 17 | $(WITH_CROSS_PATH) $(CROSS_COMPILE)objcopy -O binary -S --only-section .pretext.0 --only-section .text --only-section .data --only-section .got --only-section .last --only-section .text.2 $< $@ 18 | 19 | %.bin.s: %.bin $(call done,toolchain/gcc,gcc/install) 20 | $(WITH_CROSS_PATH) $(CROSS_COMPILE)objdump -maarch64 --disassemble-zeroes -D -bbinary $< > $@ 21 | 22 | %.s.h: %.s 23 | (NAME=$$(echo $(notdir $*) | sed -e 's/\..*//' -e 's/-/_/g'); echo "unsigned int $$NAME[] = {"; cat $< | tail -n +8 | sed -e 's/\t/ /g' | sed -e 's/^\(.*\):[ \t]*\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\)[ \t]*\(.*\)$$/\t0x\2 \/\* \1: \3 \*\/,/g'; echo "};") > $@ 24 | -------------------------------------------------------------------------------- /linux/README.org: -------------------------------------------------------------------------------- 1 | ** linux: The Linux kernel 2 | -------------------------------------------------------------------------------- /local/README.org: -------------------------------------------------------------------------------- 1 | ** local: pearl-specific software 2 | -------------------------------------------------------------------------------- /local/boot-el/boot-el.mk: -------------------------------------------------------------------------------- 1 | $(call pearl-static,$(wildcard $(PWD)/local/boot-el/pearl/share/*,$(PWD)/local/boot-el/pearl)) 2 | -------------------------------------------------------------------------------- /local/dt/adtdump.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char **argv) 9 | { 10 | char *path; 11 | char *errorstr = NULL; 12 | if (argc < 2 || !strcmp(argv[1], "--adt")) { 13 | asprintf(&path, "/sys/firmware/devicetree/base/reserved-memory/adt@800000000/reg"); 14 | } else if (!strcmp(argv[1], "--macho-header")) { 15 | asprintf(&path, "/sys/firmware/devicetree/base/reserved-memory/base@800000000/reg"); 16 | } else { 17 | asprintf(&path, "/sys/firmware/devicetree/base/reserved-memory/bootargs@800000000/reg"); 18 | } 19 | int fd = open(path, O_RDONLY); 20 | uint64_t reg[2]; 21 | if (fd < 0) { 22 | errorstr = "couldn't open path"; 23 | goto error; 24 | } 25 | if (read(fd, reg, 16) != 16) { 26 | errorstr = "couldn't read reg"; 27 | goto error; 28 | } 29 | reg[0] = __builtin_bswap64(reg[0]); 30 | reg[1] = __builtin_bswap64(reg[1]); 31 | close(fd); 32 | fd = open("/dev/mem", O_RDONLY); 33 | if (fd < 0) { 34 | errorstr = "couldn't open /dev/mem"; 35 | goto error; 36 | } 37 | if (reg[1] == 0) { 38 | fprintf(stderr, "emulator detected, exiting\n"); 39 | return 1; 40 | } 41 | void *buf = mmap(NULL, reg[1], PROT_READ, MAP_SHARED, fd, reg[0]); 42 | if (buf == MAP_FAILED) { 43 | asprintf(&errorstr, "couldn't mmap %016lx-%016lx\n", 44 | reg[0], reg[0] + reg[1]); 45 | goto error; 46 | } 47 | void *buf2 = malloc(reg[1]); 48 | if (buf2 == NULL) { 49 | errorstr = "couldn't malloc"; 50 | goto error; 51 | } 52 | volatile unsigned *p = buf; 53 | volatile unsigned *p2 = buf2; 54 | volatile unsigned *p3 = buf2; 55 | for (unsigned long off = 0; off < reg[1]; off += 4) { 56 | *p2++ = *p++; 57 | if (p2 - p3 >= 0x4000) 58 | p3 += write(1, p3, (char *)p2 - (char *)p3)/sizeof(p3[0]); 59 | } 60 | p3 += write(1, p3, (char *)p2 - (char *)p3)/sizeof(p3[0]); 61 | return 0; 62 | 63 | error: 64 | if (errorstr) 65 | fprintf(stderr, "error: %s\n", errorstr); 66 | fprintf(stderr, "usage: %s [--bootargs]\n", argv[0]); 67 | return 1; 68 | } 69 | -------------------------------------------------------------------------------- /local/dt/dt.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/dt/build/bin/dt: local/dt/dt | $(BUILD)/dt/build/bin/ 2 | $(COPY) 3 | 4 | $(BUILD)/dt/build/bin/adtdump: local/dt/adtdump.c $(call done,userspace/glibc,glibc/install) | $(BUILD)/dt/build/bin/ 5 | $(WITH_CROSS_PATH) $(CROSS_COMPILE)gcc -Os -static -o $@ $< 6 | 7 | $(BUILD)/dt/build/bin/macho-version: local/dt/macho-version.c $(call done,userspace/glibc,glibc/install) | $(BUILD)/dt/build/bin/ 8 | $(WITH_CROSS_PATH) $(CROSS_COMPILE)gcc -Os -static -o $@ $< 9 | 10 | $(BUILD)/dt/build/bin/adtp: local/dt/adtp.cc $(call done,userspace/glibc,glibc/install) $(call done,toolchain/gcc,g++/install) | $(BUILD)/dt/build/bin/ 11 | $(WITH_CROSS_PATH) $(CROSS_COMPILE)g++ -Os -static -o $@ $< 12 | 13 | $(BUILD)/dt.tar: $(BUILD)/dt/bin/dt $(BUILD)/dt/bin/adtdump 14 | (cd $(BUILD)/dt; tar c bin/dt bin/adtdump) > $@ 15 | 16 | $(BUILD)/%.dts.dtp: $(BUILD)/%.dts $(BUILD)/dt/bin/dt 17 | $(BUILD)/dt/bin/dt dts-to-dtp $< $@ 18 | 19 | $(call pearl-static,$(BUILD)/dt/build/bin/dt $(BUILD)/dt/build/bin/adtdump $(BUILD)/dt/build/bin/macho-version $(BUILD)/dt/build/bin/adtp,$(BUILD)/dt/build) 20 | -------------------------------------------------------------------------------- /local/dt/macho-version.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char **argv) 9 | { 10 | char buf[8193]; 11 | if (read(0, buf, 8192) != 8192) 12 | return 1; 13 | if (buf[0] != 0xcf || 14 | buf[1] != 0xfa || 15 | buf[2] != 0xed || 16 | buf[3] != 0xfe) 17 | return 2; 18 | buf[8192] = 0; 19 | char *p = buf + 8191; 20 | while (p[-1]) 21 | p--; 22 | printf("%s\n", p); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /local/dtc-relocs/dtc-relocs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use bytes; 4 | use IPC::Run qw(run); 5 | 6 | my $data = join("", <>); 7 | 8 | my $count = 0; 9 | my %names; 10 | 11 | sub words { 12 | my ($text) = @_; 13 | $names{$count} = $text; 14 | return 0x01010101 * $count++; 15 | } 16 | 17 | sub nonwords { 18 | return 0xffffffff; 19 | } 20 | 21 | my $data1 = $data; 22 | $data1 =~ s/\$\{(.*?)\}/words($1)/ge; 23 | my $data2 = $data; 24 | $data2 =~ s/\$\{(.*?)\}/nonwords($1)/ge; 25 | 26 | my $fdt1; 27 | my $fdt2; 28 | 29 | run(["dtc", "-Idts", "-Odtb"], \$data1, \$fdt1) or die; 30 | run(["dtc", "-Idts", "-Odtb"], \$data2, \$fdt2) or die; 31 | 32 | # print "/* " . $fdt1 . " */\n"; 33 | die unless length($fdt1) == length($fdt2); 34 | 35 | my %relocs; 36 | 37 | $fdt1 .= "\0" while (length($fdt1) % 4); 38 | $fdt2 .= "\0" while (length($fdt2) % 4); 39 | 40 | $count = 0; 41 | for my $i (0 .. length($fdt1) - 1) { 42 | next if $i % 4; 43 | if (substr($fdt1, $i, 1) ne substr($fdt2, $i, 1)) { 44 | my $index = unpack("C", substr($fdt1, $i, 1)); 45 | $relocs{$i} = $names{$index}; 46 | } 47 | } 48 | 49 | my @words = map { sprintf("0x%08x", $_) } unpack("L<*", $fdt1); 50 | 51 | for my $i (sort { $a <=> $b } keys %relocs) { 52 | next if ($i % 4); 53 | $words[$i/4] = $words[$i/4] . " /* replaced by FDT_INIT() */"; 54 | } 55 | print "static u32 fdt[] = {\n"; 56 | for my $word (@words) { 57 | print "\t$word,\n"; 58 | } 59 | print "};\n\n"; 60 | 61 | print "#define FDT_INIT() do { \\\n"; 62 | for my $i (sort { $a <=> $b } keys %relocs) { 63 | next if ($i % 4); 64 | print "\tfdt[$i/4] = $relocs{$i}; \\\n"; 65 | } 66 | print "} while(0)\n\n"; 67 | 68 | # This script takes an FDT template, in modified DTS syntax, as input, 69 | # and produces C code which will produce the corresponding FDT binary 70 | # tree at runtime, with substitutions of ${}-expressions. So you can write: 71 | # 72 | # memory { reg = <0 0 ${BIGMEM ? 8 : 4} 0}; }; 73 | # 74 | # and you get a variable called "fdt" which represents the device 75 | # tree's static data, and a macro called "FDT_INIT()" which modifies 76 | # the appropriate elements of fdt to produce either "reg = <0 0 8 0>" 77 | # or "reg = <0 0 4 0>". 78 | # 79 | # The reason for its existence is the Apple M1 SOC platform, which 80 | # requires glue code to set up a minimal FDT based on iBoot's hand-off 81 | # data before launching the kernel proper. 82 | # 83 | # It's limited to replacing 32-bit words (but runs the input through 84 | # CPP so macros can help with that), and it can only handle 254 85 | # replacements. 86 | -------------------------------------------------------------------------------- /local/dtc-relocs/dtc-relocs.mk: -------------------------------------------------------------------------------- 1 | %.dts.h: %.dts local/dtc-relocs/dtc-relocs 2 | gcc -E -x assembler-with-cpp -nostdinc $< | local/dtc-relocs/dtc-relocs > $@ 3 | -------------------------------------------------------------------------------- /local/initramfs/build-cpiospec.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | my %paths; 3 | while () { 4 | chomp; 5 | my $key = $_; 6 | for my $prefix (@ARGV) { 7 | if (substr($key, 0, length($prefix)) eq $prefix) { 8 | $key = substr($key, length($prefix)); 9 | } 10 | } 11 | $paths{$key} = $_; 12 | } 13 | 14 | my $didsomething = 1; 15 | while ($didsomething) { 16 | $didsomething = 0; 17 | for my $path (sort keys %paths) { 18 | my $dir = $path; 19 | $dir =~ s/\/[^\/]*$//; 20 | next if (exists $paths{$dir} or ($dir eq "/usr") or ($dir eq "/local")); 21 | $paths{$dir} = "/"; 22 | $didsomething = 1; 23 | } 24 | } 25 | 26 | print "dir / 755 0 0\n"; 27 | print "slink /usr / 755 0 0\n"; 28 | print "slink /local / 755 0 0\n"; 29 | 30 | for my $key (sort { $a cmp $b } keys %paths) { 31 | next if $key eq "" or $key eq "/usr" or $key eq "/local"; 32 | if ($paths{$key} eq "/" or -d $paths{$key}) { 33 | print "dir $key 755 0 0\n"; 34 | } elsif (-l $paths{$key}) { 35 | print "slink $key " . readlink($paths{$key}) . " 755 0 0\n"; 36 | } elsif (-x $paths{$key}) { 37 | print "file $key " . $paths{$key} . " 755 0 0\n"; 38 | } else { 39 | print "file $key " . $paths{$key} . " 644 0 0\n"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /local/initramfs/initramfs.mk: -------------------------------------------------------------------------------- 1 | # XXX this currently makes all files executable 2 | 3 | $(BUILD)/linux/pearl.cpio: $(BUILD)/initramfs/pearl.cpio ; $(SYMLINK) 4 | $(BUILD)/linux/debian.cpio: $(BUILD)/initramfs/debian.cpio ; $(SYMLINK) 5 | $(BUILD)/initramfs/%: local/initramfs/% ; $(COPY) 6 | $(BUILD)/initramfs/pearl.cpiospec: local/initramfs/pearl.cpiospec $(call done,userspace,install) local/initramfs/build-cpiospec.pl 7 | $(MKDIR) $(dir $@) 8 | @(cat $<; (ls $(wordlist 4,$(words $^),$^); find $(BUILD)/pearl/install/ -type f -o -type l) | LC_ALL=C perl local/initramfs/build-cpiospec.pl $(BUILD)/pearl/install $(BUILD)/initramfs/pearl) > $@ 9 | 10 | $(BUILD)/initramfs/%.cpio: $(BUILD)/initramfs/%.cpiospec $(call done,linux,checkout) | $(BUILD)/initramfs/ 11 | (cd $(BUILD)/linux/linux/build/; ./usr/gen_initramfs.sh -o $@ $<) 12 | 13 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/stage2.image 14 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/stage2.dtb 15 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/stage2.modules 16 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/stage2-j313.dtb 17 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/stage2-j293.dtb 18 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/stage2-j274.dtb 19 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/linux.image 20 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/linux.dtb 21 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/linux-j313.dtb 22 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/linux-j293.dtb 23 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/linux-j274.dtb 24 | $(BUILD)/initramfs/pearl.cpiospec: $(BUILD)/initramfs/pearl/boot/linux.modules 25 | 26 | $(BUILD)/initramfs/pearl/boot/stage2.image: $(BUILD)/linux/stage2.image ; $(COPY) 27 | $(BUILD)/initramfs/pearl/boot/linux.image: $(BUILD)/linux/linux.image ; $(COPY) 28 | 29 | $(BUILD)/initramfs/pearl/boot/stage2.dtb: $(BUILD)/linux/stage2.dtb ; $(COPY) 30 | $(BUILD)/initramfs/pearl/boot/stage2.modules: $(BUILD)/linux/stage2.modules ; $(COPY) 31 | $(BUILD)/initramfs/pearl/boot/stage2-j313.dtb: $(BUILD)/linux/stage2-j313.dtb ; $(COPY) 32 | $(BUILD)/initramfs/pearl/boot/stage2-j293.dtb: $(BUILD)/linux/stage2-j293.dtb ; $(COPY) 33 | $(BUILD)/initramfs/pearl/boot/stage2-j274.dtb: $(BUILD)/linux/stage2-j274.dtb ; $(COPY) 34 | $(BUILD)/initramfs/pearl/boot/linux.dtb: $(BUILD)/linux/linux.dtb ; $(COPY) 35 | $(BUILD)/initramfs/pearl/boot/linux-j313.dtb: $(BUILD)/linux/linux-j313.dtb ; $(COPY) 36 | $(BUILD)/initramfs/pearl/boot/linux-j293.dtb: $(BUILD)/linux/linux-j293.dtb ; $(COPY) 37 | $(BUILD)/initramfs/pearl/boot/linux-j274.dtb: $(BUILD)/linux/linux-j274.dtb ; $(COPY) 38 | $(BUILD)/initramfs/pearl/boot/linux.modules: $(BUILD)/linux/linux.modules ; $(COPY) 39 | 40 | $(BUILD)/initramfs/debian.cpiospec: $(BUILD)/initramfs/pearl.cpiospec $(BUILD)/debian/debootstrap/stage15.tar 41 | cat $< > $@ 42 | echo "dir /debian 755 0 0" >> $@ 43 | echo "file /debian/debian.tar $(BUILD)/debian/debootstrap/stage15.tar 644 0 0" >> $@ 44 | 45 | # $(BUILD)/initramfs/list.mk: $(call done,userspace,install) | $(BUILD)/initramfs/ 46 | # (cd $(BUILD)/pearl/install; find * -type f) | sed -e 's/:/\\\\:/g' | while read FILE; \ 47 | # do \ 48 | # echo "\$$(BUILD)/initramfs/pearl.cpio: \$$(BUILD)/userspace/install/$$FILE"; \ 49 | # done > $@ 50 | 51 | # -include $(BUILD)/initramfs/list.mk 52 | 53 | SECTARGETS += $(BUILD)/linux/pearl.cpio 54 | SECTARGETS += $(BUILD)/initramfs/pearl.cpio 55 | SECTARGETS += $(BUILD)/initramfs/pearl.cpiospec 56 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/stage2.image 57 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/stage2.dtb 58 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/stage2.modules 59 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/stage2-j313.dtb 60 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/stage2-j293.dtb 61 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/stage2-j274.dtb 62 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/linux.image 63 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/linux.dtb 64 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/linux-j313.dtb 65 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/linux-j293.dtb 66 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/linux-j274.dtb 67 | SECTARGETS += $(BUILD)/initramfs/pearl/boot/linux.modules 68 | -------------------------------------------------------------------------------- /local/initramfs/pearl.cpiospec: -------------------------------------------------------------------------------- 1 | dir dev 755 0 0 2 | dir bin 755 0 0 3 | nod dev/mem 644 0 0 c 1 1 4 | nod dev/null 644 0 0 c 1 3 5 | nod dev/zero 644 0 0 c 1 5 6 | nod dev/console 644 0 0 c 5 1 7 | nod dev/tty1 644 0 0 c 4 1 8 | nod dev/tty2 644 0 0 c 4 2 9 | nod dev/tty3 644 0 0 c 4 3 10 | nod dev/tty4 644 0 0 c 4 4 11 | slink bin/sh busybox 777 0 0 12 | -------------------------------------------------------------------------------- /local/interactor/interactor.mk: -------------------------------------------------------------------------------- 1 | $(call pearl-static,$(wildcard $(PWD)/local/interactor/pearl/bin/*),$(PWD)/local/interactor/pearl) 2 | -------------------------------------------------------------------------------- /local/interactor/pearl/bin/interactor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | STAGE=$(cat /persist/stage) 3 | mkdir -p /etc /run /dev/pts 4 | echo "root:x:0:0:root:/:/bin/sh" >> /etc/passwd 5 | mount -t devpts devpts /dev/pts 6 | ln -sf pts/ptmx /dev 7 | 8 | mkdir -p /var/help 9 | echo "booted" "$(cat /persist/stage)" of "$(/bin/adtdump --macho-header|/bin/macho-version)" > /var/help/001-title 10 | echo "stage1 " "$(cat /persist/stage1-uname.txt)" >> /var/help/001-title 11 | echo "running" "$(uname -a)" >> /var/help/001-title 12 | 13 | cat > /bin/help < /var/help/008-heartbeat; 16 | for a in /var/help/*; do 17 | cat \$a 18 | echo 19 | done 20 | EOF 21 | 22 | chmod u+x /bin/help 23 | 24 | cat > .screenrc < /proc/sys/kernel/printk 54 | 55 | while sleep 1m; do screen -X redisplay; done & 56 | screen -c .screenrc 57 | sh 58 | 59 | touch /noboot 60 | cat > /var/help/050-shell < /var/last-button 3 | 4 | while true; do 5 | MENUFILE="/var/menu" 6 | STAGE="$(cat /persist/stage)" 7 | > "$MENUFILE" 8 | LAST_COMMAND="$([ -e /var/last-button ] && cat /var/last-button)" 9 | echo "dialog --output-fd 3 --cr-wrap \\" >> "$MENUFILE" 10 | if [ "x$LAST_COMMAND" != "x" ]; then 11 | echo "--default-item \"$LAST_COMMAND\" \\" >> "$MENUFILE" 12 | fi 13 | echo "--menu 'User-Friendly Menu (* marks broken options)' 0 0 0 \\" >> "$MENUFILE" 14 | echo "' 'shell 'Shell prompt' \\" >> "$MENUFILE" 15 | echo "' 'dmesg 'Kernel messages' \\" >> "$MENUFILE" 16 | echo "' 'linux 'Boot Linux' \\" >> "$MENUFILE" 17 | if [ "$STAGE" != "stage2" ]; then 18 | echo "' 'stage2 'enter stage2' \\" >> "$MENUFILE" 19 | fi 20 | if [ "$STAGE" != "stage3" ]; then 21 | echo "' 'stage3 'enter stage3' \\" >> "$MENUFILE" 22 | fi 23 | echo "' 'm1n1 'launch m1n1' \\" >> "$MENUFILE" 24 | echo "' 'u-boot 'launch U-Boot' \\" >> "$MENUFILE" 25 | echo "'*'grub 'launch grub' \\" >> "$MENUFILE" 26 | echo "' 'barebox 'launch barebox' \\" >> "$MENUFILE" 27 | echo "'*'macos 'launch macOS' \\" >> "$MENUFILE" 28 | if [ "$STAGE" = "stage2" ]; then 29 | echo "' 'stage2 're-enter stage2' \\" >> "$MENUFILE" 30 | fi 31 | if [ "$STAGE" = "stage3" ]; then 32 | echo "' 'stage3 're-enter stage3' \\" >> "$MENUFILE" 33 | fi 34 | [ "$(cat /persist/stage)" = "stage2" ] && 35 | echo "' 'gadget '(re)start USB gadget' \\" >> "$MENUFILE" 36 | [ "$(cat /persist/stage)" = "stage3" ] && 37 | echo "'*'wifi '(re)start WiFi gadget' \\" >> "$MENUFILE" 38 | echo "' 'x8r8g8b8 'fix framebuffer colors' \\" >> "$MENUFILE" 39 | echo "' 'x2r10g10b10 'break framebuffer colors' \\" >> "$MENUFILE" 40 | echo "' 'dwc3 'reload dwc3 driver' \\" >> "$MENUFILE" 41 | echo "' 'enable-wdt 'enable the Watchdog Timer (will reboot)' \\" >> "$MENUFILE" 42 | echo "'*'reboot 'reboot immediately' \\" >> "$MENUFILE" 43 | echo "' 'reboot-wdt 'reboot immediately using WDT' \\" >> "$MENUFILE" 44 | echo "' 'reboot-recovery 'reboot to Recovery Mode using WDT' \\" >> "$MENUFILE" 45 | echo "LAST_COMMAND $LAST_COMMAND" >> /last-command-log 46 | echo "" >> "$MENUFILE" 47 | echo "> /var/menu" >> "$MENUFILE" 48 | 49 | sh /var/menu "$([ -e /var/last-button ] && cat /var/last-button)" 3> /var/dialog-response 50 | rm /var/menu 51 | COMMAND="$(cat /var/dialog-response)" 52 | echo "$COMMAND" > /var/last-button 53 | COMMAND="$(echo "$COMMAND"|sed -e 's/^.//')" 54 | echo "Currently executing command $COMMAND" > /var/help/002-state 55 | if [ "$COMMAND"x = x ]; then 56 | true 57 | elif [ "$COMMAND" = "shell" ]; then 58 | screen -X focus bottom 59 | elif [ "$COMMAND" = "stage2" ]; then 60 | $COMMAND 61 | elif [ "$COMMAND" = "stage3" ]; then 62 | $COMMAND 63 | elif [ "$COMMAND" = "linux" ]; then 64 | $COMMAND 65 | elif [ "$COMMAND" = "m1n1" ]; then 66 | $COMMAND 67 | elif [ "$COMMAND" = "u-boot" ]; then 68 | $COMMAND 69 | elif [ "$COMMAND" = "grub" ]; then 70 | $COMMAND 71 | elif [ "$COMMAND" = "macos" ]; then 72 | $COMMAND 73 | elif [ "$COMMAND" = "gadget" ]; then 74 | $COMMAND 75 | elif [ "$COMMAND" = "wifi" ]; then 76 | $COMMAND 77 | elif [ "$COMMAND" = "x8r8g8b8" ]; then 78 | $COMMAND 79 | elif [ "$COMMAND" = "x2r10g10b10" ]; then 80 | $COMMAND 81 | elif [ "$COMMAND" = "enable-wdt" ]; then 82 | $COMMAND 83 | elif [ "$COMMAND" = "dwc3" ]; then 84 | DEVS="$(cd /sys/bus/platform/drivers/dwc3; echo *.dwc3)" 85 | DEVS="$DEVS 502280000.dwc3" 86 | for dev in $DEVS; do 87 | cd /sys/bus/platform/drivers/dwc3; echo $dev > unbind 88 | done 89 | for dev in $DEVS; do 90 | cd /sys/bus/platform/drivers/dwc3; echo $dev > bind 91 | done 92 | elif [ "$COMMAND" = "reboot" ]; then 93 | $COMMAND 94 | elif [ "$COMMAND" = "reboot-wdt" ]; then 95 | $COMMAND 96 | elif [ "$COMMAND" = "reboot-recovery" ]; then 97 | $COMMAND 98 | elif [ "$COMMAND" = "barebox" ]; then 99 | $COMMAND 100 | elif [ "$COMMAND" = "dmesg" ]; then 101 | dmesg > /var/dmesg 102 | dialog --textbox /var/dmesg 0 0 103 | rm /var/dmesg 104 | fi; 105 | (sleep 3 && rm -f /var/help/002-state) & 106 | done 107 | -------------------------------------------------------------------------------- /local/interactor/pearl/bin/interactor-perl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use IPC::Run qw(run); 4 | use File::Slurp qw(write_file read_file); 5 | 6 | my %broken = { 7 | reboot => 1, 8 | grub => 1, 9 | macos => 1, 10 | }; 11 | 12 | sub switch_to_shell { 13 | run(["screen", "-X", "focus", "bottom"]); 14 | } 15 | 16 | sub dialog { 17 | my ($title, $entries) = @_; 18 | my @entries = @$entries; 19 | my @args; 20 | my $response; 21 | 22 | while (@entries) { 23 | my $tag = shift @entries; 24 | my $desc = shift @entries; 25 | 26 | push @args, ((($broken{$tag}) ? "*" : " ") . $tag); 27 | push @args, $desc; 28 | } 29 | run(["dialog", "--output-fd", "3", "--menu", $title, 0, 0, 0, 30 | @args], '3>', \$response); 31 | 32 | system("touch /interactive") if $response; 33 | 34 | return $response = substr($response, 1); 35 | } 36 | 37 | sub dialog_booting { 38 | my $title = "Boot Menu"; 39 | my @entries = 40 | (stage3 => "(re)enter stage3", 41 | stage2 => "(re)enter stage2", 42 | m1n1 => "launch m1n1", 43 | barebox => "launch barebox", 44 | "u-boot" => "launch U-Boot", 45 | grub => "launch GRUB", 46 | macos => "boot macOS", 47 | linux => "boot Linux", 48 | rootshell => "enter stage3 with an init root shell", 49 | ); 50 | 51 | my $response = dialog($title, \@entries); 52 | 53 | system($response); 54 | } 55 | 56 | sub dialog_hardware { 57 | my $title = "Hardware Menu"; 58 | my @entries = 59 | (gadget => "(re)start USB gadget", 60 | wifi => "(re)start WiFi", 61 | "x8r8g8b8" => "fix framebuffer colors", 62 | "undim-framebuffer" => "increase panel backlight to max", 63 | "x2r10g10b10" => "break framebuffer colors", 64 | dwc3 => "re-initialize USB", 65 | nvme => "initialize NVMe", 66 | "enable-wdt", "enable Watchdog Timer", 67 | "reboot", "reboot immediately", 68 | "reboot-wdt", "reboot immediately using WDT", 69 | "reboot-recovery", "reboot to Recovery Mode using WDT", 70 | "poweroff", "shut down system"); 71 | 72 | my $response = dialog($title, \@entries); 73 | 74 | system($response); 75 | } 76 | 77 | sub dialog_info { 78 | my $title = "Info Menu"; 79 | my @entries = 80 | (uname => `uname -a`, 81 | dmesg => "kernel messages", 82 | uptime => `cat /proc/uptime`); 83 | 84 | my $response = dialog($title, \@entries); 85 | 86 | if ($response eq "dmesg") { 87 | my $dmesg; 88 | run(["dmesg"], '>', \$dmesg); 89 | write_file("/var/dmesg", $dmesg); 90 | run(["dialog", "--textbox", "/var/dmesg", 0, 0]) 91 | } 92 | if ($response eq "uname") { 93 | my $uname; 94 | run(["uname", "-a"], '>', \$uname); 95 | write_file("/var/dmesg", $uname); 96 | run(["dialog", "--textbox", "/var/dmesg", 0, 0]) 97 | } 98 | } 99 | 100 | sub dialog_main { 101 | my $title = "User-Friendly Menu (* marks broken options)"; 102 | my @entries = 103 | (shell => "Shell prompt - Ctrl-D to return", 104 | booting => "Booting", 105 | hardware => "Hardware", 106 | info => "Information"); 107 | unshift @entries, (debian => "Continue to Debian"); 108 | unshift @entries, (installer => "Install Debian"); 109 | unshift @entries, (final => "Boot final stage of Linux"); 110 | my %next = 111 | (installer => sub { run(["installer"]) }, 112 | debian => sub { run(["debian"]) }, 113 | final => sub { run(["final"]) }, 114 | shell => \&switch_to_shell, 115 | linux => sub { run(["linux"]) }, 116 | booting => \&dialog_booting, 117 | hardware => \&dialog_hardware, 118 | info => \&dialog_info); 119 | my $response = dialog($title, \@entries); 120 | 121 | $next{$response}->(); 122 | } 123 | 124 | while (1) { 125 | dialog_main; 126 | } 127 | -------------------------------------------------------------------------------- /local/interactor/pearl/bin/once-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | while true; 3 | do 4 | /bin/sh 5 | screen -X 'focus' 'top' 6 | done 7 | -------------------------------------------------------------------------------- /local/local.mk: -------------------------------------------------------------------------------- 1 | include local/dtc-relocs/dtc-relocs.mk 2 | include local/dt/dt.mk 3 | include local/initramfs/initramfs.mk 4 | include local/interactor/interactor.mk 5 | include local/sendfile/sendfile.mk 6 | include local/memdump/memdump.mk 7 | -------------------------------------------------------------------------------- /local/memdump/boot.c: -------------------------------------------------------------------------------- 1 | #include "snippet.h" 2 | 3 | #include 4 | #include 5 | typedef unsigned long u64; 6 | typedef unsigned u32; 7 | 8 | extern void macho_entry(void *) __attribute__((noreturn)); 9 | 10 | struct memdump_args { 11 | unsigned long header[10]; 12 | void *current_base; 13 | void *bootargs; 14 | void *original_base; 15 | unsigned long length_of_header; 16 | unsigned long length_of_memdump; 17 | typeof(&macho_entry) entry; 18 | }; 19 | 20 | static inline void memmove(void *p, void *q, size_t len) 21 | { 22 | unsigned __int128 *p128 = p; 23 | unsigned __int128 *q128 = q; 24 | 25 | len += 15; 26 | len /= 16; 27 | if (p128 < q128) 28 | while (len--) 29 | *p128++ = *q128++; 30 | else 31 | while (len--) 32 | p128[len] = q128[len]; 33 | } 34 | 35 | static inline void memset(void *p, unsigned long pattern64, size_t len) 36 | { 37 | unsigned __int128 *p128 = p; 38 | unsigned __int128 pattern = pattern64; 39 | pattern <<= 64; 40 | pattern += pattern64; 41 | len += 15; 42 | len /= 16; 43 | while (len--) 44 | *p128++ = pattern; 45 | } 46 | 47 | void boot_memdump(struct memdump_args *args) 48 | __attribute__((noreturn)); 49 | 50 | void boot_memdump(struct memdump_args *args) 51 | { 52 | memmove(args->original_base, args->current_base + args->length_of_header, 53 | args->length_of_memdump); 54 | asm volatile("isb"); 55 | args->entry(args->bootargs); 56 | } 57 | -------------------------------------------------------------------------------- /local/memdump/image.S: -------------------------------------------------------------------------------- 1 | 0: 2 | nop 3 | b primary_entry 4 | .quad 0 5 | .quad 256 * 1024 * 1024 // image size, to be fixed by code 6 | .quad 0 7 | .quad 0 8 | .quad 0 9 | .quad 0 10 | .ascii "ARMd" 11 | .long 0xe 12 | primary_entry: 13 | isb 14 | b 1f 15 | .align 4 16 | current_base: 17 | .ascii "currbase" 18 | bootargs: 19 | .ascii "bootargs" 20 | original_base: 21 | .ascii "origbase" 22 | length_of_header: 23 | .ascii "headrlen" 24 | length_of_memdump: 25 | .ascii "mdumplen" 26 | entry: 27 | .ascii "physpcst" 28 | 29 | adr x1, stack 30 | sub x1, x1, #16 31 | mov sp, x1 32 | bl 1f 33 | .p2align 12 34 | .rept 0x1000 35 | .byte 0 36 | .endr 37 | stack: 38 | 1: 39 | adr x0, 0b 40 | str x0, [x0, 0x50] 41 | -------------------------------------------------------------------------------- /local/memdump/memdump-to-image.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define PRELUDE_SIZE 256 * 1024 8 | 9 | typedef unsigned long long u64; 10 | typedef unsigned int u32; 11 | 12 | #define NULL ((void *)0) 13 | 14 | /* these strange includes are precompiled assembly snippets included 15 | as binary code in the (native) binaries. */ 16 | 17 | static 18 | #include "boot..h" 19 | ; 20 | 21 | static 22 | #include "image..h" 23 | ; 24 | 25 | extern void macho_entry(void *) __attribute__((noreturn)); 26 | 27 | struct memdump_args { 28 | unsigned long header[10]; 29 | void *current_base; 30 | void *bootargs; 31 | void *original_base; 32 | unsigned long length_of_header; 33 | unsigned long length_of_memdump; 34 | typeof(&macho_entry) entry; 35 | }; 36 | 37 | int main(int argc, char **argv) 38 | { 39 | const size_t prelude_size = PRELUDE_SIZE; 40 | if (argc != 6) { 41 | error: 42 | fprintf(stderr, "usage: %s \n", 43 | argv[0]); 44 | exit(1); 45 | } 46 | 47 | FILE *f = fopen(argv[1], "r"); 48 | if (!f) 49 | goto error; 50 | 51 | u64 bootargs = strtoll(argv[3], NULL, 0); 52 | u64 original_base = strtoll(argv[4], NULL, 0); 53 | u64 pc = strtoll(argv[5], NULL, 0); 54 | 55 | fseek(f, 0, SEEK_END); 56 | size_t memdump_size = ftell(f); 57 | fseek(f, 0, SEEK_SET); 58 | void *buf = malloc(prelude_size + memdump_size); 59 | if (!buf) 60 | goto error; 61 | 62 | memset(buf, 0, prelude_size + memdump_size); 63 | 64 | void *p = buf; 65 | memcpy(p, image, sizeof(image)); 66 | *((unsigned long *)p + 2) = prelude_size + memdump_size; 67 | p += sizeof(image); 68 | //memcpy(p, disable_timers, sizeof(disable_timers)); 69 | //p += sizeof(disable_timers); 70 | memcpy(p, boot, sizeof(boot)); 71 | p += sizeof(boot); 72 | 73 | struct memdump_args *args = buf; 74 | args->bootargs = (void *)bootargs; 75 | args->original_base = (void *)original_base; 76 | args->length_of_header = prelude_size; 77 | args->length_of_memdump = memdump_size; 78 | args->entry = (void*)pc; 79 | 80 | void *memdump = buf + prelude_size; 81 | assert(p <= memdump); 82 | 83 | fread(memdump, memdump_size, 1, f); 84 | fclose(f); 85 | f = fopen(argv[2], "w"); 86 | if (!f) 87 | goto error; 88 | fwrite(buf, 1, prelude_size + memdump_size, f); 89 | fclose(f); 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /local/memdump/memdump.mk: -------------------------------------------------------------------------------- 1 | $(BUILD)/memdump/bin/macho-to-memdump: local/memdump/macho-to-memdump | $(BUILD)/memdump/bin/ ; $(COPY) 2 | $(BUILD)/memdump/bin/memdump-to-image: local/memdump/memdump-to-image.c $(call deps,glibc gcc) | $(BUILD)/memdump/bin/ 3 | $(WITH_CROSS_PATH) $(WITH_CROSS_CC) $(CROSS_CC) -static -Os -I$(BUILD)/local/memdump -o $@ $< 4 | 5 | $(BUILD)/local/memdump/boot.c: local/memdump/boot.c 6 | $(COPY) 7 | 8 | $(BUILD)/local/memdump/image.S: local/memdump/image.S 9 | $(COPY) 10 | 11 | $(BUILD)/memdump/bin/memdump-to-image: $(BUILD)/local/memdump/boot..h 12 | $(BUILD)/memdump/bin/memdump-to-image: $(BUILD)/local/memdump/image..h 13 | 14 | $(call pearl-static,$(BUILD)/memdump/bin/memdump-to-image $(BUILD)/memdump/bin/macho-to-memdump,$(BUILD)/memdump) 15 | -------------------------------------------------------------------------------- /local/sendfile/receive-sendfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int main(void) 12 | { 13 | int fd = open("/commfile", O_RDWR); 14 | if (fd < 0) 15 | return -1; 16 | lseek(fd, 1024 * 1024, SEEK_SET); 17 | write(fd, "m1lli is ready and waiting\n", strlen("m1lli is ready and waiting\n")); 18 | lseek(fd, 0, SEEK_SET); 19 | write(fd, "m1lli is ready and waiting\n", strlen("m1lli is ready and waiting\n")); 20 | int seen_message = 0; 21 | while (true) { 22 | char buf[32]; 23 | unsigned long long size; 24 | if (pread(fd, buf, 32, 0) != 32) 25 | return -1; 26 | if (sscanf(buf, "%lld", &size) != 1) { 27 | sleep(1); 28 | continue; 29 | } 30 | if (!seen_message) { 31 | seen_message = 1; 32 | system("touch /interactive"); 33 | FILE *f = fopen("/var/help/002-state", "w"); 34 | if (f) { 35 | fprintf(f, "%ld-byte commfile being loaded\n", size - 32); 36 | fclose(f); 37 | } 38 | } 39 | if (pread(fd, buf, 32, size) != 32) 40 | return -1; 41 | if (strncmp(buf, "READY", 32) != 0) 42 | continue; 43 | char *data = malloc(size); 44 | if (!data) 45 | return -1; 46 | pread(fd, data, size - 32, 32); 47 | { 48 | FILE *f = fopen("/var/help/002-state", "w"); 49 | if (f) { 50 | fprintf(f, "%ld-byte commfile being booted\n", size - 32); 51 | fclose(f); 52 | } 53 | } 54 | if (strncmp(data, "#!/bin/zsh\n", strlen("#!/bin/zsh\n")) == 0) { 55 | FILE *f = popen("zsh", "w"); 56 | fwrite(data, 1, size - 32, f); 57 | fclose(f); 58 | return 0; 59 | } 60 | FILE *f = popen("tar xz", "w"); 61 | fwrite(data, 1, size - 32, f); 62 | fclose(f); 63 | if (system("/script")) { 64 | FILE *f = popen("zsh", "w"); 65 | fwrite(data, 1, size - 32, f); 66 | fclose(f); 67 | } 68 | return 0; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /local/sendfile/send-sendfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use File::Slurp qw(read_file); 3 | use Fcntl qw(SEEK_SET); 4 | use bytes; 5 | 6 | while (1) { 7 | my $data = read_file($ARGV[0]); 8 | for my $dev (glob "/sys/class/block/*") { 9 | $dev =~ s/^\/sys\/class\/block\///; 10 | if ($dev =~ /sd[a-z]/) { 11 | my $fh; 12 | open $fh, "+ $@ 14 | 15 | %.macho.sendfile: %.macho 16 | $(MKDIR) $@.d 17 | $(CP) $< $@.d 18 | (echo "#!/bin/sh"; echo "macho-to-memdump $$(basename $*.macho)"; echo "kexec --mem-min=0x900000000 -fix image") > $@.d/script 19 | chmod u+x $@.d/script 20 | tar -C $@.d -c . | gzip -1 > $@ 21 | 22 | %.macho.zsh: %.macho.pack 23 | cat $< > $@ 24 | (echo "#!/bin/zsh"; echo "macho-to-memdump /persist/$$(basename $*.macho)"; echo "kexec --mem-min=0x900000000 -fix image") >> $@ 25 | 26 | %.sendfile{send}: %.sendfile 27 | $(SUDO) local/sendfile/send-sendfile $< 28 | 29 | %.zsh{send}: %.zsh 30 | $(SUDO) local/sendfile/send-sendfile $< 31 | 32 | $(call pearl-static,$(BUILD)/pearl/bin/receive-sendfile,$(BUILD)/pearl) 33 | -------------------------------------------------------------------------------- /pearl.ditaa: -------------------------------------------------------------------------------- 1 | +---------------------------------------+ 2 | |pearl.pl cYEL 195MB | 3 | | +-------------------------------------+ 4 | | |kmutil-script cYEL 2KB | 5 | | +-------------------------------------+ 6 | | |readline.pm cYEL 133KB | 7 | | +-------------------------------------+ 8 | | |pearl.zst.image 195MB | 9 | | | +-----------------------------------+ 10 | | | |preboot code 80KB | 11 | | | +-----------------------------------+ 12 | | | |pearl.zst 195MB | 13 | | | |(decompresses to) 1079MB | 14 | | | | +---------------------------------+ 15 | | | | |pearl.macho 512MB | 16 | | | | | +-------------------------------+ 17 | | | | | |stage1 linux 100MB | 18 | | | | | +-------------------------------+ 19 | | | | | |stage1 initrd cpio 400MB | 20 | | | | +-+-------------------------------+ 21 | | | | |debian.cpio cGRE 512MB | 22 | | | | | +-------------------------------+ +------+----------------------------+ 23 | | | | | |debian files cGRE 480MB | | cYEL | used in Recovery Mode only | 24 | | | | | +-------------------------------+ +------+----------------------------+ 25 | | | | | |installer.cpio cGRE 40MB | | cGRE | used for Debian only | 26 | | +-+-+-+-------------------------------+ +------+----------------------------+ 27 | | |pack.bash cYEL 2KB | | | used for normal booting | 28 | +-+-------------------------------------+ +------+----------------------------+ 29 | 30 | 31 | +-------------------------------------+ 32 | |pearl.macho 230MB | 33 | | +-----------------------------------+ 34 | | |preboot code 80KB | 35 | | +-----------------------------------+ 36 | | |pearl.zst 195MB | 37 | | |(decompresses to) 1079MB | 38 | | | +---------------------------------+ 39 | | | |pearl.macho 512MB | 40 | | | | +-------------------------------+ 41 | | | | |stage1 linux 100MB | 42 | | | | +-------------------------------+ 43 | | | | |stage1 initrd cpio 400MB | 44 | | | +-+-------------------------------+ 45 | | | |debian.cpio cGRE 512MB | 46 | | | | +-------------------------------+ 47 | | | | |debian files cGRE 480MB | 48 | | | | +-------------------------------+ 49 | | | | |installer.cpio cGRE 40MB | 50 | | +-+-+-------------------------------+ 51 | | |wifi.tar.gz 11MB | 52 | +-+-----------------------------------+ 53 | 54 | +--------+ 55 | | preboot| 56 | +-+------+ 57 | | 58 | v 59 | +--------+ 60 | | stage1 | 61 | +-+------+ 62 | | 63 | | +-------+ 64 | | | | 65 | v v | 66 | +--------+ | 67 | | stage2 | : +--------+ 68 | +-+--+-+-+ | +-------->| m1n1 | 69 | | | | | : +--------+ 70 | | | +-------+ | 71 | | | | +--------+ +------+ 72 | | +--------------+-------->| U-Boot +---->| GRUB | 73 | | | +--------+ +------+ 74 | v + 75 | +-------+ | +--------+ 76 | | Linux | +-------->|barebox | 77 | +-------+ +--------+ -------------------------------------------------------------------------------- /pearl/bin/debian-init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /debootstrap/debootstrap --second-stage 3 | (cd /usr; tar xvf /persist/linux.modules) 4 | depmod -a 5 | yes x | passwd 6 | yes | adduser y 7 | mount -t proc proc proc 8 | mount -t sysfs sys sys 9 | mount -t debugfs debug sys/kernel/debug 10 | cd /sys/kernel/debug/kvbox/23e400000.smc_asc:smc_asc_smc@20/gP0d-ffffffff 11 | echo -ne '\x01\x00\x00\x00' > value 12 | cd /sys/bus/platform/drivers/pcie-apple 13 | for i in $(seq 1 16); do 14 | echo 690000000.pcie > bind 15 | sleep .1 16 | done 17 | cd /sys/bus/platform/drivers/apple-dart 18 | for i in $(seq 1 16); do 19 | echo 681008000.dart > bind 20 | sleep .1 21 | done 22 | for i in $(seq 1 16); do 23 | echo 682008000.dart > bind 24 | sleep .1 25 | done 26 | for i in $(seq 1 16); do 27 | echo 683008000.dart > bind 28 | sleep .1 29 | done 30 | cd /sys/bus/pci/drivers/tg3 31 | DEV="$(ls -d 0*)" 32 | echo $DEV > unbind 33 | echo $DEV > bind 34 | cd /sys/bus/pci/drivers/xhci_hcd 35 | DEV="$(ls -d 0*)" 36 | echo $DEV > unbind 37 | echo $DEV > bind 38 | mkdir -p /tmp/firmware 39 | tar -C /tmp/firmware -xf /persist/wifi.tar 40 | mkdir -p /lib/firmware/brcm 41 | for MODEL in j274 j293 j313; do 42 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/P-honshu_M-RASP_V-m__m-6.11.txt /lib/firmware/brcm/brcmfmac4378-pcie.apple,$MODEL.txt 43 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/honshu.txcb /lib/firmware/brcm/brcmfmac4378-pcie.txcb 44 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/honshu.clmb /lib/firmware/brcm/brcmfmac4378-pcie.clm_blob 45 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/honshu.trx /lib/firmware/brcm/brcmfmac4378-pcie.apple,$MODEL.bin 46 | done 47 | (cd /; tar c lib/firmware/brcm/brcmfmac4378*) > /persist/brcmfmac.tar 48 | MAC_ADDR=16 49 | for i in $(seq 1 5); do 50 | BYTE=$(($RANDOM%256)) 51 | MAC_ADDR=$MAC_ADDR$(printf "%02X" $BYTE) 52 | done 53 | modprobe brcmfmac nvram_mac_addr=$MAC_ADDR 54 | MAC_ADDR=16 55 | for i in $(seq 1 5); do 56 | BYTE=$(($RANDOM%256)) 57 | MAC_ADDR=$MAC_ADDR:$(printf "%02X" $BYTE) 58 | done 59 | ifconfig eth0 hw ether $MAC_ADDR 60 | sed -i -e 's/ExecStart.*/ExecStart=-\/sbin\/agetty -n -a root %I \$TERM/' /lib/systemd/system/getty\@.service 61 | sed -i -e 's/ExecStart.*/ExecStart=getty@ttyGS0.service/' /lib/systemd/system/getty-static 62 | cp /root/.profile /root/.profile.old 63 | if [ x"$(cat /persist/substage)" = x"installer" ]; then 64 | echo 'mkfifo /installer-fifo && echo launching installer in 15 seconds. Control-C to interrupt and get a shell instead. && sleep 15 && installer' >> /root/.profile 65 | else 66 | echo "nmtui" >> /root/.profile 67 | fi 68 | echo "mv /root/.profile.old /root/.profile" >> /root/.profile 69 | cat /root/.profile.old >> /root/.profile 70 | echo N > /sys/module/g_serial/parameters/enable 71 | echo Y > /sys/module/g_serial/parameters/enable 72 | systemctl enable serial-getty@ttyGS0.service 73 | exec /sbin/init 74 | -------------------------------------------------------------------------------- /pearl/bin/delay: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "$@" > /persist/timeout 3 | -------------------------------------------------------------------------------- /pearl/bin/enable-framebuffer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if test -e /nofb; then 3 | rm /nofb 4 | exit 5 | fi 6 | if ! grep -q 'dance = <0x01>' /persist/dcp.dtp; then 7 | x8r8g8b8 8 | exit 9 | fi 10 | tar xf /boot/stage2.modules 11 | depmod -a 12 | echo 0 > /sys/bus/platform/drivers_autoprobe 13 | modprobe apple_mailbox ; sleep 1 14 | echo 231c08000.dcp_mbox > /sys/bus/platform/drivers/apple-mailbox/bind 15 | modprobe apple_asc_mgmt ; sleep 1 16 | echo 231c00000.remoteproc > /sys/bus/platform/drivers/apple-asc/bind 17 | echo 231c00000.remoteproc:dcp_asc_mgmt@0 > /sys/bus/platform/drivers/apple-asc-mgmt/bind 18 | modprobe apple_asc_panic ; sleep 1 19 | echo 231c00000.remoteproc:dcp_asc_panic@1 > /sys/bus/platform/drivers/apple-asc-panic/bind 20 | modprobe apple_asc_syslog ; sleep 1 21 | echo 231c00000.remoteproc:dcp_asc_syslog@2 > /sys/bus/platform/drivers/apple-asc-syslog/bind 22 | modprobe apple_asc_iorpt ; sleep 1 23 | echo 231c00000.remoteproc:dcp_asc_ioreport@4 > /sys/bus/platform/drivers/apple-asc-ioreport/bind 24 | modprobe apple_asc_initonly; sleep 1 25 | echo 231c00000.remoteproc:dcp_asc_oslog@8 > /sys/bus/platform/drivers/apple-asc-initonly/bind 26 | modprobe apple_asc_dcp ; sleep 1 27 | echo 231c00000.remoteproc:dcp_asc_dcp@37 > /sys/bus/platform/drivers/apple-asc-dcp/bind 28 | modprobe apple-dcp-display & sleep 1 29 | echo 231c00000.remoteproc:dcp_asc_dcp@37:apple_dcp > /sys/bus/platform/drivers/apple-dcp/bind 30 | modprobe apple-dcp-fb & sleep 1 31 | echo 231c00000.remoteproc:dcp_asc_dcp@37:apple_dcp:apple_dcp_fb > /sys/bus/platform/drivers/apple-dcp-fb/bind 32 | echo 231c00000.remoteproc:dcp_asc_dcp@37:apple_dcp:apple_dcp_display > /sys/bus/platform/drivers/apple-dcp-display/bind 33 | egrep -v '\.dcp'< /boot/linux.dtp > /boot/linux.dtp.new 34 | -------------------------------------------------------------------------------- /pearl/bin/enable-wdt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | memtool mw 0x23d2b0010 0 720000000 0 4 -------------------------------------------------------------------------------- /pearl/bin/final: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm /commfile 3 | cp /boot/linux.modules /persist 4 | cd / 5 | chmod a+x init 6 | rm -f /persist/payload 7 | echo final > /persist/stage 8 | echo "$@" > /persist/substages 9 | cd / 10 | egrep -v 'persist' /file.list > /file.list.new 11 | mv /file.list.new /file.list 12 | find /persist >> /file.list 13 | dt dtb-to-dtp /boot/linux.dtb /boot/linux.dtp 14 | dt permallocs >> /boot/linux.dtp 15 | # egrep -v '\.dcp' < /boot/linux.dtp > /boot/linux.dtp.new 16 | # mv /boot/linux.dtp.new /boot/linux.dtp 17 | # sed -e 's/host\|dual-role/gadget/g' < /boot/linux.dtp > /boot/linux.dtp.new 18 | # mv /boot/linux.dtp.new /boot/linux.dtp 19 | dt dtp-to-dtb /boot/linux.dtp /boot/linux.dtb 20 | if [ -e /persist/emulated ]; then cp /sys/firmware/fdt /boot/linux.dtb; fi 21 | cat /file.list | cpio -H newc -o > /boot/linux.cpio 22 | /bin/kexec --mem-min=`dt mem-min` -fix /boot/linux.image --dtb=/boot/linux.dtb --ramdisk=/boot/linux.cpio --command-line="clk_ignore_unused" 23 | -------------------------------------------------------------------------------- /pearl/bin/gadget-mode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | -e "/boot/fixed.dtp" || exit 0; 3 | for my $arg (@ARGV) { 4 | my $fh; 5 | my $ofh; 6 | open $fh, "/boot/fixed-stage2.dtp.new"; 8 | while (<$fh>) { 9 | chomp; 10 | s/^(soc\.usb${arg}\@(.*?)) = \"(dual-role|host)\"$/$1 = "gadget"/; 11 | s/^(soc(.*?)hpm${arg}\@(.*?)) = \"(dual-role|host)\"$/$1 = "gadget"/; 12 | print $ofh "$_\n"; 13 | } 14 | system("mv /boot/fixed-stage2.dtp.new /boot/fixed-stage2.dtp"); 15 | } 16 | -------------------------------------------------------------------------------- /pearl/bin/in-stage2: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ x"$(cat /persist/stage)" = xstage2 ]; then 3 | $@ 4 | else 5 | echo "$@" >> /persist/stage2.zsh 6 | fi 7 | -------------------------------------------------------------------------------- /pearl/bin/init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | /bin/busybox find / > file.list 3 | /bin/busybox --list | while read TARGET; do busybox ln -sf busybox bin/$TARGET; done 4 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin 5 | tar xf /deb.tar 6 | ln -sf /proc/self/fd/0 /dev/stdin 7 | mkdir -p boot proc sys tmp persist 8 | mount -t proc proc proc 9 | mount -t sysfs sys sys 10 | if [ -e persist/stage ]; then 11 | stage=$(cat persist/stage) 12 | else 13 | stage=stage1 14 | fi 15 | exec bin/init-$stage 16 | -------------------------------------------------------------------------------- /pearl/bin/init-final: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SUBSTAGES="$(cat /persist/substages)" 3 | if [ x"$SUBSTAGES" = x"" ]; then 4 | if [ -e /persist/root ]; then 5 | SUBSTAGES="root installer" 6 | else 7 | SUBSTAGES="root debian" 8 | fi 9 | fi 10 | [ -e /persist/emulated ] || linux-init 11 | while true; do 12 | for SUBSTAGE in $SUBSTAGES root debian; do 13 | echo "$SUBSTAGE" > /persist/substage 14 | if [ "$SUBSTAGE" = "root" ]; then 15 | exec init-final-root 16 | elif [ "$SUBSTAGE" = "installer" ] || [ "$SUBSTAGE" = "debian" ]; then 17 | exec init-final-"$SUBSTAGE" 18 | elif [ "$SUBSTAGE" = "shell" ]; then 19 | exec init-final-shell 20 | fi 21 | done 22 | done 23 | -------------------------------------------------------------------------------- /pearl/bin/init-final-debian: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir /debian 3 | mount -t ramfs debian /debian 4 | echo "uncompressing Debian filesystem" 5 | dt extract-payload /persist/payload /persist/debian.cpio 6 | cat /persist/debian.cpio | (cd /debian; cpio -id) 7 | rm -f /persist/debian.cpio 8 | cp -a /persist /debian/persist/ 9 | cp /bin/debian-init /debian/init 10 | chmod a+x /debian/init 11 | (test -e /debian/init || test -l /debian/init) && exec switch_root /debian /init 12 | -------------------------------------------------------------------------------- /pearl/bin/init-final-installer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec init-final-debian 3 | -------------------------------------------------------------------------------- /pearl/bin/init-final-root: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir /mnt 3 | mount -t proc proc /proc 4 | mount -t sysfs sys /sys 5 | mount -t devtmpfs dev /dev 6 | mount -t configfs config /sys/kernel/config 7 | mount -t debugfs debug /sys/kernel/debug 8 | cp modules.tar /persist 9 | cd / 10 | tar xf /boot/linux.modules 11 | cp /boot/linux.modules /persist 12 | count=1 13 | while true; do 14 | ROOT=$(cat /persist/root 2>/dev/null || /dev/debian) 15 | ([ -x /mnt/sbin/init ] || [ -L /mnt/sbin/init ]) && mkdir -p /mnt/persist && cp persist/* /mnt/persist && (cd /mnt; tar x) < /persist/brcmfmac.tar && (cd /mnt; cd usr; tar x) < /persist/linux.modules && (cp /persist/brcmfmac.conf /mnt/etc/modprobe.d/) && sync && exec switch_root /mnt /sbin/init 16 | mount $ROOT /mnt -o subvol='@rootfs' && continue 17 | mount $ROOT /mnt && continue 18 | PRECOUNT=$(ls /dev|wc -l) 19 | vgchange -ay 20 | POSTCOUNT=$(ls /dev|wc -l); 21 | if [ "$PRECOUNT" != "$POSTCOUNT" ]; then 22 | continue 23 | fi 24 | (cd /sys/class/block; for DM in $(ls -d dm-*); do 25 | NAME=$(cat $DM/dm/name) 26 | ln -sf $DM /dev/$NAME 27 | if ! [ -e /dev/$NAME-decrypted ] && cryptsetup isLuks /dev/$NAME; then 28 | cryptsetup open /dev/$NAME $NAME-decrypted && continue 29 | fi 30 | done) 31 | if [ $count -gt 10 ]; then 32 | break 33 | fi 34 | count=$(($count + 1)) 35 | done 36 | -------------------------------------------------------------------------------- /pearl/bin/init-final-shell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec /bin/sh -i 3 | -------------------------------------------------------------------------------- /pearl/bin/init-linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir mnt 3 | mount -t proc proc /proc 4 | mount -t sysfs sys /sys 5 | mount -t devtmpfs dev /dev 6 | mount -t configfs config /sys/kernel/config 7 | mount -t debugfs debug /sys/kernel/debug 8 | linux-init 9 | cp modules.tar /persist 10 | cd / 11 | tar xf /boot/linux.modules 12 | cp /boot/linux.modules /persist 13 | count=1; 14 | while true; do 15 | ROOT=$(cat /persist/root 2>/dev/null || /dev/debian) 16 | ([ -x /mnt/sbin/init ] || [ -L /mnt/sbin/init ]) && mkdir -p /mnt/persist && cp persist/* /mnt/persist && sync && exec switch_root /mnt /sbin/init 17 | mount $ROOT /mnt && continue 18 | vgchange -ay 19 | (cd /sys/class/block; for DM in $(ls -d dm-*); do 20 | NAME=$(cat $DM/dm/name) 21 | ln -sf $DM /dev/$NAME 22 | [ -e /dev/$NAME-decrypted ] || cryptsetup open /dev/$NAME $NAME-decrypted; 23 | done) 24 | if [ $count -gt 10 ]; then 25 | /bin/sh 26 | fi 27 | count=$(($count + 1)) 28 | done 29 | -------------------------------------------------------------------------------- /pearl/bin/init-rootshell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec /bin/ash 3 | -------------------------------------------------------------------------------- /pearl/bin/init-shell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir mnt 3 | mount -t proc proc /proc 4 | mount -t sysfs sys /sys 5 | mount -t devtmpfs dev /dev 6 | mount -t configfs config /sys/kernel/config 7 | mount -t debugfs debug /sys/kernel/debug 8 | cp modules.tar /persist 9 | cd / 10 | tar xf /boot/linux.modules 11 | # sleep 1; memtool md 0xbfff80000 12 | # sleep 1; memtool md 0xbfff84000 13 | # sleep 1; memtool md 0xbfff88000 14 | # sleep 10 15 | # sleep 1; memtool mw -q 0x231c08800 0x0060000000000220 0 16 | # sleep 1; memtool md -q 0x231c08830+16 17 | # sleep 1; memtool mw -q 0x231c08800 0x00200001000b000b 0 18 | # sleep 1; memtool md -q 0x231c08830+16 19 | # sleep 1; memtool mw -q 0x231c08800 0x008000000000001f 0 20 | # sleep 1; memtool md -q 0x231c08830+16 21 | # sleep 1; memtool mw -q 0x231c08800 0x0088000100803fff 0 22 | # sleep 1; memtool md -q 0x231c08830+16 23 | # sleep 1; memtool md -q 0x231c08830+16 24 | # sleep 1; memtool md -q 0x231c08830+16 25 | # sleep 1; memtool mw -q 0x231c08800 0x0050003700000002 0 26 | # sleep 1; memtool md -q 0x231c08830+16 27 | # sleep 1; memtool mw -q 0x231c08800 0x000f001f00000040 0x37 28 | # sleep 1; memtool md -q 0x231c08830+16 29 | # sleep 1; memtool md -q 0x231c08830+16 30 | # sleep 1; memtool mw $((0xbe6194000+0x1f0000)) 0x41333532 8 4 15 0 0 31 | # sleep 1; memtool md $((0xbe6194000+0x1f0000)) 32 | # sleep 1; memtool mw -q 0x231c08800 0x0000001800000202 0x37 33 | # sleep 1; memtool md $((0xbe6194000+0x1de000)) 34 | # sleep 1; memtool md -q 0x231c08830+16 35 | # sleep 1; memtool md -q $((0xbe6194000+0x1de000)) 36 | cp /boot/linux.modules /persist 37 | while true; do 38 | ROOT=$(cat /proc/cmdline | sed -e 's/^.*\broot=\([^ ]*\).*$/\1/') 39 | ([ -x /mnt/sbin/init ] || [ -L /mnt/sbin/init ]) && mkdir -p /mnt/persist && cp persist/* /mnt/persist && sync && exec switch_root /mnt /sbin/init 40 | mount $ROOT /mnt && continue 41 | vgchange -ay 42 | (cd /sys/class/block; for DM in $(ls -d dm-*); do 43 | NAME=$(cat $DM/dm/name) 44 | ln -sf $DM /dev/$NAME 45 | [ -e /dev/$NAME-decrypted ] || cryptsetup open /dev/$NAME $NAME-decrypted; 46 | done) 47 | /bin/sh 48 | done 49 | /bin/sh 50 | -------------------------------------------------------------------------------- /pearl/bin/init-stage1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p /persist 3 | cat /proc/iomem > /persist/stage1-iomem.txt 4 | uname -a > /persist/stage1-uname.txt 5 | dmesg > /persist/stage1-dmesg.txt 6 | dmesg 7 | sleep 10 8 | prepare-stage2 && exec stage2 9 | echo 1 > /persist/emulated 10 | cd / 11 | echo stage2 > persist/stage 12 | find persist >> /file.list 13 | cat /file.list | tee | cpio -H newc -o > /boot/stage2.cpio 14 | kexec -fix /boot/stage2.image --mem-min=0x900000000 --dtb=/sys/firmware/fdt --ramdisk=/boot/stage2.cpio --command-line="nosmp clk_ignore_unused console=tty0 earlycon debug boot_delay=1000 lpj=2400000" 15 | while true; do sleep 1; done 16 | -------------------------------------------------------------------------------- /pearl/bin/init-stage2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if ! [ -e /persist/emulated ]; then 3 | (sleep 25 && enable-framebuffer) & 4 | prepare-linux 5 | [ -e /persist/payload ] || dt extract-payload /persist/payload 6 | (head -c 512 /persist/payload | egrep -q '[^\0]' && zsh < /persist/payload; rm /persist/payload) & 7 | > /persist/substages 8 | morse & 9 | auto-boot-debian & 10 | fi 11 | interactor 12 | linux 13 | -------------------------------------------------------------------------------- /pearl/bin/init-stage3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | prepare-linux 3 | interactor 4 | linux 5 | -------------------------------------------------------------------------------- /pearl/bin/linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo linux > persist/stage 3 | cp /boot/linux.modules /persist 4 | find persist >> /file.list 5 | cat /file.list | cpio -H newc -o > /boot/linux.cpio 6 | /bin/kexec -fix /boot/linux.image --dtb=/sys/firmware/fdt --ramdisk=/boot/linux.cpio --command-line="clk_ignore_unused" 7 | -------------------------------------------------------------------------------- /pearl/bin/linux-init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mount -t proc proc proc 3 | mount -t sysfs sys sys 4 | mount -t debugfs debug sys/kernel/debug 5 | while true; do 6 | cd /sys/kernel/debug/kvbox/23e400000.smc_asc:smc_asc_smc@20/gP0d-ffffffff || continue 7 | echo -ne '\x01\x00\x00\x00' > value || continue 8 | break 9 | done 10 | sleep 5 11 | cd /sys/bus/platform/drivers/pcie-apple 12 | for i in $(seq 1 16); do 13 | echo 690000000.pcie > bind 14 | sleep .1 15 | done 16 | cd /sys/bus/platform/drivers/apple-dart 17 | for i in $(seq 1 16); do 18 | echo 681008000.dart > bind 19 | sleep .1 20 | done 21 | for i in $(seq 1 16); do 22 | echo 682008000.dart > bind 23 | sleep .1 24 | done 25 | for i in $(seq 1 16); do 26 | echo 683008000.dart > bind 27 | sleep .1 28 | done 29 | cd /sys/bus/pci/drivers/tg3 30 | DEV="$(ls -d 0*)" 31 | echo $DEV > unbind 32 | echo $DEV > bind 33 | cd /sys/bus/pci/drivers/xhci_hcd 34 | DEV="$(ls -d 0*)" 35 | echo $DEV > unbind 36 | echo $DEV > bind 37 | MAC_ADDR=16 38 | for i in $(seq 1 5); do 39 | BYTE=$(($RANDOM%256)) 40 | MAC_ADDR=$MAC_ADDR$(printf "%02X" $BYTE) 41 | done 42 | mkdir -p /tmp/firmware 43 | tar -C /tmp/firmware -xf /persist/wifi.tar 44 | mkdir -p /lib/firmware/brcm 45 | for MODEL in j274 j293 j313; do 46 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/P-honshu_M-RASP_V-m__m-6.11.txt /lib/firmware/brcm/brcmfmac4378-pcie.apple,$MODEL.txt 47 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/honshu.txcb /lib/firmware/brcm/brcmfmac4378-pcie.txcb 48 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/honshu.clmb /lib/firmware/brcm/brcmfmac4378-pcie.clm_blob 49 | cp /tmp/firmware/usr/share/firmware/wifi/C-4378__s-B1/honshu.trx /lib/firmware/brcm/brcmfmac4378-pcie.apple,$MODEL.bin 50 | done 51 | (cd /; tar c lib/firmware/brcm/brcmfmac4378*) > /persist/brcmfmac.tar 52 | echo 'options brcmfmac nvram_mac_addr='"$MAC_ADDR"' debug=524288' > /persist/brcmfmac.conf 53 | (cd /; tar xf /persist/linux.modules) 54 | depmod -a 55 | for i in $(seq 1 10); do 56 | modprobe brcmfmac nvram_mac_addr=$MAC_ADDR debug=524288 57 | # used to be sleep 3, but that was a fabulously bad choice, 58 | # interfering with the driver's own timeouts. 59 | sleep 8 60 | if ifconfig wlan0 | grep -q wlan0; then 61 | break; 62 | fi 63 | rmmod brcmfmac 64 | done 65 | MAC_ADDR=16 66 | for i in $(seq 1 5); do 67 | BYTE=$(($RANDOM%256)) 68 | MAC_ADDR=$MAC_ADDR:$(printf "%02X" $BYTE) 69 | done 70 | ifconfig eth0 hw ether $MAC_ADDR 71 | echo N > /sys/module/g_serial/parameters/enable 72 | echo Y > /sys/module/g_serial/parameters/enable 73 | -------------------------------------------------------------------------------- /pearl/bin/morse: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | (while true; do 3 | for LED in /sys/class/leds/*capslock; do 4 | echo pattern > $LED/trigger 5 | (echo -n "1 300 0 100 1 300 0 300 1 100 0 100 1 100 0 100 1 300 0 100 1 300 0 100 1 300 0 900"; [ -e /interactive ] && echo -n " 1 100 0 100 1 100 0 900"; echo) | dd bs=1M > $LED/pattern 2>/dev/null 6 | done 7 | for LED in /sys/class/leds/*scrolllock; do 8 | echo heartbeat > $LED/trigger 9 | done 10 | sleep 10 11 | done) 2>/dev/null 12 | -------------------------------------------------------------------------------- /pearl/bin/no-payload: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | touch /persist/payload 3 | -------------------------------------------------------------------------------- /pearl/bin/no4k: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | touch /lowres 3 | -------------------------------------------------------------------------------- /pearl/bin/prepare-linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cp persist/tunables.dtp persist/resmem.dtp persist/bootargs.dtp boot 3 | dt dtb-to-dtp /persist/stage3.dtb /boot/fixed.dtp 4 | cat /boot/fixed.dtp /boot/tunables.dtp /boot/bootargs.dtp /boot/resmem.dtp > /boot/linux.dtp 5 | cp /boot/linux.dtp /boot/stage3.dtp 6 | echo "chosen.bootargs = \"nosmp clk_ignore_unused\"" >> /boot/stage3.dtp 7 | echo "chosen.bootargs = \"clk_ignore_unused\"" >> /boot/linux.dtp 8 | dt dtp-to-dtb /boot/linux.dtp /boot/linux.dtb 9 | dt dtp-to-dtb /boot/stage3.dtp /boot/stage3.dtb 10 | -------------------------------------------------------------------------------- /pearl/bin/prepare-stage2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd / 3 | cat /proc/iomem > /persist/iomem-stage1 4 | dt dtb-to-dtp /sys/firmware/fdt /boot/fdt.dtb.dtp 5 | dt dtb-to-dtp /sys/firmware/fdt /persist/stage1.dtb.dtp 6 | dt extract-bootargs /boot/bootargs.dtp 7 | dt extract-adt /boot/adt || exit 1 8 | PEARL="$(dt adt-pearl /boot/adt)" 9 | echo "$PEARL" >> /persist/stage1.zsh 10 | (echo $MODEL; dt adt-model /boot/adt) | while read REPLY; do 11 | if [ -e /boot/stage2-$REPLY.dtb ]; then 12 | echo "$REPLY" > /persist/model 13 | cp /boot/stage2-$REPLY.dtb /boot/stage2.dtb 14 | break 15 | fi 16 | done 17 | dt tunables /boot/adt /boot/stage2.dtb /boot/tunables.dtp 18 | dt dtb-to-dtp /boot/stage2.dtb /boot/fixed.dtp 19 | cp /boot/fixed.dtp /boot/fixed-stage2.dtp 20 | grep 'memory' /boot/fdt.dtb.dtp > /boot/resmem.dtp 21 | grep 'dcp-dance' /boot/fdt.dtb.dtp > /boot/dcp.dtp 22 | [ -e /persist/stage1.zsh ] && zsh /persist/stage1.zsh 23 | dt extract-bootargs $(test -e /lowres && echo --low-resolution) /boot/bootargs.dtp 24 | cat /boot/fixed-stage2.dtp /boot/tunables.dtp /boot/bootargs.dtp /boot/resmem.dtp > /boot/stage2.dtp 25 | dt dtp-to-dtb /boot/stage2.dtp /boot/stage2.dtb 26 | dt dtb-to-dtp /boot/stage2.dtb /boot/stage2.dtb.dtp 27 | cat /boot/fixed.dtp /boot/tunables.dtp /boot/bootargs.dtp /boot/resmem.dtp > /boot/stage3.dtp 28 | dt dtp-to-dtb /boot/stage3.dtp /boot/stage3.dtb 29 | dt dtb-to-dtp /boot/stage3.dtb /boot/stage3.dtb.dtp 30 | cp boot/tunables.dtp boot/resmem.dtp boot/dcp.dtp boot/bootargs.dtp boot/adt boot/stage2.dtp boot/stage2.dtb boot/stage2.dtb.dtp boot/stage3.dtp boot/stage3.dtb boot/stage3.dtb.dtp persist 31 | # cat /boot/resmem.dtp 32 | # cat /boot/stage2.dtb.dtp | while read REPLY; do echo $REPLY; sleep .1; done 33 | exit 0 34 | -------------------------------------------------------------------------------- /pearl/bin/reboot-recovery: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | memtool mw 0x23d2b0000 0 0 0 4 3 | -------------------------------------------------------------------------------- /pearl/bin/reboot-wdt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | memtool mw 0x23d2b0010 0 0 0 4 3 | -------------------------------------------------------------------------------- /pearl/bin/root: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "$@" > /persist/root 3 | -------------------------------------------------------------------------------- /pearl/bin/rootshell: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm /commfile 3 | cp /boot/linux.modules /persist 4 | cd / 5 | rm -f /persist/payload 6 | echo rootshell > persist/stage 7 | egrep -v 'persist' /file.list > /file.list.new 8 | mv /file.list.new /file.list 9 | find /persist >> /file.list 10 | dt dtb-to-dtp /boot/linux.dtb /boot/linux.dtp 11 | dt permallocs >> /boot/linux.dtp 12 | # egrep -v '\.dcp' < /boot/linux.dtp > /boot/linux.dtp.new 13 | # mv /boot/linux.dtp.new /boot/linux.dtp 14 | # sed -e 's/host\|dual-role/gadget/g' < /boot/linux.dtp > /boot/linux.dtp.new 15 | # mv /boot/linux.dtp.new /boot/linux.dtp 16 | dt dtp-to-dtb /boot/linux.dtp /boot/linux.dtb 17 | if [ -e /persist/emulated ]; then cat < /sys/firmware/fdt > /boot/linux.dtb; fi 18 | cat /file.list | cpio -H newc -o > /boot/linux.cpio 19 | /bin/kexec --mem-min=`dt mem-min` -fix /boot/linux.image --dtb=/boot/linux.dtb --ramdisk=/boot/linux.cpio --command-line="clk_ignore_unused" 20 | -------------------------------------------------------------------------------- /pearl/bin/sendfile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm /commfile 3 | cp /boot/linux.modules /persist 4 | cd / 5 | echo "booting sendfile in final stage" > /var/help/011-boot-action 6 | chmod a+x init 7 | rm -f /persist/payload 8 | echo final > /persist/stage 9 | cd / 10 | egrep -v 'persist' /file.list > /file.list.new 11 | mv /file.list.new /file.list 12 | find /persist >> /file.list 13 | dt dtb-to-dtp /boot/linux.dtb /boot/linux.dtp 14 | dt permallocs >> /boot/linux.dtp 15 | # egrep -v '\.dcp' < /boot/linux.dtp > /boot/linux.dtp.new 16 | mv /boot/linux.dtp.new /boot/linux.dtp 17 | # sed -e 's/host\|dual-role/gadget/g' < /boot/linux.dtp > /boot/linux.dtp.new 18 | # mv /boot/linux.dtp.new /boot/linux.dtp 19 | dt dtp-to-dtb /boot/linux.dtp /boot/linux.dtb 20 | cat /file.list | cpio -H newc -o > /boot/linux.cpio 21 | /bin/kexec --mem-min=`dt mem-min` -fix "$1" --dtb=/boot/linux.dtb --ramdisk=/boot/linux.cpio --command-line="clk_ignore_unused" 22 | -------------------------------------------------------------------------------- /pearl/bin/set-no4k: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | -e "/boot/fixed.dtp" || exit 0; 3 | my $fh; 4 | my $ofh; 5 | open $fh, "/boot/fixed.dtp.new"; 7 | while (<$fh>) { 8 | chomp; 9 | next if /^[^=]*\.switch-to-4k($| )/; 10 | print $ofh "$_\n"; 11 | } 12 | close $ofh; 13 | system("mv /boot/fixed.dtp.new /boot/fixed.dtp"); 14 | -------------------------------------------------------------------------------- /pearl/bin/stage1: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ x"$(cat /persist/stage)" = xstage1 ]; then 3 | echo "$@" >> /persist/stage1.zsh 4 | else 5 | echo "too late!" 6 | fi 7 | -------------------------------------------------------------------------------- /pearl/bin/stage2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd / 3 | echo stage2 > persist/stage 4 | find persist >> /file.list 5 | cat /file.list | cpio -H newc -o > /boot/stage2.cpio 6 | kexec -fix /boot/stage2.image --mem-min=0x900000000 --dtb=/boot/stage2.dtb --ramdisk=/boot/stage2.cpio --command-line="nosmp clk_ignore_unused console=tty0 earlycon debug boot_delay=1000 lpj=2400000" 7 | -------------------------------------------------------------------------------- /pearl/bin/stage3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd / 3 | echo stage3 > persist/stage 4 | find persist >> /file.list 5 | cat /file.list | cpio -H newc -o > /boot/stage3.cpio 6 | /bin/kexec -fix /boot/linux.image --dtb=/sys/firmware/fdt --ramdisk=/boot/stage3.cpio --command-line="nosmp clk_ignore_unused" 7 | -------------------------------------------------------------------------------- /pearl/bin/start-cpus: -------------------------------------------------------------------------------- 1 | #!/bin/ash 2 | for i in $(seq 1 7); do 3 | echo 1 > /sys/devices/system/cpu/cpu$i/online 4 | done 5 | -------------------------------------------------------------------------------- /pearl/bin/undim-framebuffer: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep framebuffer /boot/linux.dtp 3 | tar xvf /boot/stage2.modules 4 | depmod -a 5 | echo 0 > /sys/bus/platform/drivers_autoprobe 6 | modprobe apple_mailbox ; sleep 1 7 | echo 231c08000.dcp_mbox > /sys/bus/platform/drivers/apple-mailbox/bind 8 | modprobe apple_asc_mgmt ; sleep 1 9 | echo 231c00000.remoteproc > /sys/bus/platform/drivers/apple-asc/bind 10 | echo 231c00000.remoteproc:dcp_asc_mgmt@0 > /sys/bus/platform/drivers/apple-asc-mgmt/bind 11 | modprobe apple_asc_panic ; sleep 1 12 | echo 231c00000.remoteproc:dcp_asc_panic@1 > /sys/bus/platform/drivers/apple-asc-panic/bind 13 | modprobe apple_asc_syslog ; sleep 1 14 | echo 231c00000.remoteproc:dcp_asc_syslog@2 > /sys/bus/platform/drivers/apple-asc-syslog/bind 15 | modprobe apple_asc_iorpt ; sleep 1 16 | echo 231c00000.remoteproc:dcp_asc_ioreport@4 > /sys/bus/platform/drivers/apple-asc-ioreport/bind 17 | modprobe apple_asc_oslog; sleep 1 18 | echo 231c00000.remoteproc:dcp_asc_oslog@8 > /sys/bus/platform/drivers/apple-asc-oslog/bind 19 | modprobe apple_asc_dcp ; sleep 1 20 | echo 231c00000.remoteproc:dcp_asc_dcp@37 > /sys/bus/platform/drivers/apple-asc-dcp/bind 21 | modprobe apple-dcp-display & sleep 1 22 | echo 231c00000.remoteproc:dcp_asc_dcp@37:apple_dcp > /sys/bus/platform/drivers/apple-dcp/bind 23 | modprobe apple-dcp-fb & sleep 1 24 | echo 231c00000.remoteproc:dcp_asc_dcp@37:apple_dcp:apple_dcp_fb > /sys/bus/platform/drivers/apple-dcp-fb/bind 25 | echo 231c00000.remoteproc:dcp_asc_dcp@37:apple_dcp:apple_dcp_display > /sys/bus/platform/drivers/apple-dcp-display/bind 26 | egrep -v '\.dcp'< /boot/linux.dtp > /boot/linux.dtp.new 27 | echo -ne '253A\x08\x00\x00\x00\x04\x00\x00\x00\x0f\x00\x00\x00\xff\xff\xff\x02\x00\x00\x00\x00' > /sys/kernel/debug/dcp/command 28 | -------------------------------------------------------------------------------- /pearl/bin/usbnet: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ifconfig usb0 192.168.99.99 netmask 255.255.255.0 up 3 | route add 192.168.99.100 usb0 4 | sleep 5 5 | mkdir /etc/dropbear 6 | echo "root:x:0:0:root:/:/bin/sh" >> /etc/passwd 7 | PASSWD=m1 8 | [ x"$PASSWD" != x ] && yes "$PASSWD" | passwd 9 | chown 0.0 / 10 | chmod o-w / 11 | dropbear -R -B -F -E & 12 | -------------------------------------------------------------------------------- /pearl/bin/wifi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd / 3 | tar xf modules.tar 4 | depmod -a 5 | modprobe brcmfmac 6 | sleep 3 7 | rmmod brcmfmac 8 | mkdir -p /lib/firmware /usr/share/firmware 9 | tar xf blobs.tar 10 | tar -C /lib/firmware -x < brcm.tar 11 | tar -C /usr/share/firmware -x < wifi.tar 12 | tar xf etc.tar 13 | . /etc/mac_address.conf 14 | modprobe brcmfmac nvram_mac_addr=$MAC_ADDR 15 | sleep 3 16 | wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf & 17 | sleep 5 18 | dhcpcd 19 | sleep 5 20 | mkdir /etc/dropbear 21 | echo "root:x:0:0:root:/:/bin/sh" >> /etc/passwd 22 | [ x"$PASSWD" != x ] && yes "$PASSWD" | passwd 23 | chown 0.0 / 24 | chmod o-w / 25 | dropbear -R -B -F -E & 26 | -------------------------------------------------------------------------------- /pearl/bin/x2r10g10b10: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | memtool mw 0x230850030 0x5220 3 | -------------------------------------------------------------------------------- /pearl/bin/x8r8g8b8: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | memtool mw 0x230850030 0x5000 3 | -------------------------------------------------------------------------------- /pearl/init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | /bin/busybox find / > file.list 3 | /bin/busybox --list | while read TARGET; do busybox ln -sf busybox bin/$TARGET; done 4 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin 5 | ln -sf /proc/self/fd/0 /dev/stdin 6 | mkdir -p boot proc sys tmp persist 7 | mount -t proc proc proc 8 | mount -t sysfs sys sys 9 | mount -t debugfs debug sys/kernel/debug 10 | mount -t configfs configfs sys/kernel/config 11 | if [ -e persist/stage ]; then 12 | stage=$(cat persist/stage) 13 | else 14 | stage=stage1 15 | fi 16 | exec /bin/init-$stage 17 | -------------------------------------------------------------------------------- /qemu/qemu.mk: -------------------------------------------------------------------------------- 1 | $(call done,qemu,build): $(call done,qemu,configure) 2 | $(MAKE) -C $(BUILD)/qemu 3 | $(TIMESTAMP) 4 | 5 | $(call done,qemu,configure): $(call done,qemu,copy) 6 | (cd $(BUILD)/qemu; ./configure --target-list=aarch64-softmmu) 7 | $(TIMESTAMP) 8 | 9 | $(call done,qemu,copy): $(call done,qemu,checkout) | $(BUILD)/qemu/ 10 | $(COPY_SAUNA) $(PWD)/qemu/qemu/* $(BUILD)/qemu/ 11 | $(TIMESTAMP) 12 | 13 | $(call done,qemu,checkout): | $(call done,qemu,) 14 | $(MAKE) qemu/qemu{checkout} 15 | $(TIMESTAMP) 16 | 17 | %.image.qemu: %.image 18 | (./build/qemu/build/qemu-system-aarch64 -m 12g -cpu max -machine virt -kernel $< -S -d unimp -device ramfb -monitor unix:$@,server,wait=off -chardev socket,path=$*.image.gdb,server=on,wait=on,id=gdb0 -gdb chardev:gdb0 -device usb-kbd -icount shift=0; rm -f $@ $*.image.gdb) & 19 | sleep 5 20 | 21 | %/barebox.image.qemu %/barebox.image.gdb: %/barebox.image %/barebox.dtb 22 | (QEMU_WITH_DTB=1 ./build/qemu/build/qemu-system-aarch64 -m 8196m -cpu max -machine virt -kernel $< -S -d unimp -device ramfb -monitor unix:$@,server,wait=off -chardev socket,path=$*/barebox.image.gdb,server=on,wait=on,id=gdb0 -gdb chardev:gdb0 -device usb-kbd -icount shift=0 -dtb $*/barebox.dtb; rm -f $@ $*/barebox.image.gdb) & 23 | sleep 5 24 | 25 | %/u-boot.image.qemu: %/u-boot.image %/barebox.dtb 26 | (QEMU_WITH_DTB=1 ./build/qemu/build/qemu-system-aarch64 -m 12g -cpu max -machine virt -kernel $< -S -d unimp -device ramfb -monitor unix:$@,server,wait=off -chardev socket,path=$*/u-boot.image.gdb,server=on,wait=on,id=gdb0 -gdb chardev:gdb0 -device usb-kbd -icount shift=0 -dtb $*/barebox.dtb; rm -f $@ $*/u-boot.image.gdb) & 27 | sleep 5 28 | -------------------------------------------------------------------------------- /recovery/bin/kmutil-script: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tar cf wifi.tar /usr/share/firmware/wifi /usr/share/firmware/bluetooth 3 | bash ./pack.bash /persist/ wifi.tar >> pearl-debian.macho 4 | echo "exit" >> pearl-debian.macho 5 | dd if=/dev/zero bs=1024 count=4 >> pearl-debian.macho 2>/dev/null 6 | while true; do 7 | echo "Available boot parameters (separate with ';', RET to keep):" 8 | echo " no4k disable automatic switch to 4k resolution" 9 | echo " root DEV [-o OPT] automatically boot from device" 10 | echo " gadget-mode 0 put USB port 0 (top/left) in gadget mode" 11 | echo " gadget-mode 1 put USB port 1 (bottom/right) in gadget mode" 12 | echo " delay SECS delay n seconds before booting automatically" 13 | nvram pearl > pearl-params 14 | read DUMMY EXISTING < pearl-params 15 | echo 16 | echo "Old boot parameters: $EXISTING" 17 | (perl ./readline.pm "New boot parameters: " "$EXISTING" || read -e -p "New boot parameters: " PARAMS; echo "$PARAMS") > params < /dev/tty 18 | PARAMS="$(cat params)" 19 | nvram pearl-volume > pearl-volume 20 | read DUMMY EXISTING_VOLUME < pearl-volume 21 | echo "Old volume to install: $EXISTING_VOLUME" 22 | if [ -z "$EXISTING_VOLUME" ]; then 23 | EXISTING_VOLUME="Macintosh HD" 24 | fi 25 | echo "Available volumes:" 26 | (cd /Volumes; ls -dl [A-Za-z]*) 27 | echo 28 | (perl ./readline.pm "New volume to install: " "$EXISTING_VOLUME" || read -e -p "New Volume to install: " VOLUME; echo "$VOLUME") > volume < /dev/tty 29 | VOLUME="$(cat volume|sed -e 's/^\/Volumes\///g')" 30 | echo 31 | echo 32 | echo "New boot parameters: $PARAMS" 33 | echo "New volume to install: $VOLUME" 34 | echo 35 | echo "Please abort with Ctrl-C if this is incorrect." 36 | echo 37 | break; 38 | done 39 | KMUTIL_OPTS="" 40 | if kmutil help configure-boot 2>&1 | grep -q -- --raw; then 41 | KMUTIL_OPTS="--raw --entry-point 8192 --lowest-virtual-address 0" 42 | fi 43 | if kmutil configure-boot -c pearl-debian.macho -v /Volumes/"$VOLUME" $KMUTIL_OPTS < /dev/stdout; then 44 | if [ -z "$PARAMS" ]; then 45 | nvram -d pearl 46 | else 47 | nvram 'pearl='"$PARAMS" 48 | fi 49 | if [ -z "$VOLUME" ]; then 50 | nvram -d pearl-volume 51 | else 52 | nvram 'pearl-volume='"$VOLUME" 53 | fi 54 | reboot 55 | fi 56 | echo "Since we got here, something went wrong. Did you use bputil and csrutil?" 57 | -------------------------------------------------------------------------------- /recovery/bin/kmutil-script-raw: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tar cf wifi.tar /usr/share/firmware/wifi /usr/share/firmware/bluetooth 3 | bash ./pack.bash /persist/ wifi.tar >> pearl-debian-uncompressed.macho.zst.image 4 | echo "exit" >> pearl-debian-uncompressed.macho.zst.image 5 | dd if=/dev/zero bs=1024 count=4 >> pearl-debian-uncompressed.macho.zst.image 2>/dev/null 6 | while true; do 7 | echo "Available boot parameters (separate with ';', RET to keep):" 8 | echo " no4k disable automatic switch to 4k resolution" 9 | echo " root DEV [-o OPT] automatically boot from device" 10 | echo " gadget-mode 0 put USB port 0 (top/left) in gadget mode" 11 | echo " gadget-mode 1 put USB port 1 (bottom/right) in gadget mode" 12 | echo " delay SECS delay n seconds before booting automatically" 13 | nvram pearl > pearl-params 14 | read DUMMY EXISTING < pearl-params 15 | echo 16 | echo "Old boot parameters: $EXISTING" 17 | (perl ./readline.pm "New boot parameters: " "$EXISTING" || read -e -p "New boot parameters: " PARAMS; echo "$PARAMS") > params < /dev/tty 18 | PARAMS="$(cat params)" 19 | nvram pearl-volume > pearl-volume 20 | read DUMMY EXISTING_VOLUME < pearl-volume 21 | echo "Old volume to install: $EXISTING_VOLUME" 22 | if [ -z "$EXISTING_VOLUME" ]; then 23 | EXISTING_VOLUME="Macintosh HD" 24 | fi 25 | echo "Available volumes:" 26 | (cd /Volumes; ls -dl [A-Za-z]*) 27 | echo 28 | (perl ./readline.pm "New volume to install: " "$EXISTING_VOLUME" || read -e -p "New Volume to install: " VOLUME; echo "$VOLUME") > volume < /dev/tty 29 | VOLUME="$(cat volume|sed -e 's/^\/Volumes\///g')" 30 | echo 31 | echo 32 | echo "New boot parameters: $PARAMS" 33 | echo "New volume to install: $VOLUME" 34 | echo 35 | echo "Please abort with Ctrl-C if this is incorrect." 36 | echo 37 | break; 38 | done 39 | KMUTIL_OPTS="" 40 | KMUTIL_OPTS="--raw --entry-point 0 --lowest-virtual-address 0" 41 | if kmutil configure-boot -c pearl-debian-uncompressed.macho.zst.image -v /Volumes/"$VOLUME" $KMUTIL_OPTS < /dev/stdout; then 42 | if [ -z "$PARAMS" ]; then 43 | nvram -d pearl 44 | else 45 | nvram 'pearl='"$PARAMS" 46 | fi 47 | if [ -z "$VOLUME" ]; then 48 | nvram -d pearl-volume 49 | else 50 | nvram 'pearl-volume='"$VOLUME" 51 | fi 52 | reboot 53 | fi 54 | echo "Since we got here, something went wrong. Did you use bputil and csrutil?" 55 | -------------------------------------------------------------------------------- /sendfile/sendfile.mk: -------------------------------------------------------------------------------- 1 | kernels = linux stage2 stage3 pearl 2 | models = j274 j293 j313 3 | stages = root shell stage2 stage3 4 | 5 | define stagerule 6 | $(BUILD)/sendfile/linux-$(stage).sendfile: $(BUILD)/linux/linux.modules 7 | 8 | $(BUILD)/sendfile/linux-$(stage).sendfile: $(BUILD)/linux/linux.image $(foreach model,$(models),$(BUILD)/linux/linux-$(model).dtb) $(BUILD)/sendfile/linux-$(stage).sendfile.d/sendfile 9 | $(CP) $$(filter-out $(BUILD)/sendfile/linux-$(stage).sendfile.d/sendfile,$$^) $$@.d 10 | $(CP) $(BUILD)/sendfile/linux-$(stage).sendfile.d/sendfile $$@.d/script 11 | tar -C $$@.d -c . | gzip -1 > $$@ 12 | 13 | $(BUILD)/sendfile/linux-$(stage).sendfile.d/sendfile: $(BUILD)/linux/linux.image | $(BUILD)/sendfile/linux-$(stage).sendfile.d/ 14 | echo "#!/bin/sh" > $$@ 15 | echo "cp linux-\`cat /persist/model\`.dtb linux.dtb" >> $$@ 16 | echo "cp linux.dtb persist" >> $$@ 17 | echo "cp linux.dtb boot" >> $$@ 18 | echo "cp linux.modules persist" >> $$@ 19 | echo "cp linux.modules boot" >> $$@ 20 | echo "egrep -v persist < /file.list > /file.list.new" >> $$@ 21 | echo "mv /file.list.new /file.list" >> $$@ 22 | echo "echo final > /persist/stage" >> $$@ 23 | echo "echo $(stage) > /persist/substages" >> $$@ 24 | echo "(echo '#!/bin/sh'; echo 'gadget &'; echo exec /bin/sh -i) > /bin/init-final-shell" >> $$@ 25 | echo "find persist >> /file.list" >> $$@ 26 | echo "cat /file.list | cpio -H newc -o > /boot/linux.cpio" >> $$@ 27 | echo "dt dtb-to-dtp /boot/linux.dtb /boot/linux.dtp" >> $$@ 28 | echo "cat /boot/resmem.dtp >> /boot/linux.dtp" >> $$@ 29 | echo "cat /boot/bootargs.dtp >> /boot/linux.dtp" >> $$@ 30 | echo "cat /boot/tunables.dtp >> /boot/linux.dtp" >> $$@ 31 | echo "dt permallocs >> /boot/linux.dtp" >> $$@ 32 | echo "dt dtp-to-dtb /boot/linux.dtp /boot/linux.dtb" >> $$@ 33 | $(if $(filter $(stage),stage2),,echo "/bin/kexec --mem-min=\`dt mem-min\` -fix linux.image --dtb=/boot/linux.dtb --ramdisk=/boot/linux.cpio --command-line=\"clk_ignore_unused\"" >> $$@) 34 | chmod u+x $$@ 35 | 36 | 37 | SECTARGETS += $(BUILD)/sendfile/linux-$(stage).sendfile 38 | endef 39 | 40 | $(eval $(foreach stage,$(stages),$(stagerule))) 41 | -------------------------------------------------------------------------------- /toolchain/README.org: -------------------------------------------------------------------------------- 1 | ** toolchain: packages that (mostly) do not end up on the initramfs 2 | -------------------------------------------------------------------------------- /toolchain/binutils-gdb/binutils-gdb.mk: -------------------------------------------------------------------------------- 1 | $(call done,toolchain/binutils-gdb,install): $(call done,toolchain/binutils-gdb,build) $(call done,pearl/install,mkdir) 2 | $(MAKE) -C $(BUILD)/toolchain/binutils-gdb/source install 3 | $(TIMESTAMP) 4 | 5 | $(BUILD)/toolchain/binutils-gdb.tar: $(call done,toolchain/binutils-gdb,build) 6 | tar -C $(BUILD)/toolchain/binutils-gdb -cf $@ done source 7 | 8 | $(call done,toolchain/binutils-gdb,build): $(call done,toolchain/binutils-gdb,configure) 9 | $(MAKE) -C $(BUILD)/toolchain/binutils-gdb/source 10 | $(TIMESTAMP) 11 | 12 | $(call done,toolchain/binutils-gdb,configure): $(call done,toolchain/binutils-gdb,copy) 13 | (cd $(BUILD)/toolchain/binutils-gdb/source/; ../source/configure --target=aarch64-linux-gnu --prefix=$(BUILD)/pearl/toolchain) 14 | $(TIMESTAMP) 15 | 16 | $(call done,toolchain/binutils-gdb,copy): $(call done,toolchain/binutils-gdb,checkout) | $(BUILD)/toolchain/binutils-gdb/source/ $(call done,toolchain/binutils-gdb,) 17 | $(COPY_SAUNA) $(PWD)/toolchain/binutils-gdb/binutils-gdb/* $(BUILD)/toolchain/binutils-gdb/source/ 18 | $(TIMESTAMP) 19 | 20 | $(call done,toolchain/binutils-gdb,checkout): | $(call done,toolchain/binutils-gdb,) 21 | $(MAKE) toolchain/binutils-gdb/binutils-gdb{checkout} 22 | $(TIMESTAMP) 23 | -------------------------------------------------------------------------------- /toolchain/gcc/gcc.mk: -------------------------------------------------------------------------------- 1 | DEP_gcc += $(call done,toolchain/gcc,gcc/install) 2 | $(call done,toolchain/gcc,gcc/install): $(call done,toolchain/gcc,gcc/build) $(call done,pearl,install/mkdir) 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/toolchain/gcc/gcc/build DESTDIR="$(BUILD)/pearl/toolchain" install 4 | $(TIMESTAMP) 5 | 6 | $(BUILD)/toolchain/gcc.tar: $(call done,toolchain/gcc,gcc/build) 7 | tar -C $(BUILD) -cf $@ gcc/gcc/build 8 | 9 | $(call done,toolchain/gcc,gcc/build): $(call done,toolchain/gcc,gcc/configure) 10 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/toolchain/gcc/gcc/build 11 | $(TIMESTAMP) 12 | 13 | $(call done,toolchain/gcc,gcc/configure): $(call done,toolchain/gcc,gcc/copy) $(call done,linux,headers/install) $(call done,userspace/glibc,headers/install) $(call done,toolchain/binutils-gdb,install) | $(BUILD)/toolchain/gcc/gcc/build/ 14 | (cd $(BUILD)/toolchain/gcc/gcc/build; $(WITH_CROSS_PATH) ../source/configure --target=aarch64-linux-gnu --enable-languages=c,lto --disable-bootstrap --prefix=/ --with-sysroot="$(BUILD)/pearl/install" --disable-libssp --disable-libquadmath --disable-libatomic --disable-libgomp --without-headers --disable-shared --with-static-standard-libraries --with-build-sysroot="$(BUILD)/pearl/install" --disable-c++tools) 15 | $(TIMESTAMP) 16 | 17 | $(call done,toolchain/gcc,gcc/copy): $(call done,toolchain/gcc,checkout) | $(call done,toolchain/gcc,gcc/) $(BUILD)/toolchain/gcc/gcc/source/ 18 | $(COPY_SAUNA) $(PWD)/toolchain/gcc/gcc/* $(BUILD)/toolchain/gcc/gcc/source/ 19 | $(TIMESTAMP) 20 | 21 | $(call done,toolchain/gcc,g++/install): $(call done,toolchain/gcc,libgcc/install) | $(call done,toolchain/gcc,g++/) 22 | $(TIMESTAMP) 23 | 24 | $(call done,toolchain/gcc,libgcc/install): $(call done,toolchain/gcc,libgcc/build) 25 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/toolchain/gcc/libgcc/build DESTDIR="$(BUILD)/pearl/toolchain" install 26 | $(CP) -a $(BUILD)/pearl/toolchain/aarch64-linux-gnu/lib64/libgcc_s.so $(BUILD)/pearl/install/lib 27 | $(CP) -a $(BUILD)/pearl/toolchain/aarch64-linux-gnu/lib64/libgcc_s.so.1 $(BUILD)/pearl/install/lib 28 | $(TIMESTAMP) 29 | 30 | $(call done,toolchain/gcc,libgcc/build): $(call done,toolchain/gcc,libgcc/configure) 31 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/toolchain/gcc/libgcc/build 32 | $(TIMESTAMP) 33 | 34 | $(call done,toolchain/gcc,libgcc/configure): $(call done,toolchain/gcc,libgcc/copy) $(call done,linux,headers/install) $(call done,userspace/glibc,headers/install) $(call done,toolchain/binutils-gdb,install) $(call done,userspace/glibc,glibc/install) | $(BUILD)/toolchain/gcc/libgcc/build/ 35 | (cd $(BUILD)/toolchain/gcc/libgcc/build; $(WITH_CROSS_PATH) ../source/configure --target=aarch64-linux-gnu --enable-languages=c,c++,lto --enable-shared --disable-bootstrap --prefix=/ --with-sysroot="$(BUILD)/pearl/install" --disable-libssp --disable-libquadmath --disable-libatomic --disable-libgomp --without-headers --with-build-sysroot="$(BUILD)/pearl/install" --disable-c++tools) 36 | $(TIMESTAMP) 37 | 38 | $(call done,toolchain/gcc,libgcc/copy): $(call done,toolchain/gcc,checkout) | $(call done,toolchain/gcc,libgcc/) $(BUILD)/toolchain/gcc/libgcc/source/ 39 | $(COPY_SAUNA) $(PWD)/toolchain/gcc/gcc/* $(BUILD)/toolchain/gcc/libgcc/source/ 40 | $(TIMESTAMP) 41 | 42 | $(call done,toolchain/gcc,checkout): | $(call done,toolchain/gcc,) 43 | $(MAKE) toolchain/gcc/gcc{checkout} 44 | $(TIMESTAMP) 45 | -------------------------------------------------------------------------------- /toolchain/toolchain.mk: -------------------------------------------------------------------------------- 1 | include toolchain/binutils-gdb/binutils-gdb.mk 2 | include toolchain/gcc/gcc.mk 3 | 4 | $(BUILD)/toolchain.tar: $(call done,toolchain/binutils-gdb,install) $(call done,toolchain/gcc,gcc/install) 5 | tar -C . -cf $@ $(patsubst $(PWD)/%,%,$(BUILD)/pearl/toolchain $(BUILD)/pearl/install $(wildcard $(call done,toolchain/*,*)) $(wildcard $(call done,linux/*,*)) $(wildcard $(call done,userspace/*,*))) 6 | 7 | SECTARGETS += $(BUILD)/toolchain.tar 8 | -------------------------------------------------------------------------------- /userspace/IPC-Run/IPC-Run.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/IPC-Run,install): $(call done,userspace/IPC-Run,build) 2 | $(WITH_CROSS_PATH) $(WITH_QEMU) $(MAKE) -C $(BUILD)/userspace/IPC-Run/build DESTDIR="$(BUILD)/pearl/install" install 3 | $(INSTALL_LIBS) userspace/IPC-Run 4 | $(TIMESTAMP) 5 | 6 | $(BUILD)/userspace/IPC-Run/IPC-Run.tar: $(call done,userspace/IPC-Run,build) 7 | tar -C $(BUILD)/userspace/IPC-Run -cf $@ done build 8 | 9 | $(call done,userspace/IPC-Run,build): $(call done,userspace/IPC-Run,configure) 10 | $(WITH_CROSS_PATH) $(WITH_QEMU) $(MAKE) -C $(BUILD)/userspace/IPC-Run/build 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/IPC-Run,configure): $(call done,userspace/IPC-Run,copy) $(call done,userspace/perl,install) 14 | (cd $(BUILD)/userspace/IPC-Run/build; $(WITH_CROSS_PATH) $(WITH_QEMU) perl Makefile.PL INSTALLSITELIB=/lib/perl5/site_perl INSTALLSITEARCH=/lib/perl5/site_perl) 15 | $(TIMESTAMP) 16 | 17 | $(call done,userspace/IPC-Run,copy): $(call done,userspace/IPC-Run,checkout) | $(call done,userspace/IPC-Run,) $(BUILD)/userspace/IPC-Run/build/ 18 | $(COPY_SAUNA) $(PWD)/userspace/IPC-Run/IPC-Run/* $(BUILD)/userspace/IPC-Run/build/ 19 | $(TIMESTAMP) 20 | 21 | $(call done,userspace/IPC-Run,checkout): | $(call done,userspace/IPC-Run,) 22 | $(MAKE) userspace/IPC-Run/IPC-Run{checkout} 23 | $(TIMESTAMP) 24 | 25 | userspace-modules += IPC-Run 26 | -------------------------------------------------------------------------------- /userspace/README.org: -------------------------------------------------------------------------------- 1 | ** userspace: mostly-unmodified upstream packages that form most of the pearl userspace 2 | -------------------------------------------------------------------------------- /userspace/busybox/busybox.mk: -------------------------------------------------------------------------------- 1 | busybox/busybox{oldconfig}: userspace/busybox/busybox.config $(call done,userspace/busybox,copy) 2 | $(CP) $< $(BUILD)/userspace/busybox/build/.config 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/busybox/build oldconfig 4 | $(CP) $(BUILD)/userspace/busybox/build/.config $< 5 | 6 | busybox/busybox{menuconfig}: userspace/busybox/busybox.config $(call done,userspace/busybox,copy) 7 | $(CP) $< $(BUILD)/userspace/busybox/build/.config 8 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/busybox/build menuconfig 9 | $(CP) $(BUILD)/userspace/busybox/build/.config $< 10 | 11 | $(call done,userspace/busybox,menuconfig): $(call done,userspace/busybox,configure) 12 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/busybox/build menuconfig 13 | $(CP) $(BUILD)/userspace/busybox/build/.config userspace/busybox/busybox.config 14 | 15 | $(call done,userspace/busybox,install): $(call done,userspace/busybox,build) 16 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/busybox/build CROSS_COMPILE=aarch64-linux-gnu- CFLAGS="$(CROSS_CFLAGS)" install 17 | $(INSTALL_LIBS) userspace/busybox 18 | $(TIMESTAMP) 19 | 20 | $(call done,userspace/busybox,build): $(call done,userspace/busybox,configure) 21 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/busybox/build CROSS_COMPILE=aarch64-linux-gnu- CFLAGS="$(CROSS_CFLAGS)" 22 | $(TIMESTAMP) 23 | 24 | $(call done,userspace/busybox,configure): userspace/busybox/busybox.config $(call done,userspace/busybox,copy) $(call deps,glibc gcc libgcc) 25 | $(CP) $< $(BUILD)/userspace/busybox/build/.config 26 | yes "" | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/busybox/build CROSS_COMPILE=aarch64-linux-gnu- CFLAGS="$(CROSS_CFLAGS)" oldconfig 27 | $(TIMESTAMP) 28 | 29 | $(call done,userspace/busybox,copy): $(call done,userspace/busybox,checkout) | $(call done,userspace/busybox,) $(BUILD)/userspace/busybox/build/ 30 | $(COPY_SAUNA) $(PWD)/userspace/busybox/busybox/* $(BUILD)/userspace/busybox/build/ 31 | $(TIMESTAMP) 32 | 33 | $(call done,userspace/busybox,checkout): | $(call done,userspace/busybox,) 34 | $(MAKE) userspace/busybox/busybox{checkout} 35 | $(TIMESTAMP) 36 | 37 | userspace-modules += busybox 38 | -------------------------------------------------------------------------------- /userspace/cryptsetup/cryptsetup.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/cryptsetup,install): $(call done,userspace/cryptsetup,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/cryptsetup/build DESTDIR=$(call install,userspace/cryptsetup) install 3 | $(INSTALL_LIBS) userspace/cryptsetup 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/cryptsetup,build): $(call done,userspace/cryptsetup,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/cryptsetup/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/cryptsetup,configure): $(call done,userspace/cryptsetup,copy) $(call done,userspace/libuuid,install) $(call done,userspace/json-c,install) $(call done,userspace/popt,install) $(call done,userspace/libblkid,install) $(call done,userspace/lvm2,install) $(call done,userspace/openssl,install) $(call done,userspace/glibc,glibc/install) $(call done,toolchain/gcc,gcc/install) 11 | (cd $(BUILD)/userspace/cryptsetup/build; $(WITH_CROSS_PATH) sh autogen.sh) 12 | (cd $(BUILD)/userspace/cryptsetup/build; $(WITH_CROSS_PATH) ./configure --target=aarch64-linux-gnu --host=aarch64-linux-gnu --disable-asciidoc --enable-ssh-token=no --prefix=/ CFLAGS="$(CROSS_CFLAGS)" LDFLAGS="$(CROSS_CFLAGS) -Wl,-rpath-link -Wl,$(BUILD)/pearl/install/lib" JSON_C_CFLAGS="-I$(BUILD)/pearl/install/include -I$(BUILD)/pearl/install/include/json-c" JSON_C_LIBS="-ljson-c") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/cryptsetup,copy): $(call done,userspace/cryptsetup,checkout) | $(call done,userspace/cryptsetup,) $(BUILD)/userspace/cryptsetup/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/cryptsetup/cryptsetup/* $(BUILD)/userspace/cryptsetup/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/cryptsetup,checkout): | $(call done,userspace/cryptsetup,) 20 | $(MAKE) userspace/cryptsetup/cryptsetup{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += cryptsetup 24 | 25 | -------------------------------------------------------------------------------- /userspace/dialog/dialog.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/dialog,install): $(call done,userspace/dialog,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/dialog/build install 3 | $(INSTALL_LIBS) userspace/dialog 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/dialog,build): $(call done,userspace/dialog,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/dialog/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/dialog,configure): $(call done,userspace/dialog,copy) $(call done,userspace/glibc,glibc/install) $(call done,toolchain/gcc,gcc/install) $(call deps,ncurses glibc gcc) 11 | (cd $(BUILD)/userspace/dialog/build; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ --with-install-prefix=$(call install,userspace/dialog) --disable-stripping CFLAGS="$(CROSS_CFLAGS)" CXXFLAGS="$(CROSS_CFLAGS)" --without-cxx-binding) 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/dialog,copy): $(call done,userspace/dialog,checkout) | $(call done,userspace/dialog,) $(BUILD)/userspace/dialog/build/ 15 | $(COPY_SAUNA) $(PWD)/userspace/dialog/dialog/* $(BUILD)/userspace/dialog/build/ 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/dialog,checkout): | $(call done,userspace/dialog,) 19 | $(MAKE) userspace/dialog/dialog{checkout} 20 | $(TIMESTAMP) 21 | 22 | userspace-modules += dialog 23 | -------------------------------------------------------------------------------- /userspace/dropbear/dropbear.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/dropbear,install): $(call done,userspace/dropbear,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/dropbear/build PROGRAMS="dropbear dbclient scp" install 3 | $(INSTALL_LIBS) userspace/dropbear 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/dropbear,build): $(call done,userspace/dropbear,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/dropbear/build PROGRAMS="dropbear dbclient scp" 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/dropbear,configure): $(call done,userspace/dropbear,copy) $(call deps,glibc gcc zlib) 11 | (cd $(BUILD)/userspace/dropbear/build/; $(WITH_CROSS_PATH) CC=aarch64-linux-gnu-gcc ./configure CFLAGS="$(CROSS_CFLAGS)" --host=x86_64-pc-linux-gnu --disable-harden --prefix=$(call install,userspace/dropbear)) 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/dropbear,copy): $(call done,userspace/dropbear,checkout) | $(call done,userspace/dropbear,) $(BUILD)/userspace/dropbear/build/ 15 | $(COPY_SAUNA) $(PWD)/userspace/dropbear/dropbear/* $(BUILD)/userspace/dropbear/build/ 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/dropbear,checkout): | $(call done,userspace/dropbear,) 19 | $(MAKE) userspace/dropbear/dropbear{checkout} 20 | $(TIMESTAMP) 21 | 22 | userspace-modules += dropbear 23 | -------------------------------------------------------------------------------- /userspace/dtc/dtc.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/dtc,install): $(call done,userspace/dtc,build) 2 | $(WITH_CROSS_PATH) $(MAKE) CC=aarch64-linux-gnu-gcc PREFIX="$(call install,userspace/dtc)" CFLAGS="$(CROSS_CFLAGS)" NO_PYTHON=1 -C $(BUILD)/userspace/dtc/build install 3 | $(INSTALL_LIBS) userspace/dtc 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/dtc,build): $(call done,userspace/dtc,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) PKG_CONFIG=/bin/false CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS)" PREFIX="$(BUILD)/pearl/install" LDFLAGS="$(CROSS_CFLAGS)" NO_PYTHON=1 -C $(BUILD)/userspace/dtc/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/dtc,configure): $(call done,userspace/dtc,copy) $(call done,userspace/glibc,glibc/install) 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/dtc,copy): $(call done,userspace/dtc,checkout) | $(call done,userspace/dtc,) $(BUILD)/userspace/dtc/build/ 14 | $(COPY_SAUNA) $(PWD)/userspace/dtc/dtc/* $(BUILD)/userspace/dtc/build/ 15 | $(TIMESTAMP) 16 | 17 | $(call done,userspace/dtc,checkout): | $(call done,userspace/dtc,) 18 | $(MAKE) userspace/dtc/dtc{checkout} 19 | $(TIMESTAMP) 20 | 21 | userspace-modules += dtc 22 | 23 | DTC ?= dtc 24 | 25 | $(BUILD)/%.dtb.h: $(BUILD)/%.dtb 26 | (echo "{"; cat $< | od -tx4 --width=4 -Anone -v | sed -e 's/ \(.*\)/\t0x\1,/'; echo "};") > $@ 27 | 28 | $(BUILD)/%.dts.dtb: $(BUILD)/%.dts 29 | $(DTC) -Idts -Odtb $< > $@.tmp && mv $@.tmp $@ 30 | 31 | $(BUILD)/%.dtb.dts: $(BUILD)/%.dtb 32 | $(DTC) -Idtb -Odts $< > $@.tmp && mv $@.tmp $@ 33 | -------------------------------------------------------------------------------- /userspace/emacs/emacs.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/emacs,cross/install): $(call done,userspace/emacs,cross/build) 2 | $(NATIVE_CODE_ENV) PATH="$(CROSS_PATH):$$PATH" $(MAKE) -C $(BUILD)/userspace/emacs/cross DESTDIR=$(call install,userspace/emacs) install 3 | $(INSTALL_LIBS) userspace/emacs 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/emacs,cross/build): $(call done,userspace/emacs,cross/configure) 7 | $(NATIVE_CODE_ENV) PATH="$(CROSS_PATH):$$PATH" $(MAKE) -C $(BUILD)/userspace/emacs/cross/ 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/emacs,cross/configure): $(call done,userspace/emacs,cross/copy) $(call done,toolchain/gcc,gcc/install) $(call done,userspace/glibc,glibc/install) $(call done,userspace/ncurses,install) 11 | (cd $(BUILD)/userspace/emacs/cross; $(NATIVE_CODE_ENV) PATH="$(CROSS_PATH):$$PATH" ./configure --target=aarch64-linux-gnu --without-all --without-json --without-x --host=aarch64-linux-gnu CFLAGS="$(CROSS_CFLAGS)" --prefix=/) 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/emacs,cross/copy): $(call done,userspace/emacs,native/build) $(call done,userspace/emacs,checkout) | $(call done,userspace/emacs,cross/) $(BUILD)/userspace/emacs/cross/ 15 | $(COPY_SAUNA) $(BUILD)/userspace/emacs/native/* $(BUILD)/userspace/emacs/cross/ 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/emacs,native/build): $(call done,userspace/emacs,native/configure) 19 | $(MAKE) -C $(BUILD)/userspace/emacs/native 20 | $(TIMESTAMP) 21 | 22 | $(call done,userspace/emacs,native/configure): $(call done,userspace/emacs,native/copy) 23 | (cd $(BUILD)/userspace/emacs/native; sh autogen.sh) 24 | (cd $(BUILD)/userspace/emacs/native; ./configure --without-all --without-x) 25 | $(TIMESTAMP) 26 | 27 | $(call done,userspace/emacs,native/copy): $(call done,userspace/emacs,checkout) | $(call done,userspace/emacs,native/) $(BUILD)/userspace/emacs/native/ 28 | $(COPY_SAUNA) $(PWD)/userspace/emacs/emacs/* $(BUILD)/userspace/emacs/native/ 29 | $(TIMESTAMP) 30 | 31 | $(call done,userspace/emacs,checkout): | $(call done,userspace/emacs,) 32 | $(MAKE) userspace/emacs/emacs{checkout} 33 | $(TIMESTAMP) 34 | 35 | $(call done,userspace/emacs,install): $(call done,userspace/emacs,cross/install) 36 | $(TIMESTAMP) 37 | 38 | userspace-modules += emacs 39 | -------------------------------------------------------------------------------- /userspace/glibc/glibc.mk: -------------------------------------------------------------------------------- 1 | DEP_glibc += $(call done,userspace/glibc,glibc/install) 2 | $(call done,userspace/glibc,glibc/install): $(call done,userspace/glibc,glibc/build) 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/glibc/glibc/build DESTDIR=$(call install,userspace/glibc/glibc) CXX="" install 4 | $(INSTALL_LIBS) userspace/glibc 5 | $(TIMESTAMP) 6 | 7 | $(call done,userspace/glibc,glibc/build): $(call done,userspace/glibc,glibc/configure) 8 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/glibc/glibc/build CXX="" 9 | $(TIMESTAMP) 10 | 11 | $(call done,userspace/glibc,glibc/configure): $(call done,userspace/glibc,glibc/copy) $(call done,linux,headers/install) $(call done,toolchain/gcc,gcc/install) | $(BUILD)/userspace/glibc/glibc/build/ 12 | (cd $(BUILD)/userspace/glibc/glibc/build; $(WITH_CROSS_PATH) ../source/configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --disable-werror --prefix=/ CFLAGS="$(CROSS_CFLAGS) -Wno-error=array-bounds" CXX="") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/glibc,glibc/copy): $(call done,userspace/glibc,checkout) | $(BUILD)/userspace/glibc/glibc/source/ $(call done,userspace/glibc,glibc/) 16 | $(CP) -naus $(PWD)/userspace/glibc/glibc/* $(BUILD)/userspace/glibc/glibc/source/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/glibc,stage1/install): $(call done,userspace/glibc,stage1/build) 20 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/glibc/stage1/build DESTDIR=$(call install,userspace/glibc/stage1) install 21 | $(INSTALL_LIBS) userspace/glibc stage1 22 | $(TIMESTAMP) 23 | 24 | $(call done,userspace/glibc,stage1/build): $(call done,userspace/glibc,stage1/configure) 25 | $(TIMESTAMP) 26 | 27 | $(call done,userspace/glibc,stage1/configure): $(call done,userspace/glibc,stage1/copy) | $(BUILD)/userspace/glibc/stage1/build/ 28 | (cd $(BUILD)/userspace/glibc/stage1/build; $(WITH_CROSS_PATH) ../source/configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --disable-werror --prefix=/ CFLAGS="$(CROSS_CFLAGS)" CXX="") 29 | $(TIMESTAMP) 30 | 31 | $(call done,userspace/glibc,stage1/copy): $(call done,userspace/glibc,checkout) | $(BUILD)/userspace/glibc/stage1/source/ $(call done,userspace/glibc,stage1/) 32 | $(COPY_SAUNA) $(PWD)/userspace/glibc/glibc/* $(BUILD)/userspace/glibc/stage1/source/ 33 | $(TIMESTAMP) 34 | 35 | $(call done,userspace/glibc,headers/install): $(call done,userspace/glibc,headers/build) $(call done,pearl,install/mkdir) 36 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/glibc/headers/build DESTDIR=$(call install,userspace/glibc/headers) install-headers 37 | $(MKDIR) $(call install,userspace/glibc/headers)/include/gnu/ 38 | touch $(call install,userspace/glibc/headers)/include/gnu/stubs.h 39 | $(INSTALL_LIBS) userspace/glibc headers 40 | $(TIMESTAMP) 41 | 42 | $(call done,userspace/glibc,headers/build): $(call done,userspace/glibc,headers/configure) 43 | $(TIMESTAMP) 44 | 45 | $(call done,userspace/glibc,headers/configure): $(call done,userspace/glibc,headers/copy) $(call done,linux,headers/install) | $(BUILD)/userspace/glibc/headers/build/ 46 | (cd $(BUILD)/userspace/glibc/headers/build; $(WITH_CROSS_PATH) ../source/configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --disable-werror --prefix=/ CFLAGS="$(CROSS_CFLAGS)" CXX="") 47 | $(TIMESTAMP) 48 | 49 | $(call done,userspace/glibc,headers/copy): $(call done,userspace/glibc,checkout) | $(BUILD)/userspace/glibc/headers/source/ $(call done,userspace/glibc,headers/) 50 | $(COPY_SAUNA) $(PWD)/userspace/glibc/glibc/* $(BUILD)/userspace/glibc/headers/source/ 51 | $(TIMESTAMP) 52 | 53 | $(call done,userspace/glibc,checkout): | $(call done,userspace/glibc,) 54 | $(MAKE) userspace/glibc/glibc{checkout} 55 | $(TIMESTAMP) 56 | 57 | $(call done,userspace/glibc,install): $(call done,userspace/glibc,glibc/install) 58 | $(TIMESTAMP) 59 | 60 | userspace-modules += glibc 61 | -------------------------------------------------------------------------------- /userspace/json-c/json-c.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/json-c,install): $(call done,userspace/json-c,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/json-c/build DESTDIR="$(call install,userspace/json-c)" install 3 | $(INSTALL_LIBS) userspace/json-c 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/json-c,build): $(call done,userspace/json-c,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/json-c/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/json-c,configure): $(call done,userspace/json-c,copy) $(call deps,glibc gcc) 11 | (cd $(BUILD)/userspace/json-c/build; cmake -DCMAKE_LINKER=$(BUILD)/pearl/toolchain/bin/aarch64-linux-gnu-ld -DCMAKE_SHARED_LINKER=$(BUILD)/pearl/toolchain/bin/aarch64-linux-gnu-ld -DCMAKE_C_COMPILER=$(BUILD)/pearl/toolchain/bin/aarch64-linux-gnu-gcc -DCMAKE_C_FLAGS="-I$(BUILD)/pearl/install/include -L$(BUILD)/pearl/install/lib --sysroot=$(BUILD)/pearl/install" .) 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/json-c,copy): $(call done,userspace/json-c,checkout) | $(call done,userspace/json-c,) $(BUILD)/userspace/json-c/build/ 15 | $(CP) -au $(PWD)/userspace/json-c/json-c/* $(BUILD)/userspace/json-c/build/ 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/json-c,checkout): | $(call done,userspace/json-c,) 19 | $(MAKE) userspace/json-c/json-c{checkout} 20 | $(TIMESTAMP) 21 | 22 | userspace-modules += json-c 23 | -------------------------------------------------------------------------------- /userspace/kexec-tools/kexec-tools.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/kexec-tools,install): $(call done,userspace/kexec-tools,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/kexec-tools/source DESTDIR="$(call install,userspace/kexec-tools)" install 3 | $(INSTALL_LIBS) userspace/kexec-tools 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/kexec-tools,build): $(call done,userspace/kexec-tools,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/kexec-tools/source 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/kexec-tools,configure): $(call done,userspace/kexec-tools,copy) $(call deps,glibc gcc) 11 | (cd $(BUILD)/userspace/kexec-tools/source; ./bootstrap) 12 | (cd $(BUILD)/userspace/kexec-tools/source; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/kexec-tools,copy): $(call done,userspace/kexec-tools,checkout) | $(BUILD)/userspace/kexec-tools/source/ $(call done,userspace/kexec-tools,) 16 | $(COPY_SAUNA) $(PWD)/userspace/kexec-tools/kexec-tools/* $(BUILD)/userspace/kexec-tools/source/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/kexec-tools,checkout): | $(call done,userspace/kexec-tools,) 20 | $(MAKE) userspace/kexec-tools/kexec-tools{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += kexec-tools 24 | -------------------------------------------------------------------------------- /userspace/libaio/libaio.mk: -------------------------------------------------------------------------------- 1 | DEP_libaio += $(call done,userspace/libaio,install) 2 | $(call done,userspace/libaio,install): $(call done,userspace/libaio,build) 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libaio/build CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS)" DESTDIR=$(call install,userspace/libaio) install 4 | $(INSTALL_LIBS) userspace/libaio 5 | $(TIMESTAMP) 6 | 7 | $(call done,userspace/libaio,build): $(call done,userspace/libaio,configure) 8 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libaio/build CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS) -I." 9 | $(TIMESTAMP) 10 | 11 | $(call done,userspace/libaio,configure): $(call done,userspace/libaio,copy) $(call deps,libblkid glibc gcc) 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/libaio,copy): $(call done,userspace/libaio,checkout) | $(BUILD)/userspace/libaio/build/ $(call done,userspace/libaio,) 15 | $(COPY_SAUNA) $(PWD)/userspace/libaio/libaio/* $(BUILD)/userspace/libaio/build 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/libaio,checkout): | $(call done,userspace/libaio,) 19 | $(MAKE) userspace/libaio/libaio{checkout} 20 | $(TIMESTAMP) 21 | 22 | userspace-modules += libaio 23 | -------------------------------------------------------------------------------- /userspace/libnl/libnl.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/libnl,install): $(call done,userspace/libnl,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libnl/build DESTDIR=$(call install,userspace/libnl) install 3 | $(INSTALL_LIBS) userspace/libnl 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/libnl,build): $(call done,userspace/libnl,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libnl/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/libnl,configure): $(call done,userspace/libnl,copy) $(call deps,glibc gcc) 11 | (cd $(BUILD)/userspace/libnl/build; $(WITH_CROSS_PATH) sh autogen.sh) 12 | (cd $(BUILD)/userspace/libnl/build; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)" LDFLAGS="-L$(BUILD)/pearl/install/lib") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/libnl,copy): $(call done,userspace/libnl,checkout) | $(call done,userspace/libnl,) $(BUILD)/userspace/libnl/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/libnl/libnl/* $(BUILD)/userspace/libnl/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/libnl,checkout): | $(call done,userspace/libnl,) 20 | $(MAKE) userspace/libnl/libnl{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += libnl 24 | -------------------------------------------------------------------------------- /userspace/lvm2/lvm2.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/lvm2,install): $(call done,userspace/lvm2,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/lvm2/build DESTDIR=$(call install,userspace/lvm2) install 3 | $(INSTALL_LIBS) userspace/lvm2 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/lvm2,build): $(call done,userspace/lvm2,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/lvm2/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/lvm2,configure): $(call done,userspace/lvm2,copy) $(call deps,libaio libblkid glibc gcc) 11 | (cd $(BUILD)/userspace/lvm2/build; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS) -I." LDFLAGS="-L$(BUILD)/pearl/install/lib") 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/lvm2,copy): $(call done,userspace/lvm2,checkout) | $(BUILD)/userspace/lvm2/build/ $(call done,userspace/lvm2,) 15 | $(COPY_SAUNA) $(PWD)/userspace/lvm2/lvm2/* $(BUILD)/userspace/lvm2/build 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/lvm2,checkout): | $(call done,userspace/lvm2,) 19 | $(MAKE) userspace/lvm2/lvm2{checkout} 20 | $(TIMESTAMP) 21 | 22 | userspace-modules += lvm2 23 | -------------------------------------------------------------------------------- /userspace/memtool/memtool.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/memtool,install): $(call done,userspace/memtool,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/memtool/build install 3 | $(INSTALL_LIBS) userspace/memtool 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/memtool,build): $(call done,userspace/memtool,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/memtool/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/memtool,configure): $(call done,userspace/memtool,copy) $(call deps,glibc gcc) 11 | (cd $(BUILD)/userspace/memtool/build; $(WITH_CROSS_PATH) autoreconf -ivf) 12 | (cd $(BUILD)/userspace/memtool/build; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix="$(call install,userspace/memtool)" CFLAGS="$(CROSS_CFLAGS)") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/memtool,copy): $(call done,userspace/memtool,checkout) | $(call done,userspace/memtool,) $(BUILD)/userspace/memtool/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/memtool/memtool/* $(BUILD)/userspace/memtool/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/memtool,checkout): | $(call done,userspace/memtool,) 20 | $(MAKE) userspace/memtool/memtool{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += memtool 24 | -------------------------------------------------------------------------------- /userspace/ncurses/ncurses.mk: -------------------------------------------------------------------------------- 1 | DEP_ncurses += $(call done,userspace/ncurses,install) 2 | $(call done,userspace/ncurses,install): $(call done,userspace/ncurses,build) 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/ncurses/build install 4 | $(MKDIR) $(call install,userspace/ncurses)/lib/pkgconfig/ 5 | $(CP) $(call install,userspace/ncurses)/lib/aarch64-linux-gnu/pkgconfig/ncurses.pc $(call install,userspace/ncurses)/lib/pkgconfig/ || $(CP) $(call install,userspace/ncurses)/lib/x86_64-*linux-gnu/pkgconfig/ncurses.pc $(call install,userspace/ncurses)/lib/pkgconfig/ || true 6 | $(INSTALL_LIBS) userspace/ncurses 7 | $(TIMESTAMP) 8 | 9 | $(call done,userspace/ncurses,build): $(call done,userspace/ncurses,configure) 10 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/ncurses/build 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/ncurses,configure): $(call done,userspace/ncurses,copy) $(call deps,glibc gcc) 14 | (cd $(BUILD)/userspace/ncurses/build; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ --with-install-prefix=$(call install,userspace/ncurses) --disable-stripping CFLAGS="$(CROSS_CFLAGS)" CXXFLAGS="$(CROSS_CFLAGS)" --without-cxx-binding --enable-pc-files=yes) 15 | $(TIMESTAMP) 16 | 17 | $(call done,userspace/ncurses,copy): $(call done,userspace/ncurses,checkout) | $(call done,userspace/ncurses,) $(BUILD)/userspace/ncurses/build/ 18 | $(COPY_SAUNA) $(PWD)/userspace/ncurses/ncurses/* $(BUILD)/userspace/ncurses/build/ 19 | $(TIMESTAMP) 20 | 21 | $(call done,userspace/ncurses,checkout): | $(call done,userspace/ncurses,) 22 | $(MAKE) userspace/ncurses/ncurses{checkout} 23 | $(TIMESTAMP) 24 | 25 | userspace-modules += ncurses 26 | -------------------------------------------------------------------------------- /userspace/nvme-cli/nvme-cli.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/nvme-cli,install): $(call done,userspace/nvme-cli,build) 2 | $(WITH_CROSS_PATH) CFLAGS="$(CROSS_CFLAGS)" PREFIX="$(BUILD)/pearl/install" $(MAKE) $(WITH_CROSS_CC) -C $(BUILD)/userspace/nvme-cli/build install-bin 3 | $(INSTALL_LIBS) userspace/nvme-cli 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/nvme-cli,build): $(call done,userspace/nvme-cli,copy) $(call deps,glibc libblkid libuuid) 7 | $(WITH_CROSS_PATH) CFLAGS="$(CROSS_CFLAGS)" PREFIX="$(call install,userspace/nvme-cli)" $(MAKE) $(WITH_CROSS_CC) -C $(BUILD)/userspace/nvme-cli/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/nvme-cli,copy): $(call done,userspace/nvme-cli,checkout) | $(call done,userspace/nvme-cli,) $(BUILD)/userspace/nvme-cli/build/ 11 | $(COPY_SAUNA) $(PWD)/userspace/nvme-cli/nvme-cli/* $(BUILD)/userspace/nvme-cli/build/ 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/nvme-cli,checkout): | $(call done,userspace/nvme-cli,) 15 | $(MAKE) userspace/nvme-cli/nvme-cli{checkout} 16 | $(TIMESTAMP) 17 | 18 | userspace-modules += nvme-cli 19 | -------------------------------------------------------------------------------- /userspace/openssl/openssl.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/openssl,install): $(call done,userspace/openssl,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/openssl/build install 3 | $(INSTALL_LIBS) userspace/openssl 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/openssl,build): $(call done,userspace/openssl,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/openssl/build CFLAGS="$(CROSS_CFLAGS)" 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/openssl,configure): $(call done,userspace/openssl,copy) $(call deps,glibc gcc) 11 | (cd $(BUILD)/userspace/openssl/build/; $(WITH_CROSS_PATH) CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS)" ./Configure linux-aarch64 --prefix=$(call install,userspace/openssl)) 12 | $(TIMESTAMP) 13 | 14 | $(call done,userspace/openssl,copy): $(call done,userspace/openssl,checkout) | $(call done,userspace/openssl,) $(BUILD)/userspace/openssl/build/ 15 | $(COPY_SAUNA) $(PWD)/userspace/openssl/openssl/* $(BUILD)/userspace/openssl/build/ 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/openssl,checkout): | $(call done,userspace/openssl,) 19 | $(MAKE) userspace/openssl/openssl{checkout} 20 | $(TIMESTAMP) 21 | 22 | userspace-modules += openssl 23 | -------------------------------------------------------------------------------- /userspace/perl/perl.mk: -------------------------------------------------------------------------------- 1 | DEP_perl += $(call done,userspace/perl,install) 2 | $(call done,userspace/perl,install): $(call done,userspace/perl,build) 3 | $(NATIVE_CODE_ENV) $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/perl/build install 4 | $(INSTALL_LIBS) userspace/perl 5 | $(TIMESTAMP) 6 | 7 | $(call done,userspace/perl,build): $(call done,userspace/perl,configure) 8 | $(NATIVE_CODE_ENV) $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/perl/build 9 | $(TIMESTAMP) 10 | 11 | $(call done,userspace/perl,configure): $(call done,userspace/perl,copy) $(call deps,glibc gcc) 12 | (cd $(BUILD)/userspace/perl/build; $(NATIVE_CODE_ENV) $(WITH_CROSS_PATH) sh ./Configure -der -Uversiononly -Uusemymalloc -Dtargetarch="aarch64-linux-gnu" -Dcc="aarch64-linux-gnu-gcc $(CORE_CFLAGS)" -Dccflags="$(CORE_CFLAGS)" -Doptimize="$(CORE_CFLAGS) -fno-strict-aliasing" -Dincpth='' -Dcccdlflags="-fPIC -Wl,--shared -shared" -Dlddlflags="-Wl,--shared -shared" -Uman1dir -Dusedevel -Uversiononly -Dprefix="/" -Dsitelib="/lib/perl5/site_perl /share/perl5/site_perl" -Dinstallprefix="$(call install,userspace/perl)" -Dsysroot="$(BUILD)/pearl/install/") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/perl,copy): $(call done,userspace/perl,checkout) | $(BUILD)/userspace/perl/build/ $(call done,userspace/perl,) 16 | $(COPY_SAUNA) $(PWD)/userspace/perl/perl/* $(addprefix $(PWD)/userspace/perl/perl/.,dir-locals.el editorconfig lgtm.yml metaconf-exclusions.txt travis.yml) $(BUILD)/userspace/perl/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/perl,checkout): | $(call done,userspace/perl,) 20 | $(MAKE) userspace/perl/perl{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += perl 24 | -------------------------------------------------------------------------------- /userspace/popt/popt.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/popt,install): $(call done,userspace/popt,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/popt/build DESTDIR="$(call install,userspace/popt)" install 3 | $(INSTALL_LIBS) userspace/popt 4 | $(TIMESTAMP) 5 | 6 | $(BUILD)/userspace/popt/popt.tar: $(call done,userspace/popt,build) 7 | tar -C $(BUILD)/userspace/popt -cf $@ done build 8 | 9 | $(call done,userspace/popt,build): $(call done,userspace/popt,configure) 10 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/popt/build 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/popt,configure): $(call done,userspace/popt,copy) $(call deps,glibc gcc) 14 | (cd $(BUILD)/userspace/popt/build; $(WITH_CROSS_PATH) sh autogen.sh) 15 | (cd $(BUILD)/userspace/popt/build; $(WITH_CROSS_PATH) ./configure --target=aarch64-linux-gnu --host=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)") 16 | $(TIMESTAMP) 17 | 18 | $(call done,userspace/popt,copy): $(call done,userspace/popt,checkout) | $(call done,userspace/popt,) $(BUILD)/userspace/popt/build/ 19 | $(COPY_SAUNA) $(PWD)/userspace/popt/popt/* $(BUILD)/userspace/popt/build/ 20 | $(TIMESTAMP) 21 | 22 | $(call done,userspace/popt,checkout): | $(call done,userspace/popt,) 23 | $(MAKE) userspace/popt/popt{checkout} 24 | $(TIMESTAMP) 25 | 26 | userspace-modules += popt 27 | -------------------------------------------------------------------------------- /userspace/procps/procps.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/procps,install): $(call done,userspace/procps,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/procps/build DESTDIR="$(call install,userspace/procps)" install 3 | $(INSTALL_LIBS) userspace/procps 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/procps,build): $(call done,userspace/procps,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/procps/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/procps,configure): $(call done,userspace/procps,copy) $(call deps,glibc ncurses) 11 | (cd $(BUILD)/userspace/procps/build; $(WITH_CROSS_PATH) sh autogen.sh) 12 | (cd $(BUILD)/userspace/procps/build; $(WITH_CROSS_PATH) ./configure --target=aarch64-linux-gnu --host=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)" PKG_CONFIG_PATH="$(BUILD)/pearl/install/lib/pkgconfig") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/procps,copy): $(call done,userspace/procps,checkout) | $(call done,userspace/procps,) $(BUILD)/userspace/procps/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/procps/procps/* $(BUILD)/userspace/procps/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/procps,checkout): | $(call done,userspace/procps,) 20 | $(MAKE) userspace/procps/procps{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += procps 24 | -------------------------------------------------------------------------------- /userspace/screen/screen.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/screen,install): $(call done,userspace/screen,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/screen/build/src DESTDIR="$(call install,userspace/screen)" install 3 | $(INSTALL_LIBS) userspace/screen 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/screen,build): $(call done,userspace/screen,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/screen/build/src 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/screen,configure): $(call done,userspace/screen,copy) $(call deps,glibc ncurses) 11 | (cd $(BUILD)/userspace/screen/build/src; $(WITH_CROSS_PATH) autoreconf --install) 12 | (cd $(BUILD)/userspace/screen/build/src; $(WITH_CROSS_PATH) sh autogen.sh) 13 | (cd $(BUILD)/userspace/screen/build/src; $(WITH_CROSS_PATH) ./configure --target=aarch64-linux-gnu --host=aarch64-linux-gnu --prefix=/ --enable-pam=no CFLAGS="$(CROSS_CFLAGS)") 14 | $(TIMESTAMP) 15 | 16 | $(call done,userspace/screen,copy): $(call done,userspace/screen,checkout) | $(call done,userspace/screen,) $(BUILD)/userspace/screen/build/ 17 | $(COPY_SAUNA) $(PWD)/userspace/screen/screen/* $(BUILD)/userspace/screen/build/ 18 | $(TIMESTAMP) 19 | 20 | $(call done,userspace/screen,checkout): | $(call done,userspace/screen,) 21 | $(MAKE) userspace/screen/screen{checkout} 22 | $(TIMESTAMP) 23 | 24 | userspace-modules += screen 25 | -------------------------------------------------------------------------------- /userspace/slurp/slurp.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/slurp,install): $(call done,userspace/slurp,build) 2 | $(WITH_CROSS_PATH) $(WITH_QEMU) $(MAKE) -C $(BUILD)/userspace/slurp/build DESTDIR="$(call install,userspace/slurp)" install 3 | $(INSTALL_LIBS) userspace/slurp 4 | $(TIMESTAMP) 5 | 6 | $(BUILD)/userspace/slurp/slurp.tar: $(call done,userspace/slurp,build) 7 | tar -C $(BUILD)/userspace/slurp -cf $@ done build 8 | 9 | $(call done,userspace/slurp,build): $(call done,userspace/slurp,configure) 10 | $(WITH_CROSS_PATH) $(WITH_QEMU) $(MAKE) -C $(BUILD)/userspace/slurp/build 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/slurp,configure): $(call done,userspace/slurp,copy) $(call deps,perl) 14 | (cd $(BUILD)/userspace/slurp/build; $(WITH_CROSS_PATH) $(WITH_QEMU) perl Makefile.PL INSTALLSITELIB=/lib/perl5/site_perl) 15 | $(TIMESTAMP) 16 | 17 | $(call done,userspace/slurp,copy): $(call done,userspace/slurp,checkout) | $(call done,userspace/slurp,) $(BUILD)/userspace/slurp/build/ 18 | $(COPY_SAUNA) $(PWD)/userspace/slurp/slurp/* $(BUILD)/userspace/slurp/build/ 19 | $(TIMESTAMP) 20 | 21 | $(call done,userspace/slurp,checkout): | $(call done,userspace/slurp,) 22 | $(MAKE) userspace/slurp/slurp{checkout} 23 | $(TIMESTAMP) 24 | 25 | userspace-modules += slurp 26 | -------------------------------------------------------------------------------- /userspace/sys-mmap/sys-mmap.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/sys-mmap,install): $(call done,userspace/sys-mmap,build) 2 | $(WITH_CROSS_PATH) $(WITH_CROSS_CC) $(WITH_QEMU) $(MAKE) -C $(BUILD)/userspace/sys-mmap/build install 3 | $(INSTALL_LIBS) userspace/sys-mmap 4 | $(TIMESTAMP) 5 | 6 | $(BUILD)/userspace/sys-mmap/sys-mmap.tar: $(call done,userspace/sys-mmap,build) 7 | tar -C $(BUILD)/userspace/sys-mmap -cf $@ done build 8 | 9 | $(call done,userspace/sys-mmap,build): $(call done,userspace/sys-mmap,configure) 10 | $(WITH_CROSS_PATH) $(WITH_CROSS_CC) $(WITH_QEMU) $(MAKE) -C $(BUILD)/userspace/sys-mmap/build 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/sys-mmap,configure): $(call done,userspace/sys-mmap,copy) $(call deps,perl) 14 | (cd $(BUILD)/userspace/sys-mmap/build; export PERLDIR=$$(ls -d $(PWD)/build/pearl/install/lib/perl5/5.*); $(WITH_CROSS_PATH) $(WITH_CROSS_CC) $(WITH_QEMU) $(PWD)/build/pearl/install/bin/perl -I $$PERLDIR/linux-gnu -I $$PERLDIR Makefile.PL PERLPREFIX=$(PWD)/build/pearl/install/ PERL_ARCHLIB=$$PERLDIR/linux-gnu PERL_LIB=$$PERLDIR INSTALLDIRS=perl) 15 | $(TIMESTAMP) 16 | 17 | $(call done,userspace/sys-mmap,copy): $(call done,userspace/sys-mmap,checkout) | $(call done,userspace/sys-mmap,) $(BUILD)/userspace/sys-mmap/build/ 18 | $(COPY_SAUNA) $(PWD)/userspace/sys-mmap/sys-mmap/* $(BUILD)/userspace/sys-mmap/build/ 19 | $(TIMESTAMP) 20 | 21 | $(call done,userspace/sys-mmap,checkout): | $(call done,userspace/sys-mmap,) 22 | $(MAKE) userspace/sys-mmap/sys-mmap{checkout} 23 | $(TIMESTAMP) 24 | 25 | userspace-modules += sys-mmap 26 | -------------------------------------------------------------------------------- /userspace/userspace.mk: -------------------------------------------------------------------------------- 1 | include userspace/IPC-Run/IPC-Run.mk 2 | include userspace/busybox/busybox.mk 3 | include userspace/cryptsetup/cryptsetup.mk 4 | include userspace/dialog/dialog.mk 5 | include userspace/dropbear/dropbear.mk 6 | include userspace/dtc/dtc.mk 7 | include userspace/emacs/emacs.mk 8 | include userspace/glibc/glibc.mk 9 | include userspace/json-c/json-c.mk 10 | include userspace/kexec-tools/kexec-tools.mk 11 | include userspace/libaio/libaio.mk 12 | include userspace/libnl/libnl.mk 13 | include userspace/lvm2/lvm2.mk 14 | include userspace/memtool/memtool.mk 15 | include userspace/ncurses/ncurses.mk 16 | include userspace/openssl/openssl.mk 17 | include userspace/perl/perl.mk 18 | include userspace/popt/popt.mk 19 | include userspace/procps/procps.mk 20 | include userspace/screen/screen.mk 21 | include userspace/slurp/slurp.mk 22 | include userspace/sys-mmap/sys-mmap.mk 23 | include userspace/util-linux/util-linux.mk 24 | include userspace/wpa/wpa.mk 25 | include userspace/zlib/zlib.mk 26 | include userspace/zsh/zsh.mk 27 | include userspace/zstd/zstd.mk 28 | 29 | $(call done,userspace,%): $(foreach module,$(userspace-modules),$(call done,userspace/$(module),%)) | $(call done,userspace,) 30 | $(TIMESTAMP) 31 | 32 | SECTARGETS += $(call done,userspace,build) 33 | SECTARGETS += $(call done,userspace,install) 34 | 35 | $(BUILD)/userspace.tar: $(call done,userspace,install) 36 | tar -C . -cf $@ $(patsubst $(PWD)/%,%,$(BUILD)/pearl/install $(BUILD)/pearl/toolchain $(wildcard $(BUILD)/*/done)) 37 | -------------------------------------------------------------------------------- /userspace/util-linux/util-linux.mk: -------------------------------------------------------------------------------- 1 | DEP_libuuid += $(call done,userspace/libuuid,install) 2 | $(call done,userspace/libuuid,install): $(call done,userspace/libuuid,build) 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libuuid/build DESTDIR=$(call install,userspace/libuuid) install 4 | $(INSTALL_LIBS) userspace/libuuid 5 | $(TIMESTAMP) 6 | 7 | $(call done,userspace/libuuid,build): $(call done,userspace/libuuid,configure) 8 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libuuid/build 9 | $(TIMESTAMP) 10 | 11 | $(call done,userspace/libuuid,configure): $(call done,userspace/libuuid,copy) $(call deps,glibc gcc) 12 | (cd $(BUILD)/userspace/libuuid/build; $(WITH_CROSS_PATH) autoreconf -fi) 13 | (cd $(BUILD)/userspace/libuuid/build; $(WITH_CROSS_PATH) ./configure --disable-all-programs --enable-libuuid --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)" LDFLAGS="-L$(BUILD)/pearl/install/lib") 14 | $(TIMESTAMP) 15 | 16 | $(call done,userspace/libuuid,copy): $(call done,userspace/util-linux,checkout) | $(call done,userspace/libuuid,) $(BUILD)/userspace/libuuid/build/ 17 | $(COPY_SAUNA) $(PWD)/userspace/util-linux/util-linux/* $(BUILD)/userspace/libuuid/build/ 18 | $(TIMESTAMP) 19 | 20 | userspace-modules += libuuid 21 | 22 | DEP_libblkid += $(call done,userspace/libblkid,install) 23 | $(call done,userspace/libblkid,install): $(call done,userspace/libblkid,build) 24 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libblkid/build DESTDIR=$(call install,userspace/libblkid) install 25 | $(INSTALL_LIBS) userspace/libblkid 26 | $(TIMESTAMP) 27 | 28 | $(call done,userspace/libblkid,build): $(call done,userspace/libblkid,configure) 29 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/libblkid/build 30 | $(TIMESTAMP) 31 | 32 | $(call done,userspace/libblkid,configure): $(call done,userspace/libblkid,copy) $(call deps,glibc gcc) 33 | (cd $(BUILD)/userspace/libblkid/build; $(WITH_CROSS_PATH) autoreconf -fi) 34 | (cd $(BUILD)/userspace/libblkid/build; $(WITH_CROSS_PATH) ./configure --disable-all-programs --enable-libblkid --host=aarch64-linux-gnu --target=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)" LDFLAGS="-L$(BUILD)/pearl/install/lib") 35 | $(TIMESTAMP) 36 | 37 | $(call done,userspace/libblkid,copy): $(call done,userspace/util-linux,checkout) | $(call done,userspace/libblkid,) $(BUILD)/userspace/libblkid/build/ 38 | $(COPY_SAUNA) $(PWD)/userspace/util-linux/util-linux/* $(BUILD)/userspace/libblkid/build/ 39 | $(TIMESTAMP) 40 | 41 | userspace-modules += libblkid 42 | 43 | $(call done,userspace/util-linux,checkout): | $(call done,userspace/util-linux,) 44 | $(MAKE) userspace/util-linux/util-linux{checkout} 45 | $(TIMESTAMP) 46 | 47 | -------------------------------------------------------------------------------- /userspace/wpa/wpa.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/wpa_supplicant,install): $(call done,userspace/wpa_supplicant,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/wpa_supplicant/build/wpa_supplicant $(WITH_CROSS_CC) PKG_CONFIG=/bin/false DESTDIR=$(call install,userspace/wpa_supplicant) install 3 | $(INSTALL_LIBS) userspace/wpa_supplicant 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/wpa_supplicant,build): $(call done,userspace/wpa_supplicant,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/wpa_supplicant/build/wpa_supplicant $(WITH_CROSS_CC) EXTRA_CFLAGS="$(CROSS_CFLAGS) -I$(BUILD)/pearl/install/include/libnl3" PKG_CONFIG=/bin/false 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/wpa_supplicant,configure): userspace/wpa/wpa_supplicant.config $(call done,userspace/wpa_supplicant,copy) $(call done,userspace/libnl,install) $(call done,userspace/openssl,install) 11 | cp $< $(BUILD)/userspace/wpa_supplicant/build/wpa_supplicant/.config 12 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/wpa_supplicant/build/wpa_supplicant $(WITH_CROSS_CC) EXTRA_CFLAGS="$(CROSS_CFLAGS) -I$(BUILD)/pearl/install/include/libnl3" PKG_CONFIG=/bin/false defconfig 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/wpa_supplicant,copy): $(call done,userspace/wpa_supplicant,checkout) | $(BUILD)/userspace/wpa_supplicant/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/wpa/wpa/* $(BUILD)/userspace/wpa_supplicant/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/wpa_supplicant,checkout): | $(call done,userspace/wpa_supplicant,) 20 | $(MAKE) userspace/wpa/wpa{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += wpa_supplicant 24 | -------------------------------------------------------------------------------- /userspace/zlib/zlib.mk: -------------------------------------------------------------------------------- 1 | DEP_zlib += $(call done,userspace/zlib,install) 2 | $(call done,userspace/zlib,install): $(call done,userspace/zlib,build) 3 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/zlib/build install 4 | $(INSTALL_LIBS) userspace/zlib 5 | $(TIMESTAMP) 6 | 7 | $(call done,userspace/zlib,build): $(call done,userspace/zlib,configure) 8 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/zlib/build CFLAGS="$(CROSS_CFLAGS)" 9 | $(TIMESTAMP) 10 | 11 | $(call done,userspace/zlib,configure): $(call done,userspace/zlib,copy) $(call deps,glibc gcc) 12 | (cd $(BUILD)/userspace/zlib/build/; $(WITH_CROSS_PATH) CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS) -fPIC" ./configure --prefix=$(call install,userspace/zlib)) 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/zlib,copy): $(call done,userspace/zlib,checkout) | $(call done,userspace/zlib,) $(BUILD)/userspace/zlib/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/zlib/zlib/* $(BUILD)/userspace/zlib/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/zlib,checkout): | $(call done,userspace/zlib,) 20 | $(MAKE) userspace/zlib/zlib{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += zlib 24 | -------------------------------------------------------------------------------- /userspace/zsh/zsh.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/zsh,install): $(call done,userspace/zsh,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/zsh/build DESTDIR="$(call install,userspace/zsh)" install.bin install.modules install.fns 3 | $(INSTALL_LIBS) userspace/zsh 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/zsh,build): $(call done,userspace/zsh,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/zsh/build 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/zsh,configure): $(call done,userspace/zsh,copy) $(call deps,glibc gcc libgcc ncurses) 11 | (cd $(BUILD)/userspace/zsh/build; autoreconf -vif) 12 | (cd $(BUILD)/userspace/zsh/build; $(WITH_CROSS_PATH) ./configure --host=aarch64-linux-gnu --prefix=/ CFLAGS="$(CROSS_CFLAGS)") 13 | $(TIMESTAMP) 14 | 15 | $(call done,userspace/zsh,copy): $(call done,userspace/zsh,checkout) | $(call done,userspace/zsh,) $(BUILD)/userspace/zsh/build/ 16 | $(COPY_SAUNA) $(PWD)/userspace/zsh/zsh/* $(BUILD)/userspace/zsh/build/ 17 | $(TIMESTAMP) 18 | 19 | $(call done,userspace/zsh,checkout): | $(call done,userspace/zsh,) 20 | $(MAKE) userspace/zsh/zsh{checkout} 21 | $(TIMESTAMP) 22 | 23 | userspace-modules += zsh 24 | -------------------------------------------------------------------------------- /userspace/zstd/zstd.mk: -------------------------------------------------------------------------------- 1 | $(call done,userspace/zstd,install): $(call done,userspace/zstd,build) 2 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/zstd/build CROSS_COMPILE=aarch64-linux-gnu- CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS) -fPIC" PREFIX=$(call install,userspace/zstd) install 3 | $(INSTALL_LIBS) userspace/zstd 4 | $(TIMESTAMP) 5 | 6 | $(call done,userspace/zstd,build): $(call done,userspace/zstd,configure) 7 | $(WITH_CROSS_PATH) $(MAKE) -C $(BUILD)/userspace/zstd/build CROSS_COMPILE=aarch64-linux-gnu- CC=aarch64-linux-gnu-gcc CFLAGS="$(CROSS_CFLAGS) -fPIC" PREFIX=$(call install,userspace/zstd) 8 | $(TIMESTAMP) 9 | 10 | $(call done,userspace/zstd,configure): $(call done,userspace/zstd,copy) $(call deps,glibc gcc libgcc) 11 | $(TIMESTAMP) 12 | 13 | $(call done,userspace/zstd,copy): $(call done,userspace/zstd,checkout) | $(call done,userspace/zstd,) $(BUILD)/userspace/zstd/build/ 14 | $(COPY_SAUNA) $(PWD)/userspace/zstd/zstd/* $(BUILD)/userspace/zstd/build/ 15 | $(TIMESTAMP) 16 | 17 | $(call done,userspace/zstd,checkout): | $(call done,userspace/zstd,) 18 | $(MAKE) userspace/zstd/zstd{checkout} 19 | $(TIMESTAMP) 20 | 21 | userspace-modules += zstd 22 | -------------------------------------------------------------------------------- /video/barebox.mk: -------------------------------------------------------------------------------- 1 | $(eval $(BUILD)/video/barebox/script.gdb: | $(BUILD)/video/barebox/ ; $(call video-gdb-no-bootargs,$(BUILD)/bootloaders/barebox.image.gdb,$(BUILD)/bootloaders/barebox.image)) 2 | 3 | $(eval $(BUILD)/video/barebox/video.mp4: $(BUILD)/bootloaders/barebox.image.qemu $(BUILD)/video/barebox/script.gdb | $(BUILD)/video/barebox/ ; $(call video-mp4,$(BUILD)/video/barebox/data,$(BUILD)/video/barebox/script.gdb,$$<,1000)) 4 | 5 | $(BUILD)/video/barebox/video.mp4: $(call done,bootloaders/barebox,build) 6 | -------------------------------------------------------------------------------- /video/pearl-debian.mk: -------------------------------------------------------------------------------- 1 | $(eval $(BUILD)/video/pearl-debian/script.gdb: | $(BUILD)/video/pearl-debian/ ; $(call video-gdb-bootargs-x0,$(BUILD)/pearl-debian-uncompressed.macho.zst.image.gdb,,10000)) 2 | 3 | $(eval $(BUILD)/video/pearl-debian/video.mp4: $(BUILD)/pearl-debian-uncompressed.macho.zst.image.qemu $(BUILD)/video/pearl-debian/script.gdb | $(BUILD)/video/pearl-debian/ ; $(call video-mp4,$(BUILD)/video/pearl-debian/data,$(BUILD)/video/pearl-debian/script.gdb,$$<,2000)) 4 | -------------------------------------------------------------------------------- /video/pearl.mk: -------------------------------------------------------------------------------- 1 | $(eval $(BUILD)/video/pearl/script.gdb: | $(BUILD)/video/pearl/ ; $(call video-gdb-bootargs,$(BUILD)/linux/pearl.image.gdb,$(BUILD)/linux/pearl.image)) 2 | 3 | $(eval $(BUILD)/video/pearl/video.mp4: $(BUILD)/linux/pearl.image.qemu $(BUILD)/video/pearl/script.gdb | $(BUILD)/video/pearl/ ; $(call video-mp4,$(BUILD)/video/pearl/data,$(BUILD)/video/pearl/script.gdb,$$<,1000)) 4 | -------------------------------------------------------------------------------- /video/u-boot.mk: -------------------------------------------------------------------------------- 1 | $(eval $(BUILD)/video/u-boot/script.gdb: | $(BUILD)/video/u-boot/ ; $(call video-gdb-no-bootargs,$(BUILD)/bootloaders/u-boot.image.gdb,$(BUILD)/bootloaders/u-boot.image)) 2 | 3 | $(eval $(BUILD)/video/u-boot/video.mp4: $(BUILD)/bootloaders/u-boot.image.qemu $(BUILD)/video/u-boot/script.gdb | $(BUILD)/video/u-boot/ ; $(call video-mp4,$(BUILD)/video/u-boot/data,$(BUILD)/video/u-boot/script.gdb,$$<,1000)) 4 | 5 | $(BUILD)/video/u-boot/video.mp4: $(call done,bootloaders/barebox,build) 6 | $(BUILD)/video/u-boot/video.mp4: $(call done,bootloaders/u-boot,build) 7 | -------------------------------------------------------------------------------- /zstd/zstd.lds: -------------------------------------------------------------------------------- 1 | PHDRS { 2 | hdr PT_LOAD; 3 | text PT_LOAD; 4 | } 5 | 6 | SECTIONS { 7 | . = 0x800200000; 8 | /DISCARD/ : { *(.eh_frame) } 9 | .text : { 10 | *(.text) 11 | *(.bss) 12 | *(.data) 13 | *(.rodata.*) 14 | *(.rodata) 15 | } :text 16 | } 17 | -------------------------------------------------------------------------------- /zstd/zstdlib.c: -------------------------------------------------------------------------------- 1 | extern void *memcpy(void *dst, void *src, unsigned long count) __attribute__((used)); 2 | void *memcpy(void *dst, void *src, unsigned long count) 3 | { 4 | unsigned char *d8 = dst; 5 | unsigned char *s8 = src; 6 | while (count--) 7 | *d8++ = *s8++; 8 | return dst; 9 | } 10 | --------------------------------------------------------------------------------