git-svn-id: http://phraktured.net/archiso@8 00a9fe69-e71b-0410-bb23-df0e5024db41

This commit is contained in:
Aaron Griffin 2006-09-12 18:14:17 +00:00
parent 5c56aefa6b
commit 93a6284c32
3 changed files with 78 additions and 111 deletions

View File

@ -39,6 +39,7 @@ lzo2
mailx mailx
man man
man-pages man-pages
memtest86+
mktemp mktemp
module-init-tools module-init-tools
nano nano
@ -68,7 +69,7 @@ reiserfsprogs
rp-pppoe rp-pppoe
sed sed
shadow shadow
squashfs squashfs-tools
sysfsutils sysfsutils
syslog-ng syslog-ng
sysvinit sysvinit
@ -76,7 +77,7 @@ tar
tcp_wrappers tcp_wrappers
tcpdump tcpdump
udev udev
unionfs unionfs-utils
unrar unrar
unzip unzip
usbutils usbutils

166
mkarchiso
View File

@ -1,79 +1,80 @@
#!/bin/sh #!/bin/sh
CONFIG="$(pwd)/mkarchiso.conf" CONFIG="$(pwd)/mkarchiso.conf"
CPIOCONFIG="$(pwd)/mkinitcpio.conf" CPIOCONFIG="$(pwd)/archiso-mkinitcpio.conf"
DEF_CONFIG_DIR="$(pwd)/default-config" DEF_CONFIG_DIR="$(pwd)/default-config"
QUIET="y" QUIET="y"
FORCE="n"
SKIP_INSTALL="n" command_name=""
SKIP_SQUASHFS="n" work_dir=""
SKIP_BOOTIMG="n" isoname=""
SKIP_ISO="n"
PKGDIR="." PKGDIR="."
APPNAME=$(basename "${0}") APPNAME=$(basename "${0}")
ALL_ARGS="${@}" ALL_ARGS="${@}" #for fakeroot usage
usage () usage ()
{ {
echo "usage ${APPNAME} [options] working-directory imagename.iso" echo "usage ${APPNAME} [options] command <command options>"
echo " general options:"
echo " -c CONFIG Use CONFIG file. default: /etc/archlive/mkarchiso.conf" echo " -c CONFIG Use CONFIG file. default: /etc/archlive/mkarchiso.conf"
echo " -i CPIO CONFIG Use CONFIG file for mkinitcpio. default: /etc/archlive/mkinitcpio.conf" echo " -i CPIO CONFIG Use CONFIG file for mkinitcpio. default: /etc/archlive/mkinitcpio.conf"
echo " -s a,b,c Skip creation section. Valid sections are:" echo " -f Force overwrite of working files / iso"
echo " install : This section installs all packages."
echo " squashfs: This section creates a squashfs root image"
echo " bootimg : This section creates a boot image."
echo " iso : This section builds the final iso."
echo " -v Verbose output. Default: no" echo " -v Verbose output. Default: no"
echo " -h This message." echo " -h This message."
echo " commands:"
echo " install <working dir> : where to build the ISO root"
echo " squash <working dir> : generate a squashfs image of the ISO root"
echo " iso <working dir> <iso name> : build an iso from the working directory"
echo " all <working dir> <iso name> : perform all of the above, in order"
exit 1 exit 1
} }
skipopts ()
{
for i in $@; do
case $i in
install) SKIP_INSTALL="y" ;;
squashfs) SKIP_SQUASHFS="y" ;;
bootimg) SKIP_BOOTIMG="y" ;;
iso) SKIP_ISO="y" ;;
*) echo "invalid section '$i'"; usage ;;
esac
done
}
while getopts 'c:i:n:s:pvh' arg; do while getopts 'c:i:n:s:pvh' arg; do
case "$arg" in case "${arg}" in
c) CONFIG="$OPTARG" ;; c) CONFIG="${OPTARG}" ;;
i) CPIOCONFIG="$OPTARG" ;; i) CPIOCONFIG="${OPTARG}" ;;
s) OLDIFS=$IFS; IFS=, v) FORCE="f" ;;
skipopts $OPTARG
IFS=$OLDIFS ;;
v) QUIET="n" ;; v) QUIET="n" ;;
h|?) usage ;; h|?) usage ;;
*) echo "invalid argument '$arg'"; usage ;; *) echo "invalid argument '${arg}'"; usage ;;
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -ne 2 ]; then [ $# -le 1 ] && usage
usage
else
work_dir=${1}
isoname=${2}
fi
if [ -e "${work_dir}" -a "${SKIP_INSTALL}" != "y" ]; then command_name="${1}"
case "${command_name}" in
install) work_dir="${2}" ;;
squash) work_dir="${2}" ;;
iso) work_dir="${2}"; isoname="${3}" ;;
all) work_dir="${2}"; isoname="${3}" ;;
*) echo "invalid command name '${command_name}'"; usage ;;
esac
[ "x${work_dir}" = "x" ] && (echo "please specify a working directory" && usage)
if [ -e "${work_dir}" -a "${FORCE}" = "n" ]; then
echo "Working dir '${work_dir}' already exists, aborting..." echo "Working dir '${work_dir}' already exists, aborting..."
exit 1 exit 1
fi fi
if [ -e "${isoname}" -a "${SKIP_ISO}" != "y" ]; then if [ "${command_name}" = "iso" -o "${command_name}" = "all" ]; then
[ "x${isoname}" = "x" ] && (echo "please specify an iso name" && usage)
if [ -e "${isoname}" -a "${FORCE}" = "n"]; then
echo "ISO Image '${isoname}' already exists, aborting..." echo "ISO Image '${isoname}' already exists, aborting..."
exit 1 exit 1
fi
if [ -e "${CPIOCONFIG}" ]; then
echo "mkinitcpio config '${CPIOCONFIG}' does not exist, aborting..."
exit 1
fi
fi fi
#TODO - do we even need a config file?
if [ -e "${CONFIG}" ]; then if [ -e "${CONFIG}" ]; then
source "${CONFIG}" source "${CONFIG}"
else else
@ -81,13 +82,7 @@ else
exit 1 exit 1
fi fi
if [ -e "${CPIOCONFIG}" ]; then # {{{ Build
source "${CPIOCONFIG}"
else
echo "mkinitcpio config '${CPIOCONFIG}' does not exist, aborting..."
exit 1
fi
isoroot="${work_dir}/iso" isoroot="${work_dir}/iso"
instroot="${work_dir}/install" instroot="${work_dir}/install"
@ -104,34 +99,18 @@ _kversion ()
sed "s|.*/lib/modules/\([^/]*\).*/$|\1|") sed "s|.*/lib/modules/\([^/]*\).*/$|\1|")
} }
#Work-arounds for depmod core dumps.... I guess we could just ulimit for now...
_safepacman ()
{
FAKEROOTSAV=$FAKEROOTKEY; unset FAKEROOTKEY
if ! pacman -Sf --noconfirm -r "${instroot}" $* 2>&1 | grep "\[#"; then
echo "pacman failed to install '$*', aborting..."
exit 1
fi
FAKEROOTKEY=$FAKEROOTSAV
}
safe_install_pkgfile ()
{
if [ -e "${1}" ]; then
toinstall=""
while read pkg; do
#skip packages listed in IGNOREPKGS
echo $ignorepkgs | grep "\<$pkg\>" >/dev/null 2>&1 && continue
toinstall="${toinstall} ${pkg}"
done < ${1}
_safepacman "${toinstall}"
fi
}
_pacman () _pacman ()
{ {
#depmod causes fakechroot to coredump - it's harmless, but makes the output ugly
fkchroot=""
if [ "${1}" = "-safe" ]; then
fkchroot=""
shift 1
fi
FAKEROOTSAV=$FAKEROOTKEY; unset FAKEROOTKEY FAKEROOTSAV=$FAKEROOTKEY; unset FAKEROOTKEY
if ! fakechroot pacman -Sf --noconfirm -r "${instroot}" $* 2>&1 | grep "\[#"; then #TODO this grep is a tad weird...
echo "pacman failed to install '$*', aborting..." if ! eval "${fkchroot} pacman -Sf --noconfirm -r \"${instroot}\" $*" | grep "\[#"; then
exit 1 exit 1
fi fi
FAKEROOTKEY=$FAKEROOTSAV FAKEROOTKEY=$FAKEROOTSAV
@ -139,17 +118,22 @@ _pacman ()
install_pkgfile () install_pkgfile ()
{ {
safe=""
if [ "${1}" = "-safe" ]; then
safe="-safe"
shift 1
fi
if [ -e "${1}" ]; then if [ -e "${1}" ]; then
toinstall="" toinstall=""
while read pkg; do while read pkg; do
echo $ignorepkgs | grep "\<$pkg\>" >/dev/null 2>&1 && continue echo $ignorepkgs | grep "\<$pkg\>" >/dev/null 2>&1 && continue
toinstall="${toinstall} ${pkg}" toinstall="${toinstall} ${pkg}"
done < ${1} done < ${1}
_pacman "${toinstall}" _pacman "${safe}" "${toinstall}"
fi fi
} }
if [ "${SKIP_INSTALL}" = "n" ]; then if [ "${command_name}" = "install" -o "${command_name}" = "all" ]; then
mkdir -p "${isoroot}" mkdir -p "${isoroot}"
mkdir -p "${instroot}" mkdir -p "${instroot}"
@ -163,9 +147,6 @@ if [ "${SKIP_INSTALL}" = "n" ]; then
echo "Installing 'base' packages..." echo "Installing 'base' packages..."
install_pkgfile "${PKGDIR}/base.packages" install_pkgfile "${PKGDIR}/base.packages"
echo "Installing _required_ packages..."
_pacman "memtest86+ unionfs unionfs-utils usbutils libusb pciutils squashfs-tools"
echo "Installing custom packages..." echo "Installing custom packages..."
for fil in ${package_files}; do for fil in ${package_files}; do
#TODO search for file if not absolute... #TODO search for file if not absolute...
@ -178,11 +159,8 @@ if [ "${SKIP_INSTALL}" = "n" ]; then
done done
echo "Installing kernel '${kernelpkg}'" echo "Installing kernel '${kernelpkg}'"
# fakechroot and depmod don't get along well. We'll do that stuff
# manually...
# TODO: fix fakechroot instead of working around it like a jackass
FAKEROOTSAV=$FAKEROOTKEY; unset FAKEROOTKEY FAKEROOTSAV=$FAKEROOTKEY; unset FAKEROOTKEY
if ! _safepacman "${kernelpkg}" ; then if ! _pacman -safe "${kernelpkg}" ; then
echo "pacman failed to install '${kernelpkg}', aborting..." echo "pacman failed to install '${kernelpkg}', aborting..."
exit 1 exit 1
fi fi
@ -190,12 +168,12 @@ if [ "${SKIP_INSTALL}" = "n" ]; then
kernelver=$(_kversion) kernelver=$(_kversion)
kernelsuffix=${kernelver##*-} kernelsuffix=${kernelver##*-}
echo "Kernel Version ${kernelver} (${kernelsuffix}) installed - installing modules..." echo "Kernel Version ${kernelver} (${kernelsuffix}) installed - installing modules..."
safe_install_pkgfile "modules.${kernelsuffix}" install_pkgfile -safe "modules.${kernelsuffix}"
echo "Updating module dependancies" echo "Updating module dependancies"
[ "${kernelsuffix}" == "ARCH" ] && kernelsuffix="" [ "${kernelsuffix}" = "ARCH" ] && kernelsuffix=""
depmod -a -b "${instroot}" -v "${kernelver}" -F "${instroot}/boot/System.map26${kernelsuffix}" >/dev/null depmod -a -b "${instroot}" -v "${kernelver}" -F "${instroot}/boot/System.map26${kernelsuffix}" >/dev/null
find "${instroot}/boot" -name *.img -delete find "${instroot}/boot" -name *.img -delete #TODO, will this delete our special stuff?
echo "Applying default configuration for the Arch ISO." echo "Applying default configuration for the Arch ISO."
cp -rf ${DEF_CONFIG_DIR}/* "${instroot}" cp -rf ${DEF_CONFIG_DIR}/* "${instroot}"
@ -236,7 +214,7 @@ if [ "${SKIP_INSTALL}" = "n" ]; then
fi fi
fi fi
if [ "${SKIP_SQUASHFS}" = "n" ]; then if [ "${command_name}" = "squash" -o "${command_name}" = "all" ]; then
if [ -e "${isoroot}/archlive.sqfs" ]; then if [ -e "${isoroot}/archlive.sqfs" ]; then
echo -n "Removing old squashfs image..." echo -n "Removing old squashfs image..."
rm "${isoroot}/archlive.sqfs" rm "${isoroot}/archlive.sqfs"
@ -249,7 +227,7 @@ if [ "${SKIP_SQUASHFS}" = "n" ]; then
echo "done in $(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }') minutes." echo "done in $(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }') minutes."
fi fi
if [ "${SKIP_BOOTIMG}" = "n" ]; then if [ "${command_name}" = "iso" -o "${command_name}" = "all" ]; then
kernelver=$(_kversion) kernelver=$(_kversion)
basedir=${instroot} basedir=${instroot}
[ "${instroot:0:1}" != "/" ] && basedir="$(pwd)/${instroot}" [ "${instroot:0:1}" != "/" ] && basedir="$(pwd)/${instroot}"
@ -264,16 +242,10 @@ fi
if [ "${SKIP_ISO}" = "n" ]; then if [ "${SKIP_ISO}" = "n" ]; then
echo "Creating ISO image..." echo "Creating ISO image..."
mkisofs ${q} -r -l -b "boot/grub/stage2_eltorito" -uid 0 -gid 0 -no-emul-boot \ q=""
[ "${QUIET}" = "y" ] && q="-q"
mkisofs "${q}" -r -l -b "boot/grub/stage2_eltorito" -uid 0 -gid 0 -no-emul-boot \
-boot-load-size 4 -boot-info-table -publisher "Arch Linux <archlinux.org>" \ -boot-load-size 4 -boot-info-table -publisher "Arch Linux <archlinux.org>" \
-input-charset=UTF-8 \ -input-charset=UTF-8 -p "prepared by $NAME" -A "Arch Linux Live/Rescue CD" \
-p "prepared by $NAME" -A "Arch Linux Live/Rescue CD" -copyright /etc/copyright \ -copyright /etc/copyright -o "${isoname}" "${isoroot}"
-o "${isoname}" "${isoroot}"
fi
if [ "${qemu_test}" = "y" ]; then
echo "Testing image via qemu..."
qemu -boot d -kernel-kqemu -cdrom "${isoname}" ${qemuparams}
else
echo "Image completed: ${isoname}"
fi fi

View File

@ -1,6 +0,0 @@
# vim:set ft=sh
# This file is for mkarchiso ONLY and is not to be edited by hand
MODULES=""
BINARIES=""
FILES=""
HOOKS="base udev archlive ide scsi sata usb fw filesystems"