generate_omaha_config.sh: correct DMG file name.

Include the version number in the DMG file name, and add a TODO
about how the DMG file name is obtained. The former because of
the change to build_dmg.sh, and the latter because the way it's
being done right now is terribly fragile.

Change the download URL to what will ultimately be used, excluding
ossible version number changes.

Add documentation comment for the generate_config function.

Remove deprecated NeedsAdmin flag from generated configuration data.

Change-Id: I89f16ca81ab49b34f932a03b516166ef91094b08
diff --git a/installer/scripts/build/generate_omaha_config.sh b/installer/scripts/build/generate_omaha_config.sh
index 98c4856..fb52886 100755
--- a/installer/scripts/build/generate_omaha_config.sh
+++ b/installer/scripts/build/generate_omaha_config.sh
@@ -24,14 +24,38 @@
 source scripts/build/util.sh
 file_exists "$(which openssl)" || die "openssl does not exist in PATH."
 
+# generate_config <|COMPONENT|> <|DMG_BASE|> <|CONFIG_NAME|>
+#
+# Generates Omaha server configuration for |COMPONENT|. |COMPONENT| must be
+# a bundle. |DMG_BASE| is the file name part of the DMG file in which
+# |COMPONENT| will be distributed. |CONFIG_NAME| is the friendly name for the
+# Omaha configuration.
+#
+# All parameters are required. |generate_config| will |die| when a param is
+# missing, empty, or invalid.
 generate_config() {
   local readonly COMPONENT="$1"
   file_exists "${COMPONENT}" || die "${COMPONENT} does not exist."
-  local readonly DMG_FILE="$2"
-  file_exists "${DMG_FILE}" || die "${DMG_FILE} does not exist."
+  local readonly DMG_BASE="$2"
+  [[ -n "${DMG_BASE}" ]] || die "empty DMG_BASE in ${FUNCNAME}."
   local readonly CONFIG_NAME="$3"
   [[ -n "${CONFIG_NAME}" ]] || die "empty CONFIG_NAME in ${FUNCNAME}."
 
+  # Read the application ID and version from |COMPONENT|.
+  local readonly READ_PLIST="scripts/build/read_bundle_plist.sh"
+  file_exists "${READ_PLIST}" || die "${READ_PLIST} does not exist."
+  local readonly BUNDLE_ID=$(${READ_PLIST} "${COMPONENT}" id)
+  [[ -n "${BUNDLE_ID}" ]] || die "empty BUNDLE_ID in ${FUNCNAME}."
+  local readonly VERSION=$(${READ_PLIST} "${COMPONENT}" v)
+  [[ -n "${VERSION}" ]] || die "empty VERSION in ${FUNCNAME}."
+
+  # TODO(tomfinegan): Integrate the DMG build and config generation, and pass
+  #                   the actual DMG file name around instead of this building
+  #                   it nonsense.
+  # Build |DMG_FILE| using |VERSION| and |DMG_BASE|.
+  local readonly DMG_FILE="${DMG_BASE}_${VERSION}.dmg"
+  file_exists "${DMG_FILE}" || die "${DMG_FILE} does not exist."
+
   # Get the size of |DMG_FILE|.
   local readonly DMG_SIZE="$(stat -f%z "${DMG_FILE}")"
   [[ -n "${DMG_SIZE}" ]] || die "empty DMG_SIZE in ${FUNCNAME}."
@@ -41,14 +65,6 @@
       | openssl base64)
   [[ -n "${OMAHA_HASH}" ]] || die "empty OMAHA_HASH in ${FUNCNAME}."
 
-  # Read the application ID and version from |COMPONENT|.
-  READ_PLIST="scripts/build/read_bundle_plist.sh"
-  file_exists "${READ_PLIST}" || die "${READ_PLIST} does not exist."
-  local readonly BUNDLE_ID=$(${READ_PLIST} "${COMPONENT}" id)
-  [[ -n "${BUNDLE_ID}" ]] || die "empty BUNDLE_ID in ${FUNCNAME}."
-  local readonly VERSION=$(${READ_PLIST} "${COMPONENT}" v)
-  [[ -n "${VERSION}" ]] || die "empty VERSION in ${FUNCNAME}."
-
   cat <<__END_CONFIG
 # Autogenerated Omaha config for ${CONFIG_NAME}
 AppId: "${BUNDLE_ID}"
@@ -58,10 +74,9 @@
   Test {Version: "[-${VERSION})"}
 
   Update {
-    Codebase: "http://dl.google.com/mac/download/${DMG_FILE}"
+    Codebase: "https://dl.google.com/dl/webmquicktime/${DMG_FILE}"
     Hash: "${OMAHA_HASH}"
     Size: "${DMG_SIZE}"
-    NeedsAdmin: "true"
   }
 }
 __END_CONFIG
@@ -74,6 +89,6 @@
 fi
 
 generate_config "../build/Release/AWebM.component" \
-    "webm_quicktime_installer.dmg" "WebM QuickTime Installer" \
+    "webm_quicktime_installer" "WebM QuickTime Installer" \
     > "${CONFIG_FILE}"
 debuglog "Done, wrote config to ${CONFIG_FILE}."