2021-01-29 01:31:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-04-13 00:08:29 +01:00
|
|
|
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
|
2022-03-07 07:58:20 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
|
2021-02-19 16:14:54 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
|
2021-02-18 07:29:58 +00:00
|
|
|
#
|
2021-01-29 01:31:56 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-04-07 00:14:52 +01:00
|
|
|
# shellcheck disable=SC2154
|
2022-09-16 08:34:07 +01:00
|
|
|
PREFIX="${prefix}"
|
2022-09-14 13:07:13 +01:00
|
|
|
# shellcheck disable=SC2034
|
2022-09-17 06:41:10 +01:00
|
|
|
LIBDIR="${prefix}/lib/i386-unknown-linux-musl"
|
2022-04-07 00:14:52 +01:00
|
|
|
# shellcheck disable=SC2154
|
2022-09-16 08:34:07 +01:00
|
|
|
SOURCES="${sysa}"
|
|
|
|
DISTFILES="${sysa}/distfiles"
|
|
|
|
DESTDIR=/tmp/destdir
|
2022-05-20 15:55:35 +01:00
|
|
|
# shellcheck disable=SC2154
|
2022-09-16 08:34:07 +01:00
|
|
|
SRCDIR="${srcdir}"
|
2021-07-26 06:19:07 +01:00
|
|
|
|
2022-05-23 06:56:18 +01:00
|
|
|
# shellcheck source=sysa/helpers.sh
|
|
|
|
. helpers.sh
|
|
|
|
|
2021-07-06 01:52:10 +01:00
|
|
|
create_sysb() {
|
|
|
|
# Copy everything in
|
|
|
|
echo "Creating sysb rootfs"
|
2022-05-23 06:56:18 +01:00
|
|
|
sys_transfer /sysb_image /sysb gzip patch
|
|
|
|
cp -rl /sysc /sysb_image/sysc_src
|
2021-10-10 21:54:23 +01:00
|
|
|
echo "Creating sysb initramfs"
|
2022-05-23 06:56:18 +01:00
|
|
|
gen_initramfs_list.sh -o "${PREFIX}/boot/initramfs-sysb.cpio.gz" /sysb_image
|
2022-05-22 01:03:21 +01:00
|
|
|
rm -rf /sysb /sysb_image # Cleanup
|
2021-07-06 01:52:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
go_sysb() {
|
|
|
|
# Mount proc for kexec
|
|
|
|
mkdir /proc /etc
|
|
|
|
mount -t proc proc /proc
|
|
|
|
# kexec time
|
|
|
|
echo "Loading kernel + sysb initramfs using kexec"
|
2021-08-04 03:56:07 +01:00
|
|
|
kexec -l "${PREFIX}/boot/linux-4.9.10" --console-serial \
|
2021-10-10 21:54:23 +01:00
|
|
|
--initrd="${PREFIX}/boot/initramfs-sysb.cpio.gz" \
|
2021-08-04 03:56:07 +01:00
|
|
|
--append="init=/init console=ttyS0"
|
2021-07-06 01:52:10 +01:00
|
|
|
echo "kexecing into sysb"
|
|
|
|
kexec -e
|
2021-02-27 12:22:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-03 02:28:08 +01:00
|
|
|
# Ask some questions
|
|
|
|
echo
|
|
|
|
echo "Now that bash has been built, there are potentially some questions for you!"
|
|
|
|
echo "To give your answer, type your answer, press Enter, and then Control-D."
|
|
|
|
echo
|
|
|
|
|
|
|
|
ask_chroot() {
|
|
|
|
read -r CHROOT_STRING
|
|
|
|
if [ "${CHROOT_STRING}" = "yes" ] || [ "${CHROOT_STRING}" = "y" ]; then
|
|
|
|
CHROOT=True
|
|
|
|
elif [ "${CHROOT_STRING}" = "no" ] || [ "${CHROOT_STRING}" = "n" ]; then
|
|
|
|
CHROOT=False
|
|
|
|
else
|
|
|
|
echo "Invalid response. Please give a yes/no answer."
|
|
|
|
ask_chroot
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "${CHROOT}" ]; then
|
|
|
|
echo "Currently, it is unknown if live-bootstrap is running in a chroot"
|
|
|
|
echo "or not. Is it? (yes/no answer)"
|
|
|
|
ask_chroot
|
|
|
|
echo
|
2022-03-06 12:07:03 +00:00
|
|
|
|
2022-05-15 09:49:50 +01:00
|
|
|
echo "CHROOT=${CHROOT}" >> "${SOURCES}/bootstrap.cfg"
|
2021-10-03 02:28:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
ask_timestamps() {
|
|
|
|
read -r TIMESTAMPS_STRING
|
|
|
|
if [ "${TIMESTAMPS_STRING}" = "yes" ] || [ "${TIMESTAMPS_STRING}" = "y" ]; then
|
|
|
|
FORCE_TIMESTAMPS=True
|
|
|
|
elif [ "${TIMESTAMPS_STRING}" = "no" ] || [ "${TIMESTAMPS_STRING}" = "n" ]; then
|
|
|
|
FORCE_TIMESTAMPS=False
|
|
|
|
else
|
|
|
|
echo "Invalid response. Please give a yes/no answer."
|
|
|
|
ask_timestamps
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "${FORCE_TIMESTAMPS}" ]; then
|
|
|
|
echo "Would you like all timestamps to be set to unix time 0"
|
|
|
|
echo "(Jan 1 1970 00:00) at the end of the bootstrap? This makes a"
|
|
|
|
echo "fully reproducible disk image. (yes/no answer)"
|
|
|
|
ask_timestamps
|
|
|
|
echo
|
2022-03-06 12:07:03 +00:00
|
|
|
|
2022-05-15 09:49:50 +01:00
|
|
|
echo "FORCE_TIMESTAMPS=${FORCE_TIMESTAMPS}" >> "${SOURCES}/bootstrap.cfg"
|
2021-10-03 02:28:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Thank you! All done."
|
|
|
|
|
2022-05-15 09:49:50 +01:00
|
|
|
echo "ARCH=${ARCH}" >> "${SOURCES}/bootstrap.cfg"
|
2021-10-03 02:28:08 +01:00
|
|
|
|
2022-05-20 15:55:35 +01:00
|
|
|
mkdir -p "${DESTDIR}" "${SRCDIR}/repo" /dev
|
2022-01-14 11:02:08 +00:00
|
|
|
|
2021-02-07 15:39:42 +00:00
|
|
|
build flex-2.5.11
|
2021-01-29 01:31:56 +00:00
|
|
|
|
2022-12-25 01:49:54 +00:00
|
|
|
# Rebuild tcc with some patches
|
|
|
|
build tcc-0.9.27 tcc-mes-pass2.sh
|
|
|
|
|
2022-05-04 19:32:45 +01:00
|
|
|
build musl-1.1.24
|
2021-01-28 18:53:44 +00:00
|
|
|
|
2021-02-25 05:48:21 +00:00
|
|
|
# Rebuild tcc using musl
|
2022-05-04 19:32:45 +01:00
|
|
|
build tcc-0.9.27 tcc-musl-pass1.sh
|
2021-02-01 01:09:24 +00:00
|
|
|
|
2021-02-25 05:48:21 +00:00
|
|
|
# Rebuild musl using tcc-musl
|
2022-05-04 19:32:45 +01:00
|
|
|
build musl-1.1.24
|
2021-02-03 00:16:39 +00:00
|
|
|
|
2021-02-25 05:48:21 +00:00
|
|
|
# Rebuild tcc-musl using new musl
|
2022-05-04 19:32:45 +01:00
|
|
|
build tcc-0.9.27 tcc-musl-pass2.sh
|
2021-02-15 08:33:12 +00:00
|
|
|
|
2021-03-11 18:12:52 +00:00
|
|
|
# Rebuild sed using musl
|
2022-05-04 19:32:45 +01:00
|
|
|
build sed-4.0.9 sed-4.0.9.sh
|
2021-03-11 18:12:52 +00:00
|
|
|
|
2021-02-25 05:48:21 +00:00
|
|
|
# Rebuild bzip2 using musl
|
2022-05-04 19:32:45 +01:00
|
|
|
build bzip2-1.0.8 bzip2-1.0.8.sh
|
2021-02-19 16:14:54 +00:00
|
|
|
|
2021-02-24 01:28:23 +00:00
|
|
|
build m4-1.4.7
|
2021-02-19 16:14:54 +00:00
|
|
|
|
2021-02-24 01:28:23 +00:00
|
|
|
build flex-2.6.4
|
|
|
|
|
2022-05-04 19:32:45 +01:00
|
|
|
build bison-3.4.1 stage1.sh
|
|
|
|
build bison-3.4.1 stage2.sh
|
|
|
|
build bison-3.4.1 stage3.sh
|
2021-02-04 21:41:43 +00:00
|
|
|
|
2021-02-10 18:06:40 +00:00
|
|
|
build grep-2.4
|
|
|
|
|
2021-02-06 00:16:32 +00:00
|
|
|
build diffutils-2.7
|
|
|
|
|
2021-02-25 05:48:21 +00:00
|
|
|
# Rebuild coreutils using musl
|
2022-05-17 01:01:48 +01:00
|
|
|
build coreutils-5.0 coreutils-5.0.sh patches-musl
|
2021-02-07 23:05:02 +00:00
|
|
|
|
2021-03-23 19:14:45 +00:00
|
|
|
# Build only date, mktemp and sha256sum
|
|
|
|
build coreutils-6.10
|
2021-02-28 20:53:20 +00:00
|
|
|
|
2021-02-11 09:22:12 +00:00
|
|
|
build gawk-3.0.4
|
|
|
|
|
2021-02-17 20:23:50 +00:00
|
|
|
build perl-5.000
|
2021-02-14 15:36:05 +00:00
|
|
|
|
2021-02-17 20:23:50 +00:00
|
|
|
build perl-5.003
|
2021-02-16 23:20:34 +00:00
|
|
|
|
2022-05-04 19:32:45 +01:00
|
|
|
build perl5.004-05 '' '' perl5.004_05
|
2021-02-17 23:46:18 +00:00
|
|
|
|
2022-05-04 19:32:45 +01:00
|
|
|
build perl5.005-03 '' '' perl5.005_03
|
2021-02-18 23:19:09 +00:00
|
|
|
|
2021-02-24 01:02:10 +00:00
|
|
|
build perl-5.6.2
|
|
|
|
|
2021-02-27 12:22:22 +00:00
|
|
|
populate_device_nodes
|
|
|
|
|
2021-02-27 17:35:02 +00:00
|
|
|
build autoconf-2.52 stage1.sh
|
2021-02-21 21:09:47 +00:00
|
|
|
|
2021-03-17 00:24:37 +00:00
|
|
|
build automake-1.6.3 stage1.sh
|
|
|
|
build automake-1.6.3 stage2.sh
|
|
|
|
build automake-1.6.3 stage3.sh
|
|
|
|
|
|
|
|
build automake-1.4-p6
|
2021-02-27 17:08:17 +00:00
|
|
|
|
2021-02-27 17:35:02 +00:00
|
|
|
build autoconf-2.52 stage2.sh
|
|
|
|
|
2021-02-27 20:07:04 +00:00
|
|
|
build autoconf-2.13
|
|
|
|
|
2021-02-27 22:42:23 +00:00
|
|
|
build autoconf-2.12
|
|
|
|
|
2021-03-25 19:14:34 +00:00
|
|
|
build libtool-1.4
|
2021-03-12 00:28:29 +00:00
|
|
|
|
2021-02-24 14:38:10 +00:00
|
|
|
build binutils-2.14
|
|
|
|
|
2021-03-03 00:05:33 +00:00
|
|
|
# Build musl with fewer patches
|
2022-05-04 19:32:45 +01:00
|
|
|
build musl-1.1.24 binutils-rebuild.sh patches-pass3
|
2021-03-03 00:05:33 +00:00
|
|
|
|
2021-03-03 00:54:17 +00:00
|
|
|
# Rebuild tcc-musl using new musl
|
2022-05-04 19:32:45 +01:00
|
|
|
build tcc-0.9.27 tcc-musl-pass3.sh patches-musl-pass3
|
|
|
|
|
|
|
|
populate_device_nodes
|
2021-03-03 00:54:17 +00:00
|
|
|
|
2022-06-12 17:36:00 +01:00
|
|
|
build autoconf-2.53
|
2021-03-17 22:17:11 +00:00
|
|
|
|
2022-06-12 17:36:00 +01:00
|
|
|
build automake-1.7
|
2021-03-18 00:23:40 +00:00
|
|
|
|
2022-06-12 17:36:00 +01:00
|
|
|
build autoconf-2.54
|
2021-03-18 00:23:40 +00:00
|
|
|
|
2021-03-18 17:47:12 +00:00
|
|
|
build autoconf-2.55
|
|
|
|
|
2021-03-18 19:25:50 +00:00
|
|
|
build automake-1.7.8
|
|
|
|
|
2021-03-18 19:33:54 +00:00
|
|
|
build autoconf-2.57
|
|
|
|
|
2021-03-18 19:37:07 +00:00
|
|
|
build autoconf-2.59
|
|
|
|
|
2021-03-18 19:53:06 +00:00
|
|
|
build automake-1.8.5
|
|
|
|
|
2021-03-19 15:40:07 +00:00
|
|
|
build help2man-1.36.4
|
|
|
|
|
2022-06-12 17:36:00 +01:00
|
|
|
build autoconf-2.61
|
2021-03-19 20:00:43 +00:00
|
|
|
|
2022-06-12 17:36:00 +01:00
|
|
|
build automake-1.9.6
|
2021-02-25 19:52:05 +00:00
|
|
|
|
2021-03-25 17:52:31 +00:00
|
|
|
build findutils-4.2.33
|
|
|
|
|
2021-03-25 19:14:34 +00:00
|
|
|
build libtool-2.2.4
|
|
|
|
|
2021-03-25 20:39:08 +00:00
|
|
|
build automake-1.10.3
|
|
|
|
|
2021-06-30 18:43:33 +01:00
|
|
|
build autoconf-2.64
|
2021-03-25 21:35:43 +00:00
|
|
|
|
2022-05-04 19:32:45 +01:00
|
|
|
build gcc-4.0.4 pass1.sh
|
2021-03-21 16:10:53 +00:00
|
|
|
|
2022-01-14 10:59:24 +00:00
|
|
|
# This hack fixes a strange bug in mes libc bash
|
|
|
|
set -x
|
2022-05-04 19:32:45 +01:00
|
|
|
build linux-headers-5.10.41 '' '' linux-5.10.41
|
2022-01-14 10:59:24 +00:00
|
|
|
set +x
|
2021-06-10 11:26:46 +01:00
|
|
|
|
2022-05-12 00:41:17 +01:00
|
|
|
build musl-1.2.3
|
2021-03-21 16:10:53 +00:00
|
|
|
|
2022-05-04 19:32:45 +01:00
|
|
|
build gcc-4.0.4 pass2.sh
|
2021-03-21 16:10:53 +00:00
|
|
|
|
2021-08-04 03:45:39 +01:00
|
|
|
build util-linux-2.19.1
|
2021-06-22 11:11:23 +01:00
|
|
|
|
2022-05-22 00:56:18 +01:00
|
|
|
build e2fsprogs-1.45.7
|
|
|
|
|
2022-05-22 13:09:03 +01:00
|
|
|
build dhcpcd-9.4.1 '' '' dhcpcd-dhcpcd-9.4.1-1663155
|
|
|
|
|
2021-08-04 03:45:39 +01:00
|
|
|
build kbd-1.15
|
|
|
|
|
|
|
|
build make-3.82
|
2021-06-10 11:27:45 +01:00
|
|
|
|
2022-05-07 22:59:59 +01:00
|
|
|
build curl-7.83.0
|
|
|
|
|
2021-10-10 21:53:44 +01:00
|
|
|
# Clear up some RAM space
|
|
|
|
grep '^build' "${SOURCES}/run.sh" | sed "s/build //" | sed "s/ .*$//" | while read -r p ; do
|
|
|
|
rm -rf "${SOURCES:?}/${p:?}"
|
|
|
|
done
|
|
|
|
|
2021-08-04 03:45:39 +01:00
|
|
|
if [ "${CHROOT}" = False ]; then
|
|
|
|
build kexec-tools-2.0.22
|
2021-07-26 06:19:07 +01:00
|
|
|
|
2021-08-04 03:56:07 +01:00
|
|
|
build linux-4.9.10
|
2021-03-21 16:10:53 +00:00
|
|
|
|
2021-10-10 21:54:23 +01:00
|
|
|
create_sysb
|
2021-07-06 01:52:10 +01:00
|
|
|
go_sysb
|
|
|
|
fi
|
2021-10-10 16:01:50 +01:00
|
|
|
|
|
|
|
# In chroot mode transition directly into System C.
|
2022-05-22 01:03:21 +01:00
|
|
|
SYSC=/sysc_image
|
|
|
|
sys_transfer "${SYSC}" /sysc gzip patch
|
2021-10-10 16:01:50 +01:00
|
|
|
exec chroot "${SYSC}" /init
|