releasetools: Fix an issue in common.GetSparseImage

Fix incorrect report "Failed to find the ZIP entry" error when
generate OTA package.

This happens when we have a file in ROOT which name contains 'system'
such as init.system_init.rc, and init.system_init.rc will be rename to
init.SYSTEM_init.rc incorrectly, so we failed to find the entry in ZIP.

Test: manual test
Change-Id: I97359e513aaca7521fe9c035f6a4264a2053b86d
Signed-off-by: wangshumin <wangshumin@xiaomi.com>
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index da189f3..054795b 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1934,12 +1934,13 @@
     # filename listed in system.map may contain an additional leading slash
     # (i.e. "//system/framework/am.jar"). Using lstrip to get consistent
     # results.
-    arcname = entry.replace(which, which.upper(), 1).lstrip('/')
-
-    # Special handling another case, where files not under /system
+    # And handle another special case, where files not under /system
     # (e.g. "/sbin/charger") are packed under ROOT/ in a target_files.zip.
-    if which == 'system' and not arcname.startswith('SYSTEM'):
+    arcname = entry.lstrip('/')
+    if which == 'system' and not arcname.startswith('system'):
       arcname = 'ROOT/' + arcname
+    else:
+      arcname = arcname.replace(which, which.upper(), 1)
 
     assert arcname in input_zip.namelist(), \
         "Failed to find the ZIP entry for {}".format(entry)