2011-06-18 23:38:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e -u
|
|
|
|
|
2011-08-29 06:45:49 +02:00
|
|
|
iso_name=archlinux
|
2011-06-18 23:38:58 +02:00
|
|
|
iso_label="ARCH_$(date +%Y%m)"
|
2011-08-29 06:45:49 +02:00
|
|
|
iso_version=$(date +%Y.%m.%d)
|
2011-06-18 23:38:58 +02:00
|
|
|
install_dir=arch
|
|
|
|
arch=$(uname -m)
|
|
|
|
work_dir=work
|
2011-08-29 06:45:49 +02:00
|
|
|
out_dir=out
|
2011-06-18 23:38:58 +02:00
|
|
|
|
2020-06-25 23:01:54 +02:00
|
|
|
script_path=$(readlink -f "${0%/*}")
|
2011-07-14 05:46:42 +02:00
|
|
|
|
2018-06-23 21:09:33 +02:00
|
|
|
umask 0022
|
|
|
|
|
2013-01-03 00:38:59 +01:00
|
|
|
# Helper function to run make_*() only one time per architecture.
|
|
|
|
run_once() {
|
2020-06-25 23:01:54 +02:00
|
|
|
if [[ ! -e "${work_dir}/build.${1}_${arch}" ]]; then
|
|
|
|
"$1"
|
|
|
|
touch "${work_dir}/build.${1}_${arch}"
|
2013-01-03 00:38:59 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-06-28 05:35:50 +02:00
|
|
|
# Base installation (airootfs)
|
2011-06-18 23:38:58 +02:00
|
|
|
make_basefs() {
|
2013-01-03 00:38:59 +01:00
|
|
|
mkarchiso -v -w "${work_dir}" -D "${install_dir}" init
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
2014-06-28 05:35:50 +02:00
|
|
|
# Copy mkinitcpio archiso hooks and build initramfs (airootfs)
|
2011-06-28 00:16:29 +02:00
|
|
|
make_setup_mkinitcpio() {
|
2020-06-25 23:01:54 +02:00
|
|
|
mkdir -p "${work_dir}/airootfs/etc/initcpio/hooks"
|
|
|
|
mkdir -p "${work_dir}/airootfs/etc/initcpio/install"
|
|
|
|
cp /usr/lib/initcpio/hooks/archiso "${work_dir}/airootfs/etc/initcpio/hooks"
|
|
|
|
cp /usr/lib/initcpio/install/archiso "${work_dir}/airootfs/etc/initcpio/install"
|
|
|
|
cp "${script_path}/mkinitcpio.conf" "${work_dir}/airootfs/etc/mkinitcpio-archiso.conf"
|
|
|
|
mkarchiso -v -w "${work_dir}" -D "${install_dir}" \
|
|
|
|
-r 'mkinitcpio -c /etc/mkinitcpio-archiso.conf -k /boot/vmlinuz-linux -g /boot/archiso.img' run
|
2011-06-28 00:16:29 +02:00
|
|
|
}
|
|
|
|
|
2011-06-18 23:38:58 +02:00
|
|
|
# Prepare ${install_dir}/boot/
|
|
|
|
make_boot() {
|
2020-06-25 23:01:54 +02:00
|
|
|
mkdir -p "${work_dir}/iso/${install_dir}/boot/${arch}"
|
|
|
|
cp "${work_dir}/airootfs/boot/archiso.img" "${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img"
|
|
|
|
cp "${work_dir}/airootfs/boot/vmlinuz-linux" "${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz"
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Prepare /${install_dir}/boot/syslinux
|
|
|
|
make_syslinux() {
|
2020-06-25 23:01:54 +02:00
|
|
|
mkdir -p "${work_dir}/iso/${install_dir}/boot/syslinux"
|
2013-01-03 00:38:59 +01:00
|
|
|
sed "s|%ARCHISO_LABEL%|${iso_label}|g;
|
|
|
|
s|%INSTALL_DIR%|${install_dir}|g;
|
2020-06-25 23:01:54 +02:00
|
|
|
s|%ARCH%|${arch}|g" "${script_path}/syslinux/syslinux.cfg" > \
|
|
|
|
"${work_dir}/iso/${install_dir}/boot/syslinux/syslinux.cfg"
|
|
|
|
cp "${work_dir}/airootfs/usr/lib/syslinux/bios/ldlinux.c32" "${work_dir}/iso/${install_dir}/boot/syslinux/"
|
|
|
|
cp "${work_dir}/airootfs/usr/lib/syslinux/bios/menu.c32" "${work_dir}/iso/${install_dir}/boot/syslinux/"
|
|
|
|
cp "${work_dir}/airootfs/usr/lib/syslinux/bios/libutil.c32" "${work_dir}/iso/${install_dir}/boot/syslinux/"
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Prepare /isolinux
|
|
|
|
make_isolinux() {
|
2020-06-25 23:01:54 +02:00
|
|
|
mkdir -p "${work_dir}/iso/isolinux"
|
|
|
|
sed "s|%INSTALL_DIR%|${install_dir}|g" "${script_path}/isolinux/isolinux.cfg" > \
|
|
|
|
"${work_dir}/iso/isolinux/isolinux.cfg"
|
|
|
|
cp "${work_dir}/airootfs/usr/lib/syslinux/bios/isolinux.bin" "${work_dir}/iso/isolinux/"
|
|
|
|
cp "${work_dir}/airootfs/usr/lib/syslinux/bios/isohdpfx.bin" "${work_dir}/iso/isolinux/"
|
|
|
|
cp "${work_dir}/airootfs/usr/lib/syslinux/bios/ldlinux.c32" "${work_dir}/iso/isolinux/"
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
2014-06-28 05:35:50 +02:00
|
|
|
# Build airootfs filesystem image
|
2011-06-18 23:38:58 +02:00
|
|
|
make_prepare() {
|
2013-01-03 00:38:59 +01:00
|
|
|
mkarchiso -v -w "${work_dir}" -D "${install_dir}" prepare
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Build ISO
|
|
|
|
make_iso() {
|
2020-06-25 23:01:54 +02:00
|
|
|
mkarchiso -v -w "${work_dir}" -D "${install_dir}" -L "${iso_label}" -o "${out_dir}" iso \
|
|
|
|
"${iso_name}-${iso_version}-${arch}.iso"
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
2013-01-03 00:38:59 +01:00
|
|
|
run_once make_basefs
|
|
|
|
run_once make_setup_mkinitcpio
|
|
|
|
run_once make_boot
|
|
|
|
run_once make_syslinux
|
|
|
|
run_once make_isolinux
|
|
|
|
run_once make_prepare
|
|
|
|
run_once make_iso
|