cros_mirror: support simple hostname command

If `hostname -f` fails, fallback to plain `hostname`.

BUG=chromium:322261
TEST=CQ passes

Change-Id: I9a3d8a5488181170516098138fde4cfae091edda
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2666926
Tested-by: Mike Frysinger <vapier@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
Commit-Queue: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/scripts/cros_mirror b/scripts/cros_mirror
index 9231781..15b143a 100755
--- a/scripts/cros_mirror
+++ b/scripts/cros_mirror
@@ -66,7 +66,7 @@
 
 Example:
 # Create a full mirror in \${PWD} and have users fetch from the local machine.
-\$ ${ARGV0} -r . -u git://$(hostname -f)
+\$ ${ARGV0} -r . -u git://${HOSTNAME}
 # Update the mirror (put this into a cronjob).
 \$ ${ARGV0} -q -r ${ROOT:-${PWD}}
 
@@ -76,6 +76,7 @@
   exit ${1:-0}
 }
 
+HOSTNAME=$(hostname -f 2>/dev/null || hostname)
 JOBS=$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)
 MANIFEST_URL=
 MANIFEST_NAME=default.xml
@@ -206,7 +207,7 @@
     URL=$(eval $(grep -h fetch= *.xml); echo ${fetch})
     if [[ ${URL} == "https://chromium.googlesource.com" ]]; then
       # Guess they want the current system.
-      URL="git://$(hostname -f)"
+      URL="git://${HOSTNAME}"
     fi
   fi