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:
parent
30ff7ea7a6
commit
4e638eaf24
@ -3,8 +3,6 @@
|
||||
PKGLIST=""
|
||||
QUIET="y"
|
||||
FORCE="n"
|
||||
MOUNTFILE="$(pwd)/mounts"
|
||||
IMG_TYPE="iso"
|
||||
|
||||
APPNAME=$(basename "${0}")
|
||||
|
||||
@ -42,7 +40,6 @@ done
|
||||
PKGLIST="$(echo $PKGLIST)"
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
echo "ARGS: $@"
|
||||
|
||||
# do UID checking here so someone can at least get usage instructions
|
||||
if [ "$EUID" != "0" ]; then
|
||||
@ -61,23 +58,22 @@ case "${command_name}" in
|
||||
*) echo "invalid command name '${command_name}'"; usage 1 ;;
|
||||
esac
|
||||
|
||||
[ "x${imgname}" = "x" ] && (echo "Image name must be specified" && usage 1)
|
||||
[ "x${work_dir}" = "x" ] && (echo "Please specify a working directory" && 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
|
||||
|
||||
echo "${APPNAME} : Configuration Settings"
|
||||
echo " working directory: ${work_dir}"
|
||||
echo " image name: ${imgname}"
|
||||
echo " image type: ${IMG_TYPE}"
|
||||
|
||||
# usage: _pacman <packages>...
|
||||
_pacman ()
|
||||
{
|
||||
local ret
|
||||
if [ "${QUIET}" = "y" ]; then
|
||||
mkarchroot -f ${work_dir} $* 2>&1 >/dev/null
|
||||
mkarchroot -f "${work_dir}/root-image" $* 2>&1 >/dev/null
|
||||
ret=$?
|
||||
else
|
||||
mkarchroot -f ${work_dir} $*
|
||||
mkarchroot -f "${work_dir}/root-image" $*
|
||||
ret=$?
|
||||
fi
|
||||
|
||||
@ -139,16 +135,23 @@ The iso dir is later used to build the actual bootable iso.
|
||||
fi
|
||||
}
|
||||
|
||||
# command_squash path image
|
||||
command_squash () {
|
||||
echo "====> Generating SquashFS image ${imgname}"
|
||||
if [ -e "${imgname}" ]; then
|
||||
# _mksquash dirname
|
||||
_mksquash () {
|
||||
echo "_mksquash $1"
|
||||
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
|
||||
echo -n "Removing old SquashFS image..."
|
||||
rm "${imgname}"
|
||||
rm "${sqimg}"
|
||||
echo "done."
|
||||
else
|
||||
echo "error: SquashFS image '${imgname}' already exists, aborting."
|
||||
echo "error: SquashFS image '${sqimg}' already exists, aborting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@ -156,16 +159,37 @@ command_squash () {
|
||||
echo "Creating SquashFS image. This may take some time..."
|
||||
start=$(date +%s)
|
||||
if [ "${QUIET}" = "y" ]; then
|
||||
mksquashfs "${work_dir}" "${imgname}" -noappend >/dev/null
|
||||
mksquashfs "${1}" "${sqimg}" -noappend >/dev/null
|
||||
else
|
||||
mksquashfs "${work_dir}" "${imgname}" -noappend
|
||||
mksquashfs "${1}" "${sqimg}" -noappend
|
||||
fi
|
||||
minutes=$(echo $start $(date +%s) | awk '{ printf "%0.2f",($2-$1)/60 }')
|
||||
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"
|
||||
|
||||
# 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 [ "${FORCE}" = "y" ]; then
|
||||
echo "Removing existing bootable image..."
|
||||
@ -176,11 +200,11 @@ command_image () {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -e "${MOUNTFILE}" ]; then
|
||||
echo "error: mount file '${MOUNTFILE}' does not exist, aborting."
|
||||
exit 1
|
||||
fi
|
||||
cp "${MOUNTFILE}" "${work_dir}/mounts"
|
||||
cp "${work_dir}/isomounts" "${work_dir}/iso/"
|
||||
}
|
||||
|
||||
command_iso () {
|
||||
_imgcommon
|
||||
|
||||
bootflags=""
|
||||
if [ "$PKGLIST" = "grub" -o "$PKGLIST" = "grub-gfx" ]; then
|
||||
@ -195,20 +219,20 @@ command_image () {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${work_dir}/boot/grub/stage2_eltorito" ]; then
|
||||
echo "error: grub stage files not found in '${work_dir}/boot/grub"
|
||||
if [ ! -e "${work_dir}/iso/boot/grub/stage2_eltorito" ]; then
|
||||
echo "error: grub stage files not found in '${work_dir}/iso/boot/grub'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bootflags="-b boot/grub/stage2_eltorito"
|
||||
elif [ "$PKGLIST" = "syslinux" ]; then
|
||||
elif [ "$PKGLIST" = "isolinux" ]; then
|
||||
if ! pacman -Qi $PKGLIST >/dev/null 2>&1; then
|
||||
echo "$PKGLIST not found on host system. Cannot install!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${work_dir}/boot/isolinux/isolinux.bin" ]; then
|
||||
echo "error: isolinux bin file not found in '${work_dir}/boot/isolinux"
|
||||
if [ ! -e "${work_dir}/iso/boot/isolinux/isolinux.bin" ]; then
|
||||
echo "error: isolinux bin file not found in '${work_dir}/iso/boot/isolinux'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -218,20 +242,77 @@ command_image () {
|
||||
echo " Supported Bootloaders:"
|
||||
echo " grub"
|
||||
echo " grub-gfx"
|
||||
echo " syslinux"
|
||||
echo " isolinux"
|
||||
exit 1
|
||||
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
|
||||
# to do everything. Start with 'install'.
|
||||
if [ "${command_name}" = "install" ]; then
|
||||
command_install
|
||||
if [ "${command_name}" = "create" ]; then
|
||||
command_create
|
||||
fi
|
||||
if [ "${command_name}" = "squash" ]; then
|
||||
command_squash
|
||||
if [ "${command_name}" = "iso" ]; then
|
||||
command_iso
|
||||
fi
|
||||
if [ "${command_name}" = "image" ]; then
|
||||
command_image
|
||||
if [ "${command_name}" = "usb" ]; then
|
||||
command_usb
|
||||
fi
|
||||
|
||||
# vim:ts=4:sw=4:et:
|
||||
|
@ -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"
|
@ -1,9 +1,11 @@
|
||||
ver=2008.10
|
||||
ver=2008.12
|
||||
kver=2.6.27-ARCH
|
||||
|
||||
#Define outside of 'make' for other arches
|
||||
ARCH=i686
|
||||
|
||||
WORKDIR=work
|
||||
|
||||
PWD=`pwd`
|
||||
FTPname=$(PWD)/archlinux-$(ver)-ftp-$(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-usb: core-usb ftp-usb
|
||||
|
||||
core-usb: core-pkgs root-image boot-files
|
||||
mkarchiso -v -p grub-gfx -t disk image image-dir/ $(COREname).img
|
||||
core-usb: core-pkgs overlay
|
||||
mkarchiso -v -p grub-gfx usb $(WORKDIR) $(FTPname).iso
|
||||
|
||||
core-iso: core-pkgs root-image boot-files
|
||||
mkarchiso -v -p grub-gfx image image-dir/ $(FTPname).iso
|
||||
core-iso: core-pkgs overlay
|
||||
mkarchiso -v -p grub-gfx iso $(WORKDIR) $(FTPname).iso
|
||||
|
||||
ftp-usb: root-image boot-files
|
||||
mkarchiso -v -p grub-gfx -t disk image image-dir/ $(FTPname).img
|
||||
ftp-usb: overlay
|
||||
mkarchiso -v -p grub-gfx usb $(WORKDIR) $(FTPname).img
|
||||
|
||||
ftp-iso: root-image boot-files
|
||||
mkarchiso -v -p grub-gfx image image-dir/ $(FTPname).iso
|
||||
ftp-iso: overlay
|
||||
mkarchiso -v -p grub-gfx iso $(WORKDIR) $(FTPname).iso
|
||||
|
||||
.PHONY: boot-files
|
||||
boot-files:
|
||||
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
|
||||
overlay: base-iso
|
||||
cp -r overlay $(WORKDIR)/
|
||||
|
||||
root-image:
|
||||
mkarchiso -v -p "`cat packages.list-$(ARCH)`" install work
|
||||
cp -r overlay/* work
|
||||
chmod 0440 work/etc/sudoers
|
||||
mkdir image-dir/
|
||||
mkarchiso -v squash work image-dir/root-image.sqfs
|
||||
mkarchiso -v -p "`cat packages.list-$(ARCH)`" create $(WORKDIR)
|
||||
|
||||
base-iso: root-image
|
||||
mv $(WORKDIR)/root-image/boot $(WORKDIR)/iso/
|
||||
cp -r boot-files/* $(WORKDIR)/iso/boot/
|
||||
cp -r $(WORKDIR)/root-image/usr/lib/grub/i386-pc/* $(WORKDIR)/iso/boot/grub
|
||||
cp -r $(WORKDIR)/root-image/usr/lib/syslinux/isolinux.bin $(WORKDIR)/iso/boot/isolinux
|
||||
|
||||
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
|
||||
|
||||
# hacky way to always pull
|
||||
.PHONY: core-pkgs
|
||||
core-pkgs:
|
||||
wget --mirror -P core-pkgs -nH --cut-dirs=3 ftp://ftp.archlinux.org/core/os/$(ARCH)
|
||||
mkdir image-dir/
|
||||
mkarchiso -v squash core-pkgs image-dir/core-pkgs.sqfs
|
||||
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:
|
||||
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
|
||||
|
12
configs/install-iso/isomounts
Normal file
12
configs/install-iso/isomounts
Normal 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
|
@ -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
|
Loading…
Reference in New Issue
Block a user