From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 83B8D1388B6 for ; Tue, 5 Jan 2016 19:39:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2EA6A21C03A; Tue, 5 Jan 2016 19:39:48 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B7E5F21C03A for ; Tue, 5 Jan 2016 19:39:47 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BF086340914 for ; Tue, 5 Jan 2016 19:39:46 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1ADE1CEB for ; Tue, 5 Jan 2016 19:39:42 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1452022436.7316481040d27ac85c5663b51c74d5547671166f.robbat2@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: /, defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts gen_initramfs.sh X-VCS-Directories: defaults/ / X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 7316481040d27ac85c5663b51c74d5547671166f X-VCS-Branch: master Date: Tue, 5 Jan 2016 19:39:42 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e6d24525-819e-4b1f-ad16-eec5ac69f5b0 X-Archives-Hash: cd57b41661f4c886478c8a384a5d4884 commit: 7316481040d27ac85c5663b51c74d5547671166f Author: Robin H. Johnson gentoo org> AuthorDate: Tue Jan 5 19:33:50 2016 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Tue Jan 5 19:33:56 2016 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=73164810 lvm: be more robust in build & init Commit ed52f905b6 was a good start, but missed that the cleanup nuked the moved file. Improve the unpacking as well as usage of the LVM binary to be much safer, and give useful errors if something is not as it should be. Signed-off-by: Robin H. Johnson gentoo.org> defaults/initrd.scripts | 17 ++++++++++------- gen_initramfs.sh | 13 ++++++++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 1bab361..94cb0cc 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -985,17 +985,22 @@ startVolumes() { if [ "${USE_LVM_NORMAL}" = '1' ] then - if [ -x '/sbin/lvm' ] + for lvm_path in /sbin/lvm /bin/lvm MISSING ; do + [ -x "$lvm_path" ] && break + fi + if [ "${lvm_path}" = "MISSING" ] then + 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 /sbin/lvm to accept the following logic - lvm_commands="#! /sbin/lvm" + # This is needed for LVM to accept the following logic + lvm_commands="#! ${lvm_path}" - # If there is a cahe, update it. Unbreak at least dmcrypt + # If there is a cache, update it. Unbreak at least dmcrypt [ -d /etc/lvm/cache ] && lvm_commands="${lvm_commands} \nvgscan" # To activate volumegroups on all devices in the cache @@ -1008,9 +1013,7 @@ startVolumes() { # 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}" | /sbin/lvm /proc/self/fd/0 - else - bad_msg "vgscan or vgchange not found: skipping LVM volume group activation!" + printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 fi fi diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 9c9dfec..7dce2cf 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -366,13 +366,24 @@ append_lvm(){ compile_lvm || gen_die "Could not compile LVM" /bin/tar -jxpf "${LVM_BINCACHE}" -C "${TEMP}/initramfs-lvm-temp" || gen_die "Could not extract lvm binary cache!"; + # Remove any dynamic binaries that exist, so the rest of the code will + # fail better if something is missing + for f in ${TEMP}/initramfs-lvm-temp/{bin,sbin}/* ; do + [ -x "$f" ] && LC_ALL="C" ldd $f | grep -sq '(' && rm -f "$f" + done + # Now move the static binaries into good places. mv ${TEMP}/initramfs-lvm-temp/sbin/lvm.static ${TEMP}/initramfs-lvm-temp/sbin/lvm || gen_die 'LVM error: Could not move lvm.static to lvm!' # See bug 382555 mv ${TEMP}/initramfs-lvm-temp/sbin/dmsetup.static ${TEMP}/initramfs-lvm-temp/bin/dmsetup || gen_die 'LVM error: Could not move dmsetup.static to dmsetup!' - rm -rf ${TEMP}/initramfs-lvm-temp/{lib,share,man,include,sbin/{lvm,dmsetup}} + # Clean up other stuff we don't need + rm -rf ${TEMP}/initramfs-lvm-temp/{lib*,share,man,include,sbin/dmeventd.static} fi + # Include a symlink in the old location, for people with other appended + # scripts that might look for it in the old location. + ln -s ../sbin/lvm "${TEMP}/initramfs-lvm-temp/bin/lvm" + # Include the LVM config now if [ -x /sbin/lvm -o -x /bin/lvm ] then # lvm dumpconfig 2>&1 > /dev/null || gen_die 'Could not copy over lvm.conf!'