dev_install: Correctly fetch package.provided

package.provided lives under etc/portage/profile instead of root
directory. Also fix a bug for the return code of curl command.

BUG=chromium:271959
TEST=Run 'dev_install --yes --reinstall' on a Link device. Verify
the content is correct in:
/usr/local/etc/portage/make.profile/package.provided/gsutil_provided

Change-Id: I1ab7400d7ca116509c2ea42c791ae80fdd9fa015
Reviewed-on: https://chromium-review.googlesource.com/65826
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>
diff --git a/dev-install/dev_install b/dev-install/dev_install
index 1020124..01e7502 100755
--- a/dev-install/dev_install
+++ b/dev-install/dev_install
@@ -156,7 +156,21 @@
   # Check for package.provided from $BINHOST.
   local package_provided="${BINHOST}/package.provided"
   local tmp_provided="$(mktemp)"
-  if ! curl --fail -o "${tmp_provided}" "${package_provided}"; then
+
+  if ! curl --fail -o "${tmp_provided}" "${package_provided}" &&
+     [ -n "${CHROMEOS_DEVSERVER}" ]; then
+    echo "${package_provided} not found"
+
+    package_provided="${CHROMEOS_DEVSERVER}/"\
+"static/pkgroot/${CHROMEOS_RELEASE_BOARD}/"\
+"/etc/portage/profile/package.provided"
+    echo "Fall back to search ${package_provided}"
+
+    if ! curl --fail -o "${tmp_provided}" "${package_provided}"; then
+      echo "${package_provided} not found"
+    fi
+  fi
+  if [ -s ${tmp_provided} ]; then
     mv "${tmp_provided}" \
         "${P_CONFIG_DEVELOPER}/make.profile/package.provided/gsutil_provided"
   fi