recipes: x-apps/emacs: Enable emacs again, trying the -no-pie option
[dragora.git] / stages / 2 / 03-initramfs
blob8bb0651ba5abdbf0bc6b6ec80679a5fd7ead28e6
1 # Build script for the single-purpose initramfs (Live CD).
3 # Copyright (c) 2017-2020, 2022 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 mkdir -p -- "${rootdir}/initrd"
18 cd -- "${rootdir}/initrd"
20 # Create essential directories for the image
22 mkdir -p proc sys dev UP
23 chmod 755 proc sys dev UP
25 cat << "EOF" > init
26 #! /bin/busybox hush
28 set -x
30 /bin/busybox mount -n -o nosuid,noexec,nodev -t proc proc /proc
31 /bin/busybox mount -n -o nosuid,noexec,nodev -t sysfs sysfs /sys
32 /bin/busybox mount -n -t devtmpfs devtmpfs /dev
33 /bin/busybox sleep 5
35 # Mount tmpfs plus create directories
36 /bin/busybox mount -n -w -o size=100% -t tmpfs tmpfs /UP
37 /bin/busybox mkdir -p \
38  /UP/cdrom /UP/squash /UP/rw /UP/workdir /UP/union
40 # Mount ISO and system image
41 /bin/busybox mount -n -r -t iso9660 LABEL="Dragora_@ARCH@" /UP/cdrom
43 # Be the system or be dead!
44 /bin/busybox mount -n -r -o loop -t squashfs \
45  /UP/cdrom/dragora.sfs /UP/squash || /bin/busybox sleep 3323;
47 # Merge Squashfs with OverlayFS
48 /bin/busybox mount -n \
49  -o lowerdir=/UP/squash,upperdir=/UP/rw,workdir=/UP/workdir \
50  -t overlay overlay /UP/union
52 # Move virtual file systems prior to switch_root
53 /bin/busybox mount -n --move /dev   /UP/union/dev
54 /bin/busybox mount -n --move /proc  /UP/union/proc
55 /bin/busybox mount -n --move /sys   /UP/union/sys
57 : > /UP/union/fastboot
58 exec /bin/busybox switch_root /UP/union /sbin/init
60 EOF
62 sed -i "s/@ARCH@/${package_arch}/" init
63 chmod 750 init
65 # Make initramfs
67 rm -f ./initrd.img
68 find . | sed -e 's!^./!!' | cpio -oC512 -H newc | \
69  lzip -s16 -0c > initrd.img