Final changes for new nextgen scripts

Too much to list. Just look at the diff 8)

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
Aaron Griffin 2008-12-18 22:08:38 -06:00
parent 30ff7ea7a6
commit 4e638eaf24
5 changed files with 154 additions and 154 deletions

View file

@ -3,8 +3,6 @@
PKGLIST="" PKGLIST=""
QUIET="y" QUIET="y"
FORCE="n" FORCE="n"
MOUNTFILE="$(pwd)/mounts"
IMG_TYPE="iso"
APPNAME=$(basename "${0}") APPNAME=$(basename "${0}")
@ -42,7 +40,6 @@ done
PKGLIST="$(echo $PKGLIST)" PKGLIST="$(echo $PKGLIST)"
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
echo "ARGS: $@"
# do UID checking here so someone can at least get usage instructions # do UID checking here so someone can at least get usage instructions
if [ "$EUID" != "0" ]; then if [ "$EUID" != "0" ]; then
@ -61,23 +58,22 @@ case "${command_name}" in
*) echo "invalid command name '${command_name}'"; usage 1 ;; *) echo "invalid command name '${command_name}'"; usage 1 ;;
esac esac
[ "x${imgname}" = "x" ] && (echo "Image name must be specified" && usage 1) [ "x${imgname}" = "x" ] && echo "Image name must be specified" && usage 1
[ "x${work_dir}" = "x" ] && (echo "Please specify a working directory" && usage 1) [ "x${work_dir}" = "x" ] && echo "Please specify a working directory" && usage 1
echo "${APPNAME} : Configuration Settings" echo "${APPNAME} : Configuration Settings"
echo " working directory: ${work_dir}" echo " working directory: ${work_dir}"
echo " image name: ${imgname}" echo " image name: ${imgname}"
echo " image type: ${IMG_TYPE}"
# usage: _pacman <packages>... # usage: _pacman <packages>...
_pacman () _pacman ()
{ {
local ret local ret
if [ "${QUIET}" = "y" ]; then if [ "${QUIET}" = "y" ]; then
mkarchroot -f ${work_dir} $* 2>&1 >/dev/null mkarchroot -f "${work_dir}/root-image" $* 2>&1 >/dev/null
ret=$? ret=$?
else else
mkarchroot -f ${work_dir} $* mkarchroot -f "${work_dir}/root-image" $*
ret=$? ret=$?
fi fi
@ -139,16 +135,23 @@ The iso dir is later used to build the actual bootable iso.
fi fi
} }
# command_squash path image # _mksquash dirname
command_squash () { _mksquash () {
echo "====> Generating SquashFS image ${imgname}" echo "_mksquash $1"
if [ -e "${imgname}" ]; then if [ ! -d "$1" ]; then
echo "Error: '$1' is not a directory"
return 1
fi
sqimg="${work_dir}/iso/$(basename ${1}).sqfs"
echo "====> Generating SquashFS image for '${1}'"
if [ -e "${sqimg}" ]; then
if [ "${FORCE}" = "y" ]; then if [ "${FORCE}" = "y" ]; then
echo -n "Removing old SquashFS image..." echo -n "Removing old SquashFS image..."
rm "${imgname}" rm "${sqimg}"
echo "done." echo "done."
else else
echo "error: SquashFS image '${imgname}' already exists, aborting." echo "error: SquashFS image '${sqimg}' already exists, aborting."
exit 1 exit 1
fi fi
fi fi
@ -156,16 +159,37 @@ command_squash () {
echo "Creating SquashFS image. This may take some time..." echo "Creating SquashFS image. This may take some time..."
start=$(date +%s) start=$(date +%s)
if [ "${QUIET}" = "y" ]; then if [ "${QUIET}" = "y" ]; then
mksquashfs "${work_dir}" "${imgname}" -noappend >/dev/null mksquashfs "${1}" "${sqimg}" -noappend >/dev/null
else else
mksquashfs "${work_dir}" "${imgname}" -noappend mksquashfs "${1}" "${sqimg}" -noappend
fi fi
minutes=$(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }') minutes=$(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }')
echo "Image creation done in $minutes minutes." echo "Image creation done in $minutes minutes."
} }
command_image () { _imgcommon () {
for d in $(find "${work_dir}" -maxdepth 1 -type d -name '[^.]*'); do
if [ "$d" != "${work_dir}/iso" -a \
"$(basename "$d")" != "iso" -a \
"$d" != "${work_dir}" ]; then
_mksquash "$d"
fi
done
echo "====> Making bootable image" echo "====> Making bootable image"
# Sanity checks
if [ ! -d "${work_dir}/iso" ]; then
echo "Error: '${work_dir}/iso' doesn't exist. What did you do?!"
exit 1
fi
if [ ! -f "${work_dir}/isomounts" ]; then
echo "Error: the isomounts file doesn't exist. This image won't do anything"
echo " Protecting you from yourself and erroring out here..."
exit 1
fi
if [ -e "${imgname}" ]; then if [ -e "${imgname}" ]; then
if [ "${FORCE}" = "y" ]; then if [ "${FORCE}" = "y" ]; then
echo "Removing existing bootable image..." echo "Removing existing bootable image..."
@ -176,11 +200,11 @@ command_image () {
fi fi
fi fi
if [ ! -e "${MOUNTFILE}" ]; then cp "${work_dir}/isomounts" "${work_dir}/iso/"
echo "error: mount file '${MOUNTFILE}' does not exist, aborting." }
exit 1
fi command_iso () {
cp "${MOUNTFILE}" "${work_dir}/mounts" _imgcommon
bootflags="" bootflags=""
if [ "$PKGLIST" = "grub" -o "$PKGLIST" = "grub-gfx" ]; then if [ "$PKGLIST" = "grub" -o "$PKGLIST" = "grub-gfx" ]; then
@ -195,20 +219,20 @@ command_image () {
exit 1 exit 1
fi fi
if [ ! -e "${work_dir}/boot/grub/stage2_eltorito" ]; then if [ ! -e "${work_dir}/iso/boot/grub/stage2_eltorito" ]; then
echo "error: grub stage files not found in '${work_dir}/boot/grub" echo "error: grub stage files not found in '${work_dir}/iso/boot/grub'"
exit 1 exit 1
fi fi
bootflags="-b boot/grub/stage2_eltorito" bootflags="-b boot/grub/stage2_eltorito"
elif [ "$PKGLIST" = "syslinux" ]; then elif [ "$PKGLIST" = "isolinux" ]; then
if ! pacman -Qi $PKGLIST >/dev/null 2>&1; then if ! pacman -Qi $PKGLIST >/dev/null 2>&1; then
echo "$PKGLIST not found on host system. Cannot install!" echo "$PKGLIST not found on host system. Cannot install!"
exit 1 exit 1
fi fi
if [ ! -e "${work_dir}/boot/isolinux/isolinux.bin" ]; then if [ ! -e "${work_dir}/iso/boot/isolinux/isolinux.bin" ]; then
echo "error: isolinux bin file not found in '${work_dir}/boot/isolinux" echo "error: isolinux bin file not found in '${work_dir}/iso/boot/isolinux'"
exit 1 exit 1
fi fi
@ -218,20 +242,77 @@ command_image () {
echo " Supported Bootloaders:" echo " Supported Bootloaders:"
echo " grub" echo " grub"
echo " grub-gfx" echo " grub-gfx"
echo " syslinux" echo " isolinux"
exit 1 exit 1
fi fi
echo "Creating ISO image..."
qflag=""
[ "${QUIET}" = "y" ] && qflag="-q"
mkisofs ${qflag} -r -l $bootflags -uid 0 -gid 0 \
-input-charset utf-8 -p "prepared by mkarchiso" \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-publisher "ArchLinux <archlinux.org>" \
-A "ArchLinux Live/Rescue CD" \
-o "${imgname}" "${work_dir}/iso/"
}
command_usb () {
_imgcommon
fsimg="${imgname}.part1"
# ext2 overhead's upper bound is 6%, empirically tested up to 1GB
rootsize=$(du -bs ${IMGROOT}|cut -f1)
imgsz=$(( (${rootsize}*106)/100/512 + 1)) # image size in sectors
# create the filesystem image file
dd if=/dev/zero of="$fsimg" bs=512 count="$imgsz"
# create a filesystem on the image
mke2fs -m 0 -F "$fsimg"
# mount the filesystem and copy data
modprobe loop
TMPDIR=$(mktemp -d archiso-usbXXXXXX)
mount -o loop "$fsimg" "$TMPDIR"
cp -a "${work_dir}"/iso/* "$TMPDIR"
umount "$TMPDIR"
rm -f "$TMPDIR"
# add sectors 0-62, then glue together
dd if=/dev/zero of="${imgname}" bs=512 count=63
cat "$fsimg" >> "${imgname}"
rm "$fsimg"
# create a partition table
# if this looks like voodoo, it's because it is
sfdisk -uS -f "${imgname}" << EOF
63,$imgsz,83,*
0,0,00
0,0,00
0,0,00
EOF
# install grub on the image
grub --no-floppy --batch << EOF
device (hd0) ${imgname}
root (hd0,0)
setup (hd0)
EOF
}
# Go through the main commands in order. If 'all' was specified, then we want # Go through the main commands in order. If 'all' was specified, then we want
# to do everything. Start with 'install'. # to do everything. Start with 'install'.
if [ "${command_name}" = "install" ]; then if [ "${command_name}" = "create" ]; then
command_install command_create
fi fi
if [ "${command_name}" = "squash" ]; then if [ "${command_name}" = "iso" ]; then
command_squash command_iso
fi fi
if [ "${command_name}" = "image" ]; then if [ "${command_name}" = "usb" ]; then
command_image command_usb
fi fi
# vim:ts=4:sw=4:et: # vim:ts=4:sw=4:et:

View file

@ -1,79 +0,0 @@
#!/bin/bash
#
# mkusbimg - creates a bootable disk image
# Copyright (C) 2008 Simo Leone <simo@archlinux.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# usage(exitvalue)
# outputs a usage message and exits with value
APPNAME=$(basename "${0}")
usage()
{
echo "usage: ${APPNAME} <imageroot> <imagefile>"
exit $1
}
##################################################
if [ $# -ne 2 ]; then
usage 1
fi
DISKIMG="${2}"
IMGROOT="${1}"
TMPDIR=$(mktemp -d)
FSIMG=$(mktemp)
# ext2 overhead's upper bound is 6%
# empirically tested up to 1GB
rootsize=$(du -bs ${IMGROOT}|cut -f1)
IMGSZ=$(( (${rootsize}*106)/100/512 + 1)) # image size in sectors
# create the filesystem image file
dd if=/dev/zero of="$FSIMG" bs=512 count="$IMGSZ"
# create a filesystem on the image
mke2fs -m 0 -F "$FSIMG"
# mount the filesystem and copy data
modprobe loop
mount -o loop "$FSIMG" "$TMPDIR"
cp -a "$IMGROOT"/* "$TMPDIR"
# unmount filesystem
umount "$TMPDIR"
# add sectors 0-62, then glue together
dd if=/dev/zero of="$DISKIMG" bs=512 count=63
cat "$FSIMG" >> "$DISKIMG"
# create a partition table
# if this looks like voodoo, it's because it is
sfdisk -uS -f "$DISKIMG" << EOF
63,$IMGSZ,83,*
0,0,00
0,0,00
0,0,00
EOF
# install grub on the image
grub --no-floppy --batch << EOF
device (hd0) $DISKIMG
root (hd0,0)
setup (hd0)
EOF
# all done :)
rm -fr "$TMPDIR" "$FSIMG"

View file

@ -1,9 +1,11 @@
ver=2008.10 ver=2008.12
kver=2.6.27-ARCH kver=2.6.27-ARCH
#Define outside of 'make' for other arches #Define outside of 'make' for other arches
ARCH=i686 ARCH=i686
WORKDIR=work
PWD=`pwd` PWD=`pwd`
FTPname=$(PWD)/archlinux-$(ver)-ftp-$(ARCH) FTPname=$(PWD)/archlinux-$(ver)-ftp-$(ARCH)
COREname=$(PWD)/archlinux-$(ver)-core-$(ARCH) COREname=$(PWD)/archlinux-$(ver)-core-$(ARCH)
@ -12,44 +14,36 @@ all: core-iso core-usb ftp-iso ftp-usb
all-iso: core-iso ftp-iso all-iso: core-iso ftp-iso
all-usb: core-usb ftp-usb all-usb: core-usb ftp-usb
core-usb: core-pkgs root-image boot-files core-usb: core-pkgs overlay
mkarchiso -v -p grub-gfx -t disk image image-dir/ $(COREname).img mkarchiso -v -p grub-gfx usb $(WORKDIR) $(FTPname).iso
core-iso: core-pkgs root-image boot-files core-iso: core-pkgs overlay
mkarchiso -v -p grub-gfx image image-dir/ $(FTPname).iso mkarchiso -v -p grub-gfx iso $(WORKDIR) $(FTPname).iso
ftp-usb: root-image boot-files ftp-usb: overlay
mkarchiso -v -p grub-gfx -t disk image image-dir/ $(FTPname).img mkarchiso -v -p grub-gfx usb $(WORKDIR) $(FTPname).img
ftp-iso: root-image boot-files ftp-iso: overlay
mkarchiso -v -p grub-gfx image image-dir/ $(FTPname).iso mkarchiso -v -p grub-gfx iso $(WORKDIR) $(FTPname).iso
.PHONY: boot-files overlay: base-iso
boot-files: cp -r overlay $(WORKDIR)/
mkdir -p image-dir/boot/grub/
mkdir -p image-dir/boot/isolinux
#ick! this section needs reworking
cp -r work/usr/lib/grub/i386-pc/* image-dir/boot/grub
cp -r work/usr/lib/syslinux/isolinux.bin image-dir/boot/isolinux
cp -r work/boot/* image-dir/boot/
cp -r boot-files/* image-dir/boot/
#end ick
mkinitcpio -c initcpio-ide -b work/ -k $(kver) -g image-dir/boot/archiso_ide.img
mkinitcpio -c initcpio-pata -b work/ -k $(kver) -g image-dir/boot/archiso_pata.img
root-image: root-image:
mkarchiso -v -p "`cat packages.list-$(ARCH)`" install work mkarchiso -v -p "`cat packages.list-$(ARCH)`" create $(WORKDIR)
cp -r overlay/* work
chmod 0440 work/etc/sudoers
mkdir image-dir/
mkarchiso -v squash work image-dir/root-image.sqfs
# hacky way to always pull base-iso: root-image
.PHONY: core-pkgs mv $(WORKDIR)/root-image/boot $(WORKDIR)/iso/
core-pkgs: cp -r boot-files/* $(WORKDIR)/iso/boot/
wget --mirror -P core-pkgs -nH --cut-dirs=3 ftp://ftp.archlinux.org/core/os/$(ARCH) cp -r $(WORKDIR)/root-image/usr/lib/grub/i386-pc/* $(WORKDIR)/iso/boot/grub
mkdir image-dir/ cp -r $(WORKDIR)/root-image/usr/lib/syslinux/isolinux.bin $(WORKDIR)/iso/boot/isolinux
mkarchiso -v squash core-pkgs image-dir/core-pkgs.sqfs
mkinitcpio -c initcpio-ide -b $(WORKDIR)/root-image -k $(kver) -g $(WORKDIR)/iso/boot/archiso-ide.img
mkinitcpio -c initcpio-pata -b $(WORKDIR)/root-image -k $(kver) -g $(WORKDIR)/iso/boot/archiso-pata.img
core-pkgs: base-iso
mkdir $(WORKDIR)/core-pkgs/
wget --mirror -P $(WORKDIR)/core-pkgs -nH --cut-dirs=3 ftp://ftp.archlinux.org/core/os/$(ARCH)
clean: clean:
rm -rf work image-dir $(FTPname).img $(FTPname).iso $(COREname).img $(COREname).iso rm -rf $(WORKDIR) image-dir $(FTPname).img $(FTPname).iso $(COREname).img $(COREname).iso

View file

@ -0,0 +1,12 @@
# archiso isomounts file
# img - location of image/directory to mount relative to addons directory
# arch - architecture of this image
# mount point - absolute location on the post-initrd root
# type - either 'bind' or 'squashfs' for now
# syntax: <img> <arch> <mount point> <type>
root-image.sqfs i686 / squashfs
overlay.sqfs i686 / squashfs
overlay.sqfs x86_64 / squashfs
core-pkgs.sqfs i686 /src/core/pkg squashfs

View file

@ -1,8 +0,0 @@
# img - location of image/directory to mount relative to addons directory
# mount point - absolute location on the post-initrd root
# type - either 'bind' or 'squashfs' for now
# syntax: <img> <mount point> <type>
root-image / bind
core-pkgs /src/core/pkg bind