forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-rootfs.sh
More file actions
executable file
·43 lines (36 loc) · 1.24 KB
/
Copy pathsetup-rootfs.sh
File metadata and controls
executable file
·43 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -e
ROOTFS_DIR=/rootfs
ROOTFS_IMG=/kernel/rootfs.img
LTP_DIR=/kernel/ltp
IMG_SIZE_MB=4096
echo "=== Step 1: Create rootfs with debootstrap ==="
debootstrap --arch=arm64 jammy "$ROOTFS_DIR" http://ports.ubuntu.com/ubuntu-ports
echo "=== Step 2: Build and install LTP ==="
cd "$LTP_DIR"
make autotools
./configure
make -j$(nproc)
make install DESTDIR="$ROOTFS_DIR"
echo "=== Step 3: Install kirk into rootfs ==="
pip3 install kirk --target "$ROOTFS_DIR/usr/local/lib/python3/dist-packages"
cp "$(which kirk)" "$ROOTFS_DIR/usr/local/bin/kirk"
echo "=== Step 4: Configure kirk PATH in rootfs ==="
cat >> "$ROOTFS_DIR/etc/profile" << 'EOF'
export PATH=$PATH:/usr/local/lib/python3/dist-packages/bin
EOF
echo "=== Step 5: Package rootfs into image ==="
dd if=/dev/zero of="$ROOTFS_IMG" bs=1M count="$IMG_SIZE_MB"
mkfs.ext4 -d "$ROOTFS_DIR" "$ROOTFS_IMG"
echo "=== Done ==="
echo "rootfs image: $ROOTFS_IMG"
echo ""
echo "Boot with:"
echo " qemu-system-aarch64 \\"
echo " -M virt \\"
echo " -cpu cortex-a57 \\"
echo " -m 2G \\"
echo " -kernel /kernel/linux/arch/arm64/boot/Image \\"
echo " -append \"root=/dev/vda rw console=ttyAMA0 init=/bin/bash\" \\"
echo " -drive file=$ROOTFS_IMG,format=raw,if=virtio \\"
echo " -nographic"