#!/bin/sh set -e BASE=/root/archi486/iso ROOTFS="$BASE/airootfs" ROOTMNT="$BASE/mnt" umount "$ROOTMNT" || true rm -rf "$ROOTFS" rm -f "$BASE/pacman-i486.conf" rm -f "$BASE/mirrorlist32" if test ! -d "$ROOTMNT"; then mkdir "$ROOTMNT" fi if test ! -d "$ROOTFS"; then mkdir "$ROOTFS" fi echo "Fetch and patch mirrorlist for Archlinux32.." 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/"* rm -rf "$ROOTFS/usr/include/" rm -rf "$ROOTFS/usr/lib/"*.a rm -rf "$ROOTFS/usr/share/man/" rm -rf "$ROOTFS/usr/share/info/" rm -rf "$ROOTFS/usr/share/locale/" rm -rf "$ROOTFS/usr/share/i18/locales/" 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" # /var/tmp should be writeable echo "/tmp /var/tmp none bind 0 0" >> "$ROOTFS/etc/fstab" 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 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 cp $BASE/system-auth "$ROOTMNT"/etc/pam.d/system-auth echo "Installining syslinux (isolinux).." if test ! -d "$ROOTFS/isolinux"; then mkdir "$ROOTFS/isolinux" fi for file in isolinux.bin ldlinux.c32; do cp "$ROOTFS"/usr/lib/syslinux/bios/"$file" "$ROOTFS/isolinux" done 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 " 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."