Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/mkarchiso486
blob: 517fa5ab2e6d84986516ee5beaa6e7e2b8fd4015 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh

BASE=/data/arch32/archi486
ROOTFS="$BASE/airootfs"
ROOTMNT="$BASE/mnt"

umount "$ROOTMNT"
rm -rf "$ROOTFS"
rm -f "$BASE/pacman-i486.conf"
rm -f "$BASE/mirrorlist32"

if test ! -d "$ROOTMNT"; then
	mkdir "$ROOTMNT"
fi

# get and patch mirrorlist for Archlinux32
if test ! -d "$ROOTFS"; then
	mkdir "$ROOTFS"
fi

if test ! -f "$BASE/mirrorlist32"; then
	wget -O "$BASE/mirrorlist32" "https://www.archlinux32.org/mirrorlist/?country=all&protocol=http&protocol=https&ip_version=4&ip_version=6"
	sed -i '/https.*mirror.archlinux32.org/s/#Server/Server/' "$BASE/mirrorlist32"
fi

echo "Patch host pacman.conf for installation of i486 chroot.."
cp /etc/pacman.conf "$BASE/pacman-i486.conf"
sed -i 's/^Architecture.*=.*/Architecture = i486/' "$BASE/pacman-i486.conf"
sed -i "s|/etc/pacman.d/mirrorlist|$BASE/mirrorlist32|" "$BASE/pacman-i486.conf"
sed -i 's|.*ParallelDownloads.*|ParallelDownloads = 1|' "$BASE/pacman-i486.conf"

pacstrap -C "$BASE/pacman-i486.conf" -G -M "$ROOTFS" base linux

echo "Cleaning up root filesystem to fit to an ISO.."
rm -rf "$ROOTFS/var/cache/pacman/pkg/"*

echo "Patching pacman.conf and mirrorlist on the ISO.."
sed -i 's/^Architecture.*=.*/Architecture = i486/' "$ROOTFS/etc/pacman.conf"
sed -i 's/^#\(Server.*=.*https:\/\/.*mirror\.archlinux32.org.*\)/\1/' "$ROOTFS/etc/pacman.d/mirrorlist"
sed -i 's|.*ParallelDownloads.*|ParallelDownloads = 1|' "$ROOTFS/etc/pacman.conf"

mount --bind "$ROOTFS" "$ROOTMNT"

echo "Preparing keyring inside chroot.."
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'pacman-key --init'
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'pacman-key --populate archlinux'
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'pacman-key --populate archlinux32'
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'pacman -Syyu --noconfirm syslinux dhclient dhcpcd pciutils nano joe vi arch-install-scripts openssh'

echo "Install configuration.."
for i in 1 2 3 4; do
	mkdir -p "$ROOTFS"/etc/systemd/system/getty@tty$i.service.d
	cp $BASE/autologin.conf "$ROOTFS"/etc/systemd/system/getty@tty$i.service.d/.
done
cp $BASE/resolv.conf "$ROOTFS"/etc/resolv.conf
cp $BASE/sshd_config "$ROOTFS"/etc/ssh/sshd_config
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'ssh-keygen -b 2048 -t rsa -f etc/ssh/ssh_host_rsa_key -N ""'
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'ssh-keygen -b 1024 -t dsa -f etc/ssh/ssh_host_dsa_key -N ""'
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'ssh-keygen -b 521 -t ecdsa -f etc/ssh/ssh_host_ecdsa_key -N ""'
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'ssh-keygen -b 2048 -t ed25519 -f etc/ssh/ssh_host_ed25519_key -N ""'
chmod 0400 "$ROOTFS"/etc/ssh/ssh_host_*_key
cp $BASE/motd "$ROOTFS"/etc/motd
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'echo "root:arch" | /usr/bin/chpasswd'
cp $BASE/system-login "$ROOTMNT"/etc/pam.d/system-login

echo "Installining syslinux (isolinux).."
if test ! -d "$ROOTFS/isolinux"; then
	mkdir "$ROOTFS/isolinux"
fi
cp "$ROOTFS"/usr/lib/syslinux/bios/isolinux.bin "$ROOTFS/isolinux"
cp "$ROOTFS"/usr/lib/syslinux/bios/ldlinux.c32 "$ROOTFS/isolinux"
cp "$BASE"/isolinux-i486.cfg "$ROOTFS/isolinux/isolinux.cfg"

echo "Creating ramdisk for ISO.."
cp "$BASE"/mkinitcpio-i486.conf "$ROOTFS/etc/mkinitcpio.conf"
linux32 arch-chroot "$ROOTMNT" /bin/bash -c 'mkinitcpio -P'

umount "$ROOTMNT"

echo "Creating ISO.."
TODAY=`date +'%Y.%m.%d'`
cd "$ROOTFS"
iso_label="ARCH_$(date +%Y%m)"
iso_publisher="Arch Linux <http://www.archlinux32.org>"
iso_application="ArchLinux32 i486 Live/Rescue CD"
mkisofs -o "$BASE/archlinux32-$TODAY-i486.iso" \
	-b "isolinux/isolinux.bin" \
	-c "isolinux/boot.cat" \
        -volid "${iso_label}" \
        -appid "${iso_application}" \
        -publisher "${iso_publisher}" \
        -preparer "prepared by mkarchiso" \
	-no-emul-boot -boot-load-size 4 -boot-info-table \
	-R -full-iso9660-filenames -iso-level 3 \
	"."
cd ..

echo "Done."