aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2019-06-26 19:13:34 +0200
committerMarvin Borner2019-06-26 19:13:34 +0200
commit0019754be97684676682ad0efa65066504faf26c (patch)
tree29101bbe8b096f3609ebc35681f661e2f728cd33
Added initial files
-rw-r--r--.gitignore2
-rw-r--r--boot/grub/grub.cfg8
-rw-r--r--bootstrap.sh197
-rw-r--r--etc/fstab8
-rw-r--r--etc/group11
-rw-r--r--etc/inittab11
-rw-r--r--etc/issue2
-rw-r--r--etc/mdev.conf61
-rw-r--r--etc/passwd1
-rw-r--r--etc/profile16
-rw-r--r--test.sh6
11 files changed, 323 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..994d0f5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea
+Melvix.iml \ No newline at end of file
diff --git a/boot/grub/grub.cfg b/boot/grub/grub.cfg
new file mode 100644
index 0000000..552dee9
--- /dev/null
+++ b/boot/grub/grub.cfg
@@ -0,0 +1,8 @@
+set default=0
+set timeout=5
+
+set root=(hd0,1)
+
+menuentry "Linux Journal OS 0.1a" {
+ linux /boot/vmlinuz root=/dev/sda1 ro quiet
+}
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100644
index 0000000..dc7edaa
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,197 @@
+#!/usr/bin/env bash
+
+export source=$(pwd)
+
+sudo useradd -m melvix
+sudo mkdir /home/melvix
+sudo chown -R melvix /home/melvix
+sudo -i -u melvix bash << SUPERAWESOMEENDLINGLINE
+
+set +h
+umask 022
+export MELVIX=/home/melvix/os
+mkdir -pv ${MELVIX}
+cd ${MELVIX}
+
+export LC_ALL=POSIX
+export PATH=${MELVIX}/cross-tools/bin:/bin:/usr/bin
+
+mkdir -pv ${MELVIX}/sources
+cd ${MELVIX}/sources
+wget "http://ftp.gnu.org/gnu/binutils/binutils-2.32.tar.xz" && tar xf binutils-2.32.tar.xz
+wget "https://busybox.net/downloads/busybox-1.31.0.tar.bz2" && tar xf busybox-1.31.0.tar.bz2
+wget "https://github.com/cross-lfs/bootscripts-embedded/archive/master.tar.gz" && tar xf master.tar.gz
+wget "https://gcc.gnu.org/pub/gcc/releases/gcc-9.1.0/gcc-9.1.0.tar.xz" && tar xf gcc-9.1.0.tar.bz2
+wget "http://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz" && tar gmp-6.1.2.tar.xz
+wget "https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.1.tar.xz" && tar xf linux-5.1.tar.xz
+wget "http://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz" && tar xf mpc-1.1.0.tar.gz
+wget "http://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz" && tar xf glibc-2.29.tar.xz
+wget "http://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz" && tar xf mpfr-4.0.2.tar.xz
+wget "https://www.zlib.net/zlib-1.2.11.tar.xz" && tar xf zlib-1.2.11.tar.xz
+cd ${MELVIX}
+
+mkdir -pv ${MELVIX}/{bin,boot{,grub},dev,{etc/,}opt,home,lib/{firmware,modules},lib64,mnt}
+mkdir -pv ${MELVIX}/{proc,media/{floppy,cdrom},sbin,srv,sys}
+mkdir -pv ${MELVIX}/var/{lock,log,mail,run,spool}
+mkdir -pv ${MELVIX}/var/{opt,cache,lib/{misc,locate},local}
+install -dv -m 0750 ${MELVIX}/root
+install -dv -m 1777 ${MELVIX}{/var,}/tmp
+install -dv ${MELVIX}/etc/init.d
+mkdir -pv ${MELVIX}/usr/{,local/}{bin,include,lib{,64},sbin,src}
+mkdir -pv ${MELVIX}/usr/{,local/}share/{doc,info,locale,man}
+mkdir -pv ${MELVIX}/usr/{,local/}share/{misc,terminfo,zoneinfo}
+mkdir -pv ${MELVIX}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
+for dir in ${MELVIX}/usr{,/local}; do
+ ln -sv share/{man,doc,info} ${dir}
+ done
+
+install -dv ${MELVIX}/cross-tools{,/bin}
+ln -svf ../proc/mounts ${MELVIX}/etc/mtab
+
+cp -rfv ${source}/etc/* ${MELVIX}/etc/
+
+echo "melvix" > ${MELVIX}/etc/HOSTNAME
+
+touch ${MELVIX}/var/run/utmp ${MELVIX}/var/log/{btmp,lastlog,wtmp}
+chmod -v 664 ${MELVIX}/var/run/utmp ${MELVIX}/var/log/lastlog
+
+unset CFLAGS
+unset CXXFLAGS
+export MELVIX_HOST=$(echo ${MACHTYPE} | sed "s/-[^-]*/-cross/")
+export MELVIX_TARGET=x86_64-unknown-linux-gnu
+export MELVIX_CPU=k8
+export MELVIX_ARCH=$(echo ${MELVIX_TARGET} | sed -e 's/-.*//' -e 's/i.86/i386/')
+export MELVIX_ENDIAN=little
+
+cd ${MELVIX}/sources/linux-5.1/
+make mrproper
+make ARCH=${MELVIX_ARCH} headers_check
+make ARCH=${MELVIX_ARCH} INSTALL_HDR_PATH=dest headers_install
+cp -rv dest/include/* ${MELVIX}/usr/include
+
+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
+ln -sv lib ${MELVIX}/cross-tools/lib64
+make install
+cp -v ../binutils-2.32/include/libiberty.h ${MELVIX}/usr/include
+
+cd ${MELVIX}/sources/
+mv gmp-6.1.2 gcc-9.1.0/gmp/
+mv mpc-1.1.0 gcc-9.1.0/mpc/
+mv mpfr-4.0.2 gcc-9.1.0/mpfr/
+mkdir ${MELVIX}/sources/gcc-static
+cd ${MELVIX}/sources/gcc-static
+AR=ar LDFLAGS="-Wl,-rpath,${MELVIX}/cross-tools/lib" \
+../gcc-9.1.0/configure --prefix=${MELVIX}/cross-tools \
+--build=${MELVIX_HOST} --host=${MELVIX_HOST} \
+--target=${MELVIX_TARGET} \
+--with-sysroot=${MELVIX}/target --disable-nls \
+--disable-shared \
+--with-mpfr-include=$(pwd)/../gcc-9.1.0/mpfr/src \
+--with-mpfr-lib=$(pwd)/mpfr/src/.libs \
+--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
+ln -vs libgcc.a `${MELVIX_TARGET}-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
+
+mkdir ${MELVIX}/sources/glibc-build
+cd ${MELVIX}/sources/glibc-build
+echo "libc_cv_forced_unwind=yes" > config.cache
+echo "libc_cv_c_cleanup=yes" >> config.cache
+echo "libc_cv_ssp=no" >> config.cache
+echo "libc_cv_ssp_strong=no" >> config.cache
+BUILD_CC="gcc" CC="${MELVIX_TARGET}-gcc" \
+AR="${MELVIX_TARGET}-ar" \
+RANLIB="${MELVIX_TARGET}-ranlib" CFLAGS="-O2" \
+../glibc-2.29/configure --prefix=/usr \
+--host=${MELVIX_TARGET} --build=${MELVIX_HOST} \
+--disable-profile --enable-add-ons --with-tls \
+--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
+
+mkdir ${MELVIX}/sources/gcc-build
+cd ${MELVIX}/sources/gcc-build
+AR=ar LDFLAGS="-Wl,-rpath,${MELVIX}/cross-tools/lib" \
+../gcc-9.1.0/configure --prefix=${MELVIX}/cross-tools \
+--build=${MELVIX_HOST} --target=${MELVIX_TARGET} \
+--host=${MELVIX_HOST} --with-sysroot=${MELVIX} \
+--disable-nls --enable-shared \
+--enable-languages=c,c++ --enable-c99 \
+--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
+cp -v ${MELVIX}/cross-tools/${MELVIX_TARGET}/lib64/libgcc_s.so.1 ${MELVIX}/lib64
+export CC="${MELVIX_TARGET}-gcc"
+export CXX="${MELVIX_TARGET}-g++"
+export CPP="${MELVIX_TARGET}-gcc -E"
+export AR="${MELVIX_TARGET}-ar"
+export AS="${MELVIX_TARGET}-as"
+export LD="${MELVIX_TARGET}-ld"
+export RANLIB="${MELVIX_TARGET}-ranlib"
+export READELF="${MELVIX_TARGET}-readelf"
+export STRIP="${MELVIX_TARGET}-strip"
+
+cd ${MELVIX}/sources/binutils-2.32
+make CROSS_COMPILE="${MELVIX_TARGET}-" defconfig
+# make CROSS_COMPILE="${MELVIX_TARGET}-" menuconfig
+make CROSS_COMPILE="${MELVIX_TARGET}-"
+make CROSS_COMPILE="${MELVIX_TARGET}-" CONFIG_PREFIX="${MELVIX}" install
+cp -v examples/depmod.pl ${MELVIX}/cross-tools/bin
+chmod 755 ${MELVIX}/cross-tools/bin/depmod.pl
+
+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}- menuconfig
+make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}-
+make ARCH=${MELVIX_ARCH} CROSS_COMPILE=${MELVIX_TARGET}- INSTALL_MOD_PATH=${MELVIX} modules_install
+cp -v arch/x86/boot/bzImage ${MELVIX}/boot/vmlinuz
+cp -v System.map ${MELVIX}/boot/System.map
+cp -v .config ${MELVIX}/boot/config
+
+${MELVIX}/cross-tools/bin/depmod.pl -F ${MELVIX}/boot/System.map -b ${MELVIX}/lib/modules/5.1.0
+
+cd ${MELVIX}/sources/bootscripts-embedded-master
+make DESTDIR=${MELVIX}/ install-bootscripts
+ln -sv ../rc.d/startup ${MELVIX}/etc/init.d/rcS
+
+cd ${MELVIX}/sources/zlib-1.2.11
+sed -i 's/-O3/-Os/g' configure
+./configure --prefix=/usr --shared
+make && make DESTDIR=${MELVIX}/ install
+mv -v ${MELVIX}/usr/lib/libz.so.* ${MELVIX}/lib
+ln -svf ../../lib/libz.so.1 ${MELVIX}/usr/lib/libz.so
+ln -svf ../../lib/libz.so.1 ${MELVIX}/usr/lib/libz.so.1
+ln -svf ../lib/libz.so.1 ${MELVIX}/lib64/libz.so.1
+
+# Cleanup
+cp -rf ${MELVIX}/ ${MELVIX}-copy
+rm -rfv ${MELVIX}-copy/cross-tools
+rm -rfv ${MELVIX}-copy/usr/src/*
+rm -rfv ${MELVIX}-copy/sources
+FILES="$(ls ${MELVIX}-copy/usr/lib64/*.a)"
+for file in ${FILES};
+do rm -f ${file}
+done
+
+SUPERAWESOMEENDLINGLINE
+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 '{}' ';'
+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
+sudo mknod -m 0600 ${MELVIX}-copy/dev/console c 5 1
+sudo chmod 4755 ${MELVIX}-copy/bin/busybox
+
+cd ${MELVIX}-copy/
+sudo tar cfJ ../melvix-build.tar.xz *
diff --git a/etc/fstab b/etc/fstab
new file mode 100644
index 0000000..3f36fc2
--- /dev/null
+++ b/etc/fstab
@@ -0,0 +1,8 @@
+# file system mount-point type options dump fsck
+# order
+
+rootfs / auto defaults 1 1
+proc /proc proc defaults 0 0
+sysfs /sys sysfs defaults 0 0
+devpts /dev/pts devpts gid=4,mode=620 0 0
+tmpfs /dev/shm tmpfs defaults 0 0 \ No newline at end of file
diff --git a/etc/group b/etc/group
new file mode 100644
index 0000000..ad3bf97
--- /dev/null
+++ b/etc/group
@@ -0,0 +1,11 @@
+root:x:0:
+bin:x:1:
+sys:x:2:
+kmem:x:3:
+tty:x:4:
+daemon:x:6:
+disk:x:8:
+dialout:x:10:
+video:x:12:
+utmp:x:13:
+usb:x:14: \ No newline at end of file
diff --git a/etc/inittab b/etc/inittab
new file mode 100644
index 0000000..830a9ee
--- /dev/null
+++ b/etc/inittab
@@ -0,0 +1,11 @@
+::sysinit:/etc/rc.d/startup
+
+tty1::respawn:/sbin/getty 38400 tty1
+tty2::respawn:/sbin/getty 38400 tty2
+tty3::respawn:/sbin/getty 38400 tty3
+tty4::respawn:/sbin/getty 38400 tty4
+tty5::respawn:/sbin/getty 38400 tty5
+tty6::respawn:/sbin/getty 38400 tty6
+
+::shutdown:/etc/rc.d/shutdown
+::ctrlaltdel:/sbin/reboot \ No newline at end of file
diff --git a/etc/issue b/etc/issue
new file mode 100644
index 0000000..1e67e99
--- /dev/null
+++ b/etc/issue
@@ -0,0 +1,2 @@
+Melvix 0.1a
+Kernel \r on an \m
diff --git a/etc/mdev.conf b/etc/mdev.conf
new file mode 100644
index 0000000..26bb575
--- /dev/null
+++ b/etc/mdev.conf
@@ -0,0 +1,61 @@
+# Devices:
+# Syntax: %s %d:%d %s
+# devices user:group mode
+
+# null does already exist; therefore ownership has to
+# be changed with command
+null root:root 0666 @chmod 666 $MDEV
+zero root:root 0666
+grsec root:root 0660
+full root:root 0666
+
+random root:root 0666
+urandom root:root 0444
+hwrandom root:root 0660
+
+# console does already exist; therefore ownership has to
+# be changed with command
+console root:tty 0600 @mkdir -pm 755 fd && cd fd && for x
+ ↪in 0 1 2 3 ; do ln -sf /proc/self/fd/$x $x; done
+
+kmem root:root 0640
+mem root:root 0640
+port root:root 0640
+ptmx root:tty 0666
+
+# ram.*
+ram([0-9]*) root:disk 0660 >rd/%1
+loop([0-9]+) root:disk 0660 >loop/%1
+sd[a-z].* root:disk 0660 */lib/mdev/usbdisk_link
+hd[a-z][0-9]* root:disk 0660 */lib/mdev/ide_links
+
+tty root:tty 0666
+tty[0-9] root:root 0600
+tty[0-9][0-9] root:tty 0660
+ttyO[0-9]* root:tty 0660
+pty.* root:tty 0660
+vcs[0-9]* root:tty 0660
+vcsa[0-9]* root:tty 0660
+
+ttyLTM[0-9] root:dialout 0660 @ln -sf $MDEV modem
+ttySHSF[0-9] root:dialout 0660 @ln -sf $MDEV modem
+slamr root:dialout 0660 @ln -sf $MDEV slamr0
+slusb root:dialout 0660 @ln -sf $MDEV slusb0
+fuse root:root 0666
+
+# misc stuff
+agpgart root:root 0660 >misc/
+psaux root:root 0660 >misc/
+rtc root:root 0664 >misc/
+
+# input stuff
+event[0-9]+ root:root 0640 =input/
+ts[0-9] root:root 0600 =input/
+
+# v4l stuff
+vbi[0-9] root:video 0660 >v4l/
+video[0-9] root:video 0660 >v4l/
+
+# load drivers for usb devices
+usbdev[0-9].[0-9] root:root 0660 */lib/mdev/usbdev
+usbdev[0-9].[0-9]_.* root:root 0660 \ No newline at end of file
diff --git a/etc/passwd b/etc/passwd
new file mode 100644
index 0000000..221b37e
--- /dev/null
+++ b/etc/passwd
@@ -0,0 +1 @@
+root::0:0:root:/root:/bin/ash \ No newline at end of file
diff --git a/etc/profile b/etc/profile
new file mode 100644
index 0000000..c8a1a52
--- /dev/null
+++ b/etc/profile
@@ -0,0 +1,16 @@
+export PATH=/bin:/usr/bin
+
+if [ `id -u` -eq 0 ] ; then
+ PATH=/bin:/sbin:/usr/bin:/usr/sbin
+ unset HISTFILE
+fi
+
+
+# Set up some environment variables.
+export USER=`id -un`
+export LOGNAME=$USER
+export HOSTNAME=`/bin/hostname`
+export HISTSIZE=1000
+export HISTFILESIZE=1000
+export PAGER='/bin/more '
+export EDITOR='/bin/vi' \ No newline at end of file
diff --git a/test.sh b/test.sh
new file mode 100644
index 0000000..c362b35
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,6 @@
+sudo -i -u lfs bash << AWESOMEENDINGLINE
+whoami
+echo $(pwd)
+AWESOMEENDINGLINE
+whoami
+echo $(pwd)