[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master cbb0642 4/5: Fix 'set -e' issues
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master cbb0642 4/5: Fix 'set -e' issues |
Date: |
Fri, 5 Jun 2020 12:03:21 -0400 (EDT) |
branch: master
commit cbb0642b412253afd42f8eb88ccc37b9ec193ae2
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Fix 'set -e' issues
Explicitly allowed several commands to fail. Tested with redhat-7.7,
though not with debian-testing's new gcc-10.0.0 .
When 'yum' finds nothing to do, this command:
yum --assumeyes install <package-name>
succeeds, incidentally reporting:
Nothing to do
but this command:
yum --assumeyes install <URL-for-rpm>
fails, reporting:
Error: Nothing to do
Therefore, appended "|| true" only in the latter case.
---
lmi_setup_02.sh | 10 +++++-----
lmi_setup_07r.sh | 2 +-
lmi_setup_11.sh | 5 +++--
lmi_setup_43.sh | 2 +-
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/lmi_setup_02.sh b/lmi_setup_02.sh
index f88d281..5594227 100755
--- a/lmi_setup_02.sh
+++ b/lmi_setup_02.sh
@@ -69,10 +69,10 @@ assert_not_chrooted
# | column -t
# along with '-r' because '-l' does a poor job of columnization.
-umount /srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
-umount /srv/chroot/"${CHRTNAME}"/srv/cache_for_lmi
-umount /srv/chroot/"${CHRTNAME}"/dev/pts
-umount /srv/chroot/"${CHRTNAME}"/proc
+umount /srv/chroot/"${CHRTNAME}"/var/cache/apt/archives || true
+umount /srv/chroot/"${CHRTNAME}"/srv/cache_for_lmi || true
+umount /srv/chroot/"${CHRTNAME}"/dev/pts || true
+umount /srv/chroot/"${CHRTNAME}"/proc || true
findmnt -ro SOURCE,TARGET \
| grep "${CHRTNAME}" \
@@ -91,7 +91,7 @@ rm --one-file-system --recursive --force \
# schroot allows configuration files in /etc/schroot/chroot.d/ only.
-rm /etc/schroot/chroot.d/"${CHRTNAME}".conf
+rm --force /etc/schroot/chroot.d/"${CHRTNAME}".conf
# These commands fail harmlessly if the chroot doesn't already exist.
diff --git a/lmi_setup_07r.sh b/lmi_setup_07r.sh
index 58059b1..7fabcf4 100755
--- a/lmi_setup_07r.sh
+++ b/lmi_setup_07r.sh
@@ -53,7 +53,7 @@ yum --assumeyes install ca-certificates curl nss-pem wget
#rpm -ivh
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Instead, use 'yum' to install "EPEL". Both of the following lines
# are required to install 'debootstrap' and 'schroot' later on RHEL:
-yum --assumeyes install
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
+yum --assumeyes install
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm || true
yum --assumeyes install epel-release
stamp=$(date -u +'%Y%m%dT%H%M%SZ')
diff --git a/lmi_setup_11.sh b/lmi_setup_11.sh
index 96d44b9..a9d2c6a 100755
--- a/lmi_setup_11.sh
+++ b/lmi_setup_11.sh
@@ -74,9 +74,10 @@ du -sb /srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
# - while not chrooted, so that the host filesystem is accessible.
mount --bind "${CACHEDIR}" /srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
-# Should the next two commands both find the mount just established?
-findmnt "${CACHEDIR}"
+# Show the mount just established:
findmnt /srv/chroot/"${CHRTNAME}"/var/cache/apt/archives
+# Show any underlying mount (e.g., for an intermediate chroot):
+findmnt "${CACHEDIR}" || true
# Are the next two commands useful?
findmnt /proc
diff --git a/lmi_setup_43.sh b/lmi_setup_43.sh
index d927284..db749b5 100755
--- a/lmi_setup_43.sh
+++ b/lmi_setup_43.sh
@@ -110,7 +110,7 @@ cd /opt/lmi/src/lmi || { printf 'failed: cd\n'; exit 3; }
make "$coefficiency" system_test 2>&1 |sed -e'/^Cannot open.*test/d'
# That test fails the first time because no results are saved in
# touchstone/ yet. Remove timestamped summaries...
-rm /opt/lmi/test/analysis-* /opt/lmi/test/diffs-* /opt/lmi/test/md5sums-*
+rm --force /opt/lmi/test/analysis-* /opt/lmi/test/diffs-*
/opt/lmi/test/md5sums-*
# ...copy the results just generated...
cp -a /opt/lmi/test/* /opt/lmi/touchstone
# ...and rerun the test, which should now succeed: