aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstrap.sh88
-rw-r--r--install.sh7
2 files changed, 53 insertions, 42 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index 138e85c..3ee41cb 100644
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -12,34 +12,36 @@ export PATH=${MELVIX}/cross-tools/bin:/bin:/usr/bin
mkdir -p ${MELVIX}/sources
cd ${MELVIX}/sources
-curl -SL "http://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz" | tar xJ
-curl -SL "https://busybox.net/downloads/busybox-1.31.0.tar.bz2" | tar xj
-curl -SL "https://github.com/cross-lfs/bootscripts-embedded/archive/master.tar.gz" | tar xz
-curl -SL "https://gcc.gnu.org/pub/gcc/releases/gcc-9.1.0/gcc-9.1.0.tar.xz" | tar xJ
-curl -SL "http://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz" | tar xJ
-curl -SL "https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.1.tar.xz" | tar xJ
-curl -SL "http://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz" | tar xz
-curl -SL "http://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz" | tar xJ
-curl -SL "http://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz" | tar xJ
-curl -SL "https://www.zlib.net/zlib-1.2.11.tar.xz" | tar xJ
+echo "Downloading resources"
+curl -sSL "http://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz" | tar xJ
+curl -sSL "https://busybox.net/downloads/busybox-1.31.0.tar.bz2" | tar xj
+curl -sSL "https://github.com/cross-lfs/bootscripts-embedded/archive/master.tar.gz" | tar xz
+curl -sSL "https://gcc.gnu.org/pub/gcc/releases/gcc-9.1.0/gcc-9.1.0.tar.xz" | tar xJ
+curl -sSL "http://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz" | tar xJ
+curl -sSL "https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.1.tar.xz" | tar xJ
+curl -sSL "http://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz" | tar xz
+curl -sSL "http://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz" | tar xJ
+curl -sSL "http://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz" | tar xJ
+curl -sSL "https://www.zlib.net/zlib-1.2.11.tar.xz" | tar xJ
cd ${MELVIX}
+echo "Initializing filesystem structure"
mkdir -p ${MELVIX}/{bin,boot{,grub},dev,{etc/,}opt,home,lib/{firmware,modules},lib64,mnt}
mkdir -p ${MELVIX}/{proc,media/{floppy,cdrom},sbin,srv,sys}
mkdir -p ${MELVIX}/var/{lock,log,mail,run,spool}
mkdir -p ${MELVIX}/var/{opt,cache,lib/{misc,locate},local}
-install -d -m 0750 ${MELVIX}/root
-install -d -m 1777 ${MELVIX}{/var,}/tmp
-install -d ${MELVIX}/etc/init.d
+install -d -m 0750 ${MELVIX}/root &> /dev/null
+install -d -m 1777 ${MELVIX}{/var,}/tmp &> /dev/null
+install -d ${MELVIX}/etc/init.d &> /dev/null
mkdir -p ${MELVIX}/usr/{,local/}{bin,include,lib{,64},sbin,src}
mkdir -p ${MELVIX}/usr/{,local/}share/{doc,info,locale,man}
mkdir -p ${MELVIX}/usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -p ${MELVIX}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
for dir in ${MELVIX}/usr{,/local}; do
- ln -s share/{man,doc,info} ${dir}
+ ln -s share/{man,doc,info} ${dir} &> /dev/null
done
-install -d ${MELVIX}/cross-tools{,/bin}
+install -d ${MELVIX}/cross-tools{,/bin} &> /dev/null
ln -sf /proc/mounts ${MELVIX}/etc/mtab
echo "melvix" > ${MELVIX}/etc/HOSTNAME
@@ -55,20 +57,23 @@ export MELVIX_CPU=k8
export MELVIX_ARCH=$(echo ${MELVIX_TARGET} | sed -e 's/-.*//' -e 's/i.86/i386/')
export MELVIX_ENDIAN=little
+echo "Building kernel headers"
cd ${MELVIX}/sources/linux-5.1/
-make mrproper
-make ARCH=${MELVIX_ARCH} headers_check
-make ARCH=${MELVIX_ARCH} INSTALL_HDR_PATH=dest headers_install
+make mrproper &> /dev/null
+make ARCH=${MELVIX_ARCH} headers_check &> /dev/null
+make ARCH=${MELVIX_ARCH} INSTALL_HDR_PATH=dest headers_install &> /dev/null
cp -r dest/include/* ${MELVIX}/usr/include
+echo "Building binutils"
mkdir ${MELVIX}/sources/binutils-build/
cd ${MELVIX}/sources/binutils-build/
-../binutils-2.32/configure --prefix=${MELVIX}/cross-tools --target=${MELVIX_TARGET} --with-sysroot=${MELVIX} --disable-nls --enable-shared --disable-multilib
-make configure-host && make
+../binutils-2.32/configure --prefix=${MELVIX}/cross-tools --target=${MELVIX_TARGET} --with-sysroot=${MELVIX} --disable-nls --enable-shared --disable-multilib &> /dev/null
+make configure-host &> /dev/null && make &> /dev/null
ln -s lib ${MELVIX}/cross-tools/lib64
-make install
+make install &> /dev/null
cp ../binutils-2.32/include/libiberty.h ${MELVIX}/usr/include
+echo "Building static gcc"
cd ${MELVIX}/sources/
mv gmp-6.1.2 gcc-9.1.0/gmp/
mv mpc-1.1.0 gcc-9.1.0/mpc/
@@ -86,11 +91,12 @@ AR=ar LDFLAGS="-Wl,-rpath,${MELVIX}/cross-tools/lib" \
--without-headers --with-newlib --disable-decimal-float \
--disable-libgomp --disable-libmudflap --disable-libssp \
--disable-threads --enable-languages=c,c++ \
---disable-multilib --with-arch=${MELVIX_CPU}
-make all-gcc all-target-libgcc
-make install-gcc install-target-libgcc
+--disable-multilib --with-arch=${MELVIX_CPU} &> /dev/null
+make all-gcc all-target-libgcc &> /dev/null
+make install-gcc install-target-libgcc &> /dev/null
ln -s libgcc.a `${MELVIX_TARGET}-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
+echo "Building glibc"
mkdir ${MELVIX}/sources/glibc-build
cd ${MELVIX}/sources/glibc-build
echo "libc_cv_forced_unwind=yes" > config.cache
@@ -106,9 +112,10 @@ RANLIB="${MELVIX_TARGET}-ranlib" CFLAGS="-O2" \
--enable-kernel=2.6.32 --with-__thread \
--with-binutils=${MELVIX}/cross-tools/bin \
--with-headers=${MELVIX}/usr/include \
---cache-file=config.cache
-make && make install_root=${MELVIX}/ install
+--cache-file=config.cache &> /dev/null
+make && make install_root=${MELVIX}/ install &> /dev/null
+echo "Building gcc"
mkdir ${MELVIX}/sources/gcc-build
cd ${MELVIX}/sources/gcc-build
AR=ar LDFLAGS="-Wl,-rpath,${MELVIX}/cross-tools/lib" \
@@ -120,8 +127,8 @@ AR=ar LDFLAGS="-Wl,-rpath,${MELVIX}/cross-tools/lib" \
--enable-long-long \
--with-mpfr-include=$(pwd)/../gcc-9.1.0/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs \
---disable-multilib --with-arch=${MELVIX_CPU}
-make && make install
+--disable-multilib --with-arch=${MELVIX_CPU} &> /dev/null
+make && make install &> /dev/null
cp ${MELVIX}/cross-tools/${MELVIX_TARGET}/lib64/libgcc_s.so.1 ${MELVIX}/lib64
export CC="${MELVIX_TARGET}-gcc"
export CXX="${MELVIX_TARGET}-g++"
@@ -133,39 +140,44 @@ export RANLIB="${MELVIX_TARGET}-ranlib"
export READELF="${MELVIX_TARGET}-readelf"
export STRIP="${MELVIX_TARGET}-strip"
+echo "Building busybox"
cd ${MELVIX}/sources/busybox-1.31.0
-make CROSS_COMPILE="${MELVIX_TARGET}-" defconfig
+make CROSS_COMPILE="${MELVIX_TARGET}-" defconfig &> /dev/null
# make CROSS_COMPILE="${MELVIX_TARGET}-" menuconfig
-make CROSS_COMPILE="${MELVIX_TARGET}-"
-make CROSS_COMPILE="${MELVIX_TARGET}-" CONFIG_PREFIX="${MELVIX}" install
+make CROSS_COMPILE="${MELVIX_TARGET}-" &> /dev/null
+make CROSS_COMPILE="${MELVIX_TARGET}-" CONFIG_PREFIX="${MELVIX}" install &> /dev/null
cp examples/depmod.pl ${MELVIX}/cross-tools/bin
chmod 755 ${MELVIX}/cross-tools/bin/depmod.pl
+echo "Building kernel"
cd ${MELVIX}/sources/linux-5.1
-make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- x86_64_defconfig
+make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- x86_64_defconfig &> /dev/null
# make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- menuconfig
-make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}-
-make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- INSTALL_MOD_PATH=${MELVIX} modules_install
+make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- &> /dev/null
+make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- INSTALL_MOD_PATH=${MELVIX} modules_install &> /dev/null
cp arch/x86/boot/bzImage ${MELVIX}/boot/vmlinuz
cp System.map ${MELVIX}/boot/System.map
cp .config ${MELVIX}/boot/config
-${MELVIX}/cross-tools/bin/depmod.pl -F ${MELVIX}/boot/System.map -b ${MELVIX}/lib/modules/5.1.0
+${MELVIX}/cross-tools/bin/depmod.pl -F ${MELVIX}/boot/System.map -b ${MELVIX}/lib/modules/5.1.0 &> /dev/null
+echo "Installing boot scripts"
cd ${MELVIX}/sources/bootscripts-embedded-master
-make DESTDIR=${MELVIX}/ install-bootscripts
+make DESTDIR=${MELVIX}/ install-bootscripts &> /dev/null
ln -s ../rc.d/startup ${MELVIX}/etc/init.d/rcS
+echo "Building zlib"
cd ${MELVIX}/sources/zlib-1.2.11
sed -i 's/-O3/-Os/g' configure
-./configure --prefix=/usr --shared
-make && make DESTDIR=${MELVIX}/ install
+./configure --prefix=/usr --shared &> /dev/null
+make && make DESTDIR=${MELVIX}/ install &> /dev/null
mv ${MELVIX}/usr/lib/libz.so.* ${MELVIX}/lib
ln -sf ../../lib/libz.so.1 ${MELVIX}/usr/lib/libz.so
ln -sf ../../lib/libz.so.1 ${MELVIX}/usr/lib/libz.so.1
ln -sf ../lib/libz.so.1 ${MELVIX}/lib64/libz.so.1
# Cleanup
+echo "Cleaning up and backing up current state"
cp -rf ${MELVIX}/ ${MELVIX}-copy
rm -rf ${MELVIX}-copy/cross-tools
rm -rf ${MELVIX}-copy/usr/src/*
diff --git a/install.sh b/install.sh
index 903a574..d487814 100644
--- a/install.sh
+++ b/install.sh
@@ -8,15 +8,14 @@ sudo cp -r boot etc /home/melvix/os
sudo chown -R melvix /home/melvix
sudo cp bootstrap.sh /home/melvix
-echo "Compiling and packaging Melvix..."
while :;do for s in / - \\ \|; do printf "\r$s";sleep .1;done;done &
trap "kill $!" EXIT
-sudo -i -u melvix bash bootstrap.sh ${source} &> /dev/null
+sudo -i -u melvix bash bootstrap.sh ${source}
kill $! && trap " " EXIT
export MELVIX=/home/melvix/os
-find ${MELVIX}-copy/{,usr/}{bin,lib,sbin} -type f -exec sudo strip --strip-debug '{}' ';'
-find ${MELVIX}-copy/{,usr/}lib64 -type f -exec sudo strip --strip-debug '{}' ';'
+sudi find ${MELVIX}-copy/{,usr/}{bin,lib,sbin} -type f -exec sudo strip --strip-debug '{}' ';'
+sudo find ${MELVIX}-copy/{,usr/}lib64 -type f -exec sudo strip --strip-debug '{}' ';'
sudo chown -R root:root ${MELVIX}-copy
sudo chgrp 13 ${MELVIX}-copy/var/run/utmp ${MELVIX}-copy/var/log/lastlog
sudo mknod -m 0666 ${MELVIX}-copy/dev/null c 1 3