mklive.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. #!/bin/bash
  2. #
  3. #-
  4. # Copyright (c) 2009-2015 Juan Romero Pardines.
  5. # All rights reserved.
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. # 1. Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. # 2. Redistributions in binary form must reproduce the above copyright
  13. # notice, this list of conditions and the following disclaimer in the
  14. # documentation and/or other materials provided with the distribution.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. #-
  27. trap 'error_out $? $LINENO' INT TERM 0
  28. umask 022
  29. . ./lib.sh
  30. readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-i386-efi grub-x86_64-efi memtest86+ squashfs-tools xorriso"
  31. readonly INITRAMFS_PKGS="binutils xz device-mapper dhclient dracut-network openresolv"
  32. readonly PROGNAME=$(basename "$0")
  33. declare -a INCLUDE_DIRS=()
  34. info_msg() {
  35. printf "\033[1m$@\n\033[m"
  36. }
  37. die() {
  38. info_msg "ERROR: $@"
  39. error_out 1 $LINENO
  40. }
  41. print_step() {
  42. CURRENT_STEP=$((CURRENT_STEP+1))
  43. info_msg "[${CURRENT_STEP}/${STEP_COUNT}] $@"
  44. }
  45. mount_pseudofs() {
  46. for f in sys dev proc; do
  47. mkdir -p "$ROOTFS"/$f
  48. mount --rbind /$f "$ROOTFS"/$f
  49. done
  50. }
  51. umount_pseudofs() {
  52. umount -R -f "$ROOTFS"/sys >/dev/null 2>&1
  53. umount -R -f "$ROOTFS"/dev >/dev/null 2>&1
  54. umount -R -f "$ROOTFS"/proc >/dev/null 2>&1
  55. }
  56. error_out() {
  57. umount_pseudofs
  58. [ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR"
  59. exit "${1:=0}"
  60. }
  61. usage() {
  62. cat <<-EOH
  63. Usage: $PROGNAME [options]
  64. Generates a basic live ISO image of Void Linux. This ISO image can be written
  65. to a CD/DVD-ROM or any USB stick.
  66. To generate a more complete live ISO image, use build-x86-images.sh.
  67. OPTIONS
  68. -a <arch> Set XBPS_ARCH in the ISO image
  69. -b <system-pkg> Set an alternative base package (default: base-system)
  70. -r <repo> Use this XBPS repository. May be specified multiple times
  71. -c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)
  72. -k <keymap> Default keymap to use (default: us)
  73. -l <locale> Default locale to use (default: en_US.UTF-8)
  74. -i <lz4|gzip|bzip2|xz>
  75. Compression type for the initramfs image (default: xz)
  76. -s <gzip|lzo|xz> Compression type for the squashfs image (default: xz)
  77. -o <file> Output file name for the ISO image (default: automatic)
  78. -p "<pkg> ..." Install additional packages in the ISO image
  79. -g "<pkg> ..." Ignore packages when building the ISO image
  80. -I <includedir> Include directory structure under given path in the ROOTFS
  81. -S "<service> ..." Enable services in the ISO image
  82. -C "<arg> ..." Add additional kernel command line arguments
  83. -T <title> Modify the bootloader title (default: Void Linux)
  84. -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage)
  85. -K Do not remove builddir
  86. -h Show this help and exit
  87. -V Show version and exit
  88. EOH
  89. }
  90. copy_void_keys() {
  91. mkdir -p "$1"/var/db/xbps/keys
  92. cp keys/*.plist "$1"/var/db/xbps/keys
  93. }
  94. copy_dracut_files() {
  95. mkdir -p "$1"/usr/lib/dracut/modules.d/01vmklive
  96. cp dracut/vmklive/* "$1"/usr/lib/dracut/modules.d/01vmklive/
  97. }
  98. copy_autoinstaller_files() {
  99. mkdir -p "$1"/usr/lib/dracut/modules.d/01autoinstaller
  100. cp dracut/autoinstaller/* "$1"/usr/lib/dracut/modules.d/01autoinstaller/
  101. }
  102. install_prereqs() {
  103. XBPS_ARCH=$ARCH "$XBPS_INSTALL_CMD" -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} \
  104. -c "$XBPS_HOST_CACHEDIR" -y $REQUIRED_PKGS
  105. [ $? -ne 0 ] && die "Failed to install required software, exiting..."
  106. }
  107. install_packages() {
  108. XBPS_ARCH=$BASE_ARCH "${XBPS_INSTALL_CMD}" -r "$ROOTFS" \
  109. ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -yn $PACKAGE_LIST $INITRAMFS_PKGS
  110. [ $? -ne 0 ] && die "Missing required binary packages, exiting..."
  111. mount_pseudofs
  112. LANG=C XBPS_ARCH=$BASE_ARCH "${XBPS_INSTALL_CMD}" -U -r "$ROOTFS" \
  113. ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -y $PACKAGE_LIST $INITRAMFS_PKGS
  114. [ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST"
  115. xbps-reconfigure -r "$ROOTFS" -f base-files >/dev/null 2>&1
  116. chroot "$ROOTFS" env -i xbps-reconfigure -f base-files
  117. # Enable choosen UTF-8 locale and generate it into the target rootfs.
  118. if [ -f "$ROOTFS"/etc/default/libc-locales ]; then
  119. sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i "$ROOTFS"/etc/default/libc-locales
  120. fi
  121. chroot "$ROOTFS" env -i xbps-reconfigure -a
  122. # Cleanup and remove useless stuff.
  123. rm -rf "$ROOTFS"/var/cache/* "$ROOTFS"/run/* "$ROOTFS"/var/run/*
  124. }
  125. ignore_packages() {
  126. mkdir -p "$ROOTFS"/etc/xbps.d
  127. for pkg in $IGNORE_PKGS; do
  128. echo "ignorepkg=$pkg" >> "$ROOTFS"/etc/xbps.d/mklive-ignore.conf
  129. done
  130. }
  131. enable_services() {
  132. SERVICE_LIST="$*"
  133. for service in $SERVICE_LIST; do
  134. if ! [ -e $ROOTFS/etc/sv/$service ]; then
  135. die "service $service not in /etc/sv"
  136. fi
  137. ln -sf /etc/sv/$service $ROOTFS/etc/runit/runsvdir/default/
  138. done
  139. }
  140. copy_include_directories() {
  141. for includedir in "${INCLUDE_DIRS[@]}"; do
  142. info_msg "=> copying include directory '$includedir' ..."
  143. find "$includedir" -mindepth 1 -maxdepth 1 -exec cp -rfpPv {} "$ROOTFS"/ \;
  144. done
  145. }
  146. generate_initramfs() {
  147. local _args
  148. copy_dracut_files "$ROOTFS"
  149. copy_autoinstaller_files "$ROOTFS"
  150. chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \
  151. --add-drivers "ahci" --force-add "vmklive autoinstaller" --omit systemd "/boot/initrd" $KERNELVERSION
  152. [ $? -ne 0 ] && die "Failed to generate the initramfs"
  153. mv "$ROOTFS"/boot/initrd "$BOOT_DIR"
  154. cp "$ROOTFS"/boot/vmlinuz-$KERNELVERSION "$BOOT_DIR"/vmlinuz
  155. }
  156. cleanup_rootfs() {
  157. for f in ${INITRAMFS_PKGS}; do
  158. revdeps=$(xbps-query -r "$ROOTFS" -X $f)
  159. if [ -n "$revdeps" ]; then
  160. xbps-pkgdb -r "$ROOTFS" -m auto $f
  161. else
  162. xbps-remove -r "$ROOTFS" -Ry ${f} >/dev/null 2>&1
  163. fi
  164. done
  165. rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01vmklive
  166. rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01autoinstaller
  167. }
  168. generate_isolinux_boot() {
  169. cp -f "$SYSLINUX_DATADIR"/isolinux.bin "$ISOLINUX_DIR"
  170. cp -f "$SYSLINUX_DATADIR"/ldlinux.c32 "$ISOLINUX_DIR"
  171. cp -f "$SYSLINUX_DATADIR"/libcom32.c32 "$ISOLINUX_DIR"
  172. cp -f "$SYSLINUX_DATADIR"/vesamenu.c32 "$ISOLINUX_DIR"
  173. cp -f "$SYSLINUX_DATADIR"/libutil.c32 "$ISOLINUX_DIR"
  174. cp -f "$SYSLINUX_DATADIR"/chain.c32 "$ISOLINUX_DIR"
  175. cp -f "$SYSLINUX_DATADIR"/reboot.c32 "$ISOLINUX_DIR"
  176. cp -f "$SYSLINUX_DATADIR"/poweroff.c32 "$ISOLINUX_DIR"
  177. cp -f isolinux/isolinux.cfg.in "$ISOLINUX_DIR"/isolinux.cfg
  178. cp -f ${SPLASH_IMAGE} "$ISOLINUX_DIR"
  179. sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \
  180. -e "s|@@KERNVER@@|${KERNELVERSION}|" \
  181. -e "s|@@KEYMAP@@|${KEYMAP}|" \
  182. -e "s|@@ARCH@@|$BASE_ARCH|" \
  183. -e "s|@@LOCALE@@|${LOCALE}|" \
  184. -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
  185. -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
  186. "$ISOLINUX_DIR"/isolinux.cfg
  187. # include memtest86+
  188. cp -f "$VOIDHOSTDIR"/boot/memtest.bin "$BOOT_DIR"
  189. }
  190. generate_grub_efi_boot() {
  191. cp -f grub/grub.cfg "$GRUB_DIR"
  192. cp -f grub/grub_void.cfg.in "$GRUB_DIR"/grub_void.cfg
  193. sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \
  194. -e "s|@@KERNVER@@|${KERNELVERSION}|" \
  195. -e "s|@@KEYMAP@@|${KEYMAP}|" \
  196. -e "s|@@ARCH@@|$BASE_ARCH|" \
  197. -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
  198. -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
  199. -e "s|@@LOCALE@@|${LOCALE}|" "$GRUB_DIR"/grub_void.cfg
  200. mkdir -p "$GRUB_DIR"/fonts
  201. cp -f "$GRUB_DATADIR"/unicode.pf2 "$GRUB_DIR"/fonts
  202. modprobe -q loop || :
  203. # Create EFI vfat image.
  204. truncate -s 32M "$GRUB_DIR"/efiboot.img >/dev/null 2>&1
  205. mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1
  206. GRUB_EFI_TMPDIR="$(mktemp --tmpdir="$HOME" -d)"
  207. LOOP_DEVICE="$(losetup --show --find "${GRUB_DIR}"/efiboot.img)"
  208. mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1
  209. cp -a "$IMAGEDIR"/boot "$VOIDHOSTDIR"
  210. xbps-uchroot "$VOIDHOSTDIR" grub-mkstandalone -- \
  211. --directory="/usr/lib/grub/i386-efi" \
  212. --format="i386-efi" \
  213. --output="/tmp/bootia32.efi" \
  214. "boot/grub/grub.cfg"
  215. if [ $? -ne 0 ]; then
  216. umount "$GRUB_EFI_TMPDIR"
  217. losetup --detach "${LOOP_DEVICE}"
  218. die "Failed to generate EFI loader"
  219. fi
  220. mkdir -p "${GRUB_EFI_TMPDIR}"/EFI/BOOT
  221. cp -f "$VOIDHOSTDIR"/tmp/bootia32.efi "${GRUB_EFI_TMPDIR}"/EFI/BOOT/BOOTIA32.EFI
  222. xbps-uchroot "$VOIDHOSTDIR" grub-mkstandalone -- \
  223. --directory="/usr/lib/grub/x86_64-efi" \
  224. --format="x86_64-efi" \
  225. --output="/tmp/bootx64.efi" \
  226. "boot/grub/grub.cfg"
  227. if [ $? -ne 0 ]; then
  228. umount "$GRUB_EFI_TMPDIR"
  229. losetup --detach "${LOOP_DEVICE}"
  230. die "Failed to generate EFI loader"
  231. fi
  232. cp -f "$VOIDHOSTDIR"/tmp/bootx64.efi "${GRUB_EFI_TMPDIR}"/EFI/BOOT/BOOTX64.EFI
  233. umount "$GRUB_EFI_TMPDIR"
  234. losetup --detach "${LOOP_DEVICE}"
  235. rm -rf "$GRUB_EFI_TMPDIR"
  236. # include memtest86+
  237. cp -f "$VOIDHOSTDIR"/boot/memtest.efi "$BOOT_DIR"
  238. }
  239. generate_squashfs() {
  240. umount_pseudofs
  241. # Find out required size for the rootfs and create an ext3fs image off it.
  242. ROOTFS_SIZE=$(du --apparent-size -sm "$ROOTFS"|awk '{print $1}')
  243. mkdir -p "$BUILDDIR/tmp/LiveOS"
  244. truncate -s "$((ROOTFS_SIZE+ROOTFS_SIZE))M" \
  245. "$BUILDDIR"/tmp/LiveOS/ext3fs.img >/dev/null 2>&1
  246. mkdir -p "$BUILDDIR/tmp-rootfs"
  247. mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" >/dev/null 2>&1
  248. mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" "$BUILDDIR/tmp-rootfs"
  249. cp -a "$ROOTFS"/* "$BUILDDIR"/tmp-rootfs/
  250. umount -f "$BUILDDIR/tmp-rootfs"
  251. mkdir -p "$IMAGEDIR/LiveOS"
  252. "$VOIDHOSTDIR"/usr/bin/mksquashfs "$BUILDDIR/tmp" "$IMAGEDIR/LiveOS/squashfs.img" \
  253. -comp "${SQUASHFS_COMPRESSION}" || die "Failed to generate squashfs image"
  254. chmod 444 "$IMAGEDIR/LiveOS/squashfs.img"
  255. # Remove rootfs and temporary dirs, we don't need them anymore.
  256. rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp"
  257. }
  258. generate_iso_image() {
  259. "$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs \
  260. -iso-level 3 -rock -joliet \
  261. -max-iso9660-filenames -omit-period \
  262. -omit-version-number -relaxed-filenames -allow-lowercase \
  263. -volid "VOID_LIVE" \
  264. -eltorito-boot boot/isolinux/isolinux.bin \
  265. -eltorito-catalog boot/isolinux/boot.cat \
  266. -no-emul-boot -boot-load-size 4 -boot-info-table \
  267. -eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
  268. -isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin \
  269. -output "$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image"
  270. }
  271. #
  272. # main()
  273. #
  274. while getopts "a:b:r:c:C:T:Kk:l:i:I:S:s:o:p:g:v:Vh" opt; do
  275. case $opt in
  276. a) BASE_ARCH="$OPTARG";;
  277. b) BASE_SYSTEM_PKG="$OPTARG";;
  278. r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
  279. c) XBPS_CACHEDIR="$OPTARG";;
  280. g) IGNORE_PKGS="$IGNORE_PKGS $OPTARG" ;;
  281. K) readonly KEEP_BUILDDIR=1;;
  282. k) KEYMAP="$OPTARG";;
  283. l) LOCALE="$OPTARG";;
  284. i) INITRAMFS_COMPRESSION="$OPTARG";;
  285. I) INCLUDE_DIRS+=("$OPTARG");;
  286. S) SERVICE_LIST="$SERVICE_LIST $OPTARG";;
  287. s) SQUASHFS_COMPRESSION="$OPTARG";;
  288. o) OUTPUT_FILE="$OPTARG";;
  289. p) PACKAGE_LIST="$PACKAGE_LIST $OPTARG";;
  290. C) BOOT_CMDLINE="$OPTARG";;
  291. T) BOOT_TITLE="$OPTARG";;
  292. v) LINUX_VERSION="$OPTARG";;
  293. V) version; exit 0;;
  294. h) usage; exit 0;;
  295. *) usage >&2; exit 1;;
  296. esac
  297. done
  298. shift $((OPTIND - 1))
  299. XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=https://repo-default.voidlinux.org/current --repository=https://repo-default.voidlinux.org/current/musl"
  300. # Configure dracut to use overlayfs for the writable overlay.
  301. BOOT_CMDLINE="$BOOT_CMDLINE rd.live.overlay.overlayfs=1 "
  302. ARCH=$(xbps-uhelper arch)
  303. # Set defaults
  304. : ${BASE_ARCH:=$(xbps-uhelper arch 2>/dev/null || uname -m)}
  305. : ${XBPS_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${BASE_ARCH}}
  306. : ${XBPS_HOST_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${ARCH}}
  307. : ${KEYMAP:=us}
  308. : ${LOCALE:=en_US.UTF-8}
  309. : ${INITRAMFS_COMPRESSION:=xz}
  310. : ${SQUASHFS_COMPRESSION:=xz}
  311. : ${BASE_SYSTEM_PKG:=base-system}
  312. : ${BOOT_TITLE:="Void Linux"}
  313. case $BASE_ARCH in
  314. x86_64*|i686*) ;;
  315. *) >&2 echo architecture $BASE_ARCH not supported by mklive.sh; exit 1;;
  316. esac
  317. # Required packages in the image for a working system.
  318. PACKAGE_LIST="$BASE_SYSTEM_PKG $PACKAGE_LIST"
  319. # Check for root permissions.
  320. if [ "$(id -u)" -ne 0 ]; then
  321. die "Must be run as root, exiting..."
  322. fi
  323. if [ -n "$ROOTDIR" ]; then
  324. BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d)
  325. else
  326. BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -d)
  327. fi
  328. BUILDDIR=$(readlink -f "$BUILDDIR")
  329. IMAGEDIR="$BUILDDIR/image"
  330. ROOTFS="$IMAGEDIR/rootfs"
  331. VOIDHOSTDIR="$BUILDDIR/void-host"
  332. BOOT_DIR="$IMAGEDIR/boot"
  333. ISOLINUX_DIR="$BOOT_DIR/isolinux"
  334. GRUB_DIR="$BOOT_DIR/grub"
  335. CURRENT_STEP=0
  336. STEP_COUNT=10
  337. [ "${#INCLUDE_DIRS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1))
  338. [ -n "${IGNORE_PKGS}" ] && STEP_COUNT=$((STEP_COUNT+1))
  339. : ${SYSLINUX_DATADIR:="$VOIDHOSTDIR"/usr/lib/syslinux}
  340. : ${GRUB_DATADIR:="$VOIDHOSTDIR"/usr/share/grub}
  341. : ${SPLASH_IMAGE:=data/splash.png}
  342. : ${XBPS_INSTALL_CMD:=xbps-install}
  343. : ${XBPS_REMOVE_CMD:=xbps-remove}
  344. : ${XBPS_QUERY_CMD:=xbps-query}
  345. : ${XBPS_RINDEX_CMD:=xbps-rindex}
  346. : ${XBPS_UHELPER_CMD:=xbps-uhelper}
  347. : ${XBPS_RECONFIGURE_CMD:=xbps-reconfigure}
  348. mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$ISOLINUX_DIR" "$GRUB_DIR"
  349. print_step "Synchronizing XBPS repository data..."
  350. copy_void_keys "$ROOTFS"
  351. copy_void_keys "$VOIDHOSTDIR"
  352. XBPS_ARCH=$BASE_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -S
  353. XBPS_ARCH=$ARCH $XBPS_INSTALL_CMD -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} -S
  354. # Get linux version for ISO
  355. # If linux version option specified use
  356. if [ -n "$LINUX_VERSION" ]; then
  357. if ! echo "$LINUX_VERSION" | grep "linux[0-9._]\+"; then
  358. die "-v option must be in format linux<version>"
  359. fi
  360. _linux_series="$LINUX_VERSION"
  361. PACKAGE_LIST="$PACKAGE_LIST $LINUX_VERSION"
  362. else # Otherwise find latest stable version from linux meta-package
  363. _linux_series=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x linux | grep 'linux[0-9._]\+')
  364. fi
  365. _kver=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -p pkgver ${_linux_series})
  366. KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion ${_kver})
  367. if [ "$?" -ne "0" ]; then
  368. die "Failed to find kernel package version"
  369. fi
  370. : ${OUTPUT_FILE="void-live-${BASE_ARCH}-${KERNELVERSION}-$(date -u +%Y%m%d).iso"}
  371. print_step "Installing software to generate the image: ${REQUIRED_PKGS} ..."
  372. install_prereqs
  373. mkdir -p "$ROOTFS"/etc
  374. [ -s data/motd ] && cp data/motd "$ROOTFS"/etc
  375. [ -s data/issue ] && cp data/issue "$ROOTFS"/etc
  376. if [ -n "$IGNORE_PKGS" ]; then
  377. print_step "Ignoring packages in the rootfs: ${IGNORE_PKGS} ..."
  378. ignore_packages
  379. fi
  380. print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST} ..."
  381. install_packages
  382. : ${DEFAULT_SERVICE_LIST:=agetty-tty1 agetty-tty2 agetty-tty3 agetty-tty4 agetty-tty5 agetty-tty6 udevd}
  383. print_step "Enabling services: ${SERVICE_LIST} ..."
  384. enable_services ${DEFAULT_SERVICE_LIST} ${SERVICE_LIST}
  385. if [ "${#INCLUDE_DIRS[@]}" -gt 0 ];then
  386. print_step "Copying directory structures into the rootfs ..."
  387. copy_include_directories
  388. fi
  389. print_step "Generating initramfs image ($INITRAMFS_COMPRESSION)..."
  390. generate_initramfs
  391. print_step "Generating isolinux support for PC-BIOS systems..."
  392. generate_isolinux_boot
  393. print_step "Generating GRUB support for EFI systems..."
  394. generate_grub_efi_boot
  395. print_step "Cleaning up rootfs..."
  396. cleanup_rootfs
  397. print_step "Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..."
  398. generate_squashfs
  399. print_step "Generating ISO image..."
  400. generate_iso_image
  401. hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}')
  402. info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully."