[configs/baseline] Rework build.sh add run_once() like in releng profile and other misc things

Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
Gerardo Exequiel Pozzi 2013-01-02 20:38:59 -03:00
parent 58bcf48091
commit 845bf0f2d2

View File

@ -9,91 +9,75 @@ install_dir=arch
arch=$(uname -m) arch=$(uname -m)
work_dir=work work_dir=work
out_dir=out out_dir=out
verbose="n"
script_path=$(readlink -f ${0%/*}) script_path=$(readlink -f ${0%/*})
# Base installation (root-image) # Helper function to run make_*() only one time per architecture.
make_basefs() { run_once() {
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" init if [[ ! -e ${work_dir}/build.${1}_${arch} ]]; then
$1
touch ${work_dir}/build.${1}_${arch}
fi
} }
# Copy mkinitcpio archiso hooks (root-image) # Base installation (root-image)
make_basefs() {
mkarchiso -v -w "${work_dir}" -D "${install_dir}" init
}
# Copy mkinitcpio archiso hooks and build initramfs (root-image)
make_setup_mkinitcpio() { make_setup_mkinitcpio() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
cp /usr/lib/initcpio/hooks/archiso ${work_dir}/root-image/usr/lib/initcpio/hooks cp /usr/lib/initcpio/hooks/archiso ${work_dir}/root-image/usr/lib/initcpio/hooks
cp /usr/lib/initcpio/install/archiso ${work_dir}/root-image/usr/lib/initcpio/install cp /usr/lib/initcpio/install/archiso ${work_dir}/root-image/usr/lib/initcpio/install
cp ${script_path}/mkinitcpio.conf ${work_dir}/root-image/etc/mkinitcpio-archiso.conf cp ${script_path}/mkinitcpio.conf ${work_dir}/root-image/etc/mkinitcpio-archiso.conf
: > ${work_dir}/build.${FUNCNAME} mkarchiso -v -w "${work_dir}" -D "${install_dir}" -r 'mkinitcpio -c /etc/mkinitcpio-archiso.conf -k /boot/vmlinuz-linux -g /boot/archiso.img' run
fi
} }
# Prepare ${install_dir}/boot/ # Prepare ${install_dir}/boot/
make_boot() { make_boot() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
mkdir -p ${work_dir}/iso/${install_dir}/boot/${arch} mkdir -p ${work_dir}/iso/${install_dir}/boot/${arch}
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" \
-r 'mkinitcpio -c /etc/mkinitcpio-archiso.conf -k /boot/vmlinuz-linux -g /boot/archiso.img' \
run
cp ${work_dir}/root-image/boot/archiso.img ${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img cp ${work_dir}/root-image/boot/archiso.img ${work_dir}/iso/${install_dir}/boot/${arch}/archiso.img
cp ${work_dir}/root-image/boot/vmlinuz-linux ${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz cp ${work_dir}/root-image/boot/vmlinuz-linux ${work_dir}/iso/${install_dir}/boot/${arch}/vmlinuz
: > ${work_dir}/build.${FUNCNAME}
fi
} }
# Prepare /${install_dir}/boot/syslinux # Prepare /${install_dir}/boot/syslinux
make_syslinux() { make_syslinux() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
mkdir -p ${work_dir}/iso/${install_dir}/boot/syslinux mkdir -p ${work_dir}/iso/${install_dir}/boot/syslinux
sed "s|%ARCHISO_LABEL%|${iso_label}|g; sed "s|%ARCHISO_LABEL%|${iso_label}|g;
s|%INSTALL_DIR%|${install_dir}|g; s|%INSTALL_DIR%|${install_dir}|g;
s|%ARCH%|${arch}|g" ${script_path}/syslinux/syslinux.cfg > ${work_dir}/iso/${install_dir}/boot/syslinux/syslinux.cfg s|%ARCH%|${arch}|g" ${script_path}/syslinux/syslinux.cfg > ${work_dir}/iso/${install_dir}/boot/syslinux/syslinux.cfg
cp ${work_dir}/root-image/usr/lib/syslinux/menu.c32 ${work_dir}/iso/${install_dir}/boot/syslinux/ cp ${work_dir}/root-image/usr/lib/syslinux/menu.c32 ${work_dir}/iso/${install_dir}/boot/syslinux/
: > ${work_dir}/build.${FUNCNAME}
fi
} }
# Prepare /isolinux # Prepare /isolinux
make_isolinux() { make_isolinux() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
mkdir -p ${work_dir}/iso/isolinux mkdir -p ${work_dir}/iso/isolinux
sed "s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/isolinux/isolinux.cfg > ${work_dir}/iso/isolinux/isolinux.cfg sed "s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/isolinux/isolinux.cfg > ${work_dir}/iso/isolinux/isolinux.cfg
cp ${work_dir}/root-image/usr/lib/syslinux/isolinux.bin ${work_dir}/iso/isolinux/ cp ${work_dir}/root-image/usr/lib/syslinux/isolinux.bin ${work_dir}/iso/isolinux/
cp ${work_dir}/root-image/usr/lib/syslinux/isohdpfx.bin ${work_dir}/iso/isolinux/ cp ${work_dir}/root-image/usr/lib/syslinux/isohdpfx.bin ${work_dir}/iso/isolinux/
: > ${work_dir}/build.${FUNCNAME}
fi
} }
# Process aitab # Process aitab
make_aitab() { make_aitab() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
sed "s|%ARCH%|${arch}|g" ${script_path}/aitab > ${work_dir}/iso/${install_dir}/aitab sed "s|%ARCH%|${arch}|g" ${script_path}/aitab > ${work_dir}/iso/${install_dir}/aitab
: > ${work_dir}/build.${FUNCNAME}
fi
} }
# Build all filesystem images specified in aitab (.fs .fs.sfs .sfs) # Build all filesystem images specified in aitab (.fs.sfs .sfs)
make_prepare() { make_prepare() {
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" prepare mkarchiso -v -w "${work_dir}" -D "${install_dir}" prepare
} }
# Build ISO # Build ISO
make_iso() { make_iso() {
mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" checksum mkarchiso -v -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" mkarchiso -v -w "${work_dir}" -D "${install_dir}" -L "${iso_label}" -o "${out_dir}" iso "${iso_name}-${iso_version}-${arch}.iso"
} }
if [[ ${verbose} == "y" ]]; then run_once make_basefs
verbose="-v" run_once make_setup_mkinitcpio
else run_once make_boot
verbose="" run_once make_syslinux
fi run_once make_isolinux
run_once make_aitab
make_basefs run_once make_prepare
make_setup_mkinitcpio run_once make_iso
make_boot
make_syslinux
make_isolinux
make_aitab
make_prepare
make_iso