commit: 34a9e674dc70e6a00c7a89e2660a6cf236c89e4f
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jun 16 04:48:40 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 17 03:00:38 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=34a9e674
emerge-webrsync: address a slew of shellcheck warnings
As concerns the fetch_file() function, suppress an instance of SC2034.
It is a false positive because the subsequent use of the 'URI' variable
is concealed by the use of the eval builtin.
As concerns the sync_local() function, address five instances of SC2086
by quoting the expansions of various variables, and by declaring and
using the 'chown_opts' and 'rsync_opts' variables as arrays.
A concerns the do_snapshot() function, address an instance of SC2004 by
refraining from performing an unnecessary parameter expansion upon the
'utc_seconds' variable in the arithmetic context.
A concerns the do_latest_snapshot() function, address an instance of
SC2004 by refraining from performing an unnecessary parameter expansion
upon the 'attempts' variable in the arithmetic context.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/emerge-webrsync | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 3d83265970..93e0e5a87d 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -199,6 +199,7 @@ get_repository_timestamp() {
}
fetch_file() {
+ # shellcheck disable=2034
local URI=$1 FILE=$2
local opts
@@ -368,7 +369,8 @@ get_snapshot_timestamp() {
sync_local() {
local file=$1
- local chown_opts rsync_opts ownership post_sync
+ local ownership post_sync
+ local -a chown_opts rsync_opts
[[ ${PORTAGE_QUIET} -eq 1 ]] || einfo "Syncing local repository ..."
@@ -385,12 +387,14 @@ sync_local() {
fi
if type -P tarsync > /dev/null ; then
- chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
- chown ${ownership} "${repo_location}" > /dev/null 2>&1 ||
chown_opts=""
-
- if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \
- -e /distfiles -e /packages -e /local "${file}"
"${repo_location}"; then
+ chown_opts=( -o "${ownership%:*}" -g "${ownership#*:}" )
+ if ! chown "${ownership}" "${repo_location}" 2>/dev/null; then
+ chown_opts=()
+ fi
+ if ! tarsync $(vvecho -v) -s 1 "${chown_opts[@]}" \
+ -e /distfiles -e /packages -e /local "${file}"
"${repo_location}"
+ then
eerror "tarsync failed; tarball is corrupt? (${file})"
return 1
fi
@@ -403,14 +407,14 @@ sync_local() {
# Free disk space
${keep} || rm -f "${file}"
- rsync_opts="${PORTAGE_RSYNC_OPTS} ${PORTAGE_RSYNC_EXTRA_OPTS}
$(nvecho -q)"
- if chown ${ownership} . > /dev/null 2>&1; then
- chown -R ${ownership} .
- rsync_opts+=" --owner --group"
+ read -rd '' -a rsync_opts <<<"${PORTAGE_RSYNC_OPTS}
${PORTAGE_RSYNC_EXTRA_OPTS} $(nvecho -q)"
+ if chown "${ownership}" . 2>/dev/null; then
+ chown -R "${ownership}" .
+ rsync_opts+=( --owner --group )
fi
chmod 755 .
- rsync ${rsync_opts} . "${repo_location%%/}" || {
+ rsync "${rsync_opts[@]}" . "${repo_location%%/}" || {
eerror "rsync failed: $?"
die "Aborting because of rsync failure"
}
@@ -494,7 +498,7 @@ do_snapshot() {
# Check that this snapshot is what the
age it claims to be
if [[ ${snapshot_timestamp} -lt
${utc_seconds} || \
- ${snapshot_timestamp} -gt
$((${utc_seconds}+ 2*86400)) ]]; then
+ ${snapshot_timestamp} -gt $((
utc_seconds + 2 * 86400 )) ]]; then
ewarn "Snapshot timestamp is
not within acceptable period!"
have_files=0
@@ -549,8 +553,7 @@ do_latest_snapshot() {
snapshot_date=$(get_date_part "${start_time}" "%Y%m%d")
snapshot_date_seconds=$(get_utc_second_from_string "${snapshot_date}")
- while (( ${attempts} < 40 )) ; do
- (( attempts++ ))
+ while (( attempts++ < 40 )); do
(( snapshot_date_seconds -= 86400 ))
# snapshots are created at 00:45
(( approx_snapshot_time = snapshot_date_seconds + 86400 + 2700
))