87 lines
2.4 KiB
Bash
87 lines
2.4 KiB
Bash
set -ex -o pipefail
|
|
|
|
mkdir -p $out
|
|
mkdir -p $out/etc/repart.d $out/dev $out/proc $out/sys $out/tmp $out/root $out/run $out/boot
|
|
ln -sf ../usr/bin $out/bin
|
|
ln -sf ../usr/bin $out/sbin
|
|
ln -sf ../usr/lib $out/lib
|
|
ln -sf ../usr/lib $out/lib64
|
|
ln -sf ../proc/self/mounts $out/etc/mtab
|
|
|
|
### install systemd
|
|
echo "Installing systemd"
|
|
cp -Pr $systemd/* $out/
|
|
find $out -type d -exec chmod 755 {} \;
|
|
rm -rf $out/usr/include
|
|
rm -rf $out/usr/sbin
|
|
rm -f $out/usr/lib/systemd/system/sysinit.target.wants/systemd-firstboot.service
|
|
# remove vconsole setup
|
|
rm -f $out/usr/lib/udev/rules.d/90-vconsole.rules
|
|
|
|
cat <<EOF > $out/etc/os-release
|
|
NAME="PatOS"
|
|
PRETTY_NAME="PatOS 0.0.1 (pre-alpha)"
|
|
ID=patos
|
|
VERSION="0.0.1 (pre-alpha)"
|
|
VERSION_CODENAME=pre-alpha
|
|
VERSION_ID="0.0.1"
|
|
EOF
|
|
|
|
sed -i 's#After=\(.*\)#After=sysroot.mount \1#' $out/usr/lib/systemd/system/systemd-repart.service
|
|
cat <<EOF > $out/etc/repart.d/10-esp.conf
|
|
[Partition]
|
|
Type=esp
|
|
Format=vfat
|
|
EOF
|
|
|
|
cat <<EOF > $out/etc/repart.d/22-root.conf
|
|
[Partition]
|
|
Type=root
|
|
EOF
|
|
|
|
#FIXME: use btrfs instead on ext2(busybox) but need the btrfs tools in rootfs.
|
|
cat <<EOF > $out/etc/repart.d/40-var.conf
|
|
[Partition]
|
|
Type=var
|
|
UUID=4d21b016-b534-45c2-a9fb-5c16e091fd2d
|
|
Format=ext2
|
|
Label=patos-state
|
|
Minimize=off
|
|
FactoryReset=yes
|
|
SizeMinBytes=1G
|
|
SplitName=-
|
|
EOF
|
|
|
|
### install PatOS glibc
|
|
cp -P $glibcPatos/lib/*.so* $out/usr/lib/
|
|
|
|
### install kernel modules
|
|
cp -r $kernel/lib/modules $out/usr/lib/
|
|
find $out/usr/lib/modules -type d -exec chmod 755 {} \;
|
|
|
|
### install busybox
|
|
cp $busybox/bin/busybox $out/usr/bin/
|
|
$out/usr/bin/busybox --list | xargs -I {} ln -sf busybox $out/usr/bin/{}
|
|
|
|
### install dbus broker
|
|
cp -r $dbusBroker/* $out/
|
|
|
|
### install lib kmod
|
|
cp -P $kmodLibs/lib/* $out/usr/lib
|
|
cp -P $kmodBin/bin/* $out/usr/bin
|
|
|
|
### install libbpf
|
|
cp -P $libbpf/lib/libbpf* $out/usr/lib
|
|
|
|
### Find and install all shared libs
|
|
find $out -type f -executable -exec ldd {} \; | awk '{print $3}' | grep -v systemd | grep -v glibc | sort -u | xargs cp -t $out/usr/lib
|
|
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 {} \;
|
|
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 {} \;
|
|
find $out -type d -exec chmod 755 {} \;
|