Merge branch 'master' of https://github.com/void-linux/void-mklive
This commit is contained in:
commit
1583f1a1ea
@ -10,8 +10,12 @@ This repository contains utilities for Void Linux:
|
|||||||
* mkrootfs (The Void Linux rootfs maker for ARM platforms)
|
* mkrootfs (The Void Linux rootfs maker for ARM platforms)
|
||||||
* mknet (Script to generate netboot tarballs for Void)
|
* mknet (Script to generate netboot tarballs for Void)
|
||||||
|
|
||||||
#### Dependencies
|
#### Build Dependencies
|
||||||
|
* make
|
||||||
|
|
||||||
|
#### Dependencies
|
||||||
|
* Compression type for the initramfs image
|
||||||
|
* liblz4 (for lz4, xz) (default)
|
||||||
* xbps>=0.45
|
* xbps>=0.45
|
||||||
* qemu-user-static binaries (for mkrootfs)
|
* qemu-user-static binaries (for mkrootfs)
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
||||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
||||||
|
|
||||||
# Copy the initramfs back to the new rootfs for proper shutdown.
|
|
||||||
KVER=$(uname -r)
|
|
||||||
if [ -x /usr/bin/systemctl ]; then
|
|
||||||
cp /run/initramfs/live/boot/initrd $NEWROOT/boot/initramfs-${KVER}.img
|
|
||||||
fi
|
|
@ -577,22 +577,22 @@ set_locale() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu_timezone() {
|
menu_timezone() {
|
||||||
local _tzones="$(cd /usr/share/zoneinfo; find Africa/ America/ Antarctica/ Arctic/ Asia/ Atlantic/ Australia/ Europe/ Indian/ Pacific/ posix/ -type f | sort)"
|
local areas=(Africa America Antarctica Arctic Asia Atlantic Australia Europe Indian Pacific)
|
||||||
local _TIMEZONES=
|
|
||||||
|
|
||||||
for f in ${_tzones}; do
|
local area locations location
|
||||||
_TIMEZONES="${_TIMEZONES} ${f} -"
|
while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title " Select area " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do
|
||||||
done
|
area=$(cat $ANSWER)
|
||||||
while true; do
|
read -a locations -d '\n' < <(find /usr/share/zoneinfo/$area -type f -printf '%P\n' | sort)
|
||||||
DIALOG --title " Select your timezone " --menu "$MENULABEL" 14 70 14 ${_TIMEZONES}
|
if (IFS='|'; DIALOG --title " Select location (${area}) " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then
|
||||||
if [ $? -eq 0 ]; then
|
location=$(tr ' ' '_' < $ANSWER)
|
||||||
set_option TIMEZONE "$(cat $ANSWER)"
|
set_option TIMEZONE "$area/$location"
|
||||||
TIMEZONE_DONE=1
|
TIMEZONE_DONE=1
|
||||||
break
|
return 0
|
||||||
else
|
else
|
||||||
return
|
continue
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
set_timezone() {
|
set_timezone() {
|
||||||
@ -1342,7 +1342,7 @@ menu_source() {
|
|||||||
DIALOG --title " Select installation source " \
|
DIALOG --title " Select installation source " \
|
||||||
--menu "$MENULABEL" 8 70 0 \
|
--menu "$MENULABEL" 8 70 0 \
|
||||||
"Local" "Packages from ISO image" \
|
"Local" "Packages from ISO image" \
|
||||||
"Network" "Packages from official remote reposity"
|
"Network" "Base system only, downloaded from official reposity"
|
||||||
case "$(cat $ANSWER)" in
|
case "$(cat $ANSWER)" in
|
||||||
"Local") src="local";;
|
"Local") src="local";;
|
||||||
"Network") src="net";
|
"Network") src="net";
|
||||||
@ -1425,7 +1425,7 @@ menu() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -x /bin/dialog ]; then
|
if ! command -v dialog >/dev/null; then
|
||||||
echo "ERROR: missing dialog command, exiting..."
|
echo "ERROR: missing dialog command, exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
12
lib.sh.in
12
lib.sh.in
@ -173,6 +173,18 @@ register_binfmt() {
|
|||||||
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
|
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
|
||||||
QEMU_BIN=qemu-aarch64-static
|
QEMU_BIN=qemu-aarch64-static
|
||||||
;;
|
;;
|
||||||
|
ppc64le*)
|
||||||
|
_cpu=ppc64le
|
||||||
|
_magic="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00"
|
||||||
|
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00"
|
||||||
|
QEMU_BIN=qemu-ppc64le-static
|
||||||
|
;;
|
||||||
|
ppc64*)
|
||||||
|
_cpu=ppc64
|
||||||
|
_magic="\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15"
|
||||||
|
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
|
||||||
|
QEMU_BIN=qemu-ppc64-static
|
||||||
|
;;
|
||||||
ppc*)
|
ppc*)
|
||||||
_cpu=ppc
|
_cpu=ppc
|
||||||
_magic="\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14"
|
_magic="\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14"
|
||||||
|
16
mklive.sh.in
16
mklive.sh.in
@ -155,13 +155,8 @@ generate_initramfs() {
|
|||||||
|
|
||||||
copy_dracut_files "$ROOTFS"
|
copy_dracut_files "$ROOTFS"
|
||||||
copy_autoinstaller_files "$ROOTFS"
|
copy_autoinstaller_files "$ROOTFS"
|
||||||
if [ "$BASE_SYSTEM_PKG" = "base-system-systemd" ]; then
|
|
||||||
_args="--add systemd"
|
|
||||||
else
|
|
||||||
_args="--omit systemd"
|
|
||||||
fi
|
|
||||||
chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \
|
chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \
|
||||||
--add-drivers "ahci" --force-add "vmklive autoinstaller" ${_args} "/boot/initrd" $KERNELVERSION
|
--add-drivers "ahci" --force-add "vmklive autoinstaller" --omit systemd "/boot/initrd" $KERNELVERSION
|
||||||
[ $? -ne 0 ] && die "Failed to generate the initramfs"
|
[ $? -ne 0 ] && die "Failed to generate the initramfs"
|
||||||
|
|
||||||
mv "$ROOTFS"/boot/initrd "$BOOT_DIR"
|
mv "$ROOTFS"/boot/initrd "$BOOT_DIR"
|
||||||
@ -287,7 +282,7 @@ generate_iso_image() {
|
|||||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||||
-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
|
-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
|
||||||
-isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin \
|
-isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin \
|
||||||
-output "$CURDIR/$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image"
|
-output "$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -340,9 +335,6 @@ if [ "$(id -u)" -ne 0 ]; then
|
|||||||
die "Must be run as root, exiting..."
|
die "Must be run as root, exiting..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly CURDIR="$PWD"
|
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$ROOTDIR" ]; then
|
if [ -n "$ROOTDIR" ]; then
|
||||||
BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d)
|
BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d)
|
||||||
else
|
else
|
||||||
@ -417,7 +409,7 @@ generate_squashfs
|
|||||||
print_step "Generating ISO image..."
|
print_step "Generating ISO image..."
|
||||||
generate_iso_image
|
generate_iso_image
|
||||||
|
|
||||||
hsize=$(du -sh "$CURDIR/$OUTPUT_FILE"|awk '{print $1}')
|
hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}')
|
||||||
info_msg "Created $(readlink -f "$CURDIR"/"$OUTPUT_FILE") ($hsize) successfully."
|
info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully."
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ Options
|
|||||||
-C <file> Full path to the XBPS configuration file
|
-C <file> Full path to the XBPS configuration file
|
||||||
-r <repo> Set XBPS repository (may be set multiple times)
|
-r <repo> Set XBPS repository (may be set multiple times)
|
||||||
-x <num> Use <num> threads to compress the image (dynamic if unset)
|
-x <num> Use <num> threads to compress the image (dynamic if unset)
|
||||||
|
-n Do not compress the image, instead print out the rootfs directory
|
||||||
-h Show this help
|
-h Show this help
|
||||||
-V Show version
|
-V Show version
|
||||||
_EOF
|
_EOF
|
||||||
@ -71,8 +72,9 @@ _EOF
|
|||||||
# ########################################
|
# ########################################
|
||||||
|
|
||||||
BASEPKG=base-system
|
BASEPKG=base-system
|
||||||
|
COMPRESSION="y"
|
||||||
|
|
||||||
while getopts "b:p:k:c:C:r:x:hV" opt; do
|
while getopts "b:p:k:c:C:r:x:nhV" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
b) BASEPKG="$OPTARG" ;;
|
b) BASEPKG="$OPTARG" ;;
|
||||||
p) EXTRA_PKGS="$OPTARG" ;;
|
p) EXTRA_PKGS="$OPTARG" ;;
|
||||||
@ -81,6 +83,7 @@ while getopts "b:p:k:c:C:r:x:hV" opt; do
|
|||||||
C) XBPS_CONFFILE="-C $OPTARG" ;;
|
C) XBPS_CONFFILE="-C $OPTARG" ;;
|
||||||
r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG" ;;
|
r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG" ;;
|
||||||
x) COMPRESSOR_THREADS="$OPTARG" ;;
|
x) COMPRESSOR_THREADS="$OPTARG" ;;
|
||||||
|
n) COMPRESSION="n" ;;
|
||||||
h) usage; exit 0 ;;
|
h) usage; exit 0 ;;
|
||||||
V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;;
|
V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
@ -143,6 +146,10 @@ ROOTFS=$(mktemp -d) || die "failed to create tempdir, exiting..."
|
|||||||
|
|
||||||
# Now that we have a directory for the ROOTFS, we can expand the
|
# Now that we have a directory for the ROOTFS, we can expand the
|
||||||
# existing base filesystem into the directory
|
# existing base filesystem into the directory
|
||||||
|
if [ ! -e "$BASE_TARBALL" ]; then
|
||||||
|
die "no valid base tarball given, exiting."
|
||||||
|
fi
|
||||||
|
|
||||||
info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build."
|
info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build."
|
||||||
tar xf "$BASE_TARBALL" -C "$ROOTFS"
|
tar xf "$BASE_TARBALL" -C "$ROOTFS"
|
||||||
|
|
||||||
@ -203,17 +210,31 @@ cleanup_chroot
|
|||||||
# only for it to be out of date, we remove it now.
|
# only for it to be out of date, we remove it now.
|
||||||
rm -rf "$ROOTFS/var/cache/*" 2>/dev/null
|
rm -rf "$ROOTFS/var/cache/*" 2>/dev/null
|
||||||
|
|
||||||
# Finally we can compress the tarball, the name will include the
|
# Now we can run the POST_CMD script. This user-supplied script gets the
|
||||||
# platform and the date on which the tarball was built.
|
# $ROOTFS as a parameter.
|
||||||
tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz
|
if [ -n "$POST_CMD" ]; then
|
||||||
run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball "
|
info_msg "Running user supllied command: $POST_CMD"
|
||||||
|
run_cmd $POST_CMD $ROOTFS
|
||||||
|
fi
|
||||||
|
|
||||||
# Now that we have the tarball we don't need the rootfs anymore, so we
|
|
||||||
# can get rid of it.
|
|
||||||
rm -rf "$ROOTFS"
|
|
||||||
|
|
||||||
# Last thing to do before closing out is to let the user know that
|
# Compress the tarball or just print out the path?
|
||||||
# this succeeded. This also ensures that there's something visible
|
if [ "$COMPRESSION" = "y" ]; then
|
||||||
# that the user can look for at the end of the script, which can make
|
# Finally we can compress the tarball, the name will include the
|
||||||
# it easier to see what's going on if something above failed.
|
# platform and the date on which the tarball was built.
|
||||||
info_msg "Successfully created $tarball ($PLATFORM)"
|
tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz
|
||||||
|
run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball "
|
||||||
|
|
||||||
|
# Now that we have the tarball we don't need the rootfs anymore, so we
|
||||||
|
# can get rid of it.
|
||||||
|
rm -rf "$ROOTFS"
|
||||||
|
|
||||||
|
# Last thing to do before closing out is to let the user know that
|
||||||
|
# this succeeded. This also ensures that there's something visible
|
||||||
|
# that the user can look for at the end of the script, which can make
|
||||||
|
# it easier to see what's going on if something above failed.
|
||||||
|
info_msg "Successfully created $tarball ($PLATFORM)"
|
||||||
|
else
|
||||||
|
# User requested just printing out the path to the rootfs, here it comes.
|
||||||
|
info_msg "Successfully created rootfs under $ROOTFS"
|
||||||
|
fi
|
||||||
|
@ -53,11 +53,12 @@ Supported architectures: i686, i686-musl, x86_64, x86_64-musl,
|
|||||||
armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl
|
armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl
|
||||||
aarch64, aarch64-musl,
|
aarch64, aarch64-musl,
|
||||||
mipsel, mipsel-musl
|
mipsel, mipsel-musl
|
||||||
ppc
|
ppc, ppc-musl
|
||||||
|
ppc64le, ppc64le-musl, ppc64, ppc64-musl
|
||||||
|
|
||||||
|
|
||||||
Options
|
Options
|
||||||
-b <syspkg> Set an alternative base-system package (defaults to base-system)
|
-b <syspkg> Set an alternative base-system package (defaults to base-voidstrap)
|
||||||
-c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>)
|
-c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>)
|
||||||
-C <file> Full path to the XBPS configuration file
|
-C <file> Full path to the XBPS configuration file
|
||||||
-h Show this help
|
-h Show this help
|
||||||
@ -72,10 +73,14 @@ _EOF
|
|||||||
# SCRIPT EXECUTION STARTS HERE
|
# SCRIPT EXECUTION STARTS HERE
|
||||||
# ########################################
|
# ########################################
|
||||||
|
|
||||||
|
# Set the default system package.
|
||||||
|
SYSPKG="base-voidstrap"
|
||||||
|
|
||||||
# Boilerplate option parsing. This script supports the bare minimum
|
# Boilerplate option parsing. This script supports the bare minimum
|
||||||
# needed to build an image.
|
# needed to build an image.
|
||||||
while getopts "C:c:hr:x:o:V" opt; do
|
while getopts "b:C:c:hr:x:o:V" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
|
b) SYSPKG="$OPTARG";;
|
||||||
C) XBPS_CONFFILE="-C $OPTARG";;
|
C) XBPS_CONFFILE="-C $OPTARG";;
|
||||||
c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
|
c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
|
||||||
h) usage; exit 0;;
|
h) usage; exit 0;;
|
||||||
@ -136,10 +141,10 @@ chmod 755 "$ROOTFS"
|
|||||||
mount_pseudofs
|
mount_pseudofs
|
||||||
|
|
||||||
# With everything setup, we can now run the install to load the
|
# With everything setup, we can now run the install to load the
|
||||||
# base-voidstrap package into the rootfs. This will not produce a
|
# system package into the rootfs. This will not produce a
|
||||||
# bootable system but will instead produce a base component that can
|
# bootable system but will instead produce a base component that can
|
||||||
# be quickly expanded to perform other actions on.
|
# be quickly expanded to perform other actions on.
|
||||||
run_cmd_target "xbps-install -S $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -y base-voidstrap"
|
run_cmd_target "xbps-install -S $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -y $SYSPKG"
|
||||||
|
|
||||||
# Enable en_US.UTF-8 locale and generate it into the target ROOTFS.
|
# Enable en_US.UTF-8 locale and generate it into the target ROOTFS.
|
||||||
# This is a bit of a hack since some glibc stuff doesn't really work
|
# This is a bit of a hack since some glibc stuff doesn't really work
|
||||||
|
Loading…
x
Reference in New Issue
Block a user