1
0
mirror of https://github.com/MichielDerhaeg/build-linux.git synced 2025-09-08 15:10:39 +02:00

did lots of work

This commit is contained in:
Michiel Derhaeg
2016-08-06 10:08:36 +02:00
parent c66748b657
commit 517586891e
8 changed files with 53 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ KERNEL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$(KERNEL_VERSION).
BUSYBOX_VERSION=1.24.2
BUSYBOX_URL=https://www.busybox.net/downloads/busybox-$(BUSYBOX_VERSION).tar.bz2
all: bzImage
all: fs.tar
linux-$(KERNEL_VERSION).tar.xz:
wget $(KERNEL_URL)
@@ -33,3 +33,5 @@ fs.tar: bzImage busybox
mdos.img: fs.tar gen_image.sh
./gen_image.sh
.PHONY: fs.tar

View File

@@ -1,4 +1,4 @@
FS_FILES=build.sh crypttab filesystem.install fstab group gshadow host.conf hosts inittab issue ld.so.conf locale.sh modprobe.d.usb-load-ehci-first motd nsswitch.conf os-release passwd profile rcS resolv.conf securetty shadow shells
FS_FILES=build.sh crypttab filesystem.install fstab group gshadow host.conf hosts inittab issue ld.so.conf locale.sh modprobe.d.usb-load-ehci-first motd nsswitch.conf os-release passwd profile systemctl resolv.conf securetty shadow shells
all: build.sh $(FS_FILES)
../fs.tar: build.sh $(FS_FILES)
fakeroot ./build.sh

View File

@@ -89,6 +89,6 @@ busybox --install -s usr/bin
install -m644 "$srcdir/inittab" etc/inittab
install -d -m755 etc/init.d
install -m755 "$srcdir/rcS" etc/init.d/rcS
install -m755 "$srcdir/systemctl" sbin/systemctl
tar --xattrs -cpf ../../fs.tar *

View File

@@ -1,3 +1,4 @@
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::sysinit:/sbin/systemctl init
::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
::shutdown:/usr/bin/umount -a -r

View File

@@ -1,4 +1,4 @@
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/sh
bin:x:1:1:bin:/bin:/usr/bin/nologin
daemon:x:2:2:daemon:/:/usr/bin/nologin
mail:x:8:12:mail:/var/spool/mail:/usr/bin/nologin
@@ -7,8 +7,3 @@ http:x:33:33:http:/srv/http:/usr/bin/nologin
uuidd:x:68:68:uuidd:/:/usr/bin/nologin
dbus:x:81:81:dbus:/:/usr/bin/nologin
nobody:x:99:99:nobody:/:/usr/bin/nologin
systemd-journal-gateway:x:191:191:systemd-journal-gateway:/:/usr/bin/nologin
systemd-timesync:x:192:192:systemd-timesync:/:/usr/bin/nologin
systemd-network:x:193:193:systemd-network:/:/usr/bin/nologin
systemd-bus-proxy:x:194:194:systemd-bus-proxy:/:/usr/bin/nologin
systemd-resolve:x:195:195:systemd-resolve:/:/usr/bin/nologin

View File

@@ -1,2 +0,0 @@
#!/bin/sh
/usr/bin/mount -a

27
filesystem/systemctl Normal file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
init() {
# TODO options
/usr/bin/mount -t proc proc /proc
/usr/bin/mount -t sysfs sys /sys
/usr/bin/mount -t devtmpfs dev /dev
mkdir -p /dev/pts /dev/shm # TODO check if in filesystem
/usr/bin/mount -t devpts devpts /dev/pts
/usr/bin/mount -t tmpfs tmpfs /dev/shm
if [[ -f /etc/hostname ]]; then
echo "$(cat /etc/hostname)" > /proc/sys/kernel/hostname
fi
/sbin/mdev -s
echo /sbin/mdev > /proc/sys/kernel/hotplug
/usr/bin/mount -a
/usr/bin/mount -o remount,rw /
}
case $1 in
init)
init
;;
esac

View File

@@ -5,10 +5,12 @@ if [[ $(id -u) -ne 0 ]]; then
exit 1
fi
rm -f mdos.img
fallocate -l 100M mdos.img
echo -e "o\nn\n\n\n\n\nw\n" | fdisk mdos.img
loopdevice="$(losetup -P --show -f mdos.img)"
image=mdos.img
rm -f $image
fallocate -l 100M $image
echo -e "o\nn\n\n\n\n\nw\n" | fdisk $image
loopdevice="$(losetup -P --show -f $image)"
looppart=${loopdevice}p1
mkfs.ext4 $looppart
@@ -16,9 +18,18 @@ mkdir -p mountdir
mount $looppart mountdir
cd mountdir
tar --xattrs -xpf ../fs.tar
grub-install --target=i386-pc --boot-directory="$PWD/boot/grub" $loopdevice
grub-install --target=i386-pc --boot-directory="$PWD/boot" $loopdevice
cd ..
## generate grub.cfg (since linux 3.8 32-bit MBR "NT disk signatures" are allowed)
uuid=$(fdisk -l $image | grep "Disk identifier" | cut -d " " -f 3 | cut --complement -c 1,2)-01
echo -e "linux /boot/bzImage root=PARTUUID=$uuid\nboot" > "mountdir/boot/grub/grub.cfg"
umount mountdir
sync
rm -rf mountdir
losetup -d $loopdevice
if [[ -n $SUDO_UID ]]; then
chown $SUDO_UID:$SUDO_GID $image
fi