Compare commits
1 commit
649b64b9c4
...
ad62856703
Author | SHA1 | Date | |
---|---|---|---|
ad62856703 |
3 changed files with 11 additions and 49 deletions
|
@ -14,6 +14,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
|
||||
buildInputs = with pkgs; [
|
||||
glibc
|
||||
binutils
|
||||
];
|
||||
|
||||
glibcPatos = "${patosPkgs.glibc.out}";
|
||||
|
|
|
@ -13,10 +13,10 @@ rm -f $out/usr/lib/systemd/system/sysinit.target.wants/systemd-firstboot.service
|
|||
rm -f $out/usr/lib/udev/rules.d/90-vconsole.rules
|
||||
|
||||
### install PatOS glibc
|
||||
cp -Pr $glibcPatos/lib/*.so* $out/usr/lib/
|
||||
cp -P $glibcPatos/lib/*.so* $out/usr/lib/
|
||||
|
||||
### install kernel modules
|
||||
cp -Pr $kernel/lib/modules $out/usr/lib/
|
||||
cp -r $kernel/lib/modules $out/usr/lib/
|
||||
find $out/usr/lib/modules -type d -exec chmod 755 {} \;
|
||||
|
||||
### install busybox
|
||||
|
@ -38,11 +38,11 @@ find $out -type f -executable -exec ldd {} \; | awk '{print $3}' | grep -v syste
|
|||
find $out -type f -executable -exec chmod 755 {} \;
|
||||
|
||||
# FIXME: ELF patching. Is there a better way?
|
||||
find $out -type f -executable -exec patchelf --set-rpath /lib:/usr/lib:/usr/lib/systemd {} \; 2> /dev/null
|
||||
find $out -type f -executable -exec patchelf --set-interpreter /lib/ld-linux-x86-64.so.2 {} \; 2> /dev/null
|
||||
find $out -type f -executable -exec patchelf --set-rpath /lib:/usr/lib:/usr/lib/systemd {} \;
|
||||
find $out -type f -executable -exec patchelf --set-interpreter /lib/ld-linux-x86-64.so.2 {} \;
|
||||
patchelf --remove-rpath $out/usr/lib/ld-linux-x86-64.so.2
|
||||
|
||||
# strip binaries
|
||||
find $out -type f -executable -exec strip {} \; 2> /dev/null
|
||||
find $out -type f -executable -exec strip {} \;
|
||||
find $out -type d -exec chmod 755 {} \;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ pkgs.writeShellApplication {
|
|||
name = "mkinitrd";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
patchelf
|
||||
cpio
|
||||
gzip
|
||||
];
|
||||
|
@ -17,6 +16,10 @@ pkgs.writeShellApplication {
|
|||
mkdir -p root
|
||||
pushd root
|
||||
|
||||
### copy rootfs
|
||||
cp -prP ${patosPkgs.rootfs}/* .
|
||||
find . -type d -exec chmod 755 {} \;
|
||||
|
||||
### create directories
|
||||
mkdir -p etc dev proc sys tmp root
|
||||
ln -sf usr/bin bin
|
||||
|
@ -26,47 +29,14 @@ pkgs.writeShellApplication {
|
|||
ln -sf ../proc/self/mounts etc/mtab
|
||||
ln -sf ../usr/lib/systemd/systemd init
|
||||
|
||||
### install systemd
|
||||
cp -Pr ${patosPkgs.systemd.out}/* ./
|
||||
find . -type d -exec chmod 755 {} \;
|
||||
rm -rf ./usr/include
|
||||
rm -rf ./usr/sbin
|
||||
# set default target to basic
|
||||
mkdir usr/lib/systemd/system/basic.target.wants
|
||||
ln -sf basic.target usr/lib/systemd/system/default.target
|
||||
# remove first boot
|
||||
rm -f usr/lib/systemd/system/sysinit.target.wants/systemd-firstboot.service
|
||||
# remove vconsole setup
|
||||
rm -f usr/lib/udev/rules.d/90-vconsole.rules
|
||||
|
||||
### install PatOS glibc
|
||||
cp -Pr ${patosPkgs.glibc.out}/lib/*.so* ./usr/lib/
|
||||
|
||||
### install kernel modules
|
||||
cp -Pr ${patosPkgs.kernel.kernel}/lib/modules ./usr/lib/
|
||||
find usr/lib/modules -type d -exec chmod 755 {} \;
|
||||
|
||||
### install busybox
|
||||
cp ${pkgs.busybox.out}/bin/busybox ./usr/bin/
|
||||
usr/bin/busybox --list | xargs -I {} ln -sf busybox usr/bin/{}
|
||||
|
||||
### install dbus broker
|
||||
cp -r ${patosPkgs.dbus-broker.out}/* ./
|
||||
# enable dbus broker
|
||||
ln -sf ../dbus-broker.service usr/lib/systemd/system/basic.target.wants/dbus.service
|
||||
ln -sf ../dbus.socket usr/lib/systemd/system/sockets.target.wants/dbus.socket
|
||||
|
||||
### install lib kmod
|
||||
cp -P ${pkgs.kmod.lib}/lib/* ./usr/lib
|
||||
cp -P ${pkgs.kmod.out}/bin/* ./usr/bin
|
||||
|
||||
### install libbpf
|
||||
cp -P ${pkgs.libbpf.out}/lib/libbpf* ./usr/lib
|
||||
|
||||
### Find and install all shared libs
|
||||
find . -type f -executable -exec ldd {} \; 2> /dev/null | awk '{print $3}' | grep -v systemd | grep -v glibc | sort -u | xargs cp -t usr/lib
|
||||
find . -type f -executable -exec chmod 755 {} \;
|
||||
|
||||
|
||||
### Create needed files
|
||||
echo patos > ./etc/hostname
|
||||
cat <<EOF > ./etc/os-release
|
||||
|
@ -152,15 +122,6 @@ pkgs.writeShellApplication {
|
|||
EOF
|
||||
ln -sf ../demo.service usr/lib/systemd/system/basic.target.wants/demo.service
|
||||
|
||||
# FIXME: ELF patching. Is there a better way?
|
||||
find . -type f -executable -exec patchelf --set-rpath /lib:/usr/lib:/usr/lib/systemd {} \; 2> /dev/null
|
||||
find . -type f -executable -exec patchelf --set-interpreter /lib/ld-linux-x86-64.so.2 {} \; 2> /dev/null
|
||||
patchelf --remove-rpath ./usr/lib/ld-linux-x86-64.so.2
|
||||
|
||||
# strip binaries
|
||||
find . -type f -executable -exec strip {} \; 2> /dev/null
|
||||
find . -type d -exec chmod 755 {} \;
|
||||
|
||||
# gen initrd
|
||||
find . -print0 | cpio --null --owner=root:root -o --format=newc | gzip -9 > ../initrd.gz
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue