From 6bdcc59f94ecd2fd84facda953f92e1d2a5cf727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fabian=20Silva=20Delgado?= Date: Fri, 4 May 2012 15:33:55 -0300 Subject: updating all files --- configs/releng/build.sh | 450 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 332 insertions(+), 118 deletions(-) (limited to 'configs/releng/build.sh') diff --git a/configs/releng/build.sh b/configs/releng/build.sh index 4a48b0a..8080d25 100755 --- a/configs/releng/build.sh +++ b/configs/releng/build.sh @@ -2,53 +2,41 @@ set -e -u -name=parabola +iso_name=parabola iso_label="LIBRE_$(date +%Y%m)" -version=$(date +%Y.%m.%d) +iso_version=$(date +%Y.%m.%d) install_dir=libre arch=$(uname -m) work_dir=work -verbose="n" +out_dir=out +verbose="" +cmd_args="" script_path=$(readlink -f ${0%/*}) # Base installation (root-image) make_basefs() { - mkarchiso ${verbose} -D "${install_dir}" -p "base" create "${work_dir}" - mkarchiso ${verbose} -D "${install_dir}" -p "memtest86+ syslinux mkinitcpio-nfs-utils nbd" create "${work_dir}" + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" init + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" -p "memtest86+ mkinitcpio-nfs-utils nbd curl" install } # Additional packages (root-image) make_packages() { - mkarchiso ${verbose} -D "${install_dir}" -p "$(grep -v ^# ${script_path}/packages.${arch})" create "${work_dir}" -} - -# Customize installation (root-image) -make_customize_root_image() { - if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then - cp -af ${script_path}/root-image ${work_dir} - chmod 750 ${work_dir}/root-image/etc/sudoers.d - chmod 440 ${work_dir}/root-image/etc/sudoers.d/g_wheel - mkdir -p ${work_dir}/root-image/etc/pacman.d - echo "Server = http://repo.parabolagnulinux.org/\$repo/os/\$arch" > \ - ${work_dir}/root-image/etc/pacman.d/mirrorlist - chroot ${work_dir}/root-image /usr/sbin/locale-gen - chroot ${work_dir}/root-image /usr/sbin/useradd -m -p "" -g users -G "audio,disk,optical,wheel" libre -# Cleanup, makes the ISO lighter -# Remove headers - rm -rf ${work_dir}/root-image/usr/include/* - : > ${work_dir}/build.${FUNCNAME} - fi + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" -p "$(grep -v ^# ${script_path}/packages.${arch})" install } # Copy mkinitcpio archiso hooks (root-image) make_setup_mkinitcpio() { if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then local _hook - for _hook in archiso archiso_pxe_nbd archiso_loop_mnt; do - cp /lib/initcpio/hooks/${_hook} ${work_dir}/root-image/lib/initcpio/hooks - cp /lib/initcpio/install/${_hook} ${work_dir}/root-image/lib/initcpio/install + for _hook in archiso archiso_shutdown archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs archiso_loop_mnt; do + cp /usr/lib/initcpio/hooks/${_hook} ${work_dir}/root-image/usr/lib/initcpio/hooks + cp /usr/lib/initcpio/install/${_hook} ${work_dir}/root-image/usr/lib/initcpio/install done + cp /usr/lib/initcpio/install/archiso_kms ${work_dir}/root-image/usr/lib/initcpio/install + cp /usr/lib/initcpio/archiso_shutdown ${work_dir}/root-image/usr/lib/initcpio + cp /usr/lib/initcpio/archiso_pxe_nbd ${work_dir}/root-image/usr/lib/initcpio + cp ${script_path}/mkinitcpio.conf ${work_dir}/root-image/etc/mkinitcpio-libreiso.conf : > ${work_dir}/build.${FUNCNAME} fi } @@ -59,11 +47,10 @@ make_boot() { local _src=${work_dir}/root-image local _dst_boot=${work_dir}/iso/${install_dir}/boot mkdir -p ${_dst_boot}/${arch} - mkinitcpio \ - -c ${script_path}/mkinitcpio.conf \ - -b ${_src} \ - -k /boot/vmlinuz-linux-libre \ - -g ${_dst_boot}/${arch}/libreiso.img + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" \ + -r 'mkinitcpio -c /etc/mkinitcpio-libreiso.conf -k /boot/vmlinuz-linux-libre -g /boot/archiso.img' \ + run + mv ${_src}/boot/archiso.img ${_dst_boot}/${arch}/libreiso.img mv ${_src}/boot/vmlinuz-linux-libre ${_dst_boot}/${arch}/vmlinuz cp ${_src}/boot/memtest86+/memtest.bin ${_dst_boot}/memtest cp ${_src}/usr/share/licenses/common/GPL2/license.txt ${_dst_boot}/memtest.COPYING @@ -71,15 +58,54 @@ make_boot() { fi } +# Prepare EFI "El Torito" boot image (using Linux >= 3.3 EFI boot stub) +make_boot_efi() { + if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then + if [[ ${arch} == "x86_64" ]]; then + mkdir -p ${work_dir}/iso/EFI/archiso + dd of=${work_dir}/iso/EFI/archiso/efiboot.img bs=1 seek=20M count=0 + mkfs.vfat ${work_dir}/iso/EFI/archiso/efiboot.img + + mkdir -p ${work_dir}/efiboot + mount ${work_dir}/iso/EFI/archiso/efiboot.img ${work_dir}/efiboot + + mkdir -p ${work_dir}/efiboot/EFI/archiso + cp ${work_dir}/iso/${install_dir}/boot/x86_64/vmlinuz ${work_dir}/efiboot/EFI/archiso/vmlinuz.efi + cp ${work_dir}/iso/${install_dir}/boot/x86_64/libreiso.img ${work_dir}/efiboot/EFI/archiso/libreiso.img + + # There are plans to support command line options via a config file (not yet in linux-3.3) + #cp ${work_dir}/iso/${install_dir}/boot/x86_64/vmlinuz ${work_dir}/efiboot/EFI/boot/bootx64.efi + #cp ${work_dir}/iso/${install_dir}/boot/x86_64/libreiso.img ${work_dir}/efiboot/EFI/boot/linux-libre.img + #echo "archisolabel=${iso_label} initrd=\EFI\boot\linux-libre.img" | iconv -f ascii -t ucs2 > ${work_dir}/iso/EFI/boot/linux-libre.conf + + # For now, provide an EFI-shell until 'linux-libre.conf' hits mainline. + mkdir -p ${work_dir}/efiboot/EFI/boot + # EFI Shell 2.0 for UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=UEFI_Shell ) + #wget -O ${work_dir}/efiboot/EFI/boot/bootx64.efi https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi + # EFI Shell 1.0 for non UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Efi-shell ) + wget -O ${work_dir}/efiboot/EFI/boot/bootx64.efi https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EdkShellBinPkg/FullShell/X64/Shell_Full.efi + + # Add an EFI shell script for automatic boot if ESC-key is not pressed within 5 seconds timeout. + sed "s|%ARCHISO_LABEL%|${iso_label}|g; + s|%INSTALL_DIR%|${install_dir}|g" ${script_path}/efiboot/EFI/boot/startup.nsh > ${work_dir}/efiboot/EFI/boot/startup.nsh + + umount ${work_dir}/efiboot + fi + : > ${work_dir}/build.${FUNCNAME} + fi +} + # Prepare /${install_dir}/boot/syslinux make_syslinux() { if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then local _src_syslinux=${work_dir}/root-image/usr/lib/syslinux local _dst_syslinux=${work_dir}/iso/${install_dir}/boot/syslinux mkdir -p ${_dst_syslinux} - sed "s|%ARCHISO_LABEL%|${iso_label}|g; - s|%INSTALL_DIR%|${install_dir}|g; - s|%ARCH%|${arch}|g" ${script_path}/syslinux/syslinux.cfg > ${_dst_syslinux}/syslinux.cfg + for _cfg in ${script_path}/syslinux/*.cfg; do + sed "s|%ARCHISO_LABEL%|${iso_label}|g; + s|%INSTALL_DIR%|${install_dir}|g; + s|%ARCH%|${arch}|g" ${_cfg} > ${_dst_syslinux}/${_cfg##*/} + done cp ${script_path}/syslinux/splash.png ${_dst_syslinux} cp ${_src_syslinux}/*.c32 ${_dst_syslinux} cp ${_src_syslinux}/*.com ${_dst_syslinux} @@ -98,6 +124,27 @@ make_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 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/ + : > ${work_dir}/build.${FUNCNAME} + fi +} + +# Customize installation (root-image) +make_customize_root_image() { + if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then + cp -af ${script_path}/root-image ${work_dir} + chmod 750 ${work_dir}/root-image/etc/sudoers.d + chmod 440 ${work_dir}/root-image/etc/sudoers.d/g_wheel + mkdir -p ${work_dir}/root-image/etc/pacman.d + wget -O ${work_dir}/root-image/etc/pacman.d/mirrorlist https://parabolagnulinux.org/mirrorlist/all/ + sed -i "s/#Server/Server/g" ${work_dir}/root-image/etc/pacman.d/mirrorlist + sed -i 's/#\(en_US\.UTF-8\)/\1/' ${work_dir}/root-image/etc/locale.gen + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" \ + -r 'locale-gen' \ + run + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" \ + -r 'useradd -m -p "" -g users -G "audio,disk,optical,wheel" libre' \ + run : > ${work_dir}/build.${FUNCNAME} fi } @@ -122,28 +169,28 @@ make_usr_share() { # TODO add 'base' packages on [libre] make_core_repo() { if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then - local _url _urls _pkg_name _cached_pkg _dst + local _url _urls _pkg_name _cached_pkg _dst _pkgs mkdir -p ${work_dir}/repo-core-any mkdir -p ${work_dir}/repo-core-${arch} - pacman -Sy - _urls=$(pacman -Sddp $(comm -2 -3 <(pacman -Sql core | sort ) <(grep -v ^# ${script_path}/core.exclude.${arch} | sort))) + mkdir -p ${work_dir}/pacman.db/var/lib/pacman + pacman -Sy -r ${work_dir}/pacman.db + _pkgs=$(comm -2 -3 <(pacman -Sql -r ${work_dir}/pacman.db core | sort | sed 's@^@core/@') \ + <(grep -v ^# ${script_path}/core.exclude.${arch} | sort | sed 's@^@core/@')) + _urls=$(pacman -Sddp -r ${work_dir}/pacman.db ${_pkgs}) + pacman -Swdd -r ${work_dir}/pacman.db --noprogressbar --noconfirm ${_pkgs} for _url in ${_urls}; do _pkg_name=${_url##*/} _cached_pkg=/var/cache/pacman/pkg/${_pkg_name} _dst=${work_dir}/repo-core-${arch}/${_pkg_name} - if [[ ! -e ${_dst} ]]; then - if [[ -e ${_cached_pkg} ]]; then - cp -v "${_cached_pkg}" "${_dst}" - else - wget -nv "${_url}" -O "${_dst}" - fi - fi - repo-add -q ${work_dir}/repo-core-${arch}/core.db.tar.gz ${work_dir}/repo-core-${arch}/${_pkg_name} - if [[ ${_pkg_name} =~ any.pkg ]]; then - mv "${_dst}" ${work_dir}/repo-core-any/${_pkg_name} - ln -sf ../any/${_pkg_name} ${work_dir}/repo-core-${arch}/${_pkg_name} + cp ${_cached_pkg} ${_dst} + repo-add -q ${work_dir}/repo-core-${arch}/core.db.tar.gz ${_dst} + if [[ ${_pkg_name} == *any.pkg.tar* ]]; then + mv ${_dst} ${work_dir}/repo-core-any/${_pkg_name} + ln -sf ../any/${_pkg_name} ${_dst} fi done + mkdir -p ${work_dir}/iso/${install_dir} + pacman -Sp -r ${work_dir}/pacman.db --print-format "%r/%n-%v" ${_pkgs} | sort > ${work_dir}/iso/${install_dir}/pkglist.repo-core.${arch}.txt : > ${work_dir}/build.${FUNCNAME} fi } @@ -160,15 +207,16 @@ make_aitab() { # Build all filesystem images specified in aitab (.fs .fs.sfs .sfs) make_prepare() { - mkarchiso ${verbose} -D "${install_dir}" prepare "${work_dir}" + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" pkglist + mkarchiso ${verbose} -w "${work_dir}" -D "${install_dir}" prepare } # Build ISO # args: $1 (core | netinstall) make_iso() { local _iso_type=${1} - mkarchiso ${verbose} -D "${install_dir}" checksum "${work_dir}" - mkarchiso ${verbose} -D "${install_dir}" -L "${iso_label}" iso "${work_dir}" "${name}-${version}-${_iso_type}-${arch}.iso" + 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}-${_iso_type}-${arch}.iso" } # Build dual-iso images from ${work_dir}/i686/iso and ${work_dir}/x86_64/iso @@ -192,7 +240,7 @@ make_dual() { cp -a -l -f ${_src_one} ${work_dir}/dual cp -a -l -n ${_src_two} ${work_dir}/dual rm -f ${work_dir}/dual/iso/${install_dir}/aitab - rm -f ${work_dir}/dual/iso/${install_dir}/boot/syslinux/syslinux.cfg + rm -f ${work_dir}/dual/iso/${install_dir}/boot/syslinux/*.cfg if [[ ${_iso_type} == "core" ]]; then if [[ ! -e ${work_dir}/dual/iso/${install_dir}/any/repo-core-any.sfs || ! -e ${work_dir}/dual/iso/${install_dir}/i686/repo-core-i686.sfs || @@ -204,6 +252,8 @@ make_dual() { rm -f ${work_dir}/dual/iso/${install_dir}/any/repo-core-any.sfs rm -f ${work_dir}/dual/iso/${install_dir}/i686/repo-core-i686.sfs rm -f ${work_dir}/dual/iso/${install_dir}/x86_64/repo-core-x86_64.sfs + rm -f ${work_dir}/dual/iso/${install_dir}/pkglist.repo-core.i686.txt + rm -f ${work_dir}/dual/iso/${install_dir}/pkglist.repo-core.x86_64.txt fi paste -d"\n" <(sed "s|%ARCH%|i686|g" ${script_path}/aitab.${_iso_type}) \ <(sed "s|%ARCH%|x86_64|g" ${script_path}/aitab.${_iso_type}) | uniq > ${work_dir}/dual/iso/${install_dir}/aitab @@ -211,19 +261,89 @@ make_dual() { sed "s|%ARCHISO_LABEL%|${iso_label}|g; s|%INSTALL_DIR%|${install_dir}|g" ${_cfg} > ${work_dir}/dual/iso/${install_dir}/boot/syslinux/${_cfg##*/} done - mkarchiso ${verbose} -D "${install_dir}" checksum "${work_dir}/dual" - mkarchiso ${verbose} -D "${install_dir}" -L "${iso_label}" iso "${work_dir}/dual" "${name}-${version}-${_iso_type}-dual.iso" + mkarchiso ${verbose} -w "${work_dir}/dual" -D "${install_dir}" checksum + mkarchiso ${verbose} -w "${work_dir}/dual" -D "${install_dir}" -L "${iso_label}" -o "${out_dir}" iso "${iso_name}-${iso_version}-${_iso_type}-dual.iso" : > ${work_dir}/dual/build.${FUNCNAME}_${_iso_type} fi } +purge_single () +{ + if [[ -d ${work_dir} ]]; then + find ${work_dir} -mindepth 1 -maxdepth 1 \ + ! -path ${work_dir}/iso -prune \ + | xargs rm -rf + fi +} + +purge_dual () +{ + if [[ -d ${work_dir}/dual ]]; then + find ${work_dir}/dual -mindepth 1 -maxdepth 1 \ + ! -path ${work_dir}/dual/iso -prune \ + | xargs rm -rf + fi +} + +clean_single () +{ + rm -rf ${work_dir} + rm -f ${out_dir}/${iso_name}-${iso_version}-*-${arch}.iso +} + +clean_dual () +{ + rm -rf ${work_dir}/dual + rm -f ${out_dir}/${iso_name}-${iso_version}-*-dual.iso +} +make_common_single() { + make_basefs + make_packages + make_setup_mkinitcpio + make_boot + make_boot_efi + make_syslinux + make_isolinux + make_customize_root_image + make_lib_modules + make_usr_share + make_aitab $1 + make_prepare $1 + make_iso $1 +} _usage () { - echo "usage ${0##*/} net_iso_single | core_iso_single | all_iso_single | purge_single | clean_single" - echo " net_iso_dual | core_iso_dual | all_iso_dual | purge_dual | clean_dual" + echo "usage ${0} [options] command " + echo + echo " General options:" + echo " -N Set an iso filename (prefix)" + echo " Default: ${iso_name}" + echo " -V Set an iso version (in filename)" + echo " Default: ${iso_version}" + echo " -L Set an iso label (disk label)" + echo " Default: ${iso_label}" + echo " -D Set an install_dir (directory inside iso)" + echo " Default: ${install_dir}" + echo " -w Set the working directory" + echo " Default: ${work_dir}" + echo " -o Set the output directory" + echo " Default: ${out_dir}" + echo " -v Enable verbose output" + echo " -h This help message" echo + echo " Commands:" + echo " build " + echo " Build selected .iso by and " + echo " purge " + echo " Clean working directory except iso/ directory of build " + echo " clean " + echo " Clean working directory and .iso file in output directory of build " + echo + echo " Command options:" + echo " Valid values 'single', 'dual' or 'all'" + echo " Valid values 'netinstall', 'core' or 'all'" exit ${1} } @@ -232,81 +352,175 @@ if [[ ${EUID} -ne 0 ]]; then _usage 1 fi +while getopts 'N:V:L:D:w:o:vh' arg; do + case "${arg}" in + N) + iso_name="${OPTARG}" + cmd_args+=" -N ${iso_name}" + ;; + V) + iso_version="${OPTARG}" + cmd_args+=" -V ${iso_version}" + ;; + L) + iso_label="${OPTARG}" + cmd_args+=" -L ${iso_label}" + ;; + D) + install_dir="${OPTARG}" + cmd_args+=" -D ${install_dir}" + ;; + w) + work_dir="${OPTARG}" + cmd_args+=" -w ${work_dir}" + ;; + o) + out_dir="${OPTARG}" + cmd_args+=" -o ${out_dir}" + ;; + v) + verbose="-v" + cmd_args+=" -v" + ;; + h|?) _usage 0 ;; + *) + _msg_error "Invalid argument '${arg}'" 0 + _usage 1 + ;; + esac +done + +shift $((OPTIND - 1)) + if [[ $# -lt 1 ]]; then echo "No command specified" _usage 1 fi command_name="${1}" -if [[ ${verbose} == "y" ]]; then - verbose="-v" -else - verbose="" +if [[ $# -lt 2 ]]; then + echo "No command mode specified" + _usage 1 fi +command_mode="${2}" -if [[ ${command_name} =~ single ]]; then - work_dir=${work_dir}/${arch} +if [[ ${command_name} == "build" ]]; then + if [[ $# -lt 3 ]]; then + echo "No build type specified" + _usage 1 + fi +command_type="${3}" fi -make_common_single() { - make_basefs - make_packages - make_customize_root_image - make_setup_mkinitcpio - make_boot - make_syslinux - make_isolinux - make_lib_modules - make_usr_share - make_aitab $1 - make_prepare $1 - make_iso $1 -} +if [[ ${command_mode} == "all" && ${arch} != "x86_64" ]]; then + echo "This mode needs to be run on x86_64" + _usage 1 +fi + +if [[ ${command_mode} == "single" ]]; then + work_dir=${work_dir}/${arch} +fi case "${command_name}" in - net_iso_single) - make_common_single netinstall - ;; - core_iso_single) - make_core_repo - make_common_single core - ;; - all_iso_single) - make_common_single netinstall - make_core_repo - make_common_single core - ;; - net_iso_dual) - make_dual netinstall - ;; - core_iso_dual) - make_dual core - ;; - all_iso_dual) - make_dual netinstall - make_dual core - ;; - purge_single) - if [[ -d ${work_dir} ]]; then - find ${work_dir} -mindepth 1 -maxdepth 1 \ - ! -path ${work_dir}/iso -prune \ - | xargs rm -rf - fi - ;; - purge_dual) - if [[ -d ${work_dir}/dual ]]; then - find ${work_dir}/dual -mindepth 1 -maxdepth 1 \ - ! -path ${work_dir}/dual/iso -prune \ - | xargs rm -rf - fi + build) + case "${command_mode}" in + single) + case "${command_type}" in + netinstall) + make_common_single netinstall + ;; + core) + make_core_repo + make_common_single core + ;; + all) + make_common_single netinstall + make_core_repo + make_common_single core + ;; + *) + echo "Invalid build type '${command_type}'" + _usage 1 + ;; + esac + ;; + dual) + case "${command_type}" in + netinstall) + make_dual netinstall + ;; + core) + make_dual core + ;; + all) + make_dual netinstall + make_dual core + ;; + *) + echo "Invalid build type '${command_type}'" + _usage 1 + ;; + esac + ;; + all) + case "${command_type}" in + netinstall|core|all) + $0 ${cmd_args} build single ${command_type} + $0 ${cmd_args} purge single + linux32 $0 ${cmd_args} build single ${command_type} + linux32 $0 ${cmd_args} purge single + $0 ${cmd_args} build dual ${command_type} + $0 ${cmd_args} purge dual + ;; + *) + echo "Invalid build type '${command_type}'" + _usage 1 + ;; + esac + ;; + *) + echo "Invalid build mode '${command_mode}'" + _usage 1 + ;; + esac ;; - clean_single) - rm -rf ${work_dir} - rm -f ${name}-${version}-*-${arch}.iso + purge) + case "${command_mode}" in + single) + purge_single + ;; + dual) + purge_dual + ;; + all) + $0 ${cmd_args} purge single + linux32 $0 ${cmd_args} purge single + $0 ${cmd_args} purge dual + ;; + *) + echo "Invalid purge mode '${command_mode}'" + _usage 1 + ;; + esac ;; - clean_dual) - rm -rf ${work_dir}/dual - rm -f ${name}-${version}-*-dual.iso + clean) + case "${command_mode}" in + single) + clean_single + ;; + dual) + clean_dual + ;; + all) + $0 ${cmd_args} clean single + linux32 $0 ${cmd_args} clean single + $0 ${cmd_args} clean dual + ;; + *) + echo "Invalid clean mode '${command_mode}'" + _usage 1 + ;; + esac ;; *) echo "Invalid command name '${command_name}'" -- cgit v1.2.2