logo

bootstrap-initrd

Linux initrd to bootstrap from a small binary seed git clone https://hacktivis.me/git/make-initrd.git
commit: eb6178be7fa7f91fc0860946d3db4c7fe378c604
parent 639205a9e7547b622b1ed346f033b7385de1aa5f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed,  1 May 2024 16:02:24 +0200

Add multiarch support

Diffstat:

MREADME.md5+++++
Mcommon.sh4+++-
Mdistfiles.SHA512SUM49++++++++++++++++++++++++++++++++++++++++++-------
Mfetch.sh17++++++++++-------
Mmake-initrd.sh5+++--
Mmake-root.sh7++++---
6 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md @@ -9,6 +9,11 @@ Full source bootstrap isn't intended as a goal but no further binaries than TCC Status: Very early experiments, has yet to build enough to bootstrap any distro. +## Architectures + +You can set `ALPINE_ARCH` to change the architecture, by default it's set to `x86_64` but `x86` (32-bit) is supported as well. +aarch64/armhf/armv7/riscv64/… can also be built but are untested. + ## Rationales Each of those roughly by their build order. diff --git a/common.sh b/common.sh @@ -12,7 +12,9 @@ APKS_testing=" ALPINE_MIRROR="http://dl-cdn.alpinelinux.org/alpine" # Alpine edge is definitely not a good way to do it but I need TCC with musl and /testing/ means edge-only ALPINE_BRANCH="edge" -ALPINE_ARCH="x86_64" +ALPINE_ARCH="${ALPINE_ARCH:-x86_64}" +# Architectures which alpine supports for tcc (+musl of course) +ALPINE_ARCHES="x86 x86_64 aarch64 armhf armv7 riscv64" die() { echo "[Error] die: ${*}" diff --git a/distfiles.SHA512SUM b/distfiles.SHA512SUM @@ -4,16 +4,51 @@ a054917c975f65dfb5f8eb35665044ddacacdbd2d1e1113e6bf62d5cd8d5f4fd775ff5f20e28191d2417016684a310f23115af102b834aa33083e2be41034477 distfiles/loksh-7.3.tar.xz 9d81ba58f5460e341d9de7c4b2af38c7bf39ae40fdcfac1652e7ad64bd903d58222128880daeb30ef5c1726a244d815ab9c7b22b9cb92c7aeaaa7728f29c4116 distfiles/minised-1.16.tar.gz 6acd3ee911442934082f4f877d795b07c5e23022eaa9c0874799d97e92a2f5a663cb45f94b7f9745c49cbbce6b7e755a29e381ccfb9e68a0be1eedbd22fd5d3b distfiles/mk-20210330.tar.gz -8bb997e077850195621916ee0722be7e054086fa5c2907c7d290ee8892910c073e3aece13a2839589966987711f4af6b2f4bffdc6c45d636a24655ef9cbec101 distfiles/musl-1.2.5-r0.apk -5d93191c3c9bf03b466dc169b57e519f0165c6551d117ae09538907c57a49f58afa3c9225aafc7a61625f224276eff4ee2dbe79d65cf684d03a46c24dd78aa4c distfiles/musl-dev-1.2.5-r0.apk -dacee8ce46c236fcc09ae767bd2f1bc1dfcba026a49134cb8f915d2d4ad31eb089fc8edeb8b1027276a9450ca14be56043747c93acbcbab334efa1bd20069084 distfiles/musl-libintl-1.2.5-r0.apk +dddd12728842e84bf7d532901d9b9e26e2c8c86e25a3625329586c9088ec9b3825ce3e512c56b7e875b923905308b89494d31d7ca05ebda5485bd00de3954236 distfiles/musl-1.2.5-r0.apk.aarch64 +4d76f479017b6f666c36782183f3bdb3e58a48f7400cd125c129e380a8654cf99f685f8d3e97b51cb0199b59720a320e251dd9b89fe55ef8f542a043ab3e7355 distfiles/musl-1.2.5-r0.apk.armhf +74e482403f77b9d302a4bb0ad6b86a18e81b5be0eb987296a4b0033c996e474b86eac079abc52bd8f02723aa242ea2a74e61bbd0eee036fbf79a21ae250a6e04 distfiles/musl-1.2.5-r0.apk.armv7 +c11fb5eed8dab05504d88660a4750981a40020a1609b4ec4f9184cf7645283893e7cafc48da471012a4095699d371517cc9e09c0ec73fef4612280c95feebca2 distfiles/musl-1.2.5-r0.apk.riscv64 +7403427bbe6683739ce00c0396dc4bfa8fce2f3e4957d12bc6c31bfb1a60bafca9e7ba266d1ba7ca469ab3738874965cf25e8f3bd838c002b4e5aad702a79e18 distfiles/musl-1.2.5-r0.apk.x86 +8bb997e077850195621916ee0722be7e054086fa5c2907c7d290ee8892910c073e3aece13a2839589966987711f4af6b2f4bffdc6c45d636a24655ef9cbec101 distfiles/musl-1.2.5-r0.apk.x86_64 +061e68319d2069c211169d7f39b1da572a4c0ab56f8cfe5267c024921ea0e5f44ecc1cca6051bebaa9c83d067f0fd2cbc6b6b73d0e3075410eaf889a25cc82b4 distfiles/musl-dev-1.2.5-r0.apk.aarch64 +7fa4e9ed4acb6292d46939a63e572eb92085e577bbfce75139a3ebef910434230fcbbb7a236efde7ad6d150d84e31c46edcfe835f4102cb9e68f062eb8488a1e distfiles/musl-dev-1.2.5-r0.apk.armhf +02321d629aaa3712546b01645f1eb308f5e25e49bc3c2c42eff3a7cf84cd60327c6bc9818ebeb7d1d9556ddfaa2e132fdab0dc2142eec4df3a799e3402329c49 distfiles/musl-dev-1.2.5-r0.apk.armv7 +77eba42ed78e680419f838f47a9a9f17d42288259540b70792af23b22f85ba1d2f87958e7db77b11b43629d8593fa58a02902453ecb0a46dd7c33cfca750b820 distfiles/musl-dev-1.2.5-r0.apk.riscv64 +f5b0dfe7543bd7d1de3bfc8617c61fb7287227ea4dd9a722bfd4ec99e8a9405826973375a81a380b04bcba419c18e292cf60aaf1c9503eec3b420ed7adbacd68 distfiles/musl-dev-1.2.5-r0.apk.x86 +5d93191c3c9bf03b466dc169b57e519f0165c6551d117ae09538907c57a49f58afa3c9225aafc7a61625f224276eff4ee2dbe79d65cf684d03a46c24dd78aa4c distfiles/musl-dev-1.2.5-r0.apk.x86_64 +724094f7eb066e2c83f9c4090b8939090440cd37c381b81315f8c35c0b144b87a1f8949707084a4cf2d166d68d744e387ab1f7e973cef18701bf767e62e098ef distfiles/musl-libintl-1.2.5-r0.apk.aarch64 +05311c77083695ad0c184dea04c7557c4bd83a436a4db7c210229f0e6530132ad5c5f329c8f3d04aac595bf18ae6ff71446610374eb3d7846533832e74a463c2 distfiles/musl-libintl-1.2.5-r0.apk.armhf +d74d86400cb5a772f8652d3c08fd041ae7999475eeef500aa8bca6c11109389d6604764184136a4b53835fdc5769fcb4fbeef9acb1caa8681f97ba3404128730 distfiles/musl-libintl-1.2.5-r0.apk.armv7 +54655fc021c3ca58a8db3d6af7745079495730ee7d9480ba294906d6c47a663977e687925ecacf117d3783207328e8188a2a5f8ad42278cce2f36d9c0aecda8b distfiles/musl-libintl-1.2.5-r0.apk.riscv64 +05d97e8c9f1428e5d391bcaa010f0883997f955d302531b602b943732e474aac534b671d6a20792894432c9eef1de94c8fd4e319449e655e83e166eee5a02f33 distfiles/musl-libintl-1.2.5-r0.apk.x86 +dacee8ce46c236fcc09ae767bd2f1bc1dfcba026a49134cb8f915d2d4ad31eb089fc8edeb8b1027276a9450ca14be56043747c93acbcbab334efa1bd20069084 distfiles/musl-libintl-1.2.5-r0.apk.x86_64 3d5626b0d6033a9eb8f3d81acbe0b30842e99f4c40563ca3f906ecfebdb72d754de18cd180345131868ad325fead4a6e66bfb765af45267180e256f46a76f316 distfiles/nawk-20240422.tar.gz a64d6dcf3f4319cf40af684d0775f8c7e3a21e07a5262fc83b588bf7ea85f2e91d2d171307c93734799af59e1dc50c498543356c78cbaf7fb721a14f71f128c2 distfiles/om4-6.7.tar.gz ae3d9d593e1645d65f9ab77aa828600c9af4bb30d0a073da7ae3dd805e65b87efaf6a0efb980f2d0168e475ae506eba194547d6479956dabb9d88293a9078a7f distfiles/pigz-2.8.tar.gz -87b951c39d35684bb7c8ddb9952009294de1f39ae3632a8cb5d27233fa1ef2551af1cd5d7c10220c0035011c68569bc85c382878180bb51d3a55241646e587ee distfiles/tcc-0.9.27_git20240117-r0.apk -a9329a3fccbdeb033c2352355e4ac09d7d1bde62e375d9e13ee8c4e2c5c67b923f770e8d54b4b25fadbd5f74d46132f781d618db6b3e6fdb3db60222dc746217 distfiles/tcc-dev-0.9.27_git20240117-r0.apk -6511c496d31d33ad7a14f1be6dee3383ffd178046fc6a717f63ccfe8b65174c4a49a48b08eea5ab0e751e93daf59d0979fd6020329d26e54523b1a8d623cd66e distfiles/tcc-libs-0.9.27_git20240117-r0.apk -b89b489fbee7c19a21175ad61168d250856801175fa000261b35202312148ee8e7b6cb1994d042503ad36f2651ee1ba68c4f83d96051abb50fb4e0e5dbc78960 distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk +991f742ead7dcfd063b7e9bdc5d604353da76038729b599a597e6dd55ba7c9f4dd1df5f508f8b42a1c8b41e711301d772a69f015917c4c4ec678717784efc714 distfiles/tcc-0.9.27_git20240117-r0.apk.aarch64 +41c4bfcd5b68a236ead6910cc28edcc47775f0221f032bae33f67239342c08a12405da8c32e5f3fb25c4d57af4005a359526d0854284787331fd1f2183d30d75 distfiles/tcc-0.9.27_git20240117-r0.apk.armhf +13f5b9d5f40e8ae27c66f4d5d4499f1f4d17ae27a04981a1aa4542a08630ebe3d8ad0f58521a951b1ffe9f236a4e2ae2dbe29aafbd2c19f8a6c576b667cdf4ff distfiles/tcc-0.9.27_git20240117-r0.apk.armv7 +fbdc81a0ac4f52edc83cea4e0b1406afa459ea5e55977045a32ea52cda4ae41bc083ae336c454d0f31031882d25747f7ec2adc0bdce907f0343329c9988e2038 distfiles/tcc-0.9.27_git20240117-r0.apk.riscv64 +18adc5ddf67a82c5ec2911c2864832b25e752ea3e77362108303a030abbacf26691dd1563bb752d13b3173058e67ba603aabba70c5f4c5cecb05767e57de0915 distfiles/tcc-0.9.27_git20240117-r0.apk.x86 +87b951c39d35684bb7c8ddb9952009294de1f39ae3632a8cb5d27233fa1ef2551af1cd5d7c10220c0035011c68569bc85c382878180bb51d3a55241646e587ee distfiles/tcc-0.9.27_git20240117-r0.apk.x86_64 +6ac80ebcf03565b466a44aa1ed2d36276f39c9e1eed76b147e5a25a165865f14aeac9238a2a06ce1dd9c0235964c10e8f16739a01f1ccbf40c3c5322ee63d1ba distfiles/tcc-dev-0.9.27_git20240117-r0.apk.aarch64 +fcda57ee1e2943ded9355031ac204d6ce0bbbc050412140f237e5a05a0b1c6c5678a599c3b15394a8073bd6df5c510fa11bb63e6a6c783c9c471b3211964e476 distfiles/tcc-dev-0.9.27_git20240117-r0.apk.armhf +86c9793680a0688d544c61ce324c27099ae8881aed26b8e8050a8725756dedd83a8a367efb9feeb8e3a8c5a859e0e156605c805442772c8c4c8cf74997480189 distfiles/tcc-dev-0.9.27_git20240117-r0.apk.armv7 +e39db9bd75f52e5a602ca2ce4b69d9f990a075c1fa02587924d1076e75ba81978683a2e43a7b100172a7e2eb898e47c451a5b9d6b4231157c8d50ffaf6efdae0 distfiles/tcc-dev-0.9.27_git20240117-r0.apk.riscv64 +d3d9577939d0b0233a0ee5b15895be5263812d9ec4cc17ea8dda821ceb53fb43af447437b369d35ebfca09a0b46d53de875421136be19cc595d81d884a6de363 distfiles/tcc-dev-0.9.27_git20240117-r0.apk.x86 +a9329a3fccbdeb033c2352355e4ac09d7d1bde62e375d9e13ee8c4e2c5c67b923f770e8d54b4b25fadbd5f74d46132f781d618db6b3e6fdb3db60222dc746217 distfiles/tcc-dev-0.9.27_git20240117-r0.apk.x86_64 +08cf5a86451132bf191879dc21cab50684c3e91c5b18374da27e2e7dc526981963274220f3e0baee1c562d956ecc29e185ec6c2cc19e53b02031c9dc6de03ae1 distfiles/tcc-libs-0.9.27_git20240117-r0.apk.aarch64 +fef088714e115c000cc1e52cccb03e46d924a814ccfe4e5fa4d3e0e281995768b348673893a8156a15402222ecb0e696721bd4f8db35672e6cfc8600b26c3ebb distfiles/tcc-libs-0.9.27_git20240117-r0.apk.armhf +708718f6bcc954ae65ac616ed8f959be83eaac207c7893ff042de8085d03d94980c90d9286d2bd3ab94a097588fce9ac06e0e2f9f378ada8f1dafd6703531629 distfiles/tcc-libs-0.9.27_git20240117-r0.apk.armv7 +fe7b2529e4f65be34cdbc9b70bfa8189f19585781853564fa5667230001c08dbcc7c5f67f2e98b72e9496dd6f994a4cb361a3b817cba7b8f6a050b414d4e6d1b distfiles/tcc-libs-0.9.27_git20240117-r0.apk.riscv64 +a8fc33e3369cae75341c7a5d2b222770458f0e55065019eeeaed312ee93f6919373418f7c10da1c9ac774bf7814d38ad8851bf12cbbdb07f53ac5ce9981aa1bd distfiles/tcc-libs-0.9.27_git20240117-r0.apk.x86 +6511c496d31d33ad7a14f1be6dee3383ffd178046fc6a717f63ccfe8b65174c4a49a48b08eea5ab0e751e93daf59d0979fd6020329d26e54523b1a8d623cd66e distfiles/tcc-libs-0.9.27_git20240117-r0.apk.x86_64 +ede1616d9892b2ca1fdb332a4329ac26f544321620cae1abc73bea13c79120599e7bc626296494ef02a11170324ad8055e98c036076945e19d4bb5d7de528ae5 distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk.aarch64 +0b912e876dd871ac8dbd8ab7360ac4c650a4b98793c661a563a3cf8af5b3de53002aa960903afe480a251582777e94eb4f0af86efa591d504fff361e27b49aa1 distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk.armhf +54c0d34cbea15fe374617ec0fb40662776026919f0460cc96b1f3e1be4bf122352aceb33b3e4a4267414ec123ed4bd896d5afe2542d23c7ae4b2b6e4ed364965 distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk.armv7 +3a9059301beabff72586d4de2df1713005426fe1951cf6f09371b80411ab5a3e7831f154765c7af24dd87f19894bbc2e41905ac0c362f0f438ef6c89ff6af0e0 distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk.riscv64 +b932d4c4d05193a4c68370607234f3d77ce0fba93aadf6323529ad6aa56e51b38309c0d85870a040baac704eb30807a71e6510351e8893fbd2aa7b1265027ecc distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk.x86 +b89b489fbee7c19a21175ad61168d250856801175fa000261b35202312148ee8e7b6cb1994d042503ad36f2651ee1ba68c4f83d96051abb50fb4e0e5dbc78960 distfiles/tcc-libs-static-0.9.27_git20240117-r0.apk.x86_64 52f040e8d0f07d12f4625c0b6de19b2a82bf2fb45aec8518a5c53e96a79512c24ad22661b7ce327b4b0f0705e54ee28fdea5b1ecb5497e341733458d9d666347 distfiles/utils-std-75774b4.tar.gz 6adb51c5f07e8084a86688589f52d9eee0183fb4d77508e36621a6b0ba91a5c4195feb87db3401ec69560554f71f2f6984dec01266e41e0fd54fa72ef1780e80 distfiles/yacc-1.9.1.tar.Z 1e8e70b362d64a233591906a1f50b59001db04ca14aaffad522198b04680be501736e7d536b4191e2f99767e7001ca486cd802362cca2be05d5d409b83ea732d distfiles/zlib-1.3.1.tar.xz diff --git a/fetch.sh b/fetch.sh @@ -25,14 +25,17 @@ do test -e "$file" || curl -L -o "$file" "$url" done -for apk in $APKS_main +for arch in ${ALPINE_ARCH:-$ALPINE_ARCHES} do - test -e "$apk" || curl -L -o "$apk" "${ALPINE_MIRROR}/${ALPINE_BRANCH}/main/${ALPINE_ARCH}/${apk}" -done - -for apk in $APKS_testing -do - test -e "$apk" || curl -L -o "$apk" "${ALPINE_MIRROR}/${ALPINE_BRANCH}/testing/${ALPINE_ARCH}/${apk}" + for apk in $APKS_main + do + test -e "$apk.$arch" || curl -L -o "$apk.${arch}" "${ALPINE_MIRROR}/${ALPINE_BRANCH}/main/${arch}/${apk}" + done + + for apk in $APKS_testing + do + test -e "$apk.$arch" || curl -L -o "$apk.${arch}" "${ALPINE_MIRROR}/${ALPINE_BRANCH}/testing/${arch}/${apk}" + done done # Only has ./CVS and .travis-ci.yml removed compared to Github autogenerated tarball diff --git a/make-initrd.sh b/make-initrd.sh @@ -5,11 +5,12 @@ WORKDIR="$(dirname "$0")" WORKDIR="$(realpath "$WORKDIR")" -name_base="initramfs-tcc" -out_base="${WORKDIR}/${name_base}" . "$WORKDIR/common.sh" +name_base="initramfs-tcc-${ALPINE_ARCH}" +out_base="${WORKDIR}/${name_base}" + set -ex ./make-root.sh || die "Failed: make-root" diff --git a/make-root.sh b/make-root.sh @@ -18,11 +18,12 @@ tarballs=" " WORKDIR="$(dirname "$0")" WORKDIR="$(realpath "$WORKDIR")" -name_base="initramfs-tcc" -out_base="${WORKDIR}/${name_base}" . "$WORKDIR/common.sh" +name_base="initramfs-tcc-${ALPINE_ARCH}" +out_base="${WORKDIR}/${name_base}" + gen_loksh_tcc_h() { cd loksh-*/ || die printf 'char *loksh_tcc_cmd[] = {' @@ -69,7 +70,7 @@ done for apk in $APKS_main $APKS_testing do - tar xf "${WORKDIR}/distfiles/$apk" --exclude '.*' + tar xf "${WORKDIR}/distfiles/$apk.${ALPINE_ARCH}" --exclude '.*' done # Allows to shave off ~9.1M from the binary seed rm usr/lib/libc.a