aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--defaults/busy-config9
-rw-r--r--defaults/config.sh7
-rw-r--r--defaults/initrd.defaults16
-rw-r--r--defaults/initrd.scripts904
l---------defaults/keymaps/10.map2
l---------defaults/keymaps/11.map2
l---------defaults/keymaps/12.map2
l---------defaults/keymaps/13.map2
l---------defaults/keymaps/14.map2
l---------defaults/keymaps/15.map2
l---------defaults/keymaps/16.map2
l---------defaults/keymaps/17.map2
l---------defaults/keymaps/18.map2
l---------defaults/keymaps/19.map2
l---------defaults/keymaps/20.map2
l---------defaults/keymaps/21.map2
l---------defaults/keymaps/22.map2
l---------defaults/keymaps/23.map2
l---------defaults/keymaps/24.map2
l---------defaults/keymaps/25.map2
l---------defaults/keymaps/26.map2
l---------defaults/keymaps/27.map2
l---------defaults/keymaps/28.map2
l---------defaults/keymaps/29.map2
l---------defaults/keymaps/3.map2
l---------defaults/keymaps/30.map2
l---------defaults/keymaps/31.map2
l---------defaults/keymaps/32.map2
l---------defaults/keymaps/33.map2
l---------defaults/keymaps/34.map2
l---------defaults/keymaps/35.map2
l---------defaults/keymaps/36.map2
l---------defaults/keymaps/37.map2
l---------defaults/keymaps/38.map1
l---------defaults/keymaps/39.map2
l---------defaults/keymaps/4.map2
l---------defaults/keymaps/40.map2
l---------defaults/keymaps/41.map2
l---------defaults/keymaps/42.map2
l---------defaults/keymaps/43.map2
l---------defaults/keymaps/44.map1
l---------defaults/keymaps/5.map2
l---------defaults/keymaps/6.map2
l---------defaults/keymaps/7.map2
l---------defaults/keymaps/8.map2
l---------defaults/keymaps/9.map2
-rw-r--r--defaults/keymaps/bepo.mapbin0 -> 2823 bytes
-rw-r--r--defaults/keymaps/colemak.mapbin0 -> 2823 bytes
-rw-r--r--defaults/keymaps/keymapList16
-rw-r--r--defaults/linuxrc199
-rw-r--r--defaults/login-remote.sh81
-rw-r--r--defaults/resume-boot.sh25
-rw-r--r--defaults/software.sh28
-rw-r--r--defaults/unlock-luks.sh44
-rw-r--r--doc/genkernel.8.txt221
-rwxr-xr-xgen_bootloader.sh12
-rwxr-xr-xgen_cmdline.sh105
-rwxr-xr-xgen_compile.sh52
-rwxr-xr-xgen_configkernel.sh101
-rwxr-xr-xgen_determineargs.sh509
-rwxr-xr-xgen_funcs.sh510
-rwxr-xr-xgen_initramfs.sh392
-rwxr-xr-xgen_package.sh120
-rwxr-xr-xgenkernel216
-rw-r--r--genkernel.conf35
-rw-r--r--gkbuilds/boost-build.gkbuild64
-rw-r--r--gkbuilds/boost.gkbuild80
-rw-r--r--gkbuilds/expat.gkbuild19
-rw-r--r--gkbuilds/lvm.gkbuild7
-rw-r--r--gkbuilds/thin-provisioning-tools.gkbuild33
-rw-r--r--gkbuilds/xfsprogs.gkbuild1
-rw-r--r--patches/boost-build/1.71.0/boost-build-1.48.0-disable_python_rpath.patch11
-rw-r--r--patches/boost-build/1.71.0/boost-build-1.62.0-sparc-no-default-flags.patch47
-rw-r--r--patches/boost-build/1.71.0/boost-build-1.66.0-add-none-feature-options.patch26
-rw-r--r--patches/boost-build/1.71.0/boost-build-1.71.0-respect-c_ld-flags.patch9
-rw-r--r--patches/boost/1.71.0/boost-1.69.0-context-x32.patch38
-rw-r--r--patches/btrfs-progs/5.2.2/btrfs-lzo2.patch (renamed from patches/btrfs-progs/5.1.1/btrfs-lzo2.patch)0
-rw-r--r--patches/btrfs-progs/5.2.2/btrfs-m4.patch (renamed from patches/btrfs-progs/5.1.1/btrfs-m4.patch)0
-rw-r--r--patches/busybox/1.31.0/busybox-1.26.0-mdstart.patch80
-rw-r--r--patches/libgcrypt/1.8.5/libgcrypt-1.8.4-ac_cv_sys_symbol_underscore.patch (renamed from patches/libgcrypt/1.8.4/libgcrypt-1.8.4-ac_cv_sys_symbol_underscore.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-001-example.conf.in.patch (renamed from patches/lvm/2.02.185/lvm2-001-example.conf.in.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-002-always-make-static-libdm.patch (renamed from patches/lvm/2.02.185/lvm2-002-always-make-static-libdm.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-003-lvm2create_initrd.patch (renamed from patches/lvm/2.02.185/lvm2-003-lvm2create_initrd.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-004-createinitrd.patch (renamed from patches/lvm/2.02.185/lvm2-004-createinitrd.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-005-locale-muck.patch (renamed from patches/lvm/2.02.185/lvm2-005-locale-muck.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-006-asneeded.patch (renamed from patches/lvm/2.02.185/lvm2-006-asneeded.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-007-dynamic-static-ldflags.patch (renamed from patches/lvm/2.02.185/lvm2-007-dynamic-static-ldflags.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-008-static-pkgconfig-libs.patch (renamed from patches/lvm/2.02.185/lvm2-008-static-pkgconfig-libs.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-009-pthread-pkgconfig.patch (renamed from patches/lvm/2.02.185/lvm2-009-pthread-pkgconfig.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-010-static-libm.patch (renamed from patches/lvm/2.02.185/lvm2-010-static-libm.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-011-HPPA-no-O_DIRECT.patch (renamed from patches/lvm/2.02.185/lvm2-011-HPPA-no-O_DIRECT.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-012-mallinfo.patch (renamed from patches/lvm/2.02.185/lvm2-012-mallinfo.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-013-fix-stdio-usage.patch (renamed from patches/lvm/2.02.185/lvm2-013-fix-stdio-usage.patch)4
-rw-r--r--patches/lvm/2.02.186/lvm2-014-make-malloc-realloc-check-optional.patch (renamed from patches/lvm/2.02.185/lvm2-014-make-malloc-realloc-check-optional.patch)0
-rw-r--r--patches/lvm/2.02.186/lvm2-015-mksh_build.patch (renamed from patches/lvm/2.02.185/lvm2-015-mksh_build.patch)0
-rw-r--r--patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.7.0-build-fixes.patch34
-rw-r--r--patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.8.5-libaio-0.3.112.patch84
-rw-r--r--patches/xfsprogs/5.0.0/xfsprogs-4.15.0-sharedlibs.patch105
-rw-r--r--patches/xfsprogs/5.2.1/xfsprogs-4.9.0-underlinking.patch (renamed from patches/xfsprogs/5.0.0/xfsprogs-4.9.0-underlinking.patch)0
-rw-r--r--worker_modules/gkbuild.sh56
-rw-r--r--worker_modules/unpack.sh2
102 files changed, 3194 insertions, 1193 deletions
diff --git a/Makefile b/Makefile
index da579aa..36a73fd 100644
--- a/Makefile
+++ b/Makefile
@@ -73,7 +73,8 @@ verify-doc: doc/genkernel.8.txt
sed -r \
-e 's,[[:space:]]*--(no-)?,,g' \
-e '/bootloader/s,=\(grub\|grub2\),,g' \
- -e '/microcode/s,\[\],,g' | \
+ -e '/microcode/s,=\(all\|amd\|intel\),,g' \
+ -e '/ssh-host-keys/s,=\(create\|create-from-host\|runtime\),,g' | \
while read opt ; do \
regex="^*--(...no-...)?$$opt" ; \
if ! egrep -e "$$regex" $< -sq ; then \
diff --git a/defaults/busy-config b/defaults/busy-config
index 1184633..0a2456a 100644
--- a/defaults/busy-config
+++ b/defaults/busy-config
@@ -1,5 +1,3 @@
-# Gentoo patch:
-CONFIG_MDSTART=y
# Options to match older versions of busybox:
CONFIG_ASH_BUILTIN_ECHO=y
CONFIG_ASH_BUILTIN_PRINTF=y
@@ -111,7 +109,7 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SMALL=1
CONFIG_SHA3_SMALL=1
-# CONFIG_FEATURE_FAST_TOP is not set
+CONFIG_FEATURE_FAST_TOP=y
# CONFIG_FEATURE_ETC_NETWORKS is not set
CONFIG_FEATURE_EDITING=y
CONFIG_FEATURE_EDITING_MAX_LEN=1024
@@ -353,7 +351,7 @@ CONFIG_BASE64=y
CONFIG_WC=y
CONFIG_FEATURE_WC_LARGE=y
CONFIG_WHOAMI=y
-# CONFIG_WHO is not set
+CONFIG_WHO=y
# CONFIG_W is not set
# CONFIG_USERS is not set
CONFIG_YES=y
@@ -1054,6 +1052,7 @@ CONFIG_FEATURE_SHOW_THREADS=y
# CONFIG_FEATURE_RUNSVDIR_LOG is not set
# CONFIG_SV is not set
CONFIG_SV_DEFAULT_SERVICE_DIR=""
+# CONFIG_SVOK is not set
# CONFIG_SVC is not set
# CONFIG_SVLOGD is not set
# CONFIG_CHCON is not set
@@ -1135,7 +1134,7 @@ CONFIG_CTTYHACK=y
#
CONFIG_FEATURE_SH_MATH=y
CONFIG_FEATURE_SH_MATH_64=y
-# CONFIG_FEATURE_SH_EXTRA_QUIET is not set
+CONFIG_FEATURE_SH_EXTRA_QUIET=y
# CONFIG_FEATURE_SH_STANDALONE is not set
# CONFIG_FEATURE_SH_NOFORK is not set
CONFIG_FEATURE_SH_HISTFILESIZE=y
diff --git a/defaults/config.sh b/defaults/config.sh
index 3546299..9d15633 100644
--- a/defaults/config.sh
+++ b/defaults/config.sh
@@ -21,6 +21,13 @@ KERNEL_SUPPORT_MICROCODE=no
# Arch-specific defaults that can be overridden in the config file or on the
# command line.
#
+DEFAULT_INITRAMFS_FILENAME="initramfs-%%KV%%.img"
+DEFAULT_INITRAMFS_SYMLINK_NAME="initramfs"
+DEFAULT_KERNEL_FILENAME="vmlinuz-%%KV%%"
+DEFAULT_KERNEL_SYMLINK_NAME="kernel"
+DEFAULT_SYSTEMMAP_FILENAME="System.map-%%KV%%"
+DEFAULT_SYSTEMMAP_SYMLINK_NAME="System.map"
+
DEFAULT_COMPRESS_INITRD=yes
DEFAULT_COMPRESS_INITRD_TYPE=best
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index fbbd214..8fa2822 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -6,7 +6,6 @@ PATH="/usr/sbin:/usr/bin:/sbin:/bin"
# ctrl-V then esc will print ^[
# ctrl-V then ctrl-shift-m will print ^M
BACK_UP="\033[1K\033[0G"
-NORMAL="\033[0m"
WARN="\033[33;1m"
BAD="\033[31;1m"
BOLD="\033[1m"
@@ -71,6 +70,12 @@ CDROOT_MARKER='/livecd'
VERIFY=0
IP='dhcp'
+GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled"
+GK_INIT_LOG='/tmp/init.log'
+GK_INIT_LOG_COPYTO=
+GK_INIT_LOG_COPYTO_DEFAULT='/genkernel-boot.log'
+GK_INIT_LOG_DISABLED='/tmp/no-init.log'
+GK_INIT_LOG_PREFIX=
GK_NET_DHCP_PIDFILE='/var/run/udhcpc.pid'
GK_NET_DHCP_RETRIES=3
GK_NET_GW=
@@ -80,7 +85,10 @@ GK_NET_ROUTES=
GK_NET_TIMEOUT_DAD=10
GK_NET_TIMEOUT_DECONFIGURATION=10
GK_NET_TIMEOUT_DHCP=10
-GK_SHELL_LOCKFILE='/var/run/rescueshell.pid'
+GK_NET_TIMEOUT_INTERFACE=10
+GK_PROMPT_FILE='/tmp/current_prompt'
+GK_PROMPT_TIMEOUT=0
+GK_SHELL_LOCKFILE='/tmp/rescueshell.lock'
GK_SSHD_LOCKFILE='/tmp/remote-rescueshell.lock'
GK_SSHD_PIDFILE='/var/run/dropbear.pid'
GK_SSHD_PORT=22
@@ -119,8 +127,8 @@ DEFAULT_NFSOPTIONS="ro,nolock"
# - modules
HWOPTS_BLK='nvme pata sata scsi usb firewire waitscan'
HWOPTS_OBSOLETE='pcmcia ataraid' # Obsolete stuff that might be useful on old hardware, do$X only.
-HWOPTS="keymap cache modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid multipath mdadm zfs fs net iscsi crypto"
+HWOPTS="keymap cache modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid multipath mdadm zfs fs iscsi crypto"
# This is the set of default HWOPTS, in the order that they are loaded.
# This is whitespace aligned with HWOPTS above.
-MY_HWOPTS=" modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid mdadm fs net crypto"
+MY_HWOPTS=" modules virtio hyperv ${HWOPTS_BLK} bcache lvm dmraid mdadm fs crypto"
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index bc19fff..2969f44 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -34,6 +34,17 @@ modules_scan() {
[ -n "${MODS}" ] && [ -z "${QUIET}" ] && \
printf "%b" "${BOLD} ::${NORMAL} Loading from ${1}: "
+ if [ -z "${MODULES_SCAN_WARNING_SHOWN}" ]
+ then
+ local note_msg="NOTE: Due to how genkernel auto-detects your"
+ note_msg="${note_msg} hardware you will now see a lot of failed modprobe" \
+ note_msg="${note_msg} attempts which you can ignore:"
+
+ log_msg "${note_msg}"
+
+ MODULES_SCAN_WARNING_SHOWN=yes
+ fi
+
for x in ${MODS}
do
MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/")
@@ -49,21 +60,21 @@ modules_scan() {
break
fi
- if [ -n "${DEBUG}" ]
+ if is_debug
then
printf "%b" "${BOLD} ::${NORMAL} "
printf "%b" "Scanning for ${x} ..."
fi
- modprobe ${x} >/dev/null 2>&1
+ run modprobe ${x} >/dev/null 2>&1
loaded=${?}
- [ -n "${DEBUG}" -a "${loaded}" = "0" ] && \
+ is_debug && [ "${loaded}" = "0" ] && \
echo "loaded"
- [ -n "${DEBUG}" -a "${loaded}" != "0" ] && \
+ is_debug && [ "${loaded}" != "0" ] && \
echo "not loaded"
- [ -z "${DEBUG}" -a "${loaded}" = "0" ] && \
+ ! is_debug && [ "${loaded}" = "0" ] && \
[ -z "${QUIET}" ] && \
printf "%b" "${x} "
else
@@ -79,7 +90,6 @@ uppercase() {
echo $1 | tr 'a-z' 'A-Z'
}
-
findmediamount() {
# $1 = mount dir name / media name
# $2 = recognition file
@@ -130,14 +140,14 @@ findmediamount() {
fi
good_msg "Attempting to mount media: ${x}" ${CRYPT_SILENT}
- mount -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1
+ run mount -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1
if [ $? -eq 0 ]
then
if [ -n "${ISOBOOT}" ]
then
if [ -f "${mntcddir}/${ISOBOOT}" ]
then
- mount -o loop "${mntcddir}/${ISOBOOT}" "${mntdir}"
+ run mount -o loop "${mntcddir}/${ISOBOOT}" "${mntdir}"
if [ $? -eq 0 ]
then
good_msg "iso mounted on ${mntdir}"
@@ -153,7 +163,7 @@ findmediamount() {
good_msg "Media found on ${x}" ${CRYPT_SILENT}
break
else
- umount ${mntcddir}
+ run umount ${mntcddir}
fi
fi
fi
@@ -203,37 +213,37 @@ bootstrapFS() {
aufs_branch=${aufs_memory}/aufs-rw-branch/${aufs_dev_uid}
fi
- mkdir -p ${aufs_memory} ${aufs_union} ${aufs_dev_mnt}
+ run mkdir -p ${aufs_memory} ${aufs_union} ${aufs_dev_mnt}
else
# Legacy SquashFS implementation
good_msg "Making tmpfs for ${NEW_ROOT}"
- mount -n -t tmpfs tmpfs ${NEW_ROOT}
+ run mount -n -t tmpfs tmpfs ${NEW_ROOT}
fi
# Setup the filesystem nodes and directories
for i in ${CDROOT_PATH} /mnt/livecd /mnt/key /mnt/gentoo /tmp /tmp/.initrd /dev /proc /run /sys; do
- mkdir -p "${NEW_ROOT}${i}"
- chmod 755 "${NEW_ROOT}${i}"
+ run mkdir -p "${NEW_ROOT}${i}"
+ run chmod 755 "${NEW_ROOT}${i}"
done
- [ ! -d "${CDROOT_PATH}" ] && mkdir -p "${CDROOT_PATH}"
- [ ! -e "${NEW_ROOT}/dev/null" ] && mknod -m 666 "${NEW_ROOT}"/dev/null c 1 3
- [ ! -e "${NEW_ROOT}/dev/zero" ] && mknod -m 666 "${NEW_ROOT}"/dev/zero c 1 5
- [ ! -e "${NEW_ROOT}/dev/console" ] && mknod -m 600 "${NEW_ROOT}"/dev/console c 5 1
- [ ! -e "${NEW_ROOT}/dev/ttyS0" ] && mknod -m 660 "${NEW_ROOT}"/dev/ttyS0 c 4 64
+ [ ! -d "${CDROOT_PATH}" ] && run mkdir -p "${CDROOT_PATH}"
+ [ ! -e "${NEW_ROOT}/dev/null" ] && run mknod -m 666 "${NEW_ROOT}"/dev/null c 1 3
+ [ ! -e "${NEW_ROOT}/dev/zero" ] && run mknod -m 666 "${NEW_ROOT}"/dev/zero c 1 5
+ [ ! -e "${NEW_ROOT}/dev/console" ] && run mknod -m 600 "${NEW_ROOT}"/dev/console c 5 1
+ [ ! -e "${NEW_ROOT}/dev/ttyS0" ] && run mknod -m 660 "${NEW_ROOT}"/dev/ttyS0 c 4 64
# For SGI LiveCDs
if [ "${LOOPTYPE}" = "sgimips" ]
then
- [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0
- [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0
+ [ ! -e "${NEW_ROOT}/dev/sr0" ] && run mknod "${NEW_ROOT}/dev/sr0" b 11 0
+ [ ! -e "${NEW_ROOT}/dev/loop0" ] && run mknod "${NEW_ROOT}/dev/loop0" b 7 0
fi
# Required for splash to work. Not an issue with the initrd as this
# device isn't created there and is not needed.
for minor in 0 1
do
- [ ! -e "${NEW_ROOT}/dev/${minor}" ] && mknod -m 600 "${NEW_ROOT}/dev/tty${minor}" c 4 ${minor}
+ [ ! -e "${NEW_ROOT}/dev/${minor}" ] && run mknod -m 600 "${NEW_ROOT}/dev/tty${minor}" c 4 ${minor}
done
}
@@ -254,11 +264,11 @@ bootstrapCD() {
if [ -f isoroot_checksums ]
then
good_msg "Verifying checksums, this may take some time ..."
- if ! busybox sha512sum -c isoroot_checksums
+ if ! run sha512sum -c isoroot_checksums
then
bad_msg "Some checksums failed, press any key to poweroff ..."
read -n1 -s
- busybox poweroff -f
+ poweroff -f
else
good_msg "Checksums all valid, continuing boot ..."
fi
@@ -294,23 +304,25 @@ cache_cd_contents() {
# echo ${z}
good_msg "Copying loop file for caching ..."
# Verify that the needed directory exists
- mkdir -p "$(dirname ${NEW_ROOT}/mnt/${LOOP})"
- cp -a ${CDROOT_PATH}/${LOOP} ${NEW_ROOT}/mnt/${LOOP}
+ run mkdir -p "$(dirname ${NEW_ROOT}/mnt/${LOOP})"
+ run cp -a ${CDROOT_PATH}/${LOOP} ${NEW_ROOT}/mnt/${LOOP}
if [ $? -ne 0 ]
then
warn_msg "Failed to cache the loop file! Lack of RAM?"
- rm -rf ${NEW_ROOT}/mnt/${LOOP} 2>/dev/null
- rm -rf ${NEW_ROOT}/mnt/livecd.* 2>/dev/null
- rm -rf ${NEW_ROOT}/mnt/image.* 2>/dev/null
- rm -rf ${NEW_ROOT}/mnt/zisofs 2>/dev/null
+ run rm -rf ${NEW_ROOT}/mnt/${LOOP} 2>/dev/null
+ run rm -rf ${NEW_ROOT}/mnt/livecd.* 2>/dev/null
+ run rm -rf ${NEW_ROOT}/mnt/image.* 2>/dev/null
+ run rm -rf ${NEW_ROOT}/mnt/zisofs 2>/dev/null
fi
fi
fi
}
mount_sysfs() {
- mount -t sysfs sysfs /sys -o noexec,nosuid,nodev >/dev/null 2>&1
- [ $? -eq 0 ] || bad_msg "Failed to mount /sys!"
+ if ! run mount -t sysfs sysfs /sys -o noexec,nosuid,nodev >/dev/null 2>&1
+ then
+ bad_msg "Failed to mount /sys!"
+ fi
}
# Check support for both aufs and overlayfs
@@ -345,8 +357,8 @@ is_union_modules() {
else
warn_msg "Adding all modules in ${mod_dir}"
- mkdir /mnt/modules
- mount "${mod_dir}" /mnt/modules
+ run mkdir /mnt/modules
+ run mount "${mod_dir}" /mnt/modules
union_insert_modules /mnt/modules
fi
fi
@@ -361,7 +373,7 @@ is_union_modules() {
#
aufs_insert_dir() {
# Always mount it over the precedent (add:1:)
- if mount -n -o "remount,add:1:$2=rr" aufs "$1"
+ if run mount -n -o "remount,add:1:$2=rr" aufs "$1"
then
good_msg "Addition of $2 to $1 successful"
fi
@@ -409,18 +421,18 @@ union_mod() {
then
if [ ! -d "${aufs_union}"/mnt/"${mod}" ]
then
- mkdir -p "${aufs_union}"/mnt/modules/"${mod}" || return
+ run mkdir -p "${aufs_union}"/mnt/modules/"${mod}" || return
fi
- mount -o loop,ro "$2" "${aufs_union}"/mnt/modules/"${mod}"
+ run mount -o loop,ro "$2" "${aufs_union}"/mnt/modules/"${mod}"
aufs_insert_dir "${aufs_union}" "${aufs_union}"/mnt/modules/"${mod}"
else
if [ ! -d "${mod_dir}/.${mod}" ]
then
- mkdir -p "${mod_dir}/.${mod}" || return
+ run mkdir -p "${mod_dir}/.${mod}" || return
fi
- mount -o loop,ro "$2" "${mod_dir}/.${mod}"
+ run mount -o loop,ro "$2" "${mod_dir}/.${mod}"
fi
}
@@ -450,7 +462,7 @@ conf_rc_no_umounts() {
if [ -n "${cmd}" ]
then
- sed -i "${cmd%;}" ${conf}
+ run sed -i "${cmd%;}" ${conf}
test_success "Unable to edit /etc/conf.d/localmount"
fi
fi
@@ -462,6 +474,17 @@ conf_rc_no_umounts() {
fi
}
+is_debug() {
+ is_debug=1
+
+ if [ -f "${GK_DEBUGMODE_STATEFILE}" ]
+ then
+ is_debug=0
+ fi
+
+ return ${is_debug}
+}
+
# is_int "${A}" ["${B}"..]
# NOTE we consider a leading 0 false as it would be interpreted as octal
is_int() {
@@ -475,6 +498,39 @@ is_int() {
done
}
+is_log_enabled() {
+ if [ -z "${GK_INIT_LOG}" ]
+ then
+ return 1
+ elif [ -f "${GK_INIT_LOG_DISABLED}" ]
+ then
+ return 1
+ fi
+
+ return 0
+}
+
+is_true() {
+ case "$1" in
+ [Tt][Rr][Uu][Ee])
+ return 0
+ ;;
+ [Tt])
+ return 0
+ ;;
+ [Yy][Ee][Ss])
+ return 0
+ ;;
+ [Yy])
+ return 0
+ ;;
+ 1)
+ return 0
+ ;;
+ esac
+ return 1
+}
+
# Function to create an ext2 fs on $aufs_dev, $aufs_dev_mnt mountpoint
create_changefs() {
local size
@@ -493,13 +549,13 @@ create_changefs() {
then
bad_msg "Please give a size of at least 16 Megabytes"
else
- if dd if=/dev/zero "of=${aufs_dev_mnt}${aufs_union_file}" bs=1 seek="${size}"M count=0 >/dev/null 2>&1
+ if run dd if=/dev/zero "of=${aufs_dev_mnt}${aufs_union_file}" bs=1 seek="${size}"M count=0 >/dev/null 2>&1
then
good_msg "Creation of ${aufs_union_file}, ${size}MB on ${aufs_dev successful}, formatting it ext2"
- mke2fs -F "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1
+ run mke2fs -F "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1
break
else
- rm "${aufs_dev_mnt}${aufs_union_file}"
+ run rm "${aufs_dev_mnt}${aufs_union_file}"
bad_msg "Unable to create ${aufs_union_file#*/} on ${aufs_dev} of ${size}MB"
bad_msg "Ensure your disk is not full or read-only"
@@ -507,7 +563,7 @@ create_changefs() {
if [ "${doabort}" = 'a' ]
then
bad_msg "Aborting creation of ${aufs_union_file}!"
- umount "${aufs_dev}" && rmdir "${aufs_dev_mnt}"
+ run umount "${aufs_dev}" && rmdir "${aufs_dev_mnt}"
return 1
fi
fi
@@ -551,7 +607,7 @@ setup_aufs() {
then
good_msg "Mounting ${aufs_dev} to ${aufs_memory} for aufs support"
- if ! mount -t auto "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1
+ if ! run mount -t auto "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1
then
bad_msg "Mount of ${aufs_dev} failed, falling back to ramdisk based aufs"
unset aufs_dev
@@ -561,12 +617,12 @@ setup_aufs() {
# Check and attempt to create the AUFS union file
if [ ! -e ${aufs_dev_mnt}${aufs_union_file} ] && [ -n "${aufs_dev}" ]
then
- create_changefs && mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}"
+ create_changefs && run mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}"
elif [ -n "${aufs_dev}" ]
then
while :;
do
- if mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}" >/dev/null 2>&1
+ if run mount -t auto "${aufs_dev_mnt}${aufs_union_file}" "${aufs_memory}" >/dev/null 2>&1
then
if [ "${aufs_union_file}" = "/casper-rw" ]
then
@@ -581,18 +637,18 @@ setup_aufs() {
bad_msg "/sbin/e2fsck not found! aborting filesystem check"
bad_msg "Moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad"
- mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad"
+ run mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad"
break
fi
- if e2fsck "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1
+ if run e2fsck "${aufs_dev_mnt}${aufs_union_file}" >/dev/null 2>&1
then
good_msg "e2fsck ran successfully. Please verify data after bootup"
else
bad_msg "Your ${aufs_union_file#*/} image might be corrupted"
bad_msg "moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad"
- mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad"
+ run mv "${aufs_dev_mnt}${aufs_union_file}" "${aufs_dev_mnt}${aufs_union_file}.bad"
break
fi
fi
@@ -617,22 +673,22 @@ setup_aufs() {
bad_msg "Falling back to ramdisk based aufs"
good_msg "Mounting ramdisk to ${aufs_memory} for aufs support"
- mount -t tmpfs tmpfs "${aufs_memory}"
+ run mount -t tmpfs tmpfs "${aufs_memory}"
else
aufs_xino=${aufs_memory}/xino
- mkdir -p "${aufs_xino}"
- mount -t tmpfs aufs-xino "${aufs_xino}"
+ run mkdir -p "${aufs_xino}"
+ run mount -t tmpfs aufs-xino "${aufs_xino}"
fi
else
aufs_xino=${aufs_memory}
good_msg "Mounting ramdisk to ${aufs_memory} for aufs support"
- mount -t tmpfs tmpfs "${aufs_memory}"
+ run mount -t tmpfs tmpfs "${aufs_memory}"
fi
- mkdir -p "${aufs_branch}"
- if ! mount -t aufs -n -o "nowarn_perm,udba=none,xino=${aufs_xino}/.aufs.xino,br:${aufs_branch}=rw" aufs "${aufs_union}"
+ run mkdir -p "${aufs_branch}"
+ if ! run mount -t aufs -n -o "nowarn_perm,udba=none,xino=${aufs_xino}/.aufs.xino,br:${aufs_branch}=rw" aufs "${aufs_union}"
then
bad_msg "Can't setup union ${aufs_union} in directory!"
aufs=0
@@ -649,11 +705,11 @@ setup_overlayfs() {
rundebugshell overlayfs
for i in "${overlay}" "${static}"
do
- [ ! -d "${i}" ] && mkdir -p "${i}"
+ [ ! -d "${i}" ] && run mkdir -p "${i}"
done
good_msg "Loading overlayfs"
- modprobe overlay >/dev/null 2>&1
+ run modprobe overlay >/dev/null 2>&1
checkfs overlay
mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${static}"
@@ -661,7 +717,7 @@ setup_overlayfs() {
mkdir "${upperdir}" "${workdir}"
is_union_modules overlayfs
- mount -t overlay overlay -o lowerdir="${static}${mod_path}",upperdir="${upperdir}",workdir="${workdir}" "${NEW_ROOT}"
+ run mount -t overlay overlay -o lowerdir="${static}${mod_path}",upperdir="${upperdir}",workdir="${workdir}" "${NEW_ROOT}"
[ ! -d "${NEW_ROOT}${overlay}" ] && mkdir -p "${NEW_ROOT}${overlay}"
[ ! -d "${NEW_ROOT}${static}" ] && mkdir -p "${NEW_ROOT}${static}"
@@ -670,7 +726,7 @@ setup_overlayfs() {
for i in "${overlay}" "${static}"
do
- mount --bind "${i}" "${NEW_ROOT}${i}"
+ run mount --bind "${i}" "${NEW_ROOT}${i}"
done
# Did we populate the overlayfs modules path locations variable?
@@ -678,7 +734,7 @@ setup_overlayfs() {
then
for i in ${mods}
do
- mount --bind "${overlay}/.${i}" "${NEW_ROOT}/${overlay}/.${i}"
+ run mount --bind "${overlay}/.${i}" "${NEW_ROOT}/${overlay}/.${i}"
done
fi
}
@@ -736,7 +792,7 @@ findnfsmount() {
if [ "${CDROOT}" != '0' ]
then
good_msg "Attempting to mount NFS CD image on ${NFSROOT} with options ${NFSOPTIONS}"
- mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${CDROOT_PATH}
+ run mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${CDROOT_PATH}
if [ $? -eq 0 ]
then
REAL_ROOT="/dev/nfs"
@@ -746,7 +802,7 @@ findnfsmount() {
fi
else
good_msg "Attempting to mount NFS root on ${NFSROOT} with options ${NFSOPTIONS}"
- mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${NEW_ROOT}
+ run mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${NEW_ROOT}
if [ $? -eq 0 ]
then
REAL_ROOT="/dev/nfs"
@@ -804,27 +860,61 @@ check_loop() {
fi
}
+run() {
+ local retval
+
+ if "$@"; then
+ retval=$?
+ log_msg "Executed: '$*'"
+ else
+ retval=$?
+ log_msg "Failed (${retval}): '$*'"
+ fi
+
+ return ${retval}
+}
+
run_shell() {
[ -x /bin/sh ] && SH=/bin/sh || SH=/bin/ash
+ run touch "${GK_SHELL_LOCKFILE}"
+
export PS1='rescueshell \w \# '
- if [ -n "${CONSOLE}" ] && [ -c "/dev/${CONSOLE}" ]
+ echo
+ GOOD=${BLUE} good_msg "${NORMAL}Welcome to ${BOLD}${gk_ver}${NORMAL} (${gk_build_date}) ${BOLD}rescue shell${NORMAL}!"
+ GOOD=${BLUE} good_msg "${NORMAL}...running Linux kernel ${BOLD}${kernel_ver}${NORMAL}"
+ echo
+
+ # Avoid /dev/{console,tty0} due to "can't access tty; job control turned off" problem;
+ # cttyhack will handle this for us...
+ if [ -n "${CONSOLE}" ] \
+ && [ "${CONSOLE}" != "/dev/console" ] \
+ && [ "${CONSOLE}" != "/dev/tty0" ] \
+ && [ -c "${CONSOLE}" ]
then
- setsid ${SH} -c "exec sh --login </dev/${CONSOLE} >/dev/${CONSOLE} 2>&1"
+ log_msg "Opening rescue shell on ${CONSOLE} ..."
+ setsid ${SH} -c "exec sh --login <${CONSOLE} >${CONSOLE} 2>&1"
elif command -v cttyhack 1>/dev/null 2>&1
then
+ log_msg "Opening rescue shell using cttyhack ..."
setsid cttyhack ${SH} --login
elif [ -c '/dev/tty1' ]
then
+ log_msg "Opening rescue shell on /dev/tty1 fallback ..."
setsid ${SH} -c 'exec sh --login </dev/tty1 >/dev/tty1 2>&1'
else
+ log_msg "Opening rescue shell (last resort) ..."
${SH} --login
fi
+ rm "${GK_SHELL_LOCKFILE}"
+
echo
- :> "${GK_SHELL_LOCKFILE}"
+ # We maybe have called exec and dettached from main script; We
+ # must restore control...
+ exec >${CONSOLE} <${CONSOLE} 2>&1
}
fs_type_in_use() {
@@ -845,15 +935,15 @@ mount_devfs() {
# Options copied from /etc/init.d/udev-mount, should probably be kept in sync
if ! fs_type_in_use devtmpfs
then
- mount -t ${devfs} -o "exec,nosuid,mode=0755,size=10M" udev /dev \
+ run mount -t ${devfs} -o "exec,nosuid,mode=0755,size=10M" udev /dev \
|| bad_msg "Failed to mount /dev as ${devfs}"
fi
# http://git.busybox.net/busybox/plain/docs/mdev.txt
if ! fs_type_in_use devpts
then
- mkdir -m 0755 /dev/pts
- mount -t devpts -o gid=5,mode=0620 devpts /dev/pts || bad_msg "Failed to mount /dev/pts"
+ run mkdir -m 0755 /dev/pts
+ run mount -t devpts -o gid=5,mode=0620 devpts /dev/pts || bad_msg "Failed to mount /dev/pts"
fi
}
@@ -869,30 +959,61 @@ test_success() {
fi
}
+log_msg() {
+ is_log_enabled || return
+
+ if [ ! -f "${GK_INIT_LOG}" ]
+ then
+ touch "${GK_INIT_LOG}"
+ fi
+
+ local log_prefix=
+ [ -n "${GK_INIT_LOG_PREFIX}" ] && log_prefix="${GK_INIT_LOG_PREFIX}: "
+
+ local msg=${1}
+
+ # Cannot use substitution because $msg could contain infinite color
+ # codes and substitution can't be greedy.
+ # Because Busybox's sed cannot deal with control characters, we
+ # have to get rid of all non-printable characters like "^[" first...
+ LANG=C echo "${log_prefix}${msg}" | sed \
+ -e "s,[^[:print:]],,g" \
+ -e 's,\(\\033\)\?\[[0-9;]\+m,,g' \
+ | ts '[%Y-%m-%d %H:%M:%S]' >> "${GK_INIT_LOG}"
+}
# msg functions arguments
# $1 string
# $2 hide flag
good_msg() {
- [ -n "${QUIET}" ] && [ -z "${DEBUG}" ] && return 0
+ [ -n "${QUIET}" ] && ! is_debug && return 0
- msg_string=${1}
+ local msg_string=${1}
msg_string="${msg_string:-...}"
+
+ log_msg "[OK] ${msg_string}"
+
[ "$2" != '1' ] && printf "%b\n" "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
}
good_msg_n() {
- [ -n "${QUIET}" ] && [ -z "${DEBUG}" ] && return 0
+ [ -n "${QUIET}" ] && ! is_debug && return 0
- msg_string=${1}
+ local msg_string=${1}
msg_string="${msg_string:-...}"
+
+ log_msg "[OK] ${msg_string}"
+
[ "$2" != '1' ] && printf "%b" "${GOOD}>>${NORMAL}${BOLD} ${msg_string}"
}
bad_msg() {
- msg_string=${1}
+ local msg_string=${1}
msg_string="${msg_string:-...}"
+
+ log_msg "[!!] ${msg_string}"
+
if [ "$2" != '1' ]
then
splash 'verbose' >/dev/null &
@@ -901,18 +1022,21 @@ bad_msg() {
}
warn_msg() {
- msg_string=${1}
+ local msg_string=${1}
msg_string="${msg_string:-...}"
+
+ log_msg "[**] ${msg_string}"
+
[ "$2" != '1' ] && printf "%b\n" "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
}
crypt_filter() {
if [ "${CRYPT_SILENT}" = '1' ]
then
- eval $1 >/dev/null 2>&1
+ eval run ${1} >/dev/null 2>&1
else
splash 'verbose' >/dev/null &
- eval $1
+ eval run ${1}
res=$?
if [ ${res} -eq 0 ]
then
@@ -922,6 +1046,76 @@ crypt_filter() {
fi
}
+preserve_log() {
+ is_log_enabled || return
+ [ ! -s "${GK_INIT_LOG}" ] && return
+ [ -z "${GK_INIT_LOG_COPYTO}" ] && return
+
+ local have_errors=0
+
+ local logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO#/}"
+ if ! echo "${logfile_target}" | grep -qE '^.*/[A-Za-z0-9._-]+$'
+ then
+ # The test above will make sure that a filename was given
+ # so we can be sure that dirname() will always return a
+ # path.
+ warn_msg "gk.log.keep value '${GK_INIT_LOG_COPYTO}' is invalid; Will copy log to '${GK_INIT_LOG_COPYTO_DEFAULT}' instead ..."
+ logfile_target="${CHROOT}/${GK_INIT_LOG_COPYTO_DEFAULT#/}"
+ fi
+
+ local fail_msg="Failed to copy '${GK_INIT_LOG}' to '${logfile_target}'"
+ local logfile_target_dir="$(dirname "${logfile_target}")"
+
+ if [ -z "${logfile_target_dir}" ]
+ then
+ bad_msg "${fail_msg}: Failed to determine dirname of '${logfile_target}'!"
+ return 1
+ fi
+
+ local logfile_mountpoint="${logfile_target_dir}"
+ while [ true ]
+ do
+ if run mountpoint "${logfile_mountpoint}" 1>/dev/null 2>&1
+ then
+ if run mount -o remount,rw "${logfile_mountpoint}" 1>/dev/null 2>&1
+ then
+ break
+ else
+ bad_msg "${fail_msg}: 'mount -o remount,rw \"${logfile_mountpoint}\"' failed!"
+ return 1
+ fi
+ fi
+
+ logfile_mountpoint="$(dirname "${logfile_mountpoint}")"
+ if [ "${logfile_mountpoint}" = "/" ]
+ then
+ # Stop here
+ bad_msg "${fail_msg}: Failed to determine mountpoint for '${logfile_target}'!"
+ return 1
+ fi
+ done
+
+ if [ ! -d "${logfile_target_dir}" ]
+ then
+ if ! run mkdir -p "${logfile_target_dir}" 2>/dev/null
+ then
+ bad_msg "${fail_msg}: Failed to create '${logfile_target_dir}'!"
+ return 1
+ fi
+ fi
+
+ good_msg "gk.log.keep set; Copying '${GK_INIT_LOG}' to '${logfile_target}' ..."
+ if ! run cp -f "${GK_INIT_LOG}" "${logfile_target}" 2>/dev/null
+ then
+ bad_msg "${fail_msg}!"
+ fi
+
+ if ! run mount -o remount,ro "${logfile_mountpoint}" 1>/dev/null 2>&1
+ then
+ bad_msg "Failed to re-mount ${logfile_mountpoint} read-only!"
+ fi
+}
+
prompt_user() {
# $1 = variable whose value is the path (examples: "REAL_ROOT",
# "LUKS_KEYDEV")
@@ -944,12 +1138,30 @@ prompt_user() {
bad_msg '- type "shell" for a shell'
bad_msg '- type "q" to skip ...'
printf "%s" "${2}(${oldvalue}) :: "
- read ${1}
- #if [ $? -gt 0 ]
- #then
- # # prompt timed out
- # printf "\n"
- #fi
+
+ if [ "${GK_PROMPT_TIMEOUT}" = '0' ]
+ then
+ read ${1}
+ else
+ local read_timeout_timestamp
+ let read_timeout_timestamp=$(date +%s)+${GK_PROMPT_TIMEOUT}
+
+ echo "# Could not find the ${2} in ${oldvalue}${explnt}" > "${GK_PROMPT_FILE}"
+ echo "# Please specify another value (file will be processed at $(date -d @${read_timeout_timestamp}):" >> "${GK_PROMPT_FILE}"
+ echo "${1}=${oldvalue}" >> "${GK_PROMPT_FILE}"
+ read -t ${GK_PROMPT_TIMEOUT} ${1}
+ if [ $? -gt 0 ]
+ then
+ # prompt timed out
+ printf "\n"
+
+ if [ -f "${GK_PROMPT_FILE}" ]
+ then
+ warn_msg "Timeout! Trying to read answer from '${GK_PROMPT_FILE}' ..."
+ . "${GK_PROMPT_FILE}" && run rm "${GK_PROMPT_FILE}"
+ fi
+ fi
+ fi
case $(eval echo '$'${1}) in
'q')
@@ -1016,7 +1228,7 @@ load_modules() {
# kernel version
if [ -d "/lib/modules/${KV}" ]
then
- good_msg 'Loading modules'
+ good_msg 'Loading modules ...'
# Load appropriate kernel modules
for modules in ${MY_HWOPTS}
do
@@ -1033,13 +1245,12 @@ setup_keymap() {
if [ ! -e /dev/vc/0 -a ! -e /dev/tty0 ]
then
DEVBIND=1
- mount -o bind ${NEW_ROOT}/dev /dev
+ run mount -o bind ${NEW_ROOT}/dev /dev
fi
- [ ! -e /dev/tty0 ] && ln -s /dev/tty1 /dev/tty0
[ -f /lib/keymaps/keymapList ] && chooseKeymap
- [ "${DEVBIND}" = '1' ] && umount /dev
+ [ "${DEVBIND}" = '1' ] && run umount /dev
fi
}
@@ -1055,66 +1266,62 @@ chooseKeymap() {
if [ -z "${keymap}" ]
then
splash 'verbose' >/dev/null &
- cat /lib/keymaps/keymapList
+ run cat /lib/keymaps/keymapList
read -t 10 -p '<< Load keymap (Enter for default): ' keymap
case ${keymap} in
1|azerty) keymap=azerty ;;
2|be) keymap=be ;;
- 3|bg) keymap=bg ;;
- 4|br-a) keymap=br-a ;;
- 5|br-l) keymap=br-l ;;
- 6|by) keymap=by ;;
- 7|cf) keymap=cf ;;
- 8|croat) keymap=croat ;;
- 9|cz) keymap=cz ;;
- 10|de) keymap=de ;;
- 11|dk) keymap=dk ;;
- 12|dvorak) keymap=dvorak ;;
- 13|es) keymap=es ;;
- 14|et) keymap=et ;;
- 15|fi) keymap=fi ;;
- 16|fr) keymap=fr ;;
- 17|gr) keymap=gr ;;
- 18|hu) keymap=hu ;;
- 19|il) keymap=il ;;
- 20|is) keymap=is ;;
- 21|it) keymap=it ;;
- 22|jp) keymap=jp ;;
- 23|la) keymap=la ;;
- 24|lt) keymap=lt ;;
- 25|mk) keymap=mk ;;
- 26|nl) keymap=nl ;;
- 27|no) keymap=no ;;
- 28|pl) keymap=pl ;;
- 29|pt) keymap=pt ;;
- 30|ro) keymap=ro ;;
- 31|ru) keymap=ru ;;
- 32|se) keymap=se ;;
- 33|sg) keymap=sg ;;
- 34|sk-y) keymap=sk-y ;;
- 35|sk-z) keymap=sk-z ;;
- 36|slovene) keymap=slovene ;;
- 37|trf) keymap=trf ;;
- 38|trq) keymap=trq ;;
- 39|ua) keymap=ua ;;
- 40|uk) keymap=uk ;;
- 41|us) keymap=us ;;
- 42|wangbe) keymap=wangbe ;;
- 43|sf|ch*) keymap=sf ;;
+ 3|bepo) keymap=bepo ;;
+ 4|bg) keymap=bg ;;
+ 5|br-a) keymap=br-a ;;
+ 6|br-l) keymap=br-l ;;
+ 7|by) keymap=by ;;
+ 8|cf) keymap=cf ;;
+ 9|colemak) keymap=colemak ;;
+ 10|croat) keymap=croat ;;
+ 11|cz) keymap=cz ;;
+ 12|de) keymap=de ;;
+ 13|dk) keymap=dk ;;
+ 14|dvorak) keymap=dvorak ;;
+ 15|es) keymap=es ;;
+ 16|et) keymap=et ;;
+ 17|fi) keymap=fi ;;
+ 18|fr) keymap=fr ;;
+ 19|gr) keymap=gr ;;
+ 20|hu) keymap=hu ;;
+ 21|il) keymap=il ;;
+ 22|is) keymap=is ;;
+ 23|it) keymap=it ;;
+ 24|jp) keymap=jp ;;
+ 25|la) keymap=la ;;
+ 26|lt) keymap=lt ;;
+ 27|mk) keymap=mk ;;
+ 28|nl) keymap=nl ;;
+ 29|no) keymap=no ;;
+ 30|pl) keymap=pl ;;
+ 31|pt) keymap=pt ;;
+ 32|ro) keymap=ro ;;
+ 33|ru) keymap=ru ;;
+ 34|se) keymap=se ;;
+ 35|sf|ch*) keymap=sf ;;
+ 36|sg) keymap=sg ;;
+ 37|sk-y) keymap=sk-y ;;
+ 38|sk-z) keymap=sk-z ;;
+ 39|slovene) keymap=slovene ;;
+ 40|trf) keymap=trf ;;
+ 41|ua) keymap=ua ;;
+ 42|uk) keymap=uk ;;
+ 43|us) keymap=us ;;
+ 44|wangbe) keymap=wangbe ;;
esac
fi
+
if [ -e /lib/keymaps/${keymap}.map ]
then
good_msg "Loading the '${keymap}' keymap ..."
- loadkmap < /lib/keymaps/${keymap}.map
-# xkeymap=${keymap}
-# echo ${keymap} | egrep -e "[0-9]+" >/dev/null 2>&1
-# if [ $? -eq 0 ]
-# then
-# xkeymap=$(tail -n 8 /lib/keymaps/keymapList | grep ${keymap} | sed -r "s/.*\s+${keymap}\s+([a-z-]+).*/\1/g" | egrep -v 1)
-# fi
- mkdir -p /etc/sysconfig
-# echo "XKEYBOARD=${xkeymap}" > /etc/sysconfig/keyboard
+ run loadkmap < /lib/keymaps/${keymap}.map
+
+ run mkdir -p /etc/sysconfig
echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard
splash set_msg "Set keymap to '${keymap}'"
elif [ -z "${keymap}" ]
@@ -1135,8 +1342,8 @@ chooseKeymap() {
copyKeymap() {
if [ -e /etc/sysconfig/keyboard -a ${CDROOT} -eq 1 ]
then
- [ ! -d ${NEW_ROOT}/etc/sysconfig ] && mkdir -p ${NEW_ROOT}/etc/sysconfig
- cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard
+ [ ! -d ${NEW_ROOT}/etc/sysconfig ] && run mkdir -p ${NEW_ROOT}/etc/sysconfig
+ run cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard
fi
}
@@ -1151,25 +1358,34 @@ waitForZFS() {
exit 1
}
+splash() {
+ return 0
+}
+
start_volumes() {
# Here, we check for /dev/device-mapper, and if it exists, we setup a
# a symlink, which should hopefully fix bug #142775 and bug #147015
if [ -e /dev/device-mapper ] && [ ! -e /dev/mapper/control ]
then
- mkdir -p /dev/mapper
- ln -sf /dev/device-mapper /dev/mapper/control
+ run mkdir -p /dev/mapper
+ run ln -sf /dev/device-mapper /dev/mapper/control
fi
if [ "${USE_MDADM}" = '1' ]
then
if [ -x '/sbin/mdadm' ]
then
- /sbin/mdadm --assemble --scan
+ local mdadm_cmd="run /sbin/mdadm --assemble --scan 2>&1"
+ is_log_enabled && mdadm_cmd="${mdadm_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${mdadm_cmd}"
+
#Intel Matrix RAID (and possibly others) have a container layer above the actual volumes,
#So we have to look for volumes that haven't been activated.
- mdadm -IRs
+ mdadm_cmd="run /sbin/mdadm -IRs 2>&1"
+ is_log_enabled && mdadm_cmd="${mdadm_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${mdadm_cmd}"
else
- bad_msg "mdadm not found: skipping mdadm raid assembly!"
+ bad_msg "domdadm invoked but /sbin/mdadm not found; Skipping mdadm raid assembly ..."
fi
fi
@@ -1180,7 +1396,7 @@ start_volumes() {
[ -x "${multipath_path}" ] && break
done
- for dmsetup_path in /sbin/dmsetup /bin/dmsetup MISSING
+ for dmsetup_path in /usr/sbin/dmsetup /sbin/dmsetup /bin/dmsetup MISSING
do
[ -x "${dmsetup_path}" ] && break
done
@@ -1199,19 +1415,24 @@ start_volumes() {
then
good_msg "Scanning for multipath devices"
good_msg ":: Populating scsi_id info for libudev queries"
- mkdir -p /run/udev/data
+ run mkdir -p /run/udev/data
local ech
for ech in /sys/block/*
do
local tgtfile=b$(cat ${ech}/dev)
- /lib/udev/scsi_id -g -x /dev/${ech##*/} |sed -e 's/^/E:/' >/run/udev/data/${tgtfile}
+ run /lib/udev/scsi_id -g -x /dev/${ech##*/} | sed -e 's/^/E:/' >/run/udev/data/${tgtfile}
done
- ${multipath_path} -v 0
+ local multipath_cmd="run ${multipath_path} -v 0 2>&1"
+ is_log_enabled && multipath_cmd="${multipath_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${multipath_cmd}"
sleep 2
- good_msg "Activating multipath devices"
- ${dmsetup_path} ls --target multipath --exec "${kpartx_path} -a -v"
+
+ good_msg "Activating multipath devices ..."
+ multipath_cmd="run ${dmsetup_path} ls --target multipath --exec '${kpartx_path} -a -v' 2>&1"
+ is_log_enabled && multipath_cmd="${multipath_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${multipath_cmd}"
fi
fi
@@ -1219,14 +1440,25 @@ start_volumes() {
then
if [ -x '/sbin/dmraid' ]
then
- good_msg "Activating Device-Mapper RAID(s)"
+ good_msg "Activating Device-Mapper RAID(s) ..."
+ local dmraid_cmd="run /sbin/dmraid -ay"
if [ -z "${DMRAID_OPTS}" ]
then
- /sbin/dmraid -ay
+ dmraid_cmd="${dmraid_cmd} 2>&1"
else
- /sbin/dmraid -ay ${DMRAID_OPTS}
+ dmraid_cmd="${dmraid_cmd} ${DMRAID_OPTS} 2>&1"
+ fi
+ is_log_enabled && dmraid_cmd="${dmraid_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${dmraid_cmd}"
+
+ if [ -x '/sbin/kpartx' ]
+ then
+ dmraid_cmd="run /sbin/dmsetup ls --exec '/sbin/kpartx -a -s' 2>&1"
+ is_log_enabled && dmraid_cmd="${dmraid_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${dmraid_cmd}"
fi
- [ -x '/sbin/kpartx' ] && /sbin/dmsetup ls --exec '/sbin/kpartx -a -s'
+ else
+ bad_msg "dodmraid invoked but /sbin/dmraid not found; Skipping dmraid activation ..."
fi
fi
@@ -1239,30 +1471,37 @@ start_volumes() {
if [ "${lvm_path}" = "MISSING" ]
then
- bad_msg "dolvm invoked, but LVM binary not available! skipping LVM volume group activation!"
+ bad_msg "dolvm invoked but LVM binary not available; Skipping LVM volume group activation ..."
else
for dev in ${RAID_DEVICES}
do
setup_md_device "${dev}"
done
- # This is needed for LVM to accept the following logic
- lvm_commands="#! ${lvm_path}"
+ local lvm_cmd
# If there is a cache, update it. Unbreak at least dmcrypt
- [ -d /etc/lvm/cache ] && lvm_commands="${lvm_commands} \nvgscan"
+ if [ -d /etc/lvm/cache ]
+ then
+ good_msg "Scanning for volume groups ..."
+ lvm_cmd="run ${lvm_path} vgscan 2>&1"
+ is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${lvm_cmd}"
+ fi
+
+ good_msg "Activating volume groups ..."
# To activate volumegroups on all devices in the cache
- lvm_commands="${lvm_commands} \nvgchange -ay --sysinit"
+ local lvm_cmd="run ${lvm_path} vgchange -ay --sysinit 2>&1"
+ is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${lvm_cmd}"
- # To create symlinks so users can use real_root=/dev/vg/root
+ # To create symlinks so users can use root=/dev/vg/root
# This needs to run after vgchange, using vgchange --mknodes is too
# early.
- lvm_commands="${lvm_commands} \nvgmknodes --ignorelockingfailure"
-
- # And finally execute it all (/proc/... needed if lvm is compiled without readline)
- good_msg "Scanning for and activating Volume Groups"
- printf "%b\n" "${lvm_commands}" | ${lvm_path} /proc/self/fd/0
+ local lvm_cmd="run ${lvm_path} vgmknodes --ignorelockingfailure 2>&1"
+ is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${lvm_cmd}"
fi
fi
@@ -1270,7 +1509,7 @@ start_volumes() {
then
if [ ! -e /sys/fs/bcache/register_quiet ]
then
- warn_msg "'/sys/fs/bcache/register_quiet' does not exist. Missing kernel driver? Skipping dobcache ..."
+ bad_msg "dobcache invoked but '/sys/fs/bcache/register_quiet' does not exist; Skipping bcache initialization ..."
else
local i=
for i in $(awk '$4 !~ /^(name$|$)/ { print $4 }' /proc/partitions)
@@ -1279,6 +1518,7 @@ start_volumes() {
then
# Push all the block devices to register_quiet
# If its bcache, it will bring it up, if not, it will simply ignore it.
+ log_msg "COMMAND: 'echo \"/dev/${i}\" >/sys/fs/bcache/register_quiet'"
echo "/dev/${i}" >/sys/fs/bcache/register_quiet 2>/dev/null
else
warn_msg "'/dev/${i}' should exist but is missing; Ignoring ..."
@@ -1291,9 +1531,12 @@ start_volumes() {
then
if [ -x '/sbin/btrfs' ]
then
- /sbin/btrfs device scan
+ local btrfs_cmd="run /sbin/btrfs device scan 2>&1"
+ is_log_enabled && btrfs_cmd="${btrfs_cmd} | tee -a '${GK_INIT_LOG}'"
+
+ eval "${btrfs_cmd}"
else
- bad_msg "btrfs not found: skipping btrfs device scanning!"
+ bad_msg "dobtrfs invoked but /sbin/btrfs not found; Skipping btrfs device scanning ..."
fi
fi
@@ -1305,14 +1548,16 @@ start_volumes() {
bad_msg "Cannot import ZFS pool because /dev/zfs is missing"
elif [ -z "${ZFS_POOL}" ]
then
- good_msg "Importing ZFS pools"
+ good_msg "Importing ZFS pools ..."
- /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE}
+ local zfs_cmd="run /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE} 2>&1"
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${zfs_cmd}"
if [ $? -eq 0 ]
then
- good_msg "Importing ZFS pools succeeded"
+ good_msg "Importing ZFS pools succeeded!"
else
- bad_msg "Imported ZFS pools failed"
+ bad_msg "Imported ZFS pools failed!"
fi
else
@@ -1322,19 +1567,27 @@ start_volumes() {
if [ -n "${CRYPT_ROOT}" -o -n "${CRYPT_SWAP}" ]
then
- good_msg "LUKS detected. Reimporting ${ZFS_POOL}"
- /sbin/zpool export -f "${ZFS_POOL}"
- /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} "${ZFS_POOL}"
+ good_msg "LUKS detected. Reimporting ${ZFS_POOL} ..."
+
+ local zfs_cmd="run /sbin/zpool export -f '${ZFS_POOL}' 2>&1"
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${zfs_cmd}"
+
+ zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1"
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${zfs_cmd}"
fi
else
- good_msg "Importing ZFS pool ${ZFS_POOL}"
+ good_msg "Importing ZFS pool ${ZFS_POOL} ..."
- /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} "${ZFS_POOL}"
+ local zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1"
+ is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${zfs_cmd}"
if [ $? -eq 0 ]
then
- good_msg "Import of ${ZFS_POOL} succeeded"
+ good_msg "Import of ${ZFS_POOL} succeeded!"
else
- bad_msg "Import of ${ZFS_POOL} failed"
+ bad_msg "Import of ${ZFS_POOL} failed!"
fi
fi
fi
@@ -1342,10 +1595,15 @@ start_volumes() {
}
start_iscsi() {
+ local iscsi_cmd
+
if [ ! -n "${ISCSI_NOIBFT}" ]
then
- good_msg "Activating iSCSI via iBFT"
- iscsistart -b
+ good_msg "Activating iSCSI via iBFT ..."
+
+ iscsi_cmd="run iscsistart -b 2>&1"
+ is_log_enabled && iscsi_cmd="${iscsi_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${iscsi_cmd}"
fi
if [ -n "${ISCSI_INITIATORNAME}" ] && [ -n "${ISCSI_TARGET}" ] && [ -n "${ISCSI_ADDRESS}" ]
@@ -1389,7 +1647,9 @@ start_iscsi() {
ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}"
fi
- iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -a "${ISCSI_ADDRESS}" ${ADDITIONAL}
+ iscsi_cmd="run iscsistart -i '${ISCSI_INITIATORNAME}' -t '${ISCSI_TARGET}' -a '${ISCSI_ADDRESS}' ${ADDITIONAL} 2>&1"
+ is_log_enabled && iscsi_cmd="${iscsi_cmd} | tee -a '${GK_INIT_LOG}'"
+ eval "${iscsi_cmd}"
fi
}
@@ -1452,8 +1712,7 @@ openLUKS() {
fi
setup_md_device ${LUKS_DEVICE}
- cryptsetup isLuks ${LUKS_DEVICE}
- if [ $? -ne 0 ]
+ if ! run cryptsetup isLuks ${LUKS_DEVICE}
then
bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT}
DEV_ERROR=1
@@ -1509,8 +1768,7 @@ openLUKS() {
# At this point a device was recognized, now let's see if the key is there
[ ! -d "${mntkey}" ] && mkdir -p "${mntkey}" >/dev/null 2>&1
- mount -n -o ro ${REAL_LUKS_KEYDEV} ${mntkey} >/dev/null 2>&1
- if [ "$?" != '0' ]
+ if ! run mount -n -o ro ${REAL_LUKS_KEYDEV} ${mntkey} >/dev/null 2>&1
then
KEYDEV_ERROR=1
bad_msg "Mounting of device ${REAL_LUKS_KEYDEV} failed." ${CRYPT_SILENT}
@@ -1521,7 +1779,7 @@ openLUKS() {
# keyfile exists?
if [ ! -e "${mntkey}${LUKS_KEY}" ]
then
- umount -n "${mntkey}" >/dev/null 2>&1
+ run umount -n "${mntkey}" >/dev/null 2>&1
KEY_ERROR=1
KEYDEV_ERROR=1
bad_msg "Key {LUKS_KEY} on device ${REAL_LUKS_KEYDEV} not found." ${CRYPT_SILENT}
@@ -1534,15 +1792,15 @@ openLUKS() {
if [ "$(echo ${LUKS_KEY} | grep -o '.gpg$')" = ".gpg" ]
then
- if [ ! -x '/sbin/gpg' ]
+ if [ ! -x '/usr/bin/gpg' ]
then
bad_msg "GPG-encrypted key file provided but gpg program is missing. Was initramfs built without --gpg parameter?"
bad_msg "Falling back to passphrase usage!"
else
- [ -e /dev/tty ] && mv /dev/tty /dev/tty.org
- mknod /dev/tty c 5 1
+ [ -e /dev/tty ] && run mv /dev/tty /dev/tty.org
+ run mknod /dev/tty c 5 1
cryptsetup_options="${cryptsetup_options} -d -"
- gpg_cmd="/sbin/gpg --logger-file /dev/null --quiet --decrypt ${mntkey}${LUKS_KEY} |"
+ gpg_cmd="/usr/bin/gpg --logger-file /dev/null --quiet --decrypt ${mntkey}${LUKS_KEY} |"
fi
else
cryptsetup_options="${cryptsetup_options} -d ${mntkey}${LUKS_KEY}"
@@ -1553,12 +1811,12 @@ openLUKS() {
crypt_filter_ret=$?
[ -e /dev/tty.org ] \
- && rm -f /dev/tty \
- && mv /dev/tty.org /dev/tty
+ && run rm -f /dev/tty \
+ && run mv /dev/tty.org /dev/tty
if [ ${crypt_filter_ret} -eq 0 ]
then
- touch "${OPENED_LOCKFILE}"
+ run touch "${OPENED_LOCKFILE}"
good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
break
elif [ ! -e "${OPENED_LOCKFILE}" ]
@@ -1571,8 +1829,13 @@ openLUKS() {
fi
fi
done
- umount "${mntkey}" >/dev/null 2>&1
- rmdir -p "${mntkey}" >/dev/null 2>&1
+
+ if run mountpoint "${mntkey}" >/dev/null 2>&1
+ then
+ run umount "${mntkey}" >/dev/null 2>&1
+ fi
+
+ [ -d "${mntkey}" ] run rmdir -p "${mntkey}" >/dev/null 2>&1
}
iface_name() {
@@ -1597,6 +1860,10 @@ iface_name() {
}
start_network() {
+ # Load network modules only when we need them to avoid possible
+ # firmware problems for people not using network that early
+ MY_HWOPTS=net load_modules
+
# At least gk.net.iface can only be processed after sysfs was
# mounted.
local x=
@@ -1620,17 +1887,21 @@ start_network() {
GK_NET_GW=${x#*=}
;;
gk.net.iface=*)
- local tmp_iface=$(iface_name "${x#*=}")
- if [ -z "${tmp_iface}" ]
- then
- warn_msg "Interface specified by '${x}' not found, falling back to genkernel defaults ..."
- else
- GK_NET_IFACE=${tmp_iface}
- fi
+ GK_NET_IFACE=${x#*=}
;;
gk.net.routes=*)
GK_NET_ROUTES=${x#*=}
;;
+ gk.net.timeout.interface=*)
+ local tmp_interface_timeout=${x#*=}
+ if is_int "${tmp_interface_timeout}"
+ then
+ GK_NET_TIMEOUT_INTERFACE=${tmp_interface_timeout}
+ else
+ warn_msg "'${x}' does not look like a valid number -- will keep using default value ${GK_NET_TIMEOUT_INTERFACE}!"
+ fi
+ unset tmp_interface_timeout
+ ;;
gk.net.timeout.dad=*)
local tmp_dad_timeout=${x#*=}
if is_int "${tmp_dad_timeout}"
@@ -1664,27 +1935,105 @@ start_network() {
esac
done
- if [ ! -d "/sys/class/net/${GK_NET_IFACE}" ]
+ local interface_identifier=device
+ if echo "${GK_NET_IFACE}" | grep -qE ':|-'
then
- warn_msg "Interface ${GK_NET_IFACE} not found; Will not try to start network ..."
- return
+ interface_identifier=mac
+ good_msg_n "Waiting for interface with MAC address ${GK_NET_IFACE} ..."
+ else
+ good_msg_n "Waiting for interface ${GK_NET_IFACE} ..."
+ fi
+
+ local tmp_interface=
+ local have_interface=0
+ local interface_time_waited=0
+ local interface_timeout_100msec_modulo=
+ local interface_timeout && let interface_timeout=$(date +%s)+1
+ [ -n "${GK_NET_TIMEOUT_INTERFACE}" -a "${GK_NET_TIMEOUT_INTERFACE}" -gt 0 ] && let interface_timeout=${interface_timeout}+${GK_NET_TIMEOUT_INTERFACE}-1
+
+ while [ "${have_interface}" != '1' -a $(date +%s) -le ${interface_timeout} ]
+ do
+ tmp_interface=$(iface_name "${GK_NET_IFACE}")
+ if [ -n "${tmp_interface}" ]
+ then
+ # We got at least something to probe
+ if [ -d "/sys/class/net/${tmp_interface}" ]
+ then
+ GK_NET_IFACE="${tmp_interface}"
+ have_interface=1
+ break
+ fi
+ fi
+
+ if [ "${have_interface}" != '1' ]
+ then
+ let interface_time_waited=${interface_time_waited}+1
+ sleep 0.1s
+
+ let interface_timeout_100msec_modulo=${interface_time_waited}%10
+ if [ ${interface_timeout_100msec_modulo} = 0 ]
+ then
+ printf "."
+ fi
+ fi
+ done
+
+ echo
+
+ if [ "${have_interface}" != '1' ]
+ then
+ # Timeout!
+ if [ "${interface_identifier}" = 'mac' ]
+ then
+ bad_msg "Interface with MAC address ${GK_NET_IFACE} not found!"
+ else
+ bad_msg "Interface ${GK_NET_IFACE} not found!"
+ fi
+
+ warn_msg "Will not try to start network ..."
+ return 1
+ elif [ "${interface_identifier}" = 'mac' ]
+ then
+ good_msg "Interface detected as ${GK_NET_IFACE}"
fi
if [ -z "${IP}" -o "${IP}" = 'dhcp' ]
then
+ if is_interface_up
+ then
+ # CONFIG_IP_PNP_DHCP and ip=dhcp probably caused kernel to bring up
+ # network for us. Really no need re-run dhcp...
+ warn_msg "Interface ${GK_NET_IFACE} is already up."
+ warn_msg "Skipping network setup; Will use existing network configuration ..."
+ run touch "${GK_NET_LOCKFILE}"
+ return 0
+ fi
+
+ local udhcpc_cmd="run udhcpc -i '${GK_NET_IFACE}' -n -t ${GK_NET_DHCP_RETRIES} -T ${GK_NET_TIMEOUT_DHCP} -R -p '${GK_NET_DHCP_PIDFILE}' 2>&1"
+ is_log_enabled && udhcpc_cmd="${udhcpc_cmd} | tee -a '${GK_INIT_LOG}'"
+
good_msg "Bringing up interface ${GK_NET_IFACE} using dhcp ..." ${QUIET}
- busybox udhcpc -i "${GK_NET_IFACE}" -n -t ${GK_NET_DHCP_RETRIES} -T ${GK_NET_TIMEOUT_DHCP} -R -p "${GK_NET_DHCP_PIDFILE}"
+ eval "${udhcpc_cmd}"
if [ $? -ne 0 ]
then
bad_msg "Failed to start udhcpc for interface ${GK_NET_IFACE}!"
- return
+ return 1
fi
else
+ if is_interface_up
+ then
+ # At this point we don't know if kernel has brought up network the
+ # way we wanted. It's safer to restart interface and do it on our own...
+ warn_msg "Interface ${GK_NET_IFACE} is already up and therefore in an unknown state!"
+ warn_msg "Will now restart interface ${GK_NET_IFACE} to get into a known state ..."
+ kill_network
+ fi
+
good_msg "Bringing up interface ${GK_NET_IFACE} ..." ${QUIET}
- ip link set "${GK_NET_IFACE}" up
+ run ip link set "${GK_NET_IFACE}" up
good_msg "Setting address '${IP}' on ${GK_NET_IFACE} ..." ${QUIET}
- ip addr add "${IP}" dev "${GK_NET_IFACE}"
+ run ip addr add "${IP}" dev "${GK_NET_IFACE}"
if [ -n "${GK_NET_ROUTES}" ]
then
@@ -1692,25 +2041,25 @@ start_network() {
for route in ${GK_NET_ROUTES}
do
good_msg "Adding additional route '${route}' on ${GK_NET_IFACE} ..." ${QUIET}
- ip route add "${route}" dev "${GK_NET_IFACE}"
+ run ip route add "${route}" dev "${GK_NET_IFACE}"
done
fi
if [ -n "${GK_NET_GW}" ]
then
good_msg "Adding default route via '${GK_NET_GW}' on ${GK_NET_IFACE} ..." ${QUIET}
- ip route add default via "${GK_NET_GW}" dev "${GK_NET_IFACE}"
+ run ip route add default via "${GK_NET_GW}" dev "${GK_NET_IFACE}"
fi
fi
- touch "${GK_NET_LOCKFILE}"
+ run touch "${GK_NET_LOCKFILE}"
}
kill_network() {
if [ -s "${GK_NET_DHCP_PIDFILE}" ]
then
good_msg "Stopping udhcpc ..."
- kill $(cat "${GK_NET_DHCP_PIDFILE}")
+ run kill $(cat "${GK_NET_DHCP_PIDFILE}")
fi
if [ ! -d "/sys/class/net/${GK_NET_IFACE}" ]
@@ -1728,8 +2077,7 @@ kill_network() {
# interface.
if ipv6_tentative
then
- [ -z "${QUIET}" ] && \
- printf "%b" "${WARN}**${NORMAL}${BOLD} Waiting for tentative IPv6 addresses to complete DAD ${NORMAL}..."
+ [ -z "${QUIET}" ] && good_msg_n "Waiting for tentative IPv6 addresses to complete DAD ..."
local dad_timeout=10
while [ ${dad_timeout} -gt 0 ]
@@ -1737,11 +2085,10 @@ kill_network() {
ipv6_tentative || break
sleep 1
: $(( dad_timeout -= 1 ))
- [ -z "${QUIET}" ] && \
- printf "."
+ [ -z "${QUIET}" ] && printf "."
done
- echo ""
+ [ -z "${QUIET}" ] && echo ''
if [ ${dad_timeout} -le 0 ]
then
@@ -1749,26 +2096,24 @@ kill_network() {
fi
fi
- [ -z "${QUIET}" ] && \
- printf "%b" "${GOOD}>>${NORMAL}${BOLD} Bringing down interface ${GK_NET_IFACE} ${NORMAL}..."
+ [ -z "${QUIET}" ] && good_msg_n "Bringing down interface ${GK_NET_IFACE} ..."
local deconfiguration_timeout=${GK_NET_TIMEOUT_DECONFIGURATION}
while [ ${deconfiguration_timeout} -gt 0 ]
do
- ip addr flush dev "${GK_NET_IFACE}"
- ip route flush dev "${GK_NET_IFACE}"
- ip link set "${GK_NET_IFACE}" down
+ run ip addr flush dev "${GK_NET_IFACE}"
+ run ip route flush dev "${GK_NET_IFACE}"
+ run ip link set "${GK_NET_IFACE}" down
if grep -q "down" "/sys/class/net/${GK_NET_IFACE}/operstate" 2>/dev/null
then
break
fi
sleep 1
: $(( deconfiguration_timeout -= 1 ))
- [ -z "${QUIET}" ] && \
- printf "."
+ [ -z "${QUIET}" ] && printf "."
done
- echo ""
+ [ -z "${QUIET}" ] && echo ''
if [ ${deconfiguration_timeout} -le 0 ]
then
@@ -1776,7 +2121,16 @@ kill_network() {
return
fi
- rm "${GK_NET_LOCKFILE}"
+ [ -f "${GK_NET_LOCKFILE}" ] && run rm "${GK_NET_LOCKFILE}"
+}
+
+is_interface_up() {
+ if ip link show dev "${GK_NET_IFACE}" 2>/dev/null | grep -q ',UP,'
+ then
+ return 0
+ else
+ return 1
+ fi
}
ipv6_tentative() {
@@ -1835,6 +2189,12 @@ start_sshd() {
return
fi
+ if [ "${GK_PROMPT_TIMEOUT}" = '0' ]
+ then
+ warn_msg "Changing gk.prompt.timeout=0 to 30 ..."
+ GK_PROMPT_TIMEOUT=30
+ fi
+
if [ ! -x "/usr/sbin/dropbear" ]
then
bad_msg "/usr/sbin/dropbear not found! Did you call genkernel with --ssh parameter?"
@@ -1843,17 +2203,17 @@ start_sshd() {
# setup environment variables for the ssh login shell
local varname= varvalue=
- touch "${CRYPT_ENV_FILE}"
- for varname in CRYPT_ROOT CRYPT_ROOT_TRIM CRYPT_SILENT CRYPT_SWAP DEBUG
+ run touch "${CRYPT_ENV_FILE}"
+ for varname in CRYPT_ROOT CRYPT_ROOT_TRIM CRYPT_SILENT CRYPT_SWAP
do
eval varvalue=\$${varname}
echo "${varname}=${varvalue}" >> "${CRYPT_ENV_FILE}"
done
- touch /var/log/lastlog
+ run touch /var/log/lastlog
good_msg "Starting dropbear sshd ..." ${QUIET}
- /usr/sbin/dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/var/log/dropbear.log
+ run /usr/sbin/dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 2>/var/log/dropbear.log
test_success "Failed to start dropbear"
}
@@ -1868,7 +2228,10 @@ wait_sshd() {
return
fi
- printf "%b" "${GOOD}>>${NORMAL}${BOLD} gk.sshd.wait set; Waiting ${GK_SSHD_WAIT} seconds for SSH connection ${NORMAL}..."
+ good_msg_n "gk.sshd.wait set; Waiting ${GK_SSHD_WAIT} seconds for SSH connection ..."
+
+ local last_cmd="run last -W 2>/dev/null | head -n 3"
+ is_log_enabled && last_cmd="${last_cmd} | tee -a '${GK_INIT_LOG}'"
local ssh_timeout=${GK_SSHD_WAIT}
while [ ${ssh_timeout} -gt 0 ]
@@ -1876,7 +2239,7 @@ wait_sshd() {
if [ -f "${GK_SSHD_LOCKFILE}" ]
then
echo ""
- last -W | head -n 3 2>/dev/null
+ eval "${last_cmd}"
break
fi
sleep 1
@@ -1891,7 +2254,7 @@ kill_sshd() {
if [ -s "${GK_SSHD_PIDFILE}" ]
then
good_msg "Stopping dropbear sshd ..." ${QUIET}
- kill $(cat "${GK_SSHD_PIDFILE}")
+ run kill $(cat "${GK_SSHD_PIDFILE}")
fi
}
@@ -1917,11 +2280,19 @@ cleanup() {
kill_sshd
# Ensure that we terminated any existing connection
- pkill -9 dropbear >/dev/null 2>&1
+ if pgrep dropbear >/dev/null 2>&1
+ then
+ run pkill -9 dropbear >/dev/null 2>&1
+ fi
if [ -f "${GK_NET_LOCKFILE}" ]
then
- kill_network
+ if [ "${REAL_ROOT}" = "/dev/nfs" ]
+ then
+ warn_msg "real_root=/dev/nfs; Will not bring down interface ${GK_NET_IFACE} ..."
+ else
+ kill_network
+ fi
fi
}
@@ -1929,7 +2300,7 @@ sdelay() {
# Sleep a specific number of seconds if SDELAY is set
if [ -n "${SDELAY}" ]
then
- good_msg_n "Waiting ${SDELAY} seconds ..."
+ good_msg_n "scandelay set; Waiting ${SDELAY} seconds ..."
while [ ${SDELAY} -gt 0 ]
do
let SDELAY=${SDELAY}-1
@@ -1945,12 +2316,20 @@ sdelay() {
quiet_kmsg() {
# if QUIET is set make the kernel less chatty
- [ -n "${QUIET}" ] && echo '0' > /proc/sys/kernel/printk
+ if [ -n "${QUIET}" ]
+ then
+ echo '0' > /proc/sys/kernel/printk \
+ && log_msg "COMMAND: 'echo \"0\" > /proc/sys/kernel/printk'"
+ fi
}
verbose_kmsg() {
# if QUIET is set make the kernel less chatty
- [ -n "${QUIET}" ] && echo '6' > /proc/sys/kernel/printk
+ if [ -n "${QUIET}" ]
+ then
+ echo '6' > /proc/sys/kernel/printk \
+ && log_msg "COMMAND: 'echo \"6\" > /proc/sys/kernel/printk'"
+ fi
}
cdupdate() {
@@ -1965,7 +2344,7 @@ cdupdate() {
if [ -n "${cdupdate_path}" ]
then
good_msg "Running cdupdate.sh (${cdupdate_path})"
- ${cdupdate_path}
+ run ${cdupdate_path}
if [ "$?" != '0' ]
then
bad_msg "Executing cdupdate.sh failed!"
@@ -1979,7 +2358,13 @@ cdupdate() {
setup_btrfsctl() {
# start BTRFS volume detection, if available
- [ -x /sbin/btrfsctl ] && /sbin/btrfsctl -a
+ if [ -x /sbin/btrfsctl ]
+ then
+ local btrfs_cmd="run /sbin/btrfsctl -a 2>&1"
+ is_log_enabled && btrfs_cmd="${btrfs_cmd} | tee -a '${GK_INIT_LOG}'"
+
+ eval "${btrfs_cmd}"
+ fi
}
setup_md_device() {
@@ -1994,20 +2379,23 @@ setup_md_device() {
MD_NUMBER=$(echo ${device}|sed -e 's#\(luks:\)\?/dev/md\([[:digit:]]\+\)#\2#')
if [ ! -e /dev/md${MD_NUMBER} ]
then
- mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1
+ run mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1
[ $? -ne 0 ] && bad_msg "Creation of /dev/md${MD_NUMBER} failed ..."
fi
- mdstart ${MDPART} /dev/md${MD_NUMBER}
+ run raidautorun /dev/md${MD_NUMBER}
fi
}
rundebugshell() {
- if [ -n "${DEBUG}" ]
+ if is_debug
then
good_msg 'Starting debug shell as requested by "debug" option.'
- good_msg "Stopping by: ${1}"
- run_shell
+ else
+ return 0
fi
+
+ good_msg "Stopping by: ${1}"
+ run_shell
}
do_resume() {
@@ -2113,16 +2501,16 @@ setup_squashfs_aufs() {
for dir in ${aufs_rw_branch} ${aufs_ro_branch}
do
- [ ! -d "${dir}" ] && mkdir -p "${dir}"
+ [ ! -d "${dir}" ] && run mkdir -p "${dir}"
done
good_msg "Loading aufs module ..."
- modprobe aufs >/dev/null 2>&1
+ run modprobe aufs >/dev/null 2>&1
checkfs aufs
- mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${aufs_ro_branch}"
- mount -t tmpfs none "${aufs_rw_branch}"
- mount -t aufs -o "br:${aufs_rw_branch}:${aufs_ro_branch}" aufs "${NEW_ROOT}"
+ run mount -t squashfs -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${aufs_ro_branch}"
+ run mount -t tmpfs none "${aufs_rw_branch}"
+ run mount -t aufs -o "br:${aufs_rw_branch}:${aufs_ro_branch}" aufs "${NEW_ROOT}"
}
setup_unionfs() {
@@ -2141,9 +2529,9 @@ setup_unionfs() {
# fi
# mkdir -p ${MEMORY}
- mkdir -p ${UNION}
+ run mkdir -p ${UNION}
good_msg "Loading fuse module"
- modprobe fuse >/dev/null 2>&1
+ run modprobe fuse >/dev/null 2>&1
# if [ -n "${UNIONFS}" ]
# then
# CHANGESDEV=${UNIONFS}
@@ -2170,12 +2558,12 @@ setup_unionfs() {
# mount -t tmpfs tmpfs ${MEMORY}
# fi
- mkdir /tmp
- mkdir -p ${UNION}
+ run mkdir /tmp
+ run mkdir -p ${UNION}
# mkdir -p ${CHANGES}
# mount -t unionfs -o dirs=${CHANGES}=rw unionfs ${UNION}
good_msg "Creating union mount"
- unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null
+ run unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null
ret=$?
if [ ${ret} -ne 0 ]
then
@@ -2183,7 +2571,7 @@ setup_unionfs() {
USE_UNIONFS_NORMAL=0
fi
[ ! -d "${NEW_ROOT}${CDROOT_PATH}" ] && mkdir -p "${NEW_ROOT}${CDROOT_PATH}"
- mount --bind "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}"
+ run mount --bind "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}"
else
USE_UNIONFS_NORMAL=0
fi
diff --git a/defaults/keymaps/10.map b/defaults/keymaps/10.map
index 9f72389..0da9af3 120000
--- a/defaults/keymaps/10.map
+++ b/defaults/keymaps/10.map
@@ -1 +1 @@
-de.map \ No newline at end of file
+croat.map \ No newline at end of file
diff --git a/defaults/keymaps/11.map b/defaults/keymaps/11.map
index bceb1bd..cc77cf9 120000
--- a/defaults/keymaps/11.map
+++ b/defaults/keymaps/11.map
@@ -1 +1 @@
-dk.map \ No newline at end of file
+cz.map \ No newline at end of file
diff --git a/defaults/keymaps/12.map b/defaults/keymaps/12.map
index 451cc56..9f72389 120000
--- a/defaults/keymaps/12.map
+++ b/defaults/keymaps/12.map
@@ -1 +1 @@
-dvorak.map \ No newline at end of file
+de.map \ No newline at end of file
diff --git a/defaults/keymaps/13.map b/defaults/keymaps/13.map
index 168fab9..bceb1bd 120000
--- a/defaults/keymaps/13.map
+++ b/defaults/keymaps/13.map
@@ -1 +1 @@
-es.map \ No newline at end of file
+dk.map \ No newline at end of file
diff --git a/defaults/keymaps/14.map b/defaults/keymaps/14.map
index 3d123bb..451cc56 120000
--- a/defaults/keymaps/14.map
+++ b/defaults/keymaps/14.map
@@ -1 +1 @@
-et.map \ No newline at end of file
+dvorak.map \ No newline at end of file
diff --git a/defaults/keymaps/15.map b/defaults/keymaps/15.map
index 066af66..168fab9 120000
--- a/defaults/keymaps/15.map
+++ b/defaults/keymaps/15.map
@@ -1 +1 @@
-fi.map \ No newline at end of file
+es.map \ No newline at end of file
diff --git a/defaults/keymaps/16.map b/defaults/keymaps/16.map
index 80c93fe..3d123bb 120000
--- a/defaults/keymaps/16.map
+++ b/defaults/keymaps/16.map
@@ -1 +1 @@
-fr.map \ No newline at end of file
+et.map \ No newline at end of file
diff --git a/defaults/keymaps/17.map b/defaults/keymaps/17.map
index 8a051ab..066af66 120000
--- a/defaults/keymaps/17.map
+++ b/defaults/keymaps/17.map
@@ -1 +1 @@
-gr.map \ No newline at end of file
+fi.map \ No newline at end of file
diff --git a/defaults/keymaps/18.map b/defaults/keymaps/18.map
index 9474d62..80c93fe 120000
--- a/defaults/keymaps/18.map
+++ b/defaults/keymaps/18.map
@@ -1 +1 @@
-hu.map \ No newline at end of file
+fr.map \ No newline at end of file
diff --git a/defaults/keymaps/19.map b/defaults/keymaps/19.map
index d590003..8a051ab 120000
--- a/defaults/keymaps/19.map
+++ b/defaults/keymaps/19.map
@@ -1 +1 @@
-il.map \ No newline at end of file
+gr.map \ No newline at end of file
diff --git a/defaults/keymaps/20.map b/defaults/keymaps/20.map
index 7727bac..9474d62 120000
--- a/defaults/keymaps/20.map
+++ b/defaults/keymaps/20.map
@@ -1 +1 @@
-is.map \ No newline at end of file
+hu.map \ No newline at end of file
diff --git a/defaults/keymaps/21.map b/defaults/keymaps/21.map
index d678e48..d590003 120000
--- a/defaults/keymaps/21.map
+++ b/defaults/keymaps/21.map
@@ -1 +1 @@
-it.map \ No newline at end of file
+il.map \ No newline at end of file
diff --git a/defaults/keymaps/22.map b/defaults/keymaps/22.map
index 60e7d65..7727bac 120000
--- a/defaults/keymaps/22.map
+++ b/defaults/keymaps/22.map
@@ -1 +1 @@
-jp.map \ No newline at end of file
+is.map \ No newline at end of file
diff --git a/defaults/keymaps/23.map b/defaults/keymaps/23.map
index d1a9079..d678e48 120000
--- a/defaults/keymaps/23.map
+++ b/defaults/keymaps/23.map
@@ -1 +1 @@
-la.map \ No newline at end of file
+it.map \ No newline at end of file
diff --git a/defaults/keymaps/24.map b/defaults/keymaps/24.map
index fbb0b72..60e7d65 120000
--- a/defaults/keymaps/24.map
+++ b/defaults/keymaps/24.map
@@ -1 +1 @@
-lt.map \ No newline at end of file
+jp.map \ No newline at end of file
diff --git a/defaults/keymaps/25.map b/defaults/keymaps/25.map
index f2533fb..d1a9079 120000
--- a/defaults/keymaps/25.map
+++ b/defaults/keymaps/25.map
@@ -1 +1 @@
-mk.map \ No newline at end of file
+la.map \ No newline at end of file
diff --git a/defaults/keymaps/26.map b/defaults/keymaps/26.map
index 2761f4d..fbb0b72 120000
--- a/defaults/keymaps/26.map
+++ b/defaults/keymaps/26.map
@@ -1 +1 @@
-nl.map \ No newline at end of file
+lt.map \ No newline at end of file
diff --git a/defaults/keymaps/27.map b/defaults/keymaps/27.map
index b035af9..f2533fb 120000
--- a/defaults/keymaps/27.map
+++ b/defaults/keymaps/27.map
@@ -1 +1 @@
-no.map \ No newline at end of file
+mk.map \ No newline at end of file
diff --git a/defaults/keymaps/28.map b/defaults/keymaps/28.map
index fbd6e21..2761f4d 120000
--- a/defaults/keymaps/28.map
+++ b/defaults/keymaps/28.map
@@ -1 +1 @@
-pl.map \ No newline at end of file
+nl.map \ No newline at end of file
diff --git a/defaults/keymaps/29.map b/defaults/keymaps/29.map
index 7978523..b035af9 120000
--- a/defaults/keymaps/29.map
+++ b/defaults/keymaps/29.map
@@ -1 +1 @@
-pt.map \ No newline at end of file
+no.map \ No newline at end of file
diff --git a/defaults/keymaps/3.map b/defaults/keymaps/3.map
index 63107de..b9efb65 120000
--- a/defaults/keymaps/3.map
+++ b/defaults/keymaps/3.map
@@ -1 +1 @@
-bg.map \ No newline at end of file
+bepo.map \ No newline at end of file
diff --git a/defaults/keymaps/30.map b/defaults/keymaps/30.map
index a51e4db..fbd6e21 120000
--- a/defaults/keymaps/30.map
+++ b/defaults/keymaps/30.map
@@ -1 +1 @@
-ro.map \ No newline at end of file
+pl.map \ No newline at end of file
diff --git a/defaults/keymaps/31.map b/defaults/keymaps/31.map
index c23004d..7978523 120000
--- a/defaults/keymaps/31.map
+++ b/defaults/keymaps/31.map
@@ -1 +1 @@
-ru.map \ No newline at end of file
+pt.map \ No newline at end of file
diff --git a/defaults/keymaps/32.map b/defaults/keymaps/32.map
index 7b5cb3f..a51e4db 120000
--- a/defaults/keymaps/32.map
+++ b/defaults/keymaps/32.map
@@ -1 +1 @@
-se.map \ No newline at end of file
+ro.map \ No newline at end of file
diff --git a/defaults/keymaps/33.map b/defaults/keymaps/33.map
index b510287..c23004d 120000
--- a/defaults/keymaps/33.map
+++ b/defaults/keymaps/33.map
@@ -1 +1 @@
-sg.map \ No newline at end of file
+ru.map \ No newline at end of file
diff --git a/defaults/keymaps/34.map b/defaults/keymaps/34.map
index f6cb818..7b5cb3f 120000
--- a/defaults/keymaps/34.map
+++ b/defaults/keymaps/34.map
@@ -1 +1 @@
-sk-y.map \ No newline at end of file
+se.map \ No newline at end of file
diff --git a/defaults/keymaps/35.map b/defaults/keymaps/35.map
index d2429bb..a0cb60e 120000
--- a/defaults/keymaps/35.map
+++ b/defaults/keymaps/35.map
@@ -1 +1 @@
-sk-z.map \ No newline at end of file
+sf.map \ No newline at end of file
diff --git a/defaults/keymaps/36.map b/defaults/keymaps/36.map
index e8d5b5f..b510287 120000
--- a/defaults/keymaps/36.map
+++ b/defaults/keymaps/36.map
@@ -1 +1 @@
-slovene.map \ No newline at end of file
+sg.map \ No newline at end of file
diff --git a/defaults/keymaps/37.map b/defaults/keymaps/37.map
index e76e565..f6cb818 120000
--- a/defaults/keymaps/37.map
+++ b/defaults/keymaps/37.map
@@ -1 +1 @@
-trf.map \ No newline at end of file
+sk-y.map \ No newline at end of file
diff --git a/defaults/keymaps/38.map b/defaults/keymaps/38.map
new file mode 120000
index 0000000..d2429bb
--- /dev/null
+++ b/defaults/keymaps/38.map
@@ -0,0 +1 @@
+sk-z.map \ No newline at end of file
diff --git a/defaults/keymaps/39.map b/defaults/keymaps/39.map
index 3e8aa5b..e8d5b5f 120000
--- a/defaults/keymaps/39.map
+++ b/defaults/keymaps/39.map
@@ -1 +1 @@
-ua.map \ No newline at end of file
+slovene.map \ No newline at end of file
diff --git a/defaults/keymaps/4.map b/defaults/keymaps/4.map
index 1c53a25..63107de 120000
--- a/defaults/keymaps/4.map
+++ b/defaults/keymaps/4.map
@@ -1 +1 @@
-br-a.map \ No newline at end of file
+bg.map \ No newline at end of file
diff --git a/defaults/keymaps/40.map b/defaults/keymaps/40.map
index 0eca050..e76e565 120000
--- a/defaults/keymaps/40.map
+++ b/defaults/keymaps/40.map
@@ -1 +1 @@
-uk.map \ No newline at end of file
+trf.map \ No newline at end of file
diff --git a/defaults/keymaps/41.map b/defaults/keymaps/41.map
index 2a3add6..3e8aa5b 120000
--- a/defaults/keymaps/41.map
+++ b/defaults/keymaps/41.map
@@ -1 +1 @@
-us.map \ No newline at end of file
+ua.map \ No newline at end of file
diff --git a/defaults/keymaps/42.map b/defaults/keymaps/42.map
index c800071..0eca050 120000
--- a/defaults/keymaps/42.map
+++ b/defaults/keymaps/42.map
@@ -1 +1 @@
-wangbe.map \ No newline at end of file
+uk.map \ No newline at end of file
diff --git a/defaults/keymaps/43.map b/defaults/keymaps/43.map
index a0cb60e..2a3add6 120000
--- a/defaults/keymaps/43.map
+++ b/defaults/keymaps/43.map
@@ -1 +1 @@
-sf.map \ No newline at end of file
+us.map \ No newline at end of file
diff --git a/defaults/keymaps/44.map b/defaults/keymaps/44.map
new file mode 120000
index 0000000..c800071
--- /dev/null
+++ b/defaults/keymaps/44.map
@@ -0,0 +1 @@
+wangbe.map \ No newline at end of file
diff --git a/defaults/keymaps/5.map b/defaults/keymaps/5.map
index 171e281..1c53a25 120000
--- a/defaults/keymaps/5.map
+++ b/defaults/keymaps/5.map
@@ -1 +1 @@
-br-l.map \ No newline at end of file
+br-a.map \ No newline at end of file
diff --git a/defaults/keymaps/6.map b/defaults/keymaps/6.map
index daaf368..171e281 120000
--- a/defaults/keymaps/6.map
+++ b/defaults/keymaps/6.map
@@ -1 +1 @@
-by.map \ No newline at end of file
+br-l.map \ No newline at end of file
diff --git a/defaults/keymaps/7.map b/defaults/keymaps/7.map
index d233aed..daaf368 120000
--- a/defaults/keymaps/7.map
+++ b/defaults/keymaps/7.map
@@ -1 +1 @@
-cf.map \ No newline at end of file
+by.map \ No newline at end of file
diff --git a/defaults/keymaps/8.map b/defaults/keymaps/8.map
index 0da9af3..d233aed 120000
--- a/defaults/keymaps/8.map
+++ b/defaults/keymaps/8.map
@@ -1 +1 @@
-croat.map \ No newline at end of file
+cf.map \ No newline at end of file
diff --git a/defaults/keymaps/9.map b/defaults/keymaps/9.map
index cc77cf9..cc3ef87 120000
--- a/defaults/keymaps/9.map
+++ b/defaults/keymaps/9.map
@@ -1 +1 @@
-cz.map \ No newline at end of file
+colemak.map \ No newline at end of file
diff --git a/defaults/keymaps/bepo.map b/defaults/keymaps/bepo.map
new file mode 100644
index 0000000..ee0ef15
--- /dev/null
+++ b/defaults/keymaps/bepo.map
Binary files differ
diff --git a/defaults/keymaps/colemak.map b/defaults/keymaps/colemak.map
new file mode 100644
index 0000000..ee0ef15
--- /dev/null
+++ b/defaults/keymaps/colemak.map
Binary files differ
diff --git a/defaults/keymaps/keymapList b/defaults/keymaps/keymapList
index 4ad3721..f46ff0a 100644
--- a/defaults/keymaps/keymapList
+++ b/defaults/keymaps/keymapList
@@ -1,10 +1,10 @@
Please select a keymap from the following list by typing in the appropriate
-name or number. Hit Enter for the default "us/41" US English keymap.
+name or number. Hit Enter for the default "us/43" US English keymap.
- 1 azerty 8 croat 15 fi 22 jp 29 pt 36 slovene 43 sf
- 2 be 9 cz 16 fr 23 la 30 ro 37 trf
- 3 bg 10 de 17 gr 24 lt 31 ru 38 --
- 4 br-a 11 dk 18 hu 25 mk 32 se 39 ua
- 5 br-l 12 dvorak 19 il 26 nl 33 sg 40 uk
- 6 by 13 es 20 is 27 no 34 sk-y 41 us
- 7 cf 14 et 21 it 28 pl 35 sk-z 42 wangbe
+ 1 azerty 8 cf 15 es 22 is 29 no 36 sg 43 us
+ 2 be 9 colemak 16 et 23 it 30 pl 37 sk-y 44 wangbe
+ 3 bepo 10 croat 17 fi 24 jp 31 pt 38 sk-z
+ 4 bg 11 cz 18 fr 25 la 32 ro 39 slovene
+ 5 br-a 12 de 19 gr 26 lt 33 ru 40 trf
+ 6 br-l 13 dk 20 hu 27 mk 34 se 41 ua
+ 7 by 14 dvorak 21 il 28 nl 35 sf 42 uk
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 41a53fc..c0d4c0d 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -3,13 +3,21 @@
. /etc/initrd.defaults
. /etc/initrd.scripts
-splash() {
- return 0
-}
-
[ -e /etc/initrd.splash ] && . /etc/initrd.splash
-# Clean input/output
+# Basic /dev content, we need it as fast as possible.
+[ ! -e /dev/console ] && mknod /dev/console c 5 1
+[ ! -e /dev/null ] && mknod /dev/null c 1 3
+[ ! -e /dev/tty ] && mknod /dev/tty c 5 0
+[ ! -e /dev/tty0 ] && mknod /dev/tty0 c 4 0
+[ ! -e /dev/tty1 ] && mknod /dev/tty1 c 4 1
+[ ! -e /dev/ttyS0 ] && mknod /dev/ttyS0 c 4 64
+[ ! -e /dev/ttyS1 ] && mknod /dev/ttyS1 c 4 65
+[ ! -e /dev/urandom ] && mknod /dev/urandom c 1 9
+[ ! -e /dev/random ] && mknod /dev/random c 1 8
+[ ! -e /dev/zero ] && mknod /dev/zero c 1 5
+
+# Take control
exec >${CONSOLE} <${CONSOLE} 2>&1
if [ "$$" != '1' ]
@@ -20,7 +28,7 @@ then
exit 1
fi
-mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1
+run mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1
mount -o remount,rw / >/dev/null 2>&1
# Prevent superfluous printks from being printed to the console
@@ -29,11 +37,11 @@ echo 1 > /proc/sys/kernel/printk
if [ ! -s /etc/ld.so.cache ]
then
# Looks like we were unable to run ldconfig during initramfs generation
- [ -x /sbin/ldconfig ] && /sbin/ldconfig
+ [ -x /sbin/ldconfig ] && run /sbin/ldconfig
fi
# Set up symlinks
-/bin/busybox --install -s
+run /bin/busybox --install -s
gk_ver="$(cat /etc/build_id)"
gk_build_date="$(cat /etc/build_date)"
@@ -43,7 +51,7 @@ good_msg "${gk_ver} (${gk_build_date}). Linux kernel ${kernel_ver}"
if [ "$0" = '/init' ]
then
- [ -e /linuxrc ] && rm /linuxrc
+ [ -e /linuxrc ] && run rm /linuxrc
fi
CMDLINE=$(cat /proc/cmdline)
@@ -55,7 +63,7 @@ ROOTFSTYPE='auto'
CRYPT_SILENT=0
QUIET=''
-mkdir -p /etc/cmdline /etc/modprobe.d
+run mkdir -p /etc/cmdline /etc/modprobe.d
for x in ${CMDLINE}
do
case "${x}" in
@@ -118,6 +126,7 @@ do
;;
dozfs*)
USE_ZFS=1
+ export ZPOOL_IMPORT_UDEV_TIMEOUT_MS=0
case "${x#*=}" in
*force*)
@@ -147,7 +156,7 @@ do
;;
# Debug Options
debug)
- DEBUG='yes'
+ run touch "${GK_DEBUGMODE_STATEFILE}"
;;
# Scan delay options
scandelay=*)
@@ -178,9 +187,9 @@ do
;;
# Redirect output to a specific tty
CONSOLE=*|console=*)
- CONSOLE=${x#*=}
- CONSOLE=$(basename ${CONSOLE})
-# exec >${CONSOLE} <${CONSOLE} 2>&1
+ NEW_CONSOLE=${x#*=}
+ NEW_CONSOLE=$(basename ${NEW_CONSOLE})
+ NEW_CONSOLE=${NEW_CONSOLE%%,*}
;;
# /dev/md
lvmraid=*)
@@ -267,6 +276,47 @@ do
dosshd)
USE_SSH=1
;;
+ gk.log.disabled=*)
+ tmp_disabled=${x#*=}
+ if is_true "${tmp_disabled}"
+ then
+ [ -f "${GK_INIT_LOG}" ] && rm "${GK_INIT_LOG}"
+ GK_INIT_LOG=
+ touch "${GK_INIT_LOG_DISABLED}"
+ fi
+ unset tmp_disabled
+ ;;
+ gk.log.keep=*)
+ case "${x#*=}" in
+ [Tt][Rr][Uu][Ee])
+ GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
+ ;;
+ [Yy][Ee][Ss])
+ GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
+ ;;
+ [Yy])
+ GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
+ ;;
+ 1)
+ GK_INIT_LOG_COPYTO="${GK_INIT_LOG_COPYTO_DEFAULT}"
+ ;;
+ [Ff][Aa][Ll][Ss][Ee])
+ GK_INIT_LOG_COPYTO=
+ ;;
+ [Nn][Oo])
+ GK_INIT_LOG_COPYTO=
+ ;;
+ [Nn])
+ GK_INIT_LOG_COPYTO=
+ ;;
+ 0)
+ GK_INIT_LOG_COPYTO=
+ ;;
+ *)
+ GK_INIT_LOG_COPYTO=${x#*=}
+ ;;
+ esac
+ ;;
gk.sshd.port=*)
tmp_port=${x#*=}
if is_int "${tmp_port}"
@@ -287,6 +337,16 @@ do
fi
unset tmp_wait
;;
+ gk.prompt.timeout=*)
+ tmp_timeout=${x#*=}
+ if is_int "${tmp_timeout}"
+ then
+ GK_PROMPT_TIMEOUT=${tmp_timeout}
+ else
+ warn_msg "'${x}' does not look like a valid time (second) value -- ignored!"
+ fi
+ unset tmp_timeout
+ ;;
real_rootflags=*)
REAL_ROOTFLAGS=${x#*=}
;;
@@ -356,6 +416,21 @@ do
esac
done
+if [ -n "${NEW_CONSOLE}" ]
+then
+ # We cannot update console while processing CMDLINE because we
+ # are only interested in last console= value.
+ [ ! -c "${NEW_CONSOLE}" ] && NEW_CONSOLE="/dev/${NEW_CONSOLE}"
+ if [ -c "${NEW_CONSOLE}" ]
+ then
+ exec >${NEW_CONSOLE} <${NEW_CONSOLE} 2>&1
+ good_msg "Console switched from '${CONSOLE}' to '${NEW_CONSOLE}'!"
+ CONSOLE="${NEW_CONSOLE}"
+ else
+ bad_msg "Unable to switch console: '${NEW_CONSOLE}' not found or not a character device!"
+ fi
+fi
+
quiet_kmsg
if [ "${CDROOT}" = '0' ]
@@ -419,14 +494,15 @@ mount_devfs
mount_sysfs
# Initialize mdev
-good_msg 'Activating mdev'
+good_msg 'Activating mdev ...'
# Serialize hotplug events
-touch /dev/mdev.seq
+run touch /dev/mdev.seq
# Setup hotplugging for firmware loading
if [ -f "/proc/sys/kernel/hotplug" ]
then
+ log_msg "COMMAND: 'echo /sbin/mdev > /proc/sys/kernel/hotplug'"
echo /sbin/mdev > /proc/sys/kernel/hotplug
fi
@@ -436,7 +512,7 @@ then
good_msg 'Skipping module load; disabled via commandline'
elif [ -d "/lib/modules/${KV}" ]
then
- good_msg 'Loading modules'
+ good_msg 'Loading modules ...'
if [ -n "${FIRSTMODS}" ]
then
# try these modules first -- detected modules for root device:
@@ -458,7 +534,7 @@ else
fi
# Ensure that device nodes are properly configured
-mdev -s || bad_msg "mdev -s failed"
+run mdev -s || bad_msg "mdev -s failed"
cd /
@@ -538,7 +614,7 @@ then
fi
fi
-mkdir -p "${NEW_ROOT}"
+run mkdir -p "${NEW_ROOT}"
CHROOT="${NEW_ROOT}"
# Run debug shell if requested
@@ -580,12 +656,12 @@ then
if [ "${REAL_ROOT}" = '' ] && [ "${got_good_root}" != '1' ]
then
# Undo stuff
- umount "${NEW_ROOT}/dev" 2>/dev/null
- umount "${NEW_ROOT}/sys" 2>/dev/null
- umount /sys 2>/dev/null
+ run umount "${NEW_ROOT}/dev" 2>/dev/null
+ run umount "${NEW_ROOT}/sys" 2>/dev/null
+ run umount /sys 2>/dev/null
- umount "${NEW_ROOT}"
- rm -rf "${NEW_ROOT}/*"
+ run umount "${NEW_ROOT}"
+ run rm -rf "${NEW_ROOT}/*"
bad_msg 'Could not find CD to boot, something else needed!'
CDROOT=0
@@ -598,7 +674,7 @@ ROOTDELAY_TIME_WAITED=0
[ -n "${ROOTDELAY}" -a ${ROOTDELAY} -gt 0 ] && let ROOTDELAY_TIMEOUT=${ROOTDELAY_TIMEOUT}+${ROOTDELAY}-1
while true
do
- good_msg_n 'Determining root device ...'
+ good_msg_n "Determining root device (trying ${REAL_ROOT}) ..."
while [ "${got_good_root}" != '1' ]
do
@@ -627,7 +703,7 @@ do
got_good_root=1
REAL_ROOT="${ROOT_DEV}"
echo
- good_msg "Detected real_root=${ROOT_DEV}"
+ good_msg "Root device detected as ${REAL_ROOT}!"
break
fi
;;
@@ -641,20 +717,20 @@ do
ROOT_DEV="${REAL_ROOT#*=}"
if [ "${ROOT_DEV}" != 'ZFS' ]
then
- if [ "$(zfs get type -o value -H ${ROOT_DEV})" = 'filesystem' ]
+ if [ "$(zfs get type -o value -H ${ROOT_DEV} 2>/dev/null)" = 'filesystem' ]
then
got_good_root=1
REAL_ROOT=${ROOT_DEV}
ROOTFSTYPE=zfs
echo
- good_msg "Detected real_root=${ROOT_DEV}"
+ good_msg "Root device detected as ${REAL_ROOT}!"
break
else
bad_msg "${ROOT_DEV} is not a filesystem"
continue
fi
else
- BOOTFS=$(/sbin/zpool list -H -o bootfs)
+ BOOTFS=$(/sbin/zpool list -H -o bootfs 2>/dev/null)
if [ "${BOOTFS}" != '-' ]
then
for i in ${BOOTFS}
@@ -666,7 +742,7 @@ do
REAL_ROOT=${i}
ROOTFSTYPE=zfs
echo
- good_msg "Detected real_root=${ROOT_DEV}"
+ good_msg "Root device detected as ${REAL_ROOT}!"
break
fi
done
@@ -678,7 +754,7 @@ do
then
got_good_root=1
echo
- good_msg "Detected real_root=${REAL_ROOT}"
+ good_msg "Root device detected as ${REAL_ROOT}!"
break
fi
;;
@@ -709,10 +785,10 @@ do
then
# at this point we determined dataset and are ready to mount
# let's check if this dataset is encrypted and ask for passphrase
- if [ "$(zpool list -H -o feature@encryption "${REAL_ROOT%%/*}")" = 'active' ]
+ if [ "$(zpool list -H -o feature@encryption "${REAL_ROOT%%/*}" 2>/dev/null)" = 'active' ]
then
- ZFS_KEYSTATUS="$(zfs get -H -o value keystatus "${REAL_ROOT}")"
- ZFS_ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${REAL_ROOT}")"
+ ZFS_KEYSTATUS="$(zfs get -H -o value keystatus "${REAL_ROOT}" 2>/dev/null)"
+ ZFS_ENCRYPTIONROOT="$(zfs get -H -o value encryptionroot "${REAL_ROOT}" 2>/dev/null)"
if ! [ "${ZFS_ENCRYPTIONROOT}" = '-' ] || [ "${ZFS_KEYSTATUS}" = 'available' ]
then
good_msg "Detected ZFS encryption, asking for key"
@@ -773,11 +849,11 @@ do
if [ "${REAL_ROOTFLAGS}" = '' ]
then
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}"
- mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}
+ run mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}
mountret=$?
else
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}"
- mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
+ run mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
mountret=$?
fi
fi
@@ -829,7 +905,7 @@ do
then
if mountpoint "${NEW_ROOT}" 1>/dev/null 2>&1
then
- umount "${NEW_ROOT}" 1>/dev/null 2>&1
+ run umount "${NEW_ROOT}" 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
echo
@@ -847,8 +923,6 @@ do
done
# End determine root device
-#verbose_kmsg
-
# If CD root is set determine the looptype to boot
if [ "${CDROOT}" = '1' ]
then
@@ -881,7 +955,7 @@ then
MOUNTTYPE="${LOOPTYPE}"
;;
esac
- mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"
+ run mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"
test_success 'Mount filesystem'
FS_LOCATION='mnt/livecd'
# Setup the loopback mounts, if unencrypted
@@ -889,7 +963,7 @@ then
if [ "${LOOPTYPE}" = 'normal' ]
then
good_msg 'Mounting loop filesystem'
- mount -t ext2 -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
+ run mount -t ext2 -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
test_success 'Mount filesystem'
FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'squashfs' ]
@@ -928,7 +1002,7 @@ then
echo ' ' | losetup -E 19 -e ucl-0 -p0 "${NEW_ROOT}/dev/loop0" "${CDROOT_PATH}/${LOOPEXT}${LOOP}"
test_success 'losetup the loop device'
- mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd"
+ run mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd"
test_success 'Mount the losetup loop device'
FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'zisofs' ]
@@ -956,7 +1030,7 @@ then
test_success 'losetup /dev/sr0 /dev/loop0'
good_msg 'Mounting the Root Partition'
- mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd"
+ run mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd"
test_success 'mount /dev/loop0 /'
FS_LOCATION='mnt/livecd'
fi
@@ -974,7 +1048,7 @@ then
then
for dir in /var/tmp /tmp
do
- [ ! -d ${CHROOT}${dir} ] && mkdir -p "${CHROOT}${dir}"
+ [ ! -d ${CHROOT}${dir} ] && run mkdir -p "${CHROOT}${dir}"
done
cat > "${CHROOT}/etc/fstab" << FSTAB
@@ -997,8 +1071,8 @@ FSTAB
# Check to see if we successfully mounted $aufs_dev
if [ -n "${aufs_dev}" ] && grep ${aufs_dev} /etc/mtab 1>/dev/null
then
- [ ! -d ${CHROOT}${aufs_dev_mnt} ] && mkdir -p "${CHROOT}${aufs_dev_mnt}"
- mount --move "${aufs_dev_mnt}" "${CHROOT}${aufs_dev_mnt}"
+ [ ! -d ${CHROOT}${aufs_dev_mnt} ] && run mkdir -p "${CHROOT}${aufs_dev_mnt}"
+ run mount --move "${aufs_dev_mnt}" "${CHROOT}${aufs_dev_mnt}"
fi
fi
@@ -1088,10 +1162,10 @@ FSTAB
if [ "${aufs}" = '1' ]
then
[ ! -d "${CHROOT}${CDROOT_PATH}" ] && mkdir "${CHROOT}${CDROOT_PATH}"
- mount --move "${CDROOT_PATH}" "${CHROOT}${CDROOT_PATH}"
+ run mount --move "${CDROOT_PATH}" "${CHROOT}${CDROOT_PATH}"
else
[ ! -d "${NEW_ROOT}${CDROOT_PATH}" ] && mkdir -p "${NEW_ROOT}${CDROOT_PATH}"
- mount --move "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}"
+ run mount --move "${CDROOT_PATH}" "${NEW_ROOT}${CDROOT_PATH}"
fi
# Let Init scripts know that we booted from CD
@@ -1100,14 +1174,14 @@ FSTAB
else
if [ "${USE_UNIONFS_NORMAL}" = '1' ]
then
- mkdir /union_changes
- mount -t tmpfs tmpfs /union_changes
+ run mkdir /union_changes
+ run mount -t tmpfs tmpfs /union_changes
setup_unionfs /union_changes ${NEW_ROOT}
- mkdir -p ${UNION}/tmp/.initrd
+ run mkdir -p ${UNION}/tmp/.initrd
elif [ "${aufs}" = '1' ]
then
aufs_insert_dir "${aufs_union}" "${NEW_ROOT}"
- mkdir -p "${aufs_union}/tmp/.initrd"
+ run mkdir -p "${aufs_union}/tmp/.initrd"
fi
fi # if [ "${CDROOT}" = '1' ]
@@ -1161,19 +1235,19 @@ if [ "${aufs}" = '1' ]
then
aufs_union_memory=${CHROOT}/.unions/memory
- mkdir -p "${aufs_union_memory}"
- mount --move "${aufs_memory}" "${aufs_union_memory}"
+ run mkdir -p "${aufs_union_memory}"
+ run mount --move "${aufs_memory}" "${aufs_union_memory}"
test_success "Failed to move aufs ${aufs_memory} into the system root"
for dir in /mnt/gentoo ${aufs_rw_branch} ${aufs_ro_branch}
do
- mkdir -p "${CHROOT}${dir}"
- chmod 755 "${CHROOT}${dir}"
+ run mkdir -p "${CHROOT}${dir}"
+ run chmod 755 "${CHROOT}${dir}"
done
for mount in ${aufs_rw_branch} ${aufs_ro_branch}
do
- mount --move "${mount}" "${CHROOT}${mount}"
+ run mount --move "${mount}" "${CHROOT}${mount}"
done
fi
@@ -1190,11 +1264,6 @@ fi
cleanup
-good_msg "Booting (initramfs)"
-
-cd "${CHROOT}"
-mkdir "${CHROOT}/proc" "${CHROOT}/sys" "${CHROOT}/run" 2>/dev/null
-
# If devtmpfs is mounted, try move it to the new root
# If that fails, try to unmount all possible mounts of
# devtmpfs as stuff breaks otherwise
@@ -1202,9 +1271,9 @@ for fs in /dev /sys /proc
do
if grep -qs "${fs}" /proc/mounts
then
- if ! mount -o move ${fs} "${CHROOT}"${fs}
+ if ! run mount -o move ${fs} "${CHROOT}"${fs}
then
- umount ${fs} || \
+ run umount ${fs} || \
bad_msg "Failed to move and unmount the ramdisk ${fs}!"
fi
fi
@@ -1221,6 +1290,8 @@ fi
# Run debug shell if requested
rundebugshell "before entering switch_root"
+preserve_log
+
# init_opts is set in the environment by the kernel when it parses the command line
init=${REAL_INIT:-/sbin/init}
if ! mountpoint "${CHROOT}" 1>/dev/null 2>&1
diff --git a/defaults/login-remote.sh b/defaults/login-remote.sh
index 7f711da..588504f 100644
--- a/defaults/login-remote.sh
+++ b/defaults/login-remote.sh
@@ -5,12 +5,22 @@
. /etc/initrd.scripts
. "${CRYPT_ENV_FILE}"
-splash() {
- return 0
-}
-
[ -e /etc/initrd.splash ] && . /etc/initrd.splash
+GK_INIT_LOG_PREFIX=${0}
+if [ -n "${SSH_CLIENT}" ]
+then
+ SSH_CLIENT_IP=$(echo "${SSH_CLIENT}" | awk '{ print $1 }')
+ SSH_CLIENT_PORT=$(echo "${SSH_CLIENT}" | awk '{ print $2 }')
+
+ if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ]
+ then
+ GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]"
+ export SSH_CLIENT_IP
+ export SSH_CLIENT_PORT
+ fi
+fi
+
receivefile() {
case ${1} in
root)
@@ -19,31 +29,31 @@ receivefile() {
swap)
file=${CRYPT_KEYFILE_SWAP}
;;
+ '')
+ bad_msg "No keyfile specified." "${CRYPT_SILENT}"
+ exit 1
+ ;;
*)
- bad_msg "Unknown '${1}' keyfile received." ${CRYPT_SILENT}
+ bad_msg "Unknown '${1}' keyfile received." "${CRYPT_SILENT}"
exit 1
;;
esac
# limit maximum stored bytes to 1M to avoid killing the server
- dd of=${file} count=1k bs=1k 2>/dev/null
+ run dd of="${file}" count=1k bs=1k 2>/dev/null
return $?
}
-
-
if [ "x${1}" = "x-c" ]
then
- command=$(echo ${2} | awk -F" " '{print $1}')
- type=$(echo ${2} | awk -F" " '{print $2}')
+ command=$(echo "${2}" | awk '{ print $1 }')
+ type=$(echo "${2}" | awk '{ print $2 }')
case ${command} in
post)
- receivefile ${type}
- if [ $? -eq 0 ]
+ if receivefile "${type}"
then
- unlock-luks ${type}
- if [ $? -eq 0 ]
+ if unlock-luks "${type}"
then
if [ "${type}" = 'root' ]
then
@@ -57,34 +67,53 @@ then
exit 1
fi
else
- bad_msg "Keyfile was not properly received!" ${CRYPT_SILENT}
+ bad_msg "Keyfile was not properly received!" "${CRYPT_SILENT}"
exit 1
fi
;;
*)
- bad_msg "Command '${command}' is not supported!" ${CRYPT_SILENT}
+ bad_msg "Command '${command}' is not supported!" "${CRYPT_SILENT}"
exit 1
esac
else
+ run touch "${GK_SSHD_LOCKFILE}"
+
+ # Don't log further remote shell output
+ GK_INIT_LOG=
+
+ gk_ver="$(cat /etc/build_id)"
+ gk_build_date="$(cat /etc/build_date)"
+ kernel_ver="$(uname -r)"
+
export PS1='remote rescueshell \w \# '
- touch "${GK_SSHD_LOCKFILE}"
- good_msg "The lockfile '${GK_SSHD_LOCKFILE}' was created."
- good_msg "In order to resume boot process, run 'resume-boot'."
- good_msg "Be aware that it will kill your connection which means"
- good_msg "you will no longer be able work in this shell."
- if [ -n "${CRYPT_ROOT}" -a ! -f "${CRYPT_ROOT_OPENED_LOCKFILE}" ]
+ GOOD=${BLUE} good_msg "${NORMAL}Welcome to ${BOLD}${gk_ver}${NORMAL} (${gk_build_date}) ${BOLD}remote rescue shell${NORMAL}!"
+ GOOD=${BLUE} good_msg "${NORMAL}...running Linux kernel ${BOLD}${kernel_ver}${NORMAL}"
+ echo
+ good_msg "${NORMAL}The lockfile '${BOLD}${GK_SSHD_LOCKFILE}${NORMAL}' was created."
+ good_msg "${NORMAL}In order to resume boot process, run '${BOLD}resume-boot${NORMAL}'."
+ good_msg "${NORMAL}Be aware that it will kill your connection which means"
+ good_msg "${NORMAL}you will no longer be able to work in this shell."
+
+ if [ -n "${CRYPT_ROOT}" ] && [ ! -f "${CRYPT_ROOT_OPENED_LOCKFILE}" ]
then
- good_msg "To remote unlock LUKS-encrypted root device, run 'unlock-luks root'."
+ good_msg "${NORMAL}To remote unlock LUKS-encrypted root device, run '${BOLD}unlock-luks root${NORMAL}'."
fi
- if [ -n "${CRYPT_SWAP}" -a ! -f "${CRYPT_ROOT_OPENED_LOCKFILE}" ]
+ if [ -n "${CRYPT_SWAP}" ] && [ ! -f "${CRYPT_ROOT_OPENED_LOCKFILE}" ]
then
- good_msg "To remote unlock LUKS-encrypted swap device, run 'unlock-luks swap'."
+ good_msg "${NORMAL}To remote unlock LUKS-encrypted swap device, run '${BOLD}unlock-luks swap${NORMAL}'."
fi
+ echo
+
[ -x /bin/sh ] && SH=/bin/sh || SH=/bin/ash
- exec ${SH} --login
+
+ exec \
+ env \
+ SSH_CLIENT_IP="${SSH_CLIENT_IP}" \
+ SSH_CLIENT_PORT="${SSH_CLIENT_PORT}" \
+ ${SH} --login
fi
exit 0
diff --git a/defaults/resume-boot.sh b/defaults/resume-boot.sh
index cb29831..f4dd4b2 100644
--- a/defaults/resume-boot.sh
+++ b/defaults/resume-boot.sh
@@ -1,15 +1,28 @@
#!/bin/sh
. /etc/initrd.defaults
+. /etc/initrd.scripts
-if [ -s "${GK_SHELL_LOCKFILE}" ]
+GK_INIT_LOG_PREFIX=${0}
+if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ]
then
- kill -9 "$(cat "${GK_SHELL_LOCKFILE}")"
+ GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]"
fi
-if [ -f "${GK_SSHD_LOCKFILE}" ]
-then
- rm "${GK_SSHD_LOCKFILE}"
-fi
+# We don't want to kill init script (PID 1),
+# ourselves and parent process yet...
+pids_to_keep="1 ${$} ${PPID}"
+
+for pid in $(pgrep sh)
+do
+ if ! echo " ${pids_to_keep} " | grep -q " ${pid} "
+ then
+ kill -9 ${pid}
+ fi
+done
+
+good_msg "Resuming boot process ..."
+[ -f "${GK_SSHD_LOCKFILE}" ] && run rm "${GK_SSHD_LOCKFILE}"
+[ "${PPID}" != '1' ] && kill -9 ${PPID}
exit 0
diff --git a/defaults/software.sh b/defaults/software.sh
index ec4dc78..363013f 100644
--- a/defaults/software.sh
+++ b/defaults/software.sh
@@ -9,6 +9,20 @@
# - This file should not override previously defined variables, as their values may
# originate from user changes to /etc/genkernel.conf .
+GKPKG_BOOST_PN="boost"
+GKPKG_BOOST_PV="${GKPKG_BOOST_PV:-VERSION_BOOST}"
+GKPKG_BOOST_DEPS="boost-build"
+GKPKG_BOOST_SRCTAR="${GKPKG_BOOST_SRCTAR:-${DISTDIR}/boost_${GKPKG_BOOST_PV//./_}.tar.bz2}"
+GKPKG_BOOST_SRCDIR="${GKPKG_BOOST_SRCDIR:-boost_${GKPKG_BOOST_PV//./_}}"
+GKPKG_BOOST_BINPKG="${GKPKG_BOOST_BINPKG:-%%CACHE%%/boost-${GKPKG_BOOST_PV}-%%ARCH%%.tar.xz}"
+
+GKPKG_BOOST_BUILD_PN="boost-build"
+GKPKG_BOOST_BUILD_PV="${GKPKG_BOOST_PV}"
+GKPKG_BOOST_BUILD_DEPS=""
+GKPKG_BOOST_BUILD_SRCTAR="${GKPKG_BOOST_SRCTAR}"
+GKPKG_BOOST_BUILD_SRCDIR="${GKPKG_BOOST_SRCDIR}"
+GKPKG_BOOST_BUILD_BINPKG="${GKPKG_BOOST_BUILD_BINPKG:-%%CACHE%%/boost-build-${GKPKG_BOOST_BUILD_PV}.tar.xz}"
+
GKPKG_BTRFS_PROGS_PN="btrfs-progs"
GKPKG_BTRFS_PROGS_PV="${GKPKG_BTRFS_PROGS_PV:-VERSION_BTRFS_PROGS}"
GKPKG_BTRFS_PROGS_DEPS="util-linux zlib zstd lzo"
@@ -51,6 +65,13 @@ GKPKG_EUDEV_SRCTAR="${GKPKG_EUDEV_SRCTAR:-${DISTDIR}/eudev-${GKPKG_EUDEV_PV}.tar
GKPKG_EUDEV_SRCDIR="${GKPKG_EUDEV_SRCDIR:-eudev-${GKPKG_EUDEV_PV}}"
GKPKG_EUDEV_BINPKG="${GKPKG_EUDEV_BINPKG:-%%CACHE%%/eudev-${GKPKG_EUDEV_PV}-%%ARCH%%.tar.xz}"
+GKPKG_EXPAT_PN="expat"
+GKPKG_EXPAT_PV="${GKPKG_EXPAT_PV:-VERSION_EXPAT}"
+GKPKG_EXPAT_DEPS=""
+GKPKG_EXPAT_SRCTAR="${GKPKG_EXPAT_SRCTAR:-${DISTDIR}/expat-${GKPKG_EXPAT_PV}.tar.xz}"
+GKPKG_EXPAT_SRCDIR="${GKPKG_EXPAT_SRCDIR:-expat-${GKPKG_EXPAT_PV}}"
+GKPKG_EXPAT_BINPKG="${GKPKG_EXPAT_BINPKG:-%%CACHE%%/expat-${GKPKG_EXPAT_PV}-%%ARCH%%.tar.xz}"
+
GKPKG_E2FSPROGS_PN="e2fsprogs"
GKPKG_E2FSPROGS_PV="${GKPKG_E2FSPROGS_PV:-VERSION_E2FSPROGS}"
GKPKG_E2FSPROGS_DEPS="util-linux"
@@ -149,6 +170,13 @@ GKPKG_STRACE_SRCTAR="${GKPKG_STRACE_SRCTAR:-${DISTDIR}/strace-${GKPKG_STRACE_PV}
GKPKG_STRACE_SRCDIR="${GKPKG_STRACE_SRCDIR:-strace-${GKPKG_STRACE_PV}}"
GKPKG_STRACE_BINPKG="${GKPKG_STRACE_BINPKG:-%%CACHE%%/strace-${GKPKG_STRACE_PV}-%%ARCH%%.tar.xz}"
+GKPKG_THIN_PROVISIONING_TOOLS_PN="thin-provisioning-tools"
+GKPKG_THIN_PROVISIONING_TOOLS_PV="${GKPKG_THIN_PROVISIONING_TOOLS_PV:-VERSION_THIN_PROVISIONING_TOOLS}"
+GKPKG_THIN_PROVISIONING_TOOLS_DEPS="boost libaio expat"
+GKPKG_THIN_PROVISIONING_TOOLS_SRCTAR="${GKPKG_THIN_PROVISIONING_TOOLS_SRCTAR:-${DISTDIR}/thin-provisioning-tools-${GKPKG_THIN_PROVISIONING_TOOLS_PV}.tar.gz}"
+GKPKG_THIN_PROVISIONING_TOOLS_SRCDIR="${GKPKG_THIN_PROVISIONING_TOOLS_SRCDIR:-thin-provisioning-tools-${GKPKG_THIN_PROVISIONING_TOOLS_PV}}"
+GKPKG_THIN_PROVISIONING_TOOLS_BINPKG="${GKPKG_THIN_PROVISIONING_TOOLS_BINPKG:-%%CACHE%%/thin-provisioning-tools-${GKPKG_THIN_PROVISIONING_TOOLS_PV}-%%ARCH%%.tar.xz}"
+
GKPKG_UNIONFS_FUSE_PN="unionfs-fuse"
GKPKG_UNIONFS_FUSE_PV="${GKPKG_UNIONFS_FUSE_PV:-VERSION_UNIONFS_FUSE}"
GKPKG_UNIONFS_FUSE_DEPS="fuse"
diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh
index ef6b816..457aa54 100644
--- a/defaults/unlock-luks.sh
+++ b/defaults/unlock-luks.sh
@@ -4,10 +4,6 @@ print_usage() {
echo "Usage: $0 root|swap" >&2
}
-splash() {
- return 0
-}
-
if [ -z "${1}" ]
then
print_usage
@@ -34,6 +30,12 @@ esac
. /etc/initrd.scripts
. "${CRYPT_ENV_FILE}"
+GK_INIT_LOG_PREFIX=${0}
+if [ -n "${SSH_CLIENT_IP}" ] && [ -n "${SSH_CLIENT_PORT}" ]
+then
+ GK_INIT_LOG_PREFIX="${0}[${SSH_CLIENT_IP}:${SSH_CLIENT_PORT}]"
+fi
+
main() {
if [ ! -x /sbin/cryptsetup ]
then
@@ -43,11 +45,11 @@ main() {
eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="${NAME}" LUKS_KEY='"${CRYPT_KEYFILE_'${TYPE}'}"'
eval local LUKS_TRIM='"${CRYPT_'${TYPE}'_TRIM}"' OPENED_LOCKFILE='"${CRYPT_'${TYPE}'_OPENED_LOCKFILE}"'
- local cryptsetup_options=
+ local cryptsetup_options
while true
do
- local gpg_cmd= crypt_filter_ret=
+ local gpg_cmd crypt_filter_ret
if [ -e "${OPENED_LOCKFILE}" ]
then
@@ -57,15 +59,14 @@ main() {
LUKS_DEVICE=$(find_real_device "${LUKS_DEVICE}")
if [ -z "${LUKS_DEVICE}" ]
then
- bad_msg "Looks like CRYPT_${TYPE} kernel cmdline argument is not set." ${CRYPT_SILENT}
+ bad_msg "Looks like CRYPT_${TYPE} kernel cmdline argument is not set." "${CRYPT_SILENT}"
exit 1
fi
- setup_md_device ${LUKS_DEVICE}
- cryptsetup isLuks ${LUKS_DEVICE}
- if [ $? -ne 0 ]
+ setup_md_device "${LUKS_DEVICE}"
+ if ! run cryptsetup isLuks "${LUKS_DEVICE}"
then
- bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT}
+ bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" "${CRYPT_SILENT}"
# User has SSH access and is able to call script again or
# able to investigate the problem on its own.
@@ -73,7 +74,7 @@ main() {
else
if [ "x${LUKS_TRIM}" = "xyes" ]
then
- good_msg "Enabling TRIM support for ${LUKS_NAME} ..." ${CRYPT_SILENT}
+ good_msg "Enabling TRIM support for ${LUKS_NAME} ..." "${CRYPT_SILENT}"
cryptsetup_options="${cryptsetup_options} --allow-discards"
fi
@@ -89,16 +90,16 @@ main() {
crypt_filter_ret=$?
[ -e /dev/tty.org ] \
- && rm -f /dev/tty \
- && mv /dev/tty.org /dev/tty
+ && run rm -f /dev/tty \
+ && run mv /dev/tty.org /dev/tty
if [ ${crypt_filter_ret} -eq 0 ]
then
- touch "${OPENED_LOCKFILE}"
- good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
+ run touch "${OPENED_LOCKFILE}"
+ good_msg "LUKS device ${LUKS_DEVICE} opened" "${CRYPT_SILENT}"
break
else
- bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" ${CRYPT_SILENT}
+ bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" "${CRYPT_SILENT}"
# We need to stop here with a non-zero exit code to prevent
# a loop when invalid keyfile was sent.
@@ -110,9 +111,9 @@ main() {
if [ -s "${LUKS_KEY}" ]
then
- if [ "${DEBUG}" != 'yes' ]
+ if ! is_debug
then
- rm -f "${LUKS_KEY}"
+ run rm -f "${LUKS_KEY}"
else
warn_msg "LUKS key file '${LUKS_KEY}' not deleted because DEBUG mode is enabled!"
fi
@@ -120,8 +121,9 @@ main() {
if [ "${crypt_filter_ret}" = '0' ]
then
- # Kill any running cryptsetup prompt for this device
- pkill -9 -f "luksOpen.*${LUKS_NAME}\$" >/dev/null 2>&1
+ # Kill any running cryptsetup prompt for this device.
+ # But SIGINT only to keep shell functional.
+ run pkill -2 -f "luksOpen.*${LUKS_NAME}\$" >/dev/null 2>&1
fi
}
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index da0f44e..82da1e1 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -124,6 +124,27 @@ KERNEL CONFIGURATION
*--*[*no-*]*virtio*::
Adds, or skip adding VirtIO support to kernel configuration.
+*--kernel-append-localversion*=<...>::
+ Appends value to genkernel's *KERNEL_LOCALVERSION* option (see below).
+ The idea is to use this option to allow to easily build a new revision
+ with own kernel binary, initramfs and modules directory without losing
+ default *KERNEL_LOCALVERSION* value.
+
+*--kernel-localversion*=<...>::
+Set kernel option *LOCALVERSION*. Use special value *UNSET* to
+unset any already set *LOCALVERSION*. The following placeholders are
+available:
++
+[horizontal]
+*%%ARCH%%*:::
+Will be replaced with genkernel arch value, for example 'x86_64'.
+
++
+*LOCALVERSION* is only allowed to contain characters like 'a-z' or 'A-Z',
+'0-9', '_', '.' and '-'.
++
+By default, *LOCALVERSION* will be set to '-%%ARCH%%'.
+
KERNEL COMPILATION
~~~~~~~~~~~~~~~~~~
@@ -146,16 +167,20 @@ KERNEL COMPILATION
are copied over.
*--*[*no-*]*symlink*::
- Manages, or does not manage, symlinks in '/boot' like the manual
- kernel "make install" process does. A kernel (or, depending on
- options, kernelz) symlink will link to the most recently built
- kernel image and a kernel.old (or kernelz.old) symlink will link
- to the second most recently built image, if one exists. Similar
- symlinks (both * and *.old) are managed for initramfs and System.map.
- The corresponding work products (i.e., the actual kernel
- and initramfs images, and System.map) are also managed accordingly.
- NOTE: Specifying *--symlink* does nothing unless
- *--install* is also specified.
+Manages, or does not manage, symlinks in '/boot' like the manual
+kernel "make install" process does. A 'kernel' (or, depending on
+options, 'kernelz') symlink will link to the most recently built
+kernel image and a 'kernel.old' (or 'kernelz.old') symlink will link
+to the second most recently built image, if one exists. Similar
+symlinks (with and without '.old' suffix) are managed for initramfs and
+System.map. The corresponding work products (i.e., the actual kernel
+and initramfs images, and System.map) are also managed accordingly.
++
+The symlink name can be controlled via *--kernel-symlink-name* and/or
+*--initramfs-symlink-name* option.
+
+NOTE: Specifying *--symlink* does nothing unless *--install* is also
+specified.
*--*[*no-*]*oldconfig*::
Runs, or does not run, "make oldconfig" before compilation. Specifying
@@ -240,6 +265,9 @@ LOW-LEVEL COMPILATION OPTIONS
*--utils-as*=<assembler>::
Assembler to use for utilities.
+*--utils-cflags*=<cflags>::
+ C compiler flags used to compile utilities.
+
*--utils-cc*=<compiler>::
Compiler to use for utilities.
@@ -263,7 +291,7 @@ LOW-LEVEL COMPILATION OPTIONS
*--*[*no-*]*nice*[=<niceness>]::
Runs the kernel make at the default niceness (reduction in priority) of
- 10, or in the case of --no-nice, runs the kernel make at normal priority.
+ 10, or in the case of *--no-nice*, runs the kernel make at normal priority.
INITIALIZATION
@@ -290,12 +318,12 @@ INITIALIZATION
When enabled, this will compile LVM for you.
*--*[*no-*]*mdadm*::
- Includes or excludes mdadm/mdmon support.
- Without sys-fs/mdadm[static] installed, this will compile mdadm for you.
+ Includes or excludes mdadm support.
+ When enabled, this will compile mdadm for you.
*--mdadm-config*=<file>::
Use <file> as configfile for MDADM.
- By default the ramdisk will be built *without* an mdadm.conf and
+ By default the ramdisk will be built *without* an 'mdadm.conf' and
will auto-detect arrays during boot-up.
*--*[*no-*]*microcode-initramfs*::
@@ -305,40 +333,50 @@ INITIALIZATION
*--*[*no-*]*dmraid*::
Includes or excludes DMRAID support.
+ When enabled, this will compile dmraid for you.
*--*[*no-*]*nfs*::
Includes or excludes NFS support.
*--*[*no-*]*e2fsprogs*::
Includes or excludes e2fsprogs.
+ When enabled, this will compile e2fsprogs for you.
*--*[*no-*]*xfsprogs*::
Includes or excludes xfsprogs.
+ When enabled, this will compile xfsprogs for you.
*--*[*no-*]*zfs*::
Includes or excludes ZFS support.
*--*[*no-*]*btrfs*::
Includes or excludes Btrfs support.
+ When enabled, this will compile btrfs-progs for you.
*--*[*no-*]*multipath*::
Includes or excludes Multipath support.
+ When enabled, this will compile multipath-tools for you.
*--*[*no-*]*iscsi*::
Includes or excludes iSCSI support.
+ When enabled, this will compile open-iscsi for you.
+
+*--*[*no-*]*sandbox*::
+ Enables or disables sandbox-ing when building initramfs.
*--*[*no-*]*ssh*::
Includes or excludes SSH (dropbear) support for remote LUKS keys.
+ When enabled, this will compile dropbear for you.
*--ssh-authorized-keys-file*=<file>::
Specifies a user created authorized_keys file. By default genkernel
- will use "/etc/dropbear/authorized_keys".
+ will use '/etc/dropbear/authorized_keys'.
*--ssh-host-keys*=<create|create-from-host|runtime>::
When set to *create*, which is the default value, genkernel will embed
- SSH host keys from "/etc/dropbear" and will create those keys when missing.
+ SSH host keys from '/etc/dropbear' and will create those keys when missing.
When set to *create-from-host*, genkernel will embed SSH host keys from
- "/etc/dropbear" but will create those keys from "/etc/ssh" when missing
+ '/etc/dropbear' but will create those keys from '/etc/ssh' when missing
(not recommended for security reasons).
When set to *runtime*, genkernel will not embed any SSH host key in
initramfs and dropbear will generate needed host key at runtime (`dropbear -R`).
@@ -356,10 +394,12 @@ INITIALIZATION
Make and install kernelz image from 'arch/powerpc/boot/zImage.initrd'.
*--*[*no-*]*disklabel*::
- Includes or excludes disk label and uuid support in your initrd.
+ Includes or excludes disk label and uuid support in your initramfs.
+ When enabled, this will compile util-linux for you.
*--*[*no-*]*luks*::
Includes or excludes LUKS support.
+ When enabled, this will compile cryptsetup for you.
*--*[*no-*]*gpg*::
Includes or excludes support for GnuPG 1.x, the portable standalone branch
@@ -368,16 +408,19 @@ INITIALIZATION
After that, re-point the *root_key* argument to the new .gpg file.
*--*[*no-*]*busybox*::
- Includes or excludes busybox in the initrd or initramfs.
+ Includes or excludes busybox in the initramfs.
+ When enabled, this will compile busybox for you.
*--*[*no-*]*unionfs*::
Includes or excludes support for unionfs.
+ When enabled, this will compile unionfs-fuse for you.
*--*[*no-*]*netboot*::
Creates or does not create a self-contained env in the initramfs.
*--real-root*=<foo>::
- Specify a default for *real_root*= kernel option.
+ Specify a default for *real_root*= kernel option which will be
+ embedded into initramfs.
INTERNALS
@@ -385,11 +428,20 @@ INTERNALS
*--cachedir*=<dir>::
Override the default cache location.
+*--check-free-disk-space-bootdir*=<MB>::
+ When set to a non-zero value, genkernel will check early on start for
+ specified amount of free disk space in megabyte in *BOOTDIR*.
+
+*--check-free-disk-space-kerneloutputdir*=<MB>::
+ When set to a non-zero value, genkernel will check early on start for
+ specified amount of free disk space in megabyte in *KERNEL_OUTPUTDIR*.
+
*--*[*no-*]*clear-cachedir*::
Clears or skips clearing all files in cache location on genkernel start.
-*--tempdir*=<dir>::
- Sets genkernel's temporary working directory to <dir>.
+*--tmpdir*=<dir>::
+ Sets genkernel's temporary working directory to <dir>. By default, a
+ directory below '/var/tmp/genkernel' will be used.
*--*[*no-*]*postclear*::
Clears or skips clearing all tmp files and caches after genkernel has run.
@@ -397,28 +449,88 @@ INTERNALS
OUTPUT SETTINGS
~~~~~~~~~~~~~~~
-*--kernname*=<...>::
- Tag the kernel and initrd with a name, if not defined this
- option defaults to genkernel.
+*--initramfs-filename*=<...>::
+Set initramfs filename which will be used when initramfs will be installed
+into *BOOTDIR* (implies *--install* option). Please see
+*--kernel-filename* option for available placeholders and restrictions.
++
+By default, initramfs filename will be set to 'initramfs-%%KV%%.img'.
+
+*--initramfs-symlink-name*=<...>::
+Set initramfs symlink name which will be used when initramfs will be
+installed into *BOOTDIR* (implies *--install* option) and *--symlink*
+option is given. Please see *--kernel-filename* option for available
+placeholders and restrictions.
++
+By default, initramfs symlink name will be set to 'initramfs'.
+
+NOTE: Initramfs filename and initramfs symlink name must be different.
*--minkernpackage*=<file>::
- Archive file created using tar containing kernel and initramfs.
- NOTE: No modules outside of the initramfs will be included!
+Archive file created using tar containing kernel and initramfs.
+
+NOTE: No modules outside of the initramfs will be included!
*--modulespackage*=<archive>::
Archive file created using tar containing modules after the callbacks
have run.
*--kerncache*=<archive>::
- Archive file created using tar containing kernel binary, content of
- '/lib/modules' and the kernel config. NOTE: Archive is created before
- the callbacks are run.
+ Archive file created using tar containing kernel binary, content of
+ '/lib/modules' and the kernel config after the callbacks have run.
+
+*--kernel-filename*=<...>::
+Set kernel filename which will be used when kernel will be installed
+into *BOOTDIR* (implies *--install* option). The following placeholders
+are available:
++
+[horizontal]
+*%%ARCH%%*:::
+Will be replaced with genkernel arch value, for example 'x86_64'.
+*%%KV%%*:::
+Will be replaced with kernel version, for example '5.2.3-gentoo'.
+
++
+Kernel filename is only allowed to contain characters like 'a-z' or 'A-Z',
+'0-9', '_', '.' and '-'.
++
+By default, kernel name will be set to 'vmlinuz-%%KV%%'.
+
+NOTE: When setting a custom kernel name make sure that your bootloader and
+tools like *kexec* when used are recognizing your custom kernel name.
*--*[*no-*]*kernel-sources*::
This option is only valid if kerncache is defined If there is a
valid kerncache no checks will be made against a kernel source
tree.
+*--kernel-symlink-name*=<...>::
+Set kernel symlink name which will be used when kernel will be installed
+into *BOOTDIR* (implies *--install* option) and *--symlink* option is
+given. Please see *--kernel-filename* option for available placeholders
+and restrictions.
++
+By default, kernel symlink name will be set to 'kernel'.
+
+NOTE: Kernel filename and kernel symlink name must be different.
+
+*--systemmap-filename*=<...>::
+Set System.map filename which will be used when kernel will be installed
+into *BOOTDIR* (implies *--install* option). Please see
+*--kernel-filename* option for available placeholders and restrictions.
++
+By default, System.map filename will be set to 'System.map-%%KV%%'.
+
+*--systemmap-symlink-name*=<...>::
+Set System.map symlink name which will be used when kernel will be
+installed into *BOOTDIR* (implies *--install* option) and *--symlink*
+option is given. Please see *--kernel-filename* option for available
+placeholders and restrictions.
++
+By default, System.map symlink name will be set to 'System.map'.
+
+NOTE: System.map filename and System.map symlink name must be different.
+
*--initramfs-overlay*=<dir>::
Directory structure to include in the initramfs, only available
on >=2.6 kernels.
@@ -572,9 +684,22 @@ recognized by the kernel itself.
*gk.net.timeout.dhcp*=<...>::
By default we will wait up to 10 seconds for a DHCP server reply.
+*gk.net.timeout.interface*=<...>::
+ By default we will wait up to 10 seconds for interface to show up.
+
+*gk.prompt.timeout*=<...>::
+By default a prompt within genkernel initramfs like shown when set
+*root* could not be found will never timeout. Use this option to set
+a timeout.
+
+NOTE: When *dosshd* is used, *gk.prompt.timeout* will be set to 30 seconds
+when not set. This will allow remote user to provide answer through
+*GK_PROMPT_FILE* which is set to '/tmp/current_prompt' by default.
+
*dosshd*::
- Will start an SSH daemon within initramfs allowing to remotely unlock
- encrypted devices or just for debugging purpose.
+ Will bring up an interface and start a SSH daemon within initramfs
+ allowing to remotely unlock encrypted devices or just for debugging
+ purpose. See *ip* option for how to configure network.
*gk.sshd.port*=<...>::
By default, sshd will listen on port 22.
@@ -644,6 +769,22 @@ recognized by the kernel itself.
*debug*::
Drop into a debug shell early in the process.
+*gk.log.disabled*=<...>::
+ By default, any shown message and external command calls will be logged
+ to '/tmp/init.log' in initramfs. This boolean option allows you to
+ disable logging for some reason.
+
+*gk.log.keep*=<...>::
+When set to a boolean value, genkernel will preserve '/tmp/init.log',
+see above, and copy file to '/genkernel-boot.log' on *root* device.
+You can also set your own file like '/root/my-genkernel-boot.log' to
+copy log to a custom path.
+
+NOTE: The default file '/genkernel-boot.log' on *root* was chosen because
+genkernel's initramfs will only mount root filesystem by default. If you
+want to store the log file in '/var/log/genkernel-boot.log' for example
+make sure that this mountpoint is accessible, see *initramfs.mounts*.
+
*noload*=<...>::
List of modules to skip loading.
Separate using commas or spaces.
@@ -736,6 +877,18 @@ recognized by the kernel itself.
Loop-mount an ISO file from the boot device to get the filesystem image.
Useful with chain-loading environments and USB keys.
+initramfs.mounts
+----------------
+By default, genkernel's initramfs will only mount *root* device. But
+sometimes additional mounts are required before initramfs can switch to
+real root (for example on systems with a seperate '/usr' mount).
+
+Therefore genkernel package contains '/etc/initramfs.mounts' file which
+will allow you to specify additional mounts which should be mounted before
+initramfs will switch to real root.
+
+NOTE: This file will not be included in initramfs. Instead, booted initramfs
+will check for this file on specified *root* device.
NETBOOTING
----------
@@ -789,6 +942,8 @@ AUTHORS
SEE ALSO
--------
-/etc/genkernel.conf - genkernel configuration file
+'/etc/initramfs.mounts' - additional required mounts before switching to real root
+
+'/etc/genkernel.conf' - genkernel configuration file
// vim: ft=asciidoc et tw=72 sts=4 ts=4 :
diff --git a/gen_bootloader.sh b/gen_bootloader.sh
index b215cd8..5202047 100755
--- a/gen_bootloader.sh
+++ b/gen_bootloader.sh
@@ -102,12 +102,12 @@ set_bootloader_grub() {
# Add grub configuration to grub.conf
echo "# Genkernel generated entry, see GRUB documentation for details" >> ${GRUB_CONF}
echo "title=Gentoo Linux ($KV)" >> ${GRUB_CONF}
- printf "%b\n" "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
+ printf "%b\n" "\tkernel /${GK_FILENAME_KERNEL} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
if isTrue "${BUILD_RAMDISK}"
then
if [ "${PAT}" -gt '4' ]
then
- printf "%b\n" "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
+ printf "%b\n" "\tinitrd /${GK_FILENAME_INITRAMFS}" >> ${GRUB_CONF}
fi
fi
echo >> ${GRUB_CONF}
@@ -129,14 +129,14 @@ set_bootloader_grub() {
}
set_bootloader_grub_duplicate_default_replace_kernel_initrd() {
- sed -r -e "/^[[:space:]]*kernel/s/kernel-[[:alnum:][:punct:]]+/kernel-${KNAME}-${ARCH}-${KV}/" - |
- sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/init\1-${KNAME}-${ARCH}-${KV}/"
+ sed -r -e "/^[[:space:]]*kernel/s/kernel-[[:alnum:][:punct:]]+/${GK_FILENAME_KERNEL}/" - |
+ sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/${GK_FILENAME_INITRAMFS}/"
}
set_bootloader_grub_check_for_existing_entry() {
local GRUB_CONF=$1
- if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/kernel-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}" &&
- grep -q "^[[:space:]]*initrd[[:space:]=]*.*/initramfs-${KNAME}-${ARCH}-${KV}\([[:space:]]\|$\)" "${GRUB_CONF}"
+ if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/${GK_FILENAME_KERNEL}\([[:space:]]\|$\)" "${GRUB_CONF}" &&
+ grep -q "^[[:space:]]*initrd[[:space:]=]*.*/${GK_FILENAME_INITRAMFS}\([[:space:]]\|$\)" "${GRUB_CONF}"
then
return 0
fi
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index a7b35a8..7e74182 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -39,7 +39,7 @@ longusage() {
echo " --no-bcache Don't enable block layer cache (bcache) support in kernel"
echo " --hyperv Enable Microsoft Hyper-V kernel options in kernel"
echo " --no-hyperv Don't enable Microsoft Hyper-V kernel options in kernel"
- echo " --microcode=(all,amd,intel)"
+ echo " --microcode=(all|amd|intel)"
echo " Enable early microcode support in kernel configuration,"
echo " 'all' for all (default), 'amd' for AMD and 'intel' for"
echo " Intel CPU types"
@@ -71,10 +71,15 @@ longusage() {
echo " --no-static Do not build a static (monolithic kernel)"
echo " Kernel settings"
echo " --kerneldir=<dir> Location of the kernel sources"
+ echo " --kernel-append-localversion=<...>"
+ echo " Appends value to genkernel's KERNEL_LOCALVERSION option"
echo " --kernel-config=<file|default>"
echo " Kernel configuration file to use for compilation; Use"
echo " 'default' to explicitly start from scratch using"
echo " genkernel defaults"
+ echo " --kernel-localversion=<...>"
+ echo " Set kernel CONFIG_LOCALVERSION, use special value"
+ echo " 'UNSET' to unset any set LOCALVERSION"
echo " --module-prefix=<dir> Prefix to kernel module destination, modules"
echo " will be installed in <prefix>/lib/modules"
echo " Low-Level Compile settings"
@@ -133,6 +138,8 @@ longusage() {
echo " --no-multipath Exclude Multipath support"
echo " --iscsi Include iSCSI support"
echo " --no-iscsi Exclude iSCSI support"
+ echo " --sandbox Enable sandbox-ing when building initramfs"
+ echo " --no-sandbox Disable sandbox-ing when building initramfs"
echo " --ssh Include SSH (dropbear) support"
echo " --no-ssh Exclude SSH (dropbear) support"
echo " --ssh-authorized-keys-file=<file>"
@@ -163,16 +170,24 @@ longusage() {
echo " --real-root=<foo> Specify a default for real_root="
echo " Internals"
echo " --cachedir=<dir> Override the default cache location"
+ echo " --check-free-disk-space-bootdir=<MB>"
+ echo " Check for specified amount of free disk space in MB in BOOTDIR"
+ echo " at genkernel start"
+ echo " --check-free-disk-space-kerneloutputdir=<MB>"
+ echo " Check for specified amount of free disk space in MB in"
+ echo " kernel outputdir at genkernel start"
echo " --clear-cachedir Clear genkernel's cache location on start. Useful"
echo " if you want to force rebuild of included tools"
echo " like BusyBox, DMRAID, GnuPG, LVM, MDADM ..."
echo " --no-clear-cachedir Do not clean up on genkernel start"
- echo " --tempdir=<dir> Location of genkernel's temporary directory"
+ echo " --tmpdir=<dir> Location of genkernel's temporary directory"
echo " --postclear Clear all tmp files and caches after genkernel has run"
echo " --no-postclear Do not clean up after genkernel has run"
echo " Output Settings"
- echo " --kernname=<...> Tag the kernel and initramfs with a name; If not defined"
- echo " the option defaults to 'genkernel'"
+ echo " --kernel-filename=<...>"
+ echo " Set kernel filename"
+ echo " --kernel-symlink-name=<...>"
+ echo " Set kernel symlink name"
echo " --minkernpackage=<archive>"
echo " Archive file created using tar containing kernel and"
echo " initramfs"
@@ -180,14 +195,18 @@ longusage() {
echo " Archive file created using tar containing modules after"
echo " the callbacks have run"
echo " --kerncache=<archive> Archive file created using tar containing kernel binary,"
- echo " content of /lib/modules and the kernel config."
- echo " NOTE: Archive is created before the callbacks are run!"
+ echo " content of /lib/modules and the kernel config after the"
+ echo " callbacks have run"
echo " --no-kernel-sources This option is only valid if kerncache is"
echo " defined. If there is a valid kerncache no checks"
echo " will be made against a kernel source tree"
+ echo " --initramfs-filename=<...>"
+ echo " Set initramfs filename"
echo " --initramfs-overlay=<dir>"
echo " Directory structure to include in the initramfs,"
echo " only available on 2.6 kernels"
+ echo " --initramfs-symlink-name=<...>"
+ echo " Set initramfs symlink name"
echo " --firmware Enable copying of firmware into initramfs"
echo " --firmware-dir=<dir>"
echo " Specify directory to copy firmware from (defaults"
@@ -218,6 +237,10 @@ longusage() {
echo " Strip debug symbols from none, all, installed kernel (obsolete) or"
echo " modules (default)"
echo " --no-strip Don't strip installed kernel or modules, alias for --strip=none"
+ echo " --systemmap-filename=<...>"
+ echo " Set System.map filename"
+ echo " --systemmap-symlink-name=<...>"
+ echo " Set System.map symlink name"
echo
echo "For a detailed list of supported initramfs options and flags; issue:"
echo " man 8 genkernel"
@@ -343,15 +366,11 @@ parse_cmdline() {
;;
--mdadm|--no-mdadm)
CMD_MDADM=$(parse_optbool "$*")
- print_info 3 "CMD_MDADM: $CMD_MDADM"
- if isTrue "${CMD_MDADM}" && [ ! -e /sbin/mdadm ]
- then
- print_warning 'Warning: --mdadm generally requires sys-fs/mdadm present on the host system'
- fi
+ print_info 3 "CMD_MDADM: ${CMD_MDADM}"
;;
--mdadm-config=*)
CMD_MDADM_CONFIG="${*#*=}"
- print_info 3 "CMD_MDADM_CONFIG: $CMD_MDADM_CONFIG"
+ print_info 3 "CMD_MDADM_CONFIG: ${CMD_MDADM_CONFIG}"
;;
--busybox|--no-busybox)
CMD_BUSYBOX=$(parse_optbool "$*")
@@ -440,6 +459,10 @@ parse_cmdline() {
CMD_HYPERV=$(parse_optbool "$*")
print_info 3 "CMD_HYPERV: ${CMD_HYPERV}"
;;
+ --sandbox|--no-sandbox)
+ CMD_SANDBOX=$(parse_optbool "$*")
+ print_info 3 "CMD_SANDBOX: ${CMD_SANDBOX}"
+ ;;
--ssh|--no-ssh)
CMD_SSH=$(parse_optbool "$*")
print_info 3 "CMD_SSH: ${CMD_SSH}"
@@ -584,21 +607,22 @@ parse_cmdline() {
CMD_STATIC=$(parse_optbool "$*")
print_info 3 "CMD_STATIC: ${CMD_STATIC}"
;;
- --tempdir=*)
- TMPDIR="${*#*=}"
- if [ ! -d "${TMPDIR}" ]
- then
- mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!"
- fi
- TEMP=$(mktemp -d -p "${TMPDIR}" gk.XXXXXXXX 2>/dev/null)
- [ -z "${TEMP}" ] && gen_die "mktemp failed!"
- print_info 3 "TMPDIR: ${TMPDIR}"
- print_info 3 "TEMP: ${TEMP}"
+ --tmpdir=*)
+ CMD_TMPDIR="${*#*=}"
+ print_info 3 "CMD_TMPDIR: ${CMD_TMPDIR}"
;;
--postclear|--no-postclear)
CMD_POSTCLEAR=$(parse_optbool "$*")
print_info 3 "CMD_POSTCLEAR: ${CMD_POSTCLEAR}"
;;
+ --check-free-disk-space-bootdir=*)
+ CMD_CHECK_FREE_DISK_SPACE_BOOTDIR="${*#*=}"
+ print_info 3 "CMD_CHECK_FREE_DISK_SPACE_BOOTDIR: ${CMD_CHECK_FREE_DISK_SPACE_BOOTDIR}"
+ ;;
+ --check-free-disk-space-kerneloutputdir=*)
+ CMD_CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR="${*#*=}"
+ print_info 3 "CMD_CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR: ${CMD_CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR}"
+ ;;
--color|--no-color)
CMD_COLOR=$(parse_optbool "$*")
if isTrue "${CMD_COLOR}"
@@ -622,10 +646,18 @@ parse_cmdline() {
CMD_KERNEL_DIR="${*#*=}"
print_info 3 "CMD_KERNEL_DIR: ${CMD_KERNEL_DIR}"
;;
+ --kernel-append-localversion=*)
+ CMD_KERNEL_APPEND_LOCALVERSION="${*#*=}"
+ print_info 3 "CMD_KERNEL_APPEND_LOCALVERSION: ${CMD_KERNEL_APPEND_LOCALVERSION}"
+ ;;
--kernel-config=*)
CMD_KERNEL_CONFIG="${*#*=}"
print_info 3 "CMD_KERNEL_CONFIG: ${CMD_KERNEL_CONFIG}"
;;
+ --kernel-localversion=*)
+ CMD_KERNEL_LOCALVERSION="${*#*=}"
+ print_info 3 "CMD_KERNEL_LOCALVERSION: ${CMD_KERNEL_LOCALVERSION}"
+ ;;
--module-prefix=*)
CMD_INSTALL_MOD_PATH="${*#*=}"
print_info 3 "CMD_INSTALL_MOD_PATH: ${CMD_INSTALL_MOD_PATH}"
@@ -650,9 +682,13 @@ parse_cmdline() {
CMD_KERNCACHE="${*#*=}"
print_info 3 "KERNCACHE: ${CMD_KERNCACHE}"
;;
- --kernname=*)
- CMD_KERNNAME="${*#*=}"
- print_info 3 "KERNNAME: ${CMD_KERNNAME}"
+ --kernel-filename=*)
+ CMD_KERNEL_FILENAME="${*#*=}"
+ print_info 3 "CMD_KERNEL_FILENAME: ${CMD_KERNEL_FILENAME}"
+ ;;
+ --kernel-symlink-name=*)
+ CMD_KERNEL_SYMLINK_NAME="${*#*=}"
+ print_info 3 "CMD_KERNEL_SYMLINK_NAME: ${CMD_KERNEL_SYMLINK_NAME}"
;;
--symlink|--no-symlink)
CMD_SYMLINK=$(parse_optbool "$*")
@@ -662,10 +698,26 @@ parse_cmdline() {
CMD_KERNEL_SOURCES=$(parse_optbool "$*")
print_info 3 "CMD_KERNEL_SOURCES: ${CMD_KERNEL_SOURCES}"
;;
+ --initramfs-filename=*)
+ CMD_INITRAMFS_FILENAME="${*#*=}"
+ print_info 3 "CMD_INITRAMFS_FILENAME: ${CMD_INITRAMFS_FILENAME}"
+ ;;
--initramfs-overlay=*)
CMD_INITRAMFS_OVERLAY="${*#*=}"
print_info 3 "CMD_INITRAMFS_OVERLAY: ${CMD_INITRAMFS_OVERLAY}"
;;
+ --initramfs-symlink-name=*)
+ CMD_INITRAMFS_SYMLINK_NAME="${*#*=}"
+ print_info 3 "CMD_INITRAMFS_SYMLINK_NAME: ${CMD_INITRAMFS_SYMLINK_NAME}"
+ ;;
+ --systemmap-filename=*)
+ CMD_SYSTEMMAP_FILENAME="${*#*=}"
+ print_info 3 "CMD_SYSTEMMAP_FILENAME: ${CMD_SYSTEMMAP_FILENAME}"
+ ;;
+ --systemmap-symlink-name=*)
+ CMD_SYSTEMMAP_SYMLINK_NAME="${*#*=}"
+ print_info 3 "CMD_SYSTEMMAP_SYMLINK_NAME: ${CMD_SYSTEMMAP_SYMLINK_NAME}"
+ ;;
--linuxrc=*)
CMD_LINUXRC="${*#*=}"
print_info 3 "CMD_LINUXRC: ${CMD_LINUXRC}"
@@ -793,8 +845,7 @@ parse_cmdline() {
exit 0
;;
*)
- echo "Error: Unknown option '$*'!"
- exit 1
+ small_die "Unknown option '$*'!"
;;
esac
}
diff --git a/gen_compile.sh b/gen_compile.sh
index a2c70a8..fb77e2b 100755
--- a/gen_compile.sh
+++ b/gen_compile.sh
@@ -36,6 +36,8 @@ compile_external_modules() {
return
fi
+ local -x KV_OUT_DIR="${KERNEL_OUTPUTDIR}"
+
print_info 1 "$(get_indent 1)>> Compiling out-of-tree module(s) ..."
print_info 3 "COMMAND: ${command}" 1 0 1
@@ -236,7 +238,7 @@ compile_modules() {
local -x INSTALL_MOD_STRIP=1
else
print_info 1 "$(get_indent 1)>> Installing ${KV} modules ..."
- local -x INSTALL_MOD_STRIP=0
+ unset INSTALL_MOD_STRIP
fi
compile_generic "modules_install" kernel
@@ -303,38 +305,38 @@ compile_kernel() {
# if source != outputdir, we need this:
tmp_kernel_binary="${KERNEL_OUTPUTDIR}"/"${tmp_kernel_binary}"
tmp_kernel_binary2="${KERNEL_OUTPUTDIR}"/"${tmp_kernel_binary2}"
- systemmap="${KERNEL_OUTPUTDIR}"/System.map
+ local tmp_systemmap="${KERNEL_OUTPUTDIR}"/System.map
if isTrue "${CMD_INSTALL}"
then
copy_image_with_preserve \
- "kernel" \
+ "${GK_FILENAME_KERNEL_SYMLINK}" \
"${tmp_kernel_binary}" \
- "kernel-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_KERNEL}"
copy_image_with_preserve \
- "System.map" \
- "${systemmap}" \
- "System.map-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_SYSTEMMAP_SYMLINK}" \
+ "${tmp_systemmap}" \
+ "${GK_FILENAME_SYSTEMMAP}"
if isTrue "${GENZIMAGE}"
then
copy_image_with_preserve \
"kernelz" \
"${tmp_kernel_binary2}" \
- "kernelz-${KV}"
+ "${GK_FILENAME_KERNELZ}"
fi
else
- cp "${tmp_kernel_binary}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" \
- || gen_die "Could not copy the kernel binary to '${TMPDIR}'!"
+ cp "${tmp_kernel_binary}" "${TMPDIR}/${GK_FILENAME_TEMP_KERNEL}" \
+ || gen_die "Could not copy kernel binary '${tmp_kernel_binary}' to '${TMPDIR}'!"
- cp "${systemmap}" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" \
- || gen_die "Could not copy System.map to '${TMPDIR}'!"
+ cp "${tmp_systemmap}" "${TMPDIR}/${GK_FILENAME_TEMP_SYSTEMMAP}" \
+ || gen_die "Could not copy System.map '${tmp_systemmap}' to '${TMPDIR}'!"
if isTrue "${GENZIMAGE}"
then
- cp "${tmp_kernel_binary2}" "${TMPDIR}/kernelz-${KV}" \
- || gen_die "Could not copy the kernelz binary to '${TMPDIR}'!"
+ cp "${tmp_kernel_binary2}" "${TMPDIR}/${GK_FILENAME_TEMP_KERNELZ}" \
+ || gen_die "Could not copy kernelz binary '${tmp_kernel_binary2}' to '${TMPDIR}'!"
fi
fi
}
@@ -437,8 +439,7 @@ populate_binpkg() {
local REQUIRED_BINPKGS_PARENT_VARNAME="CHECK_L${CHECK_LEVEL_PARENT}_REQUIRED_BINPKGS"
local REQUIRED_BINPKGS_CURRENT_VARNAME="CHECK_L${CHECK_LEVEL_CURRENT}_REQUIRED_BINPKGS"
- local REQUIRED_BINPKGS_CURRENT_VARNAME_SEPARATE_WORD="${REQUIRED_BINPKGS_CURRENT_VARNAME}[@]"
- local REQUIRED_BINPKGS_CURRENT_VARNAME_SINGLE_WORD="${REQUIRED_BINPKGS_CURRENT_VARNAME}[*]"
+ local -n REQUIRED_BINPKGS_CURRENT_VARNAME_ref="${REQUIRED_BINPKGS_CURRENT_VARNAME}"
# Make sure we start with an empty array just in case ...
eval declare -ga ${REQUIRED_BINPKGS_CURRENT_VARNAME}=\(\)
@@ -487,7 +488,7 @@ populate_binpkg() {
# current .config.
if [[ -f "${BINPKG}" ]]
then
- local oldconfig_md5="$(tar -xaf "${BINPKG}" -O ./configs/.config.gk_orig 2>/dev/null | md5sum)"
+ local oldconfig_md5="$("${TAR_COMMAND}" -xaf "${BINPKG}" -O ./configs/.config.gk_orig 2>/dev/null | md5sum)"
local newconfig_md5="$(md5sum < "${TEMP}"/busybox-config)"
if [[ "${oldconfig_md5}" != "${newconfig_md5}" ]]
then
@@ -523,7 +524,7 @@ populate_binpkg() {
if [[ -f "${BINPKG}" ]]
then
local required_binpkg=
- for required_binpkg in "${!REQUIRED_BINPKGS_CURRENT_VARNAME_SEPARATE_WORD}"
+ for required_binpkg in "${REQUIRED_BINPKGS_CURRENT_VARNAME_ref[@]}"
do
# Create shorter variable value so we do not clutter output
local required_binpkg_filename=$(basename "${required_binpkg}")
@@ -537,7 +538,7 @@ populate_binpkg() {
print_info 3 "${CHECK_LEVEL_PREFIX}Existing ${P} binpkg is newer than '${required_binpkg_filename}'; Skipping ..."
done
- unset required_binpkg REQUIRED_BINPKGS_CURRENT_VARNAME_SEPARATE_WORD required_binpkg_filename
+ unset required_binpkg required_binpkg_filename
fi
if [[ -f "${BINPKG}" ]]
@@ -562,13 +563,22 @@ populate_binpkg() {
if [[ ! -f "${BINPKG}" ]]
then
print_info 3 "${CHECK_LEVEL_PREFIX}Binpkg '${BINPKG}' does NOT exist; Need to build ${P} ..."
+
+ local required_binpkgs=
+ local required_binpkg=
+ for required_binpkg in "${REQUIRED_BINPKGS_CURRENT_VARNAME_ref[@]}"
+ do
+ required_binpkgs+="${required_binpkg};"
+ done
+ unset required_binpkg required_binpkg_filename
+
gkbuild \
${PN} \
${PV} \
$(get_gkpkg_srcdir "${PN}") \
$(get_gkpkg_srctar "${PN}") \
"${BINPKG}" \
- "${!REQUIRED_BINPKGS_CURRENT_VARNAME_SINGLE_WORD}"
+ "${required_binpkgs}"
else
print_info 3 "${CHECK_LEVEL_PREFIX}Can keep using existing ${P} binpkg from '${BINPKG}'!"
[[ ${CHECK_LEVEL_CURRENT} -eq 0 ]] && print_info 2 "$(get_indent 2)${PN}: >> Using ${P} binpkg ..."
@@ -581,7 +591,7 @@ populate_binpkg() {
unset CHECK_L${CHECK_LEVEL_PARENT}_REQUIRED_BINPKGS
else
print_info 3 "${CHECK_LEVEL_PREFIX}Binpkg of ${P} is ready; Adding to list '${REQUIRED_BINPKGS_PARENT_VARNAME}' ..."
- eval ${REQUIRED_BINPKGS_PARENT_VARNAME}+=\( "${BINPKG}" \)
+ eval ${REQUIRED_BINPKGS_PARENT_VARNAME}+=\( \"${BINPKG}\" \)
fi
# REQUIRED_BINPKGS_CURRENT_VARNAME
diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index 503812c..2ff983f 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -17,17 +17,41 @@ determine_kernel_config_file() {
fi
else
local -a kconfig_candidates
- kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" )
- kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" )
- kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/generated-config" )
- kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config" )
- kconfig_candidates+=( "${DEFAULT_KERNEL_CONFIG}" )
+
+ local -a gk_kconfig_candidates
+ gk_kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" )
+ gk_kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" )
+ gk_kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/generated-config" )
+ gk_kconfig_candidates+=( "${GK_SHARE}/arch/${ARCH}/kernel-config" )
+ gk_kconfig_candidates+=( "${DEFAULT_KERNEL_CONFIG}" )
if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ]
then
print_info 1 "Default configuration was forced. Will ignore any user kernel configuration!"
+ kconfig_candidates=( ${gk_kconfig_candidates[@]} )
else
- kconfig_candidates=( "/etc/kernels/kernel-config-${ARCH}-${KV}" ${kconfig_candidates[@]} )
+ local -a user_kconfig_candidates
+
+ # Always prefer kernel config based on actual $KV reading
+ user_kconfig_candidates+=( "/etc/kernels/${GK_FILENAME_CONFIG}" )
+
+ if [ -n "${KERNEL_LOCALVERSION}" -a "${KERNEL_LOCALVERSION}" != "UNSET" ]
+ then
+ # Look for kernel config based on KERNEL_LOCALVERSION
+ # which we are going to use, too.
+ # This will allow user to copy previous kernel config file
+ # which includes LOV by default to new version when doing
+ # kernel upgrade since we add $ARCH to $LOV by default.
+ user_kconfig_candidates+=( "/etc/kernels/kernel-config-${VER}.${PAT}.${SUB}${EXV}${KERNEL_LOCALVERSION}" )
+ fi
+
+ # Look for genkernel-3.x configs for backward compatibility, too
+ user_kconfig_candidates+=( "/etc/kernels/kernel-config-${ARCH}-${KV}" )
+
+ kconfig_candidates=(
+ ${user_kconfig_candidates[@]}
+ ${gk_kconfig_candidates[@]}
+ )
fi
local f
@@ -72,9 +96,17 @@ determine_kernel_config_file() {
}
config_kernel() {
+ local diff_cmd="$(which zdiff 2>/dev/null)"
+ if [ -z "${diff_cmd}" ]
+ then
+ print_warning 5 "zdiff is not available."
+ diff_cmd="diff"
+ fi
+
cd "${KERNEL_DIR}" || gen_die "Failed to chdir to '${KERNEL_DIR}'!"
print_info 1 "kernel: >> Initializing ..."
+
if isTrue "${CLEAN}" && isTrue "${MRPROPER}"
then
print_info 2 "$(get_indent 1)>> --mrproper is set; Skipping 'make clean' ..."
@@ -92,16 +124,20 @@ config_kernel() {
if [ -f "${KERNEL_OUTPUTDIR}/.config" ]
then
# Current .config is different then one we are going to use
- if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] || \
- ! diff -q "${KERNEL_OUTPUTDIR}"/.config "${KERNEL_CONFIG}" >/dev/null
+ if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] \
+ || ! "${diff_cmd}" -q "${KERNEL_OUTPUTDIR}"/.config "${KERNEL_CONFIG}" >/dev/null
then
NOW=$(date +--%Y-%m-%d--%H-%M-%S)
cp "${KERNEL_OUTPUTDIR}/.config" "${KERNEL_OUTPUTDIR}/.config${NOW}.bak" \
|| gen_die "Could not backup kernel config (${KERNEL_OUTPUTDIR}/.config)"
print_info 1 "$(get_indent 1)>> Previous config backed up to .config${NOW}.bak"
- [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ] &&
- rm "${KERNEL_OUTPUTDIR}/.config" >/dev/null
+ if [ -n "${CMD_KERNEL_CONFIG}" -a "${CMD_KERNEL_CONFIG}" = "default" ]
+ then
+ print_info 3 "$(get_indent 1)>> Default kernel config was forced; Deleting existing kernel config '${KERNEL_OUTPUTDIR}/.config' ..."
+ rm "${KERNEL_OUTPUTDIR}/.config" >/dev/null \
+ || gen_die "Failed to delete '${KERNEL_OUTPUTDIR}/.config'!"
+ fi
fi
fi
fi
@@ -111,29 +147,31 @@ config_kernel() {
print_info 1 "$(get_indent 1)>> Running 'make mrproper' ..."
compile_generic mrproper kernel
else
- if [ -f "${KERNEL_OUTPUTDIR}/.config" ]
- then
- print_info 1 "$(get_indent 1)>> Using config from '${KERNEL_OUTPUTDIR}/.config' ..."
- else
- print_info 1 "$(get_indent 1)>> Using config from '${KERNEL_CONFIG}' ..."
- fi
print_info 1 "$(get_indent 1)>> --no-mrproper is set; Skipping 'make mrproper' ..."
fi
- # If we're not cleaning a la mrproper, then we don't want to try to overwrite the configs
- # or we might remove configurations someone is trying to test.
- if isTrue "${MRPROPER}" || [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
+ if [ ! -f "${KERNEL_OUTPUTDIR}/.config" ]
then
- print_info 1 "$(get_indent 1)>> Using config from '${KERNEL_CONFIG}' ..."
+ # We always need a kernel config file...
+ print_info 3 "$(get_indent 1)>> Copying '${KERNEL_CONFIG}' to '${KERNEL_OUTPUTDIR}/.config' ..."
- local message="Could not copy configuration file '${KERNEL_CONFIG}'!"
- if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}" 2>/dev/null)" == application/x-gzip ]]
+ local message="Failed to copy kernel config file '${KERNEL_CONFIG}' to '${KERNEL_OUTPUTDIR}/.config'!"
+ if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
then
# Support --kernel-config=/proc/config.gz, mainly
zcat "${KERNEL_CONFIG}" > "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
else
cp -aL "${KERNEL_CONFIG}" "${KERNEL_OUTPUTDIR}/.config" || gen_die "${message}"
fi
+ else
+ if ! "${diff_cmd}" -q "${KERNEL_OUTPUTDIR}"/.config "${KERNEL_CONFIG}" >/dev/null
+ then
+ print_warning 2 "$(get_indent 1)>> Will ignore kernel config from '${KERNEL_CONFIG}'"
+ print_warning 2 "$(get_indent 1) in favor of already existing but different kernel config"
+ print_warning 2 "$(get_indent 1) found in '${KERNEL_OUTPUTDIR}/.config' ..."
+ else
+ print_info 3 "$(get_indent 1)>> Can keep using already existing '${KERNEL_OUTPUTDIR}/.config' which is identical to --kernel-config file ..."
+ fi
fi
if isTrue "${OLDCONFIG}"
@@ -193,6 +231,25 @@ config_kernel() {
fi
fi
+ # --kernel-localversion handling
+ if [ -n "${KERNEL_LOCALVERSION}" ]
+ then
+ local cfg_CONFIG_LOCALVERSION=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_LOCALVERSION")
+ case "${KERNEL_LOCALVERSION}" in
+ UNSET)
+ print_info 2 "$(get_indent 1)>> Ensure that CONFIG_LOCALVERSION is unset ..."
+ if [ -n "${cfg_CONFIG_LOCALVERSION}" ]
+ then
+ kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_LOCALVERSION" ""
+ fi
+ ;;
+ *)
+ print_info 2 "$(get_indent 1)>> Ensure that CONFIG_LOCALVERSION is set ..."
+ kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_LOCALVERSION" "\"${KERNEL_LOCALVERSION}\""
+ ;;
+ esac
+ fi
+
# Do we support modules at all?
local cfg_CONFIG_MODULES=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_MODULES")
if isTrue "${cfg_CONFIG_MODULES}"
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index c969188..db6ccf9 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -7,7 +7,7 @@ determine_KV() {
if ! isTrue "${KERNEL_SOURCES}" && [ -e "${KERNCACHE}" ]
then
- tar -x -C "${TEMP}" -f "${KERNCACHE}" kerncache.config \
+ "${TAR_COMMAND}" -x -C "${TEMP}" -f "${KERNCACHE}" kerncache.config \
|| gen_die "Failed to extract 'kerncache.config' from '${KERNCACHE}' to '${TEMP}'!"
if [ -e "${TEMP}/kerncache.config" ]
@@ -44,10 +44,10 @@ determine_KV() {
[ -f "${KERNEL_OUTPUTDIR}/include/linux/utsrelease.h" ] && \
VERSION_SOURCE="${KERNEL_OUTPUTDIR}/include/linux/utsrelease.h"
# Handle new-style releases where version.h doesn't have UTS_RELEASE
- if [ -f ${KERNEL_OUTPUTDIR}/include/config/kernel.release ]
+ if [ -f "${KERNEL_OUTPUTDIR}/include/config/kernel.release" ]
then
print_info 3 "Using '${KERNEL_OUTPUTDIR}/include/config/kernel.release' to extract LOCALVERSION ..."
- UTS_RELEASE=$(cat ${KERNEL_OUTPUTDIR}/include/config/kernel.release)
+ UTS_RELEASE=$(cat "${KERNEL_OUTPUTDIR}/include/config/kernel.release")
LOV=$(echo ${UTS_RELEASE}|sed -e "s/${VER}.${PAT}.${SUB}${EXV}//")
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
elif [ -n "${VERSION_SOURCE}" ]
@@ -83,6 +83,168 @@ determine_KV() {
fi
}
+determine_output_filenames() {
+ print_info 5 '' 1 0
+
+ GK_FILENAME_CONFIG="kernel-config-${KV}"
+ GK_FILENAME_KERNELZ="kernelz-${KV}"
+ GK_FILENAME_TEMP_CONFIG="config-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_INITRAMFS="initramfs-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_KERNEL="kernel-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_KERNELZ="kernelz-${ARCH}-${KV}"
+ GK_FILENAME_TEMP_SYSTEMMAP="System.map-${ARCH}-${KV}"
+
+ isTrue "${CMD_INSTALL}" || return
+
+ # Do we have values?
+ if [ -z "${KERNEL_FILENAME}" ]
+ then
+ gen_die "--kernel-filename must be set to a non-empty value!"
+ elif [ -z "${KERNEL_SYMLINK_NAME}" ]
+ then
+ gen_die "--kernel-symlink-name must be set to a non-empty value!"
+ elif [ -z "${SYSTEMMAP_FILENAME}" ]
+ then
+ gen_die "--systemmap-filename must be set to a non-empty value!"
+ elif [ -z "${SYSTEMMAP_SYMLINK_NAME}" ]
+ then
+ gen_die "--systemmap-symlink-name must be set to a non-empty value!"
+ elif [ -z "${INITRAMFS_FILENAME}" ]
+ then
+ gen_die "--initramfs-filename must be set to a non-empty value!"
+ elif [ -z "${INITRAMFS_FILENAME}" ]
+ then
+ gen_die "--initramfs-filename must be set to a non-empty value!"
+ fi
+
+ # Kernel
+ GK_FILENAME_KERNEL=$(arch_replace "${KERNEL_FILENAME}")
+ GK_FILENAME_KERNEL=$(kv_replace "${GK_FILENAME_KERNEL}")
+
+ if [ -z "${GK_FILENAME_KERNEL}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_KERNEL' is empty!"
+ else
+ print_info 5 "GK_FILENAME_KERNEL set to '${GK_FILENAME_KERNEL}' (was: '${KERNEL_FILENAME}')"
+ fi
+
+ # Kernel symlink
+ GK_FILENAME_KERNEL_SYMLINK=$(arch_replace "${KERNEL_SYMLINK_NAME}")
+ GK_FILENAME_KERNEL_SYMLINK=$(kv_replace "${GK_FILENAME_KERNEL_SYMLINK}")
+
+ if [ -z "${GK_FILENAME_KERNEL_SYMLINK}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_KERNEL_SYMLINK' is empty!"
+ else
+ print_info 5 "GK_FILENAME_KERNEL_SYMLINK set to '${GK_FILENAME_KERNEL_SYMLINK}' (was: '${KERNEL_SYMLINK_NAME}')"
+ fi
+
+ if [[ "${GK_FILENAME_KERNEL}" == "${GK_FILENAME_KERNEL_SYMLINK}" ]]
+ then
+ gen_die "--kernel-filename cannot be identical with --kernel-symlink-name!"
+ fi
+
+ # System.map
+ GK_FILENAME_SYSTEMMAP=$(arch_replace "${SYSTEMMAP_FILENAME}")
+ GK_FILENAME_SYSTEMMAP=$(kv_replace "${GK_FILENAME_SYSTEMMAP}")
+
+ if [ -z "${GK_FILENAME_SYSTEMMAP}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_SYSTEMMAP' is empty!"
+ else
+ print_info 5 "GK_FILENAME_SYSTEMMAP set to '${GK_FILENAME_SYSTEMMAP}' (was: '${SYSTEMMAP_FILENAME}')"
+ fi
+
+ # System.map symlink
+ GK_FILENAME_SYSTEMMAP_SYMLINK=$(arch_replace "${SYSTEMMAP_SYMLINK_NAME}")
+ GK_FILENAME_SYSTEMMAP_SYMLINK=$(kv_replace "${GK_FILENAME_SYSTEMMAP_SYMLINK}")
+
+ if [ -z "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_SYSTEMMAP_SYMLINK' is empty!"
+ else
+ print_info 5 "GK_FILENAME_SYSTEMMAP_SYMLINK set to '${GK_FILENAME_SYSTEMMAP_SYMLINK}' (was: '${SYSTEMMAP_SYMLINK_NAME}')"
+ fi
+
+ if [[ "${GK_FILENAME_SYSTEMMAP}" == "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]]
+ then
+ gen_die "--systemmap-filename cannot be identical with --systemmap-symlink-name!"
+ fi
+
+ # Initramfs
+ GK_FILENAME_INITRAMFS=$(arch_replace "${INITRAMFS_FILENAME}")
+ GK_FILENAME_INITRAMFS=$(kv_replace "${GK_FILENAME_INITRAMFS}")
+
+ if [ -z "${GK_FILENAME_INITRAMFS}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_INITRAMFS' is empty!"
+ else
+ print_info 5 "GK_FILENAME_INITRAMFS set to '${GK_FILENAME_INITRAMFS}' (was: '${INITRAMFS_FILENAME}')"
+ fi
+
+ # Initramfs symlink
+ GK_FILENAME_INITRAMFS_SYMLINK=$(arch_replace "${INITRAMFS_SYMLINK_NAME}")
+ GK_FILENAME_INITRAMFS_SYMLINK=$(kv_replace "${GK_FILENAME_INITRAMFS_SYMLINK}")
+
+ if [ -z "${GK_FILENAME_INITRAMFS_SYMLINK}" ]
+ then
+ gen_die "Internal error: Variable 'GK_FILENAME_INITRAMFS_SYMLINK' is empty!"
+ else
+ print_info 5 "GK_FILENAME_INITRAMFS_SYMLINK set to '${GK_FILENAME_INITRAMFS_SYMLINK}' (was: '${INITRAMFS_SYMLINK_NAME}')"
+ fi
+
+ if [[ "${GK_FILENAME_INITRAMFS}" == "${GK_FILENAME_INITRAMFS_SYMLINK}" ]]
+ then
+ gen_die "--initramfs-filename cannot be identical with --initramfs-symlink-name!"
+ fi
+
+ # Make sure we have unique filenames
+ if [[ "${GK_FILENAME_KERNEL}" == "${GK_FILENAME_INITRAMFS}" ]]
+ then
+ gen_die "--kernel-filename cannot be identical with --initramfs-filename!"
+ elif [[ "${GK_FILENAME_KERNEL}" == "${GK_FILENAME_SYSTEMMAP}" ]]
+ then
+ gen_die "--kernel-filename cannot be identical with --systemmap-filename!"
+ elif [[ "${GK_FILENAME_INITRAMFS}" == "${GK_FILENAME_SYSTEMMAP}" ]]
+ then
+ gen_die "--initramfs-filename cannot be identical with --systemmap-filename!"
+ fi
+
+ if [[ "${GK_FILENAME_KERNEL_SYMLINK}" == "${GK_FILENAME_INITRAMFS_SYMLINK}" ]]
+ then
+ gen_die "--kernel-symlink-name cannot be identical with --initramfs-symlink-name!"
+ elif [[ "${GK_FILENAME_KERNEL_SYMLINK}" == "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]]
+ then
+ gen_die "--kernel-symlink-name cannot be identical with --systemmap-symlink-name!"
+ elif [[ "${GK_FILENAME_INITRAMFS_SYMLINK}" == "${GK_FILENAME_SYSTEMMAP_SYMLINK}" ]]
+ then
+ gen_die "--initramfs-symlink-name cannot be identical with --systemmap-symlink-name!"
+ fi
+
+ local -a filename_vars
+ filename_vars+=( 'GK_FILENAME_KERNEL;--kernel-filename' )
+ filename_vars+=( 'GK_FILENAME_KERNEL_SYMLINK;--kernel-symlink-name' )
+ filename_vars+=( 'GK_FILENAME_INITRAMFS;--initramfs-filename' )
+ filename_vars+=( 'GK_FILENAME_INITRAMFS_SYMLINK;--initramfs-symlink-name' )
+ filename_vars+=( 'GK_FILENAME_SYSTEMMAP;--systemmap-filename' )
+ filename_vars+=( 'GK_FILENAME_SYSTEMMAP_SYMLINK;--systemmap-symlink-name' )
+
+ local valid_filename_pattern='^[a-zA-Z0-9_.+-]{1,}$'
+ local filename_combo filename_varname filename_option
+
+ for filename_combo in "${filename_vars[@]}"
+ do
+ filename_combo=( ${filename_combo//;/ } )
+ filename_varname=${filename_combo[0]}
+ filename_option=${filename_combo[1]}
+
+ if [[ ! "${!filename_varname}" =~ ${valid_filename_pattern} ]]
+ then
+ gen_die "${filename_varname} value '${!filename_varname}' does not match regex '${valid_filename_pattern}'. Check ${filename_option} option!"
+ fi
+ done
+}
+
determine_real_args() {
# Unset known variables which will interfere with _tc-getPROG().
local tc_var tc_varname_build tc_vars=$(get_tc_vars)
@@ -95,100 +257,154 @@ determine_real_args() {
print_info 4 "Resolving config file, command line, and arch default settings."
- # Dest / Config File Command Line Arch Default
- # ------------------ ------------ ------------
- set_config_with_override STRING LOGFILE CMD_LOGFILE "/var/log/genkernel.conf"
- set_config_with_override STRING KERNEL_DIR CMD_KERNEL_DIR "${DEFAULT_KERNEL_SOURCE}"
- set_config_with_override BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes"
- set_config_with_override STRING KNAME CMD_KERNNAME "genkernel"
-
- set_config_with_override STRING COMPRESS_INITRD CMD_COMPRESS_INITRD "$DEFAULT_COMPRESS_INITRD"
- set_config_with_override STRING COMPRESS_INITRD_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE"
- set_config_with_override STRING MAKEOPTS CMD_MAKEOPTS "$DEFAULT_MAKEOPTS"
- set_config_with_override STRING NICE CMD_NICE "10"
- set_config_with_override STRING KERNEL_MAKE CMD_KERNEL_MAKE "$DEFAULT_KERNEL_MAKE"
- set_config_with_override STRING UTILS_CFLAGS CMD_UTILS_CFLAGS "$DEFAULT_UTILS_CFLAGS"
- set_config_with_override STRING UTILS_MAKE CMD_UTILS_MAKE "$DEFAULT_UTILS_MAKE"
- set_config_with_override STRING KERNEL_CC CMD_KERNEL_CC "$DEFAULT_KERNEL_CC"
- set_config_with_override STRING KERNEL_LD CMD_KERNEL_LD "$DEFAULT_KERNEL_LD"
- set_config_with_override STRING KERNEL_AS CMD_KERNEL_AS "$DEFAULT_KERNEL_AS"
- set_config_with_override STRING UTILS_CC CMD_UTILS_CC "$DEFAULT_UTILS_CC"
- set_config_with_override STRING UTILS_LD CMD_UTILS_LD "$DEFAULT_UTILS_LD"
- set_config_with_override STRING UTILS_AS CMD_UTILS_AS "$DEFAULT_UTILS_AS"
-
- set_config_with_override STRING CROSS_COMPILE CMD_CROSS_COMPILE
- set_config_with_override STRING BOOTDIR CMD_BOOTDIR "/boot"
- set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${KERNEL_DIR}"
- set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
-
- set_config_with_override BOOL SPLASH CMD_SPLASH "no"
- set_config_with_override BOOL CLEAR_CACHEDIR CMD_CLEAR_CACHEDIR "no"
- set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR "no"
- set_config_with_override BOOL MRPROPER CMD_MRPROPER "yes"
- set_config_with_override BOOL MENUCONFIG CMD_MENUCONFIG "no"
- set_config_with_override BOOL GCONFIG CMD_GCONFIG "no"
- set_config_with_override BOOL NCONFIG CMD_NCONFIG "no"
- set_config_with_override BOOL XCONFIG CMD_XCONFIG "no"
- set_config_with_override BOOL CLEAN CMD_CLEAN "yes"
-
- set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE
- set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE
- set_config_with_override BOOL MODULEREBUILD CMD_MODULEREBUILD "yes"
- set_config_with_override STRING KERNCACHE CMD_KERNCACHE
- set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes"
- set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES "no"
- set_config_with_override STRING INITRAMFS_OVERLAY CMD_INITRAMFS_OVERLAY
- set_config_with_override BOOL MOUNTBOOT CMD_MOUNTBOOT "yes"
- set_config_with_override BOOL BUILD_STATIC CMD_STATIC "no"
- set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG "yes"
- set_config_with_override BOOL SYMLINK CMD_SYMLINK "no"
- set_config_with_override STRING INSTALL_MOD_PATH CMD_INSTALL_MOD_PATH
- set_config_with_override BOOL OLDCONFIG CMD_OLDCONFIG "yes"
- set_config_with_override BOOL SSH CMD_SSH "no"
- set_config_with_override STRING SSH_AUTHORIZED_KEYS_FILE CMD_SSH_AUTHORIZED_KEYS_FILE "/etc/dropbear/authorized_keys"
- set_config_with_override STRING SSH_HOST_KEYS CMD_SSH_HOST_KEYS "create"
- set_config_with_override BOOL STRACE CMD_STRACE "no"
- set_config_with_override BOOL BCACHE CMD_BCACHE "no"
- set_config_with_override BOOL LVM CMD_LVM "no"
- set_config_with_override BOOL DMRAID CMD_DMRAID "no"
- set_config_with_override BOOL ISCSI CMD_ISCSI "no"
- set_config_with_override BOOL HYPERV CMD_HYPERV "no"
- set_config_with_override STRING BOOTLOADER CMD_BOOTLOADER "no"
- set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes"
- set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
- set_config_with_override BOOL NFS CMD_NFS "yes"
- set_config_with_override STRING MICROCODE CMD_MICROCODE "all"
- set_config_with_override BOOL MICROCODE_INITRAMFS CMD_MICROCODE_INITRAMFS "yes"
- set_config_with_override BOOL UNIONFS CMD_UNIONFS "no"
- set_config_with_override BOOL NETBOOT CMD_NETBOOT "no"
- set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT
- set_config_with_override BOOL DISKLABEL CMD_DISKLABEL "yes"
- set_config_with_override BOOL LUKS CMD_LUKS "no"
- set_config_with_override BOOL GPG CMD_GPG "no"
- set_config_with_override BOOL MDADM CMD_MDADM "no"
- set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG
- set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no"
- set_config_with_override BOOL XFSPROGS CMD_XFSPROGS "no"
- set_config_with_override BOOL ZFS CMD_ZFS "$(rootfs_type_is zfs)"
- set_config_with_override BOOL BTRFS CMD_BTRFS "$(rootfs_type_is btrfs)"
- set_config_with_override BOOL VIRTIO CMD_VIRTIO "no"
- set_config_with_override BOOL MULTIPATH CMD_MULTIPATH "no"
- set_config_with_override BOOL FIRMWARE CMD_FIRMWARE "no"
- set_config_with_override STRING FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware"
- set_config_with_override STRING FIRMWARE_FILES CMD_FIRMWARE_FILES
- set_config_with_override BOOL FIRMWARE_INSTALL CMD_FIRMWARE_INSTALL "no"
- set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS "no"
- set_config_with_override BOOL WRAP_INITRD CMD_WRAP_INITRD "no"
- set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE "no"
- set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes"
- set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO "no"
- set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
- set_config_with_override STRING STRIP_TYPE CMD_STRIP_TYPE "modules"
- set_config_with_override BOOL INSTALL CMD_INSTALL "yes"
- set_config_with_override BOOL CLEANUP CMD_CLEANUP "yes"
+ # Dest / Config File Command Line Arch Default
+ # ------------------ ------------ ------------
+ set_config_with_override STRING TMPDIR CMD_TMPDIR "/var/tmp/genkernel"
+ set_config_with_override STRING LOGFILE CMD_LOGFILE "/var/log/genkernel.conf"
+ set_config_with_override STRING KERNEL_DIR CMD_KERNEL_DIR "${DEFAULT_KERNEL_SOURCE}"
+ set_config_with_override BOOL KERNEL_SOURCES CMD_KERNEL_SOURCES "yes"
+ set_config_with_override STRING INITRAMFS_FILENAME CMD_INITRAMFS_FILENAME "${DEFAULT_INITRAMFS_FILENAME}"
+ set_config_with_override STRING INITRAMFS_SYMLINK_NAME CMD_INITRAMFS_SYMLINK_NAME "${DEFAULT_INITRAMFS_SYMLINK_NAME}"
+ set_config_with_override STRING KERNEL_FILENAME CMD_KERNEL_FILENAME "${DEFAULT_KERNEL_FILENAME}"
+ set_config_with_override STRING KERNEL_SYMLINK_NAME CMD_KERNEL_SYMLINK_NAME "${DEFAULT_KERNEL_SYMLINK_NAME}"
+ set_config_with_override STRING SYSTEMMAP_FILENAME CMD_SYSTEMMAP_FILENAME "${DEFAULT_SYSTEMMAP_FILENAME}"
+ set_config_with_override STRING SYSTEMMAP_SYMLINK_NAME CMD_SYSTEMMAP_SYMLINK_NAME "${DEFAULT_SYSTEMMAP_SYMLINK_NAME}"
+
+ set_config_with_override STRING CHECK_FREE_DISK_SPACE_BOOTDIR CMD_CHECK_FREE_DISK_SPACE_BOOTDIR
+ set_config_with_override STRING CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR CMD_CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR
+
+ set_config_with_override STRING COMPRESS_INITRD CMD_COMPRESS_INITRD "$DEFAULT_COMPRESS_INITRD"
+ set_config_with_override STRING COMPRESS_INITRD_TYPE CMD_COMPRESS_INITRD_TYPE "$DEFAULT_COMPRESS_INITRD_TYPE"
+ set_config_with_override STRING MAKEOPTS CMD_MAKEOPTS "$DEFAULT_MAKEOPTS"
+ set_config_with_override STRING NICE CMD_NICE "10"
+ set_config_with_override STRING KERNEL_MAKE CMD_KERNEL_MAKE "$DEFAULT_KERNEL_MAKE"
+ set_config_with_override STRING UTILS_CFLAGS CMD_UTILS_CFLAGS "$DEFAULT_UTILS_CFLAGS"
+ set_config_with_override STRING UTILS_MAKE CMD_UTILS_MAKE "$DEFAULT_UTILS_MAKE"
+ set_config_with_override STRING KERNEL_CC CMD_KERNEL_CC "$DEFAULT_KERNEL_CC"
+ set_config_with_override STRING KERNEL_LD CMD_KERNEL_LD "$DEFAULT_KERNEL_LD"
+ set_config_with_override STRING KERNEL_AS CMD_KERNEL_AS "$DEFAULT_KERNEL_AS"
+ set_config_with_override STRING UTILS_CC CMD_UTILS_CC "$DEFAULT_UTILS_CC"
+ set_config_with_override STRING UTILS_LD CMD_UTILS_LD "$DEFAULT_UTILS_LD"
+ set_config_with_override STRING UTILS_AS CMD_UTILS_AS "$DEFAULT_UTILS_AS"
+
+ set_config_with_override STRING CROSS_COMPILE CMD_CROSS_COMPILE
+ set_config_with_override STRING BOOTDIR CMD_BOOTDIR "/boot"
+ set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${KERNEL_DIR}"
+ set_config_with_override STRING KERNEL_APPEND_LOCALVERSION CMD_KERNEL_APPEND_LOCALVERSION
+ set_config_with_override STRING KERNEL_LOCALVERSION CMD_KERNEL_LOCALVERSION "-%%ARCH%%"
+ set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
+
+ set_config_with_override BOOL SPLASH CMD_SPLASH "no"
+ set_config_with_override BOOL CLEAR_CACHEDIR CMD_CLEAR_CACHEDIR "no"
+ set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR "no"
+ set_config_with_override BOOL MRPROPER CMD_MRPROPER "yes"
+ set_config_with_override BOOL MENUCONFIG CMD_MENUCONFIG "no"
+ set_config_with_override BOOL GCONFIG CMD_GCONFIG "no"
+ set_config_with_override BOOL NCONFIG CMD_NCONFIG "no"
+ set_config_with_override BOOL XCONFIG CMD_XCONFIG "no"
+ set_config_with_override BOOL CLEAN CMD_CLEAN "yes"
+
+ set_config_with_override STRING MINKERNPACKAGE CMD_MINKERNPACKAGE
+ set_config_with_override STRING MODULESPACKAGE CMD_MODULESPACKAGE
+ set_config_with_override BOOL MODULEREBUILD CMD_MODULEREBUILD "yes"
+ set_config_with_override STRING KERNCACHE CMD_KERNCACHE
+ set_config_with_override BOOL RAMDISKMODULES CMD_RAMDISKMODULES "yes"
+ set_config_with_override BOOL ALLRAMDISKMODULES CMD_ALLRAMDISKMODULES "no"
+ set_config_with_override STRING INITRAMFS_OVERLAY CMD_INITRAMFS_OVERLAY
+ set_config_with_override BOOL MOUNTBOOT CMD_MOUNTBOOT "yes"
+ set_config_with_override BOOL BUILD_STATIC CMD_STATIC "no"
+ set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG "yes"
+ set_config_with_override BOOL SYMLINK CMD_SYMLINK "no"
+ set_config_with_override STRING INSTALL_MOD_PATH CMD_INSTALL_MOD_PATH
+ set_config_with_override BOOL OLDCONFIG CMD_OLDCONFIG "yes"
+ set_config_with_override BOOL SANDBOX CMD_SANDBOX "yes"
+ set_config_with_override BOOL SSH CMD_SSH "no"
+ set_config_with_override STRING SSH_AUTHORIZED_KEYS_FILE CMD_SSH_AUTHORIZED_KEYS_FILE "/etc/dropbear/authorized_keys"
+ set_config_with_override STRING SSH_HOST_KEYS CMD_SSH_HOST_KEYS "create"
+ set_config_with_override BOOL STRACE CMD_STRACE "no"
+ set_config_with_override BOOL BCACHE CMD_BCACHE "no"
+ set_config_with_override BOOL LVM CMD_LVM "no"
+ set_config_with_override BOOL DMRAID CMD_DMRAID "no"
+ set_config_with_override BOOL ISCSI CMD_ISCSI "no"
+ set_config_with_override BOOL HYPERV CMD_HYPERV "no"
+ set_config_with_override STRING BOOTLOADER CMD_BOOTLOADER "no"
+ set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes"
+ set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
+ set_config_with_override BOOL NFS CMD_NFS "yes"
+ set_config_with_override STRING MICROCODE CMD_MICROCODE "all"
+ set_config_with_override BOOL MICROCODE_INITRAMFS CMD_MICROCODE_INITRAMFS "yes"
+ set_config_with_override BOOL UNIONFS CMD_UNIONFS "no"
+ set_config_with_override BOOL NETBOOT CMD_NETBOOT "no"
+ set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT
+ set_config_with_override BOOL DISKLABEL CMD_DISKLABEL "yes"
+ set_config_with_override BOOL LUKS CMD_LUKS "no"
+ set_config_with_override BOOL GPG CMD_GPG "no"
+ set_config_with_override BOOL MDADM CMD_MDADM "no"
+ set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG
+ set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no"
+ set_config_with_override BOOL XFSPROGS CMD_XFSPROGS "no"
+ set_config_with_override BOOL ZFS CMD_ZFS "$(rootfs_type_is zfs)"
+ set_config_with_override BOOL BTRFS CMD_BTRFS "$(rootfs_type_is btrfs)"
+ set_config_with_override BOOL VIRTIO CMD_VIRTIO "no"
+ set_config_with_override BOOL MULTIPATH CMD_MULTIPATH "no"
+ set_config_with_override BOOL FIRMWARE CMD_FIRMWARE "no"
+ set_config_with_override STRING FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware"
+ set_config_with_override STRING FIRMWARE_FILES CMD_FIRMWARE_FILES
+ set_config_with_override BOOL FIRMWARE_INSTALL CMD_FIRMWARE_INSTALL "no"
+ set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS "no"
+ set_config_with_override BOOL WRAP_INITRD CMD_WRAP_INITRD "no"
+ set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE "no"
+ set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes"
+ set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO "no"
+ set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG
+ set_config_with_override STRING STRIP_TYPE CMD_STRIP_TYPE "modules"
+ set_config_with_override BOOL INSTALL CMD_INSTALL "yes"
+ set_config_with_override BOOL CLEANUP CMD_CLEANUP "yes"
+
+ local can_write_log=no
+ if [ -w "${LOGFILE}" ]
+ then
+ can_write_log=yes
+ elif [ -w "$(dirname "${LOGFILE}")" ]
+ then
+ can_write_log=yes
+ fi
+
+ if ! isTrue "${can_write_log}"
+ then
+ small_die "Cannot write to '${LOGFILE}'!"
+ fi
+
+ echo ">>> Started genkernel v${GK_V} on: $(date +"%Y-%m-%d %H:%M:%S")" > "${LOGFILE}" 2>/dev/null || small_die "Could not write to '${LOGFILE}'!"
+
+ dump_debugcache
+
+ if isTrue "$(has_space_characters "${TMPDIR}")"
+ then
+ # Packages like util-linux will fail to compile when path to
+ # build dir contains spaces
+ gen_die "--tmpdir '${TMPDIR}' contains space character(s) which are not supported!"
+ fi
+
+ if [ ! -d "${TMPDIR}" ]
+ then
+ mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!"
+ fi
+
+ declare -gr TEMP=$(mktemp -d -p "${TMPDIR}" gk.XXXXXXXX 2>/dev/null)
+ [ -z "${TEMP}" ] && gen_die "'mktemp -d -p \"${TMPDIR}\" gk.XXXXXXXX' failed!"
+
+ if ! isTrue "${CLEANUP}"
+ then
+ local no_cleanup_marker="${TEMP}/.no_cleanup"
+ print_info 5 "Creating no cleanup marker '${no_cleanup_marker}' ..."
+ touch "${no_cleanup_marker}" || gen_die "Failed to create '${no_cleanup_marker}'!"
+ fi
declare -gr GK_V_CACHEDIR="${CACHE_DIR}/${GK_V}"
+ declare -gr KCONFIG_MODIFIED_MARKER="${TEMP}/.kconfig_modified"
+
if [ -n "${CMD_CROSS_COMPILE}" ]
then
if ! isTrue "$(is_valid_triplet "${CMD_CROSS_COMPILE}")"
@@ -374,6 +590,8 @@ determine_real_args() {
fi
fi
+ local need_tar=no
+
if [ -n "${MINKERNPACKAGE}" ]
then
MINKERNPACKAGE=$(expand_file "${CMD_MINKERNPACKAGE}")
@@ -388,6 +606,8 @@ determine_real_args() {
mkdir -p "${minkernpackage_dir}" \
|| gen_die "Failed to create '${minkernpackage_dir}'!"
fi
+
+ need_tar=yes
fi
if [ -n "${MODULESPACKAGE}" ]
@@ -404,6 +624,8 @@ determine_real_args() {
mkdir -p "${modulespackage_dir}" \
|| gen_die "Failed to create '${modulespackage_dir}'!"
fi
+
+ need_tar=yes
fi
if [ -n "${KERNCACHE}" ]
@@ -420,6 +642,63 @@ determine_real_args() {
mkdir -p "${kerncache_dir}" \
|| gen_die "Failed to create '${kerncache_dir}'!"
fi
+
+ need_tar=yes
+ fi
+
+ # We always need to populate KERNEL_LOCALVERSION to be able to warn
+ # if user changed value but didn't rebuild kernel
+ local valid_localversion_pattern='^[A-Za-z0-9_.+-]{1,}$'
+
+ if [ -n "${KERNEL_LOCALVERSION}" ]
+ then
+ case "${KERNEL_LOCALVERSION}" in
+ UNSET)
+ ;;
+ *)
+ KERNEL_LOCALVERSION=$(arch_replace "${KERNEL_LOCALVERSION}")
+ if [ -z "${KERNEL_LOCALVERSION}" ]
+ then
+ # We somehow lost value...
+ gen_die "Internal error: Variable 'KERNEL_LOCALVERSION' is empty!"
+ fi
+
+ if [[ ! "${KERNEL_LOCALVERSION}" =~ ${valid_localversion_pattern} ]]
+ then
+ gen_die "--kernel-localversion value '${KERNEL_LOCALVERSION}' does not match '${valid_localversion_pattern}' regex!"
+ fi
+ ;;
+ esac
+ fi
+
+ if [ -n "${KERNEL_APPEND_LOCALVERSION}" ]
+ then
+ if [[ ! "${KERNEL_APPEND_LOCALVERSION}" =~ ${valid_localversion_pattern} ]]
+ then
+ gen_die "--kernel-append-localversion value '${KERNEL_APPEND_LOCALVERSION}' does not match '${valid_localversion_pattern}' regex!"
+ fi
+
+ if [[ "${KERNEL_LOCALVERSION}" == "UNSET" ]]
+ then
+ gen_die "Cannot append '${KERNEL_APPEND_LOCALVERSION}' to KERNEL_LOCALVERSION you want to unset!"
+ else
+ KERNEL_LOCALVERSION+="${KERNEL_APPEND_LOCALVERSION}"
+ fi
+ fi
+
+ if isTrue "${BUILD_KERNEL}"
+ then
+ if isTrue "$(has_space_characters "${KERNEL_OUTPUTDIR}")"
+ then
+ # Kernel Makefile doesn't support spaces in outputdir path...
+ gen_die "--kernel-outputdir '${KERNEL_OUTPUTDIR}' contains space character(s) which are not supported!"
+ fi
+
+ if [ "${KERNEL_DIR}" != "${KERNEL_OUTPUTDIR}" -a ! -d "${KERNEL_OUTPUTDIR}" ]
+ then
+ print_warning 3 "Set --kernel-outputdir '${KERNEL_OUTPUTDIR}' does not exist; Will try to create ..."
+ mkdir -p "${KERNEL_OUTPUTDIR}" || gen_die "Failed to create '${KERNEL_OUTPUTDIR}'!"
+ fi
fi
if ! isTrue "${BUILD_RAMDISK}"
@@ -484,6 +763,48 @@ determine_real_args() {
done
unset FEATURE_REQUIRING_BUSYBOX FEATURES_REQUIRING_BUSYBOX
fi
+
+ DU_COMMAND="$(which du 2>/dev/null)"
+
+ LDDTREE_COMMAND="$(which lddtree 2>/dev/null)"
+ if [ -z "${LDDTREE_COMMAND}" ]
+ then
+ gen_die "lddtree not found. Is app-misc/pax-utils installed?"
+ fi
+
+ CPIO_COMMAND="$(which cpio 2>/dev/null)"
+ if [[ -z "${CPIO_COMMAND}" ]]
+ then
+ # This will be fatal because we cpio either way
+ gen_die "cpio binary not found. Is app-arch/cpio installed?"
+ elif ! "${LDDTREE_COMMAND}" -l "${CPIO_COMMAND}" &>/dev/null
+ then
+ # This is typically the case when app-misc/pax-utils[python] is used
+ # and selected Python version isn't supported by pax-utils or
+ # dev-python/pyelftools yet, #618056.
+ gen_die "'\"${LDDTREE_COMMAND}\" -l \"${CPIO_COMMAND}\"' failed -- cannot generate initramfs without working lddtree!"
+ fi
+
+ SANDBOX_COMMAND=
+ if isTrue "${SANDBOX}"
+ then
+ SANDBOX_COMMAND="$(which sandbox 2>/dev/null)"
+ if [ -z "${SANDBOX_COMMAND}" ]
+ then
+ gen_die "Sandbox not found. Is sys-apps/sandbox installed?"
+ fi
+ fi
+
+ need_tar=yes
+ fi
+
+ if isTrue "${need_tar}"
+ then
+ TAR_COMMAND="$(which tar 2>/dev/null)"
+ if [ -z "${TAR_COMMAND}" ]
+ then
+ gen_die "tar not found. Is app-arch/tar installed?"
+ fi
fi
MICROCODE=${MICROCODE,,}
diff --git a/gen_funcs.sh b/gen_funcs.sh
index 31e4a6c..9e7d573 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -25,26 +25,34 @@ isTrue() {
set_color_vars() {
if ! isTrue "${NOCOLOR}"
then
+ BOLD=$'\e[0;01m'
+ UNDER=$'\e[4m'
GOOD=$'\e[32;01m'
WARN=$'\e[33;01m'
BAD=$'\e[31;01m'
NORMAL=$'\e[0m'
- BOLD=$'\e[0;01m'
- UNDER=$'\e[4m'
else
+ BOLD=''
+ UNDER=''
GOOD=''
WARN=''
BAD=''
NORMAL=''
- BOLD=''
- UNDER=''
fi
}
set_color_vars
dump_debugcache() {
TODEBUGCACHE=no
- echo "${DEBUGCACHE}" >> "${LOGFILE}"
+
+ if [ -w "${LOGFILE}" ]
+ then
+ echo "${DEBUGCACHE}" >> "${LOGFILE}"
+ else
+ echo "WARNING: Cannot write to '${LOGFILE}'!"
+ echo "${DEBUGCACHE}"
+ fi
+
DEBUGCACHE=
}
@@ -201,6 +209,48 @@ can_run_programs_compiled_by_genkernel() {
echo "${can_run_programs}"
}
+has_space_characters() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
+
+ local testvalue=${1}
+ local has_space_characters=no
+
+ local space_pattern='[[:space:]]'
+ if [[ "${testvalue}" =~ ${space_pattern} ]]
+ then
+ has_space_characters=yes
+ fi
+
+ echo "${has_space_characters}"
+}
+
+is_gzipped() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
+
+ local file_to_check=${1}
+
+ if [ ! -f "${file_to_check}" ]
+ then
+ gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): File '${file_to_check}' does not exist!"
+ fi
+
+ local file_is_gzipped=no
+ local file_mimetype=$(file --brief --mime-type "${file_to_check}" 2>/dev/null)
+
+ case "${file_mimetype}" in
+ application/x-gzip)
+ file_is_gzipped=yes
+ ;;
+ application/gzip)
+ file_is_gzipped=yes
+ ;;
+ esac
+
+ echo "${file_is_gzipped}"
+}
+
is_valid_ssh_host_keys_parameter_value() {
local parameter_value=${1}
@@ -221,7 +271,7 @@ is_valid_triplet() {
local triplet=${1}
local is_triplet=no
- if [[ "${triplet}" =~ ^[a-zA-Z0-9]{2,}-[a-zA-Z0-9]{2,}-[a-zA-Z0-9]{2,} ]]
+ if [[ "${triplet}" =~ ^[^-]{2,}-[^-]{2,}-.{2,} ]]
then
is_triplet=yes
fi
@@ -264,13 +314,46 @@ cache_replace() {
var_replace "CACHE" "${GK_V_CACHEDIR}" "${1}"
}
-start_log() {
- if [ -f "${LOGFILE}" ]
- then
- (echo > "${LOGFILE}") 2>/dev/null || small_die "Genkernel: Could not write to '${LOGFILE}'."
- fi
+kv_replace() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
- dump_debugcache
+ var_replace "KV" "${KV}" "${1}"
+}
+
+# Internal func. The first argument is the version info to expand.
+# Query the preprocessor to improve compatibility across different
+# compilers rather than maintaining a --version flag matrix. #335943
+_gcc_fullversion() {
+ local ver="$1"; shift
+ set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__")
+ eval echo "$ver"
+}
+
+# @FUNCTION: gcc-fullversion
+# @RETURN: compiler version (major.minor.micro: [3.4.6])
+gcc-fullversion() {
+ _gcc_fullversion '$1.$2.$3' "$@"
+}
+# @FUNCTION: gcc-version
+# @RETURN: compiler version (major.minor: [3.4].6)
+gcc-version() {
+ _gcc_fullversion '$1.$2' "$@"
+}
+# @FUNCTION: gcc-major-version
+# @RETURN: major compiler version (major: [3].4.6)
+gcc-major-version() {
+ _gcc_fullversion '$1' "$@"
+}
+# @FUNCTION: gcc-minor-version
+# @RETURN: minor compiler version (minor: 3.[4].6)
+gcc-minor-version() {
+ _gcc_fullversion '$2' "$@"
+}
+# @FUNCTION: gcc-micro-version
+# @RETURN: micro compiler version (micro: 3.4.[6])
+gcc-micro-version() {
+ _gcc_fullversion '$3' "$@"
}
gen_die() {
@@ -283,21 +366,33 @@ gen_die() {
print_error 1 "ERROR: ${1}"
fi
- print_error 1 "Please consult '${LOGFILE}' for more information and any"
- print_error 1 "errors that were reported above."
- print_error 1 ''
- print_error 1 "Report any genkernel bugs to bugs.gentoo.org and"
- print_error 1 "assign your bug to genkernel@gentoo.org. Please include"
- print_error 1 "as much information as you can in your bug report; attaching"
- print_error 1 "'${LOGFILE}' so that your issue can be dealt with effectively."
- print_error 1 ''
- print_error 1 "Please do ${BOLD}*not*${NORMAL} report ${BOLD}kernel${NORMAL} compilation failures as genkernel bugs!"
- print_error 1 ''
-
- # Cleanup temp dirs and caches if requested
- cleanup
+ if [[ -n "${GK_MASTER_PID}" && ${BASHPID} != ${GK_MASTER_PID} ]]
+ then
+ # We died in a subshell! Let's trigger trap function...
+ kill -s SIGTERM ${GK_MASTER_PID}
+ else
+ # Don't trust $LOGFILE before determine_real_args() was called
+ if [ -n "${CMD_LOGFILE}" -a -s "${LOGFILE}" ]
+ then
+ print_error 1 "Please consult '${LOGFILE}' for more information and any"
+ print_error 1 "errors that were reported above."
+ print_error 1 ''
+ fi
+
+ print_error 1 "Report any genkernel bugs to bugs.gentoo.org and"
+ print_error 1 "assign your bug to genkernel@gentoo.org. Please include"
+ print_error 1 "as much information as you can in your bug report; attaching"
+ print_error 1 "'${LOGFILE}' so that your issue can be dealt with effectively."
+ print_error 1 ''
+ print_error 1 "Please do ${BOLD}*not*${NORMAL} report ${BOLD}kernel${NORMAL} compilation failures as genkernel bugs!"
+ print_error 1 ''
+
+ restore_boot_mount_state
+
+ # Cleanup temp dirs and caches if requested
+ cleanup
+ fi
- [[ -n "${GK_MASTER_PID}" && ${BASHPID} != ${GK_MASTER_PID} ]] && kill -s SIGTERM ${GK_MASTER_PID}
exit 1
}
@@ -366,6 +461,11 @@ cleanup() {
print_info 3 "CACHE_DIR: ${CACHE_DIR}"
print_info 3 "TMPDIR: ${TMPDIR}"
fi
+
+ GK_TIME_END=$(date +%s)
+ let GK_TIME_RUNTIME_SECONDS=${GK_TIME_END}-${GK_TIME_START}
+ let GK_TIME_RUNTIME_DAYS=${GK_TIME_RUNTIME_SECONDS}/86400
+ TZ= printf ">>> Ended on: $(date +"%Y-%m-%d %H:%M:%S") (after %d days%(%k hours %M minutes %S seconds)T)\n" ${GK_TIME_RUNTIME_DAYS} ${GK_TIME_RUNTIME_SECONDS} >> "${LOGFILE}" 2>/dev/null
}
clear_tmpdir() {
@@ -539,38 +639,42 @@ dropbear_create_key() {
[[ ${#} -ne 2 ]] \
&& gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly two arguments (${#} given)!"
- if ! hash sandbox &>/dev/null
- then
- gen_die "Sandbox not found. Please install sys-apps/sandbox!"
- fi
-
local key_file=${1}
local command=${2}
local key_type=$(dropbear_get_key_type_from_filename "${key_file}")
local -a envvars=(
- GK_SHARE="${GK_SHARE}"
- LOGLEVEL="${LOGLEVEL}"
- LOGFILE="${LOGFILE}"
- NOCOLOR="${NOCOLOR}"
- TEMP="${TEMP}"
- SANDBOX_WRITE="${LOGFILE}:${TEMP}"
+ "GK_SHARE='${GK_SHARE}'"
+ "LOGLEVEL='${LOGLEVEL}'"
+ "LOGFILE='${LOGFILE}'"
+ "NOCOLOR='${NOCOLOR}'"
+ "PATH='${PATH}'"
+ "TEMP='${TEMP}'"
)
envvars+=(
- DROPBEAR_COMMAND="${command}"
- DROPBEAR_KEY_FILE="${key_file}"
- DROPBEAR_KEY_TYPE="${key_type}"
+ "DROPBEAR_COMMAND='${command}'"
+ "DROPBEAR_KEY_FILE='${key_file}'"
+ "DROPBEAR_KEY_TYPE='${key_type}'"
)
+ if isTrue "${SANDBOX}"
+ then
+ envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}'" )
+ fi
+
# set up worker signal handler
local error_msg_detail="Failed to create dropbear key '${key_file}'!"
local error_msg="gen_worker.sh aborted: ${error_msg_detail}"
trap "gen_die \"${error_msg}\"" SIGABRT SIGHUP SIGQUIT SIGINT SIGTERM
- env -i \
- "${envvars[@]}" \
- sandbox "${GK_SHARE}"/gen_worker.sh dropbear 2>&1
+ local dropbear_command=( "env -i" )
+ dropbear_command+=( "${envvars[*]}" )
+ dropbear_command+=( "${SANDBOX_COMMAND}" )
+ dropbear_command+=( "${GK_SHARE}/gen_worker.sh" )
+ dropbear_command+=( "dropbear" )
+ dropbear_command+=( "2>&1" )
+ eval "${dropbear_command[@]}"
local RET=$?
@@ -609,11 +713,6 @@ dropbear_generate_key_info_file() {
[[ ${#} -ne 3 ]] \
&& gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly three arguments (${#} given)!"
- if ! hash sandbox &>/dev/null
- then
- gen_die "Sandbox not found. Please install sys-apps/sandbox!"
- fi
-
local command=${1}
local key_info_file=${2}
local initramfs_dropbear_dir=${3}
@@ -621,29 +720,38 @@ dropbear_generate_key_info_file() {
local key_type=$(dropbear_get_key_type_from_filename "${key_file}")
local -a envvars=(
- GK_SHARE="${GK_SHARE}"
- LOGLEVEL="${LOGLEVEL}"
- LOGFILE="${LOGFILE}"
- NOCOLOR="${NOCOLOR}"
- TEMP="${TEMP}"
- SANDBOX_WRITE="${LOGFILE}:${TEMP}"
+ "GK_SHARE='${GK_SHARE}'"
+ "LOGLEVEL='${LOGLEVEL}'"
+ "LOGFILE='${LOGFILE}'"
+ "NOCOLOR='${NOCOLOR}'"
+ "PATH='${PATH}'"
+ "TEMP='${TEMP}'"
)
envvars+=(
- DROPBEAR_COMMAND="${command}"
- DROPBEAR_KEY_FILE="${key_file}"
- DROPBEAR_KEY_TYPE="${key_type}"
- DROPBEAR_KEY_INFO_FILE="${key_info_file}"
+ "DROPBEAR_COMMAND='${command}'"
+ "DROPBEAR_KEY_FILE='${key_file}'"
+ "DROPBEAR_KEY_TYPE='${key_type}'"
+ "DROPBEAR_KEY_INFO_FILE='${key_info_file}'"
)
+ if isTrue "${SANDBOX}"
+ then
+ envvars+=( SANDBOX_WRITE="${LOGFILE}:${TEMP}" )
+ fi
+
# set up worker signal handler
local error_msg_detail="Failed to extract dropbear key information from '${key_file}'!"
local error_msg="gen_worker.sh aborted: ${error_msg_detail}"
trap "gen_die \"${error_msg}\"" SIGABRT SIGHUP SIGQUIT SIGINT SIGTERM
- env -i \
- "${envvars[@]}" \
- sandbox "${GK_SHARE}"/gen_worker.sh dropbear 2>&1
+ local dropbear_command=( "env -i" )
+ dropbear_command+=( "${envvars[*]}" )
+ dropbear_command+=( "${SANDBOX_COMMAND}" )
+ dropbear_command+=( "${GK_SHARE}/gen_worker.sh" )
+ dropbear_command+=( "dropbear" )
+ dropbear_command+=( "2>&1" )
+ eval "${dropbear_command[@]}"
local RET=$?
@@ -683,9 +791,21 @@ debug_breakpoint() {
get_chost_libdir() {
local cc=$(tc-getCC)
- local libdir=$(dirname "$(realpath "$(${cc} -print-file-name=libnss_files.so)")")
- if [[ -z "${libdir}" ]]
+ local test_file=$("${cc}" -print-file-name=libnss_files.so 2>/dev/null)
+ if [ -z "${test_file}" ]
+ then
+ gen_die "$(get_useful_function_stack "${FUNCNAME}")Unable to determine CHOST's libdir: '${cc} -print-file-name=libnss_files.so' returned nothing!"
+ fi
+
+ local test_file_realpath=$(realpath "${test_file}" 2>/dev/null)
+ if [ -z "${test_file_realpath}" ]
+ then
+ gen_die "$(get_useful_function_stack "${FUNCNAME}")Unable to determine CHOST's libdir: 'realpath \"${test_file}\"' returned nothing!"
+ fi
+
+ local libdir=$(dirname "${test_file_realpath}" 2>/dev/null)
+ if [ -z "${libdir}" ]
then
gen_die "$(get_useful_function_stack "${FUNCNAME}")Unable to determine CHOST's libdir!"
fi
@@ -693,6 +813,16 @@ get_chost_libdir() {
echo "${libdir}"
}
+get_du() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one argument (${#} given)!"
+
+ [ -z "${DU_COMMAND}" ] && return
+
+ local sz=( $("${DU_COMMAND}" -hs "${1}" 2>/dev/null) )
+ echo "${sz[0]}"
+}
+
_get_gkpkg_var_value() {
[[ ${#} -ne 2 ]] \
&& gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly two arguments (${#} given)!"
@@ -789,7 +919,8 @@ get_tar_cmd() {
local archive_file=${1}
local -a tar_cmd
- tar_cmd+=( 'tar -c' )
+ tar_cmd+=( "${TAR_COMMAND}" )
+ tar_cmd+=( '-c' )
local pcmd
if [[ "${archive_file}" == *.tar.bz2 ]]
@@ -965,6 +1096,10 @@ tc-getBUILD_CC() {
tc-getBUILD_PROG CC gcc "$@"
}
+tc-getBUILD_CXX() {
+ tc-getBUILD_PROG CXX g++ "$@"
+}
+
tc-getCC() {
tc-getPROG CC gcc "$@"
}
@@ -1096,11 +1231,6 @@ gkbuild() {
[[ ${#} -gt 7 ]] \
&& gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes at most six arguments (${#} given)!"
- if ! hash sandbox &>/dev/null
- then
- gen_die "Sandbox not found. Please install sys-apps/sandbox!"
- fi
-
local PKG=${1}
local VERSION=${2}
local SRCDIR=${3}
@@ -1132,59 +1262,84 @@ gkbuild() {
fi
local -a envvars=(
- GK_SHARE="${GK_SHARE}"
- LOGLEVEL="${LOGLEVEL}"
- LOGFILE="${LOGFILE}"
- NOCOLOR="${NOCOLOR}"
- TEMP="${TEMP}"
- SANDBOX_WRITE="${LOGFILE}:${TEMP}"
+ "GK_SHARE='${GK_SHARE}'"
+ "LOGLEVEL='${LOGLEVEL}'"
+ "LOGFILE='${LOGFILE}'"
+ "NOCOLOR='${NOCOLOR}'"
+ "PATH='${PATH}'"
+ "TEMP='${TEMP}'"
+ "TMPDIR='${TEMP}'"
)
envvars+=(
- GKPKG_PN="${PKG}"
- GKPKG_PV="${VERSION}"
- GKPKG_SRCDIR="${SRCDIR}"
- GKPKG_SRCTAR="${SRCTAR}"
- GKPKG_BINPKG="${BINPKG}"
- GKPKG_DEPS="${DEPS}"
+ "GKPKG_PN='${PKG}'"
+ "GKPKG_PV='${VERSION}'"
+ "GKPKG_SRCDIR='${SRCDIR}'"
+ "GKPKG_SRCTAR='${SRCTAR}'"
+ "GKPKG_BINPKG='${BINPKG}'"
+ "GKPKG_DEPS='${DEPS}'"
+ "DU_COMMAND='${DU_COMMAND}'"
+ "TAR_COMMAND='${TAR_COMMAND}'"
)
envvars+=(
- CFLAGS="${CMD_UTILS_CFLAGS}"
- CXXFLAGS="${CMD_UTILS_CFLAGS}"
- CBUILD="${CBUILD}"
- CHOST="${CHOST}"
- AR="$(tc-getAR)"
- AS="$(tc-getAS)"
- CC="$(tc-getCC)"
- CPP="$(tc-getCPP)"
- CXX="$(tc-getCXX)"
- LD="$(tc-getLD)"
- NM="$(tc-getNM)"
- MAKE="${CMD_UTILS_MAKE}"
- OBJCOPY="$(tc-getOBJCOPY)"
- OBJDUMP="$(tc-getOBJDUMP)"
- RANLIB="$(tc-getRANLIB)"
- STRIP="$(tc-getSTRIP)"
+ "CFLAGS='${CMD_UTILS_CFLAGS}'"
+ "CXXFLAGS='${CMD_UTILS_CFLAGS}'"
+ "CBUILD='${CBUILD}'"
+ "CHOST='${CHOST}'"
+ "AR='$(tc-getAR)'"
+ "AS='$(tc-getAS)'"
+ "CC='$(tc-getCC)'"
+ "CPP='$(tc-getCPP)'"
+ "CXX='$(tc-getCXX)'"
+ "LD='$(tc-getLD)'"
+ "NM='$(tc-getNM)'"
+ "MAKE='${CMD_UTILS_MAKE}'"
+ "OBJCOPY='$(tc-getOBJCOPY)'"
+ "OBJDUMP='$(tc-getOBJDUMP)'"
+ "RANLIB='$(tc-getRANLIB)'"
+ "STRIP='$(tc-getSTRIP)'"
)
+ local envvar_prefix envvars_to_export envvar_to_export
+ for envvar_prefix in CCACHE_ DISTCC_
+ do
+ envvars_to_export=$(compgen -A variable | grep "^${envvar_prefix}")
+ for envvar_to_export in ${envvars_to_export}
+ do
+ [ -z "${envvar_to_export}" ] && break
+
+ envvars+=( "${envvar_to_export}='${!envvar_to_export}'" )
+ done
+ done
+ unset envvar_prefix envvars_to_export envvar_to_export
+
if [ ${NICE} -ne 0 ]
then
NICEOPTS="nice -n${NICE} "
else
NICEOPTS=""
fi
- envvars+=( NICEOPTS="${NICEOPTS}" )
+ envvars+=( "NICEOPTS='${NICEOPTS}'" )
- envvars+=( MAKEOPTS="${MAKEOPTS}" )
+ envvars+=( "MAKEOPTS='${MAKEOPTS}'" )
+
+ if isTrue "${SANDBOX}"
+ then
+ envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}'" )
+ fi
# set up gkbuild signal handler
local error_msg="gen_worker.sh aborted: Failed to compile ${PKG}-${VERSION}!"
trap "gen_die \"${error_msg}\"" SIGABRT SIGHUP SIGQUIT SIGINT SIGTERM
- env -i \
- "${envvars[@]}" \
- sandbox "${GK_SHARE}"/gen_worker.sh build 2>&1
+ local build_command=( "env -i" )
+ build_command+=( "${envvars[*]}" )
+ build_command+=( "${SANDBOX_COMMAND}" )
+ build_command+=( "${GK_SHARE}/gen_worker.sh" )
+ build_command+=( "build" )
+ build_command+=( "2>&1" )
+ eval "${build_command[@]}"
local RET=$?
@@ -1206,36 +1361,41 @@ unpack() {
[[ ${#} -ne 2 ]] \
&& gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly two arguments (${#} given)!"
- if ! hash sandbox &>/dev/null
- then
- gen_die "Sandbox not found. Please install sys-apps/sandbox!"
- fi
-
local unpack_file=${1}
local unpack_dir=${2}
local -a envvars=(
- GK_SHARE="${GK_SHARE}"
- LOGLEVEL="${LOGLEVEL}"
- LOGFILE="${LOGFILE}"
- NOCOLOR="${NOCOLOR}"
- TEMP="${TEMP}"
- SANDBOX_WRITE="${LOGFILE}:${TEMP}"
+ "GK_SHARE='${GK_SHARE}'"
+ "LOGLEVEL='${LOGLEVEL}'"
+ "LOGFILE='${LOGFILE}'"
+ "NOCOLOR='${NOCOLOR}'"
+ "PATH='${PATH}'"
+ "TEMP='${TEMP}'"
)
envvars+=(
- UNPACK_FILE="${unpack_file}"
- UNPACK_DIR="${unpack_dir}"
+ "TAR_COMMAND='${TAR_COMMAND}'"
+ "UNPACK_FILE='${unpack_file}'"
+ "UNPACK_DIR='${unpack_dir}'"
)
+ if isTrue "${SANDBOX}"
+ then
+ envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}'" )
+ fi
+
# set up unpack signal handler
local error_msg_detail="Failed to unpack '${unpack_file}' to '${unpack_dir}'!"
local error_msg="gen_worker.sh aborted: ${error_msg_detail}"
trap "gen_die \"${error_msg}\"" SIGABRT SIGHUP SIGQUIT SIGINT SIGTERM
- env -i \
- "${envvars[@]}" \
- sandbox "${GK_SHARE}"/gen_worker.sh unpack 2>&1
+ local unpack_command=( "env -i" )
+ unpack_command+=( "${envvars[*]}" )
+ unpack_command+=( "${SANDBOX_COMMAND}" )
+ unpack_command+=( "${GK_SHARE}/gen_worker.sh" )
+ unpack_command+=( "unpack" )
+ unpack_command+=( "2>&1" )
+ eval "${unpack_command[@]}"
local RET=$?
@@ -1312,14 +1472,18 @@ set_config_with_override() {
then
Result=${!CfgVar}
# we need to set the CMD_* according to configfile...
- eval ${OverrideVar}=\"${Result}\"
+ eval ${OverrideVar}=\"${Result}\" \
+ || small_die "Failed to set variable '${OverrideVar}=${Result}' !"
+
print_info 5 " $CfgVar set in config file to \"${Result}\"."
else
if [ -n "$Default" ]
then
Result=${Default}
# set OverrideVar to Result, otherwise CMD_* may not be initialized...
- eval ${OverrideVar}=\"${Result}\"
+ eval ${OverrideVar}=\"${Result}\" \
+ || small_die "Failed to set variable '${OverrideVar}=${Result}' !"
+
print_info 5 " $CfgVar defaulted to \"${Result}\"."
else
print_info 5 " $CfgVar not set."
@@ -1337,7 +1501,8 @@ set_config_with_override() {
fi
fi
- eval ${CfgVar}=\"${Result}\"
+ eval ${CfgVar}=\"${Result}\" \
+ || small_die "Failed to set variable '${CfgVar}=${Result}' !"
}
# @FUNCTION: restore_boot_mount_state
@@ -1435,6 +1600,85 @@ rootfs_type_is() {
fi
}
+check_disk_space_requirements() {
+ local number_pattern='^[1-9]{1}[0-9]+$'
+ local available_free_disk_space=
+
+ # Start check for BOOTDIR
+ local need_to_check=yes
+
+ if [ -z "${CHECK_FREE_DISK_SPACE_BOOTDIR}" -o "${CHECK_FREE_DISK_SPACE_BOOTDIR}" = '0' ]
+ then
+ need_to_check=no
+ fi
+
+ if isTrue "${need_to_check}" && ! isTrue "${CMD_INSTALL}"
+ then
+ need_to_check=no
+ fi
+
+ if isTrue "${need_to_check}"
+ then
+ if [[ ! "${CHECK_FREE_DISK_SPACE_BOOTDIR}" =~ ${number_pattern} ]]
+ then
+ gen_die "--check-free-disk-space-bootdir value '${CHECK_FREE_DISK_SPACE_BOOTDIR}' is not a valid number!"
+ fi
+
+ available_free_disk_space=$(unset POSIXLY_CORRECT && df -BM "${BOOTDIR}" | awk '$3 ~ /[0-9]+/ { print $4 }')
+ if [ -n "${available_free_disk_space}" ]
+ then
+ print_info 2 '' 1 0
+ print_info 2 "Checking for at least ${CHECK_FREE_DISK_SPACE_BOOTDIR} MB free disk space in '${BOOTDIR}' ..."
+ print_info 5 "df reading: ${available_free_disk_space}"
+
+ available_free_disk_space=${available_free_disk_space%M}
+ if [ ${available_free_disk_space} -lt ${CHECK_FREE_DISK_SPACE_BOOTDIR} ]
+ then
+ gen_die "${CHECK_FREE_DISK_SPACE_BOOTDIR} MB free disk space is required in '${BOOTDIR}' but only ${available_free_disk_space} MB is available!"
+ fi
+ else
+ print_warning 1 "Invalid df value; Skipping free disk space check for '${BOOTDIR}' ..."
+ fi
+ fi
+
+ # Start check for kernel outputdir
+ need_to_check=yes
+
+ if [ -z "${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR}" -o "${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR}" = '0' ]
+ then
+ need_to_check=no
+ fi
+
+ if isTrue "${need_to_check}" && ! isTrue "${BUILD_KERNEL}"
+ then
+ need_to_check=no
+ fi
+
+ if isTrue "${need_to_check}"
+ then
+ if [[ ! "${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR}" =~ ${number_pattern} ]]
+ then
+ gen_die "--check-free-disk-space-kerneloutputdir value '${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR}' is not a valid number!"
+ fi
+
+ available_free_disk_space=$(unset POSIXLY_CORRECT && df -BM "${KERNEL_OUTPUTDIR}" | awk '$3 ~ /[0-9]+/ { print $4 }')
+ if [ -n "${available_free_disk_space}" ]
+ then
+ print_info 2 '' 1 0
+ print_info 2 "Checking for at least ${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR} MB free disk space in '${KERNEL_OUTPUTDIR}' ..."
+ print_info 5 "df reading: ${available_free_disk_space}"
+
+ available_free_disk_space=${available_free_disk_space%M}
+ if [ ${available_free_disk_space} -lt ${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR} ]
+ then
+ gen_die "${CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR} MB free disk space is required in '${BOOTDIR}' but only ${available_free_disk_space} MB is available!"
+ fi
+ else
+ print_warning 1 "Invalid df value; Skipping free disk space check for '${KERNEL_OUTPUTDIR}' ..."
+ fi
+ fi
+}
+
check_distfiles() {
local source_files=( $(compgen -A variable |grep '^GKPKG_.*SRCTAR$') )
@@ -1510,8 +1754,6 @@ kconfig_get_opt() {
-e "/^#\? \?${optname}[ =].*/{ s/.*${optname}[ =]//g; s/is not set\| +//g; p; q }"
}
-KCONFIG_MODIFIED_MARKER="${TEMP}/.kconfig_modified"
-
kconfig_set_opt() {
[[ ${#} -lt 3 ]] \
&& gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes at least three arguments (${#} given)!"
@@ -1552,7 +1794,7 @@ make_bootdir_writable() {
# Based on mount-boot.eclass code
local fstabstate=$(awk "!/^#|^[[:blank:]]+#|^${BOOTDIR//\//\\/}/ {print \$2}" /etc/fstab 2>/dev/null | egrep "^${BOOTDIR}$" )
local procstate=$(awk "\$2 ~ /^${BOOTDIR//\//\\/}\$/ {print \$2}" /proc/mounts 2>/dev/null)
- local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts 2>/dev/null | sed -n "/${BOOTDIR//\//\\/} .*,ro,/p")
+ local proc_ro=$(awk '{ print $2 " ," $4 "," }' /proc/mounts 2>/dev/null | sed -n "/^${BOOTDIR//\//\\/} .*,ro,/p")
if [ -n "${fstabstate}" ] && [ -n "${procstate}" ]
then
@@ -1626,5 +1868,25 @@ make_bootdir_writable() {
fi
}
+# @FUNCTION: makeopts_jobs
+# @USAGE: [${MAKEOPTS}] [${inf:-999}]
+# @DESCRIPTION:
+# Searches the arguments (defaults to ${MAKEOPTS}) and extracts the jobs number
+# specified therein. Useful for running non-make tools in parallel too.
+# i.e. if the user has MAKEOPTS=-j9, this will echo "9" -- we can't return the
+# number as bash normalizes it to [0, 255]. If the flags haven't specified a
+# -j flag, then "1" is shown as that is the default `make` uses. Since there's
+# no way to represent infinity, we return ${inf} (defaults to 999) if the user
+# has -j without a number.
+makeopts_jobs() {
+ [[ $# -eq 0 ]] && set -- "${MAKEOPTS}"
+ # This assumes the first .* will be more greedy than the second .*
+ # since POSIX doesn't specify a non-greedy match (i.e. ".*?").
+ local jobs=$(echo " $* " | sed -r -n \
+ -e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
+ -e "s:.*[[:space:]](-[a-z]*j|--jobs)[[:space:]].*:${2:-999}:p")
+ echo ${jobs:-1}
+}
+
unset GK_DEFAULT_IFS
declare -r GK_DEFAULT_IFS="${IFS}"
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index 8419a20..a27e2ca 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -37,7 +37,7 @@ copy_binaries() {
[[ -e "${binary}" ]] \
|| gen_die "Binary ${binary} could not be found"
- if LC_ALL=C lddtree "${binary}" 2>&1 | fgrep -q 'not found'
+ if LC_ALL=C "${LDDTREE_COMMAND}" "${binary}" 2>&1 | fgrep -q 'not found'
then
gen_die "Binary ${binary} is linked to missing libraries and may need to be re-built"
fi
@@ -45,12 +45,12 @@ copy_binaries() {
# This must be OUTSIDE the for loop, we only want to run lddtree etc ONCE.
# lddtree does not have the -V (version) nor the -l (list) options prior to version 1.18
(
- if lddtree -V > /dev/null 2>&1
+ if "${LDDTREE_COMMAND}" -V > /dev/null 2>&1
then
- lddtree -l "$@" \
+ "${LDDTREE_COMMAND}" -l "$@" \
|| gen_die "Binary '${binary}' or some of its library dependencies could not be copied!"
else
- lddtree "$@" \
+ "${LDDTREE_COMMAND}" "$@" \
| tr ')(' '\n' \
| awk '/=>/{ if($3 ~ /^\//){print $3}}' \
|| gen_die "Binary '${binary}' or some of its library dependencies could not be copied!"
@@ -58,7 +58,7 @@ copy_binaries() {
) \
| sort \
| uniq \
- | cpio -p --make-directories --dereference --quiet "${destdir}" \
+ | "${CPIO_COMMAND}" -p --make-directories --dereference --quiet "${destdir}" \
|| gen_die "Binary '${binary}' or some of its library dependencies could not be copied!"
}
@@ -135,7 +135,7 @@ copy_system_binaries() {
print_info 5 "System binary dirname set to '${base_dir}'."
fi
- if LC_ALL=C lddtree "${binary}" 2>&1 | fgrep -q 'not found'
+ if LC_ALL=C "${LDDTREE_COMMAND}" "${binary}" 2>&1 | fgrep -q 'not found'
then
gen_die "$(get_useful_function_stack)System binary '${binary}' is linked to missing libraries and may need to be re-built!"
fi
@@ -165,47 +165,77 @@ copy_system_binaries() {
print_info 5 "Need to copy dependency '${base_dir}/${binary_dependency_basename}' ..."
"${FUNCNAME}" "${destdir}" "${base_dir}/${binary_dependency_basename}"
fi
- done 3< <(lddtree -l "${binary}" 2>/dev/null)
+ done 3< <("${LDDTREE_COMMAND}" -l "${binary}" 2>/dev/null)
IFS="${GK_DEFAULT_IFS}"
done
}
log_future_cpio_content() {
+ local dir_size=$(get_du "${PWD}")
+ if [ -n "${dir_size}" ]
+ then
+ dir_size=" (${dir_size})"
+ fi
+
print_info 3 "=================================================================" 1 0 1
- print_info 3 "About to add these files from '${PWD}' to cpio archive:" 1 0 1
+ print_info 3 "About to add these files${dir_size} from '${PWD}' to cpio archive:" 1 0 1
print_info 3 "$(find . -print0 | xargs --null ls -ald)" 1 0 1
print_info 3 "=================================================================" 1 0 1
}
append_devices() {
- local TFILE="${TEMP}/initramfs-base-temp.devices"
- if [ -f "${TFILE}" ]
+ if isTrue "${BUSYBOX}"
then
- rm "${TFILE}" || gen_die "Failed to clean out existing '${TFILE}'!"
- fi
+ local TDIR="${TEMP}/initramfs-devices-temp"
+ if [ -d "${TDIR}" ]
+ then
+ rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!"
+ fi
- if [[ ! -x "${KERNEL_OUTPUTDIR}/usr/gen_init_cpio" ]]; then
- compile_gen_init_cpio
- fi
+ mkdir -p "${TDIR}/dev" || gen_die "Failed to create '${TDIR}/dev'!"
+ cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
- # WARNING, does NOT support appending to cpio!
- cat >"${TFILE}" <<-EOF
- dir /dev 0755 0 0
- nod /dev/console 660 0 0 c 5 1
- nod /dev/null 666 0 0 c 1 3
- nod /dev/zero 666 0 0 c 1 5
- nod /dev/tty0 600 0 0 c 4 0
- nod /dev/tty1 600 0 0 c 4 1
- nod /dev/ttyS0 600 0 0 c 4 64
- EOF
+ chmod 0755 dev || gen_die "Failed to chmod of '${TDIR}/dev' to 0755!"
- print_info 3 "=================================================================" 1 0 1
- print_info 3 "Adding the following devices to cpio:" 1 0 1
- print_info 3 "$(cat "${TFILE}")" 1 0 1
- print_info 3 "=================================================================" 1 0 1
+ log_future_cpio_content
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} -F "${CPIO_ARCHIVE}" \
+ || gen_die "Failed to append devices to cpio!"
- "${KERNEL_OUTPUTDIR}"/usr/gen_init_cpio "${TFILE}" >"${CPIO}" \
- || gen_die "Failed to append devices to cpio!"
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
+ else
+ local TFILE="${TEMP}/initramfs-base-temp.devices"
+ if [ -f "${TFILE}" ]
+ then
+ rm "${TFILE}" || gen_die "Failed to clean out existing '${TFILE}'!"
+ fi
+
+ if [[ ! -x "${KERNEL_OUTPUTDIR}/usr/gen_init_cpio" ]]; then
+ compile_gen_init_cpio
+ fi
+
+ # WARNING, does NOT support appending to cpio!
+ cat >"${TFILE}" <<-EOF
+ dir /dev 0755 0 0
+ nod /dev/console 660 0 0 c 5 1
+ nod /dev/null 666 0 0 c 1 3
+ nod /dev/zero 666 0 0 c 1 5
+ nod /dev/tty0 600 0 0 c 4 0
+ nod /dev/tty1 600 0 0 c 4 1
+ nod /dev/ttyS0 600 0 0 c 4 64
+ EOF
+
+ print_info 3 "=================================================================" 1 0 1
+ print_info 3 "Adding the following devices to cpio:" 1 0 1
+ print_info 3 "$(cat "${TFILE}")" 1 0 1
+ print_info 3 "=================================================================" 1 0 1
+
+ "${KERNEL_OUTPUTDIR}"/usr/gen_init_cpio "${TFILE}" >"${CPIO_ARCHIVE}" \
+ || gen_die "Failed to append devices to cpio!"
+ fi
}
append_base_layout() {
@@ -346,8 +376,14 @@ append_base_layout() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append baselayout to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_busybox() {
@@ -383,7 +419,7 @@ append_busybox() {
done
# Set up a few default symlinks
- local required_applets='[ ash sh mount uname echo cut cat'
+ local required_applets='[ ash sh mknod mount uname echo cut cat'
local required_applet=
for required_applet in ${required_applets}
do
@@ -397,8 +433,14 @@ append_busybox() {
copy_system_binaries "${TDIR}"/lib "${libdir}"/libnss_dns.so.2
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_e2fsprogs() {
@@ -418,8 +460,14 @@ append_e2fsprogs() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_blkid() {
@@ -442,8 +490,14 @@ append_blkid() {
rm -rf usr/
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append blkid to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_unionfs_fuse() {
@@ -462,8 +516,14 @@ append_unionfs_fuse() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_multipath() {
@@ -498,8 +558,14 @@ append_multipath() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_dmraid() {
@@ -527,8 +593,14 @@ append_dmraid() {
mkdir -p "${TDIR}"/var/lock/dmraid || gen_die "Failed to create '${TDIR}/var/lock/dmraid'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append dmraid to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_iscsi() {
@@ -547,8 +619,14 @@ append_iscsi() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append iscsi to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_lvm() {
@@ -560,10 +638,12 @@ append_lvm() {
fi
populate_binpkg ${PN}
+ populate_binpkg thin-provisioning-tools
mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}"
+ unpack "$(get_gkpkg_binpkg "thin-provisioning-tools")" "${TDIR}"
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
@@ -612,13 +692,22 @@ append_lvm() {
-e '/^[[:space:]]*monitoring/s,=.*,= 0,g' \
-e '/^[[:space:]]*external_device_info_source/s,=.*,= "none",g' \
-e '/^[[:space:]]*units/s,=.*"r",= "h",g' \
+ -e '/^[[:space:]]*thin_repair_executable/s,=.*,= /usr/sbin/thin_repair,g' \
+ -e '/^[[:space:]]*thin_dump_executable/s,=.*,= /usr/sbin/thin_dump,g' \
+ -e '/^[[:space:]]*thin_check_executable/s,=.*,= /usr/sbin/thin_check,g' \
"${TDIR}"/etc/lvm/lvm.conf \
|| gen_die 'Could not sed lvm.conf!'
fi
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append lvm to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_mdadm() {
@@ -646,6 +735,8 @@ append_mdadm() {
if [ -n "${MDADM_CONFIG}" ]
then
+ print_info 2 "$(get_indent 2)${PN}: >> Adding '${MDADM_CONFIG}' ..."
+
if [ -f "${MDADM_CONFIG}" ]
then
cp -aL "${MDADM_CONFIG}" "${TDIR}"/etc/mdadm.conf 2>/dev/null \
@@ -659,8 +750,14 @@ append_mdadm() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_xfsprogs() {
@@ -680,8 +777,14 @@ append_xfsprogs() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_zfs() {
@@ -725,8 +828,14 @@ append_zfs() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_btrfs() {
@@ -746,8 +855,14 @@ append_btrfs() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_libgcc_s() {
@@ -775,8 +890,14 @@ append_libgcc_s() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append libgcc_s to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_linker() {
@@ -821,8 +942,14 @@ append_linker() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append linker to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_splash() {
@@ -866,8 +993,14 @@ append_splash() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append splash to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_strace() {
@@ -886,15 +1019,21 @@ append_strace() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_overlay() {
cd "${INITRAMFS_OVERLAY}" || gen_die "Failed to chdir to '${INITRAMFS_OVERLAY}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append overlay to cpio!"
}
@@ -918,8 +1057,14 @@ append_luks() {
rm -rf usr/
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append luks to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_dropbear() {
@@ -1196,8 +1341,14 @@ append_dropbear() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_firmware() {
@@ -1230,8 +1381,14 @@ append_firmware() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append firmware to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_gpg() {
@@ -1250,8 +1407,14 @@ append_gpg() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append ${PN} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
print_list()
@@ -1281,29 +1444,32 @@ append_modules() {
mkdir -p "${TDIR}"/${mydir} || gen_die "Failed to create '${TDIR}/${mydir}'!"
done
+ local modules_dstdir="${TDIR}/lib/modules/${KV}"
+ local modules_srcdir="/lib/modules/${KV}"
+
print_info 2 "$(get_indent 2)modules: >> Copying modules to initramfs ..."
- if [ "${INSTALL_MOD_PATH}" != '' ]
+
+ if [ -n "${INSTALL_MOD_PATH}" ]
then
- cd "${INSTALL_MOD_PATH}" || gen_die "Failed to chdir to '${INSTALL_MOD_PATH}'!"
- else
- cd / || gen_die "Failed to chdir to '/'!"
+ modules_srcdir="${INSTALL_MOD_PATH%/}${modules_srcdir}"
fi
- local _MODULES_DIR="${PWD%/}/lib/modules/${KV}"
- if [ ! -d "${_MODULES_DIR}" ]
+ if [ ! -d "${modules_srcdir}" ]
then
- error_message="'${_MODULES_DIR}' does not exist! Did you forget"
+ error_message="'${modules_srcdir}' does not exist! Did you forget"
error_message+=" to compile kernel before building initramfs?"
error_message+=" If you know what you are doing please set '--no-ramdisk-modules'."
gen_die "${error_message}"
fi
+ cd "${modules_srcdir}" || gen_die "Failed to chdir to '${modules_srcdir}'!"
+
local i= mymod=
local MOD_EXT="$(modules_kext)"
local n_copied_modules=0
for i in $(gen_dep_list)
do
- mymod=$(find "${_MODULES_DIR}" -name "${i}${MOD_EXT}" 2>/dev/null | head -n 1)
+ mymod=$(find . -name "${i}${MOD_EXT}" 2>/dev/null | head -n 1)
if [ -z "${mymod}" ]
then
print_warning 3 "$(get_indent 3) - ${i}${MOD_EXT} not found; Skipping ..."
@@ -1311,8 +1477,8 @@ append_modules() {
fi
print_info 3 "$(get_indent 3) - Copying ${i}${MOD_EXT} ..."
- cp -ax --parents "${mymod}" "${TDIR}"/ 2>/dev/null \
- || gen_die "Failed to copy '${mymod}' to '${TDIR}/'!"
+ cp -ax --parents --target-directory "${modules_dstdir}" "${mymod}" 2>/dev/null \
+ || gen_die "Failed to copy '${modules_srcdir}/${mymod}' to '${modules_dstdir}'!"
n_copied_modules=$[$n_copied_modules+1]
done
@@ -1323,11 +1489,12 @@ append_modules() {
print_info 2 "$(get_indent 2)modules: ${n_copied_modules} modules copied!"
fi
- cp -ax --parents "${_MODULES_DIR}"/modules* "${TDIR}"/ 2>/dev/null \
- || gen_die "Failed to copy '${_MODULES_DIR}/modules*' to '${TDIR}/'!"
+ cp -ax --parents --target-directory "${modules_dstdir}" modules* 2>/dev/null \
+ || gen_die "Failed to copy '${modules_srcdir}/modules*' to '${modules_dstdir}'!"
local group_modules= group=
- for group_modules in ${!MODULES_*}; do
+ for group_modules in ${!MODULES_*}
+ do
group="$(echo ${group_modules} | cut -d_ -f2- | tr "[:upper:]" "[:lower:]")"
print_list ${!group_modules} > "${TDIR}"/etc/modules/${group} \
|| gen_die "Failed to create '${TDIR}/etc/modules/${group}'!"
@@ -1335,8 +1502,14 @@ append_modules() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append modules-${KV} to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_modprobed() {
@@ -1356,8 +1529,14 @@ append_modprobed() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append modprobe.d to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
# check for static linked file with objdump
@@ -1491,8 +1670,14 @@ append_auxilary() {
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
log_future_cpio_content
- find . -print0 | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
+ find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \
|| gen_die "Failed to append auxilary to cpio!"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
}
append_data() {
@@ -1508,18 +1693,11 @@ append_data() {
}
create_initramfs() {
- local lddtree_testfile=$(which cpio 2>/dev/null)
- if [[ -z "${lddtree_testfile}" || ! -e "${lddtree_testfile}" ]]; then
- print_warning 1 "cpio binary not found -- cannot check if lddtree is working!"
- elif ! lddtree "${lddtree_testfile}" 1>/dev/null 2>&1; then
- gen_die "'lddtree ${lddtree_testfile}' failed -- cannot generate initramfs without working lddtree!"
- fi
-
local compress_ext=""
print_info 1 "initramfs: >> Initializing ..."
# Create empty cpio
- CPIO="${TMPDIR}/initramfs-${KV}"
+ CPIO_ARCHIVE="${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}"
append_data 'devices' # WARNING, must be first!
append_data 'base_layout'
append_data 'auxilary' "${BUSYBOX}"
@@ -1576,27 +1754,34 @@ create_initramfs() {
# TODO: maybe replace this with:
# http://search.cpan.org/~pixel/Archive-Cpio-0.07/lib/Archive/Cpio.pm
# as then we can dedupe ourselves...
- if [[ $UID -eq 0 ]]
+ if isTrue "${BUSYBOX}" || [[ ${UID} -eq 0 ]]
then
print_info 1 "$(get_indent 1)>> Deduping cpio ..."
local TDIR="${TEMP}/initramfs-final"
mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!"
cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!"
- cpio --quiet -i -F "${CPIO}" 2>/dev/null \
- || gen_die "Failed to extract cpio '${CPIO}' for dedupe"
+ "${CPIO_COMMAND}" --quiet -i -F "${CPIO_ARCHIVE}" 2>/dev/null \
+ || gen_die "Failed to extract cpio '${CPIO_ARCHIVE}' for dedupe"
- if [ -e etc/ld.so.cache ] && ! isTrue "$(tc-is-cross-compiler)"
+ if ! isTrue "$(tc-is-cross-compiler)"
then
- # We can update /etc/ld.so.cache which was copied from host
+ # We can generate or update /etc/ld.so.cache which was copied from host
# to actually match initramfs' content.
print_info 1 "$(get_indent 1)>> Pre-generating initramfs' /etc/ld.so.cache ..."
- ldconfig -r . 2>/dev/null \
+ # Need to disable sandbox which doesn't understand chroot(), bug #431038
+ SANDBOX_ON=0 ldconfig -f /etc/ld.so.conf -r "${TDIR}" 2>/dev/null \
|| gen_die "Failed to pre-generate '${TDIR}/etc/ld.so.cache'!"
fi
- find . -print0 | sort -z | cpio ${CPIO_ARGS} --reproducible -F "${CPIO}" 2>/dev/null \
+ find . -print0 | sort -z | "${CPIO_COMMAND}" ${CPIO_ARGS} --reproducible -F "${CPIO_ARCHIVE}" 2>/dev/null \
|| gen_die "rebuilding cpio for dedupe"
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if isTrue "${CLEANUP}"
+ then
+ rm -rf "${TDIR}"
+ fi
else
print_info 1 "$(get_indent 1)>> Cannot deduping cpio contents without root; Skipping ..."
fi
@@ -1612,7 +1797,7 @@ create_initramfs() {
local ACTUAL_KERNEL_CONFIG="${KERNEL_CONFIG}"
fi
- if [[ "$(file --brief --mime-type "${ACTUAL_KERNEL_CONFIG}")" == application/x-gzip ]]
+ if isTrue "$(is_gzipped "${ACTUAL_KERNEL_CONFIG}")"
then
# Support --kernel-config=/proc/config.gz, mainly
local CONFGREP=zgrep
@@ -1624,7 +1809,7 @@ create_initramfs() {
then
# Explicitly do not compress if we are integrating into the kernel.
# The kernel will do a better job of it than us.
- mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio
+ mv "${CPIO_ARCHIVE}" "${CPIO_ARCHIVE}.cpio"
sed -i '/^.*CONFIG_INITRAMFS_SOURCE=.*$/d' "${KERNEL_OUTPUTDIR}/.config" \
|| gen_die "failed to delete CONFIG_INITRAMFS_SOURCE from '${KERNEL_OUTPUTDIR}/.config'"
@@ -1642,7 +1827,7 @@ create_initramfs() {
# All N default except XZ, so there it gets used if the kernel does
# compression on it's own.
cat >>${KERNEL_OUTPUTDIR}/.config <<-EOF
- CONFIG_INITRAMFS_SOURCE="${TMPDIR}/initramfs-${KV}.cpio${compress_ext}"
+ CONFIG_INITRAMFS_SOURCE="${CPIO_ARCHIVE}.cpio${compress_ext}"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_INITRAMFS_COMPRESSION_NONE=n
@@ -1714,9 +1899,9 @@ create_initramfs() {
esac
print_info 1 "$(get_indent 1)>> Compressing cpio data (${compress_ext}) ..."
- print_info 3 "COMMAND: ${compress_cmd} $CPIO" 1 0 1
- ${compress_cmd} "${CPIO}" || gen_die "Compression (${compress_cmd}) failed"
- mv -f "${CPIO}${compress_ext}" "${CPIO}" || gen_die "Rename failed"
+ print_info 3 "COMMAND: ${compress_cmd} ${CPIO_ARCHIVE}" 1 0 1
+ ${compress_cmd} "${CPIO_ARCHIVE}" || gen_die "Compression (${compress_cmd}) failed"
+ mv -f "${CPIO_ARCHIVE}${compress_ext}" "${CPIO_ARCHIVE}" || gen_die "Rename failed"
else
print_info 3 "$(get_indent 1)>> --no-compress-initramfs is set; Skipping compression of initramfs ..."
fi
@@ -1779,25 +1964,24 @@ create_initramfs() {
print_info 1 "$(get_indent 2)early-microcode: Creating cpio ..."
pushd "${TEMP}/ucode_tmp" &>/dev/null || gen_die "Failed to chdir to '${TEMP}/ucode_tmp'!"
log_future_cpio_content
- find . -print0 | cpio --quiet --null -o -H newc > ../ucode.cpio || gen_die "Failed to create cpu microcode cpio"
+ find . -print0 | "${CPIO_COMMAND}" --quiet --null -o -H newc > ../ucode.cpio || gen_die "Failed to create cpu microcode cpio"
popd &>/dev/null || gen_die "Failed to chdir!"
print_info 1 "$(get_indent 2)early-microcode: Prepending early-microcode to initramfs ..."
- cat "${TEMP}/ucode.cpio" "${CPIO}" > "${CPIO}.early-microcode" || gen_die "Failed to prepend early-microcode to initramfs"
- mv -f "${CPIO}.early-microcode" "${CPIO}" || gen_die "Rename failed"
+ cat "${TEMP}/ucode.cpio" "${CPIO_ARCHIVE}" > "${CPIO_ARCHIVE}.early-microcode" || gen_die "Failed to prepend early-microcode to initramfs"
+ mv -f "${CPIO_ARCHIVE}.early-microcode" "${CPIO_ARCHIVE}" || gen_die "Rename failed"
else
print_warning 1 "$(get_indent 2)early-microcode: No microcode found; Will not prepend any microcode to initramfs ..."
print_info 1 "$(get_indent 2) ${BOLD}Note:${NORMAL} You can set --no-microcode-initramfs if you load microcode on your own"
fi
- if ! isTrue "${WRAP_INITRD}" && [[ "${MICROCODE}" == intel ]]
+ if ! isTrue "${WRAP_INITRD}"
then
- # Only show this information for Intel users because we have no mechanism yet
- # to generate amd-*.img in /boot after sys-kernel/linux-firmware update
print_info 1 ''
print_info 1 "${BOLD}Note:${NORMAL}"
print_info 1 '--microcode-initramfs option is enabled by default for backward compatability.'
print_info 1 'If your bootloader can load multiple initramfs it is recommended to load'
- print_info 1 '/boot/intel-uc.img instead of embedding microcode into initramfs.'
+ print_info 1 '/boot/{amd,intel}-uc.img instead of embedding microcode into initramfs so you'
+ print_info 1 'can update microcode via package update independently of initramfs updates.'
fi
else
print_info 3 "$(get_indent 1)>> --no-microcode-initramfs is set; Skipping early-microcode support ..."
@@ -1809,9 +1993,9 @@ create_initramfs() {
[[ -z ${mkimage_cmd} ]] && gen_die "mkimage is not available. Please install package 'dev-embedded/u-boot-tools'."
local mkimage_args="-A ${ARCH} -O linux -T ramdisk -C ${compression:-none} -a 0x00000000 -e 0x00000000"
print_info 1 "$(get_indent 1)>> Wrapping initramfs using mkimage ..."
- print_info 2 "$(get_indent 1)${mkimage_cmd} ${mkimage_args} -n initramfs-${KV} -d ${CPIO} ${CPIO}.uboot"
- ${mkimage_cmd} ${mkimage_args} -n "initramfs-${KV}" -d "${CPIO}" "${CPIO}.uboot" >> ${LOGFILE} 2>&1 || gen_die "Wrapping initramfs using mkimage failed"
- mv -f "${CPIO}.uboot" "${CPIO}" || gen_die "Rename failed"
+ print_info 2 "$(get_indent 1)${mkimage_cmd} ${mkimage_args} -n ${GK_FILENAME_TEMP_INITRAMFS} -d ${CPIO_ARCHIVE} ${CPIO_ARCHIVE}.uboot"
+ ${mkimage_cmd} ${mkimage_args} -n "${GK_FILENAME_TEMP_INITRAMFS}" -d "${CPIO_ARCHIVE}" "${CPIO_ARCHIVE}.uboot" >> ${LOGFILE} 2>&1 || gen_die "Wrapping initramfs using mkimage failed"
+ mv -f "${CPIO_ARCHIVE}.uboot" "${CPIO_ARCHIVE}" || gen_die "Rename failed"
fi
fi
@@ -1820,9 +2004,9 @@ create_initramfs() {
if ! isTrue "${INTEGRATED_INITRAMFS}"
then
copy_image_with_preserve \
- "initramfs" \
- "${TMPDIR}/initramfs-${KV}" \
- "initramfs-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_INITRAMFS_SYMLINK}" \
+ "${CPIO_ARCHIVE}" \
+ "${GK_FILENAME_INITRAMFS}"
fi
fi
}
diff --git a/gen_package.sh b/gen_package.sh
index ca46a2c..aad52de 100755
--- a/gen_package.sh
+++ b/gen_package.sh
@@ -7,31 +7,37 @@ gen_minkernpackage() {
mkdir "${TEMP}/minkernpackage" || gen_die "Failed to create '${TEMP}/minkernpackage'!"
if [ -n "${KERNCACHE}" ]
then
- tar -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" kernel-${ARCH}-${KV} \
- || gen_die "Failed to extract 'kernel-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_KERNEL}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_KERNEL}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
- mv "${TEMP}"/minkernpackage/{kernel-${ARCH}-${KV},kernel-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/kernel-${ARCH}-${KV}' to 'kernel-${KNAME}-${ARCH}-${KV}'!"
-
- tar -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" System.map-${ARCH}-${KV} \
- || gen_die "Failed to extract 'System.map-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ if [[ "${GK_FILENAME_TEMP_KERNEL}" != "${GK_FILENAME_KERNEL}" ]]
+ then
+ mv "${TEMP}"/minkernpackage/{${GK_FILENAME_TEMP_KERNEL},${GK_FILENAME_KERNEL}} \
+ || gen_die "Failed to rename '${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNEL}' to '${GK_FILENAME_KERNEL}'!"
+ fi
- mv "${TEMP}"/minkernpackage/{System.map-${ARCH}-${KV},System.map-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/System.map-${ARCH}-${KV}' to 'System.map-${KNAME}-${ARCH}-${KV}'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_SYSTEMMAP}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_SYSTEMMAP}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
- tar -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" config-${ARCH}-${KV} \
- || gen_die "Failed to extract 'config-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ if [[ "${GK_FILENAME_TEMP_SYSTEMMAP}" != "${GK_FILENAME_SYSTEMMAP}" ]]
+ then
+ mv "${TEMP}"/minkernpackage/{${GK_FILENAME_TEMP_SYSTEMMAP},${GK_FILENAME_SYSTEMMAP}} \
+ || gen_die "Failed to rename '${TEMP}/minkernpackage/${GK_FILENAME_TEMP_SYSTEMMAP}' to '${GK_FILENAME_SYSTEMMAP}'!"
+ fi
- mv "${TEMP}"/minkernpackage/{config-${ARCH}-${KV},config-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/config-${ARCH}-${KV}' to 'config-${KNAME}-${ARCH}-${KV}'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_CONFIG}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_CONFIG}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
if isTrue "${GENZIMAGE}"
then
- tar -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" kernelz-${ARCH}-${KV} \
- || gen_die "Failed to extract 'kernelz-${ARCH}-${KV}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
+ "${TAR_COMMAND}" -x -C "${TEMP}"/minkernpackage -f "${KERNCACHE}" "${GK_FILENAME_TEMP_KERNELZ}" \
+ || gen_die "Failed to extract '${GK_FILENAME_TEMP_KERNELZ}' from '${KERNCACHE}' to '${TEMP}/minkernpackage'!"
- mv "${TEMP}"/minkernpackage/{kernelz-${ARCH}-${KV},kernelz-${KNAME}-${ARCH}-${KV}} \
- || gen_die "Failed to rename '${TEMP}/minkernpackage/kernelz-${ARCH}-${KV}' to 'kernelz-${KNAME}-${ARCH}-${KV}'!"
+ if [[ "${GK_FILENAME_TEMP_KERNELZ}" != "${GK_FILENAME_KERNELZ}" ]]
+ then
+ mv "${TEMP}"/minkernpackage/{${GK_FILENAME_TEMP_KERNELZ},${GK_FILENAME_KERNELZ}} \
+ || gen_die "Failed to rename '${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNELZ}' to '${GK_FILENAME_KERNELZ}'!"
+ fi
fi
else
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
@@ -42,13 +48,13 @@ gen_minkernpackage() {
cd "${KERNEL_OUTPUTDIR}" || gen_die "Failed to chdir to '${KERNEL_OUTPUTDIR}'!"
- cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KNAME}-${ARCH}-${KV}" \
+ cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNEL}" \
|| gen_die "Could not copy the kernel binary '${tmp_kernel_binary}' for the min kernel package!"
- cp "System.map" "${TEMP}/minkernpackage/System.map-${KNAME}-${ARCH}-${KV}" \
+ cp "System.map" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_SYSTEMMAP}" \
|| gen_die "Could not copy '${KERNEL_OUTPUTDIR}/System.map' for the min kernel package!"
- cp ".config" "${TEMP}/minkernpackage/config-${KNAME}-${ARCH}-${KV}" \
+ cp ".config" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_CONFIG}" \
|| gen_die "Could not copy the kernel config '${KERNEL_OUTPUTDIR}/.config' for the min kernel package!"
if isTrue "${GENZIMAGE}"
@@ -59,7 +65,7 @@ gen_minkernpackage() {
gen_die "Failed to locate kernel binary '${KERNEL_BINARY_2}'!"
fi
- cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KNAME}-${ARCH}-${KV}" \
+ cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_KERNEL}" \
|| gen_die "Could not copy the kernelz binary '${tmp_kernel_binary2}' for the min kernel package!"
fi
fi
@@ -68,8 +74,8 @@ gen_minkernpackage() {
then
if isTrue "${BUILD_RAMDISK}"
then
- cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${KNAME}-${ARCH}-${KV}" \
- || gen_die "Could not copy the initramfs '${TMPDIR}/initramfs-${KV}' for the min kernel package!"
+ cp "${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}" "${TEMP}/minkernpackage/${GK_FILENAME_TEMP_INITRAMFS}" \
+ || gen_die "Could not copy the initramfs '${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}' for the min kernel package!"
fi
fi
@@ -117,22 +123,23 @@ gen_kerncache() {
cd "${KERNEL_OUTPUTDIR}" || gen_die "Failed to chdir to '${KERNEL_OUTPUTDIR}'!"
- cp -aL "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" \
+ cp -aL "${tmp_kernel_binary}" "${TEMP}/kerncache/${GK_FILENAME_TEMP_KERNEL}" \
|| gen_die "Could not copy the kernel binary '${tmp_kernel_binary}' for the kernel package!"
- cp -aL "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}" \
+ cp -aL "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/${GK_FILENAME_TEMP_CONFIG}" \
|| gen_die "Could not copy the kernel config '${KERNEL_OUTPUTDIR}/.config' for the kernel package!"
- if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
+ if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
+ then
# Support --kernel-config=/proc/config.gz, mainly
- zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" \
+ zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/${GK_FILENAME_TEMP_CONFIG}.orig" \
|| gen_die "Could not copy the kernel config '${KERNEL_CONFIG}' for the kernel package!"
else
- cp -aL "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" \
+ cp -aL "${KERNEL_CONFIG}" "${TEMP}/kerncache/${GK_FILENAME_TEMP_CONFIG}.orig" \
|| gen_die "Could not copy the kernel config '${KERNEL_CONFIG}' for the kernel package!"
fi
- cp -aL "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}" \
+ cp -aL "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/${GK_FILENAME_TEMP_SYSTEMMAP}" \
|| gen_die "Could not copy the System.map '${KERNEL_OUTPUTDIR}/System.map' for the kernel package!"
if isTrue "${GENZIMAGE}"
@@ -143,7 +150,7 @@ gen_kerncache() {
gen_die "Failed locate kernelz binary '${KERNEL_BINARY_2}'!"
fi
- cp -aL "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" \
+ cp -aL "${tmp_kernel_binary2}" "${TEMP}/kerncache/${GK_FILENAME_TEMP_KERNELZ}" \
|| gen_die "Could not copy the kernelz '${tmp_kernel_binary2}' for the kernel package!"
fi
@@ -173,36 +180,37 @@ gen_kerncache() {
}
gen_kerncache_extract_kernel() {
- tar -xf "${KERNCACHE}" -C "${TEMP}" \
+ print_info 1 "Extracting kerncache kernel from '${KERNCACHE}' ..."
+ "${TAR_COMMAND}" -xf "${KERNCACHE}" -C "${TEMP}" \
|| gen_die "Failed to extract '${KERNCACHE}' to '${TEMP}'!"
copy_image_with_preserve \
- "kernel" \
- "${TEMP}/kernel-${ARCH}-${KV}" \
- "kernel-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_KERNEL_SYMLINK}" \
+ "${TEMP}/${GK_FILENAME_TEMP_KERNEL}" \
+ "${GK_FILENAME_KERNEL}"
if isTrue "${GENZIMAGE}"
then
copy_image_with_preserve \
"kernelz" \
- "${TEMP}/kernelz-${ARCH}-${KV}" \
- "kernelz-${KNAME}-${ARCH}-${KV}"
+ "${TEMP}/${GK_FILENAME_TEMP_KERNELZ}" \
+ "${GK_FILENAME_KERNELZ}"
fi
copy_image_with_preserve \
- "System.map" \
- "${TEMP}/System.map-${ARCH}-${KV}" \
- "System.map-${KNAME}-${ARCH}-${KV}"
+ "${GK_FILENAME_SYSTEMMAP_SYMLINK}" \
+ "${TEMP}/${GK_FILENAME_TEMP_SYSTEMMAP}" \
+ "${GK_FILENAME_SYSTEMMAP}"
}
gen_kerncache_extract_modules() {
print_info 1 "Extracting kerncache kernel modules from '${KERNCACHE}' ..."
if [ -n "${INSTALL_MOD_PATH}" ]
then
- tar -xf "${KERNCACHE}" --strip-components 1 -C "${INSTALL_MOD_PATH}"/lib \
+ "${TAR_COMMAND}" -xf "${KERNCACHE}" --strip-components 1 -C "${INSTALL_MOD_PATH}"/lib \
|| gen_die "Failed to extract kerncache modules from '${KERNCACHE}' to '${INSTALL_MOD_PATH}/lib'!"
else
- tar -xf "${KERNCACHE}" --strip-components 1 -C /lib \
+ "${TAR_COMMAND}" -xf "${KERNCACHE}" --strip-components 1 -C /lib \
|| gen_die "Failed to extract kerncache modules from '${KERNCACHE}' to '${INSTALL_MOD_PATH}/lib'!"
fi
}
@@ -215,11 +223,11 @@ gen_kerncache_extract_config() {
mkdir -p /etc/kernels || gen_die "Failed to create '/etc/kernels'!"
fi
- tar -xf "${KERNCACHE}" -C /etc/kernels config-${ARCH}-${KV} \
- || gen_die "Failed to extract kerncache config 'config-${ARCH}-${KV}' from '${KERNCACHE}' to '/etc/kernels'!"
+ "${TAR_COMMAND}" -xf "${KERNCACHE}" -C /etc/kernels "${GK_FILENAME_TEMP_CONFIG}" \
+ || gen_die "Failed to extract kerncache config '${GK_FILENAME_TEMP_CONFIG}' from '${KERNCACHE}' to '/etc/kernels'!"
- mv /etc/kernels/config-${ARCH}-${KV} /etc/kernels/kernel-config-${ARCH}-${KV} \
- || gen_die "Failed to rename kernelcache config '/etc/kernels/config-${ARCH}-${KV}' to '/etc/kernels/kernel-config-${ARCH}-${KV}'!"
+ mv /etc/kernels/${GK_FILENAME_TEMP_CONFIG} /etc/kernels/${GK_FILENAME_CONFIG} \
+ || gen_die "Failed to rename kernelcache config '/etc/kernels/${GK_FILENAME_TEMP_CONFIG}' to '/etc/kernels/${GK_FILENAME_CONFIG}'!"
}
gen_kerncache_is_valid() {
@@ -227,7 +235,7 @@ gen_kerncache_is_valid() {
if [ -e "${KERNCACHE}" ]
then
- tar -xf "${KERNCACHE}" -C "${TEMP}" \
+ "${TAR_COMMAND}" -xf "${KERNCACHE}" -C "${TEMP}" \
|| gen_die "Failed to extract '${KERNCACHE}' to '${TEMP}'!"
if ! isTrue "${KERNEL_SOURCES}"
@@ -235,22 +243,24 @@ gen_kerncache_is_valid() {
BUILD_KERNEL="no"
# Can make this more secure ....
- if [ -e "${TEMP}/config-${ARCH}-${KV}" -a -e "${TEMP}/kernel-${ARCH}-${KV}" ]
+ if [ -e "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" -a -e "${TEMP}/${GK_FILENAME_TEMP_KERNEL}" ]
then
+ print_info 1 '' 1 0
print_info 1 'Valid kerncache found; No sources will be used ...'
KERNCACHE_IS_VALID="yes"
fi
else
- if [ -e "${TEMP}/config-${ARCH}-${KV}" -a -e "${KERNEL_CONFIG}" ]
+ if [ -e "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" -a -e "${KERNEL_CONFIG}" ]
then
- if [ -e "${TEMP}/config-${ARCH}-${KV}.orig" ]
+ if [ -e "${TEMP}/${GK_FILENAME_TEMP_CONFIG}.orig" ]
then
- local test1=$(grep -v "^#" "${TEMP}/config-${ARCH}-${KV}.orig" | md5sum | cut -d " " -f 1)
+ local test1=$(grep -v "^#" "${TEMP}/${GK_FILENAME_TEMP_CONFIG}.orig" | md5sum | cut -d " " -f 1)
else
- local test1=$(grep -v "^#" "${TEMP}/config-${ARCH}-${KV}" | md5sum | cut -d " " -f 1)
+ local test1=$(grep -v "^#" "${TEMP}/${GK_FILENAME_TEMP_CONFIG}" | md5sum | cut -d " " -f 1)
fi
- if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
+ if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
+ then
# Support --kernel-config=/proc/config.gz, mainly
local CONFGREP=zgrep
else
@@ -260,9 +270,11 @@ gen_kerncache_is_valid() {
if [[ "${test1}" == "${test2}" ]]
then
+ print_info 1 '' 1 0
print_info 1 "Valid kerncache '${KERNCACHE}' found; Will skip kernel build step ..."
KERNCACHE_IS_VALID="yes"
else
+ print_info 1 '' 1 0
print_info 1 "Kerncache kernel config differs from '${KERNEL_CONFIG}'; Ignoring outdated kerncache '${KERNCACHE}' ..."
fi
else
@@ -272,14 +284,14 @@ gen_kerncache_is_valid() {
invalid_reason="Kernel config '${KERNEL_CONFIG}' does not exist -- cannot validate kerncache"
fi
+ print_info 1 '' 1 0
print_info 1 "${invalid_reason}; Ignorning kerncache '${KERNCACHE}' ..."
fi
fi
else
+ print_warning 1 '' 1 0
print_warning 1 "Kerncache '${KERNCACHE}' does not exist (yet?); Ignoring ..."
fi
- echo
-
export KERNCACHE_IS_VALID
}
diff --git a/genkernel b/genkernel
index d0f45c4..8c95c7c 100755
--- a/genkernel
+++ b/genkernel
@@ -2,11 +2,9 @@
# $Id$
PATH="${PATH}:/sbin:/usr/sbin"
-GK_V='4.0.0_beta6'
+GK_V='4.0.0_beta18'
-# Set the default for TMPDIR. May be modified by genkernel.conf or the
-# --tempdir command line option.
-TMPDIR='/var/tmp/genkernel'
+GK_TIME_START=$(date +%s)
TODEBUGCACHE=yes # Until an error occurs or LOGFILE is fully qualified.
@@ -24,15 +22,44 @@ do
[[ "${arg}" == --config=* ]] && CMD_GK_CONFIG=${arg#--config=}
done
-# Pull in our configuration
+# Pull in our configuration to get GK_SHARE only...
_GENKERNEL_CONF=${CMD_GK_CONFIG:-/etc/genkernel.conf}
-source "${_GENKERNEL_CONF}" || small_die "Could not read ${_GENKERNEL_CONF}"
+GK_SHARE=$(source "${_GENKERNEL_CONF}" &>/dev/null && echo ${GK_SHARE})
if [ -z "${GK_SHARE}" ]
then
small_die "GK_SHARE is not set. Please check used genkernel config file at '${_GENKERNEL_CONF}'!"
fi
+# Make sure that we do not clash with the environment
+GK_DETERMINEARGS_FILE="${GK_SHARE}/gen_determineargs.sh"
+GK_SETTINGS=( $(awk '/[^#]set_config_with_override/ { print $3 }' "${GK_DETERMINEARGS_FILE}" 2>/dev/null) )
+if [ ${#GK_SETTINGS[@]} -gt 0 ]
+then
+ GK_SETTINGS+=( CALLBACK )
+ GK_SETTINGS+=( EXTRAVERSION )
+ GK_SETTINGS+=( MOD_INSTALL )
+
+ for GK_SETTING in "${GK_SETTINGS[@]}"
+ do
+ for var_to_unset in ${GK_SETTING} CMD_${GK_SETTING}
+ do
+ if [ -n "${!var_to_unset}" ]
+ then
+ echo "WARNING: Will unset existing variable '${var_to_unset}' to avoid clashing with genkernel config ..." >&2
+ unset ${var_to_unset} || small_die "Failed to unset existing variable '${var_to_unset}'!"
+ fi
+ done
+ done
+
+ unset GK_DETERMINEARGS_FILE GK_SETTINGS GK_SETTING var_to_unset
+else
+ small_die "Failed to extract genkernel options from '${GK_DETERMINEARGS_FILE}'!"
+fi
+
+# Now we can source our configuration...
+source "${_GENKERNEL_CONF}" || small_die "Could not read ${_GENKERNEL_CONF}"
+
# set default LOGLEVEL if uninitialized
LOGLEVEL=${LOGLEVEL:-1}
@@ -40,23 +67,15 @@ LOGLEVEL=${LOGLEVEL:-1}
source "${GK_SHARE}"/defaults/software.sh || small_die "Could not read '${GK_SHARE}/defaults/software.sh'"
source "${GK_SHARE}"/defaults/config.sh || small_die "Could not read '${GK_SHARE}/defaults/config.sh'"
source "${GK_SHARE}"/gen_funcs.sh || small_die "Could not read '${GK_SHARE}/gen_funcs.sh'"
-source "${GK_SHARE}"/gen_cmdline.sh || gen_die "Could not read '${GK_SHARE}/gen_cmdline.sh'"
-source "${GK_SHARE}"/gen_arch.sh || gen_die "Could not read '${GK_SHARE}/gen_arch.sh'"
-source "${GK_SHARE}"/gen_determineargs.sh || gen_die "Could not read '${GK_SHARE}/gen_determineargs.sh'"
-source "${GK_SHARE}"/gen_compile.sh || gen_die "Could not read '${GK_SHARE}/gen_compile.sh'"
-source "${GK_SHARE}"/gen_configkernel.sh || gen_die "Could not read '${GK_SHARE}/gen_configkernel.sh'"
-source "${GK_SHARE}"/gen_initramfs.sh || gen_die "Could not read '${GK_SHARE}/gen_initramfs.sh'"
-source "${GK_SHARE}"/gen_moddeps.sh || gen_die "Could not read '${GK_SHARE}/gen_moddeps.sh'"
-source "${GK_SHARE}"/gen_package.sh || gen_die "Could not read '${GK_SHARE}/gen_package.sh'"
-source "${GK_SHARE}"/gen_bootloader.sh || gen_die "Could not read '${GK_SHARE}/gen_bootloader.sh'"
-
-if [ ! -d "${TMPDIR}" ]
-then
- mkdir -p "${TMPDIR}" || gen_die "Failed to create '${TMPDIR}'!"
-fi
-
-TEMP=$(mktemp -d -p "${TMPDIR}" gk.XXXXXXXX 2>/dev/null)
-[ -z "${TEMP}" ] && gen_die "mktemp failed!"
+source "${GK_SHARE}"/gen_cmdline.sh || small_die "Could not read '${GK_SHARE}/gen_cmdline.sh'"
+source "${GK_SHARE}"/gen_arch.sh || small_die "Could not read '${GK_SHARE}/gen_arch.sh'"
+source "${GK_SHARE}"/gen_determineargs.sh || small_die "Could not read '${GK_SHARE}/gen_determineargs.sh'"
+source "${GK_SHARE}"/gen_compile.sh || small_die "Could not read '${GK_SHARE}/gen_compile.sh'"
+source "${GK_SHARE}"/gen_configkernel.sh || small_die "Could not read '${GK_SHARE}/gen_configkernel.sh'"
+source "${GK_SHARE}"/gen_initramfs.sh || small_die "Could not read '${GK_SHARE}/gen_initramfs.sh'"
+source "${GK_SHARE}"/gen_moddeps.sh || small_die "Could not read '${GK_SHARE}/gen_moddeps.sh'"
+source "${GK_SHARE}"/gen_package.sh || small_die "Could not read '${GK_SHARE}/gen_package.sh'"
+source "${GK_SHARE}"/gen_bootloader.sh || small_die "Could not read '${GK_SHARE}/gen_bootloader.sh'"
export GK_MASTER_PID=${BASHPID}
@@ -82,12 +101,10 @@ then
exit 1
fi
-start_log
NORMAL=${GOOD} print_info 1 "Gentoo Linux Genkernel; Version ${GK_V}${NORMAL}"
print_info 1 "Using genkernel configuration from '${_GENKERNEL_CONF}' ..."
unset _GENKERNEL_CONF
print_info 1 "Running with options: ${GK_OPTIONS}"
-print_info 1 '' 1 0
# Save any customizations of MODULES_* first.
override_module_vars="$(compgen -A variable |grep '^MODULES_')"
@@ -100,6 +117,23 @@ done
determine_real_args
+if isTrue "${BUILD_RAMDISK}" && ! isTrue "${SANDBOX}"
+then
+ print_warning 1 '' 1 0
+ print_warning 1 "${BOLD}WARNING:${NORMAL} Will build initramfs ${BOLD}without${NORMAL} sandbox support " 0
+
+ SANDBOX_WARNING_TIMER=0
+ while [[ ${SANDBOX_WARNING_TIMER} -lt 5 ]]
+ do
+ printf '.'
+ sleep 1
+ let SANDBOX_WARNING_TIMER=${SANDBOX_WARNING_TIMER}+1
+ done
+
+ print_warning 1 '' 1 0
+fi
+
+print_info 2 '' 1 0
print_info 2 "Sourcing default modules_load from '${GK_SHARE}/defaults/modules_load' ..."
source "${GK_SHARE}/defaults/modules_load" || gen_die "Could not read '${GK_SHARE}/defaults/modules_load'!"
@@ -142,20 +176,29 @@ determine_KV
determine_kernel_arch
+determine_output_filenames
+
determine_kernel_config_file
setup_cache_dir
check_distfiles
-dump_debugcache
-
KERNCACHE_IS_VALID="no"
if [ -n "${KERNCACHE}" ]
then
gen_kerncache_is_valid
fi
+if isTrue "${KERNCACHE_IS_VALID}" && ! isTrue "${CMD_INSTALL}" && ! isTrue "${BUILD_RAMDISK}"
+then
+ error_msg="Nothing to do: Selected action does not include building initramfs."
+ error_msg+=" Because kerncache is valid, no kernel will be build."
+ error_msg+=" However, due to set --no-install option, we will not even install kernel binary from kerncache."
+ gen_die "${error_msg}"
+fi
+
+print_info 1 '' 1 0
print_info 1 "Working with Linux kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL}"
print_info 1 "Using kernel config file '${KERNEL_CONFIG}' ..."
@@ -167,6 +210,8 @@ fi
isTrue "${CMD_INSTALL}" && make_bootdir_writable
+check_disk_space_requirements
+
if isTrue "${BUILD_KERNEL}" && ! isTrue "${KERNCACHE_IS_VALID}"
then
print_info 1 '' 1 0
@@ -186,11 +231,13 @@ then
determine_KV
if [ -f "${TEMP}/.old_kv" ]
then
+ determine_output_filenames
+
old_KV=$(cat "${TEMP}/.old_kv")
print_info 1 "$(get_indent 1)>> Kernel version has changed (probably due to config change) since genkernel start:"
- print_info 1 "$(get_indent 1)>> We are now building Linux kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL} ..."
+ print_info 1 "$(get_indent 1) We are now building Linux kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL} ..."
else
- print_info 2 "$(get_indent 1)>> Kernel version has not changed since genkernel start."
+ print_info 2 "$(get_indent 1)>> Kernel version has not changed since genkernel start"
fi
compile_kernel
@@ -204,28 +251,58 @@ then
if isTrue "${SAVE_CONFIG}"
then
- print_info 1 "$(get_indent 1)>> Saving config of successful build to '/etc/kernels/kernel-config-${ARCH}-${KV}' ..."
+ print_info 1 "$(get_indent 1)>> Saving config of successful build to '/etc/kernels/${GK_FILENAME_CONFIG}' ..."
[ ! -e '/etc/kernels' ] && mkdir -p /etc/kernels
- cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/kernel-config-${ARCH}-${KV}" || \
+ cp "${KERNEL_OUTPUTDIR}/.config" "/etc/kernels/${GK_FILENAME_CONFIG}" || \
print_warning 1 "Unable to copy the kernel configuration file; Ignoring non-fatal error ..."
# Just a warning because ordinary users are not allowed to write in /etc
fi
+elif [[ -n "${KERNEL_LOCALVERSION}" && "${KERNEL_LOCALVERSION}" != "${LOV}" ]]
+then
+ if [[ "${KERNEL_LOCALVERSION}" == "UNSET" && -z "${LOV}" ]]
+ then
+ # LOV is already unset...
+ :
+ else
+ print_warning 1 '' 1 0
+ print_warning 1 "Current kernel's LOCALVERSION is set to '${LOV}'; Will ignore set --kernel-localversion value '${KERNEL_LOCALVERSION}' because kernel was not build ..."
+ fi
fi
-if isTrue "${CMD_INSTALL}"
+if isTrue "${KERNCACHE_IS_VALID}"
then
- if isTrue "${KERNCACHE_IS_VALID}"
+ if isTrue "${CMD_INSTALL}"
then
print_info 1 '' 1 0
gen_kerncache_extract_kernel
fi
-fi
-if isTrue "${KERNCACHE_IS_VALID}"
-then
- print_info 1 '' 1 0
- ! isTrue "${BUILD_STATIC}" && gen_kerncache_extract_modules
- gen_kerncache_extract_config
+ if ! isTrue "${BUILD_STATIC}"
+ then
+ if ! isTrue "${CMD_INSTALL}" && [ -z "${INSTALL_MOD_PATH}" ]
+ then
+ # We have to set $INSTALL_MOD_PATH to avoid installing files
+ # to /lib/modules because --no-install was set
+ INSTALL_MOD_PATH="$(mktemp -d -p "${TEMP}" kerncache-modules.XXXXXXX 2>/dev/null)"
+ if [ -z "${INSTALL_MOD_PATH}" ]
+ then
+ gen_die "Internal error: Variable 'INSTALL_MOD_PATH' is empty; mktemp() for kerncache modules failed!"
+ else
+ print_info 5 '' 1 0
+ print_info 5 "INSTALL_MOD_PATH set to '${INSTALL_MOD_PATH}' because --kerncache is used but --no-install was set ..."
+ mkdir "${INSTALL_MOD_PATH}/lib" || gen_die "Failed to create '${INSTALL_MOD_PATH}/lib'!"
+ fi
+ fi
+
+ print_info 1 '' 1 0
+ gen_kerncache_extract_modules
+ fi
+
+ if isTrue "${SAVE_CONFIG}"
+ then
+ print_info 1 '' 1 0
+ gen_kerncache_extract_config
+ fi
fi
# Run callback
@@ -247,6 +324,7 @@ then
if [ "${CALLBACK_ESCAPE}" -eq 0 ]
then
print_info 1 '' 1 0
+ print_info 1 '' 1 0
eval ${CMD_CALLBACK} | tee -a "${LOGFILE}"
CMD_STATUS="${PIPESTATUS[0]}"
print_info 1 '' 1 0
@@ -295,11 +373,16 @@ then
fi
fi
-if [ -n "${MINKERNPACKAGE}" -o -n "${MODULESPACKAGE}" ]
+if [ -n "${MINKERNPACKAGE}" ]
+then
+ print_info 1 '' 1 0
+ gen_minkernpackage
+fi
+
+if [ -n "${MODULESPACKAGE}" ]
then
print_info 1 '' 1 0
- [ -n "${MINKERNPACKAGE}" ] && gen_minkernpackage
- [ -n "${MODULESPACKAGE}" ] && gen_modulespackage
+ gen_modulespackage
fi
if isTrue "${BUILD_KERNEL}"
@@ -326,46 +409,57 @@ then
esac
else
print_info 1 ''
- print_info 1 "You will find the kernel image in '${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}'."
- if isTrue "${GENZIMAGE}"
+ if ! isTrue "${KERNCACHE_IS_VALID}"
then
- print_info 1 "You will find the kernelz binary in '${TMPDIR}/kernelz-${KV}'."
+ print_info 1 "You will find the kernel image in '${TMPDIR}/${GK_FILENAME_TEMP_KERNEL}'."
+
+ if isTrue "${GENZIMAGE}"
+ then
+ print_info 1 "You will find the kernelz binary in '${TMPDIR}/${GK_FILENAME_TEMP_KERNELZ}'."
+ fi
fi
if isTrue "${BUILD_RAMDISK}"
then
- print_info 1 "You will find the initramfs in '${TMPDIR}/initramfs-${KNAME}-${ARCH}-${KV}'."
+ print_info 1 "You will find the initramfs in '${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}'."
fi
fi
- print_info 1 ''
- print_info 1 'Required kernel parameter:'
- print_info 1 ''
- print_info 1 ' root=/dev/$ROOT'
- print_info 1 ''
- print_info 1 'Where $ROOT is the device node for your root partition as the'
- print_info 1 'one specified in /etc/fstab'
+ if isTrue "${CMD_INSTALL}" || ! isTrue "${KERNCACHE_IS_VALID}"
+ then
+ print_info 1 ''
+ print_info 1 'Required kernel parameter:'
+ print_info 1 ''
+ print_info 1 ' root=/dev/$ROOT'
+ print_info 1 ''
+ print_info 1 'Where $ROOT is the device node for your root partition as the'
+ print_info 1 'one specified in /etc/fstab'
+ fi
if isTrue "${show_warning_initramfs_is_required}" && isTrue "${BUILD_RAMDISK}"
then
+ INITRAMFS_FILE="${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}"
+ isTrue "${CMD_INSTALL}" && INITRAMFS_FILE="${BOOTDIR}/${GK_FILENAME_INITRAMFS}"
+
print_warning 1 '' 1 0
print_warning 1 "If you require Genkernel's hardware detection features, you ${BOLD}MUST${NORMAL}"
- print_warning 1 "tell your bootloader to use the provided initramfs file (${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV})."
+ print_warning 1 "tell your bootloader to use the provided initramfs file '${INITRAMFS_FILE}'."
+ unset INITRAMFS_FILE
fi
unset show_warning_initramfs_is_required
fi
if isTrue "${BUILD_RAMDISK}"
then
- if ! isTrue "${BUILD_KERNEL}" && ! isTrue "${CMD_INSTALL}"
- then
- print_info 1 ''
- print_info 1 "You will find the initramfs in '${TMPDIR}/initramfs-${KNAME}-${ARCH}-${KV}'."
- elif ! isTrue "${BUILD_KERNEL}" && isTrue "${CMD_INSTALL}"
+ if ! isTrue "${BUILD_KERNEL}"
then
+ INITRAMFS_FILE="${TMPDIR}/${GK_FILENAME_TEMP_INITRAMFS}"
+ isTrue "${CMD_INSTALL}" && INITRAMFS_FILE="${BOOTDIR}/${GK_FILENAME_INITRAMFS}"
+
print_info 1 ''
- print_info 1 "You will find the initramfs in '${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV}'."
+ print_info 1 "You will find the initramfs in '${INITRAMFS_FILE}'."
+ unset INITRAMFS_FILE
fi
print_warning 1 '' 1 0
@@ -406,7 +500,7 @@ then
print_warning 1 '"man genkernel" explains "dozfs" in detail.'
fi
- if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]
+ if isTrue "$(is_gzipped "${KERNEL_CONFIG}")"
then
# Support --kernel-config=/proc/config.gz, mainly
CONFGREP=zgrep
diff --git a/genkernel.conf b/genkernel.conf
index cad0297..aa458fb 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -52,6 +52,12 @@ NOCOLOR="false"
# Clear all tmp files and caches after genkernel has run
#POSTCLEAR="no"
+# Check for x MB free disk space in BOOTDIR
+#CHECK_FREE_DISK_SPACE_BOOTDIR=0
+
+# Check for x MB free disk space in kernel outputdir
+#CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR=0
+
# Genkernel uses an independent configuration for MAKEOPTS, and does not source
# /etc/portage/make.conf . You can override the default setting by uncommenting
# and tweaking the following line. Default setting is set up by
@@ -148,6 +154,9 @@ NOCOLOR="false"
# Possible values: empty/"no", "grub", "grub2"
#BOOTLOADER="no"
+# Use sandbox when building initramfs
+#SANDBOX="yes"
+
# Add boot splash using splashutils
#SPLASH="no"
@@ -163,7 +172,7 @@ NOCOLOR="false"
# Run the specified command in the current environment after the kernel and
# modules have been compiled, useful to rebuild external kernel module
# (see MODULEREBUILD above) or installing additional
-# files (use 'copy_image_with_preserve dtb path/to/dtb dtb ${KNAME}-${ARCH}-${KV}')
+# files (use 'copy_image_with_preserve dtb path/to/dtb dtb <kernelname>')
#CMD_CALLBACK=""
@@ -270,10 +279,17 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux"
# =========MISC KERNEL CONFIGURATION============
#
-# Tag the kernel and initramfs with a name:
-# If not defined the option defaults to
-# 'genkernel'
-#KNAME="genkernel"
+# Set kernel filename which will be used when kernel will be installed
+# into BOOTDIR. See man page to learn more about available placeholders.
+#KERNEL_FILENAME="vmlinuz-%%KV%%"
+
+# Set kernel symlink name which will be used when kernel will be installed
+# into BOOTDIR and SYMLINK option is enabled
+#KERNEL_SYMLINK_NAME="kernel"
+
+# This option will set kernel option CONFIG_LOCALVERSION.
+# Use special value "UNSET" to unset already set CONFIG_LOCALVERSION.
+#KERNEL_LOCALVERSION="-%%ARCH%%"
# This option is only valid if kerncache is
# defined. If there is a valid kerncache no checks
@@ -299,6 +315,15 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux"
# =========MISC INITRAMFS CONFIGURATION============
#
+# Set initramfs filename which will be used when initramfs will be
+# installed into BOOTDIR. See man page to learn more about available
+# placeholders.
+#INITRAMFS_FILENAME="initramfs-%%KV%%.img"
+
+# Set initramfs symlink name which will be used when initramfs will be
+# installed into BOOTDIR and SYMLINK option is enabled
+#INITRAMFS_SYMLINK_NAME="initramfs"
+
# Copy all compiled kernel modules to the initramfs
#ALLRAMDISKMODULES="no"
diff --git a/gkbuilds/boost-build.gkbuild b/gkbuilds/boost-build.gkbuild
new file mode 100644
index 0000000..b2883ed
--- /dev/null
+++ b/gkbuilds/boost-build.gkbuild
@@ -0,0 +1,64 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+MY_PV="${PV//./_}"
+S="${WORKDIR}/boost_${MY_PV}/tools/build/src"
+QA_IGNORE_DYNAMICALLY_LINKED_PROGRAM='(bjam|b2)$'
+
+src_prepare() {
+ default
+
+ # remove default -march/-mcpu definitions
+ # bjam is trying to be clever and injects -march= in order to
+ # optimize code for you. This breaks on 32-bit builds, because
+ # -march=i686 will not work on an i486 CHOST.
+ # https://bugs.gentoo.org/624616
+ sed -e '/^cpu-flags\s*gcc\s*OPTIONS/d' \
+ -e '/toolset\.flags\s*gcc\s*OPTIONS/d' \
+ -e "/cpu_flags('gcc',\s*'OPTIONS'/d" \
+ -i tools/gcc.{jam,py} || die "Failed removing -march/-mcpu"
+}
+
+src_compile() {
+ cd engine || die "Failed to chdir to '${S}/engine'!"
+
+ local myargs=(
+ ./build.sh
+ cxx
+ -d+2
+ --without-python
+ )
+
+ CC=$(tc-getBUILD_CC) CXX=$(tc-getBUILD_CXX) gkexec "${myargs[*]}"
+}
+
+src_install() {
+ mkdir -p "${D}"/usr/bin \
+ || die "Failed to create '${D}/usr/bin'!"
+
+ cp --target-directory="${D}/usr/bin" engine/{bjam,b2} \
+ || die "Failed to install 'engine/{bjam,b2}' to '${D}/usr/bin'!"
+
+ mkdir -p "${D}"/usr/share/boost-build \
+ || die "Failed to create '${D}/usr/share/boost-build'!"
+
+ cp \
+ --recursive \
+ --target-directory="${D}/usr/share/boost-build" \
+ ../boost-build.jam \
+ bootstrap.jam \
+ build-system.jam \
+ ../example/user-config.jam \
+ build \
+ kernel \
+ options \
+ tools \
+ util \
+ || die "Failed to copy *.jam files to '${D}/usr/share/boost-build'!"
+
+ find "${D}/usr/share/boost-build" -iname "*.py" -delete \
+ || die "Failed to remove python files"
+
+ echo 'variant gentoorelease : release : <optimization>none <debug-symbols>none <runtime-link>shared ;' > "${D}/usr/share/boost-build/site-config.jam" \
+ || die "Failed to create '${D}/usr/share/boost-build/site-config.jam'!"
+}
diff --git a/gkbuilds/boost.gkbuild b/gkbuilds/boost.gkbuild
new file mode 100644
index 0000000..8b1012b
--- /dev/null
+++ b/gkbuilds/boost.gkbuild
@@ -0,0 +1,80 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+create_user-config.jam() {
+ local user_config_jam="${S}"/user-config.jam
+ if [[ -s ${user_config_jam} ]]; then
+ return
+ fi
+
+ local compiler compiler_version compiler_executable="$(tc-getCXX)"
+ compiler="gcc"
+ compiler_version="$(gcc-version)"
+
+ cat > "${user_config_jam}" <<- __EOF__ || die
+ using ${compiler} : ${compiler_version} : ${compiler_executable} : <cflags>"${CFLAGS}" <cxxflags>"${CXXFLAGS}" <linkflags>"${LDFLAGS}" ;
+ __EOF__
+}
+
+ejam() {
+ create_user-config.jam
+
+ local myargs=(
+ b2
+ "--user-config=${S}/user-config.jam"
+ --without-python
+ "$@"
+ )
+
+ gkexec "${myargs[*]}"
+}
+
+src_configure() {
+ # Workaround for too many parallel processes requested, bug #506064
+ [[ "$(makeopts_jobs)" -gt 64 ]] && MAKEOPTS="${MAKEOPTS} -j64"
+
+ OPTIONS=(
+ gentoorelease
+ "-j$(makeopts_jobs)"
+ -q
+ -d+2
+ pch=off
+ --disable-icu boost.locale.icu=off
+ --without-mpi
+ --without-locale
+ --without-context --without-coroutine --without-fiber
+ --without-stacktrace
+ --boost-build="${BROOT}"/usr/share/boost-build
+ --prefix="/usr"
+ --layout=system
+ --no-cmake-config
+ threading=multi
+ link=shared,static
+ # this seems to be the only way to disable compression algorithms
+ # https://www.boost.org/doc/libs/1_70_0/libs/iostreams/doc/installation.html#boost-build
+ -sNO_BZIP2=1
+ -sNO_LZMA=1
+ -sNO_ZLIB=1
+ -sNO_ZSTD=1
+ )
+
+ # bug 298489
+ if [[ "${CHOST}" == powerpc* ]]; then
+ [[ $(gcc-version) > 4.3 ]] && append-flags -mno-altivec
+ fi
+
+ # Use C++14 globally as of 1.62
+ append-cxxflags -std=c++14
+}
+
+src_compile() {
+ ejam "${OPTIONS[@]}" || die "Compilation of Boot libraries failed!"
+}
+
+src_install() {
+ ejam \
+ "${OPTIONS[@]}" \
+ --includedir="${D}/usr/include" \
+ --libdir="${D}/usr/lib" \
+ install || die "Installation of Boost libraries failed!"
+}
diff --git a/gkbuilds/expat.gkbuild b/gkbuilds/expat.gkbuild
new file mode 100644
index 0000000..22dbb29
--- /dev/null
+++ b/gkbuilds/expat.gkbuild
@@ -0,0 +1,19 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_configure() {
+ local myconf=(
+ --enable-static
+ --without-docbook
+ )
+
+ gkconf "${myconf[@]}"
+}
+
+src_install() {
+ default
+
+ rm -rf \
+ "${D}"/usr/bin \
+ "${D}"/usr/share
+}
diff --git a/gkbuilds/lvm.gkbuild b/gkbuilds/lvm.gkbuild
index 05fd087..9cedead 100644
--- a/gkbuilds/lvm.gkbuild
+++ b/gkbuilds/lvm.gkbuild
@@ -27,6 +27,13 @@ src_configure() {
--disable-udev_rules
)
+ local texec
+ for texec in check dump repair restore
+ do
+ myconf+=( --with-thin-${texec}=/usr/sbin/thin_${texec} )
+ myconf+=( --with-cache-${texec}=/usr/sbin/cache_${texec} )
+ done
+
gkconf "${myconf[@]}"
}
diff --git a/gkbuilds/thin-provisioning-tools.gkbuild b/gkbuilds/thin-provisioning-tools.gkbuild
new file mode 100644
index 0000000..64500c9
--- /dev/null
+++ b/gkbuilds/thin-provisioning-tools.gkbuild
@@ -0,0 +1,33 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+src_prepare() {
+ default
+ gkautoreconf
+}
+
+src_configure() {
+ append-ldflags -static
+
+ local myconf=(
+ --with-optimisation=''
+ --disable-testing
+ )
+
+ gkconf "${myconf[@]}"
+}
+
+src_compile() {
+ gkmake
+}
+
+src_install() {
+ local MYMAKEOPTS=( "DESTDIR=${D}" )
+ MYMAKEOPTS+=( "DATADIR=${D}/usr/share" )
+ MYMAKEOPTS+=( "install" )
+
+ gkmake "${MYMAKEOPTS[@]}"
+
+ rm -rf \
+ "${D}"/usr/share
+}
diff --git a/gkbuilds/xfsprogs.gkbuild b/gkbuilds/xfsprogs.gkbuild
index 4456738..b16379f 100644
--- a/gkbuilds/xfsprogs.gkbuild
+++ b/gkbuilds/xfsprogs.gkbuild
@@ -15,7 +15,6 @@ src_configure() {
unset PLATFORM # if set in user env, this breaks configure
local myconf=(
- --disable-lto #655638
--enable-blkid
--disable-libicu
--disable-gettext
diff --git a/patches/boost-build/1.71.0/boost-build-1.48.0-disable_python_rpath.patch b/patches/boost-build/1.71.0/boost-build-1.48.0-disable_python_rpath.patch
new file mode 100644
index 0000000..84734f7
--- /dev/null
+++ b/patches/boost-build/1.71.0/boost-build-1.48.0-disable_python_rpath.patch
@@ -0,0 +1,11 @@
+--- a/tools/python.jam
++++ b/tools/python.jam
+@@ -961,7 +961,7 @@
+ # linux).
+ : $(usage-requirements)
+ <testing.launcher>$(set-PYTHONPATH)
+- <library-path>$(libraries) <dll-path>$(dll-path) <library>python.lib
++ <library-path>$(libraries) <library>python.lib
+ ;
+ }
+
diff --git a/patches/boost-build/1.71.0/boost-build-1.62.0-sparc-no-default-flags.patch b/patches/boost-build/1.71.0/boost-build-1.62.0-sparc-no-default-flags.patch
new file mode 100644
index 0000000..a3f450b
--- /dev/null
+++ b/patches/boost-build/1.71.0/boost-build-1.62.0-sparc-no-default-flags.patch
@@ -0,0 +1,47 @@
+--- a/tools/gcc.py 2018-09-07 17:44:59.668796217 +0200
++++ b/tools/gcc.py 2018-09-07 17:45:56.378794314 +0200
+@@ -811,20 +811,6 @@
+ # Sparc
+ flags('gcc', 'OPTIONS', ['<architecture>sparc/<address-model>32'], ['-m32'])
+ flags('gcc', 'OPTIONS', ['<architecture>sparc/<address-model>64'], ['-m64'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'v7', ['-mcpu=v7'], default=True)
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'cypress', ['-mcpu=cypress'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'v8', ['-mcpu=v8'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'supersparc', ['-mcpu=supersparc'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'sparclite', ['-mcpu=sparclite'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'hypersparc', ['-mcpu=hypersparc'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'sparclite86x', ['-mcpu=sparclite86x'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'f930', ['-mcpu=f930'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'f934', ['-mcpu=f934'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'sparclet', ['-mcpu=sparclet'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'tsc701', ['-mcpu=tsc701'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'v9', ['-mcpu=v9'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'ultrasparc', ['-mcpu=ultrasparc'])
+-cpu_flags('gcc', 'OPTIONS', 'sparc', 'ultrasparc3', ['-mcpu=ultrasparc3'])
+ # RS/6000 & PowerPC
+ flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>32'], ['-m32'])
+ flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>64'], ['-m64'])
+--- a/tools/gcc.jam 2018-09-07 17:45:12.168795797 +0200
++++ b/tools/gcc.jam 2018-09-07 17:46:25.498793337 +0200
+@@ -1134,21 +1134,6 @@
+ cpu-flags gcc OPTIONS : x86 : c3-2 : -march=c3-2 ;
+ ##
+ cpu-flags gcc OPTIONS : x86 : atom : -march=atom ;
+-# Sparc
+-cpu-flags gcc OPTIONS : sparc : v7 : -mcpu=v7 : default ;
+-cpu-flags gcc OPTIONS : sparc : cypress : -mcpu=cypress ;
+-cpu-flags gcc OPTIONS : sparc : v8 : -mcpu=v8 ;
+-cpu-flags gcc OPTIONS : sparc : supersparc : -mcpu=supersparc ;
+-cpu-flags gcc OPTIONS : sparc : sparclite : -mcpu=sparclite ;
+-cpu-flags gcc OPTIONS : sparc : hypersparc : -mcpu=hypersparc ;
+-cpu-flags gcc OPTIONS : sparc : sparclite86x : -mcpu=sparclite86x ;
+-cpu-flags gcc OPTIONS : sparc : f930 : -mcpu=f930 ;
+-cpu-flags gcc OPTIONS : sparc : f934 : -mcpu=f934 ;
+-cpu-flags gcc OPTIONS : sparc : sparclet : -mcpu=sparclet ;
+-cpu-flags gcc OPTIONS : sparc : tsc701 : -mcpu=tsc701 ;
+-cpu-flags gcc OPTIONS : sparc : v9 : -mcpu=v9 ;
+-cpu-flags gcc OPTIONS : sparc : ultrasparc : -mcpu=ultrasparc ;
+-cpu-flags gcc OPTIONS : sparc : ultrasparc3 : -mcpu=ultrasparc3 ;
+ # RS/6000 & PowerPC
+ cpu-flags gcc OPTIONS : power : 403 : -mcpu=403 ;
+ cpu-flags gcc OPTIONS : power : 505 : -mcpu=505 ;
diff --git a/patches/boost-build/1.71.0/boost-build-1.66.0-add-none-feature-options.patch b/patches/boost-build/1.71.0/boost-build-1.66.0-add-none-feature-options.patch
new file mode 100644
index 0000000..fd86c9e
--- /dev/null
+++ b/patches/boost-build/1.71.0/boost-build-1.66.0-add-none-feature-options.patch
@@ -0,0 +1,26 @@
+diff --git a/tools/features/debug-feature.jam b/tools/features/debug-feature.jam
+index 04958f9a..38b6acf1 100644
+--- a/tools/features/debug-feature.jam
++++ b/tools/features/debug-feature.jam
+@@ -8,7 +8,7 @@
+ import feature ;
+
+ feature.feature debug-symbols
+- : on off
++ : on off none
+ : propagated ;
+
+ feature.feature profiling
+diff --git a/tools/features/optimization-feature.jam b/tools/features/optimization-feature.jam
+index 761f76f1..fb2a5dec 100644
+--- a/tools/features/optimization-feature.jam
++++ b/tools/features/optimization-feature.jam
+@@ -8,7 +8,7 @@
+ import feature ;
+
+ feature.feature optimization
+- : off speed space
++ : off none speed space
+ : propagated ;
+
+ feature.feature inlining
diff --git a/patches/boost-build/1.71.0/boost-build-1.71.0-respect-c_ld-flags.patch b/patches/boost-build/1.71.0/boost-build-1.71.0-respect-c_ld-flags.patch
new file mode 100644
index 0000000..f51abea
--- /dev/null
+++ b/patches/boost-build/1.71.0/boost-build-1.71.0-respect-c_ld-flags.patch
@@ -0,0 +1,9 @@
+--- a/engine/build.sh
++++ b/engine/build.sh
+@@ -439,5 +439,5 @@
+ if check_debug_build "$@" ; then B2_CXXFLAGS="${B2_CXXFLAGS_DEBUG}"
+ else B2_CXXFLAGS="${B2_CXXFLAGS_RELEASE} -DNDEBUG"
+ fi
+-echo_run ${B2_CXX} ${CXXFLAGS} ${B2_CXXFLAGS} ${B2_SOURCES} -o b2
++echo_run ${B2_CXX} ${CPPFLAGS} ${CXXFLAGS} ${LDFLAGS} ${B2_CXXFLAGS} ${B2_SOURCES} -o b2
+ echo_run cp b2 bjam
diff --git a/patches/boost/1.71.0/boost-1.69.0-context-x32.patch b/patches/boost/1.71.0/boost-1.69.0-context-x32.patch
new file mode 100644
index 0000000..9ee3d54
--- /dev/null
+++ b/patches/boost/1.71.0/boost-1.69.0-context-x32.patch
@@ -0,0 +1,38 @@
+--- a/libs/context/src/asm/jump_i386_sysv_elf_gas.S
++++ b/libs/context/src/asm/jump_i386_sysv_elf_gas.S
+@@ -24,6 +24,10 @@
+ * *
+ ****************************************************************************************/
+
++#ifdef __x86_64__
++#include "jump_x86_64_sysv_elf_gas.S"
++#else
++
+ .file "jump_i386_sysv_elf_gas.S"
+ .text
+ .globl jump_fcontext
+@@ -81,3 +85,5 @@
+
+ /* Mark that we don't need executable stack. */
+ .section .note.GNU-stack,"",%progbits
++
++#endif
+--- a/libs/context/src/asm/make_i386_sysv_elf_gas.S
++++ b/libs/context/src/asm/make_i386_sysv_elf_gas.S
+@@ -24,6 +24,10 @@
+ * *
+ ****************************************************************************************/
+
++#ifdef __x86_64__
++#include "make_x86_64_sysv_elf_gas.S"
++#else
++
+ .file "make_i386_sysv_elf_gas.S"
+ .text
+ .globl make_fcontext
+@@ -105,3 +109,5 @@
+
+ /* Mark that we don't need executable stack. */
+ .section .note.GNU-stack,"",%progbits
++
++#endif
diff --git a/patches/btrfs-progs/5.1.1/btrfs-lzo2.patch b/patches/btrfs-progs/5.2.2/btrfs-lzo2.patch
index 67b31f7..67b31f7 100644
--- a/patches/btrfs-progs/5.1.1/btrfs-lzo2.patch
+++ b/patches/btrfs-progs/5.2.2/btrfs-lzo2.patch
diff --git a/patches/btrfs-progs/5.1.1/btrfs-m4.patch b/patches/btrfs-progs/5.2.2/btrfs-m4.patch
index 831ff99..831ff99 100644
--- a/patches/btrfs-progs/5.1.1/btrfs-m4.patch
+++ b/patches/btrfs-progs/5.2.2/btrfs-m4.patch
diff --git a/patches/busybox/1.31.0/busybox-1.26.0-mdstart.patch b/patches/busybox/1.31.0/busybox-1.26.0-mdstart.patch
deleted file mode 100644
index 35057b6..0000000
--- a/patches/busybox/1.31.0/busybox-1.26.0-mdstart.patch
+++ /dev/null
@@ -1,80 +0,0 @@
-diff --git a/util-linux/mdStart.c b/util-linux/mdStart.c
---- util-linux/mdStart.c 1969-12-31 18:00:00.000000000 -0600
-+++ util-linux/mdStart.c 2017-01-01 18:25:14.582737879 -0600
-@@ -0,0 +1,76 @@
-+/*
-+ * Linux 2.6(+) RAID Autostarter
-+ *
-+ * Copyright (C) 2005 by Tim Yamin <plasmaroo@gentoo.org> <plasm@roo.me.uk>
-+ * Copyright (C) 2012 by Sebastian Pipping <sebastian@pipping.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 2 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, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ *
-+ */
-+//config:config MDSTART
-+//config: bool "mdstart"
-+//config: default n
-+//config: help
-+//config: Allows you to autostart /dev/md devices if using an initramfs to
-+//config: boot.
-+
-+//applet:IF_MDSTART(APPLET(mdstart, BB_DIR_SBIN, BB_SUID_DROP))
-+
-+//kbuild:lib-$(CONFIG_MDSTART) += mdStart.o
-+
-+//usage:#define mdstart_trivial_usage
-+//usage: "[PARTITION] MD-NODE [[PARTITION] MD-NODE ...]"
-+//usage:
-+//usage:#define mdstart_full_usage "\n\n"
-+//usage: "Run the RAID_AUTORUN ioctl on the given MD number"
-+
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <sys/ioctl.h>
-+#include <linux/major.h>
-+#include <linux/raid/md_u.h>
-+
-+extern int
-+mdstart_main(int argc, char *argv[])
-+{
-+ int i, fd, part = 0, retval = 0;
-+
-+ if(argc < 2)
-+ {
-+ bb_show_usage();
-+ }
-+
-+ for(i = 1; i < argc; i++)
-+ {
-+ if(sscanf(argv[i], "%d", &part) == 1)
-+ continue;
-+
-+ fd = open(argv[i], 0, 0);
-+ if (fd >= 0)
-+ {
-+ ioctl(fd, RAID_AUTORUN, part);
-+ close(fd);
-+ } else
-+ {
-+ printf("Error: Failed to open %s!\n", argv[i]);
-+ retval=1;
-+ }
-+
-+ part = 0;
-+ }
-+
-+ return retval;
-+}
diff --git a/patches/libgcrypt/1.8.4/libgcrypt-1.8.4-ac_cv_sys_symbol_underscore.patch b/patches/libgcrypt/1.8.5/libgcrypt-1.8.4-ac_cv_sys_symbol_underscore.patch
index d2bb5d1..d2bb5d1 100644
--- a/patches/libgcrypt/1.8.4/libgcrypt-1.8.4-ac_cv_sys_symbol_underscore.patch
+++ b/patches/libgcrypt/1.8.5/libgcrypt-1.8.4-ac_cv_sys_symbol_underscore.patch
diff --git a/patches/lvm/2.02.185/lvm2-001-example.conf.in.patch b/patches/lvm/2.02.186/lvm2-001-example.conf.in.patch
index 34c710d..34c710d 100644
--- a/patches/lvm/2.02.185/lvm2-001-example.conf.in.patch
+++ b/patches/lvm/2.02.186/lvm2-001-example.conf.in.patch
diff --git a/patches/lvm/2.02.185/lvm2-002-always-make-static-libdm.patch b/patches/lvm/2.02.186/lvm2-002-always-make-static-libdm.patch
index 5ddcb4e..5ddcb4e 100644
--- a/patches/lvm/2.02.185/lvm2-002-always-make-static-libdm.patch
+++ b/patches/lvm/2.02.186/lvm2-002-always-make-static-libdm.patch
diff --git a/patches/lvm/2.02.185/lvm2-003-lvm2create_initrd.patch b/patches/lvm/2.02.186/lvm2-003-lvm2create_initrd.patch
index 59aaa9b..59aaa9b 100644
--- a/patches/lvm/2.02.185/lvm2-003-lvm2create_initrd.patch
+++ b/patches/lvm/2.02.186/lvm2-003-lvm2create_initrd.patch
diff --git a/patches/lvm/2.02.185/lvm2-004-createinitrd.patch b/patches/lvm/2.02.186/lvm2-004-createinitrd.patch
index 7f0bfb8..7f0bfb8 100644
--- a/patches/lvm/2.02.185/lvm2-004-createinitrd.patch
+++ b/patches/lvm/2.02.186/lvm2-004-createinitrd.patch
diff --git a/patches/lvm/2.02.185/lvm2-005-locale-muck.patch b/patches/lvm/2.02.186/lvm2-005-locale-muck.patch
index fe7ec87..fe7ec87 100644
--- a/patches/lvm/2.02.185/lvm2-005-locale-muck.patch
+++ b/patches/lvm/2.02.186/lvm2-005-locale-muck.patch
diff --git a/patches/lvm/2.02.185/lvm2-006-asneeded.patch b/patches/lvm/2.02.186/lvm2-006-asneeded.patch
index c831c6d..c831c6d 100644
--- a/patches/lvm/2.02.185/lvm2-006-asneeded.patch
+++ b/patches/lvm/2.02.186/lvm2-006-asneeded.patch
diff --git a/patches/lvm/2.02.185/lvm2-007-dynamic-static-ldflags.patch b/patches/lvm/2.02.186/lvm2-007-dynamic-static-ldflags.patch
index 0a0e732..0a0e732 100644
--- a/patches/lvm/2.02.185/lvm2-007-dynamic-static-ldflags.patch
+++ b/patches/lvm/2.02.186/lvm2-007-dynamic-static-ldflags.patch
diff --git a/patches/lvm/2.02.185/lvm2-008-static-pkgconfig-libs.patch b/patches/lvm/2.02.186/lvm2-008-static-pkgconfig-libs.patch
index 989b308..989b308 100644
--- a/patches/lvm/2.02.185/lvm2-008-static-pkgconfig-libs.patch
+++ b/patches/lvm/2.02.186/lvm2-008-static-pkgconfig-libs.patch
diff --git a/patches/lvm/2.02.185/lvm2-009-pthread-pkgconfig.patch b/patches/lvm/2.02.186/lvm2-009-pthread-pkgconfig.patch
index c0265e8..c0265e8 100644
--- a/patches/lvm/2.02.185/lvm2-009-pthread-pkgconfig.patch
+++ b/patches/lvm/2.02.186/lvm2-009-pthread-pkgconfig.patch
diff --git a/patches/lvm/2.02.185/lvm2-010-static-libm.patch b/patches/lvm/2.02.186/lvm2-010-static-libm.patch
index 1cbf956..1cbf956 100644
--- a/patches/lvm/2.02.185/lvm2-010-static-libm.patch
+++ b/patches/lvm/2.02.186/lvm2-010-static-libm.patch
diff --git a/patches/lvm/2.02.185/lvm2-011-HPPA-no-O_DIRECT.patch b/patches/lvm/2.02.186/lvm2-011-HPPA-no-O_DIRECT.patch
index 0f830e4..0f830e4 100644
--- a/patches/lvm/2.02.185/lvm2-011-HPPA-no-O_DIRECT.patch
+++ b/patches/lvm/2.02.186/lvm2-011-HPPA-no-O_DIRECT.patch
diff --git a/patches/lvm/2.02.185/lvm2-012-mallinfo.patch b/patches/lvm/2.02.186/lvm2-012-mallinfo.patch
index 2b64d4a..2b64d4a 100644
--- a/patches/lvm/2.02.185/lvm2-012-mallinfo.patch
+++ b/patches/lvm/2.02.186/lvm2-012-mallinfo.patch
diff --git a/patches/lvm/2.02.185/lvm2-013-fix-stdio-usage.patch b/patches/lvm/2.02.186/lvm2-013-fix-stdio-usage.patch
index b2c13d0..71b2e18 100644
--- a/patches/lvm/2.02.185/lvm2-013-fix-stdio-usage.patch
+++ b/patches/lvm/2.02.186/lvm2-013-fix-stdio-usage.patch
@@ -39,9 +39,9 @@
if (set_buffering) {
/* Allocate 2 buffers */
@@ -2241,7 +2241,7 @@
- if (cmd->libmem)
- dm_pool_destroy(cmd->libmem);
+ if (cmd->pending_delete_mem)
+ dm_pool_destroy(cmd->pending_delete_mem);
-#ifndef VALGRIND_POOL
+#if !defined(VALGRIND_POOL) && defined(__GLIBC__)
if (cmd->linebuffer) {
diff --git a/patches/lvm/2.02.185/lvm2-014-make-malloc-realloc-check-optional.patch b/patches/lvm/2.02.186/lvm2-014-make-malloc-realloc-check-optional.patch
index a5bd48a..a5bd48a 100644
--- a/patches/lvm/2.02.185/lvm2-014-make-malloc-realloc-check-optional.patch
+++ b/patches/lvm/2.02.186/lvm2-014-make-malloc-realloc-check-optional.patch
diff --git a/patches/lvm/2.02.185/lvm2-015-mksh_build.patch b/patches/lvm/2.02.186/lvm2-015-mksh_build.patch
index 49c6853..49c6853 100644
--- a/patches/lvm/2.02.185/lvm2-015-mksh_build.patch
+++ b/patches/lvm/2.02.186/lvm2-015-mksh_build.patch
diff --git a/patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.7.0-build-fixes.patch b/patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.7.0-build-fixes.patch
new file mode 100644
index 0000000..df0831f
--- /dev/null
+++ b/patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.7.0-build-fixes.patch
@@ -0,0 +1,34 @@
+--- thin-provisioning-tools-0.7.0/Makefile.in
++++ thin-provisioning-tools-0.7.0/Makefile.in
+@@ -142,9 +142,9 @@
+
+ TOP_DIR:=@top_srcdir@
+ TOP_BUILDDIR:=@top_builddir@
+-CFLAGS+=-g -Wall -O3 -fPIC
++CFLAGS+=-fPIC
+ CFLAGS+=@LFS_FLAGS@
+-CXXFLAGS+=-g -Wall -fPIC -fno-strict-aliasing -std=c++11
++CXXFLAGS+=-fPIC -fno-strict-aliasing -std=c++11
+
+ ifeq ("@DEVTOOLS@", "yes")
+ CXXFLAGS+=-DDEV_TOOLS
+--- thin-provisioning-tools-0.7.0/unit-tests/Makefile.in
++++ thin-provisioning-tools-0.7.0/unit-tests/Makefile.in
+@@ -25,7 +25,7 @@
+ -Wno-unused-local-typedefs
+
+ GMOCK_LIBS=\
+- -Llib -lpdata -lgmock -lpthread -laio
++ -Llib -lpdata -lgmock -lpthread -laio -lgtest
+
+ GMOCK_DEPS=\
+ $(wildcard $(GMOCK_DIR)/googlemock/include/*.h) \
+@@ -83,7 +83,7 @@
+ sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \
+ $(RM) $*.$$$$
+
+-unit-tests/unit_tests: $(TEST_OBJECTS) lib/libgmock.a lib/libpdata.a
++unit-tests/unit_tests: $(TEST_OBJECTS) lib/libpdata.a
+ @echo " [LD] $<"
+ $(V)g++ $(CXXFLAGS) $(LDFLAGS) -o $@ $(TEST_OBJECTS) $(LIBS) $(GMOCK_LIBS) $(LIBEXPAT)
+
diff --git a/patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.8.5-libaio-0.3.112.patch b/patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.8.5-libaio-0.3.112.patch
new file mode 100644
index 0000000..af31b90
--- /dev/null
+++ b/patches/thin-provisioning-tools/0.8.5/thin-provisioning-tools-0.8.5-libaio-0.3.112.patch
@@ -0,0 +1,84 @@
+From 6332962ee866f5289de87ab70cd3db863298982c Mon Sep 17 00:00:00 2001
+From: Joe Thornber <ejt@redhat.com>
+Date: Wed, 5 Jun 2019 15:02:05 +0100
+Subject: [PATCH] [ft-lib/bcache] rename raise() -> raise_()
+
+Name clash with signal.h on Debian and Gentoo.
+---
+ ft-lib/bcache.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/ft-lib/bcache.c b/ft-lib/bcache.c
+index 0dca5031..ee5b6c59 100644
+--- a/ft-lib/bcache.c
++++ b/ft-lib/bcache.c
+@@ -31,7 +31,7 @@ static void warn(const char *fmt, ...)
+ }
+
+ // FIXME: raise a condition somehow?
+-static void raise(const char *fmt, ...)
++static void raise_(const char *fmt, ...)
+ {
+ va_list ap;
+
+@@ -51,7 +51,7 @@ static inline struct list_head *list_pop(struct list_head *head)
+ struct list_head *l;
+
+ if (head->next == head)
+- raise("list is empty\n");
++ raise_("list is empty\n");
+
+ l = head->next;
+ list_del(l);
+@@ -98,7 +98,7 @@ static struct cb_set *cb_set_create(unsigned nr)
+ static void cb_set_destroy(struct cb_set *cbs)
+ {
+ if (!list_empty(&cbs->allocated))
+- raise("async io still in flight");
++ raise_("async io still in flight");
+
+ free(cbs->vec);
+ free(cbs);
+@@ -713,13 +713,13 @@ struct bcache *bcache_simple(const char *path, unsigned nr_cache_blocks)
+ uint64_t s;
+
+ if (fd < 0) {
+- raise("couldn't open cache file");
++ raise_("couldn't open cache file");
+ return NULL;
+ }
+
+ r = fstat(fd, &info);
+ if (r < 0) {
+- raise("couldn't stat cache file");
++ raise_("couldn't stat cache file");
+ return NULL;
+ }
+
+@@ -751,7 +751,7 @@ void bcache_destroy(struct bcache *cache)
+ static void check_index(struct bcache *cache, block_address index)
+ {
+ if (index >= cache->nr_data_blocks)
+- raise("block out of bounds (%llu >= %llu)",
++ raise_("block out of bounds (%llu >= %llu)",
+ (unsigned long long) index,
+ (unsigned long long) cache->nr_data_blocks);
+ }
+@@ -802,7 +802,7 @@ static struct block *lookup_or_read_block(struct bcache *cache,
+ // FIXME: this is insufficient. We need to also catch a read
+ // lock of a write locked block. Ref count needs to distinguish.
+ if (b->ref_count && (flags & (GF_DIRTY | GF_ZERO)))
+- raise("concurrent write lock attempt");
++ raise_("concurrent write lock attempt");
+
+ if (test_flags(b, BF_IO_PENDING)) {
+ miss(cache, flags);
+@@ -858,7 +858,7 @@ struct block *get_block(struct bcache *cache, block_address index, unsigned flag
+ return b;
+ }
+
+- raise("couldn't get block");
++ raise_("couldn't get block");
+ return NULL;
+ }
+
diff --git a/patches/xfsprogs/5.0.0/xfsprogs-4.15.0-sharedlibs.patch b/patches/xfsprogs/5.0.0/xfsprogs-4.15.0-sharedlibs.patch
deleted file mode 100644
index a8911ce..0000000
--- a/patches/xfsprogs/5.0.0/xfsprogs-4.15.0-sharedlibs.patch
+++ /dev/null
@@ -1,105 +0,0 @@
---- xfsprogs-4.15.0/include/buildmacros
-+++ xfsprogs-4.15.0/include/buildmacros
-@@ -70,18 +70,9 @@
- # /usr/lib.
- ifeq ($(ENABLE_SHARED),yes)
- INSTALL_LTLIB_DEV = \
-- cd $(TOPDIR)/$(LIBNAME)/.libs; \
-- ../$(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
-- ../$(INSTALL) -m 644 -T old_lib $(LIBNAME).lai $(PKG_LIB_DIR); \
-- ../$(INSTALL) -m 644 $(LIBNAME).lai $(PKG_LIB_DIR)/$(LIBNAME).la ; \
-- ../$(INSTALL) -m 755 -d $(PKG_ROOT_LIB_DIR); \
-- ../$(INSTALL) -T so_base $(LIBNAME).lai $(PKG_ROOT_LIB_DIR); \
-- if [ "x$(shell readlink -f $(PKG_LIB_DIR))" != \
-- "x$(shell readlink -f $(PKG_ROOT_LIB_DIR))" ]; then \
-- ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).a $(PKG_ROOT_LIB_DIR)/$(LIBNAME).a; \
-- ../$(INSTALL) -S $(PKG_LIB_DIR)/$(LIBNAME).la $(PKG_ROOT_LIB_DIR)/$(LIBNAME).la; \
-- ../$(INSTALL) -S $(PKG_ROOT_LIB_DIR)/$(LIBNAME).so $(PKG_LIB_DIR)/$(LIBNAME).so; \
-- fi
-+ set -e; cd $(TOPDIR)/$(LIBNAME); \
-+ $(INSTALL) -m 755 -d $(PKG_LIB_DIR); \
-+ env -uDIST_ROOT $(LTINSTALL) $(TOPDIR)/$(LIBNAME)/$(LIBNAME).la $(DIST_ROOT)$(PKG_LIB_DIR)/$(LIBNAME).la
- else
- INSTALL_LTLIB_DEV = $(INSTALL_LTLIB_STATIC)
- endif
---- xfsprogs-4.15.0/libfrog/Makefile
-+++ xfsprogs-4.15.0/libfrog/Makefile
-@@ -34,6 +36,9 @@
-
- include $(BUILDRULES)
-
--install install-dev: default
-+install: default
-+
-+install-dev: default
-+ $(INSTALL_LTLIB_DEV)
-
- -include .ltdep
---- xfsprogs-4.15.0/libhandle/Makefile
-+++ xfsprogs-4.15.0/libhandle/Makefile
-@@ -24,7 +24,6 @@
- include $(BUILDRULES)
-
- install: default
-- $(INSTALL_LTLIB)
-
- install-dev: default
- $(INSTALL_LTLIB_DEV)
---- xfsprogs-4.15.0/libxcmd/Makefile
-+++ xfsprogs-4.15.0/libxcmd/Makefile
-@@ -12,6 +12,8 @@
-
- CFILES = command.c input.c help.c quit.c
-
-+LTLIBS = $(LIBXFS) $(LIBBLKID)
-+
- ifeq ($(ENABLE_READLINE),yes)
- LCFLAGS += -DENABLE_READLINE
- LTLIBS += $(LIBREADLINE) $(LIBTERMCAP)
-@@ -26,6 +28,9 @@
-
- include $(BUILDRULES)
-
--install install-dev: default
-+install: default
-+
-+install-dev: default
-+ $(INSTALL_LTLIB_DEV)
-
- -include .ltdep
---- xfsprogs-4.15.0/libxfs/Makefile
-+++ xfsprogs-4.15.0/libxfs/Makefile
-@@ -151,6 +151,7 @@
-
- install-dev: install
- $(INSTALL) -m 644 $(PKGHFILES) $(PKG_INC_DIR)
-+ $(INSTALL_LTLIB_DEV)
-
- # We need to install the headers before building the dependencies. If we
- # include the .ltdep file, the makefile decides that it needs to build the
---- xfsprogs-4.15.0/libxlog/Makefile
-+++ xfsprogs-4.15.0/libxlog/Makefile
-@@ -19,6 +19,9 @@
-
- include $(BUILDRULES)
-
--install install-dev: default
-+install: default
-+
-+install-dev: default
-+ $(INSTALL_LTLIB_DEV)
-
- -include .ltdep
---- xfsprogs-4.15.0/Makefile
-+++ xfsprogs-4.15.0/Makefile
-@@ -92,6 +92,10 @@
- mkfs: libxcmd
- spaceman: libxcmd
- scrub: libhandle libxcmd
-+#libxfs: libfrog
-+#libfrog-install-dev: libxfs-install-dev
-+#libxlog: libxfs
-+#libxlog-install-dev: libxfs-install-dev
-
- ifeq ($(HAVE_BUILDDEFS), yes)
- include $(BUILDRULES)
diff --git a/patches/xfsprogs/5.0.0/xfsprogs-4.9.0-underlinking.patch b/patches/xfsprogs/5.2.1/xfsprogs-4.9.0-underlinking.patch
index 55d9efd..55d9efd 100644
--- a/patches/xfsprogs/5.0.0/xfsprogs-4.9.0-underlinking.patch
+++ b/patches/xfsprogs/5.2.1/xfsprogs-4.9.0-underlinking.patch
diff --git a/worker_modules/gkbuild.sh b/worker_modules/gkbuild.sh
index 20de263..cb2f385 100644
--- a/worker_modules/gkbuild.sh
+++ b/worker_modules/gkbuild.sh
@@ -81,19 +81,22 @@ _gkbuild_main() {
case "${current_phase}" in
src_compile)
print_info 2 "$(get_indent 2)${P}: >> Compiling source ..."
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_configure)
print_info 2 "$(get_indent 2)${P}: >> Configuring source ..."
- declare -ga CONFIGUREOPTS
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_install)
print_info 2 "$(get_indent 2)${P}: >> Install to DESTDIR ..."
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_prepare)
print_info 2 "$(get_indent 2)${P}: >> Preparing source ..."
+ cd "${S}" || die "Failed to chdir to '${S}'!"
;;
src_unpack)
@@ -178,8 +181,24 @@ _gkbuild_main() {
unset found_dyn_files
fi
- tar -caf "${GKPKG_BINPKG}" . \
- || die "Failed to create binpkg of ${P} in '${GKPKG_BINPKG}'!"
+ local -a tar_cmd=( "$(get_tar_cmd "${GKPKG_BINPKG}")" )
+ tar_cmd+=( '.' )
+
+ print_info 3 "COMMAND: ${tar_cmd[*]}" 1 0 1
+ eval "${tar_cmd[@]}" || die "Failed to create binpkg of ${P} in '${GKPKG_BINPKG}'!"
+
+ if [ -n "${DU_COMMAND}" ]
+ then
+ print_info 5 "Final size of build root: $(get_du "${BROOT}")"
+ print_info 5 "Final size of build directory: $(get_du "${S}")"
+ print_info 5 "Final size of installed tree: $(get_du "${D}")"
+ fi
+
+ cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!"
+ if [ ! -f "${TEMP}/.no_cleanup" ]
+ then
+ rm -rf "${WORKDIR}"
+ fi
}
_initialize() {
@@ -244,9 +263,6 @@ _initialize() {
die "Unable to build ${P}: '${GK_SHARE}/gkbuilds/${PN}.gkbuild' does NOT exist!"
fi
- source "${GKBUILD}" \
- || die "Failed to source '${GKBUILD}'!"
-
declare -gr WORKDIR=$(mktemp -d -p "${TEMP}" ${PN}.XXXXXXXX 2>/dev/null)
[ -z "${WORKDIR}" ] && die "mktemp failed!"
@@ -279,13 +295,15 @@ _initialize() {
S="${WORKDIR}/${GKPKG_SRCDIR}"
+ source "${GKBUILD}" \
+ || die "Failed to source '${GKBUILD}'!"
+
# Some tools like eltpatch (libtoolize) depend on these variables
export S D
if [[ -n "${GKPKG_DEPS}" ]]
then
- # GKPKG_DEPS is ${ARRAY[*]} value (single word), not ${ARRAY[@]} (separate word)!
- GKPKG_DEPS=( ${GKPKG_DEPS} )
+ IFS=';' read -r -a GKPKG_DEPS <<< "${GKPKG_DEPS}"
local GKPKG_DEP=
for GKPKG_DEP in "${GKPKG_DEPS[@]}"
do
@@ -295,13 +313,14 @@ _initialize() {
fi
print_info 2 "$(get_indent 2)${P}: >> Unpacking required binpkg '${GKPKG_DEP}' ..."
- tar -xaf "${GKPKG_DEP}" -C "${BROOT}" \
+ "${TAR_COMMAND}" -xaf "${GKPKG_DEP}" -C "${BROOT}" \
|| die "Unable to build ${P}: Failed to extract required binpkg '${GKPKG_DEP}' to '${BROOT}'!"
done
unset GKPKG_DEP
append-cflags -I"${BROOT}"/usr/include
append-cppflags -I"${BROOT}"/usr/include
+ append-cxxflags -I"${BROOT}"/usr/include
append-ldflags -L"${BROOT}"/usr/lib
fi
@@ -332,8 +351,6 @@ _initialize() {
}
_src_compile() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]
then
gkmake V=1
@@ -341,8 +358,6 @@ _src_compile() {
}
_src_configure() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
if [[ -x ${GKCONF_SOURCE:-.}/configure ]]
then
gkconf
@@ -350,8 +365,6 @@ _src_configure() {
}
_src_install() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]
then
gkmake V=1 DESTDIR="${D}" install
@@ -359,8 +372,6 @@ _src_install() {
}
_src_prepare() {
- cd "${S}" || die "Failed to chdir to '${S}'!"
-
# let's try to be smart and run autoreconf only when needed
local want_autoreconf=${WANT_AUTORECONF}
@@ -448,7 +459,7 @@ _src_prepare() {
_src_unpack() {
cd "${WORKDIR}" || die "Failed to chdir to '${WORKDIR}'!"
- tar -xaf "${GKPKG_SRCTAR}" \
+ "${TAR_COMMAND}" -xaf "${GKPKG_SRCTAR}" \
|| die "Failed to unpack '${GKPKG_SRCTAR}' to '${WORKDIR}'!"
}
@@ -623,7 +634,7 @@ gkconf() {
fi
if [[ ${conf_help} == *--with-sysroot* ]]; then
- conf_args+=( --with-sysroot="${BROOT}/usr:${SYSROOT}" )
+ conf_args+=( "--with-sysroot='${BROOT}/usr:${SYSROOT}'" )
fi
# Handle arguments containing quoted whitespace (see bug #457136).
@@ -664,7 +675,12 @@ gkconf() {
gklibtoolize() {
type -P eltpatch &>/dev/null || die "eltpatch not found; is app-portage/elt-patches installed?"
- gkexec "ELT_LOGDIR=\"${T}\" LD=\"$(tc-getLD)\" eltpatch ${*}"
+ local command=( "ELT_LOGDIR='${T}'" )
+ command+=( "LD='$(tc-getLD)'" )
+ command+=( "eltpatch" )
+ command+=( "${@}" )
+
+ gkexec "${command[*]}"
}
# @FUNCTION: gkmake
diff --git a/worker_modules/unpack.sh b/worker_modules/unpack.sh
index b0a03fc..2706bc5 100644
--- a/worker_modules/unpack.sh
+++ b/worker_modules/unpack.sh
@@ -21,6 +21,6 @@ _unpack_main() {
mkdir -p "${UNPACK_DIR}" || die "Failed to create '${UNPACK_DIR}'!"
fi
- tar -xaf "${UNPACK_FILE}" --directory "${UNPACK_DIR}" \
+ "${TAR_COMMAND}" -xaf "${UNPACK_FILE}" --directory "${UNPACK_DIR}" \
|| die "Failed to unpack '${UNPACK_FILE}' to '${UNPACK_DIR}'!"
}