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
|
|
|
verbose="n"
|
|
|
|
|
2011-07-14 05:46:42 +02:00
|
|
|
script_path=$(readlink -f ${0%/*})
|
|
|
|
|
2011-06-18 23:38:58 +02:00
|
|
|
# Base installation (root-image)
|
|
|
|
make_basefs() {
|
2011-08-29 06:45:49 +02:00
|
|
|
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" -p "base" create
|
|
|
|
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" -p "syslinux" create
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
2011-06-28 00:16:29 +02:00
|
|
|
# Copy mkinitcpio archiso hooks (root-image)
|
|
|
|
make_setup_mkinitcpio() {
|
|
|
|
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
|
|
|
cp /lib/initcpio/hooks/archiso ${work_dir}/root-image/lib/initcpio/hooks
|
|
|
|
cp /lib/initcpio/install/archiso ${work_dir}/root-image/lib/initcpio/install
|
|
|
|
: > ${work_dir}/build.${FUNCNAME}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-06-18 23:38:58 +02:00
|
|
|
# Prepare ${install_dir}/boot/
|
|
|
|
make_boot() {
|
|
|
|
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
|
|
|
mkdir -p ${work_dir}/iso/${install_dir}/boot/${arch}
|
2011-06-28 00:16:29 +02:00
|
|
|
mkinitcpio \
|
2011-07-14 05:46:42 +02:00
|
|
|
-c ${script_path}/mkinitcpio.conf \
|
2011-06-28 00:16:29 +02:00
|
|
|
-b ${work_dir}/root-image \
|
2011-07-24 23:25:33 +02:00
|
|
|
-k /boot/vmlinuz-linux \
|
2011-06-28 00:16:29 +02:00
|
|
|
-g ${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img
|
2011-07-24 23:25:33 +02:00
|
|
|
cp ${work_dir}/root-image/boot/vmlinuz-linux ${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz
|
2011-06-18 23:38:58 +02:00
|
|
|
: > ${work_dir}/build.${FUNCNAME}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Prepare /${install_dir}/boot/syslinux
|
|
|
|
make_syslinux() {
|
|
|
|
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
|
|
|
mkdir -p ${work_dir}/iso/${install_dir}/boot/syslinux
|
|
|
|
sed "s|%ARCHISO_LABEL%|${iso_label}|g;
|
|
|
|
s|%INSTALL_DIR%|${install_dir}|g;
|
2011-07-14 05:46:42 +02:00
|
|
|
s|%ARCH%|${arch}|g" ${script_path}/syslinux/syslinux.cfg > ${work_dir}/iso/${install_dir}/boot/syslinux/syslinux.cfg
|
2011-06-18 23:38:58 +02:00
|
|
|
cp ${work_dir}/root-image/usr/lib/syslinux/menu.c32 ${work_dir}/iso/${install_dir}/boot/syslinux/
|
|
|
|
: > ${work_dir}/build.${FUNCNAME}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Prepare /isolinux
|
|
|
|
make_isolinux() {
|
|
|
|
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
|
|
|
mkdir -p ${work_dir}/iso/isolinux
|
2011-07-14 05:46:42 +02:00
|
|
|
sed "s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/isolinux/isolinux.cfg > ${work_dir}/iso/isolinux/isolinux.cfg
|
2011-06-18 23:38:58 +02:00
|
|
|
cp ${work_dir}/root-image/usr/lib/syslinux/isolinux.bin ${work_dir}/iso/isolinux/
|
2011-08-29 06:47:57 +02:00
|
|
|
cp ${work_dir}/root-image/usr/lib/syslinux/isohdpfx.bin ${work_dir}/iso/isolinux/
|
2011-06-18 23:38:58 +02:00
|
|
|
: > ${work_dir}/build.${FUNCNAME}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Process aitab
|
|
|
|
make_aitab() {
|
|
|
|
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
|
2011-07-14 05:46:42 +02:00
|
|
|
sed "s|%ARCH%|${arch}|g" ${script_path}/aitab > ${work_dir}/iso/${install_dir}/aitab
|
2011-06-18 23:38:58 +02:00
|
|
|
: > ${work_dir}/build.${FUNCNAME}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build all filesystem images specified in aitab (.fs .fs.sfs .sfs)
|
|
|
|
make_prepare() {
|
2011-08-29 06:45:49 +02:00
|
|
|
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" prepare
|
2011-06-18 23:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Build ISO
|
|
|
|
make_iso() {
|
2011-08-29 06:45:49 +02:00
|
|
|
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" checksum
|
|
|
|
mkarchiso ${verbose} -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
|
|
|
}
|
|
|
|
|
2011-10-12 19:40:19 +02:00
|
|
|
if [[ ${verbose} == "y" ]]; then
|
2011-06-18 23:38:58 +02:00
|
|
|
verbose="-v"
|
|
|
|
else
|
|
|
|
verbose=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
make_basefs
|
2011-06-28 00:16:29 +02:00
|
|
|
make_setup_mkinitcpio
|
2011-06-18 23:38:58 +02:00
|
|
|
make_boot
|
|
|
|
make_syslinux
|
|
|
|
make_isolinux
|
|
|
|
make_aitab
|
|
|
|
make_prepare
|
|
|
|
make_iso
|