From 3d05bef2b96c84126e6c8921e834f2655a4ec730 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Fri, 16 Mar 2012 01:48:10 -0300 Subject: [archiso] Implement own chroot functions in mkarchiso * Remove devtools dependency. * Better control over what files are touched inside chroot (root-image). Now: NONE :) * Two new commands: + init: To install {base} group and other needed packages (syslinux for now) + run: If we want to run some command inside chroot (mkinitcpio, locale-gen, useradd, etc etc...) * Renamed command: "created" to "install", says much better what does. Signed-off-by: Gerardo Exequiel Pozzi --- archiso/mkarchiso | 103 ++++++++++++++++++++++++++++++++++++++-------- configs/baseline/build.sh | 7 ++-- configs/releng/build.sh | 19 +++++---- 3 files changed, 102 insertions(+), 27 deletions(-) diff --git a/archiso/mkarchiso b/archiso/mkarchiso index b3aa5cd..df3d354 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -5,6 +5,7 @@ set -e -u app_name=${0##*/} arch=$(uname -m) pkg_list="" +run_cmd="" quiet="y" pacman_conf="/etc/pacman.conf" export iso_label="ARCH_$(date +%Y%m)" @@ -44,6 +45,44 @@ _show_space_usage () { _msg_info "Total: ${_total} MiB (100%) | Used: ${_used} MiB (${_pct_u}) | Avail: ${_avail} MiB ($((100 - ${_pct_u%\%}))%)" } +_chroot_mount () { + mount -t devtmpfs dev "${work_dir}/root-image/dev" + mount -t devpts devpts "${work_dir}/root-image/dev/pts" + mount -t tmpfs devshm "${work_dir}/root-image/dev/shm" + mount -t proc proc "${work_dir}/root-image/proc" + mount -t tmpfs run "${work_dir}/root-image/run" + mount -t sysfs sys "${work_dir}/root-image/sys" + mount -t tmpfs tmp "${work_dir}/root-image/tmp" + + trap '_chroot_umount' EXIT HUP INT TERM +} + +_chroot_umount () { + umount "${work_dir}/root-image/tmp" + umount "${work_dir}/root-image/sys" + umount "${work_dir}/root-image/run" + umount "${work_dir}/root-image/proc" + umount "${work_dir}/root-image/dev/shm" + umount "${work_dir}/root-image/dev/pts" + umount "${work_dir}/root-image/dev" + + trap - EXIT HUP INT TERM +} + +_chroot_init() { + if [[ ! -d ${work_dir}/root-image/var/cache/pacman ]]; then + mkdir -p ${work_dir}/root-image/{dev,proc,run,sys,tmp,var/lib/pacman} + _pacman "base" + _pacman "syslinux" + fi +} + +_chroot_run() { + _chroot_mount + eval chroot ${work_dir}/root-image "${run_cmd}" + _chroot_umount +} + # Mount a filesystem (trap signals in case of error for unmounting it # $1: source image # $2: mount-point @@ -99,6 +138,7 @@ _usage () echo "usage ${app_name} [options] command " echo " general options:" echo " -p PACKAGE(S) Package(s) to install, can be used multiple times" + echo " -r Run inside root-image" echo " -C Config file for pacman. Default ${pacman_conf}" echo " -L