Rework the commands, create and iso
Initial changes to get 'create' working as intended. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
This commit is contained in:
parent
901526970e
commit
f918440da1
@ -15,20 +15,22 @@ usage ()
|
|||||||
echo " general options:"
|
echo " general options:"
|
||||||
echo " -f Force overwrite of working files/squashfs image/bootable image"
|
echo " -f Force overwrite of working files/squashfs image/bootable image"
|
||||||
echo " -p PACKAGE(S) Additional package(s) to install, can be used multiple times"
|
echo " -p PACKAGE(S) Additional package(s) to install, can be used multiple times"
|
||||||
echo " -t <iso,disk> Type of image to create. Defaults to iso."
|
|
||||||
echo " -v Enable verbose output."
|
echo " -v Enable verbose output."
|
||||||
echo " -h This message."
|
echo " -h This message."
|
||||||
echo " commands:"
|
echo " commands:"
|
||||||
echo " install <dir> : install packages to the working dir"
|
echo " create <dir>"
|
||||||
echo " squash <dir> <sqfs name> : generate a squashfs image of the working dir"
|
echo " create a base directory layout to work with"
|
||||||
echo " image -p <bootloader> <dir> <image name> : build an image from the working dir"
|
echo " includes all specified packages"
|
||||||
|
echo " iso -p <bootloader> <dir> <image name>"
|
||||||
|
echo " build an iso image from the working dir"
|
||||||
|
echo " usb -p <bootloader> <dir> <image name>"
|
||||||
|
echo " build an iso image from the working dir"
|
||||||
exit $1
|
exit $1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'i:P:p:a:t:fvh' arg; do
|
while getopts 'i:P:p:a:t:fvh' arg; do
|
||||||
case "${arg}" in
|
case "${arg}" in
|
||||||
p) PKGLIST="${PKGLIST} ${OPTARG}" ;;
|
p) PKGLIST="${PKGLIST} ${OPTARG}" ;;
|
||||||
t) IMG_TYPE="${OPTARG}" ;;
|
|
||||||
f) FORCE="y" ;;
|
f) FORCE="y" ;;
|
||||||
v) QUIET="n" ;;
|
v) QUIET="n" ;;
|
||||||
h|?) usage 0 ;;
|
h|?) usage 0 ;;
|
||||||
@ -53,16 +55,15 @@ work_dir=""
|
|||||||
imgname=""
|
imgname=""
|
||||||
|
|
||||||
case "${command_name}" in
|
case "${command_name}" in
|
||||||
install) work_dir="${2}"; imgname="none" ;;
|
create) work_dir="${2}"; imgname="none" ;;
|
||||||
squash) work_dir="${2}"; imgname="${3}" ;;
|
iso) work_dir="${2}"; imgname="${3}" ;;
|
||||||
image) work_dir="${2}"; imgname="${3}" ;;
|
usb) work_dir="${2}"; imgname="${3}" ;;
|
||||||
*) 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}"
|
||||||
@ -88,51 +89,54 @@ _pacman ()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
command_install () {
|
command_create () {
|
||||||
echo "====> Installing packages to '${work_dir}'"
|
echo "====> Creating working directory: ${work_dir}"
|
||||||
if [ -e "${work_dir}" -a "${FORCE}" = "n" ]; then
|
mkdir -p "${work_dir}/iso/"
|
||||||
echo "error: Working dir '${work_dir}' already exists, aborting."
|
mkdir -p "${work_dir}/root-image/"
|
||||||
exit 1
|
echo "# archiso isomounts file
|
||||||
fi
|
# 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
|
||||||
|
|
||||||
mkdir -p "${work_dir}"
|
# syntax: <img> <arch> <mount point> <type>
|
||||||
|
|
||||||
if [ "${PKGLIST}" = "" ]; then
|
root-image.sqfs i686 / squashfs
|
||||||
echo "error: no packages to install"
|
#root-image-x86_64.sqfs x86_64 / squashfs" > "${work_dir}/isomounts"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Installing packages..."
|
echo "README for this archiso created directory
|
||||||
|
|
||||||
|
All directories in this dir, except for 'iso' will be squashed
|
||||||
|
with squashfs and put into the iso dir as iso/<dirname>.sqfs
|
||||||
|
This should be reflected in the isomounts file
|
||||||
|
|
||||||
|
The iso dir is later used to build the actual bootable iso.
|
||||||
|
...TODO..." > "${work_dir}/README"
|
||||||
|
|
||||||
|
if [ "${PKGLIST}" != "" ]; then
|
||||||
|
echo "====> Installing packages to '${work_dir}/root-image/'"
|
||||||
_pacman "${PKGLIST}"
|
_pacman "${PKGLIST}"
|
||||||
|
|
||||||
if [ -d "${work_dir}/lib/modules/" ]; then
|
|
||||||
echo "Updating kernel module dependencies"
|
|
||||||
kernelver=$(_kversion)
|
|
||||||
depmod -a -b "${work_dir}" "${kernelver}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Cleaning up what we can"
|
echo "Cleaning up what we can"
|
||||||
if [ -d "${work_dir}/boot/" ]; then
|
if [ -d "${work_dir}/root-image/boot/" ]; then
|
||||||
# remove the initcpio images that were generated for the host system
|
# remove the initcpio images that were generated for the host system
|
||||||
find "${work_dir}/boot" -name *.img -delete
|
find "${work_dir}/root-image/boot" -name *.img -delete
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#TODO is this needed? do it at the Makefile level?
|
#TODO is this needed? do it at the Makefile level?
|
||||||
if [ -d "${work_dir}/home/" ]; then
|
if [ -d "${work_dir}/root-image/home/" ]; then
|
||||||
echo "Creating default home directory"
|
echo "Creating default home directory"
|
||||||
install -d -o1000 -g100 -m0755 "${work_dir}/home/arch"
|
install -d -o1000 -g100 -m0755 "${work_dir}/root-image/home/arch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# delete a lot of unnecessary cache/log files
|
# delete a lot of unnecessary cache/log files
|
||||||
kill_dirs="var/abs var/cache/man var/cache/pacman var/log/* var/mail tmp/* initrd"
|
kill_dirs="var/abs var/cache/man var/cache/pacman var/lib/pacman/sync var/log/* var/mail tmp/* initrd"
|
||||||
for x in ${kill_dirs}; do
|
for x in ${kill_dirs}; do
|
||||||
if [ -e "${work_dir}/${x}" ]; then
|
if [ -e "${work_dir}/root-image/${x}" ]; then
|
||||||
rm -rf "${work_dir}/${x}"
|
rm -rf "${work_dir}/root-image/${x}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
# pacman DBs are big, delete all sync dbs
|
|
||||||
rm -rf "${work_dir}/var/lib/pacman/sync"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# command_squash path image
|
# command_squash path image
|
||||||
@ -218,25 +222,6 @@ command_image () {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$IMG_TYPE" = "disk" ]; then
|
|
||||||
echo "Creating DISK image..."
|
|
||||||
mkusbimg "${work_dir}" "${imgname}"
|
|
||||||
elif [ "$IMG_TYPE" = "iso" ]; then
|
|
||||||
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}"
|
|
||||||
else
|
|
||||||
echo "Invalid image type '$IMG_TYPE' specified"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# 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}" = "install" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user